1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
13 #include <sys/queue.h>
15 #include <rte_common.h>
16 #include <rte_byteorder.h>
18 #include <rte_debug.h>
19 #include <rte_cycles.h>
20 #include <rte_memory.h>
21 #include <rte_memzone.h>
22 #include <rte_malloc.h>
23 #include <rte_launch.h>
25 #include <rte_per_lcore.h>
26 #include <rte_lcore.h>
27 #include <rte_branch_prediction.h>
29 #include <rte_mempool.h>
30 #include <rte_interrupts.h>
32 #include <rte_ether.h>
33 #include <rte_ethdev.h>
34 #include <rte_string_fns.h>
35 #include <rte_devargs.h>
40 #include <rte_mbuf_dyn.h>
42 #include <cmdline_rdline.h>
43 #include <cmdline_parse.h>
44 #include <cmdline_parse_num.h>
45 #include <cmdline_parse_string.h>
46 #include <cmdline_parse_ipaddr.h>
47 #include <cmdline_parse_etheraddr.h>
48 #include <cmdline_socket.h>
51 #include <rte_eth_bond.h>
52 #include <rte_eth_bond_8023ad.h>
54 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
55 #include <rte_pmd_dpaa.h>
58 #include <rte_pmd_ixgbe.h>
61 #include <rte_pmd_i40e.h>
64 #include <rte_pmd_bnxt.h>
67 #include "cmdline_mtr.h"
68 #include "cmdline_tm.h"
71 static struct cmdline *testpmd_cl;
72 static cmdline_parse_ctx_t *main_ctx;
73 static TAILQ_HEAD(, testpmd_driver_commands) driver_commands_head =
74 TAILQ_HEAD_INITIALIZER(driver_commands_head);
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 commands.\n"
100 " help drivers : Driver specific commands.\n"
101 " help all : All of the above sections.\n\n"
106 static cmdline_parse_token_string_t cmd_help_brief_help =
107 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
109 static cmdline_parse_inst_t cmd_help_brief = {
110 .f = cmd_help_brief_parsed,
112 .help_str = "help: Show help",
114 (void *)&cmd_help_brief_help,
119 /* *** Help command with help sections. *** */
120 struct cmd_help_long_result {
121 cmdline_fixed_string_t help;
122 cmdline_fixed_string_t section;
125 static void cmd_help_long_parsed(void *parsed_result,
127 __rte_unused void *data)
130 struct cmd_help_long_result *res = parsed_result;
132 if (!strcmp(res->section, "all"))
135 if (show_all || !strcmp(res->section, "control")) {
140 "Control forwarding:\n"
141 "-------------------\n\n"
144 " Start packet forwarding with current configuration.\n\n"
147 " Start packet forwarding with current config"
148 " after sending one burst of packets.\n\n"
151 " Stop packet forwarding, and display accumulated"
155 " Quit to prompt.\n\n"
159 if (show_all || !strcmp(res->section, "display")) {
167 "show port (info|stats|summary|xstats|fdir|dcb_tc) (port_id|all)\n"
168 " Display information for port_id, or all.\n\n"
170 "show port info (port_id) representor\n"
171 " Show supported representors for a specific port\n\n"
173 "show port port_id (module_eeprom|eeprom)\n"
174 " Display the module EEPROM or EEPROM information for port_id.\n\n"
176 "show port X rss reta (size) (mask0,mask1,...)\n"
177 " Display the rss redirection table entry indicated"
178 " by masks on port X. size is used to indicate the"
179 " hardware supported reta size\n\n"
181 "show port (port_id) rss-hash [key]\n"
182 " Display the RSS hash functions and RSS hash key of port\n\n"
184 "clear port (info|stats|xstats|fdir) (port_id|all)\n"
185 " Clear information for port_id, or all.\n\n"
187 "show (rxq|txq) info (port_id) (queue_id)\n"
188 " Display information for configured RX/TX queue.\n\n"
190 "show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n"
191 " Display the given configuration.\n\n"
193 "read rxd (port_id) (queue_id) (rxd_id)\n"
194 " Display an RX descriptor of a port RX queue.\n\n"
196 "read txd (port_id) (queue_id) (txd_id)\n"
197 " Display a TX descriptor of a port TX queue.\n\n"
199 "ddp get list (port_id)\n"
200 " Get ddp profile info list\n\n"
202 "ddp get info (profile_path)\n"
203 " Get ddp profile information.\n\n"
205 "show vf stats (port_id) (vf_id)\n"
206 " Display a VF's statistics.\n\n"
208 "clear vf stats (port_id) (vf_id)\n"
209 " Reset a VF's statistics.\n\n"
211 "show port (port_id) pctype mapping\n"
212 " Get flow ptype to pctype mapping on a port\n\n"
214 "show port meter stats (port_id) (meter_id) (clear)\n"
215 " Get meter stats on a port\n\n"
217 "show fwd stats all\n"
218 " Display statistics for all fwd engines.\n\n"
220 "clear fwd stats all\n"
221 " Clear statistics for all fwd engines.\n\n"
223 "show port (port_id) rx_offload capabilities\n"
224 " List all per queue and per port Rx offloading"
225 " capabilities of a port\n\n"
227 "show port (port_id) rx_offload configuration\n"
228 " List port level and all queue level"
229 " Rx offloading configuration\n\n"
231 "show port (port_id) tx_offload capabilities\n"
232 " List all per queue and per port"
233 " Tx offloading capabilities of a port\n\n"
235 "show port (port_id) tx_offload configuration\n"
236 " List port level and all queue level"
237 " Tx offloading configuration\n\n"
239 "show port (port_id) tx_metadata\n"
240 " Show Tx metadata value set"
241 " for a specific port\n\n"
243 "show port (port_id) ptypes\n"
244 " Show port supported ptypes"
245 " for a specific port\n\n"
247 "show device info (<identifier>|all)"
248 " Show general information about devices probed.\n\n"
250 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
251 " Show status of rx|tx descriptor.\n\n"
253 "show port (port_id) rxq (queue_id) desc used count\n"
254 " Show current number of filled receive"
255 " packet descriptors.\n\n"
257 "show port (port_id) macs|mcast_macs"
258 " Display list of mac addresses added to port.\n\n"
260 "show port (port_id) flow transfer proxy\n"
261 " Display proxy port to manage transfer flows\n\n"
263 "show port (port_id) fec capabilities"
264 " Show fec capabilities of a port.\n\n"
266 "show port (port_id) fec_mode"
267 " Show fec mode of a port.\n\n"
269 "show port (port_id) flow_ctrl"
270 " Show flow control info of a port.\n\n"
274 if (show_all || !strcmp(res->section, "config")) {
280 "Configuration changes only become active when"
281 " forwarding is started/restarted.\n\n"
284 " Reset forwarding to the default configuration.\n\n"
286 "set verbose (level)\n"
287 " Set the debug verbosity level X.\n\n"
289 "set log global|(type) (level)\n"
290 " Set the log level.\n\n"
293 " Set number of ports.\n\n"
296 " Set number of cores.\n\n"
298 "set coremask (mask)\n"
299 " Set the forwarding cores hexadecimal mask.\n\n"
301 "set portmask (mask)\n"
302 " Set the forwarding ports hexadecimal mask.\n\n"
305 " Set number of packets per burst.\n\n"
307 "set burst tx delay (microseconds) retry (num)\n"
308 " Set the transmit delay time and number of retries,"
309 " effective when retry is enabled.\n\n"
311 "set rxoffs (x[,y]*)\n"
312 " Set the offset of each packet segment on"
313 " receiving if split feature is engaged."
314 " Affects only the queues configured with split"
317 "set rxpkts (x[,y]*)\n"
318 " Set the length of each segment to scatter"
319 " packets on receiving if split feature is engaged."
320 " Affects only the queues configured with split"
323 "set txpkts (x[,y]*)\n"
324 " Set the length of each segment of TXONLY"
325 " and optionally CSUM packets.\n\n"
327 "set txsplit (off|on|rand)\n"
328 " Set the split policy for the TX packets."
329 " Right now only applicable for CSUM and TXONLY"
332 "set txtimes (x, y)\n"
333 " Set the scheduling on timestamps"
334 " timings for the TXONLY mode\n\n"
336 "set corelist (x[,y]*)\n"
337 " Set the list of forwarding cores.\n\n"
339 "set portlist (x[,y]*)\n"
340 " Set the list of forwarding ports.\n\n"
342 "set port setup on (iterator|event)\n"
343 " Select how attached port is retrieved for setup.\n\n"
345 "set tx loopback (port_id) (on|off)\n"
346 " Enable or disable tx loopback.\n\n"
348 "set all queues drop (port_id) (on|off)\n"
349 " Set drop enable bit for all queues.\n\n"
351 "set vf split drop (port_id) (vf_id) (on|off)\n"
352 " Set split drop enable bit for a VF from the PF.\n\n"
354 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
355 " Set MAC antispoof for a VF from the PF.\n\n"
357 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
358 " Enable MACsec offload.\n\n"
360 "set macsec offload (port_id) off\n"
361 " Disable MACsec offload.\n\n"
363 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
364 " Configure MACsec secure connection (SC).\n\n"
366 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
367 " Configure MACsec secure association (SA).\n\n"
369 "set vf broadcast (port_id) (vf_id) (on|off)\n"
370 " Set VF broadcast for a VF from the PF.\n\n"
372 "vlan set stripq (on|off) (port_id,queue_id)\n"
373 " Set the VLAN strip for a queue on a port.\n\n"
375 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
376 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
378 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
379 " Set VLAN insert for a VF from the PF.\n\n"
381 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
382 " Set VLAN antispoof for a VF from the PF.\n\n"
384 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
385 " Set VLAN tag for a VF from the PF.\n\n"
387 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
388 " Set a VF's max bandwidth(Mbps).\n\n"
390 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
391 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
393 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
394 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
396 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
397 " Set some TCs' strict link priority mode on a physical port.\n\n"
399 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
400 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
402 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
403 " Set the VLAN strip or filter or qinq strip or extend\n\n"
405 "vlan set (inner|outer) tpid (value) (port_id)\n"
406 " Set the VLAN TPID for Packet Filtering on"
409 "rx_vlan add (vlan_id|all) (port_id)\n"
410 " Add a vlan_id, or all identifiers, to the set"
411 " of VLAN identifiers filtered by port_id.\n\n"
413 "rx_vlan rm (vlan_id|all) (port_id)\n"
414 " Remove a vlan_id, or all identifiers, from the set"
415 " of VLAN identifiers filtered by port_id.\n\n"
417 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
418 " Add a vlan_id, to the set of VLAN identifiers"
419 "filtered for VF(s) from port_id.\n\n"
421 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
422 " Remove a vlan_id, to the set of VLAN identifiers"
423 "filtered for VF(s) from port_id.\n\n"
425 "rx_vxlan_port add (udp_port) (port_id)\n"
426 " Add an UDP port for VXLAN packet filter on a port\n\n"
428 "rx_vxlan_port rm (udp_port) (port_id)\n"
429 " Remove an UDP port for VXLAN packet filter on a port\n\n"
431 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
432 " Set hardware insertion of VLAN IDs (single or double VLAN "
433 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
435 "tx_vlan set pvid port_id vlan_id (on|off)\n"
436 " Set port based TX VLAN insertion.\n\n"
438 "tx_vlan reset (port_id)\n"
439 " Disable hardware insertion of a VLAN header in"
440 " packets sent on a port.\n\n"
442 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
443 " Select hardware or software calculation of the"
444 " checksum when transmitting a packet using the"
445 " csum forward engine.\n"
446 " ip|udp|tcp|sctp always concern the inner layer.\n"
447 " outer-ip concerns the outer IP layer in"
448 " outer-udp concerns the outer UDP layer in"
449 " case the packet is recognized as a tunnel packet by"
450 " the forward engine (vxlan, gre and ipip are supported)\n"
451 " Please check the NIC datasheet for HW limits.\n\n"
453 "csum parse-tunnel (on|off) (tx_port_id)\n"
454 " If disabled, treat tunnel packets as non-tunneled"
455 " packets (treat inner headers as payload). The port\n"
456 " argument is the port used for TX in csum forward"
459 "csum show (port_id)\n"
460 " Display tx checksum offload configuration\n\n"
462 "tso set (segsize) (portid)\n"
463 " Enable TCP Segmentation Offload in csum forward"
465 " Please check the NIC datasheet for HW limits.\n\n"
468 " Display the status of TCP Segmentation Offload.\n\n"
471 "set port (port_id) gro on|off\n"
472 " Enable or disable Generic Receive Offload in"
473 " csum forwarding engine.\n\n"
475 "show port (port_id) gro\n"
476 " Display GRO configuration.\n\n"
478 "set gro flush (cycles)\n"
479 " Set the cycle to flush GROed packets from"
480 " reassembly tables.\n\n"
484 "set port (port_id) gso (on|off)"
485 " Enable or disable Generic Segmentation Offload in"
486 " csum forwarding engine.\n\n"
488 "set gso segsz (length)\n"
489 " Set max packet length for output GSO segments,"
490 " including packet header and payload.\n\n"
492 "show port (port_id) gso\n"
493 " Show GSO configuration.\n\n"
497 " Set packet forwarding mode.\n\n"
499 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
500 " Add a MAC address on port_id.\n\n"
502 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
503 " Remove a MAC address from port_id.\n\n"
505 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
506 " Set the default MAC address for port_id.\n\n"
508 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
509 " Add a MAC address for a VF on the port.\n\n"
511 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
512 " Set the MAC address for a VF from the PF.\n\n"
514 "set eth-peer (port_id) (peer_addr)\n"
515 " set the peer address for certain port.\n\n"
517 "set port (port_id) uta (mac_address|all) (on|off)\n"
518 " Add/Remove a or all unicast hash filter(s)"
521 "set promisc (port_id|all) (on|off)\n"
522 " Set the promiscuous mode on port_id, or all.\n\n"
524 "set allmulti (port_id|all) (on|off)\n"
525 " Set the allmulti mode on port_id, or all.\n\n"
527 "set vf promisc (port_id) (vf_id) (on|off)\n"
528 " Set unicast promiscuous mode for a VF from the PF.\n\n"
530 "set vf allmulti (port_id) (vf_id) (on|off)\n"
531 " Set multicast promiscuous mode for a VF from the PF.\n\n"
533 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
534 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
535 " (on|off) autoneg (on|off) (port_id)\n"
536 "set flow_ctrl rx (on|off) (portid)\n"
537 "set flow_ctrl tx (on|off) (portid)\n"
538 "set flow_ctrl high_water (high_water) (portid)\n"
539 "set flow_ctrl low_water (low_water) (portid)\n"
540 "set flow_ctrl pause_time (pause_time) (portid)\n"
541 "set flow_ctrl send_xon (send_xon) (portid)\n"
542 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
543 "set flow_ctrl autoneg (on|off) (port_id)\n"
544 " Set the link flow control parameter on a port.\n\n"
546 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
547 " (low_water) (pause_time) (priority) (port_id)\n"
548 " Set the priority flow control parameter on a"
551 "set pfc_queue_ctrl (port_id) rx (on|off) (tx_qid)"
552 " (tx_tc) tx (on|off) (rx_qid) (rx_tc) (pause_time)\n"
553 " Set the queue priority flow control parameter on a"
554 " given Rx and Tx queues of a port.\n\n"
556 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
557 " Set statistics mapping (qmapping 0..15) for RX/TX"
559 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
560 " on port 0 to mapping 5.\n\n"
562 "set xstats-hide-zero on|off\n"
563 " Set the option to hide the zero values"
564 " for xstats display.\n"
566 "set record-core-cycles on|off\n"
567 " Set the option to enable measurement of CPU cycles.\n"
569 "set record-burst-stats on|off\n"
570 " Set the option to enable display of RX and TX bursts.\n"
572 "set port (port_id) vf (vf_id) rx|tx on|off\n"
573 " Enable/Disable a VF receive/transmit from a port\n\n"
575 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
577 " AUPE:accepts untagged VLAN;"
578 "ROPE:accept unicast hash\n\n"
579 " BAM:accepts broadcast packets;"
580 "MPE:accepts all multicast packets\n\n"
581 " Enable/Disable a VF receive mode of a port\n\n"
583 "set port (port_id) queue (queue_id) rate (rate_num)\n"
584 " Set rate limit for a queue of a port\n\n"
586 "set port (port_id) vf (vf_id) rate (rate_num) "
587 "queue_mask (queue_mask_value)\n"
588 " Set rate limit for queues in VF of a port\n\n"
590 "set flush_rx (on|off)\n"
591 " Flush (default) or don't flush RX streams before"
592 " forwarding. Mainly used with PCAP drivers.\n\n"
594 "set bypass mode (normal|bypass|isolate) (port_id)\n"
595 " Set the bypass mode for the lowest port on bypass enabled"
598 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
599 "mode (normal|bypass|isolate) (port_id)\n"
600 " Set the event required to initiate specified bypass mode for"
601 " the lowest port on a bypass enabled NIC where:\n"
602 " timeout = enable bypass after watchdog timeout.\n"
603 " os_on = enable bypass when OS/board is powered on.\n"
604 " os_off = enable bypass when OS/board is powered off.\n"
605 " power_on = enable bypass when power supply is turned on.\n"
606 " power_off = enable bypass when power supply is turned off."
609 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
610 " Set the bypass watchdog timeout to 'n' seconds"
611 " where 0 = instant.\n\n"
613 "show bypass config (port_id)\n"
614 " Show the bypass configuration for a bypass enabled NIC"
615 " using the lowest port on the NIC.\n\n"
618 "create bonded device (mode) (socket)\n"
619 " Create a new bonded device with specific bonding mode and socket.\n\n"
621 "add bonding slave (slave_id) (port_id)\n"
622 " Add a slave device to a bonded device.\n\n"
624 "remove bonding slave (slave_id) (port_id)\n"
625 " Remove a slave device from a bonded device.\n\n"
627 "set bonding mode (value) (port_id)\n"
628 " Set the bonding mode on a bonded device.\n\n"
630 "set bonding primary (slave_id) (port_id)\n"
631 " Set the primary slave for a bonded device.\n\n"
633 "show bonding config (port_id)\n"
634 " Show the bonding config for port_id.\n\n"
636 "show bonding lacp info (port_id)\n"
637 " Show the bonding lacp information for port_id.\n\n"
639 "set bonding mac_addr (port_id) (address)\n"
640 " Set the MAC address of a bonded device.\n\n"
642 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
643 " Set Aggregation mode for IEEE802.3AD (mode 4)"
645 "set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
646 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
648 "set bonding mon_period (port_id) (value)\n"
649 " Set the bonding link status monitoring polling period in ms.\n\n"
651 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
652 " Enable/disable dedicated queues for LACP control traffic.\n\n"
655 "set link-up port (port_id)\n"
656 " Set link up for a port.\n\n"
658 "set link-down port (port_id)\n"
659 " Set link down for a port.\n\n"
661 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
662 " Load a profile package on a port\n\n"
664 "ddp del (port_id) (backup_profile_path)\n"
665 " Delete a profile package from a port\n\n"
667 "ptype mapping get (port_id) (valid_only)\n"
668 " Get ptype mapping on a port\n\n"
670 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
671 " Replace target with the pkt_type in ptype mapping\n\n"
673 "ptype mapping reset (port_id)\n"
674 " Reset ptype mapping on a port\n\n"
676 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
677 " Update a ptype mapping item on a port\n\n"
679 "set port (port_id) ptype_mask (ptype_mask)\n"
680 " set packet types classification for a specific port\n\n"
682 "set port (port_id) queue-region region_id (value) "
683 "queue_start_index (value) queue_num (value)\n"
684 " Set a queue region on a port\n\n"
686 "set port (port_id) queue-region region_id (value) "
688 " Set a flowtype region index on a port\n\n"
690 "set port (port_id) queue-region UP (value) region_id (value)\n"
691 " Set the mapping of User Priority to "
692 "queue region on a port\n\n"
694 "set port (port_id) queue-region flush (on|off)\n"
695 " flush all queue region related configuration\n\n"
697 "show port meter cap (port_id)\n"
698 " Show port meter capability information\n\n"
700 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
701 " meter profile add - srtcm rfc 2697\n\n"
703 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
704 " meter profile add - trtcm rfc 2698\n\n"
706 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
707 " meter profile add - trtcm rfc 4115\n\n"
709 "del port meter profile (port_id) (profile_id)\n"
710 " meter profile delete\n\n"
712 "create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
713 "(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
714 "(dscp_tbl_entry63)]\n"
717 "enable port meter (port_id) (mtr_id)\n"
720 "disable port meter (port_id) (mtr_id)\n"
723 "del port meter (port_id) (mtr_id)\n"
726 "add port meter policy (port_id) (policy_id) g_actions (actions)\n"
727 "y_actions (actions) r_actions (actions)\n"
728 " meter policy add\n\n"
730 "del port meter policy (port_id) (policy_id)\n"
731 " meter policy delete\n\n"
733 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
734 " meter update meter profile\n\n"
736 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
737 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
738 " update meter dscp table entries\n\n"
740 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
741 "(action0) [(action1) (action2)]\n"
742 " meter update policer action\n\n"
744 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
745 " meter update stats\n\n"
747 "show port (port_id) queue-region\n"
748 " show all queue region related configuration info\n\n"
750 "set port (port_id) fec_mode auto|off|rs|baser\n"
751 " set fec mode for a specific port\n\n"
753 , list_pkt_forwarding_modes()
757 if (show_all || !strcmp(res->section, "ports")) {
763 "----------------\n\n"
765 "port start (port_id|all)\n"
766 " Start all ports or port_id.\n\n"
768 "port stop (port_id|all)\n"
769 " Stop all ports or port_id.\n\n"
771 "port close (port_id|all)\n"
772 " Close all ports or port_id.\n\n"
774 "port reset (port_id|all)\n"
775 " Reset all ports or port_id.\n\n"
777 "port attach (ident)\n"
778 " Attach physical or virtual dev by pci address or virtual device name\n\n"
780 "port detach (port_id)\n"
781 " Detach physical or virtual dev by port_id\n\n"
783 "port config (port_id|all)"
784 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
785 " duplex (half|full|auto)\n"
786 " Set speed and duplex for all ports or port_id\n\n"
788 "port config (port_id|all) loopback (mode)\n"
789 " Set loopback mode for all ports or port_id\n\n"
791 "port config all (rxq|txq|rxd|txd) (value)\n"
792 " Set number for rxq/txq/rxd/txd.\n\n"
794 "port config all max-pkt-len (value)\n"
795 " Set the max packet length.\n\n"
797 "port config all max-lro-pkt-size (value)\n"
798 " Set the max LRO aggregated packet size.\n\n"
800 "port config all drop-en (on|off)\n"
801 " Enable or disable packet drop on all RX queues of all ports when no "
802 "receive buffers available.\n\n"
804 "port config all rss (all|default|ip|tcp|udp|sctp|"
805 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|ipv4-chksum|l2tpv2|"
806 "none|level-default|level-outer|level-inner|<flowtype_id>)\n"
807 " Set the RSS mode.\n\n"
809 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
810 " Set the RSS redirection table.\n\n"
812 "port config (port_id) dcb vt (on|off) (traffic_class)"
814 " Set the DCB mode.\n\n"
816 "port config all burst (value)\n"
817 " Set the number of packets per burst.\n\n"
819 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
821 " Set the ring prefetch/host/writeback threshold"
822 " for tx/rx queue.\n\n"
824 "port config all (txfreet|txrst|rxfreet) (value)\n"
825 " Set free threshold for rx/tx, or set"
826 " tx rs bit threshold.\n\n"
827 "port config mtu X value\n"
828 " Set the MTU of port X to a given value\n\n"
830 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
831 " Set a rx/tx queue's ring size configuration, the new"
832 " value will take effect after command that (re-)start the port"
833 " or command that setup the specific queue\n\n"
835 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
836 " Start/stop a rx/tx queue of port X. Only take effect"
837 " when port X is started\n\n"
839 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
840 " Switch on/off a deferred start of port X rx/tx queue. Only"
841 " take effect when port X is stopped.\n\n"
843 "port (port_id) (rxq|txq) (queue_id) setup\n"
844 " Setup a rx/tx queue of port X.\n\n"
846 "port config (port_id) pctype mapping reset\n"
847 " Reset flow type to pctype mapping on a port\n\n"
849 "port config (port_id) pctype mapping update"
850 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
851 " Update a flow type to pctype mapping item on a port\n\n"
853 "port config (port_id) pctype (pctype_id) hash_inset|"
854 "fdir_inset|fdir_flx_inset get|set|clear field\n"
856 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
858 "port config (port_id) pctype (pctype_id) hash_inset|"
859 "fdir_inset|fdir_flx_inset clear all"
860 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
862 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
863 " Add/remove UDP tunnel port for tunneling offload\n\n"
865 "port config <port_id> rx_offload vlan_strip|"
866 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
867 "outer_ipv4_cksum|macsec_strip|header_split|"
868 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
869 "buffer_split|timestamp|security|keep_crc on|off\n"
870 " Enable or disable a per port Rx offloading"
871 " on all Rx queues of a port\n\n"
873 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
874 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
875 "outer_ipv4_cksum|macsec_strip|header_split|"
876 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
877 "buffer_split|timestamp|security|keep_crc on|off\n"
878 " Enable or disable a per queue Rx offloading"
879 " only on a specific Rx queue\n\n"
881 "port config (port_id) tx_offload vlan_insert|"
882 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
883 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
884 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
885 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
887 " Enable or disable a per port Tx offloading"
888 " on all Tx queues of a port\n\n"
890 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
891 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
892 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
893 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
894 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
896 " Enable or disable a per queue Tx offloading"
897 " only on a specific Tx queue\n\n"
899 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
900 " Load an eBPF program as a callback"
901 " for particular RX/TX queue\n\n"
903 "bpf-unload rx|tx (port) (queue)\n"
904 " Unload previously loaded eBPF program"
905 " for particular RX/TX queue\n\n"
907 "port config (port_id) tx_metadata (value)\n"
908 " Set Tx metadata value per port. Testpmd will add this value"
909 " to any Tx packet sent from this port\n\n"
911 "port config (port_id) dynf (name) set|clear\n"
912 " Register a dynf and Set/clear this flag on Tx. "
913 "Testpmd will set this value to any Tx packet "
914 "sent from this port\n\n"
916 "port cleanup (port_id) txq (queue_id) (free_cnt)\n"
917 " Cleanup txq mbufs for a specific Tx queue\n\n"
921 if (show_all || !strcmp(res->section, "registers")) {
929 "read reg (port_id) (address)\n"
930 " Display value of a port register.\n\n"
932 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
933 " Display a port register bit field.\n\n"
935 "read regbit (port_id) (address) (bit_x)\n"
936 " Display a single port register bit.\n\n"
938 "write reg (port_id) (address) (value)\n"
939 " Set value of a port register.\n\n"
941 "write regfield (port_id) (address) (bit_x) (bit_y)"
943 " Set bit field of a port register.\n\n"
945 "write regbit (port_id) (address) (bit_x) (value)\n"
946 " Set single bit value of a port register.\n\n"
949 if (show_all || !strcmp(res->section, "filters")) {
958 "flow_director_filter (port_id) mode raw (add|del|update)"
959 " flow (flow_id) (drop|fwd) queue (queue_id)"
960 " fd_id (fd_id_value) packet (packet file name)\n"
961 " Add/Del a raw type flow director filter.\n\n"
964 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
965 " src_mask (ipv4_src) (ipv6_src) (src_port)"
966 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
967 " Set flow director IP mask.\n\n"
969 "flow_director_mask (port_id) mode MAC-VLAN"
970 " vlan (vlan_value)\n"
971 " Set flow director MAC-VLAN mask.\n\n"
973 "flow_director_mask (port_id) mode Tunnel"
974 " vlan (vlan_value) mac (mac_value)"
975 " tunnel-type (tunnel_type_value)"
976 " tunnel-id (tunnel_id_value)\n"
977 " Set flow director Tunnel mask.\n\n"
979 "flow_director_flex_payload (port_id)"
980 " (raw|l2|l3|l4) (config)\n"
981 " Configure flex payload selection.\n\n"
983 "flow validate {port_id}"
984 " [group {group_id}] [priority {level}]"
985 " [ingress] [egress]"
986 " pattern {item} [/ {item} [...]] / end"
987 " actions {action} [/ {action} [...]] / end\n"
988 " Check whether a flow rule can be created.\n\n"
990 "flow create {port_id}"
991 " [group {group_id}] [priority {level}]"
992 " [ingress] [egress]"
993 " pattern {item} [/ {item} [...]] / end"
994 " actions {action} [/ {action} [...]] / end\n"
995 " Create a flow rule.\n\n"
997 "flow destroy {port_id} rule {rule_id} [...]\n"
998 " Destroy specific flow rules.\n\n"
1000 "flow flush {port_id}\n"
1001 " Destroy all flow rules.\n\n"
1003 "flow query {port_id} {rule_id} {action}\n"
1004 " Query an existing flow rule.\n\n"
1006 "flow list {port_id} [group {group_id}] [...]\n"
1007 " List existing flow rules sorted by priority,"
1008 " filtered by group identifiers.\n\n"
1010 "flow isolate {port_id} {boolean}\n"
1011 " Restrict ingress traffic to the defined"
1014 "flow aged {port_id} [destroy]\n"
1015 " List and destroy aged flows"
1018 "flow indirect_action {port_id} create"
1019 " [action_id {indirect_action_id}]"
1020 " [ingress] [egress]"
1021 " action {action} / end\n"
1022 " Create indirect action.\n\n"
1024 "flow indirect_action {port_id} update"
1025 " {indirect_action_id} action {action} / end\n"
1026 " Update indirect action.\n\n"
1028 "flow indirect_action {port_id} destroy"
1029 " action_id {indirect_action_id} [...]\n"
1030 " Destroy specific indirect actions.\n\n"
1032 "flow indirect_action {port_id} query"
1033 " {indirect_action_id}\n"
1034 " Query an existing indirect action.\n\n"
1036 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1037 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1038 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1039 " Configure the VXLAN encapsulation for flows.\n\n"
1041 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1042 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1043 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1044 " eth-dst (eth-dst)\n"
1045 " Configure the VXLAN encapsulation for flows.\n\n"
1047 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1048 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1049 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1050 " eth-dst (eth-dst)\n"
1051 " Configure the VXLAN encapsulation for flows.\n\n"
1053 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1054 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1056 " Configure the NVGRE encapsulation for flows.\n\n"
1058 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1059 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1060 " eth-src (eth-src) eth-dst (eth-dst)\n"
1061 " Configure the NVGRE encapsulation for flows.\n\n"
1063 "set raw_encap {flow items}\n"
1064 " Configure the encapsulation with raw data.\n\n"
1066 "set raw_decap {flow items}\n"
1067 " Configure the decapsulation with raw data.\n\n"
1072 if (show_all || !strcmp(res->section, "traffic_management")) {
1076 "Traffic Management:\n"
1078 "show port tm cap (port_id)\n"
1079 " Display the port TM capability.\n\n"
1081 "show port tm level cap (port_id) (level_id)\n"
1082 " Display the port TM hierarchical level capability.\n\n"
1084 "show port tm node cap (port_id) (node_id)\n"
1085 " Display the port TM node capability.\n\n"
1087 "show port tm node type (port_id) (node_id)\n"
1088 " Display the port TM node type.\n\n"
1090 "show port tm node stats (port_id) (node_id) (clear)\n"
1091 " Display the port TM node stats.\n\n"
1093 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1094 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1095 " (packet_length_adjust) (packet_mode)\n"
1096 " Add port tm node private shaper profile.\n\n"
1098 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1099 " Delete port tm node private shaper profile.\n\n"
1101 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1102 " (shaper_profile_id)\n"
1103 " Add/update port tm node shared shaper.\n\n"
1105 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1106 " Delete port tm node shared shaper.\n\n"
1108 "set port tm node shaper profile (port_id) (node_id)"
1109 " (shaper_profile_id)\n"
1110 " Set port tm node shaper profile.\n\n"
1112 "add port tm node wred profile (port_id) (wred_profile_id)"
1113 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1114 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1115 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1116 " Add port tm node wred profile.\n\n"
1118 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1119 " Delete port tm node wred profile.\n\n"
1121 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1122 " (priority) (weight) (level_id) (shaper_profile_id)"
1123 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1124 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1125 " Add port tm nonleaf node.\n\n"
1127 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1128 " (priority) (weight) (level_id) (shaper_profile_id)"
1129 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1130 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1131 " Add port tm nonleaf node with pkt mode enabled.\n\n"
1133 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1134 " (priority) (weight) (level_id) (shaper_profile_id)"
1135 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1136 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1137 " Add port tm leaf node.\n\n"
1139 "del port tm node (port_id) (node_id)\n"
1140 " Delete port tm node.\n\n"
1142 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1143 " (priority) (weight)\n"
1144 " Set port tm node parent.\n\n"
1146 "suspend port tm node (port_id) (node_id)"
1147 " Suspend tm node.\n\n"
1149 "resume port tm node (port_id) (node_id)"
1150 " Resume tm node.\n\n"
1152 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1153 " Commit tm hierarchy.\n\n"
1155 "set port tm mark ip_ecn (port) (green) (yellow)"
1157 " Enables/Disables the traffic management marking"
1158 " for IP ECN (Explicit Congestion Notification)"
1159 " packets on a given port\n\n"
1161 "set port tm mark ip_dscp (port) (green) (yellow)"
1163 " Enables/Disables the traffic management marking"
1164 " on the port for IP dscp packets\n\n"
1166 "set port tm mark vlan_dei (port) (green) (yellow)"
1168 " Enables/Disables the traffic management marking"
1169 " on the port for VLAN packets with DEI enabled\n\n"
1173 if (show_all || !strcmp(res->section, "devices")) {
1177 "Device Operations:\n"
1179 "device detach (identifier)\n"
1180 " Detach device by identifier.\n\n"
1184 if (show_all || !strcmp(res->section, "drivers")) {
1185 struct testpmd_driver_commands *c;
1191 "Driver specific:\n"
1192 "----------------\n"
1194 TAILQ_FOREACH(c, &driver_commands_head, next) {
1195 for (i = 0; c->commands[i].ctx != NULL; i++)
1196 cmdline_printf(cl, "%s\n", c->commands[i].help);
1201 static cmdline_parse_token_string_t cmd_help_long_help =
1202 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1204 static cmdline_parse_token_string_t cmd_help_long_section =
1205 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1206 "all#control#display#config#ports#registers#"
1207 "filters#traffic_management#devices#drivers");
1209 static cmdline_parse_inst_t cmd_help_long = {
1210 .f = cmd_help_long_parsed,
1212 .help_str = "help all|control|display|config|ports|register|"
1213 "filters|traffic_management|devices|drivers: "
1216 (void *)&cmd_help_long_help,
1217 (void *)&cmd_help_long_section,
1223 /* *** start/stop/close all ports *** */
1224 struct cmd_operate_port_result {
1225 cmdline_fixed_string_t keyword;
1226 cmdline_fixed_string_t name;
1227 cmdline_fixed_string_t value;
1230 static void cmd_operate_port_parsed(void *parsed_result,
1231 __rte_unused struct cmdline *cl,
1232 __rte_unused void *data)
1234 struct cmd_operate_port_result *res = parsed_result;
1236 if (!strcmp(res->name, "start"))
1237 start_port(RTE_PORT_ALL);
1238 else if (!strcmp(res->name, "stop"))
1239 stop_port(RTE_PORT_ALL);
1240 else if (!strcmp(res->name, "close"))
1241 close_port(RTE_PORT_ALL);
1242 else if (!strcmp(res->name, "reset"))
1243 reset_port(RTE_PORT_ALL);
1245 fprintf(stderr, "Unknown parameter\n");
1248 static cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1249 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1251 static cmdline_parse_token_string_t cmd_operate_port_all_port =
1252 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1253 "start#stop#close#reset");
1254 static cmdline_parse_token_string_t cmd_operate_port_all_all =
1255 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1257 static cmdline_parse_inst_t cmd_operate_port = {
1258 .f = cmd_operate_port_parsed,
1260 .help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports",
1262 (void *)&cmd_operate_port_all_cmd,
1263 (void *)&cmd_operate_port_all_port,
1264 (void *)&cmd_operate_port_all_all,
1269 /* *** start/stop/close specific port *** */
1270 struct cmd_operate_specific_port_result {
1271 cmdline_fixed_string_t keyword;
1272 cmdline_fixed_string_t name;
1276 static void cmd_operate_specific_port_parsed(void *parsed_result,
1277 __rte_unused struct cmdline *cl,
1278 __rte_unused void *data)
1280 struct cmd_operate_specific_port_result *res = parsed_result;
1282 if (!strcmp(res->name, "start"))
1283 start_port(res->value);
1284 else if (!strcmp(res->name, "stop"))
1285 stop_port(res->value);
1286 else if (!strcmp(res->name, "close"))
1287 close_port(res->value);
1288 else if (!strcmp(res->name, "reset"))
1289 reset_port(res->value);
1291 fprintf(stderr, "Unknown parameter\n");
1294 static cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1295 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1297 static cmdline_parse_token_string_t cmd_operate_specific_port_port =
1298 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1299 name, "start#stop#close#reset");
1300 static cmdline_parse_token_num_t cmd_operate_specific_port_id =
1301 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1304 static cmdline_parse_inst_t cmd_operate_specific_port = {
1305 .f = cmd_operate_specific_port_parsed,
1307 .help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id",
1309 (void *)&cmd_operate_specific_port_cmd,
1310 (void *)&cmd_operate_specific_port_port,
1311 (void *)&cmd_operate_specific_port_id,
1316 /* *** enable port setup (after attach) via iterator or event *** */
1317 struct cmd_set_port_setup_on_result {
1318 cmdline_fixed_string_t set;
1319 cmdline_fixed_string_t port;
1320 cmdline_fixed_string_t setup;
1321 cmdline_fixed_string_t on;
1322 cmdline_fixed_string_t mode;
1325 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1326 __rte_unused struct cmdline *cl,
1327 __rte_unused void *data)
1329 struct cmd_set_port_setup_on_result *res = parsed_result;
1331 if (strcmp(res->mode, "event") == 0)
1332 setup_on_probe_event = true;
1333 else if (strcmp(res->mode, "iterator") == 0)
1334 setup_on_probe_event = false;
1336 fprintf(stderr, "Unknown mode\n");
1339 static cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1340 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1342 static cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1343 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1345 static cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1346 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1348 static cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1349 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1351 static cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1352 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1353 mode, "iterator#event");
1355 static cmdline_parse_inst_t cmd_set_port_setup_on = {
1356 .f = cmd_set_port_setup_on_parsed,
1358 .help_str = "set port setup on iterator|event",
1360 (void *)&cmd_set_port_setup_on_set,
1361 (void *)&cmd_set_port_setup_on_port,
1362 (void *)&cmd_set_port_setup_on_setup,
1363 (void *)&cmd_set_port_setup_on_on,
1364 (void *)&cmd_set_port_setup_on_mode,
1369 /* *** attach a specified port *** */
1370 struct cmd_operate_attach_port_result {
1371 cmdline_fixed_string_t port;
1372 cmdline_fixed_string_t keyword;
1373 cmdline_multi_string_t identifier;
1376 static void cmd_operate_attach_port_parsed(void *parsed_result,
1377 __rte_unused struct cmdline *cl,
1378 __rte_unused void *data)
1380 struct cmd_operate_attach_port_result *res = parsed_result;
1382 if (!strcmp(res->keyword, "attach"))
1383 attach_port(res->identifier);
1385 fprintf(stderr, "Unknown parameter\n");
1388 static cmdline_parse_token_string_t cmd_operate_attach_port_port =
1389 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1391 static cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1392 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1394 static cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1395 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1396 identifier, TOKEN_STRING_MULTI);
1398 static cmdline_parse_inst_t cmd_operate_attach_port = {
1399 .f = cmd_operate_attach_port_parsed,
1401 .help_str = "port attach <identifier>: "
1402 "(identifier: pci address or virtual dev name)",
1404 (void *)&cmd_operate_attach_port_port,
1405 (void *)&cmd_operate_attach_port_keyword,
1406 (void *)&cmd_operate_attach_port_identifier,
1411 /* *** detach a specified port *** */
1412 struct cmd_operate_detach_port_result {
1413 cmdline_fixed_string_t port;
1414 cmdline_fixed_string_t keyword;
1418 static void cmd_operate_detach_port_parsed(void *parsed_result,
1419 __rte_unused struct cmdline *cl,
1420 __rte_unused void *data)
1422 struct cmd_operate_detach_port_result *res = parsed_result;
1424 if (!strcmp(res->keyword, "detach")) {
1425 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1426 detach_port_device(res->port_id);
1428 fprintf(stderr, "Unknown parameter\n");
1432 static cmdline_parse_token_string_t cmd_operate_detach_port_port =
1433 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1435 static cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1436 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1438 static cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1439 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1440 port_id, RTE_UINT16);
1442 static cmdline_parse_inst_t cmd_operate_detach_port = {
1443 .f = cmd_operate_detach_port_parsed,
1445 .help_str = "port detach <port_id>",
1447 (void *)&cmd_operate_detach_port_port,
1448 (void *)&cmd_operate_detach_port_keyword,
1449 (void *)&cmd_operate_detach_port_port_id,
1454 /* *** detach device by identifier *** */
1455 struct cmd_operate_detach_device_result {
1456 cmdline_fixed_string_t device;
1457 cmdline_fixed_string_t keyword;
1458 cmdline_fixed_string_t identifier;
1461 static void cmd_operate_detach_device_parsed(void *parsed_result,
1462 __rte_unused struct cmdline *cl,
1463 __rte_unused void *data)
1465 struct cmd_operate_detach_device_result *res = parsed_result;
1467 if (!strcmp(res->keyword, "detach"))
1468 detach_devargs(res->identifier);
1470 fprintf(stderr, "Unknown parameter\n");
1473 static cmdline_parse_token_string_t cmd_operate_detach_device_device =
1474 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1476 static cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1477 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1479 static cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1480 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1483 static cmdline_parse_inst_t cmd_operate_detach_device = {
1484 .f = cmd_operate_detach_device_parsed,
1486 .help_str = "device detach <identifier>:"
1487 "(identifier: pci address or virtual dev name)",
1489 (void *)&cmd_operate_detach_device_device,
1490 (void *)&cmd_operate_detach_device_keyword,
1491 (void *)&cmd_operate_detach_device_identifier,
1495 /* *** configure speed for all ports *** */
1496 struct cmd_config_speed_all {
1497 cmdline_fixed_string_t port;
1498 cmdline_fixed_string_t keyword;
1499 cmdline_fixed_string_t all;
1500 cmdline_fixed_string_t item1;
1501 cmdline_fixed_string_t item2;
1502 cmdline_fixed_string_t value1;
1503 cmdline_fixed_string_t value2;
1507 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1512 if (!strcmp(duplexstr, "half")) {
1513 duplex = RTE_ETH_LINK_HALF_DUPLEX;
1514 } else if (!strcmp(duplexstr, "full")) {
1515 duplex = RTE_ETH_LINK_FULL_DUPLEX;
1516 } else if (!strcmp(duplexstr, "auto")) {
1517 duplex = RTE_ETH_LINK_FULL_DUPLEX;
1519 fprintf(stderr, "Unknown duplex parameter\n");
1523 if (!strcmp(speedstr, "10")) {
1524 *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1525 RTE_ETH_LINK_SPEED_10M_HD : RTE_ETH_LINK_SPEED_10M;
1526 } else if (!strcmp(speedstr, "100")) {
1527 *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1528 RTE_ETH_LINK_SPEED_100M_HD : RTE_ETH_LINK_SPEED_100M;
1530 if (duplex != RTE_ETH_LINK_FULL_DUPLEX) {
1531 fprintf(stderr, "Invalid speed/duplex parameters\n");
1534 if (!strcmp(speedstr, "1000")) {
1535 *speed = RTE_ETH_LINK_SPEED_1G;
1536 } else if (!strcmp(speedstr, "10000")) {
1537 *speed = RTE_ETH_LINK_SPEED_10G;
1538 } else if (!strcmp(speedstr, "25000")) {
1539 *speed = RTE_ETH_LINK_SPEED_25G;
1540 } else if (!strcmp(speedstr, "40000")) {
1541 *speed = RTE_ETH_LINK_SPEED_40G;
1542 } else if (!strcmp(speedstr, "50000")) {
1543 *speed = RTE_ETH_LINK_SPEED_50G;
1544 } else if (!strcmp(speedstr, "100000")) {
1545 *speed = RTE_ETH_LINK_SPEED_100G;
1546 } else if (!strcmp(speedstr, "200000")) {
1547 *speed = RTE_ETH_LINK_SPEED_200G;
1548 } else if (!strcmp(speedstr, "auto")) {
1549 *speed = RTE_ETH_LINK_SPEED_AUTONEG;
1551 fprintf(stderr, "Unknown speed parameter\n");
1556 if (*speed != RTE_ETH_LINK_SPEED_AUTONEG)
1557 *speed |= RTE_ETH_LINK_SPEED_FIXED;
1563 cmd_config_speed_all_parsed(void *parsed_result,
1564 __rte_unused struct cmdline *cl,
1565 __rte_unused void *data)
1567 struct cmd_config_speed_all *res = parsed_result;
1568 uint32_t link_speed;
1571 if (!all_ports_stopped()) {
1572 fprintf(stderr, "Please stop all ports first\n");
1576 if (parse_and_check_speed_duplex(res->value1, res->value2,
1580 RTE_ETH_FOREACH_DEV(pid) {
1581 ports[pid].dev_conf.link_speeds = link_speed;
1584 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1587 static cmdline_parse_token_string_t cmd_config_speed_all_port =
1588 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1589 static cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1590 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1592 static cmdline_parse_token_string_t cmd_config_speed_all_all =
1593 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1594 static cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1595 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1596 static cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1597 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1598 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1599 static cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1600 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1601 static cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1602 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1605 static cmdline_parse_inst_t cmd_config_speed_all = {
1606 .f = cmd_config_speed_all_parsed,
1608 .help_str = "port config all speed "
1609 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1612 (void *)&cmd_config_speed_all_port,
1613 (void *)&cmd_config_speed_all_keyword,
1614 (void *)&cmd_config_speed_all_all,
1615 (void *)&cmd_config_speed_all_item1,
1616 (void *)&cmd_config_speed_all_value1,
1617 (void *)&cmd_config_speed_all_item2,
1618 (void *)&cmd_config_speed_all_value2,
1623 /* *** configure speed for specific port *** */
1624 struct cmd_config_speed_specific {
1625 cmdline_fixed_string_t port;
1626 cmdline_fixed_string_t keyword;
1628 cmdline_fixed_string_t item1;
1629 cmdline_fixed_string_t item2;
1630 cmdline_fixed_string_t value1;
1631 cmdline_fixed_string_t value2;
1635 cmd_config_speed_specific_parsed(void *parsed_result,
1636 __rte_unused struct cmdline *cl,
1637 __rte_unused void *data)
1639 struct cmd_config_speed_specific *res = parsed_result;
1640 uint32_t link_speed;
1642 if (port_id_is_invalid(res->id, ENABLED_WARN))
1645 if (!port_is_stopped(res->id)) {
1646 fprintf(stderr, "Please stop port %d first\n", res->id);
1650 if (parse_and_check_speed_duplex(res->value1, res->value2,
1654 ports[res->id].dev_conf.link_speeds = link_speed;
1656 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1660 static cmdline_parse_token_string_t cmd_config_speed_specific_port =
1661 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1663 static cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1664 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1666 static cmdline_parse_token_num_t cmd_config_speed_specific_id =
1667 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1668 static cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1669 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1671 static cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1672 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1673 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1674 static cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1675 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1677 static cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1678 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1681 static cmdline_parse_inst_t cmd_config_speed_specific = {
1682 .f = cmd_config_speed_specific_parsed,
1684 .help_str = "port config <port_id> speed "
1685 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1688 (void *)&cmd_config_speed_specific_port,
1689 (void *)&cmd_config_speed_specific_keyword,
1690 (void *)&cmd_config_speed_specific_id,
1691 (void *)&cmd_config_speed_specific_item1,
1692 (void *)&cmd_config_speed_specific_value1,
1693 (void *)&cmd_config_speed_specific_item2,
1694 (void *)&cmd_config_speed_specific_value2,
1699 /* *** configure loopback for all ports *** */
1700 struct cmd_config_loopback_all {
1701 cmdline_fixed_string_t port;
1702 cmdline_fixed_string_t keyword;
1703 cmdline_fixed_string_t all;
1704 cmdline_fixed_string_t item;
1709 cmd_config_loopback_all_parsed(void *parsed_result,
1710 __rte_unused struct cmdline *cl,
1711 __rte_unused void *data)
1713 struct cmd_config_loopback_all *res = parsed_result;
1716 if (!all_ports_stopped()) {
1717 fprintf(stderr, "Please stop all ports first\n");
1721 RTE_ETH_FOREACH_DEV(pid) {
1722 ports[pid].dev_conf.lpbk_mode = res->mode;
1725 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1728 static cmdline_parse_token_string_t cmd_config_loopback_all_port =
1729 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1730 static cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1731 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1733 static cmdline_parse_token_string_t cmd_config_loopback_all_all =
1734 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1735 static cmdline_parse_token_string_t cmd_config_loopback_all_item =
1736 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1738 static cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1739 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1741 static cmdline_parse_inst_t cmd_config_loopback_all = {
1742 .f = cmd_config_loopback_all_parsed,
1744 .help_str = "port config all loopback <mode>",
1746 (void *)&cmd_config_loopback_all_port,
1747 (void *)&cmd_config_loopback_all_keyword,
1748 (void *)&cmd_config_loopback_all_all,
1749 (void *)&cmd_config_loopback_all_item,
1750 (void *)&cmd_config_loopback_all_mode,
1755 /* *** configure loopback for specific port *** */
1756 struct cmd_config_loopback_specific {
1757 cmdline_fixed_string_t port;
1758 cmdline_fixed_string_t keyword;
1760 cmdline_fixed_string_t item;
1765 cmd_config_loopback_specific_parsed(void *parsed_result,
1766 __rte_unused struct cmdline *cl,
1767 __rte_unused void *data)
1769 struct cmd_config_loopback_specific *res = parsed_result;
1771 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1774 if (!port_is_stopped(res->port_id)) {
1775 fprintf(stderr, "Please stop port %u first\n", res->port_id);
1779 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1781 cmd_reconfig_device_queue(res->port_id, 1, 1);
1785 static cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1786 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1788 static cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1789 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1791 static cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1792 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1794 static cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1795 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1797 static cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1798 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1801 static cmdline_parse_inst_t cmd_config_loopback_specific = {
1802 .f = cmd_config_loopback_specific_parsed,
1804 .help_str = "port config <port_id> loopback <mode>",
1806 (void *)&cmd_config_loopback_specific_port,
1807 (void *)&cmd_config_loopback_specific_keyword,
1808 (void *)&cmd_config_loopback_specific_id,
1809 (void *)&cmd_config_loopback_specific_item,
1810 (void *)&cmd_config_loopback_specific_mode,
1815 /* *** configure txq/rxq, txd/rxd *** */
1816 struct cmd_config_rx_tx {
1817 cmdline_fixed_string_t port;
1818 cmdline_fixed_string_t keyword;
1819 cmdline_fixed_string_t all;
1820 cmdline_fixed_string_t name;
1825 cmd_config_rx_tx_parsed(void *parsed_result,
1826 __rte_unused struct cmdline *cl,
1827 __rte_unused void *data)
1829 struct cmd_config_rx_tx *res = parsed_result;
1831 if (!all_ports_stopped()) {
1832 fprintf(stderr, "Please stop all ports first\n");
1835 if (!strcmp(res->name, "rxq")) {
1836 if (!res->value && !nb_txq) {
1837 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1840 if (check_nb_rxq(res->value) != 0)
1842 nb_rxq = res->value;
1844 else if (!strcmp(res->name, "txq")) {
1845 if (!res->value && !nb_rxq) {
1846 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1849 if (check_nb_txq(res->value) != 0)
1851 nb_txq = res->value;
1853 else if (!strcmp(res->name, "rxd")) {
1854 if (check_nb_rxd(res->value) != 0)
1856 nb_rxd = res->value;
1857 } else if (!strcmp(res->name, "txd")) {
1858 if (check_nb_txd(res->value) != 0)
1861 nb_txd = res->value;
1863 fprintf(stderr, "Unknown parameter\n");
1871 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1874 static cmdline_parse_token_string_t cmd_config_rx_tx_port =
1875 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1876 static cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1877 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1878 static cmdline_parse_token_string_t cmd_config_rx_tx_all =
1879 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1880 static cmdline_parse_token_string_t cmd_config_rx_tx_name =
1881 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1883 static cmdline_parse_token_num_t cmd_config_rx_tx_value =
1884 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
1886 static cmdline_parse_inst_t cmd_config_rx_tx = {
1887 .f = cmd_config_rx_tx_parsed,
1889 .help_str = "port config all rxq|txq|rxd|txd <value>",
1891 (void *)&cmd_config_rx_tx_port,
1892 (void *)&cmd_config_rx_tx_keyword,
1893 (void *)&cmd_config_rx_tx_all,
1894 (void *)&cmd_config_rx_tx_name,
1895 (void *)&cmd_config_rx_tx_value,
1900 /* *** config max packet length *** */
1901 struct cmd_config_max_pkt_len_result {
1902 cmdline_fixed_string_t port;
1903 cmdline_fixed_string_t keyword;
1904 cmdline_fixed_string_t all;
1905 cmdline_fixed_string_t name;
1910 cmd_config_max_pkt_len_parsed(void *parsed_result,
1911 __rte_unused struct cmdline *cl,
1912 __rte_unused void *data)
1914 struct cmd_config_max_pkt_len_result *res = parsed_result;
1918 if (strcmp(res->name, "max-pkt-len") != 0) {
1919 printf("Unknown parameter\n");
1923 if (!all_ports_stopped()) {
1924 fprintf(stderr, "Please stop all ports first\n");
1928 RTE_ETH_FOREACH_DEV(port_id) {
1929 struct rte_port *port = &ports[port_id];
1931 if (res->value < RTE_ETHER_MIN_LEN) {
1933 "max-pkt-len can not be less than %d\n",
1938 ret = eth_dev_info_get_print_err(port_id, &port->dev_info);
1941 "rte_eth_dev_info_get() failed for port %u\n",
1946 update_mtu_from_frame_size(port_id, res->value);
1951 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1954 static cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1955 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1957 static cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1958 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1960 static cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1961 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1963 static cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1964 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1966 static cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1967 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1970 static cmdline_parse_inst_t cmd_config_max_pkt_len = {
1971 .f = cmd_config_max_pkt_len_parsed,
1973 .help_str = "port config all max-pkt-len <value>",
1975 (void *)&cmd_config_max_pkt_len_port,
1976 (void *)&cmd_config_max_pkt_len_keyword,
1977 (void *)&cmd_config_max_pkt_len_all,
1978 (void *)&cmd_config_max_pkt_len_name,
1979 (void *)&cmd_config_max_pkt_len_value,
1984 /* *** config max LRO aggregated packet size *** */
1985 struct cmd_config_max_lro_pkt_size_result {
1986 cmdline_fixed_string_t port;
1987 cmdline_fixed_string_t keyword;
1988 cmdline_fixed_string_t all;
1989 cmdline_fixed_string_t name;
1994 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1995 __rte_unused struct cmdline *cl,
1996 __rte_unused void *data)
1998 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2001 if (!all_ports_stopped()) {
2002 fprintf(stderr, "Please stop all ports first\n");
2006 RTE_ETH_FOREACH_DEV(pid) {
2007 struct rte_port *port = &ports[pid];
2009 if (!strcmp(res->name, "max-lro-pkt-size")) {
2011 port->dev_conf.rxmode.max_lro_pkt_size)
2014 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2016 fprintf(stderr, "Unknown parameter\n");
2023 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2026 static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2027 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2029 static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2030 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2032 static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2033 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2035 static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2036 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2037 name, "max-lro-pkt-size");
2038 static cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2039 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2042 static cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2043 .f = cmd_config_max_lro_pkt_size_parsed,
2045 .help_str = "port config all max-lro-pkt-size <value>",
2047 (void *)&cmd_config_max_lro_pkt_size_port,
2048 (void *)&cmd_config_max_lro_pkt_size_keyword,
2049 (void *)&cmd_config_max_lro_pkt_size_all,
2050 (void *)&cmd_config_max_lro_pkt_size_name,
2051 (void *)&cmd_config_max_lro_pkt_size_value,
2056 /* *** configure port MTU *** */
2057 struct cmd_config_mtu_result {
2058 cmdline_fixed_string_t port;
2059 cmdline_fixed_string_t keyword;
2060 cmdline_fixed_string_t mtu;
2066 cmd_config_mtu_parsed(void *parsed_result,
2067 __rte_unused struct cmdline *cl,
2068 __rte_unused void *data)
2070 struct cmd_config_mtu_result *res = parsed_result;
2072 port_mtu_set(res->port_id, res->value);
2075 static cmdline_parse_token_string_t cmd_config_mtu_port =
2076 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2078 static cmdline_parse_token_string_t cmd_config_mtu_keyword =
2079 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2081 static cmdline_parse_token_string_t cmd_config_mtu_mtu =
2082 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2084 static cmdline_parse_token_num_t cmd_config_mtu_port_id =
2085 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2087 static cmdline_parse_token_num_t cmd_config_mtu_value =
2088 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2091 static cmdline_parse_inst_t cmd_config_mtu = {
2092 .f = cmd_config_mtu_parsed,
2094 .help_str = "port config mtu <port_id> <value>",
2096 (void *)&cmd_config_mtu_port,
2097 (void *)&cmd_config_mtu_keyword,
2098 (void *)&cmd_config_mtu_mtu,
2099 (void *)&cmd_config_mtu_port_id,
2100 (void *)&cmd_config_mtu_value,
2105 /* *** configure rx mode *** */
2106 struct cmd_config_rx_mode_flag {
2107 cmdline_fixed_string_t port;
2108 cmdline_fixed_string_t keyword;
2109 cmdline_fixed_string_t all;
2110 cmdline_fixed_string_t name;
2111 cmdline_fixed_string_t value;
2115 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2116 __rte_unused struct cmdline *cl,
2117 __rte_unused void *data)
2119 struct cmd_config_rx_mode_flag *res = parsed_result;
2121 if (!all_ports_stopped()) {
2122 fprintf(stderr, "Please stop all ports first\n");
2126 if (!strcmp(res->name, "drop-en")) {
2127 if (!strcmp(res->value, "on"))
2129 else if (!strcmp(res->value, "off"))
2132 fprintf(stderr, "Unknown parameter\n");
2136 fprintf(stderr, "Unknown parameter\n");
2142 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2145 static cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2146 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2147 static cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2148 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2150 static cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2151 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2152 static cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2153 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2155 static cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2156 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2159 static cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2160 .f = cmd_config_rx_mode_flag_parsed,
2162 .help_str = "port config all drop-en on|off",
2164 (void *)&cmd_config_rx_mode_flag_port,
2165 (void *)&cmd_config_rx_mode_flag_keyword,
2166 (void *)&cmd_config_rx_mode_flag_all,
2167 (void *)&cmd_config_rx_mode_flag_name,
2168 (void *)&cmd_config_rx_mode_flag_value,
2173 /* *** configure rss *** */
2174 struct cmd_config_rss {
2175 cmdline_fixed_string_t port;
2176 cmdline_fixed_string_t keyword;
2177 cmdline_fixed_string_t all;
2178 cmdline_fixed_string_t name;
2179 cmdline_fixed_string_t value;
2183 cmd_config_rss_parsed(void *parsed_result,
2184 __rte_unused struct cmdline *cl,
2185 __rte_unused void *data)
2187 struct cmd_config_rss *res = parsed_result;
2188 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2189 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2190 int use_default = 0;
2191 int all_updated = 1;
2196 if (!strcmp(res->value, "all"))
2197 rss_conf.rss_hf = RTE_ETH_RSS_ETH | RTE_ETH_RSS_VLAN | RTE_ETH_RSS_IP |
2198 RTE_ETH_RSS_TCP | RTE_ETH_RSS_UDP | RTE_ETH_RSS_SCTP |
2199 RTE_ETH_RSS_L2_PAYLOAD | RTE_ETH_RSS_L2TPV3 | RTE_ETH_RSS_ESP |
2200 RTE_ETH_RSS_AH | RTE_ETH_RSS_PFCP | RTE_ETH_RSS_GTPU |
2201 RTE_ETH_RSS_ECPRI | RTE_ETH_RSS_L2TPV2;
2202 else if (!strcmp(res->value, "eth"))
2203 rss_conf.rss_hf = RTE_ETH_RSS_ETH;
2204 else if (!strcmp(res->value, "vlan"))
2205 rss_conf.rss_hf = RTE_ETH_RSS_VLAN;
2206 else if (!strcmp(res->value, "ip"))
2207 rss_conf.rss_hf = RTE_ETH_RSS_IP;
2208 else if (!strcmp(res->value, "udp"))
2209 rss_conf.rss_hf = RTE_ETH_RSS_UDP;
2210 else if (!strcmp(res->value, "tcp"))
2211 rss_conf.rss_hf = RTE_ETH_RSS_TCP;
2212 else if (!strcmp(res->value, "sctp"))
2213 rss_conf.rss_hf = RTE_ETH_RSS_SCTP;
2214 else if (!strcmp(res->value, "ether"))
2215 rss_conf.rss_hf = RTE_ETH_RSS_L2_PAYLOAD;
2216 else if (!strcmp(res->value, "port"))
2217 rss_conf.rss_hf = RTE_ETH_RSS_PORT;
2218 else if (!strcmp(res->value, "vxlan"))
2219 rss_conf.rss_hf = RTE_ETH_RSS_VXLAN;
2220 else if (!strcmp(res->value, "geneve"))
2221 rss_conf.rss_hf = RTE_ETH_RSS_GENEVE;
2222 else if (!strcmp(res->value, "nvgre"))
2223 rss_conf.rss_hf = RTE_ETH_RSS_NVGRE;
2224 else if (!strcmp(res->value, "l3-pre32"))
2225 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2226 else if (!strcmp(res->value, "l3-pre40"))
2227 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2228 else if (!strcmp(res->value, "l3-pre48"))
2229 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2230 else if (!strcmp(res->value, "l3-pre56"))
2231 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2232 else if (!strcmp(res->value, "l3-pre64"))
2233 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2234 else if (!strcmp(res->value, "l3-pre96"))
2235 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2236 else if (!strcmp(res->value, "l3-src-only"))
2237 rss_conf.rss_hf = RTE_ETH_RSS_L3_SRC_ONLY;
2238 else if (!strcmp(res->value, "l3-dst-only"))
2239 rss_conf.rss_hf = RTE_ETH_RSS_L3_DST_ONLY;
2240 else if (!strcmp(res->value, "l4-src-only"))
2241 rss_conf.rss_hf = RTE_ETH_RSS_L4_SRC_ONLY;
2242 else if (!strcmp(res->value, "l4-dst-only"))
2243 rss_conf.rss_hf = RTE_ETH_RSS_L4_DST_ONLY;
2244 else if (!strcmp(res->value, "l2-src-only"))
2245 rss_conf.rss_hf = RTE_ETH_RSS_L2_SRC_ONLY;
2246 else if (!strcmp(res->value, "l2-dst-only"))
2247 rss_conf.rss_hf = RTE_ETH_RSS_L2_DST_ONLY;
2248 else if (!strcmp(res->value, "l2tpv3"))
2249 rss_conf.rss_hf = RTE_ETH_RSS_L2TPV3;
2250 else if (!strcmp(res->value, "esp"))
2251 rss_conf.rss_hf = RTE_ETH_RSS_ESP;
2252 else if (!strcmp(res->value, "ah"))
2253 rss_conf.rss_hf = RTE_ETH_RSS_AH;
2254 else if (!strcmp(res->value, "pfcp"))
2255 rss_conf.rss_hf = RTE_ETH_RSS_PFCP;
2256 else if (!strcmp(res->value, "pppoe"))
2257 rss_conf.rss_hf = RTE_ETH_RSS_PPPOE;
2258 else if (!strcmp(res->value, "gtpu"))
2259 rss_conf.rss_hf = RTE_ETH_RSS_GTPU;
2260 else if (!strcmp(res->value, "ecpri"))
2261 rss_conf.rss_hf = RTE_ETH_RSS_ECPRI;
2262 else if (!strcmp(res->value, "mpls"))
2263 rss_conf.rss_hf = RTE_ETH_RSS_MPLS;
2264 else if (!strcmp(res->value, "ipv4-chksum"))
2265 rss_conf.rss_hf = RTE_ETH_RSS_IPV4_CHKSUM;
2266 else if (!strcmp(res->value, "l2tpv2"))
2267 rss_conf.rss_hf = RTE_ETH_RSS_L2TPV2;
2268 else if (!strcmp(res->value, "none"))
2269 rss_conf.rss_hf = 0;
2270 else if (!strcmp(res->value, "level-default")) {
2271 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2272 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_PMD_DEFAULT);
2273 } else if (!strcmp(res->value, "level-outer")) {
2274 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2275 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_OUTERMOST);
2276 } else if (!strcmp(res->value, "level-inner")) {
2277 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2278 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_INNERMOST);
2279 } else if (!strcmp(res->value, "default"))
2281 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2282 atoi(res->value) < 64)
2283 rss_conf.rss_hf = 1ULL << atoi(res->value);
2285 fprintf(stderr, "Unknown parameter\n");
2288 rss_conf.rss_key = NULL;
2289 /* Update global configuration for RSS types. */
2290 RTE_ETH_FOREACH_DEV(i) {
2291 struct rte_eth_rss_conf local_rss_conf;
2293 ret = eth_dev_info_get_print_err(i, &dev_info);
2298 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2300 local_rss_conf = rss_conf;
2301 local_rss_conf.rss_hf = rss_conf.rss_hf &
2302 dev_info.flow_type_rss_offloads;
2303 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2304 printf("Port %u modified RSS hash function based on hardware support,"
2305 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2306 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2308 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2312 "Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n",
2313 i, -diag, strerror(-diag));
2316 if (all_updated && !use_default) {
2317 rss_hf = rss_conf.rss_hf;
2318 printf("rss_hf %#"PRIx64"\n", rss_hf);
2322 static cmdline_parse_token_string_t cmd_config_rss_port =
2323 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2324 static cmdline_parse_token_string_t cmd_config_rss_keyword =
2325 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2326 static cmdline_parse_token_string_t cmd_config_rss_all =
2327 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2328 static cmdline_parse_token_string_t cmd_config_rss_name =
2329 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2330 static cmdline_parse_token_string_t cmd_config_rss_value =
2331 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2333 static cmdline_parse_inst_t cmd_config_rss = {
2334 .f = cmd_config_rss_parsed,
2336 .help_str = "port config all rss "
2337 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2338 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|ipv4-chksum|l2tpv2|"
2339 "none|level-default|level-outer|level-inner|<flowtype_id>",
2341 (void *)&cmd_config_rss_port,
2342 (void *)&cmd_config_rss_keyword,
2343 (void *)&cmd_config_rss_all,
2344 (void *)&cmd_config_rss_name,
2345 (void *)&cmd_config_rss_value,
2350 /* *** configure rss hash key *** */
2351 struct cmd_config_rss_hash_key {
2352 cmdline_fixed_string_t port;
2353 cmdline_fixed_string_t config;
2355 cmdline_fixed_string_t rss_hash_key;
2356 cmdline_fixed_string_t rss_type;
2357 cmdline_fixed_string_t key;
2361 hexa_digit_to_value(char hexa_digit)
2363 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2364 return (uint8_t) (hexa_digit - '0');
2365 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2366 return (uint8_t) ((hexa_digit - 'a') + 10);
2367 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2368 return (uint8_t) ((hexa_digit - 'A') + 10);
2369 /* Invalid hexa digit */
2374 parse_and_check_key_hexa_digit(char *key, int idx)
2378 hexa_v = hexa_digit_to_value(key[idx]);
2381 "invalid key: character %c at position %d is not a valid hexa digit\n",
2387 cmd_config_rss_hash_key_parsed(void *parsed_result,
2388 __rte_unused struct cmdline *cl,
2389 __rte_unused void *data)
2391 struct cmd_config_rss_hash_key *res = parsed_result;
2392 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2396 struct rte_eth_dev_info dev_info;
2397 uint8_t hash_key_size;
2401 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2405 if (dev_info.hash_key_size > 0 &&
2406 dev_info.hash_key_size <= sizeof(hash_key))
2407 hash_key_size = dev_info.hash_key_size;
2410 "dev_info did not provide a valid hash key size\n");
2413 /* Check the length of the RSS hash key */
2414 key_len = strlen(res->key);
2415 if (key_len != (hash_key_size * 2)) {
2417 "key length: %d invalid - key must be a string of %d hexa-decimal numbers\n",
2418 (int)key_len, hash_key_size * 2);
2421 /* Translate RSS hash key into binary representation */
2422 for (i = 0; i < hash_key_size; i++) {
2423 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2426 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2429 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2431 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2435 static cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2436 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2437 static cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2438 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2440 static cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2441 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2443 static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2444 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2445 rss_hash_key, "rss-hash-key");
2446 static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2447 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2448 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2449 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2450 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2451 "ipv6-tcp-ex#ipv6-udp-ex#"
2452 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2453 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2454 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls#l2tpv2");
2455 static cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2456 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2458 static cmdline_parse_inst_t cmd_config_rss_hash_key = {
2459 .f = cmd_config_rss_hash_key_parsed,
2461 .help_str = "port config <port_id> rss-hash-key "
2462 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2463 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2464 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2465 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2466 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2467 "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls|l2tpv2 "
2468 "<string of hex digits (variable length, NIC dependent)>",
2470 (void *)&cmd_config_rss_hash_key_port,
2471 (void *)&cmd_config_rss_hash_key_config,
2472 (void *)&cmd_config_rss_hash_key_port_id,
2473 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2474 (void *)&cmd_config_rss_hash_key_rss_type,
2475 (void *)&cmd_config_rss_hash_key_value,
2480 /* *** cleanup txq mbufs *** */
2481 struct cmd_cleanup_txq_mbufs_result {
2482 cmdline_fixed_string_t port;
2483 cmdline_fixed_string_t keyword;
2484 cmdline_fixed_string_t name;
2491 cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2492 __rte_unused struct cmdline *cl,
2493 __rte_unused void *data)
2495 struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2496 uint16_t port_id = res->port_id;
2497 uint16_t queue_id = res->queue_id;
2498 uint32_t free_cnt = res->free_cnt;
2499 struct rte_eth_txq_info qinfo;
2502 if (test_done == 0) {
2503 fprintf(stderr, "Please stop forwarding first\n");
2507 if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2508 fprintf(stderr, "Failed to get port %u Tx queue %u info\n",
2513 if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2514 fprintf(stderr, "Tx queue %u not started\n", queue_id);
2518 ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2521 "Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n",
2522 port_id, queue_id, strerror(-ret), ret);
2526 printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2527 port_id, queue_id, ret);
2530 static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2531 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2533 static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2534 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2536 static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2537 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2539 static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2540 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2542 static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2543 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2545 static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2546 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2549 static cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2550 .f = cmd_cleanup_txq_mbufs_parsed,
2552 .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2554 (void *)&cmd_cleanup_txq_mbufs_port,
2555 (void *)&cmd_cleanup_txq_mbufs_cleanup,
2556 (void *)&cmd_cleanup_txq_mbufs_port_id,
2557 (void *)&cmd_cleanup_txq_mbufs_txq,
2558 (void *)&cmd_cleanup_txq_mbufs_queue_id,
2559 (void *)&cmd_cleanup_txq_mbufs_free_cnt,
2564 /* *** configure port rxq/txq ring size *** */
2565 struct cmd_config_rxtx_ring_size {
2566 cmdline_fixed_string_t port;
2567 cmdline_fixed_string_t config;
2569 cmdline_fixed_string_t rxtxq;
2571 cmdline_fixed_string_t rsize;
2576 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2577 __rte_unused struct cmdline *cl,
2578 __rte_unused void *data)
2580 struct cmd_config_rxtx_ring_size *res = parsed_result;
2581 struct rte_port *port;
2584 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2587 if (res->portid == (portid_t)RTE_PORT_ALL) {
2588 fprintf(stderr, "Invalid port id\n");
2592 port = &ports[res->portid];
2594 if (!strcmp(res->rxtxq, "rxq"))
2596 else if (!strcmp(res->rxtxq, "txq"))
2599 fprintf(stderr, "Unknown parameter\n");
2603 if (isrx && rx_queue_id_is_invalid(res->qid))
2605 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2608 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2610 "Invalid rx ring_size, must > rx_free_thresh: %d\n",
2616 port->nb_rx_desc[res->qid] = res->size;
2618 port->nb_tx_desc[res->qid] = res->size;
2620 cmd_reconfig_device_queue(res->portid, 0, 1);
2623 static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2624 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2626 static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2627 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2629 static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2630 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2631 portid, RTE_UINT16);
2632 static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2633 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2635 static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2636 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2638 static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2639 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2640 rsize, "ring_size");
2641 static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2642 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2645 static cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2646 .f = cmd_config_rxtx_ring_size_parsed,
2648 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2650 (void *)&cmd_config_rxtx_ring_size_port,
2651 (void *)&cmd_config_rxtx_ring_size_config,
2652 (void *)&cmd_config_rxtx_ring_size_portid,
2653 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2654 (void *)&cmd_config_rxtx_ring_size_qid,
2655 (void *)&cmd_config_rxtx_ring_size_rsize,
2656 (void *)&cmd_config_rxtx_ring_size_size,
2661 /* *** configure port rxq/txq start/stop *** */
2662 struct cmd_config_rxtx_queue {
2663 cmdline_fixed_string_t port;
2665 cmdline_fixed_string_t rxtxq;
2667 cmdline_fixed_string_t opname;
2671 cmd_config_rxtx_queue_parsed(void *parsed_result,
2672 __rte_unused struct cmdline *cl,
2673 __rte_unused void *data)
2675 struct cmd_config_rxtx_queue *res = parsed_result;
2676 struct rte_port *port;
2682 if (test_done == 0) {
2683 fprintf(stderr, "Please stop forwarding first\n");
2687 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2690 if (port_is_started(res->portid) != 1) {
2691 fprintf(stderr, "Please start port %u first\n", res->portid);
2695 if (!strcmp(res->rxtxq, "rxq"))
2697 else if (!strcmp(res->rxtxq, "txq"))
2700 fprintf(stderr, "Unknown parameter\n");
2704 if (isrx && rx_queue_id_is_invalid(res->qid))
2706 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2709 if (!strcmp(res->opname, "start"))
2711 else if (!strcmp(res->opname, "stop"))
2714 fprintf(stderr, "Unknown parameter\n");
2718 if (isstart && isrx)
2719 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2720 else if (!isstart && isrx)
2721 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2722 else if (isstart && !isrx)
2723 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2725 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2727 if (ret == -ENOTSUP) {
2728 fprintf(stderr, "Function not supported in PMD\n");
2732 port = &ports[res->portid];
2733 state = isrx ? &port->rxq[res->qid].state : &port->txq[res->qid].state;
2734 *state = isstart ? RTE_ETH_QUEUE_STATE_STARTED :
2735 RTE_ETH_QUEUE_STATE_STOPPED;
2738 static cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2739 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2740 static cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2741 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2742 static cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2743 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2744 static cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2745 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2746 static cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2747 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2750 static cmdline_parse_inst_t cmd_config_rxtx_queue = {
2751 .f = cmd_config_rxtx_queue_parsed,
2753 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2755 (void *)&cmd_config_rxtx_queue_port,
2756 (void *)&cmd_config_rxtx_queue_portid,
2757 (void *)&cmd_config_rxtx_queue_rxtxq,
2758 (void *)&cmd_config_rxtx_queue_qid,
2759 (void *)&cmd_config_rxtx_queue_opname,
2764 /* *** configure port rxq/txq deferred start on/off *** */
2765 struct cmd_config_deferred_start_rxtx_queue {
2766 cmdline_fixed_string_t port;
2768 cmdline_fixed_string_t rxtxq;
2770 cmdline_fixed_string_t opname;
2771 cmdline_fixed_string_t state;
2775 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2776 __rte_unused struct cmdline *cl,
2777 __rte_unused void *data)
2779 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2780 struct rte_port *port;
2783 uint8_t needreconfig = 0;
2785 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2788 if (port_is_started(res->port_id) != 0) {
2789 fprintf(stderr, "Please stop port %u first\n", res->port_id);
2793 port = &ports[res->port_id];
2795 isrx = !strcmp(res->rxtxq, "rxq");
2797 if (isrx && rx_queue_id_is_invalid(res->qid))
2799 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2802 ison = !strcmp(res->state, "on");
2804 if (isrx && port->rxq[res->qid].conf.rx_deferred_start != ison) {
2805 port->rxq[res->qid].conf.rx_deferred_start = ison;
2807 } else if (!isrx && port->txq[res->qid].conf.tx_deferred_start != ison) {
2808 port->txq[res->qid].conf.tx_deferred_start = ison;
2813 cmd_reconfig_device_queue(res->port_id, 0, 1);
2816 static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2817 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2819 static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2820 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2821 port_id, RTE_UINT16);
2822 static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2823 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2825 static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2826 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2828 static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2829 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2830 opname, "deferred_start");
2831 static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2832 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2835 static cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2836 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2838 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2840 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2841 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2842 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2843 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2844 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2845 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2850 /* *** configure port rxq/txq setup *** */
2851 struct cmd_setup_rxtx_queue {
2852 cmdline_fixed_string_t port;
2854 cmdline_fixed_string_t rxtxq;
2856 cmdline_fixed_string_t setup;
2859 /* Common CLI fields for queue setup */
2860 static cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2861 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2862 static cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2863 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2864 static cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2865 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2866 static cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2867 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2868 static cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2869 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2872 cmd_setup_rxtx_queue_parsed(
2873 void *parsed_result,
2874 __rte_unused struct cmdline *cl,
2875 __rte_unused void *data)
2877 struct cmd_setup_rxtx_queue *res = parsed_result;
2878 struct rte_port *port;
2879 struct rte_mempool *mp;
2880 unsigned int socket_id;
2884 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2887 if (res->portid == (portid_t)RTE_PORT_ALL) {
2888 fprintf(stderr, "Invalid port id\n");
2892 if (!strcmp(res->rxtxq, "rxq"))
2894 else if (!strcmp(res->rxtxq, "txq"))
2897 fprintf(stderr, "Unknown parameter\n");
2901 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2902 fprintf(stderr, "Invalid rx queue\n");
2904 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2905 fprintf(stderr, "Invalid tx queue\n");
2909 port = &ports[res->portid];
2911 socket_id = rxring_numa[res->portid];
2912 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2913 socket_id = port->socket_id;
2915 mp = mbuf_pool_find(socket_id, 0);
2918 "Failed to setup RX queue: No mempool allocation on the socket %d\n",
2919 rxring_numa[res->portid]);
2922 ret = rx_queue_setup(res->portid,
2924 port->nb_rx_desc[res->qid],
2926 &port->rxq[res->qid].conf,
2929 fprintf(stderr, "Failed to setup RX queue\n");
2931 socket_id = txring_numa[res->portid];
2932 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2933 socket_id = port->socket_id;
2935 if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
2937 "Failed to setup TX queue: not enough descriptors\n");
2940 ret = rte_eth_tx_queue_setup(res->portid,
2942 port->nb_tx_desc[res->qid],
2944 &port->txq[res->qid].conf);
2946 fprintf(stderr, "Failed to setup TX queue\n");
2950 static cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2951 .f = cmd_setup_rxtx_queue_parsed,
2953 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2955 (void *)&cmd_setup_rxtx_queue_port,
2956 (void *)&cmd_setup_rxtx_queue_portid,
2957 (void *)&cmd_setup_rxtx_queue_rxtxq,
2958 (void *)&cmd_setup_rxtx_queue_qid,
2959 (void *)&cmd_setup_rxtx_queue_setup,
2965 /* *** Configure RSS RETA *** */
2966 struct cmd_config_rss_reta {
2967 cmdline_fixed_string_t port;
2968 cmdline_fixed_string_t keyword;
2970 cmdline_fixed_string_t name;
2971 cmdline_fixed_string_t list_name;
2972 cmdline_fixed_string_t list_of_items;
2976 parse_reta_config(const char *str,
2977 struct rte_eth_rss_reta_entry64 *reta_conf,
2978 uint16_t nb_entries)
2982 uint16_t hash_index, idx, shift;
2985 const char *p, *p0 = str;
2992 unsigned long int_fld[_NUM_FLD];
2993 char *str_fld[_NUM_FLD];
2995 while ((p = strchr(p0,'(')) != NULL) {
2997 if((p0 = strchr(p,')')) == NULL)
3001 if(size >= sizeof(s))
3004 snprintf(s, sizeof(s), "%.*s", size, p);
3005 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
3007 for (i = 0; i < _NUM_FLD; i++) {
3009 int_fld[i] = strtoul(str_fld[i], &end, 0);
3010 if (errno != 0 || end == str_fld[i] ||
3015 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
3016 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
3018 if (hash_index >= nb_entries) {
3019 fprintf(stderr, "Invalid RETA hash index=%d\n",
3024 idx = hash_index / RTE_ETH_RETA_GROUP_SIZE;
3025 shift = hash_index % RTE_ETH_RETA_GROUP_SIZE;
3026 reta_conf[idx].mask |= (1ULL << shift);
3027 reta_conf[idx].reta[shift] = nb_queue;
3034 cmd_set_rss_reta_parsed(void *parsed_result,
3035 __rte_unused struct cmdline *cl,
3036 __rte_unused void *data)
3039 struct rte_eth_dev_info dev_info;
3040 struct rte_eth_rss_reta_entry64 reta_conf[8];
3041 struct cmd_config_rss_reta *res = parsed_result;
3043 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3047 if (dev_info.reta_size == 0) {
3049 "Redirection table size is 0 which is invalid for RSS\n");
3052 printf("The reta size of port %d is %u\n",
3053 res->port_id, dev_info.reta_size);
3054 if (dev_info.reta_size > RTE_ETH_RSS_RETA_SIZE_512) {
3056 "Currently do not support more than %u entries of redirection table\n",
3057 RTE_ETH_RSS_RETA_SIZE_512);
3061 memset(reta_conf, 0, sizeof(reta_conf));
3062 if (!strcmp(res->list_name, "reta")) {
3063 if (parse_reta_config(res->list_of_items, reta_conf,
3064 dev_info.reta_size)) {
3066 "Invalid RSS Redirection Table config entered\n");
3069 ret = rte_eth_dev_rss_reta_update(res->port_id,
3070 reta_conf, dev_info.reta_size);
3073 "Bad redirection table parameter, return code = %d\n",
3078 static cmdline_parse_token_string_t cmd_config_rss_reta_port =
3079 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3080 static cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3081 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3082 static cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3083 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3084 static cmdline_parse_token_string_t cmd_config_rss_reta_name =
3085 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3086 static cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3087 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3088 static cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3089 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3091 static cmdline_parse_inst_t cmd_config_rss_reta = {
3092 .f = cmd_set_rss_reta_parsed,
3094 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3096 (void *)&cmd_config_rss_reta_port,
3097 (void *)&cmd_config_rss_reta_keyword,
3098 (void *)&cmd_config_rss_reta_port_id,
3099 (void *)&cmd_config_rss_reta_name,
3100 (void *)&cmd_config_rss_reta_list_name,
3101 (void *)&cmd_config_rss_reta_list_of_items,
3106 /* *** SHOW PORT RETA INFO *** */
3107 struct cmd_showport_reta {
3108 cmdline_fixed_string_t show;
3109 cmdline_fixed_string_t port;
3111 cmdline_fixed_string_t rss;
3112 cmdline_fixed_string_t reta;
3114 cmdline_fixed_string_t list_of_items;
3118 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3119 uint16_t nb_entries,
3123 const char *p, *p0 = str;
3128 uint16_t num = (nb_entries + RTE_ETH_RETA_GROUP_SIZE - 1) /
3129 RTE_ETH_RETA_GROUP_SIZE;
3132 p = strchr(p0, '(');
3136 p0 = strchr(p, ')');
3140 if (size >= sizeof(s)) {
3142 "The string size exceeds the internal buffer size\n");
3145 snprintf(s, sizeof(s), "%.*s", size, p);
3146 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3147 if (ret <= 0 || ret != num) {
3149 "The bits of masks do not match the number of reta entries: %u\n",
3153 for (i = 0; i < ret; i++)
3154 conf[i].mask = (uint64_t)strtoull(str_fld[i], &end, 0);
3160 cmd_showport_reta_parsed(void *parsed_result,
3161 __rte_unused struct cmdline *cl,
3162 __rte_unused void *data)
3164 struct cmd_showport_reta *res = parsed_result;
3165 struct rte_eth_rss_reta_entry64 reta_conf[8];
3166 struct rte_eth_dev_info dev_info;
3167 uint16_t max_reta_size;
3170 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3174 max_reta_size = RTE_MIN(dev_info.reta_size, RTE_ETH_RSS_RETA_SIZE_512);
3175 if (res->size == 0 || res->size > max_reta_size) {
3176 fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n",
3177 res->size, max_reta_size);
3181 memset(reta_conf, 0, sizeof(reta_conf));
3182 if (showport_parse_reta_config(reta_conf, res->size,
3183 res->list_of_items) < 0) {
3184 fprintf(stderr, "Invalid string: %s for reta masks\n",
3185 res->list_of_items);
3188 port_rss_reta_info(res->port_id, reta_conf, res->size);
3191 static cmdline_parse_token_string_t cmd_showport_reta_show =
3192 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3193 static cmdline_parse_token_string_t cmd_showport_reta_port =
3194 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3195 static cmdline_parse_token_num_t cmd_showport_reta_port_id =
3196 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3197 static cmdline_parse_token_string_t cmd_showport_reta_rss =
3198 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3199 static cmdline_parse_token_string_t cmd_showport_reta_reta =
3200 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3201 static cmdline_parse_token_num_t cmd_showport_reta_size =
3202 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3203 static cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3204 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3205 list_of_items, NULL);
3207 static cmdline_parse_inst_t cmd_showport_reta = {
3208 .f = cmd_showport_reta_parsed,
3210 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3212 (void *)&cmd_showport_reta_show,
3213 (void *)&cmd_showport_reta_port,
3214 (void *)&cmd_showport_reta_port_id,
3215 (void *)&cmd_showport_reta_rss,
3216 (void *)&cmd_showport_reta_reta,
3217 (void *)&cmd_showport_reta_size,
3218 (void *)&cmd_showport_reta_list_of_items,
3223 /* *** Show RSS hash configuration *** */
3224 struct cmd_showport_rss_hash {
3225 cmdline_fixed_string_t show;
3226 cmdline_fixed_string_t port;
3228 cmdline_fixed_string_t rss_hash;
3229 cmdline_fixed_string_t rss_type;
3230 cmdline_fixed_string_t key; /* optional argument */
3233 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3234 __rte_unused struct cmdline *cl,
3237 struct cmd_showport_rss_hash *res = parsed_result;
3239 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3242 static cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3243 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3244 static cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3245 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3246 static cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3247 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3249 static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3250 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3252 static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3253 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3255 static cmdline_parse_inst_t cmd_showport_rss_hash = {
3256 .f = cmd_showport_rss_hash_parsed,
3258 .help_str = "show port <port_id> rss-hash",
3260 (void *)&cmd_showport_rss_hash_show,
3261 (void *)&cmd_showport_rss_hash_port,
3262 (void *)&cmd_showport_rss_hash_port_id,
3263 (void *)&cmd_showport_rss_hash_rss_hash,
3268 static cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3269 .f = cmd_showport_rss_hash_parsed,
3271 .help_str = "show port <port_id> rss-hash key",
3273 (void *)&cmd_showport_rss_hash_show,
3274 (void *)&cmd_showport_rss_hash_port,
3275 (void *)&cmd_showport_rss_hash_port_id,
3276 (void *)&cmd_showport_rss_hash_rss_hash,
3277 (void *)&cmd_showport_rss_hash_rss_key,
3282 /* *** Configure DCB *** */
3283 struct cmd_config_dcb {
3284 cmdline_fixed_string_t port;
3285 cmdline_fixed_string_t config;
3287 cmdline_fixed_string_t dcb;
3288 cmdline_fixed_string_t vt;
3289 cmdline_fixed_string_t vt_en;
3291 cmdline_fixed_string_t pfc;
3292 cmdline_fixed_string_t pfc_en;
3296 cmd_config_dcb_parsed(void *parsed_result,
3297 __rte_unused struct cmdline *cl,
3298 __rte_unused void *data)
3300 struct cmd_config_dcb *res = parsed_result;
3301 struct rte_eth_dcb_info dcb_info;
3302 portid_t port_id = res->port_id;
3303 struct rte_port *port;
3307 port = &ports[port_id];
3308 /** Check if the port is not started **/
3309 if (port->port_status != RTE_PORT_STOPPED) {
3310 fprintf(stderr, "Please stop port %d first\n", port_id);
3314 if ((res->num_tcs != RTE_ETH_4_TCS) && (res->num_tcs != RTE_ETH_8_TCS)) {
3316 "The invalid number of traffic class, only 4 or 8 allowed.\n");
3320 if (nb_fwd_lcores < res->num_tcs) {
3322 "nb_cores shouldn't be less than number of TCs.\n");
3326 /* Check whether the port supports the report of DCB info. */
3327 ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3328 if (ret == -ENOTSUP) {
3329 fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n");
3333 if (!strncmp(res->pfc_en, "on", 2))
3338 /* DCB in VT mode */
3339 if (!strncmp(res->vt_en, "on", 2))
3340 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3341 (enum rte_eth_nb_tcs)res->num_tcs,
3344 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3345 (enum rte_eth_nb_tcs)res->num_tcs,
3348 fprintf(stderr, "Cannot initialize network ports.\n");
3354 cmd_reconfig_device_queue(port_id, 1, 1);
3357 static cmdline_parse_token_string_t cmd_config_dcb_port =
3358 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3359 static cmdline_parse_token_string_t cmd_config_dcb_config =
3360 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3361 static cmdline_parse_token_num_t cmd_config_dcb_port_id =
3362 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3363 static cmdline_parse_token_string_t cmd_config_dcb_dcb =
3364 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3365 static cmdline_parse_token_string_t cmd_config_dcb_vt =
3366 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3367 static cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3368 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3369 static cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3370 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3371 static cmdline_parse_token_string_t cmd_config_dcb_pfc =
3372 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3373 static cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3374 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3376 static cmdline_parse_inst_t cmd_config_dcb = {
3377 .f = cmd_config_dcb_parsed,
3379 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3381 (void *)&cmd_config_dcb_port,
3382 (void *)&cmd_config_dcb_config,
3383 (void *)&cmd_config_dcb_port_id,
3384 (void *)&cmd_config_dcb_dcb,
3385 (void *)&cmd_config_dcb_vt,
3386 (void *)&cmd_config_dcb_vt_en,
3387 (void *)&cmd_config_dcb_num_tcs,
3388 (void *)&cmd_config_dcb_pfc,
3389 (void *)&cmd_config_dcb_pfc_en,
3394 /* *** configure number of packets per burst *** */
3395 struct cmd_config_burst {
3396 cmdline_fixed_string_t port;
3397 cmdline_fixed_string_t keyword;
3398 cmdline_fixed_string_t all;
3399 cmdline_fixed_string_t name;
3404 cmd_config_burst_parsed(void *parsed_result,
3405 __rte_unused struct cmdline *cl,
3406 __rte_unused void *data)
3408 struct cmd_config_burst *res = parsed_result;
3409 struct rte_eth_dev_info dev_info;
3410 uint16_t rec_nb_pkts;
3413 if (!all_ports_stopped()) {
3414 fprintf(stderr, "Please stop all ports first\n");
3418 if (!strcmp(res->name, "burst")) {
3419 if (res->value == 0) {
3420 /* If user gives a value of zero, query the PMD for
3421 * its recommended Rx burst size. Testpmd uses a single
3422 * size for all ports, so assume all ports are the same
3423 * NIC model and use the values from Port 0.
3425 ret = eth_dev_info_get_print_err(0, &dev_info);
3429 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3431 if (rec_nb_pkts == 0) {
3432 printf("PMD does not recommend a burst size.\n"
3433 "User provided value must be between"
3434 " 1 and %d\n", MAX_PKT_BURST);
3436 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3437 printf("PMD recommended burst size of %d"
3438 " exceeds maximum value of %d\n",
3439 rec_nb_pkts, MAX_PKT_BURST);
3442 printf("Using PMD-provided burst value of %d\n",
3444 nb_pkt_per_burst = rec_nb_pkts;
3445 } else if (res->value > MAX_PKT_BURST) {
3446 fprintf(stderr, "burst must be >= 1 && <= %d\n",
3450 nb_pkt_per_burst = res->value;
3452 fprintf(stderr, "Unknown parameter\n");
3458 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3461 static cmdline_parse_token_string_t cmd_config_burst_port =
3462 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3463 static cmdline_parse_token_string_t cmd_config_burst_keyword =
3464 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3465 static cmdline_parse_token_string_t cmd_config_burst_all =
3466 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3467 static cmdline_parse_token_string_t cmd_config_burst_name =
3468 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3469 static cmdline_parse_token_num_t cmd_config_burst_value =
3470 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3472 static cmdline_parse_inst_t cmd_config_burst = {
3473 .f = cmd_config_burst_parsed,
3475 .help_str = "port config all burst <value>",
3477 (void *)&cmd_config_burst_port,
3478 (void *)&cmd_config_burst_keyword,
3479 (void *)&cmd_config_burst_all,
3480 (void *)&cmd_config_burst_name,
3481 (void *)&cmd_config_burst_value,
3486 /* *** configure rx/tx queues *** */
3487 struct cmd_config_thresh {
3488 cmdline_fixed_string_t port;
3489 cmdline_fixed_string_t keyword;
3490 cmdline_fixed_string_t all;
3491 cmdline_fixed_string_t name;
3496 cmd_config_thresh_parsed(void *parsed_result,
3497 __rte_unused struct cmdline *cl,
3498 __rte_unused void *data)
3500 struct cmd_config_thresh *res = parsed_result;
3502 if (!all_ports_stopped()) {
3503 fprintf(stderr, "Please stop all ports first\n");
3507 if (!strcmp(res->name, "txpt"))
3508 tx_pthresh = res->value;
3509 else if(!strcmp(res->name, "txht"))
3510 tx_hthresh = res->value;
3511 else if(!strcmp(res->name, "txwt"))
3512 tx_wthresh = res->value;
3513 else if(!strcmp(res->name, "rxpt"))
3514 rx_pthresh = res->value;
3515 else if(!strcmp(res->name, "rxht"))
3516 rx_hthresh = res->value;
3517 else if(!strcmp(res->name, "rxwt"))
3518 rx_wthresh = res->value;
3520 fprintf(stderr, "Unknown parameter\n");
3526 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3529 static cmdline_parse_token_string_t cmd_config_thresh_port =
3530 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3531 static cmdline_parse_token_string_t cmd_config_thresh_keyword =
3532 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3533 static cmdline_parse_token_string_t cmd_config_thresh_all =
3534 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3535 static cmdline_parse_token_string_t cmd_config_thresh_name =
3536 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3537 "txpt#txht#txwt#rxpt#rxht#rxwt");
3538 static cmdline_parse_token_num_t cmd_config_thresh_value =
3539 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3541 static cmdline_parse_inst_t cmd_config_thresh = {
3542 .f = cmd_config_thresh_parsed,
3544 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3546 (void *)&cmd_config_thresh_port,
3547 (void *)&cmd_config_thresh_keyword,
3548 (void *)&cmd_config_thresh_all,
3549 (void *)&cmd_config_thresh_name,
3550 (void *)&cmd_config_thresh_value,
3555 /* *** configure free/rs threshold *** */
3556 struct cmd_config_threshold {
3557 cmdline_fixed_string_t port;
3558 cmdline_fixed_string_t keyword;
3559 cmdline_fixed_string_t all;
3560 cmdline_fixed_string_t name;
3565 cmd_config_threshold_parsed(void *parsed_result,
3566 __rte_unused struct cmdline *cl,
3567 __rte_unused void *data)
3569 struct cmd_config_threshold *res = parsed_result;
3571 if (!all_ports_stopped()) {
3572 fprintf(stderr, "Please stop all ports first\n");
3576 if (!strcmp(res->name, "txfreet"))
3577 tx_free_thresh = res->value;
3578 else if (!strcmp(res->name, "txrst"))
3579 tx_rs_thresh = res->value;
3580 else if (!strcmp(res->name, "rxfreet"))
3581 rx_free_thresh = res->value;
3583 fprintf(stderr, "Unknown parameter\n");
3589 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3592 static cmdline_parse_token_string_t cmd_config_threshold_port =
3593 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3594 static cmdline_parse_token_string_t cmd_config_threshold_keyword =
3595 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3597 static cmdline_parse_token_string_t cmd_config_threshold_all =
3598 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3599 static cmdline_parse_token_string_t cmd_config_threshold_name =
3600 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3601 "txfreet#txrst#rxfreet");
3602 static cmdline_parse_token_num_t cmd_config_threshold_value =
3603 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3605 static cmdline_parse_inst_t cmd_config_threshold = {
3606 .f = cmd_config_threshold_parsed,
3608 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3610 (void *)&cmd_config_threshold_port,
3611 (void *)&cmd_config_threshold_keyword,
3612 (void *)&cmd_config_threshold_all,
3613 (void *)&cmd_config_threshold_name,
3614 (void *)&cmd_config_threshold_value,
3620 struct cmd_stop_result {
3621 cmdline_fixed_string_t stop;
3624 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3625 __rte_unused struct cmdline *cl,
3626 __rte_unused void *data)
3628 stop_packet_forwarding();
3631 static cmdline_parse_token_string_t cmd_stop_stop =
3632 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3634 static cmdline_parse_inst_t cmd_stop = {
3635 .f = cmd_stop_parsed,
3637 .help_str = "stop: Stop packet forwarding",
3639 (void *)&cmd_stop_stop,
3644 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3647 parse_item_list(const char *str, const char *item_name, unsigned int max_items,
3648 unsigned int *parsed_items, int check_unique_values)
3650 unsigned int nb_item;
3658 * First parse all items in the list and store their value.
3663 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3665 if ((c >= '0') && (c <= '9')) {
3666 value = (unsigned int) (value * 10 + (c - '0'));
3671 fprintf(stderr, "character %c is not a decimal digit\n", c);
3675 fprintf(stderr, "No valid value before comma\n");
3678 if (nb_item < max_items) {
3679 parsed_items[nb_item] = value;
3685 if (nb_item >= max_items) {
3686 fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
3687 item_name, nb_item + 1, max_items);
3690 parsed_items[nb_item++] = value;
3691 if (! check_unique_values)
3695 * Then, check that all values in the list are different.
3696 * No optimization here...
3698 for (i = 0; i < nb_item; i++) {
3699 for (j = i + 1; j < nb_item; j++) {
3700 if (parsed_items[j] == parsed_items[i]) {
3702 "duplicated %s %u at index %u and %u\n",
3703 item_name, parsed_items[i], i, j);
3711 struct cmd_set_list_result {
3712 cmdline_fixed_string_t cmd_keyword;
3713 cmdline_fixed_string_t list_name;
3714 cmdline_fixed_string_t list_of_items;
3717 static void cmd_set_list_parsed(void *parsed_result,
3718 __rte_unused struct cmdline *cl,
3719 __rte_unused void *data)
3721 struct cmd_set_list_result *res;
3723 unsigned int lcorelist[RTE_MAX_LCORE];
3724 unsigned int portlist[RTE_MAX_ETHPORTS];
3726 unsigned int nb_item;
3728 if (test_done == 0) {
3729 fprintf(stderr, "Please stop forwarding first\n");
3733 res = parsed_result;
3734 if (!strcmp(res->list_name, "corelist")) {
3735 nb_item = parse_item_list(res->list_of_items, "core",
3737 parsed_items.lcorelist, 1);
3739 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3744 if (!strcmp(res->list_name, "portlist")) {
3745 nb_item = parse_item_list(res->list_of_items, "port",
3747 parsed_items.portlist, 1);
3749 set_fwd_ports_list(parsed_items.portlist, nb_item);
3755 static cmdline_parse_token_string_t cmd_set_list_keyword =
3756 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3758 static cmdline_parse_token_string_t cmd_set_list_name =
3759 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3760 "corelist#portlist");
3761 static cmdline_parse_token_string_t cmd_set_list_of_items =
3762 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3765 static cmdline_parse_inst_t cmd_set_fwd_list = {
3766 .f = cmd_set_list_parsed,
3768 .help_str = "set corelist|portlist <list0[,list1]*>",
3770 (void *)&cmd_set_list_keyword,
3771 (void *)&cmd_set_list_name,
3772 (void *)&cmd_set_list_of_items,
3777 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3779 struct cmd_setmask_result {
3780 cmdline_fixed_string_t set;
3781 cmdline_fixed_string_t mask;
3785 static void cmd_set_mask_parsed(void *parsed_result,
3786 __rte_unused struct cmdline *cl,
3787 __rte_unused void *data)
3789 struct cmd_setmask_result *res = parsed_result;
3791 if (test_done == 0) {
3792 fprintf(stderr, "Please stop forwarding first\n");
3795 if (!strcmp(res->mask, "coremask")) {
3796 set_fwd_lcores_mask(res->hexavalue);
3798 } else if (!strcmp(res->mask, "portmask")) {
3799 set_fwd_ports_mask(res->hexavalue);
3804 static cmdline_parse_token_string_t cmd_setmask_set =
3805 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3806 static cmdline_parse_token_string_t cmd_setmask_mask =
3807 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3808 "coremask#portmask");
3809 static cmdline_parse_token_num_t cmd_setmask_value =
3810 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3812 static cmdline_parse_inst_t cmd_set_fwd_mask = {
3813 .f = cmd_set_mask_parsed,
3815 .help_str = "set coremask|portmask <hexadecimal value>",
3817 (void *)&cmd_setmask_set,
3818 (void *)&cmd_setmask_mask,
3819 (void *)&cmd_setmask_value,
3825 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3827 struct cmd_set_result {
3828 cmdline_fixed_string_t set;
3829 cmdline_fixed_string_t what;
3833 static void cmd_set_parsed(void *parsed_result,
3834 __rte_unused struct cmdline *cl,
3835 __rte_unused void *data)
3837 struct cmd_set_result *res = parsed_result;
3838 if (!strcmp(res->what, "nbport")) {
3839 set_fwd_ports_number(res->value);
3841 } else if (!strcmp(res->what, "nbcore")) {
3842 set_fwd_lcores_number(res->value);
3844 } else if (!strcmp(res->what, "burst"))
3845 set_nb_pkt_per_burst(res->value);
3846 else if (!strcmp(res->what, "verbose"))
3847 set_verbose_level(res->value);
3850 static cmdline_parse_token_string_t cmd_set_set =
3851 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3852 static cmdline_parse_token_string_t cmd_set_what =
3853 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3854 "nbport#nbcore#burst#verbose");
3855 static cmdline_parse_token_num_t cmd_set_value =
3856 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3858 static cmdline_parse_inst_t cmd_set_numbers = {
3859 .f = cmd_set_parsed,
3861 .help_str = "set nbport|nbcore|burst|verbose <value>",
3863 (void *)&cmd_set_set,
3864 (void *)&cmd_set_what,
3865 (void *)&cmd_set_value,
3870 /* *** SET LOG LEVEL CONFIGURATION *** */
3872 struct cmd_set_log_result {
3873 cmdline_fixed_string_t set;
3874 cmdline_fixed_string_t log;
3875 cmdline_fixed_string_t type;
3880 cmd_set_log_parsed(void *parsed_result,
3881 __rte_unused struct cmdline *cl,
3882 __rte_unused void *data)
3884 struct cmd_set_log_result *res;
3887 res = parsed_result;
3888 if (!strcmp(res->type, "global"))
3889 rte_log_set_global_level(res->level);
3891 ret = rte_log_set_level_regexp(res->type, res->level);
3893 fprintf(stderr, "Unable to set log level\n");
3897 static cmdline_parse_token_string_t cmd_set_log_set =
3898 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3899 static cmdline_parse_token_string_t cmd_set_log_log =
3900 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3901 static cmdline_parse_token_string_t cmd_set_log_type =
3902 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3903 static cmdline_parse_token_num_t cmd_set_log_level =
3904 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3906 static cmdline_parse_inst_t cmd_set_log = {
3907 .f = cmd_set_log_parsed,
3909 .help_str = "set log global|<type> <level>",
3911 (void *)&cmd_set_log_set,
3912 (void *)&cmd_set_log_log,
3913 (void *)&cmd_set_log_type,
3914 (void *)&cmd_set_log_level,
3919 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3921 struct cmd_set_rxoffs_result {
3922 cmdline_fixed_string_t cmd_keyword;
3923 cmdline_fixed_string_t rxoffs;
3924 cmdline_fixed_string_t seg_offsets;
3928 cmd_set_rxoffs_parsed(void *parsed_result,
3929 __rte_unused struct cmdline *cl,
3930 __rte_unused void *data)
3932 struct cmd_set_rxoffs_result *res;
3933 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3934 unsigned int nb_segs;
3936 res = parsed_result;
3937 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3938 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3940 set_rx_pkt_offsets(seg_offsets, nb_segs);
3941 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3944 static cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3945 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3946 cmd_keyword, "set");
3947 static cmdline_parse_token_string_t cmd_set_rxoffs_name =
3948 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3950 static cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3951 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3954 static cmdline_parse_inst_t cmd_set_rxoffs = {
3955 .f = cmd_set_rxoffs_parsed,
3957 .help_str = "set rxoffs <len0[,len1]*>",
3959 (void *)&cmd_set_rxoffs_keyword,
3960 (void *)&cmd_set_rxoffs_name,
3961 (void *)&cmd_set_rxoffs_offsets,
3966 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3968 struct cmd_set_rxpkts_result {
3969 cmdline_fixed_string_t cmd_keyword;
3970 cmdline_fixed_string_t rxpkts;
3971 cmdline_fixed_string_t seg_lengths;
3975 cmd_set_rxpkts_parsed(void *parsed_result,
3976 __rte_unused struct cmdline *cl,
3977 __rte_unused void *data)
3979 struct cmd_set_rxpkts_result *res;
3980 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3981 unsigned int nb_segs;
3983 res = parsed_result;
3984 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3985 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3987 set_rx_pkt_segments(seg_lengths, nb_segs);
3988 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3991 static cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3992 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3993 cmd_keyword, "set");
3994 static cmdline_parse_token_string_t cmd_set_rxpkts_name =
3995 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3997 static cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3998 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4001 static cmdline_parse_inst_t cmd_set_rxpkts = {
4002 .f = cmd_set_rxpkts_parsed,
4004 .help_str = "set rxpkts <len0[,len1]*>",
4006 (void *)&cmd_set_rxpkts_keyword,
4007 (void *)&cmd_set_rxpkts_name,
4008 (void *)&cmd_set_rxpkts_lengths,
4013 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
4015 struct cmd_set_txpkts_result {
4016 cmdline_fixed_string_t cmd_keyword;
4017 cmdline_fixed_string_t txpkts;
4018 cmdline_fixed_string_t seg_lengths;
4022 cmd_set_txpkts_parsed(void *parsed_result,
4023 __rte_unused struct cmdline *cl,
4024 __rte_unused void *data)
4026 struct cmd_set_txpkts_result *res;
4027 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
4028 unsigned int nb_segs;
4030 res = parsed_result;
4031 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4032 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4034 set_tx_pkt_segments(seg_lengths, nb_segs);
4037 static cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4038 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4039 cmd_keyword, "set");
4040 static cmdline_parse_token_string_t cmd_set_txpkts_name =
4041 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4043 static cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4044 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4047 static cmdline_parse_inst_t cmd_set_txpkts = {
4048 .f = cmd_set_txpkts_parsed,
4050 .help_str = "set txpkts <len0[,len1]*>",
4052 (void *)&cmd_set_txpkts_keyword,
4053 (void *)&cmd_set_txpkts_name,
4054 (void *)&cmd_set_txpkts_lengths,
4059 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4061 struct cmd_set_txsplit_result {
4062 cmdline_fixed_string_t cmd_keyword;
4063 cmdline_fixed_string_t txsplit;
4064 cmdline_fixed_string_t mode;
4068 cmd_set_txsplit_parsed(void *parsed_result,
4069 __rte_unused struct cmdline *cl,
4070 __rte_unused void *data)
4072 struct cmd_set_txsplit_result *res;
4074 res = parsed_result;
4075 set_tx_pkt_split(res->mode);
4078 static cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4079 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4080 cmd_keyword, "set");
4081 static cmdline_parse_token_string_t cmd_set_txsplit_name =
4082 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4083 txsplit, "txsplit");
4084 static cmdline_parse_token_string_t cmd_set_txsplit_mode =
4085 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4088 static cmdline_parse_inst_t cmd_set_txsplit = {
4089 .f = cmd_set_txsplit_parsed,
4091 .help_str = "set txsplit on|off|rand",
4093 (void *)&cmd_set_txsplit_keyword,
4094 (void *)&cmd_set_txsplit_name,
4095 (void *)&cmd_set_txsplit_mode,
4100 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4102 struct cmd_set_txtimes_result {
4103 cmdline_fixed_string_t cmd_keyword;
4104 cmdline_fixed_string_t txtimes;
4105 cmdline_fixed_string_t tx_times;
4109 cmd_set_txtimes_parsed(void *parsed_result,
4110 __rte_unused struct cmdline *cl,
4111 __rte_unused void *data)
4113 struct cmd_set_txtimes_result *res;
4114 unsigned int tx_times[2] = {0, 0};
4115 unsigned int n_times;
4117 res = parsed_result;
4118 n_times = parse_item_list(res->tx_times, "tx times",
4121 set_tx_pkt_times(tx_times);
4124 static cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4125 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4126 cmd_keyword, "set");
4127 static cmdline_parse_token_string_t cmd_set_txtimes_name =
4128 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4129 txtimes, "txtimes");
4130 static cmdline_parse_token_string_t cmd_set_txtimes_value =
4131 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4134 static cmdline_parse_inst_t cmd_set_txtimes = {
4135 .f = cmd_set_txtimes_parsed,
4137 .help_str = "set txtimes <inter_burst>,<intra_burst>",
4139 (void *)&cmd_set_txtimes_keyword,
4140 (void *)&cmd_set_txtimes_name,
4141 (void *)&cmd_set_txtimes_value,
4146 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4147 struct cmd_rx_vlan_filter_all_result {
4148 cmdline_fixed_string_t rx_vlan;
4149 cmdline_fixed_string_t what;
4150 cmdline_fixed_string_t all;
4155 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4156 __rte_unused struct cmdline *cl,
4157 __rte_unused void *data)
4159 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4161 if (!strcmp(res->what, "add"))
4162 rx_vlan_all_filter_set(res->port_id, 1);
4164 rx_vlan_all_filter_set(res->port_id, 0);
4167 static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4168 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4169 rx_vlan, "rx_vlan");
4170 static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4171 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4173 static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4174 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4176 static cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4177 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4178 port_id, RTE_UINT16);
4180 static cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4181 .f = cmd_rx_vlan_filter_all_parsed,
4183 .help_str = "rx_vlan add|rm all <port_id>: "
4184 "Add/Remove all identifiers to/from the set of VLAN "
4185 "identifiers filtered by a port",
4187 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4188 (void *)&cmd_rx_vlan_filter_all_what,
4189 (void *)&cmd_rx_vlan_filter_all_all,
4190 (void *)&cmd_rx_vlan_filter_all_portid,
4195 /* *** VLAN OFFLOAD SET ON A PORT *** */
4196 struct cmd_vlan_offload_result {
4197 cmdline_fixed_string_t vlan;
4198 cmdline_fixed_string_t set;
4199 cmdline_fixed_string_t vlan_type;
4200 cmdline_fixed_string_t what;
4201 cmdline_fixed_string_t on;
4202 cmdline_fixed_string_t port_id;
4206 cmd_vlan_offload_parsed(void *parsed_result,
4207 __rte_unused struct cmdline *cl,
4208 __rte_unused void *data)
4211 struct cmd_vlan_offload_result *res = parsed_result;
4214 portid_t port_id = 0;
4218 len = strnlen(str, STR_TOKEN_SIZE);
4220 /* Get port_id first */
4228 tmp = strtoul(str, NULL, 0);
4229 /* If port_id greater that what portid_t can represent, return */
4230 if(tmp >= RTE_MAX_ETHPORTS)
4232 port_id = (portid_t)tmp;
4234 if (!strcmp(res->on, "on"))
4239 if (!strcmp(res->what, "strip"))
4240 rx_vlan_strip_set(port_id, on);
4241 else if(!strcmp(res->what, "stripq")){
4242 uint16_t queue_id = 0;
4244 /* No queue_id, return */
4246 fprintf(stderr, "must specify (port,queue_id)\n");
4249 tmp = strtoul(str + i + 1, NULL, 0);
4250 /* If queue_id greater that what 16-bits can represent, return */
4254 queue_id = (uint16_t)tmp;
4255 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4257 else if (!strcmp(res->what, "filter"))
4258 rx_vlan_filter_set(port_id, on);
4259 else if (!strcmp(res->what, "qinq_strip"))
4260 rx_vlan_qinq_strip_set(port_id, on);
4262 vlan_extend_set(port_id, on);
4267 static cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4268 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4270 static cmdline_parse_token_string_t cmd_vlan_offload_set =
4271 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4273 static cmdline_parse_token_string_t cmd_vlan_offload_what =
4274 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4275 what, "strip#filter#qinq_strip#extend#stripq");
4276 static cmdline_parse_token_string_t cmd_vlan_offload_on =
4277 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4279 static cmdline_parse_token_string_t cmd_vlan_offload_portid =
4280 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4283 static cmdline_parse_inst_t cmd_vlan_offload = {
4284 .f = cmd_vlan_offload_parsed,
4286 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4287 "<port_id[,queue_id]>: "
4288 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4290 (void *)&cmd_vlan_offload_vlan,
4291 (void *)&cmd_vlan_offload_set,
4292 (void *)&cmd_vlan_offload_what,
4293 (void *)&cmd_vlan_offload_on,
4294 (void *)&cmd_vlan_offload_portid,
4299 /* *** VLAN TPID SET ON A PORT *** */
4300 struct cmd_vlan_tpid_result {
4301 cmdline_fixed_string_t vlan;
4302 cmdline_fixed_string_t set;
4303 cmdline_fixed_string_t vlan_type;
4304 cmdline_fixed_string_t what;
4310 cmd_vlan_tpid_parsed(void *parsed_result,
4311 __rte_unused struct cmdline *cl,
4312 __rte_unused void *data)
4314 struct cmd_vlan_tpid_result *res = parsed_result;
4315 enum rte_vlan_type vlan_type;
4317 if (!strcmp(res->vlan_type, "inner"))
4318 vlan_type = RTE_ETH_VLAN_TYPE_INNER;
4319 else if (!strcmp(res->vlan_type, "outer"))
4320 vlan_type = RTE_ETH_VLAN_TYPE_OUTER;
4322 fprintf(stderr, "Unknown vlan type\n");
4325 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4328 static cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4329 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4331 static cmdline_parse_token_string_t cmd_vlan_tpid_set =
4332 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4334 static cmdline_parse_token_string_t cmd_vlan_type =
4335 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4336 vlan_type, "inner#outer");
4337 static cmdline_parse_token_string_t cmd_vlan_tpid_what =
4338 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4340 static cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4341 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4343 static cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4344 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4345 port_id, RTE_UINT16);
4347 static cmdline_parse_inst_t cmd_vlan_tpid = {
4348 .f = cmd_vlan_tpid_parsed,
4350 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4351 "Set the VLAN Ether type",
4353 (void *)&cmd_vlan_tpid_vlan,
4354 (void *)&cmd_vlan_tpid_set,
4355 (void *)&cmd_vlan_type,
4356 (void *)&cmd_vlan_tpid_what,
4357 (void *)&cmd_vlan_tpid_tpid,
4358 (void *)&cmd_vlan_tpid_portid,
4363 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4364 struct cmd_rx_vlan_filter_result {
4365 cmdline_fixed_string_t rx_vlan;
4366 cmdline_fixed_string_t what;
4372 cmd_rx_vlan_filter_parsed(void *parsed_result,
4373 __rte_unused struct cmdline *cl,
4374 __rte_unused void *data)
4376 struct cmd_rx_vlan_filter_result *res = parsed_result;
4378 if (!strcmp(res->what, "add"))
4379 rx_vft_set(res->port_id, res->vlan_id, 1);
4381 rx_vft_set(res->port_id, res->vlan_id, 0);
4384 static cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4385 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4386 rx_vlan, "rx_vlan");
4387 static cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4388 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4390 static cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4391 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4392 vlan_id, RTE_UINT16);
4393 static cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4394 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4395 port_id, RTE_UINT16);
4397 static cmdline_parse_inst_t cmd_rx_vlan_filter = {
4398 .f = cmd_rx_vlan_filter_parsed,
4400 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4401 "Add/Remove a VLAN identifier to/from the set of VLAN "
4402 "identifiers filtered by a port",
4404 (void *)&cmd_rx_vlan_filter_rx_vlan,
4405 (void *)&cmd_rx_vlan_filter_what,
4406 (void *)&cmd_rx_vlan_filter_vlanid,
4407 (void *)&cmd_rx_vlan_filter_portid,
4412 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4413 struct cmd_tx_vlan_set_result {
4414 cmdline_fixed_string_t tx_vlan;
4415 cmdline_fixed_string_t set;
4421 cmd_tx_vlan_set_parsed(void *parsed_result,
4422 __rte_unused struct cmdline *cl,
4423 __rte_unused void *data)
4425 struct cmd_tx_vlan_set_result *res = parsed_result;
4427 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4430 if (!port_is_stopped(res->port_id)) {
4431 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4435 tx_vlan_set(res->port_id, res->vlan_id);
4437 cmd_reconfig_device_queue(res->port_id, 1, 1);
4440 static cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4441 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4442 tx_vlan, "tx_vlan");
4443 static cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4444 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4446 static cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4447 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4448 port_id, RTE_UINT16);
4449 static cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4450 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4451 vlan_id, RTE_UINT16);
4453 static cmdline_parse_inst_t cmd_tx_vlan_set = {
4454 .f = cmd_tx_vlan_set_parsed,
4456 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4457 "Enable hardware insertion of a single VLAN header "
4458 "with a given TAG Identifier in packets sent on a port",
4460 (void *)&cmd_tx_vlan_set_tx_vlan,
4461 (void *)&cmd_tx_vlan_set_set,
4462 (void *)&cmd_tx_vlan_set_portid,
4463 (void *)&cmd_tx_vlan_set_vlanid,
4468 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4469 struct cmd_tx_vlan_set_qinq_result {
4470 cmdline_fixed_string_t tx_vlan;
4471 cmdline_fixed_string_t set;
4474 uint16_t vlan_id_outer;
4478 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4479 __rte_unused struct cmdline *cl,
4480 __rte_unused void *data)
4482 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4484 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4487 if (!port_is_stopped(res->port_id)) {
4488 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4492 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4494 cmd_reconfig_device_queue(res->port_id, 1, 1);
4497 static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4498 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4499 tx_vlan, "tx_vlan");
4500 static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4501 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4503 static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4504 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4505 port_id, RTE_UINT16);
4506 static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4507 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4508 vlan_id, RTE_UINT16);
4509 static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4510 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4511 vlan_id_outer, RTE_UINT16);
4513 static cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4514 .f = cmd_tx_vlan_set_qinq_parsed,
4516 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4517 "Enable hardware insertion of double VLAN header "
4518 "with given TAG Identifiers in packets sent on a port",
4520 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4521 (void *)&cmd_tx_vlan_set_qinq_set,
4522 (void *)&cmd_tx_vlan_set_qinq_portid,
4523 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4524 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4529 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4530 struct cmd_tx_vlan_set_pvid_result {
4531 cmdline_fixed_string_t tx_vlan;
4532 cmdline_fixed_string_t set;
4533 cmdline_fixed_string_t pvid;
4536 cmdline_fixed_string_t mode;
4540 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4541 __rte_unused struct cmdline *cl,
4542 __rte_unused void *data)
4544 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4546 if (strcmp(res->mode, "on") == 0)
4547 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4549 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4552 static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4553 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4554 tx_vlan, "tx_vlan");
4555 static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4556 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4558 static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4559 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4561 static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4562 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4563 port_id, RTE_UINT16);
4564 static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4565 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4566 vlan_id, RTE_UINT16);
4567 static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4568 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4571 static cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4572 .f = cmd_tx_vlan_set_pvid_parsed,
4574 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4576 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4577 (void *)&cmd_tx_vlan_set_pvid_set,
4578 (void *)&cmd_tx_vlan_set_pvid_pvid,
4579 (void *)&cmd_tx_vlan_set_pvid_port_id,
4580 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4581 (void *)&cmd_tx_vlan_set_pvid_mode,
4586 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4587 struct cmd_tx_vlan_reset_result {
4588 cmdline_fixed_string_t tx_vlan;
4589 cmdline_fixed_string_t reset;
4594 cmd_tx_vlan_reset_parsed(void *parsed_result,
4595 __rte_unused struct cmdline *cl,
4596 __rte_unused void *data)
4598 struct cmd_tx_vlan_reset_result *res = parsed_result;
4600 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4603 if (!port_is_stopped(res->port_id)) {
4604 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4608 tx_vlan_reset(res->port_id);
4610 cmd_reconfig_device_queue(res->port_id, 1, 1);
4613 static cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4614 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4615 tx_vlan, "tx_vlan");
4616 static cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4617 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4619 static cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4620 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4621 port_id, RTE_UINT16);
4623 static cmdline_parse_inst_t cmd_tx_vlan_reset = {
4624 .f = cmd_tx_vlan_reset_parsed,
4626 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4627 "VLAN header in packets sent on a port",
4629 (void *)&cmd_tx_vlan_reset_tx_vlan,
4630 (void *)&cmd_tx_vlan_reset_reset,
4631 (void *)&cmd_tx_vlan_reset_portid,
4637 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4638 struct cmd_csum_result {
4639 cmdline_fixed_string_t csum;
4640 cmdline_fixed_string_t mode;
4641 cmdline_fixed_string_t proto;
4642 cmdline_fixed_string_t hwsw;
4647 csum_show(int port_id)
4649 struct rte_eth_dev_info dev_info;
4650 uint64_t tx_offloads;
4653 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4654 printf("Parse tunnel is %s\n",
4655 (ports[port_id].parse_tunnel) ? "on" : "off");
4656 printf("IP checksum offload is %s\n",
4657 (tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4658 printf("UDP checksum offload is %s\n",
4659 (tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4660 printf("TCP checksum offload is %s\n",
4661 (tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4662 printf("SCTP checksum offload is %s\n",
4663 (tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4664 printf("Outer-Ip checksum offload is %s\n",
4665 (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4666 printf("Outer-Udp checksum offload is %s\n",
4667 (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4669 /* display warnings if configuration is not supported by the NIC */
4670 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4674 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) &&
4675 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4677 "Warning: hardware IP checksum enabled but not supported by port %d\n",
4680 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) &&
4681 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) == 0) {
4683 "Warning: hardware UDP checksum enabled but not supported by port %d\n",
4686 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) &&
4687 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) == 0) {
4689 "Warning: hardware TCP checksum enabled but not supported by port %d\n",
4692 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) &&
4693 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4695 "Warning: hardware SCTP checksum enabled but not supported by port %d\n",
4698 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4699 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4701 "Warning: hardware outer IP checksum enabled but not supported by port %d\n",
4704 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4705 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)
4708 "Warning: hardware outer UDP checksum enabled but not supported by port %d\n",
4714 cmd_config_queue_tx_offloads(struct rte_port *port)
4718 /* Apply queue tx offloads configuration */
4719 for (k = 0; k < port->dev_info.max_tx_queues; k++)
4720 port->txq[k].conf.offloads =
4721 port->dev_conf.txmode.offloads;
4725 cmd_csum_parsed(void *parsed_result,
4726 __rte_unused struct cmdline *cl,
4727 __rte_unused void *data)
4729 struct cmd_csum_result *res = parsed_result;
4731 uint64_t csum_offloads = 0;
4732 struct rte_eth_dev_info dev_info;
4735 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4736 fprintf(stderr, "invalid port %d\n", res->port_id);
4739 if (!port_is_stopped(res->port_id)) {
4740 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4744 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4748 if (!strcmp(res->mode, "set")) {
4750 if (!strcmp(res->hwsw, "hw"))
4753 if (!strcmp(res->proto, "ip")) {
4754 if (hw == 0 || (dev_info.tx_offload_capa &
4755 RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)) {
4756 csum_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
4759 "IP checksum offload is not supported by port %u\n",
4762 } else if (!strcmp(res->proto, "udp")) {
4763 if (hw == 0 || (dev_info.tx_offload_capa &
4764 RTE_ETH_TX_OFFLOAD_UDP_CKSUM)) {
4765 csum_offloads |= RTE_ETH_TX_OFFLOAD_UDP_CKSUM;
4768 "UDP checksum offload is not supported by port %u\n",
4771 } else if (!strcmp(res->proto, "tcp")) {
4772 if (hw == 0 || (dev_info.tx_offload_capa &
4773 RTE_ETH_TX_OFFLOAD_TCP_CKSUM)) {
4774 csum_offloads |= RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
4777 "TCP checksum offload is not supported by port %u\n",
4780 } else if (!strcmp(res->proto, "sctp")) {
4781 if (hw == 0 || (dev_info.tx_offload_capa &
4782 RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) {
4783 csum_offloads |= RTE_ETH_TX_OFFLOAD_SCTP_CKSUM;
4786 "SCTP checksum offload is not supported by port %u\n",
4789 } else if (!strcmp(res->proto, "outer-ip")) {
4790 if (hw == 0 || (dev_info.tx_offload_capa &
4791 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4793 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4796 "Outer IP checksum offload is not supported by port %u\n",
4799 } else if (!strcmp(res->proto, "outer-udp")) {
4800 if (hw == 0 || (dev_info.tx_offload_capa &
4801 RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4803 RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM;
4806 "Outer UDP checksum offload is not supported by port %u\n",
4812 ports[res->port_id].dev_conf.txmode.offloads |=
4815 ports[res->port_id].dev_conf.txmode.offloads &=
4818 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4820 csum_show(res->port_id);
4822 cmd_reconfig_device_queue(res->port_id, 1, 1);
4825 static cmdline_parse_token_string_t cmd_csum_csum =
4826 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4828 static cmdline_parse_token_string_t cmd_csum_mode =
4829 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4831 static cmdline_parse_token_string_t cmd_csum_proto =
4832 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4833 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4834 static cmdline_parse_token_string_t cmd_csum_hwsw =
4835 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4837 static cmdline_parse_token_num_t cmd_csum_portid =
4838 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4839 port_id, RTE_UINT16);
4841 static cmdline_parse_inst_t cmd_csum_set = {
4842 .f = cmd_csum_parsed,
4844 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4845 "Enable/Disable hardware calculation of L3/L4 checksum when "
4846 "using csum forward engine",
4848 (void *)&cmd_csum_csum,
4849 (void *)&cmd_csum_mode,
4850 (void *)&cmd_csum_proto,
4851 (void *)&cmd_csum_hwsw,
4852 (void *)&cmd_csum_portid,
4857 static cmdline_parse_token_string_t cmd_csum_mode_show =
4858 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4861 static cmdline_parse_inst_t cmd_csum_show = {
4862 .f = cmd_csum_parsed,
4864 .help_str = "csum show <port_id>: Show checksum offload configuration",
4866 (void *)&cmd_csum_csum,
4867 (void *)&cmd_csum_mode_show,
4868 (void *)&cmd_csum_portid,
4873 /* Enable/disable tunnel parsing */
4874 struct cmd_csum_tunnel_result {
4875 cmdline_fixed_string_t csum;
4876 cmdline_fixed_string_t parse;
4877 cmdline_fixed_string_t onoff;
4882 cmd_csum_tunnel_parsed(void *parsed_result,
4883 __rte_unused struct cmdline *cl,
4884 __rte_unused void *data)
4886 struct cmd_csum_tunnel_result *res = parsed_result;
4888 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4891 if (!strcmp(res->onoff, "on"))
4892 ports[res->port_id].parse_tunnel = 1;
4894 ports[res->port_id].parse_tunnel = 0;
4896 csum_show(res->port_id);
4899 static cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4900 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4902 static cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4903 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4904 parse, "parse-tunnel");
4905 static cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4906 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4908 static cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4909 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4910 port_id, RTE_UINT16);
4912 static cmdline_parse_inst_t cmd_csum_tunnel = {
4913 .f = cmd_csum_tunnel_parsed,
4915 .help_str = "csum parse-tunnel on|off <port_id>: "
4916 "Enable/Disable parsing of tunnels for csum engine",
4918 (void *)&cmd_csum_tunnel_csum,
4919 (void *)&cmd_csum_tunnel_parse,
4920 (void *)&cmd_csum_tunnel_onoff,
4921 (void *)&cmd_csum_tunnel_portid,
4926 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4927 struct cmd_tso_set_result {
4928 cmdline_fixed_string_t tso;
4929 cmdline_fixed_string_t mode;
4935 cmd_tso_set_parsed(void *parsed_result,
4936 __rte_unused struct cmdline *cl,
4937 __rte_unused void *data)
4939 struct cmd_tso_set_result *res = parsed_result;
4940 struct rte_eth_dev_info dev_info;
4943 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4945 if (!port_is_stopped(res->port_id)) {
4946 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4950 if (!strcmp(res->mode, "set"))
4951 ports[res->port_id].tso_segsz = res->tso_segsz;
4953 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4957 if ((ports[res->port_id].tso_segsz != 0) &&
4958 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) {
4959 fprintf(stderr, "Error: TSO is not supported by port %d\n",
4964 if (ports[res->port_id].tso_segsz == 0) {
4965 ports[res->port_id].dev_conf.txmode.offloads &=
4966 ~RTE_ETH_TX_OFFLOAD_TCP_TSO;
4967 printf("TSO for non-tunneled packets is disabled\n");
4969 ports[res->port_id].dev_conf.txmode.offloads |=
4970 RTE_ETH_TX_OFFLOAD_TCP_TSO;
4971 printf("TSO segment size for non-tunneled packets is %d\n",
4972 ports[res->port_id].tso_segsz);
4974 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4976 /* display warnings if configuration is not supported by the NIC */
4977 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4981 if ((ports[res->port_id].tso_segsz != 0) &&
4982 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) {
4984 "Warning: TSO enabled but not supported by port %d\n",
4988 cmd_reconfig_device_queue(res->port_id, 1, 1);
4991 static cmdline_parse_token_string_t cmd_tso_set_tso =
4992 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4994 static cmdline_parse_token_string_t cmd_tso_set_mode =
4995 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4997 static cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4998 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4999 tso_segsz, RTE_UINT16);
5000 static cmdline_parse_token_num_t cmd_tso_set_portid =
5001 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
5002 port_id, RTE_UINT16);
5004 static cmdline_parse_inst_t cmd_tso_set = {
5005 .f = cmd_tso_set_parsed,
5007 .help_str = "tso set <tso_segsz> <port_id>: "
5008 "Set TSO segment size of non-tunneled packets for csum engine "
5011 (void *)&cmd_tso_set_tso,
5012 (void *)&cmd_tso_set_mode,
5013 (void *)&cmd_tso_set_tso_segsz,
5014 (void *)&cmd_tso_set_portid,
5019 static cmdline_parse_token_string_t cmd_tso_show_mode =
5020 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5024 static cmdline_parse_inst_t cmd_tso_show = {
5025 .f = cmd_tso_set_parsed,
5027 .help_str = "tso show <port_id>: "
5028 "Show TSO segment size of non-tunneled packets for csum engine",
5030 (void *)&cmd_tso_set_tso,
5031 (void *)&cmd_tso_show_mode,
5032 (void *)&cmd_tso_set_portid,
5037 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5038 struct cmd_tunnel_tso_set_result {
5039 cmdline_fixed_string_t tso;
5040 cmdline_fixed_string_t mode;
5045 static struct rte_eth_dev_info
5046 check_tunnel_tso_nic_support(portid_t port_id)
5048 struct rte_eth_dev_info dev_info;
5050 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
5053 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO))
5055 "Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n",
5057 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO))
5059 "Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n",
5061 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO))
5063 "Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n",
5065 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO))
5067 "Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n",
5069 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IP_TNL_TSO))
5071 "Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n",
5073 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO))
5075 "Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n",
5081 cmd_tunnel_tso_set_parsed(void *parsed_result,
5082 __rte_unused struct cmdline *cl,
5083 __rte_unused void *data)
5085 struct cmd_tunnel_tso_set_result *res = parsed_result;
5086 struct rte_eth_dev_info dev_info;
5088 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5090 if (!port_is_stopped(res->port_id)) {
5091 fprintf(stderr, "Please stop port %d first\n", res->port_id);
5095 if (!strcmp(res->mode, "set"))
5096 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5098 dev_info = check_tunnel_tso_nic_support(res->port_id);
5099 if (ports[res->port_id].tunnel_tso_segsz == 0) {
5100 ports[res->port_id].dev_conf.txmode.offloads &=
5101 ~(RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5102 RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5103 RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5104 RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5105 RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5106 RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO);
5107 printf("TSO for tunneled packets is disabled\n");
5109 uint64_t tso_offloads = (RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5110 RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5111 RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5112 RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5113 RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5114 RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO);
5116 ports[res->port_id].dev_conf.txmode.offloads |=
5117 (tso_offloads & dev_info.tx_offload_capa);
5118 printf("TSO segment size for tunneled packets is %d\n",
5119 ports[res->port_id].tunnel_tso_segsz);
5121 /* Below conditions are needed to make it work:
5122 * (1) tunnel TSO is supported by the NIC;
5123 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5125 * (3) for tunneled pkts with outer L3 of IPv4,
5126 * "csum set outer-ip" must be set to hw, because after tso,
5127 * total_len of outer IP header is changed, and the checksum
5128 * of outer IP header calculated by sw should be wrong; that
5129 * is not necessary for IPv6 tunneled pkts because there's no
5130 * checksum in IP header anymore.
5133 if (!ports[res->port_id].parse_tunnel)
5135 "Warning: csum parse_tunnel must be set so that tunneled packets are recognized\n");
5136 if (!(ports[res->port_id].dev_conf.txmode.offloads &
5137 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5139 "Warning: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n");
5142 cmd_config_queue_tx_offloads(&ports[res->port_id]);
5143 cmd_reconfig_device_queue(res->port_id, 1, 1);
5146 static cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5147 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5149 static cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5150 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5152 static cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5153 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5154 tso_segsz, RTE_UINT16);
5155 static cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5156 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5157 port_id, RTE_UINT16);
5159 static cmdline_parse_inst_t cmd_tunnel_tso_set = {
5160 .f = cmd_tunnel_tso_set_parsed,
5162 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5163 "Set TSO segment size of tunneled packets for csum engine "
5166 (void *)&cmd_tunnel_tso_set_tso,
5167 (void *)&cmd_tunnel_tso_set_mode,
5168 (void *)&cmd_tunnel_tso_set_tso_segsz,
5169 (void *)&cmd_tunnel_tso_set_portid,
5174 static cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5175 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5179 static cmdline_parse_inst_t cmd_tunnel_tso_show = {
5180 .f = cmd_tunnel_tso_set_parsed,
5182 .help_str = "tunnel_tso show <port_id> "
5183 "Show TSO segment size of tunneled packets for csum engine",
5185 (void *)&cmd_tunnel_tso_set_tso,
5186 (void *)&cmd_tunnel_tso_show_mode,
5187 (void *)&cmd_tunnel_tso_set_portid,
5193 /* *** SET GRO FOR A PORT *** */
5194 struct cmd_gro_enable_result {
5195 cmdline_fixed_string_t cmd_set;
5196 cmdline_fixed_string_t cmd_port;
5197 cmdline_fixed_string_t cmd_keyword;
5198 cmdline_fixed_string_t cmd_onoff;
5203 cmd_gro_enable_parsed(void *parsed_result,
5204 __rte_unused struct cmdline *cl,
5205 __rte_unused void *data)
5207 struct cmd_gro_enable_result *res;
5209 res = parsed_result;
5210 if (!strcmp(res->cmd_keyword, "gro"))
5211 setup_gro(res->cmd_onoff, res->cmd_pid);
5214 static cmdline_parse_token_string_t cmd_gro_enable_set =
5215 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5217 static cmdline_parse_token_string_t cmd_gro_enable_port =
5218 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5219 cmd_keyword, "port");
5220 static cmdline_parse_token_num_t cmd_gro_enable_pid =
5221 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5222 cmd_pid, RTE_UINT16);
5223 static cmdline_parse_token_string_t cmd_gro_enable_keyword =
5224 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5225 cmd_keyword, "gro");
5226 static cmdline_parse_token_string_t cmd_gro_enable_onoff =
5227 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5228 cmd_onoff, "on#off");
5230 static cmdline_parse_inst_t cmd_gro_enable = {
5231 .f = cmd_gro_enable_parsed,
5233 .help_str = "set port <port_id> gro on|off",
5235 (void *)&cmd_gro_enable_set,
5236 (void *)&cmd_gro_enable_port,
5237 (void *)&cmd_gro_enable_pid,
5238 (void *)&cmd_gro_enable_keyword,
5239 (void *)&cmd_gro_enable_onoff,
5244 /* *** DISPLAY GRO CONFIGURATION *** */
5245 struct cmd_gro_show_result {
5246 cmdline_fixed_string_t cmd_show;
5247 cmdline_fixed_string_t cmd_port;
5248 cmdline_fixed_string_t cmd_keyword;
5253 cmd_gro_show_parsed(void *parsed_result,
5254 __rte_unused struct cmdline *cl,
5255 __rte_unused void *data)
5257 struct cmd_gro_show_result *res;
5259 res = parsed_result;
5260 if (!strcmp(res->cmd_keyword, "gro"))
5261 show_gro(res->cmd_pid);
5264 static cmdline_parse_token_string_t cmd_gro_show_show =
5265 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5267 static cmdline_parse_token_string_t cmd_gro_show_port =
5268 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5270 static cmdline_parse_token_num_t cmd_gro_show_pid =
5271 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5272 cmd_pid, RTE_UINT16);
5273 static cmdline_parse_token_string_t cmd_gro_show_keyword =
5274 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5275 cmd_keyword, "gro");
5277 static cmdline_parse_inst_t cmd_gro_show = {
5278 .f = cmd_gro_show_parsed,
5280 .help_str = "show port <port_id> gro",
5282 (void *)&cmd_gro_show_show,
5283 (void *)&cmd_gro_show_port,
5284 (void *)&cmd_gro_show_pid,
5285 (void *)&cmd_gro_show_keyword,
5290 /* *** SET FLUSH CYCLES FOR GRO *** */
5291 struct cmd_gro_flush_result {
5292 cmdline_fixed_string_t cmd_set;
5293 cmdline_fixed_string_t cmd_keyword;
5294 cmdline_fixed_string_t cmd_flush;
5299 cmd_gro_flush_parsed(void *parsed_result,
5300 __rte_unused struct cmdline *cl,
5301 __rte_unused void *data)
5303 struct cmd_gro_flush_result *res;
5305 res = parsed_result;
5306 if ((!strcmp(res->cmd_keyword, "gro")) &&
5307 (!strcmp(res->cmd_flush, "flush")))
5308 setup_gro_flush_cycles(res->cmd_cycles);
5311 static cmdline_parse_token_string_t cmd_gro_flush_set =
5312 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5314 static cmdline_parse_token_string_t cmd_gro_flush_keyword =
5315 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5316 cmd_keyword, "gro");
5317 static cmdline_parse_token_string_t cmd_gro_flush_flush =
5318 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5319 cmd_flush, "flush");
5320 static cmdline_parse_token_num_t cmd_gro_flush_cycles =
5321 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5322 cmd_cycles, RTE_UINT8);
5324 static cmdline_parse_inst_t cmd_gro_flush = {
5325 .f = cmd_gro_flush_parsed,
5327 .help_str = "set gro flush <cycles>",
5329 (void *)&cmd_gro_flush_set,
5330 (void *)&cmd_gro_flush_keyword,
5331 (void *)&cmd_gro_flush_flush,
5332 (void *)&cmd_gro_flush_cycles,
5336 #endif /* RTE_LIB_GRO */
5339 /* *** ENABLE/DISABLE GSO *** */
5340 struct cmd_gso_enable_result {
5341 cmdline_fixed_string_t cmd_set;
5342 cmdline_fixed_string_t cmd_port;
5343 cmdline_fixed_string_t cmd_keyword;
5344 cmdline_fixed_string_t cmd_mode;
5349 cmd_gso_enable_parsed(void *parsed_result,
5350 __rte_unused struct cmdline *cl,
5351 __rte_unused void *data)
5353 struct cmd_gso_enable_result *res;
5355 res = parsed_result;
5356 if (!strcmp(res->cmd_keyword, "gso"))
5357 setup_gso(res->cmd_mode, res->cmd_pid);
5360 static cmdline_parse_token_string_t cmd_gso_enable_set =
5361 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5363 static cmdline_parse_token_string_t cmd_gso_enable_port =
5364 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5366 static cmdline_parse_token_string_t cmd_gso_enable_keyword =
5367 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5368 cmd_keyword, "gso");
5369 static cmdline_parse_token_string_t cmd_gso_enable_mode =
5370 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5371 cmd_mode, "on#off");
5372 static cmdline_parse_token_num_t cmd_gso_enable_pid =
5373 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5374 cmd_pid, RTE_UINT16);
5376 static cmdline_parse_inst_t cmd_gso_enable = {
5377 .f = cmd_gso_enable_parsed,
5379 .help_str = "set port <port_id> gso on|off",
5381 (void *)&cmd_gso_enable_set,
5382 (void *)&cmd_gso_enable_port,
5383 (void *)&cmd_gso_enable_pid,
5384 (void *)&cmd_gso_enable_keyword,
5385 (void *)&cmd_gso_enable_mode,
5390 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5391 struct cmd_gso_size_result {
5392 cmdline_fixed_string_t cmd_set;
5393 cmdline_fixed_string_t cmd_keyword;
5394 cmdline_fixed_string_t cmd_segsz;
5399 cmd_gso_size_parsed(void *parsed_result,
5400 __rte_unused struct cmdline *cl,
5401 __rte_unused void *data)
5403 struct cmd_gso_size_result *res = parsed_result;
5405 if (test_done == 0) {
5407 "Before setting GSO segsz, please first stop forwarding\n");
5411 if (!strcmp(res->cmd_keyword, "gso") &&
5412 !strcmp(res->cmd_segsz, "segsz")) {
5413 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5415 "gso_size should be larger than %zu. Please input a legal value\n",
5416 RTE_GSO_SEG_SIZE_MIN);
5418 gso_max_segment_size = res->cmd_size;
5422 static cmdline_parse_token_string_t cmd_gso_size_set =
5423 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5425 static cmdline_parse_token_string_t cmd_gso_size_keyword =
5426 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5427 cmd_keyword, "gso");
5428 static cmdline_parse_token_string_t cmd_gso_size_segsz =
5429 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5430 cmd_segsz, "segsz");
5431 static cmdline_parse_token_num_t cmd_gso_size_size =
5432 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5433 cmd_size, RTE_UINT16);
5435 static cmdline_parse_inst_t cmd_gso_size = {
5436 .f = cmd_gso_size_parsed,
5438 .help_str = "set gso segsz <length>",
5440 (void *)&cmd_gso_size_set,
5441 (void *)&cmd_gso_size_keyword,
5442 (void *)&cmd_gso_size_segsz,
5443 (void *)&cmd_gso_size_size,
5448 /* *** SHOW GSO CONFIGURATION *** */
5449 struct cmd_gso_show_result {
5450 cmdline_fixed_string_t cmd_show;
5451 cmdline_fixed_string_t cmd_port;
5452 cmdline_fixed_string_t cmd_keyword;
5457 cmd_gso_show_parsed(void *parsed_result,
5458 __rte_unused struct cmdline *cl,
5459 __rte_unused void *data)
5461 struct cmd_gso_show_result *res = parsed_result;
5463 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5464 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
5467 if (!strcmp(res->cmd_keyword, "gso")) {
5468 if (gso_ports[res->cmd_pid].enable) {
5469 printf("Max GSO'd packet size: %uB\n"
5470 "Supported GSO types: TCP/IPv4, "
5471 "UDP/IPv4, VxLAN with inner "
5472 "TCP/IPv4 packet, GRE with inner "
5473 "TCP/IPv4 packet\n",
5474 gso_max_segment_size);
5476 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5480 static cmdline_parse_token_string_t cmd_gso_show_show =
5481 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5483 static cmdline_parse_token_string_t cmd_gso_show_port =
5484 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5486 static cmdline_parse_token_string_t cmd_gso_show_keyword =
5487 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5488 cmd_keyword, "gso");
5489 static cmdline_parse_token_num_t cmd_gso_show_pid =
5490 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5491 cmd_pid, RTE_UINT16);
5493 static cmdline_parse_inst_t cmd_gso_show = {
5494 .f = cmd_gso_show_parsed,
5496 .help_str = "show port <port_id> gso",
5498 (void *)&cmd_gso_show_show,
5499 (void *)&cmd_gso_show_port,
5500 (void *)&cmd_gso_show_pid,
5501 (void *)&cmd_gso_show_keyword,
5505 #endif /* RTE_LIB_GSO */
5507 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5508 struct cmd_set_flush_rx {
5509 cmdline_fixed_string_t set;
5510 cmdline_fixed_string_t flush_rx;
5511 cmdline_fixed_string_t mode;
5515 cmd_set_flush_rx_parsed(void *parsed_result,
5516 __rte_unused struct cmdline *cl,
5517 __rte_unused void *data)
5519 struct cmd_set_flush_rx *res = parsed_result;
5521 if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) {
5522 printf("multi-process doesn't support to flush Rx queues.\n");
5526 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5529 static cmdline_parse_token_string_t cmd_setflushrx_set =
5530 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5532 static cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5533 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5534 flush_rx, "flush_rx");
5535 static cmdline_parse_token_string_t cmd_setflushrx_mode =
5536 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5540 static cmdline_parse_inst_t cmd_set_flush_rx = {
5541 .f = cmd_set_flush_rx_parsed,
5542 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5545 (void *)&cmd_setflushrx_set,
5546 (void *)&cmd_setflushrx_flush_rx,
5547 (void *)&cmd_setflushrx_mode,
5552 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5553 struct cmd_set_link_check {
5554 cmdline_fixed_string_t set;
5555 cmdline_fixed_string_t link_check;
5556 cmdline_fixed_string_t mode;
5560 cmd_set_link_check_parsed(void *parsed_result,
5561 __rte_unused struct cmdline *cl,
5562 __rte_unused void *data)
5564 struct cmd_set_link_check *res = parsed_result;
5565 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5568 static cmdline_parse_token_string_t cmd_setlinkcheck_set =
5569 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5571 static cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5572 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5573 link_check, "link_check");
5574 static cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5575 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5579 static cmdline_parse_inst_t cmd_set_link_check = {
5580 .f = cmd_set_link_check_parsed,
5581 .help_str = "set link_check on|off: Enable/Disable link status check "
5582 "when starting/stopping a port",
5585 (void *)&cmd_setlinkcheck_set,
5586 (void *)&cmd_setlinkcheck_link_check,
5587 (void *)&cmd_setlinkcheck_mode,
5592 /* *** SET NIC BYPASS MODE *** */
5593 struct cmd_set_bypass_mode_result {
5594 cmdline_fixed_string_t set;
5595 cmdline_fixed_string_t bypass;
5596 cmdline_fixed_string_t mode;
5597 cmdline_fixed_string_t value;
5602 cmd_set_bypass_mode_parsed(void *parsed_result,
5603 __rte_unused struct cmdline *cl,
5604 __rte_unused void *data)
5606 struct cmd_set_bypass_mode_result *res = parsed_result;
5607 portid_t port_id = res->port_id;
5608 int32_t rc = -EINVAL;
5610 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5611 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5613 if (!strcmp(res->value, "bypass"))
5614 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5615 else if (!strcmp(res->value, "isolate"))
5616 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5618 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5620 /* Set the bypass mode for the relevant port. */
5621 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5624 fprintf(stderr, "\t Failed to set bypass mode for port = %d.\n",
5628 static cmdline_parse_token_string_t cmd_setbypass_mode_set =
5629 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5631 static cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5632 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5634 static cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5635 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5637 static cmdline_parse_token_string_t cmd_setbypass_mode_value =
5638 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5639 value, "normal#bypass#isolate");
5640 static cmdline_parse_token_num_t cmd_setbypass_mode_port =
5641 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5642 port_id, RTE_UINT16);
5644 static cmdline_parse_inst_t cmd_set_bypass_mode = {
5645 .f = cmd_set_bypass_mode_parsed,
5646 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5647 "Set the NIC bypass mode for port_id",
5650 (void *)&cmd_setbypass_mode_set,
5651 (void *)&cmd_setbypass_mode_bypass,
5652 (void *)&cmd_setbypass_mode_mode,
5653 (void *)&cmd_setbypass_mode_value,
5654 (void *)&cmd_setbypass_mode_port,
5659 /* *** SET NIC BYPASS EVENT *** */
5660 struct cmd_set_bypass_event_result {
5661 cmdline_fixed_string_t set;
5662 cmdline_fixed_string_t bypass;
5663 cmdline_fixed_string_t event;
5664 cmdline_fixed_string_t event_value;
5665 cmdline_fixed_string_t mode;
5666 cmdline_fixed_string_t mode_value;
5671 cmd_set_bypass_event_parsed(void *parsed_result,
5672 __rte_unused struct cmdline *cl,
5673 __rte_unused void *data)
5675 int32_t rc = -EINVAL;
5676 struct cmd_set_bypass_event_result *res = parsed_result;
5677 portid_t port_id = res->port_id;
5679 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5680 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5681 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5683 if (!strcmp(res->event_value, "timeout"))
5684 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5685 else if (!strcmp(res->event_value, "os_on"))
5686 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5687 else if (!strcmp(res->event_value, "os_off"))
5688 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5689 else if (!strcmp(res->event_value, "power_on"))
5690 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5691 else if (!strcmp(res->event_value, "power_off"))
5692 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5694 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5696 if (!strcmp(res->mode_value, "bypass"))
5697 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5698 else if (!strcmp(res->mode_value, "isolate"))
5699 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5701 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5703 /* Set the watchdog timeout. */
5704 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5707 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5708 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5713 "Failed to set timeout value %u for port %d, errto code: %d.\n",
5714 bypass_timeout, port_id, rc);
5718 /* Set the bypass event to transition to bypass mode. */
5719 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5724 fprintf(stderr, "\t Failed to set bypass event for port = %d.\n",
5728 static cmdline_parse_token_string_t cmd_setbypass_event_set =
5729 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5731 static cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5732 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5734 static cmdline_parse_token_string_t cmd_setbypass_event_event =
5735 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5737 static cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5738 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5739 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5740 static cmdline_parse_token_string_t cmd_setbypass_event_mode =
5741 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5743 static cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5744 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5745 mode_value, "normal#bypass#isolate");
5746 static cmdline_parse_token_num_t cmd_setbypass_event_port =
5747 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5748 port_id, RTE_UINT16);
5750 static cmdline_parse_inst_t cmd_set_bypass_event = {
5751 .f = cmd_set_bypass_event_parsed,
5752 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5753 "power_off mode normal|bypass|isolate <port_id>: "
5754 "Set the NIC bypass event mode for port_id",
5757 (void *)&cmd_setbypass_event_set,
5758 (void *)&cmd_setbypass_event_bypass,
5759 (void *)&cmd_setbypass_event_event,
5760 (void *)&cmd_setbypass_event_event_value,
5761 (void *)&cmd_setbypass_event_mode,
5762 (void *)&cmd_setbypass_event_mode_value,
5763 (void *)&cmd_setbypass_event_port,
5769 /* *** SET NIC BYPASS TIMEOUT *** */
5770 struct cmd_set_bypass_timeout_result {
5771 cmdline_fixed_string_t set;
5772 cmdline_fixed_string_t bypass;
5773 cmdline_fixed_string_t timeout;
5774 cmdline_fixed_string_t value;
5778 cmd_set_bypass_timeout_parsed(void *parsed_result,
5779 __rte_unused struct cmdline *cl,
5780 __rte_unused void *data)
5782 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5784 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5785 if (!strcmp(res->value, "1.5"))
5786 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5787 else if (!strcmp(res->value, "2"))
5788 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5789 else if (!strcmp(res->value, "3"))
5790 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5791 else if (!strcmp(res->value, "4"))
5792 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5793 else if (!strcmp(res->value, "8"))
5794 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5795 else if (!strcmp(res->value, "16"))
5796 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5797 else if (!strcmp(res->value, "32"))
5798 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5800 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5804 static cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5805 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5807 static cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5808 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5810 static cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5811 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5812 timeout, "timeout");
5813 static cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5814 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5815 value, "0#1.5#2#3#4#8#16#32");
5817 static cmdline_parse_inst_t cmd_set_bypass_timeout = {
5818 .f = cmd_set_bypass_timeout_parsed,
5819 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5820 "Set the NIC bypass watchdog timeout in seconds",
5823 (void *)&cmd_setbypass_timeout_set,
5824 (void *)&cmd_setbypass_timeout_bypass,
5825 (void *)&cmd_setbypass_timeout_timeout,
5826 (void *)&cmd_setbypass_timeout_value,
5831 /* *** SHOW NIC BYPASS MODE *** */
5832 struct cmd_show_bypass_config_result {
5833 cmdline_fixed_string_t show;
5834 cmdline_fixed_string_t bypass;
5835 cmdline_fixed_string_t config;
5840 cmd_show_bypass_config_parsed(void *parsed_result,
5841 __rte_unused struct cmdline *cl,
5842 __rte_unused void *data)
5844 struct cmd_show_bypass_config_result *res = parsed_result;
5845 portid_t port_id = res->port_id;
5847 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5848 uint32_t event_mode;
5849 uint32_t bypass_mode;
5850 uint32_t timeout = bypass_timeout;
5853 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5854 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5855 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5856 {"UNKNOWN", "normal", "bypass", "isolate"};
5857 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5865 /* Display the bypass mode.*/
5866 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5867 fprintf(stderr, "\tFailed to get bypass mode for port = %d\n",
5872 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5873 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5875 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5878 /* Display the bypass timeout.*/
5879 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5880 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5882 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5884 /* Display the bypass events and associated modes. */
5885 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5887 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5889 "\tFailed to get bypass mode for event = %s\n",
5892 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5893 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5895 printf("\tbypass event: %-16s = %s\n", events[i],
5902 "\tFailed to get bypass configuration for port = %d\n",
5906 static cmdline_parse_token_string_t cmd_showbypass_config_show =
5907 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5909 static cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5910 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5912 static cmdline_parse_token_string_t cmd_showbypass_config_config =
5913 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5915 static cmdline_parse_token_num_t cmd_showbypass_config_port =
5916 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5917 port_id, RTE_UINT16);
5919 static cmdline_parse_inst_t cmd_show_bypass_config = {
5920 .f = cmd_show_bypass_config_parsed,
5921 .help_str = "show bypass config <port_id>: "
5922 "Show the NIC bypass config for port_id",
5925 (void *)&cmd_showbypass_config_show,
5926 (void *)&cmd_showbypass_config_bypass,
5927 (void *)&cmd_showbypass_config_config,
5928 (void *)&cmd_showbypass_config_port,
5934 /* *** SET BONDING MODE *** */
5935 struct cmd_set_bonding_mode_result {
5936 cmdline_fixed_string_t set;
5937 cmdline_fixed_string_t bonding;
5938 cmdline_fixed_string_t mode;
5943 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5944 __rte_unused struct cmdline *cl,
5945 __rte_unused void *data)
5947 struct cmd_set_bonding_mode_result *res = parsed_result;
5948 portid_t port_id = res->port_id;
5949 struct rte_port *port = &ports[port_id];
5952 * Bonding mode changed means resources of device changed, like whether
5953 * started rte timer or not. Device should be restarted when resources
5954 * of device changed.
5956 if (port->port_status != RTE_PORT_STOPPED) {
5958 "\t Error: Can't set bonding mode when port %d is not stopped\n",
5963 /* Set the bonding mode for the relevant port. */
5964 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5965 fprintf(stderr, "\t Failed to set bonding mode for port = %d.\n",
5969 static cmdline_parse_token_string_t cmd_setbonding_mode_set =
5970 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5972 static cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5973 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5974 bonding, "bonding");
5975 static cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5976 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5978 static cmdline_parse_token_num_t cmd_setbonding_mode_value =
5979 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5981 static cmdline_parse_token_num_t cmd_setbonding_mode_port =
5982 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5983 port_id, RTE_UINT16);
5985 static cmdline_parse_inst_t cmd_set_bonding_mode = {
5986 .f = cmd_set_bonding_mode_parsed,
5987 .help_str = "set bonding mode <mode_value> <port_id>: "
5988 "Set the bonding mode for port_id",
5991 (void *) &cmd_setbonding_mode_set,
5992 (void *) &cmd_setbonding_mode_bonding,
5993 (void *) &cmd_setbonding_mode_mode,
5994 (void *) &cmd_setbonding_mode_value,
5995 (void *) &cmd_setbonding_mode_port,
6000 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
6001 struct cmd_set_bonding_lacp_dedicated_queues_result {
6002 cmdline_fixed_string_t set;
6003 cmdline_fixed_string_t bonding;
6004 cmdline_fixed_string_t lacp;
6005 cmdline_fixed_string_t dedicated_queues;
6007 cmdline_fixed_string_t mode;
6010 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
6011 __rte_unused struct cmdline *cl,
6012 __rte_unused void *data)
6014 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
6015 portid_t port_id = res->port_id;
6016 struct rte_port *port;
6018 port = &ports[port_id];
6020 /** Check if the port is not started **/
6021 if (port->port_status != RTE_PORT_STOPPED) {
6022 fprintf(stderr, "Please stop port %d first\n", port_id);
6026 if (!strcmp(res->mode, "enable")) {
6027 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
6028 printf("Dedicate queues for LACP control packets"
6031 printf("Enabling dedicate queues for LACP control "
6032 "packets on port %d failed\n", port_id);
6033 } else if (!strcmp(res->mode, "disable")) {
6034 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
6035 printf("Dedicated queues for LACP control packets "
6038 printf("Disabling dedicated queues for LACP control "
6039 "traffic on port %d failed\n", port_id);
6043 static cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
6044 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6046 static cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
6047 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6048 bonding, "bonding");
6049 static cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
6050 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6052 static cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
6053 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6054 dedicated_queues, "dedicated_queues");
6055 static cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
6056 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6057 port_id, RTE_UINT16);
6058 static cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
6059 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6060 mode, "enable#disable");
6062 static cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
6063 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
6064 .help_str = "set bonding lacp dedicated_queues <port_id> "
6066 "Enable/disable dedicated queues for LACP control traffic for port_id",
6069 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
6070 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
6071 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
6072 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
6073 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
6074 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
6079 /* *** SET BALANCE XMIT POLICY *** */
6080 struct cmd_set_bonding_balance_xmit_policy_result {
6081 cmdline_fixed_string_t set;
6082 cmdline_fixed_string_t bonding;
6083 cmdline_fixed_string_t balance_xmit_policy;
6085 cmdline_fixed_string_t policy;
6088 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
6089 __rte_unused struct cmdline *cl,
6090 __rte_unused void *data)
6092 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6093 portid_t port_id = res->port_id;
6096 if (!strcmp(res->policy, "l2")) {
6097 policy = BALANCE_XMIT_POLICY_LAYER2;
6098 } else if (!strcmp(res->policy, "l23")) {
6099 policy = BALANCE_XMIT_POLICY_LAYER23;
6100 } else if (!strcmp(res->policy, "l34")) {
6101 policy = BALANCE_XMIT_POLICY_LAYER34;
6103 fprintf(stderr, "\t Invalid xmit policy selection");
6107 /* Set the bonding mode for the relevant port. */
6108 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6110 "\t Failed to set bonding balance xmit policy for port = %d.\n",
6115 static cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6116 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6118 static cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6119 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6120 bonding, "bonding");
6121 static cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6122 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6123 balance_xmit_policy, "balance_xmit_policy");
6124 static cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6125 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6126 port_id, RTE_UINT16);
6127 static cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6128 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6129 policy, "l2#l23#l34");
6131 static cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6132 .f = cmd_set_bonding_balance_xmit_policy_parsed,
6133 .help_str = "set bonding balance_xmit_policy <port_id> "
6135 "Set the bonding balance_xmit_policy for port_id",
6138 (void *)&cmd_setbonding_balance_xmit_policy_set,
6139 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
6140 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6141 (void *)&cmd_setbonding_balance_xmit_policy_port,
6142 (void *)&cmd_setbonding_balance_xmit_policy_policy,
6147 /* *** SHOW IEEE802.3 BONDING INFORMATION *** */
6148 struct cmd_show_bonding_lacp_info_result {
6149 cmdline_fixed_string_t show;
6150 cmdline_fixed_string_t bonding;
6151 cmdline_fixed_string_t lacp;
6152 cmdline_fixed_string_t info;
6156 static void port_param_show(struct port_params *params)
6158 char buf[RTE_ETHER_ADDR_FMT_SIZE];
6160 printf("\t\tsystem priority: %u\n", params->system_priority);
6161 rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, ¶ms->system);
6162 printf("\t\tsystem mac address: %s\n", buf);
6163 printf("\t\tport key: %u\n", params->key);
6164 printf("\t\tport priority: %u\n", params->port_priority);
6165 printf("\t\tport number: %u\n", params->port_number);
6168 static void lacp_slave_info_show(struct rte_eth_bond_8023ad_slave_info *info)
6170 char a_state[256] = { 0 };
6171 char p_state[256] = { 0 };
6176 static const char * const state[] = {
6186 static const char * const selection[] = {
6192 for (i = 0; i < RTE_DIM(state); i++) {
6193 if ((info->actor_state >> i) & 1)
6194 a_len += snprintf(&a_state[a_len],
6195 RTE_DIM(a_state) - a_len, "%s ",
6198 if ((info->partner_state >> i) & 1)
6199 p_len += snprintf(&p_state[p_len],
6200 RTE_DIM(p_state) - p_len, "%s ",
6203 printf("\tAggregator port id: %u\n", info->agg_port_id);
6204 printf("\tselection: %s\n", selection[info->selected]);
6205 printf("\tActor detail info:\n");
6206 port_param_show(&info->actor);
6207 printf("\t\tport state: %s\n", a_state);
6208 printf("\tPartner detail info:\n");
6209 port_param_show(&info->partner);
6210 printf("\t\tport state: %s\n", p_state);
6214 static void lacp_conf_show(struct rte_eth_bond_8023ad_conf *conf)
6216 printf("\tfast period: %u ms\n", conf->fast_periodic_ms);
6217 printf("\tslow period: %u ms\n", conf->slow_periodic_ms);
6218 printf("\tshort timeout: %u ms\n", conf->short_timeout_ms);
6219 printf("\tlong timeout: %u ms\n", conf->long_timeout_ms);
6220 printf("\taggregate wait timeout: %u ms\n",
6221 conf->aggregate_wait_timeout_ms);
6222 printf("\ttx period: %u ms\n", conf->tx_period_ms);
6223 printf("\trx marker period: %u ms\n", conf->rx_marker_period_ms);
6224 printf("\tupdate timeout: %u ms\n", conf->update_timeout_ms);
6225 switch (conf->agg_selection) {
6227 printf("\taggregation mode: bandwidth\n");
6230 printf("\taggregation mode: stable\n");
6233 printf("\taggregation mode: count\n");
6236 printf("\taggregation mode: invalid\n");
6243 static void cmd_show_bonding_lacp_info_parsed(void *parsed_result,
6244 __rte_unused struct cmdline *cl,
6245 __rte_unused void *data)
6247 struct cmd_show_bonding_lacp_info_result *res = parsed_result;
6248 struct rte_eth_bond_8023ad_slave_info slave_info;
6249 struct rte_eth_bond_8023ad_conf port_conf;
6250 portid_t slaves[RTE_MAX_ETHPORTS];
6251 portid_t port_id = res->port_id;
6252 int num_active_slaves;
6257 bonding_mode = rte_eth_bond_mode_get(port_id);
6258 if (bonding_mode != BONDING_MODE_8023AD) {
6259 fprintf(stderr, "\tBonding mode is not mode 4\n");
6263 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6265 if (num_active_slaves < 0) {
6266 fprintf(stderr, "\tFailed to get active slave list for port = %u\n",
6270 if (num_active_slaves == 0)
6271 fprintf(stderr, "\tIEEE802.3 port %u has no active slave\n",
6274 printf("\tIEEE802.3 port: %u\n", port_id);
6275 ret = rte_eth_bond_8023ad_conf_get(port_id, &port_conf);
6277 fprintf(stderr, "\tGet bonded device %u info failed\n",
6281 lacp_conf_show(&port_conf);
6283 for (i = 0; i < num_active_slaves; i++) {
6284 ret = rte_eth_bond_8023ad_slave_info(port_id, slaves[i],
6287 fprintf(stderr, "\tGet slave device %u info failed\n",
6291 printf("\tSlave Port: %u\n", slaves[i]);
6292 lacp_slave_info_show(&slave_info);
6296 static cmdline_parse_token_string_t cmd_show_bonding_lacp_info_show =
6297 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6299 static cmdline_parse_token_string_t cmd_show_bonding_lacp_info_bonding =
6300 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6301 bonding, "bonding");
6302 static cmdline_parse_token_string_t cmd_show_bonding_lacp_info_lacp =
6303 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6305 static cmdline_parse_token_string_t cmd_show_bonding_lacp_info_info =
6306 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6308 static cmdline_parse_token_num_t cmd_show_bonding_lacp_info_port_id =
6309 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6310 port_id, RTE_UINT16);
6312 static cmdline_parse_inst_t cmd_show_bonding_lacp_info = {
6313 .f = cmd_show_bonding_lacp_info_parsed,
6314 .help_str = "show bonding lacp info <port_id> : "
6315 "Show bonding IEEE802.3 information for port_id",
6318 (void *)&cmd_show_bonding_lacp_info_show,
6319 (void *)&cmd_show_bonding_lacp_info_bonding,
6320 (void *)&cmd_show_bonding_lacp_info_lacp,
6321 (void *)&cmd_show_bonding_lacp_info_info,
6322 (void *)&cmd_show_bonding_lacp_info_port_id,
6327 /* *** SHOW NIC BONDING CONFIGURATION *** */
6328 struct cmd_show_bonding_config_result {
6329 cmdline_fixed_string_t show;
6330 cmdline_fixed_string_t bonding;
6331 cmdline_fixed_string_t config;
6335 static void cmd_show_bonding_config_parsed(void *parsed_result,
6336 __rte_unused struct cmdline *cl,
6337 __rte_unused void *data)
6339 struct cmd_show_bonding_config_result *res = parsed_result;
6340 int bonding_mode, agg_mode;
6341 portid_t slaves[RTE_MAX_ETHPORTS];
6342 int num_slaves, num_active_slaves;
6345 portid_t port_id = res->port_id;
6347 /* Display the bonding mode.*/
6348 bonding_mode = rte_eth_bond_mode_get(port_id);
6349 if (bonding_mode < 0) {
6350 fprintf(stderr, "\tFailed to get bonding mode for port = %d\n",
6354 printf("\tBonding mode: %d\n", bonding_mode);
6356 if (bonding_mode == BONDING_MODE_BALANCE ||
6357 bonding_mode == BONDING_MODE_8023AD) {
6358 int balance_xmit_policy;
6360 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6361 if (balance_xmit_policy < 0) {
6363 "\tFailed to get balance xmit policy for port = %d\n",
6367 printf("\tBalance Xmit Policy: ");
6369 switch (balance_xmit_policy) {
6370 case BALANCE_XMIT_POLICY_LAYER2:
6371 printf("BALANCE_XMIT_POLICY_LAYER2");
6373 case BALANCE_XMIT_POLICY_LAYER23:
6374 printf("BALANCE_XMIT_POLICY_LAYER23");
6376 case BALANCE_XMIT_POLICY_LAYER34:
6377 printf("BALANCE_XMIT_POLICY_LAYER34");
6384 if (bonding_mode == BONDING_MODE_8023AD) {
6385 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6386 printf("\tIEEE802.3AD Aggregator Mode: ");
6389 printf("bandwidth");
6401 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6403 if (num_slaves < 0) {
6404 fprintf(stderr, "\tFailed to get slave list for port = %d\n",
6408 if (num_slaves > 0) {
6409 printf("\tSlaves (%d): [", num_slaves);
6410 for (i = 0; i < num_slaves - 1; i++)
6411 printf("%d ", slaves[i]);
6413 printf("%d]\n", slaves[num_slaves - 1]);
6415 printf("\tSlaves: []\n");
6419 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6422 if (num_active_slaves < 0) {
6424 "\tFailed to get active slave list for port = %d\n",
6428 if (num_active_slaves > 0) {
6429 printf("\tActive Slaves (%d): [", num_active_slaves);
6430 for (i = 0; i < num_active_slaves - 1; i++)
6431 printf("%d ", slaves[i]);
6433 printf("%d]\n", slaves[num_active_slaves - 1]);
6436 printf("\tActive Slaves: []\n");
6440 primary_id = rte_eth_bond_primary_get(port_id);
6441 if (primary_id < 0) {
6442 fprintf(stderr, "\tFailed to get primary slave for port = %d\n",
6446 printf("\tPrimary: [%d]\n", primary_id);
6450 static cmdline_parse_token_string_t cmd_showbonding_config_show =
6451 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6453 static cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6454 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6455 bonding, "bonding");
6456 static cmdline_parse_token_string_t cmd_showbonding_config_config =
6457 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6459 static cmdline_parse_token_num_t cmd_showbonding_config_port =
6460 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6461 port_id, RTE_UINT16);
6463 static cmdline_parse_inst_t cmd_show_bonding_config = {
6464 .f = cmd_show_bonding_config_parsed,
6465 .help_str = "show bonding config <port_id>: "
6466 "Show the bonding config for port_id",
6469 (void *)&cmd_showbonding_config_show,
6470 (void *)&cmd_showbonding_config_bonding,
6471 (void *)&cmd_showbonding_config_config,
6472 (void *)&cmd_showbonding_config_port,
6477 /* *** SET BONDING PRIMARY *** */
6478 struct cmd_set_bonding_primary_result {
6479 cmdline_fixed_string_t set;
6480 cmdline_fixed_string_t bonding;
6481 cmdline_fixed_string_t primary;
6486 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6487 __rte_unused struct cmdline *cl,
6488 __rte_unused void *data)
6490 struct cmd_set_bonding_primary_result *res = parsed_result;
6491 portid_t master_port_id = res->port_id;
6492 portid_t slave_port_id = res->slave_id;
6494 /* Set the primary slave for a bonded device. */
6495 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6496 fprintf(stderr, "\t Failed to set primary slave for port = %d.\n",
6503 static cmdline_parse_token_string_t cmd_setbonding_primary_set =
6504 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6506 static cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6507 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6508 bonding, "bonding");
6509 static cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6510 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6511 primary, "primary");
6512 static cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6513 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6514 slave_id, RTE_UINT16);
6515 static cmdline_parse_token_num_t cmd_setbonding_primary_port =
6516 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6517 port_id, RTE_UINT16);
6519 static cmdline_parse_inst_t cmd_set_bonding_primary = {
6520 .f = cmd_set_bonding_primary_parsed,
6521 .help_str = "set bonding primary <slave_id> <port_id>: "
6522 "Set the primary slave for port_id",
6525 (void *)&cmd_setbonding_primary_set,
6526 (void *)&cmd_setbonding_primary_bonding,
6527 (void *)&cmd_setbonding_primary_primary,
6528 (void *)&cmd_setbonding_primary_slave,
6529 (void *)&cmd_setbonding_primary_port,
6534 /* *** ADD SLAVE *** */
6535 struct cmd_add_bonding_slave_result {
6536 cmdline_fixed_string_t add;
6537 cmdline_fixed_string_t bonding;
6538 cmdline_fixed_string_t slave;
6543 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6544 __rte_unused struct cmdline *cl,
6545 __rte_unused void *data)
6547 struct cmd_add_bonding_slave_result *res = parsed_result;
6548 portid_t master_port_id = res->port_id;
6549 portid_t slave_port_id = res->slave_id;
6551 /* add the slave for a bonded device. */
6552 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6554 "\t Failed to add slave %d to master port = %d.\n",
6555 slave_port_id, master_port_id);
6559 set_port_slave_flag(slave_port_id);
6562 static cmdline_parse_token_string_t cmd_addbonding_slave_add =
6563 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6565 static cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6566 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6567 bonding, "bonding");
6568 static cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6569 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6571 static cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6572 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6573 slave_id, RTE_UINT16);
6574 static cmdline_parse_token_num_t cmd_addbonding_slave_port =
6575 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6576 port_id, RTE_UINT16);
6578 static cmdline_parse_inst_t cmd_add_bonding_slave = {
6579 .f = cmd_add_bonding_slave_parsed,
6580 .help_str = "add bonding slave <slave_id> <port_id>: "
6581 "Add a slave device to a bonded device",
6584 (void *)&cmd_addbonding_slave_add,
6585 (void *)&cmd_addbonding_slave_bonding,
6586 (void *)&cmd_addbonding_slave_slave,
6587 (void *)&cmd_addbonding_slave_slaveid,
6588 (void *)&cmd_addbonding_slave_port,
6593 /* *** REMOVE SLAVE *** */
6594 struct cmd_remove_bonding_slave_result {
6595 cmdline_fixed_string_t remove;
6596 cmdline_fixed_string_t bonding;
6597 cmdline_fixed_string_t slave;
6602 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6603 __rte_unused struct cmdline *cl,
6604 __rte_unused void *data)
6606 struct cmd_remove_bonding_slave_result *res = parsed_result;
6607 portid_t master_port_id = res->port_id;
6608 portid_t slave_port_id = res->slave_id;
6610 /* remove the slave from a bonded device. */
6611 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6613 "\t Failed to remove slave %d from master port = %d.\n",
6614 slave_port_id, master_port_id);
6618 clear_port_slave_flag(slave_port_id);
6621 static cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6622 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6624 static cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6625 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6626 bonding, "bonding");
6627 static cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6628 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6630 static cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6631 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6632 slave_id, RTE_UINT16);
6633 static cmdline_parse_token_num_t cmd_removebonding_slave_port =
6634 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6635 port_id, RTE_UINT16);
6637 static cmdline_parse_inst_t cmd_remove_bonding_slave = {
6638 .f = cmd_remove_bonding_slave_parsed,
6639 .help_str = "remove bonding slave <slave_id> <port_id>: "
6640 "Remove a slave device from a bonded device",
6643 (void *)&cmd_removebonding_slave_remove,
6644 (void *)&cmd_removebonding_slave_bonding,
6645 (void *)&cmd_removebonding_slave_slave,
6646 (void *)&cmd_removebonding_slave_slaveid,
6647 (void *)&cmd_removebonding_slave_port,
6652 /* *** CREATE BONDED DEVICE *** */
6653 struct cmd_create_bonded_device_result {
6654 cmdline_fixed_string_t create;
6655 cmdline_fixed_string_t bonded;
6656 cmdline_fixed_string_t device;
6661 static int bond_dev_num = 0;
6663 static void cmd_create_bonded_device_parsed(void *parsed_result,
6664 __rte_unused struct cmdline *cl,
6665 __rte_unused void *data)
6667 struct cmd_create_bonded_device_result *res = parsed_result;
6668 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6672 if (test_done == 0) {
6673 fprintf(stderr, "Please stop forwarding first\n");
6677 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6680 /* Create a new bonded device. */
6681 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6683 fprintf(stderr, "\t Failed to create bonded device.\n");
6686 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6689 /* Update number of ports */
6690 nb_ports = rte_eth_dev_count_avail();
6691 reconfig(port_id, res->socket);
6692 ret = rte_eth_promiscuous_enable(port_id);
6695 "Failed to enable promiscuous mode for port %u: %s - ignore\n",
6696 port_id, rte_strerror(-ret));
6698 ports[port_id].bond_flag = 1;
6699 ports[port_id].need_setup = 0;
6700 ports[port_id].port_status = RTE_PORT_STOPPED;
6705 static cmdline_parse_token_string_t cmd_createbonded_device_create =
6706 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6708 static cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6709 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6711 static cmdline_parse_token_string_t cmd_createbonded_device_device =
6712 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6714 static cmdline_parse_token_num_t cmd_createbonded_device_mode =
6715 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6717 static cmdline_parse_token_num_t cmd_createbonded_device_socket =
6718 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6721 static cmdline_parse_inst_t cmd_create_bonded_device = {
6722 .f = cmd_create_bonded_device_parsed,
6723 .help_str = "create bonded device <mode> <socket>: "
6724 "Create a new bonded device with specific bonding mode and socket",
6727 (void *)&cmd_createbonded_device_create,
6728 (void *)&cmd_createbonded_device_bonded,
6729 (void *)&cmd_createbonded_device_device,
6730 (void *)&cmd_createbonded_device_mode,
6731 (void *)&cmd_createbonded_device_socket,
6736 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6737 struct cmd_set_bond_mac_addr_result {
6738 cmdline_fixed_string_t set;
6739 cmdline_fixed_string_t bonding;
6740 cmdline_fixed_string_t mac_addr;
6742 struct rte_ether_addr address;
6745 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6746 __rte_unused struct cmdline *cl,
6747 __rte_unused void *data)
6749 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6752 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6755 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6757 /* check the return value and print it if is < 0 */
6759 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6763 static cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6764 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6765 static cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6766 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6768 static cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6769 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6771 static cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6772 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6773 port_num, RTE_UINT16);
6774 static cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6775 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6777 static cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6778 .f = cmd_set_bond_mac_addr_parsed,
6780 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6782 (void *)&cmd_set_bond_mac_addr_set,
6783 (void *)&cmd_set_bond_mac_addr_bonding,
6784 (void *)&cmd_set_bond_mac_addr_mac,
6785 (void *)&cmd_set_bond_mac_addr_portnum,
6786 (void *)&cmd_set_bond_mac_addr_addr,
6792 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6793 struct cmd_set_bond_mon_period_result {
6794 cmdline_fixed_string_t set;
6795 cmdline_fixed_string_t bonding;
6796 cmdline_fixed_string_t mon_period;
6801 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6802 __rte_unused struct cmdline *cl,
6803 __rte_unused void *data)
6805 struct cmd_set_bond_mon_period_result *res = parsed_result;
6808 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6810 /* check the return value and print it if is < 0 */
6812 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6816 static cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6817 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6819 static cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6820 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6821 bonding, "bonding");
6822 static cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6823 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6824 mon_period, "mon_period");
6825 static cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6826 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6827 port_num, RTE_UINT16);
6828 static cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6829 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6830 period_ms, RTE_UINT32);
6832 static cmdline_parse_inst_t cmd_set_bond_mon_period = {
6833 .f = cmd_set_bond_mon_period_parsed,
6835 .help_str = "set bonding mon_period <port_id> <period_ms>",
6837 (void *)&cmd_set_bond_mon_period_set,
6838 (void *)&cmd_set_bond_mon_period_bonding,
6839 (void *)&cmd_set_bond_mon_period_mon_period,
6840 (void *)&cmd_set_bond_mon_period_portnum,
6841 (void *)&cmd_set_bond_mon_period_period_ms,
6848 struct cmd_set_bonding_agg_mode_policy_result {
6849 cmdline_fixed_string_t set;
6850 cmdline_fixed_string_t bonding;
6851 cmdline_fixed_string_t agg_mode;
6853 cmdline_fixed_string_t policy;
6858 cmd_set_bonding_agg_mode(void *parsed_result,
6859 __rte_unused struct cmdline *cl,
6860 __rte_unused void *data)
6862 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6863 uint8_t policy = AGG_BANDWIDTH;
6865 if (!strcmp(res->policy, "bandwidth"))
6866 policy = AGG_BANDWIDTH;
6867 else if (!strcmp(res->policy, "stable"))
6868 policy = AGG_STABLE;
6869 else if (!strcmp(res->policy, "count"))
6872 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6876 static cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6877 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6879 static cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6880 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6881 bonding, "bonding");
6883 static cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6884 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6885 agg_mode, "agg_mode");
6887 static cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6888 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6889 port_num, RTE_UINT16);
6891 static cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6892 TOKEN_STRING_INITIALIZER(
6893 struct cmd_set_bonding_balance_xmit_policy_result,
6894 policy, "stable#bandwidth#count");
6896 static cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6897 .f = cmd_set_bonding_agg_mode,
6899 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6901 (void *)&cmd_set_bonding_agg_mode_set,
6902 (void *)&cmd_set_bonding_agg_mode_bonding,
6903 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6904 (void *)&cmd_set_bonding_agg_mode_portnum,
6905 (void *)&cmd_set_bonding_agg_mode_policy_string,
6911 #endif /* RTE_NET_BOND */
6913 /* *** SET FORWARDING MODE *** */
6914 struct cmd_set_fwd_mode_result {
6915 cmdline_fixed_string_t set;
6916 cmdline_fixed_string_t fwd;
6917 cmdline_fixed_string_t mode;
6920 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6921 __rte_unused struct cmdline *cl,
6922 __rte_unused void *data)
6924 struct cmd_set_fwd_mode_result *res = parsed_result;
6927 set_pkt_forwarding_mode(res->mode);
6930 static cmdline_parse_token_string_t cmd_setfwd_set =
6931 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6932 static cmdline_parse_token_string_t cmd_setfwd_fwd =
6933 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6934 static cmdline_parse_token_string_t cmd_setfwd_mode =
6935 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6936 "" /* defined at init */);
6938 static cmdline_parse_inst_t cmd_set_fwd_mode = {
6939 .f = cmd_set_fwd_mode_parsed,
6941 .help_str = NULL, /* defined at init */
6943 (void *)&cmd_setfwd_set,
6944 (void *)&cmd_setfwd_fwd,
6945 (void *)&cmd_setfwd_mode,
6950 static void cmd_set_fwd_mode_init(void)
6953 static char token[128];
6954 static char help[256];
6955 cmdline_parse_token_string_t *token_struct;
6957 modes = list_pkt_forwarding_modes();
6958 snprintf(help, sizeof(help), "set fwd %s: "
6959 "Set packet forwarding mode", modes);
6960 cmd_set_fwd_mode.help_str = help;
6962 /* string token separator is # */
6963 for (c = token; *modes != '\0'; modes++)
6968 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6969 token_struct->string_data.str = token;
6972 /* *** SET RETRY FORWARDING MODE *** */
6973 struct cmd_set_fwd_retry_mode_result {
6974 cmdline_fixed_string_t set;
6975 cmdline_fixed_string_t fwd;
6976 cmdline_fixed_string_t mode;
6977 cmdline_fixed_string_t retry;
6980 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6981 __rte_unused struct cmdline *cl,
6982 __rte_unused void *data)
6984 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6987 set_pkt_forwarding_mode(res->mode);
6990 static cmdline_parse_token_string_t cmd_setfwd_retry_set =
6991 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6993 static cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6994 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6996 static cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6997 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6999 "" /* defined at init */);
7000 static cmdline_parse_token_string_t cmd_setfwd_retry_retry =
7001 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
7004 static cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
7005 .f = cmd_set_fwd_retry_mode_parsed,
7007 .help_str = NULL, /* defined at init */
7009 (void *)&cmd_setfwd_retry_set,
7010 (void *)&cmd_setfwd_retry_fwd,
7011 (void *)&cmd_setfwd_retry_mode,
7012 (void *)&cmd_setfwd_retry_retry,
7017 static void cmd_set_fwd_retry_mode_init(void)
7020 static char token[128];
7021 static char help[256];
7022 cmdline_parse_token_string_t *token_struct;
7024 modes = list_pkt_forwarding_retry_modes();
7025 snprintf(help, sizeof(help), "set fwd %s retry: "
7026 "Set packet forwarding mode with retry", modes);
7027 cmd_set_fwd_retry_mode.help_str = help;
7029 /* string token separator is # */
7030 for (c = token; *modes != '\0'; modes++)
7035 token_struct = (cmdline_parse_token_string_t *)
7036 cmd_set_fwd_retry_mode.tokens[2];
7037 token_struct->string_data.str = token;
7040 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
7041 struct cmd_set_burst_tx_retry_result {
7042 cmdline_fixed_string_t set;
7043 cmdline_fixed_string_t burst;
7044 cmdline_fixed_string_t tx;
7045 cmdline_fixed_string_t delay;
7047 cmdline_fixed_string_t retry;
7051 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
7052 __rte_unused struct cmdline *cl,
7053 __rte_unused void *data)
7055 struct cmd_set_burst_tx_retry_result *res = parsed_result;
7057 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
7058 && !strcmp(res->tx, "tx")) {
7059 if (!strcmp(res->delay, "delay"))
7060 burst_tx_delay_time = res->time;
7061 if (!strcmp(res->retry, "retry"))
7062 burst_tx_retry_num = res->retry_num;
7067 static cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
7068 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
7069 static cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
7070 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
7072 static cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
7073 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
7074 static cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
7075 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
7076 static cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
7077 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
7079 static cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
7080 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
7081 static cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
7082 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
7085 static cmdline_parse_inst_t cmd_set_burst_tx_retry = {
7086 .f = cmd_set_burst_tx_retry_parsed,
7087 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
7089 (void *)&cmd_set_burst_tx_retry_set,
7090 (void *)&cmd_set_burst_tx_retry_burst,
7091 (void *)&cmd_set_burst_tx_retry_tx,
7092 (void *)&cmd_set_burst_tx_retry_delay,
7093 (void *)&cmd_set_burst_tx_retry_time,
7094 (void *)&cmd_set_burst_tx_retry_retry,
7095 (void *)&cmd_set_burst_tx_retry_retry_num,
7100 /* *** SET PROMISC MODE *** */
7101 struct cmd_set_promisc_mode_result {
7102 cmdline_fixed_string_t set;
7103 cmdline_fixed_string_t promisc;
7104 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
7105 uint16_t port_num; /* valid if "allports" argument == 0 */
7106 cmdline_fixed_string_t mode;
7109 static void cmd_set_promisc_mode_parsed(void *parsed_result,
7110 __rte_unused struct cmdline *cl,
7113 struct cmd_set_promisc_mode_result *res = parsed_result;
7117 if (!strcmp(res->mode, "on"))
7124 RTE_ETH_FOREACH_DEV(i)
7125 eth_set_promisc_mode(i, enable);
7127 eth_set_promisc_mode(res->port_num, enable);
7131 static cmdline_parse_token_string_t cmd_setpromisc_set =
7132 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
7133 static cmdline_parse_token_string_t cmd_setpromisc_promisc =
7134 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
7136 static cmdline_parse_token_string_t cmd_setpromisc_portall =
7137 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
7139 static cmdline_parse_token_num_t cmd_setpromisc_portnum =
7140 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
7142 static cmdline_parse_token_string_t cmd_setpromisc_mode =
7143 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
7146 static cmdline_parse_inst_t cmd_set_promisc_mode_all = {
7147 .f = cmd_set_promisc_mode_parsed,
7149 .help_str = "set promisc all on|off: Set promisc mode for all ports",
7151 (void *)&cmd_setpromisc_set,
7152 (void *)&cmd_setpromisc_promisc,
7153 (void *)&cmd_setpromisc_portall,
7154 (void *)&cmd_setpromisc_mode,
7159 static cmdline_parse_inst_t cmd_set_promisc_mode_one = {
7160 .f = cmd_set_promisc_mode_parsed,
7162 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
7164 (void *)&cmd_setpromisc_set,
7165 (void *)&cmd_setpromisc_promisc,
7166 (void *)&cmd_setpromisc_portnum,
7167 (void *)&cmd_setpromisc_mode,
7172 /* *** SET ALLMULTI MODE *** */
7173 struct cmd_set_allmulti_mode_result {
7174 cmdline_fixed_string_t set;
7175 cmdline_fixed_string_t allmulti;
7176 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
7177 uint16_t port_num; /* valid if "allports" argument == 0 */
7178 cmdline_fixed_string_t mode;
7181 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
7182 __rte_unused struct cmdline *cl,
7185 struct cmd_set_allmulti_mode_result *res = parsed_result;
7189 if (!strcmp(res->mode, "on"))
7196 RTE_ETH_FOREACH_DEV(i) {
7197 eth_set_allmulticast_mode(i, enable);
7201 eth_set_allmulticast_mode(res->port_num, enable);
7205 static cmdline_parse_token_string_t cmd_setallmulti_set =
7206 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
7207 static cmdline_parse_token_string_t cmd_setallmulti_allmulti =
7208 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
7210 static cmdline_parse_token_string_t cmd_setallmulti_portall =
7211 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
7213 static cmdline_parse_token_num_t cmd_setallmulti_portnum =
7214 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
7216 static cmdline_parse_token_string_t cmd_setallmulti_mode =
7217 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
7220 static cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
7221 .f = cmd_set_allmulti_mode_parsed,
7223 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
7225 (void *)&cmd_setallmulti_set,
7226 (void *)&cmd_setallmulti_allmulti,
7227 (void *)&cmd_setallmulti_portall,
7228 (void *)&cmd_setallmulti_mode,
7233 static cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
7234 .f = cmd_set_allmulti_mode_parsed,
7236 .help_str = "set allmulti <port_id> on|off: "
7237 "Set allmulti mode on port_id",
7239 (void *)&cmd_setallmulti_set,
7240 (void *)&cmd_setallmulti_allmulti,
7241 (void *)&cmd_setallmulti_portnum,
7242 (void *)&cmd_setallmulti_mode,
7247 /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
7248 struct cmd_link_flow_ctrl_show {
7249 cmdline_fixed_string_t show;
7250 cmdline_fixed_string_t port;
7252 cmdline_fixed_string_t flow_ctrl;
7255 static cmdline_parse_token_string_t cmd_lfc_show_show =
7256 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7258 static cmdline_parse_token_string_t cmd_lfc_show_port =
7259 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7261 static cmdline_parse_token_num_t cmd_lfc_show_portid =
7262 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
7263 port_id, RTE_UINT16);
7264 static cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
7265 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7266 flow_ctrl, "flow_ctrl");
7269 cmd_link_flow_ctrl_show_parsed(void *parsed_result,
7270 __rte_unused struct cmdline *cl,
7271 __rte_unused void *data)
7273 struct cmd_link_flow_ctrl_show *res = parsed_result;
7274 static const char *info_border = "*********************";
7275 struct rte_eth_fc_conf fc_conf;
7276 bool rx_fc_en = false;
7277 bool tx_fc_en = false;
7280 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7283 "Failed to get current flow ctrl information: err = %d\n",
7288 if (fc_conf.mode == RTE_ETH_FC_RX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
7290 if (fc_conf.mode == RTE_ETH_FC_TX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
7293 printf("\n%s Flow control infos for port %-2d %s\n",
7294 info_border, res->port_id, info_border);
7295 printf("FC mode:\n");
7296 printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
7297 printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
7298 printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
7299 printf("Pause time: 0x%x\n", fc_conf.pause_time);
7300 printf("High waterline: 0x%x\n", fc_conf.high_water);
7301 printf("Low waterline: 0x%x\n", fc_conf.low_water);
7302 printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
7303 printf("Forward MAC control frames: %s\n",
7304 fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
7305 printf("\n%s************** End ***********%s\n",
7306 info_border, info_border);
7309 static cmdline_parse_inst_t cmd_link_flow_control_show = {
7310 .f = cmd_link_flow_ctrl_show_parsed,
7312 .help_str = "show port <port_id> flow_ctrl",
7314 (void *)&cmd_lfc_show_show,
7315 (void *)&cmd_lfc_show_port,
7316 (void *)&cmd_lfc_show_portid,
7317 (void *)&cmd_lfc_show_flow_ctrl,
7322 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
7323 struct cmd_link_flow_ctrl_set_result {
7324 cmdline_fixed_string_t set;
7325 cmdline_fixed_string_t flow_ctrl;
7326 cmdline_fixed_string_t rx;
7327 cmdline_fixed_string_t rx_lfc_mode;
7328 cmdline_fixed_string_t tx;
7329 cmdline_fixed_string_t tx_lfc_mode;
7330 cmdline_fixed_string_t mac_ctrl_frame_fwd;
7331 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
7332 cmdline_fixed_string_t autoneg_str;
7333 cmdline_fixed_string_t autoneg;
7334 cmdline_fixed_string_t hw_str;
7335 uint32_t high_water;
7336 cmdline_fixed_string_t lw_str;
7338 cmdline_fixed_string_t pt_str;
7339 uint16_t pause_time;
7340 cmdline_fixed_string_t xon_str;
7345 static cmdline_parse_token_string_t cmd_lfc_set_set =
7346 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7348 static cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
7349 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7350 flow_ctrl, "flow_ctrl");
7351 static cmdline_parse_token_string_t cmd_lfc_set_rx =
7352 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7354 static cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
7355 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7356 rx_lfc_mode, "on#off");
7357 static cmdline_parse_token_string_t cmd_lfc_set_tx =
7358 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7360 static cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7361 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7362 tx_lfc_mode, "on#off");
7363 static cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7364 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7365 hw_str, "high_water");
7366 static cmdline_parse_token_num_t cmd_lfc_set_high_water =
7367 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7368 high_water, RTE_UINT32);
7369 static cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7370 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7371 lw_str, "low_water");
7372 static cmdline_parse_token_num_t cmd_lfc_set_low_water =
7373 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7374 low_water, RTE_UINT32);
7375 static cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7376 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7377 pt_str, "pause_time");
7378 static cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7379 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7380 pause_time, RTE_UINT16);
7381 static cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7382 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7383 xon_str, "send_xon");
7384 static cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7385 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7386 send_xon, RTE_UINT16);
7387 static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7388 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7389 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7390 static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7391 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7392 mac_ctrl_frame_fwd_mode, "on#off");
7393 static cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7394 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7395 autoneg_str, "autoneg");
7396 static cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7397 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7399 static cmdline_parse_token_num_t cmd_lfc_set_portid =
7400 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7401 port_id, RTE_UINT16);
7403 /* forward declaration */
7405 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7408 static cmdline_parse_inst_t cmd_link_flow_control_set = {
7409 .f = cmd_link_flow_ctrl_set_parsed,
7411 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7412 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7413 "autoneg on|off <port_id>: Configure the Ethernet flow control",
7415 (void *)&cmd_lfc_set_set,
7416 (void *)&cmd_lfc_set_flow_ctrl,
7417 (void *)&cmd_lfc_set_rx,
7418 (void *)&cmd_lfc_set_rx_mode,
7419 (void *)&cmd_lfc_set_tx,
7420 (void *)&cmd_lfc_set_tx_mode,
7421 (void *)&cmd_lfc_set_high_water,
7422 (void *)&cmd_lfc_set_low_water,
7423 (void *)&cmd_lfc_set_pause_time,
7424 (void *)&cmd_lfc_set_send_xon,
7425 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7426 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7427 (void *)&cmd_lfc_set_autoneg_str,
7428 (void *)&cmd_lfc_set_autoneg,
7429 (void *)&cmd_lfc_set_portid,
7434 static cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7435 .f = cmd_link_flow_ctrl_set_parsed,
7436 .data = (void *)&cmd_link_flow_control_set_rx,
7437 .help_str = "set flow_ctrl rx on|off <port_id>: "
7438 "Change rx flow control parameter",
7440 (void *)&cmd_lfc_set_set,
7441 (void *)&cmd_lfc_set_flow_ctrl,
7442 (void *)&cmd_lfc_set_rx,
7443 (void *)&cmd_lfc_set_rx_mode,
7444 (void *)&cmd_lfc_set_portid,
7449 static cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7450 .f = cmd_link_flow_ctrl_set_parsed,
7451 .data = (void *)&cmd_link_flow_control_set_tx,
7452 .help_str = "set flow_ctrl tx on|off <port_id>: "
7453 "Change tx flow control parameter",
7455 (void *)&cmd_lfc_set_set,
7456 (void *)&cmd_lfc_set_flow_ctrl,
7457 (void *)&cmd_lfc_set_tx,
7458 (void *)&cmd_lfc_set_tx_mode,
7459 (void *)&cmd_lfc_set_portid,
7464 static cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7465 .f = cmd_link_flow_ctrl_set_parsed,
7466 .data = (void *)&cmd_link_flow_control_set_hw,
7467 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7468 "Change high water flow control parameter",
7470 (void *)&cmd_lfc_set_set,
7471 (void *)&cmd_lfc_set_flow_ctrl,
7472 (void *)&cmd_lfc_set_high_water_str,
7473 (void *)&cmd_lfc_set_high_water,
7474 (void *)&cmd_lfc_set_portid,
7479 static cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7480 .f = cmd_link_flow_ctrl_set_parsed,
7481 .data = (void *)&cmd_link_flow_control_set_lw,
7482 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7483 "Change low water flow control parameter",
7485 (void *)&cmd_lfc_set_set,
7486 (void *)&cmd_lfc_set_flow_ctrl,
7487 (void *)&cmd_lfc_set_low_water_str,
7488 (void *)&cmd_lfc_set_low_water,
7489 (void *)&cmd_lfc_set_portid,
7494 static cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7495 .f = cmd_link_flow_ctrl_set_parsed,
7496 .data = (void *)&cmd_link_flow_control_set_pt,
7497 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7498 "Change pause time flow control parameter",
7500 (void *)&cmd_lfc_set_set,
7501 (void *)&cmd_lfc_set_flow_ctrl,
7502 (void *)&cmd_lfc_set_pause_time_str,
7503 (void *)&cmd_lfc_set_pause_time,
7504 (void *)&cmd_lfc_set_portid,
7509 static cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7510 .f = cmd_link_flow_ctrl_set_parsed,
7511 .data = (void *)&cmd_link_flow_control_set_xon,
7512 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7513 "Change send_xon flow control parameter",
7515 (void *)&cmd_lfc_set_set,
7516 (void *)&cmd_lfc_set_flow_ctrl,
7517 (void *)&cmd_lfc_set_send_xon_str,
7518 (void *)&cmd_lfc_set_send_xon,
7519 (void *)&cmd_lfc_set_portid,
7524 static cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7525 .f = cmd_link_flow_ctrl_set_parsed,
7526 .data = (void *)&cmd_link_flow_control_set_macfwd,
7527 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7528 "Change mac ctrl fwd flow control parameter",
7530 (void *)&cmd_lfc_set_set,
7531 (void *)&cmd_lfc_set_flow_ctrl,
7532 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7533 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7534 (void *)&cmd_lfc_set_portid,
7539 static cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7540 .f = cmd_link_flow_ctrl_set_parsed,
7541 .data = (void *)&cmd_link_flow_control_set_autoneg,
7542 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7543 "Change autoneg flow control parameter",
7545 (void *)&cmd_lfc_set_set,
7546 (void *)&cmd_lfc_set_flow_ctrl,
7547 (void *)&cmd_lfc_set_autoneg_str,
7548 (void *)&cmd_lfc_set_autoneg,
7549 (void *)&cmd_lfc_set_portid,
7555 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7556 __rte_unused struct cmdline *cl,
7559 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7560 cmdline_parse_inst_t *cmd = data;
7561 struct rte_eth_fc_conf fc_conf;
7567 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7568 * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7569 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7570 * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7572 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7573 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7576 /* Partial command line, retrieve current configuration */
7578 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7581 "cannot get current flow ctrl parameters, return code = %d\n",
7586 if ((fc_conf.mode == RTE_ETH_FC_RX_PAUSE) ||
7587 (fc_conf.mode == RTE_ETH_FC_FULL))
7589 if ((fc_conf.mode == RTE_ETH_FC_TX_PAUSE) ||
7590 (fc_conf.mode == RTE_ETH_FC_FULL))
7594 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7595 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7597 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7598 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7600 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7602 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7603 fc_conf.high_water = res->high_water;
7605 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7606 fc_conf.low_water = res->low_water;
7608 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7609 fc_conf.pause_time = res->pause_time;
7611 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7612 fc_conf.send_xon = res->send_xon;
7614 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7615 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7616 fc_conf.mac_ctrl_frame_fwd = 1;
7618 fc_conf.mac_ctrl_frame_fwd = 0;
7621 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7622 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7624 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7627 "bad flow control parameter, return code = %d\n",
7631 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7632 struct cmd_priority_flow_ctrl_set_result {
7633 cmdline_fixed_string_t set;
7634 cmdline_fixed_string_t pfc_ctrl;
7635 cmdline_fixed_string_t rx;
7636 cmdline_fixed_string_t rx_pfc_mode;
7637 cmdline_fixed_string_t tx;
7638 cmdline_fixed_string_t tx_pfc_mode;
7639 uint32_t high_water;
7641 uint16_t pause_time;
7647 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7648 __rte_unused struct cmdline *cl,
7649 __rte_unused void *data)
7651 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7652 struct rte_eth_pfc_conf pfc_conf;
7653 int rx_fc_enable, tx_fc_enable;
7657 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7658 * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7659 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7660 * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7662 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7663 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7666 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7667 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7668 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7669 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7670 pfc_conf.fc.high_water = res->high_water;
7671 pfc_conf.fc.low_water = res->low_water;
7672 pfc_conf.fc.pause_time = res->pause_time;
7673 pfc_conf.priority = res->priority;
7675 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7678 "bad priority flow control parameter, return code = %d\n",
7682 static cmdline_parse_token_string_t cmd_pfc_set_set =
7683 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7685 static cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7686 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7687 pfc_ctrl, "pfc_ctrl");
7688 static cmdline_parse_token_string_t cmd_pfc_set_rx =
7689 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7691 static cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7692 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7693 rx_pfc_mode, "on#off");
7694 static cmdline_parse_token_string_t cmd_pfc_set_tx =
7695 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7697 static cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7698 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7699 tx_pfc_mode, "on#off");
7700 static cmdline_parse_token_num_t cmd_pfc_set_high_water =
7701 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7702 high_water, RTE_UINT32);
7703 static cmdline_parse_token_num_t cmd_pfc_set_low_water =
7704 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7705 low_water, RTE_UINT32);
7706 static cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7707 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7708 pause_time, RTE_UINT16);
7709 static cmdline_parse_token_num_t cmd_pfc_set_priority =
7710 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7711 priority, RTE_UINT8);
7712 static cmdline_parse_token_num_t cmd_pfc_set_portid =
7713 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7714 port_id, RTE_UINT16);
7716 static cmdline_parse_inst_t cmd_priority_flow_control_set = {
7717 .f = cmd_priority_flow_ctrl_set_parsed,
7719 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7720 "<pause_time> <priority> <port_id>: "
7721 "Configure the Ethernet priority flow control",
7723 (void *)&cmd_pfc_set_set,
7724 (void *)&cmd_pfc_set_flow_ctrl,
7725 (void *)&cmd_pfc_set_rx,
7726 (void *)&cmd_pfc_set_rx_mode,
7727 (void *)&cmd_pfc_set_tx,
7728 (void *)&cmd_pfc_set_tx_mode,
7729 (void *)&cmd_pfc_set_high_water,
7730 (void *)&cmd_pfc_set_low_water,
7731 (void *)&cmd_pfc_set_pause_time,
7732 (void *)&cmd_pfc_set_priority,
7733 (void *)&cmd_pfc_set_portid,
7738 struct cmd_queue_priority_flow_ctrl_set_result {
7739 cmdline_fixed_string_t set;
7740 cmdline_fixed_string_t pfc_queue_ctrl;
7742 cmdline_fixed_string_t rx;
7743 cmdline_fixed_string_t rx_pfc_mode;
7746 cmdline_fixed_string_t tx;
7747 cmdline_fixed_string_t tx_pfc_mode;
7750 uint16_t pause_time;
7754 cmd_queue_priority_flow_ctrl_set_parsed(void *parsed_result,
7755 __rte_unused struct cmdline *cl,
7756 __rte_unused void *data)
7758 struct cmd_queue_priority_flow_ctrl_set_result *res = parsed_result;
7759 struct rte_eth_pfc_queue_conf pfc_queue_conf;
7760 int rx_fc_enable, tx_fc_enable;
7764 * Rx on/off, flow control is enabled/disabled on RX side. This can
7765 * indicate the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx
7766 * side. Tx on/off, flow control is enabled/disabled on TX side. This
7767 * can indicate the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at
7770 static enum rte_eth_fc_mode rx_tx_onoff_2_mode[2][2] = {
7771 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE},
7772 {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7775 memset(&pfc_queue_conf, 0, sizeof(struct rte_eth_pfc_queue_conf));
7776 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on", 2)) ? 1 : 0;
7777 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on", 2)) ? 1 : 0;
7778 pfc_queue_conf.mode = rx_tx_onoff_2_mode[rx_fc_enable][tx_fc_enable];
7779 pfc_queue_conf.rx_pause.tc = res->tx_tc;
7780 pfc_queue_conf.rx_pause.tx_qid = res->tx_qid;
7781 pfc_queue_conf.tx_pause.tc = res->rx_tc;
7782 pfc_queue_conf.tx_pause.rx_qid = res->rx_qid;
7783 pfc_queue_conf.tx_pause.pause_time = res->pause_time;
7785 ret = rte_eth_dev_priority_flow_ctrl_queue_configure(res->port_id,
7789 "bad queue priority flow control parameter, rc = %d\n",
7794 static cmdline_parse_token_string_t cmd_q_pfc_set_set =
7795 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7797 static cmdline_parse_token_string_t cmd_q_pfc_set_flow_ctrl =
7798 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7799 pfc_queue_ctrl, "pfc_queue_ctrl");
7800 static cmdline_parse_token_num_t cmd_q_pfc_set_portid =
7801 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7802 port_id, RTE_UINT16);
7803 static cmdline_parse_token_string_t cmd_q_pfc_set_rx =
7804 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7806 static cmdline_parse_token_string_t cmd_q_pfc_set_rx_mode =
7807 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7808 rx_pfc_mode, "on#off");
7809 static cmdline_parse_token_num_t cmd_q_pfc_set_tx_qid =
7810 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7811 tx_qid, RTE_UINT16);
7812 static cmdline_parse_token_num_t cmd_q_pfc_set_tx_tc =
7813 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7815 static cmdline_parse_token_string_t cmd_q_pfc_set_tx =
7816 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7818 static cmdline_parse_token_string_t cmd_q_pfc_set_tx_mode =
7819 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7820 tx_pfc_mode, "on#off");
7821 static cmdline_parse_token_num_t cmd_q_pfc_set_rx_qid =
7822 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7823 rx_qid, RTE_UINT16);
7824 static cmdline_parse_token_num_t cmd_q_pfc_set_rx_tc =
7825 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7827 static cmdline_parse_token_num_t cmd_q_pfc_set_pause_time =
7828 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7829 pause_time, RTE_UINT16);
7831 static cmdline_parse_inst_t cmd_queue_priority_flow_control_set = {
7832 .f = cmd_queue_priority_flow_ctrl_set_parsed,
7834 .help_str = "set pfc_queue_ctrl <port_id> rx <on|off> <tx_qid> <tx_tc> "
7835 "tx <on|off> <rx_qid> <rx_tc> <pause_time>: "
7836 "Configure the Ethernet queue priority flow control",
7838 (void *)&cmd_q_pfc_set_set,
7839 (void *)&cmd_q_pfc_set_flow_ctrl,
7840 (void *)&cmd_q_pfc_set_portid,
7841 (void *)&cmd_q_pfc_set_rx,
7842 (void *)&cmd_q_pfc_set_rx_mode,
7843 (void *)&cmd_q_pfc_set_tx_qid,
7844 (void *)&cmd_q_pfc_set_tx_tc,
7845 (void *)&cmd_q_pfc_set_tx,
7846 (void *)&cmd_q_pfc_set_tx_mode,
7847 (void *)&cmd_q_pfc_set_rx_qid,
7848 (void *)&cmd_q_pfc_set_rx_tc,
7849 (void *)&cmd_q_pfc_set_pause_time,
7854 /* *** RESET CONFIGURATION *** */
7855 struct cmd_reset_result {
7856 cmdline_fixed_string_t reset;
7857 cmdline_fixed_string_t def;
7860 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7862 __rte_unused void *data)
7864 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7865 set_def_fwd_config();
7868 static cmdline_parse_token_string_t cmd_reset_set =
7869 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7870 static cmdline_parse_token_string_t cmd_reset_def =
7871 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7874 static cmdline_parse_inst_t cmd_reset = {
7875 .f = cmd_reset_parsed,
7877 .help_str = "set default: Reset default forwarding configuration",
7879 (void *)&cmd_reset_set,
7880 (void *)&cmd_reset_def,
7885 /* *** START FORWARDING *** */
7886 struct cmd_start_result {
7887 cmdline_fixed_string_t start;
7890 static cmdline_parse_token_string_t cmd_start_start =
7891 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7893 static void cmd_start_parsed(__rte_unused void *parsed_result,
7894 __rte_unused struct cmdline *cl,
7895 __rte_unused void *data)
7897 start_packet_forwarding(0);
7900 static cmdline_parse_inst_t cmd_start = {
7901 .f = cmd_start_parsed,
7903 .help_str = "start: Start packet forwarding",
7905 (void *)&cmd_start_start,
7910 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7911 struct cmd_start_tx_first_result {
7912 cmdline_fixed_string_t start;
7913 cmdline_fixed_string_t tx_first;
7917 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7918 __rte_unused struct cmdline *cl,
7919 __rte_unused void *data)
7921 start_packet_forwarding(1);
7924 static cmdline_parse_token_string_t cmd_start_tx_first_start =
7925 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7927 static cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7928 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7929 tx_first, "tx_first");
7931 static cmdline_parse_inst_t cmd_start_tx_first = {
7932 .f = cmd_start_tx_first_parsed,
7934 .help_str = "start tx_first: Start packet forwarding, "
7935 "after sending 1 burst of packets",
7937 (void *)&cmd_start_tx_first_start,
7938 (void *)&cmd_start_tx_first_tx_first,
7943 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7944 struct cmd_start_tx_first_n_result {
7945 cmdline_fixed_string_t start;
7946 cmdline_fixed_string_t tx_first;
7951 cmd_start_tx_first_n_parsed(void *parsed_result,
7952 __rte_unused struct cmdline *cl,
7953 __rte_unused void *data)
7955 struct cmd_start_tx_first_n_result *res = parsed_result;
7957 start_packet_forwarding(res->tx_num);
7960 static cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7961 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7963 static cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7964 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7965 tx_first, "tx_first");
7966 static cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7967 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7968 tx_num, RTE_UINT32);
7970 static cmdline_parse_inst_t cmd_start_tx_first_n = {
7971 .f = cmd_start_tx_first_n_parsed,
7973 .help_str = "start tx_first <num>: "
7974 "packet forwarding, after sending <num> bursts of packets",
7976 (void *)&cmd_start_tx_first_n_start,
7977 (void *)&cmd_start_tx_first_n_tx_first,
7978 (void *)&cmd_start_tx_first_n_tx_num,
7983 /* *** SET LINK UP *** */
7984 struct cmd_set_link_up_result {
7985 cmdline_fixed_string_t set;
7986 cmdline_fixed_string_t link_up;
7987 cmdline_fixed_string_t port;
7991 static cmdline_parse_token_string_t cmd_set_link_up_set =
7992 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7993 static cmdline_parse_token_string_t cmd_set_link_up_link_up =
7994 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7996 static cmdline_parse_token_string_t cmd_set_link_up_port =
7997 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7998 static cmdline_parse_token_num_t cmd_set_link_up_port_id =
7999 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
8002 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
8003 __rte_unused struct cmdline *cl,
8004 __rte_unused void *data)
8006 struct cmd_set_link_up_result *res = parsed_result;
8007 dev_set_link_up(res->port_id);
8010 static cmdline_parse_inst_t cmd_set_link_up = {
8011 .f = cmd_set_link_up_parsed,
8013 .help_str = "set link-up port <port id>",
8015 (void *)&cmd_set_link_up_set,
8016 (void *)&cmd_set_link_up_link_up,
8017 (void *)&cmd_set_link_up_port,
8018 (void *)&cmd_set_link_up_port_id,
8023 /* *** SET LINK DOWN *** */
8024 struct cmd_set_link_down_result {
8025 cmdline_fixed_string_t set;
8026 cmdline_fixed_string_t link_down;
8027 cmdline_fixed_string_t port;
8031 static cmdline_parse_token_string_t cmd_set_link_down_set =
8032 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
8033 static cmdline_parse_token_string_t cmd_set_link_down_link_down =
8034 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
8036 static cmdline_parse_token_string_t cmd_set_link_down_port =
8037 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
8038 static cmdline_parse_token_num_t cmd_set_link_down_port_id =
8039 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
8042 static void cmd_set_link_down_parsed(
8043 __rte_unused void *parsed_result,
8044 __rte_unused struct cmdline *cl,
8045 __rte_unused void *data)
8047 struct cmd_set_link_down_result *res = parsed_result;
8048 dev_set_link_down(res->port_id);
8051 static cmdline_parse_inst_t cmd_set_link_down = {
8052 .f = cmd_set_link_down_parsed,
8054 .help_str = "set link-down port <port id>",
8056 (void *)&cmd_set_link_down_set,
8057 (void *)&cmd_set_link_down_link_down,
8058 (void *)&cmd_set_link_down_port,
8059 (void *)&cmd_set_link_down_port_id,
8064 /* *** SHOW CFG *** */
8065 struct cmd_showcfg_result {
8066 cmdline_fixed_string_t show;
8067 cmdline_fixed_string_t cfg;
8068 cmdline_fixed_string_t what;
8071 static void cmd_showcfg_parsed(void *parsed_result,
8072 __rte_unused struct cmdline *cl,
8073 __rte_unused void *data)
8075 struct cmd_showcfg_result *res = parsed_result;
8076 if (!strcmp(res->what, "rxtx"))
8077 rxtx_config_display();
8078 else if (!strcmp(res->what, "cores"))
8079 fwd_lcores_config_display();
8080 else if (!strcmp(res->what, "fwd"))
8081 pkt_fwd_config_display(&cur_fwd_config);
8082 else if (!strcmp(res->what, "rxoffs"))
8083 show_rx_pkt_offsets();
8084 else if (!strcmp(res->what, "rxpkts"))
8085 show_rx_pkt_segments();
8086 else if (!strcmp(res->what, "txpkts"))
8087 show_tx_pkt_segments();
8088 else if (!strcmp(res->what, "txtimes"))
8089 show_tx_pkt_times();
8092 static cmdline_parse_token_string_t cmd_showcfg_show =
8093 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
8094 static cmdline_parse_token_string_t cmd_showcfg_port =
8095 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
8096 static cmdline_parse_token_string_t cmd_showcfg_what =
8097 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
8098 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
8100 static cmdline_parse_inst_t cmd_showcfg = {
8101 .f = cmd_showcfg_parsed,
8103 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
8105 (void *)&cmd_showcfg_show,
8106 (void *)&cmd_showcfg_port,
8107 (void *)&cmd_showcfg_what,
8112 /* *** SHOW ALL PORT INFO *** */
8113 struct cmd_showportall_result {
8114 cmdline_fixed_string_t show;
8115 cmdline_fixed_string_t port;
8116 cmdline_fixed_string_t what;
8117 cmdline_fixed_string_t all;
8120 static void cmd_showportall_parsed(void *parsed_result,
8121 __rte_unused struct cmdline *cl,
8122 __rte_unused void *data)
8126 struct cmd_showportall_result *res = parsed_result;
8127 if (!strcmp(res->show, "clear")) {
8128 if (!strcmp(res->what, "stats"))
8129 RTE_ETH_FOREACH_DEV(i)
8131 else if (!strcmp(res->what, "xstats"))
8132 RTE_ETH_FOREACH_DEV(i)
8133 nic_xstats_clear(i);
8134 } else if (!strcmp(res->what, "info"))
8135 RTE_ETH_FOREACH_DEV(i)
8136 port_infos_display(i);
8137 else if (!strcmp(res->what, "summary")) {
8138 port_summary_header_display();
8139 RTE_ETH_FOREACH_DEV(i)
8140 port_summary_display(i);
8142 else if (!strcmp(res->what, "stats"))
8143 RTE_ETH_FOREACH_DEV(i)
8144 nic_stats_display(i);
8145 else if (!strcmp(res->what, "xstats"))
8146 RTE_ETH_FOREACH_DEV(i)
8147 nic_xstats_display(i);
8148 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
8149 else if (!strcmp(res->what, "fdir"))
8150 RTE_ETH_FOREACH_DEV(i)
8153 else if (!strcmp(res->what, "dcb_tc"))
8154 RTE_ETH_FOREACH_DEV(i)
8155 port_dcb_info_display(i);
8158 static cmdline_parse_token_string_t cmd_showportall_show =
8159 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
8161 static cmdline_parse_token_string_t cmd_showportall_port =
8162 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
8163 static cmdline_parse_token_string_t cmd_showportall_what =
8164 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
8165 "info#summary#stats#xstats#fdir#dcb_tc");
8166 static cmdline_parse_token_string_t cmd_showportall_all =
8167 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
8168 static cmdline_parse_inst_t cmd_showportall = {
8169 .f = cmd_showportall_parsed,
8171 .help_str = "show|clear port "
8172 "info|summary|stats|xstats|fdir|dcb_tc all",
8174 (void *)&cmd_showportall_show,
8175 (void *)&cmd_showportall_port,
8176 (void *)&cmd_showportall_what,
8177 (void *)&cmd_showportall_all,
8182 /* *** SHOW PORT INFO *** */
8183 struct cmd_showport_result {
8184 cmdline_fixed_string_t show;
8185 cmdline_fixed_string_t port;
8186 cmdline_fixed_string_t what;
8190 static void cmd_showport_parsed(void *parsed_result,
8191 __rte_unused struct cmdline *cl,
8192 __rte_unused void *data)
8194 struct cmd_showport_result *res = parsed_result;
8195 if (!strcmp(res->show, "clear")) {
8196 if (!strcmp(res->what, "stats"))
8197 nic_stats_clear(res->portnum);
8198 else if (!strcmp(res->what, "xstats"))
8199 nic_xstats_clear(res->portnum);
8200 } else if (!strcmp(res->what, "info"))
8201 port_infos_display(res->portnum);
8202 else if (!strcmp(res->what, "summary")) {
8203 port_summary_header_display();
8204 port_summary_display(res->portnum);
8206 else if (!strcmp(res->what, "stats"))
8207 nic_stats_display(res->portnum);
8208 else if (!strcmp(res->what, "xstats"))
8209 nic_xstats_display(res->portnum);
8210 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
8211 else if (!strcmp(res->what, "fdir"))
8212 fdir_get_infos(res->portnum);
8214 else if (!strcmp(res->what, "dcb_tc"))
8215 port_dcb_info_display(res->portnum);
8218 static cmdline_parse_token_string_t cmd_showport_show =
8219 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
8221 static cmdline_parse_token_string_t cmd_showport_port =
8222 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
8223 static cmdline_parse_token_string_t cmd_showport_what =
8224 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
8225 "info#summary#stats#xstats#fdir#dcb_tc");
8226 static cmdline_parse_token_num_t cmd_showport_portnum =
8227 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
8229 static cmdline_parse_inst_t cmd_showport = {
8230 .f = cmd_showport_parsed,
8232 .help_str = "show|clear port "
8233 "info|summary|stats|xstats|fdir|dcb_tc "
8236 (void *)&cmd_showport_show,
8237 (void *)&cmd_showport_port,
8238 (void *)&cmd_showport_what,
8239 (void *)&cmd_showport_portnum,
8244 /* *** show port representors information *** */
8245 struct cmd_representor_info_result {
8246 cmdline_fixed_string_t cmd_show;
8247 cmdline_fixed_string_t cmd_port;
8248 cmdline_fixed_string_t cmd_info;
8249 cmdline_fixed_string_t cmd_keyword;
8254 cmd_representor_info_parsed(void *parsed_result,
8255 __rte_unused struct cmdline *cl,
8256 __rte_unused void *data)
8258 struct cmd_representor_info_result *res = parsed_result;
8259 struct rte_eth_representor_info *info;
8260 struct rte_eth_representor_range *range;
8261 uint32_t range_diff;
8266 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
8267 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
8271 ret = rte_eth_representor_info_get(res->cmd_pid, NULL);
8274 "Failed to get the number of representor info ranges for port %hu: %s\n",
8275 res->cmd_pid, rte_strerror(-ret));
8280 info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0]));
8283 "Failed to allocate memory for representor info for port %hu\n",
8287 info->nb_ranges_alloc = num;
8289 ret = rte_eth_representor_info_get(res->cmd_pid, info);
8292 "Failed to get the representor info for port %hu: %s\n",
8293 res->cmd_pid, rte_strerror(-ret));
8298 printf("Port controller: %hu\n", info->controller);
8299 printf("Port PF: %hu\n", info->pf);
8301 printf("Ranges: %u\n", info->nb_ranges);
8302 for (i = 0; i < info->nb_ranges; i++) {
8303 range = &info->ranges[i];
8304 range_diff = range->id_end - range->id_base;
8306 printf("%u. ", i + 1);
8307 printf("'%s' ", range->name);
8309 printf("[%u-%u]: ", range->id_base, range->id_end);
8311 printf("[%u]: ", range->id_base);
8313 printf("Controller %d, PF %d", range->controller, range->pf);
8315 switch (range->type) {
8316 case RTE_ETH_REPRESENTOR_NONE:
8319 case RTE_ETH_REPRESENTOR_VF:
8321 printf(", VF %d..%d\n", range->vf,
8322 range->vf + range_diff);
8324 printf(", VF %d\n", range->vf);
8326 case RTE_ETH_REPRESENTOR_SF:
8327 printf(", SF %d\n", range->sf);
8329 case RTE_ETH_REPRESENTOR_PF:
8331 printf("..%d\n", range->pf + range_diff);
8336 printf(", UNKNOWN TYPE %d\n", range->type);
8344 static cmdline_parse_token_string_t cmd_representor_info_show =
8345 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8347 static cmdline_parse_token_string_t cmd_representor_info_port =
8348 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8350 static cmdline_parse_token_string_t cmd_representor_info_info =
8351 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8353 static cmdline_parse_token_num_t cmd_representor_info_pid =
8354 TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result,
8355 cmd_pid, RTE_UINT16);
8356 static cmdline_parse_token_string_t cmd_representor_info_keyword =
8357 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8358 cmd_keyword, "representor");
8360 static cmdline_parse_inst_t cmd_representor_info = {
8361 .f = cmd_representor_info_parsed,
8363 .help_str = "show port info <port_id> representor",
8365 (void *)&cmd_representor_info_show,
8366 (void *)&cmd_representor_info_port,
8367 (void *)&cmd_representor_info_info,
8368 (void *)&cmd_representor_info_pid,
8369 (void *)&cmd_representor_info_keyword,
8375 /* *** SHOW DEVICE INFO *** */
8376 struct cmd_showdevice_result {
8377 cmdline_fixed_string_t show;
8378 cmdline_fixed_string_t device;
8379 cmdline_fixed_string_t what;
8380 cmdline_fixed_string_t identifier;
8383 static void cmd_showdevice_parsed(void *parsed_result,
8384 __rte_unused struct cmdline *cl,
8385 __rte_unused void *data)
8387 struct cmd_showdevice_result *res = parsed_result;
8388 if (!strcmp(res->what, "info")) {
8389 if (!strcmp(res->identifier, "all"))
8390 device_infos_display(NULL);
8392 device_infos_display(res->identifier);
8396 static cmdline_parse_token_string_t cmd_showdevice_show =
8397 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
8399 static cmdline_parse_token_string_t cmd_showdevice_device =
8400 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
8401 static cmdline_parse_token_string_t cmd_showdevice_what =
8402 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
8404 static cmdline_parse_token_string_t cmd_showdevice_identifier =
8405 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
8408 static cmdline_parse_inst_t cmd_showdevice = {
8409 .f = cmd_showdevice_parsed,
8411 .help_str = "show device info <identifier>|all",
8413 (void *)&cmd_showdevice_show,
8414 (void *)&cmd_showdevice_device,
8415 (void *)&cmd_showdevice_what,
8416 (void *)&cmd_showdevice_identifier,
8421 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
8422 struct cmd_showeeprom_result {
8423 cmdline_fixed_string_t show;
8424 cmdline_fixed_string_t port;
8426 cmdline_fixed_string_t type;
8429 static void cmd_showeeprom_parsed(void *parsed_result,
8430 __rte_unused struct cmdline *cl,
8431 __rte_unused void *data)
8433 struct cmd_showeeprom_result *res = parsed_result;
8435 if (!strcmp(res->type, "eeprom"))
8436 port_eeprom_display(res->portnum);
8437 else if (!strcmp(res->type, "module_eeprom"))
8438 port_module_eeprom_display(res->portnum);
8440 fprintf(stderr, "Unknown argument\n");
8443 static cmdline_parse_token_string_t cmd_showeeprom_show =
8444 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
8445 static cmdline_parse_token_string_t cmd_showeeprom_port =
8446 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
8447 static cmdline_parse_token_num_t cmd_showeeprom_portnum =
8448 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
8450 static cmdline_parse_token_string_t cmd_showeeprom_type =
8451 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
8453 static cmdline_parse_inst_t cmd_showeeprom = {
8454 .f = cmd_showeeprom_parsed,
8456 .help_str = "show port <port_id> module_eeprom|eeprom",
8458 (void *)&cmd_showeeprom_show,
8459 (void *)&cmd_showeeprom_port,
8460 (void *)&cmd_showeeprom_portnum,
8461 (void *)&cmd_showeeprom_type,
8466 /* *** SHOW QUEUE INFO *** */
8467 struct cmd_showqueue_result {
8468 cmdline_fixed_string_t show;
8469 cmdline_fixed_string_t type;
8470 cmdline_fixed_string_t what;
8476 cmd_showqueue_parsed(void *parsed_result,
8477 __rte_unused struct cmdline *cl,
8478 __rte_unused void *data)
8480 struct cmd_showqueue_result *res = parsed_result;
8482 if (!strcmp(res->type, "rxq"))
8483 rx_queue_infos_display(res->portnum, res->queuenum);
8484 else if (!strcmp(res->type, "txq"))
8485 tx_queue_infos_display(res->portnum, res->queuenum);
8488 static cmdline_parse_token_string_t cmd_showqueue_show =
8489 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
8490 static cmdline_parse_token_string_t cmd_showqueue_type =
8491 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
8492 static cmdline_parse_token_string_t cmd_showqueue_what =
8493 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
8494 static cmdline_parse_token_num_t cmd_showqueue_portnum =
8495 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
8497 static cmdline_parse_token_num_t cmd_showqueue_queuenum =
8498 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
8501 static cmdline_parse_inst_t cmd_showqueue = {
8502 .f = cmd_showqueue_parsed,
8504 .help_str = "show rxq|txq info <port_id> <queue_id>",
8506 (void *)&cmd_showqueue_show,
8507 (void *)&cmd_showqueue_type,
8508 (void *)&cmd_showqueue_what,
8509 (void *)&cmd_showqueue_portnum,
8510 (void *)&cmd_showqueue_queuenum,
8515 /* show/clear fwd engine statistics */
8517 cmdline_fixed_string_t action;
8518 cmdline_fixed_string_t fwd;
8519 cmdline_fixed_string_t stats;
8520 cmdline_fixed_string_t all;
8523 static cmdline_parse_token_string_t cmd_fwd_action =
8524 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
8525 static cmdline_parse_token_string_t cmd_fwd_fwd =
8526 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
8527 static cmdline_parse_token_string_t cmd_fwd_stats =
8528 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
8529 static cmdline_parse_token_string_t cmd_fwd_all =
8530 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
8533 cmd_showfwdall_parsed(void *parsed_result,
8534 __rte_unused struct cmdline *cl,
8535 __rte_unused void *data)
8537 struct fwd_result *res = parsed_result;
8539 if (!strcmp(res->action, "show"))
8540 fwd_stats_display();
8545 static cmdline_parse_inst_t cmd_showfwdall = {
8546 .f = cmd_showfwdall_parsed,
8548 .help_str = "show|clear fwd stats all",
8550 (void *)&cmd_fwd_action,
8551 (void *)&cmd_fwd_fwd,
8552 (void *)&cmd_fwd_stats,
8553 (void *)&cmd_fwd_all,
8558 /* *** READ PORT REGISTER *** */
8559 struct cmd_read_reg_result {
8560 cmdline_fixed_string_t read;
8561 cmdline_fixed_string_t reg;
8567 cmd_read_reg_parsed(void *parsed_result,
8568 __rte_unused struct cmdline *cl,
8569 __rte_unused void *data)
8571 struct cmd_read_reg_result *res = parsed_result;
8572 port_reg_display(res->port_id, res->reg_off);
8575 static cmdline_parse_token_string_t cmd_read_reg_read =
8576 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
8577 static cmdline_parse_token_string_t cmd_read_reg_reg =
8578 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
8579 static cmdline_parse_token_num_t cmd_read_reg_port_id =
8580 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
8581 static cmdline_parse_token_num_t cmd_read_reg_reg_off =
8582 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
8584 static cmdline_parse_inst_t cmd_read_reg = {
8585 .f = cmd_read_reg_parsed,
8587 .help_str = "read reg <port_id> <reg_off>",
8589 (void *)&cmd_read_reg_read,
8590 (void *)&cmd_read_reg_reg,
8591 (void *)&cmd_read_reg_port_id,
8592 (void *)&cmd_read_reg_reg_off,
8597 /* *** READ PORT REGISTER BIT FIELD *** */
8598 struct cmd_read_reg_bit_field_result {
8599 cmdline_fixed_string_t read;
8600 cmdline_fixed_string_t regfield;
8608 cmd_read_reg_bit_field_parsed(void *parsed_result,
8609 __rte_unused struct cmdline *cl,
8610 __rte_unused void *data)
8612 struct cmd_read_reg_bit_field_result *res = parsed_result;
8613 port_reg_bit_field_display(res->port_id, res->reg_off,
8614 res->bit1_pos, res->bit2_pos);
8617 static cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8618 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8620 static cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8621 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8622 regfield, "regfield");
8623 static cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8624 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8626 static cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8627 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8629 static cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8630 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8632 static cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8633 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8636 static cmdline_parse_inst_t cmd_read_reg_bit_field = {
8637 .f = cmd_read_reg_bit_field_parsed,
8639 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8640 "Read register bit field between bit_x and bit_y included",
8642 (void *)&cmd_read_reg_bit_field_read,
8643 (void *)&cmd_read_reg_bit_field_regfield,
8644 (void *)&cmd_read_reg_bit_field_port_id,
8645 (void *)&cmd_read_reg_bit_field_reg_off,
8646 (void *)&cmd_read_reg_bit_field_bit1_pos,
8647 (void *)&cmd_read_reg_bit_field_bit2_pos,
8652 /* *** READ PORT REGISTER BIT *** */
8653 struct cmd_read_reg_bit_result {
8654 cmdline_fixed_string_t read;
8655 cmdline_fixed_string_t regbit;
8662 cmd_read_reg_bit_parsed(void *parsed_result,
8663 __rte_unused struct cmdline *cl,
8664 __rte_unused void *data)
8666 struct cmd_read_reg_bit_result *res = parsed_result;
8667 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8670 static cmdline_parse_token_string_t cmd_read_reg_bit_read =
8671 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8672 static cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8673 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8675 static cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8676 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
8678 static cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8679 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
8681 static cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8682 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
8685 static cmdline_parse_inst_t cmd_read_reg_bit = {
8686 .f = cmd_read_reg_bit_parsed,
8688 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8690 (void *)&cmd_read_reg_bit_read,
8691 (void *)&cmd_read_reg_bit_regbit,
8692 (void *)&cmd_read_reg_bit_port_id,
8693 (void *)&cmd_read_reg_bit_reg_off,
8694 (void *)&cmd_read_reg_bit_bit_pos,
8699 /* *** WRITE PORT REGISTER *** */
8700 struct cmd_write_reg_result {
8701 cmdline_fixed_string_t write;
8702 cmdline_fixed_string_t reg;
8709 cmd_write_reg_parsed(void *parsed_result,
8710 __rte_unused struct cmdline *cl,
8711 __rte_unused void *data)
8713 struct cmd_write_reg_result *res = parsed_result;
8714 port_reg_set(res->port_id, res->reg_off, res->value);
8717 static cmdline_parse_token_string_t cmd_write_reg_write =
8718 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8719 static cmdline_parse_token_string_t cmd_write_reg_reg =
8720 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8721 static cmdline_parse_token_num_t cmd_write_reg_port_id =
8722 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8723 static cmdline_parse_token_num_t cmd_write_reg_reg_off =
8724 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8725 static cmdline_parse_token_num_t cmd_write_reg_value =
8726 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8728 static cmdline_parse_inst_t cmd_write_reg = {
8729 .f = cmd_write_reg_parsed,
8731 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8733 (void *)&cmd_write_reg_write,
8734 (void *)&cmd_write_reg_reg,
8735 (void *)&cmd_write_reg_port_id,
8736 (void *)&cmd_write_reg_reg_off,
8737 (void *)&cmd_write_reg_value,
8742 /* *** WRITE PORT REGISTER BIT FIELD *** */
8743 struct cmd_write_reg_bit_field_result {
8744 cmdline_fixed_string_t write;
8745 cmdline_fixed_string_t regfield;
8754 cmd_write_reg_bit_field_parsed(void *parsed_result,
8755 __rte_unused struct cmdline *cl,
8756 __rte_unused void *data)
8758 struct cmd_write_reg_bit_field_result *res = parsed_result;
8759 port_reg_bit_field_set(res->port_id, res->reg_off,
8760 res->bit1_pos, res->bit2_pos, res->value);
8763 static cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8764 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8766 static cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8767 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8768 regfield, "regfield");
8769 static cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8770 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8772 static cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8773 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8775 static cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8776 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8778 static cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8779 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8781 static cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8782 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8785 static cmdline_parse_inst_t cmd_write_reg_bit_field = {
8786 .f = cmd_write_reg_bit_field_parsed,
8788 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8790 "Set register bit field between bit_x and bit_y included",
8792 (void *)&cmd_write_reg_bit_field_write,
8793 (void *)&cmd_write_reg_bit_field_regfield,
8794 (void *)&cmd_write_reg_bit_field_port_id,
8795 (void *)&cmd_write_reg_bit_field_reg_off,
8796 (void *)&cmd_write_reg_bit_field_bit1_pos,
8797 (void *)&cmd_write_reg_bit_field_bit2_pos,
8798 (void *)&cmd_write_reg_bit_field_value,
8803 /* *** WRITE PORT REGISTER BIT *** */
8804 struct cmd_write_reg_bit_result {
8805 cmdline_fixed_string_t write;
8806 cmdline_fixed_string_t regbit;
8814 cmd_write_reg_bit_parsed(void *parsed_result,
8815 __rte_unused struct cmdline *cl,
8816 __rte_unused void *data)
8818 struct cmd_write_reg_bit_result *res = parsed_result;
8819 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8822 static cmdline_parse_token_string_t cmd_write_reg_bit_write =
8823 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8825 static cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8826 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8828 static cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8829 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8831 static cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8832 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8834 static cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8835 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8837 static cmdline_parse_token_num_t cmd_write_reg_bit_value =
8838 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8841 static cmdline_parse_inst_t cmd_write_reg_bit = {
8842 .f = cmd_write_reg_bit_parsed,
8844 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8847 (void *)&cmd_write_reg_bit_write,
8848 (void *)&cmd_write_reg_bit_regbit,
8849 (void *)&cmd_write_reg_bit_port_id,
8850 (void *)&cmd_write_reg_bit_reg_off,
8851 (void *)&cmd_write_reg_bit_bit_pos,
8852 (void *)&cmd_write_reg_bit_value,
8857 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8858 struct cmd_read_rxd_txd_result {
8859 cmdline_fixed_string_t read;
8860 cmdline_fixed_string_t rxd_txd;
8867 cmd_read_rxd_txd_parsed(void *parsed_result,
8868 __rte_unused struct cmdline *cl,
8869 __rte_unused void *data)
8871 struct cmd_read_rxd_txd_result *res = parsed_result;
8873 if (!strcmp(res->rxd_txd, "rxd"))
8874 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8875 else if (!strcmp(res->rxd_txd, "txd"))
8876 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8879 static cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8880 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8881 static cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8882 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8884 static cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8885 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8887 static cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8888 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8890 static cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8891 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8894 static cmdline_parse_inst_t cmd_read_rxd_txd = {
8895 .f = cmd_read_rxd_txd_parsed,
8897 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8899 (void *)&cmd_read_rxd_txd_read,
8900 (void *)&cmd_read_rxd_txd_rxd_txd,
8901 (void *)&cmd_read_rxd_txd_port_id,
8902 (void *)&cmd_read_rxd_txd_queue_id,
8903 (void *)&cmd_read_rxd_txd_desc_id,
8909 struct cmd_quit_result {
8910 cmdline_fixed_string_t quit;
8913 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8915 __rte_unused void *data)
8920 static cmdline_parse_token_string_t cmd_quit_quit =
8921 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8923 static cmdline_parse_inst_t cmd_quit = {
8924 .f = cmd_quit_parsed,
8926 .help_str = "quit: Exit application",
8928 (void *)&cmd_quit_quit,
8933 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8934 struct cmd_mac_addr_result {
8935 cmdline_fixed_string_t mac_addr_cmd;
8936 cmdline_fixed_string_t what;
8938 struct rte_ether_addr address;
8941 static void cmd_mac_addr_parsed(void *parsed_result,
8942 __rte_unused struct cmdline *cl,
8943 __rte_unused void *data)
8945 struct cmd_mac_addr_result *res = parsed_result;
8948 if (strcmp(res->what, "add") == 0)
8949 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8950 else if (strcmp(res->what, "set") == 0)
8951 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8954 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8956 /* check the return value and print it if is < 0 */
8958 fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
8962 static cmdline_parse_token_string_t cmd_mac_addr_cmd =
8963 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8965 static cmdline_parse_token_string_t cmd_mac_addr_what =
8966 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8968 static cmdline_parse_token_num_t cmd_mac_addr_portnum =
8969 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8971 static cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8972 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8974 static cmdline_parse_inst_t cmd_mac_addr = {
8975 .f = cmd_mac_addr_parsed,
8977 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8978 "Add/Remove/Set MAC address on port_id",
8980 (void *)&cmd_mac_addr_cmd,
8981 (void *)&cmd_mac_addr_what,
8982 (void *)&cmd_mac_addr_portnum,
8983 (void *)&cmd_mac_addr_addr,
8988 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8989 struct cmd_eth_peer_result {
8990 cmdline_fixed_string_t set;
8991 cmdline_fixed_string_t eth_peer;
8993 cmdline_fixed_string_t peer_addr;
8996 static void cmd_set_eth_peer_parsed(void *parsed_result,
8997 __rte_unused struct cmdline *cl,
8998 __rte_unused void *data)
9000 struct cmd_eth_peer_result *res = parsed_result;
9002 if (test_done == 0) {
9003 fprintf(stderr, "Please stop forwarding first\n");
9006 if (!strcmp(res->eth_peer, "eth-peer")) {
9007 set_fwd_eth_peer(res->port_id, res->peer_addr);
9011 static cmdline_parse_token_string_t cmd_eth_peer_set =
9012 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
9013 static cmdline_parse_token_string_t cmd_eth_peer =
9014 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
9015 static cmdline_parse_token_num_t cmd_eth_peer_port_id =
9016 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
9018 static cmdline_parse_token_string_t cmd_eth_peer_addr =
9019 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
9021 static cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
9022 .f = cmd_set_eth_peer_parsed,
9024 .help_str = "set eth-peer <port_id> <peer_mac>",
9026 (void *)&cmd_eth_peer_set,
9027 (void *)&cmd_eth_peer,
9028 (void *)&cmd_eth_peer_port_id,
9029 (void *)&cmd_eth_peer_addr,
9034 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
9035 struct cmd_set_qmap_result {
9036 cmdline_fixed_string_t set;
9037 cmdline_fixed_string_t qmap;
9038 cmdline_fixed_string_t what;
9045 cmd_set_qmap_parsed(void *parsed_result,
9046 __rte_unused struct cmdline *cl,
9047 __rte_unused void *data)
9049 struct cmd_set_qmap_result *res = parsed_result;
9050 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
9052 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
9055 static cmdline_parse_token_string_t cmd_setqmap_set =
9056 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
9058 static cmdline_parse_token_string_t cmd_setqmap_qmap =
9059 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
9061 static cmdline_parse_token_string_t cmd_setqmap_what =
9062 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
9064 static cmdline_parse_token_num_t cmd_setqmap_portid =
9065 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
9066 port_id, RTE_UINT16);
9067 static cmdline_parse_token_num_t cmd_setqmap_queueid =
9068 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
9069 queue_id, RTE_UINT16);
9070 static cmdline_parse_token_num_t cmd_setqmap_mapvalue =
9071 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
9072 map_value, RTE_UINT8);
9074 static cmdline_parse_inst_t cmd_set_qmap = {
9075 .f = cmd_set_qmap_parsed,
9077 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
9078 "Set statistics mapping value on tx|rx queue_id of port_id",
9080 (void *)&cmd_setqmap_set,
9081 (void *)&cmd_setqmap_qmap,
9082 (void *)&cmd_setqmap_what,
9083 (void *)&cmd_setqmap_portid,
9084 (void *)&cmd_setqmap_queueid,
9085 (void *)&cmd_setqmap_mapvalue,
9090 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
9091 struct cmd_set_xstats_hide_zero_result {
9092 cmdline_fixed_string_t keyword;
9093 cmdline_fixed_string_t name;
9094 cmdline_fixed_string_t on_off;
9098 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
9099 __rte_unused struct cmdline *cl,
9100 __rte_unused void *data)
9102 struct cmd_set_xstats_hide_zero_result *res;
9103 uint16_t on_off = 0;
9105 res = parsed_result;
9106 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9107 set_xstats_hide_zero(on_off);
9110 static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
9111 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
9113 static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
9114 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
9115 name, "xstats-hide-zero");
9116 static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
9117 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
9120 static cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
9121 .f = cmd_set_xstats_hide_zero_parsed,
9123 .help_str = "set xstats-hide-zero on|off",
9125 (void *)&cmd_set_xstats_hide_zero_keyword,
9126 (void *)&cmd_set_xstats_hide_zero_name,
9127 (void *)&cmd_set_xstats_hide_zero_on_off,
9132 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
9133 struct cmd_set_record_core_cycles_result {
9134 cmdline_fixed_string_t keyword;
9135 cmdline_fixed_string_t name;
9136 cmdline_fixed_string_t on_off;
9140 cmd_set_record_core_cycles_parsed(void *parsed_result,
9141 __rte_unused struct cmdline *cl,
9142 __rte_unused void *data)
9144 struct cmd_set_record_core_cycles_result *res;
9145 uint16_t on_off = 0;
9147 res = parsed_result;
9148 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9149 set_record_core_cycles(on_off);
9152 static cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
9153 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9155 static cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
9156 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9157 name, "record-core-cycles");
9158 static cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
9159 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9162 static cmdline_parse_inst_t cmd_set_record_core_cycles = {
9163 .f = cmd_set_record_core_cycles_parsed,
9165 .help_str = "set record-core-cycles on|off",
9167 (void *)&cmd_set_record_core_cycles_keyword,
9168 (void *)&cmd_set_record_core_cycles_name,
9169 (void *)&cmd_set_record_core_cycles_on_off,
9174 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
9175 struct cmd_set_record_burst_stats_result {
9176 cmdline_fixed_string_t keyword;
9177 cmdline_fixed_string_t name;
9178 cmdline_fixed_string_t on_off;
9182 cmd_set_record_burst_stats_parsed(void *parsed_result,
9183 __rte_unused struct cmdline *cl,
9184 __rte_unused void *data)
9186 struct cmd_set_record_burst_stats_result *res;
9187 uint16_t on_off = 0;
9189 res = parsed_result;
9190 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9191 set_record_burst_stats(on_off);
9194 static cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
9195 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9197 static cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
9198 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9199 name, "record-burst-stats");
9200 static cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
9201 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9204 static cmdline_parse_inst_t cmd_set_record_burst_stats = {
9205 .f = cmd_set_record_burst_stats_parsed,
9207 .help_str = "set record-burst-stats on|off",
9209 (void *)&cmd_set_record_burst_stats_keyword,
9210 (void *)&cmd_set_record_burst_stats_name,
9211 (void *)&cmd_set_record_burst_stats_on_off,
9216 /* *** CONFIGURE UNICAST HASH TABLE *** */
9217 struct cmd_set_uc_hash_table {
9218 cmdline_fixed_string_t set;
9219 cmdline_fixed_string_t port;
9221 cmdline_fixed_string_t what;
9222 struct rte_ether_addr address;
9223 cmdline_fixed_string_t mode;
9227 cmd_set_uc_hash_parsed(void *parsed_result,
9228 __rte_unused struct cmdline *cl,
9229 __rte_unused void *data)
9232 struct cmd_set_uc_hash_table *res = parsed_result;
9234 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9236 if (strcmp(res->what, "uta") == 0)
9237 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
9238 &res->address,(uint8_t)is_on);
9241 "bad unicast hash table parameter, return code = %d\n",
9246 static cmdline_parse_token_string_t cmd_set_uc_hash_set =
9247 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9249 static cmdline_parse_token_string_t cmd_set_uc_hash_port =
9250 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9252 static cmdline_parse_token_num_t cmd_set_uc_hash_portid =
9253 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
9254 port_id, RTE_UINT16);
9255 static cmdline_parse_token_string_t cmd_set_uc_hash_what =
9256 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9258 static cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
9259 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
9261 static cmdline_parse_token_string_t cmd_set_uc_hash_mode =
9262 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9265 static cmdline_parse_inst_t cmd_set_uc_hash_filter = {
9266 .f = cmd_set_uc_hash_parsed,
9268 .help_str = "set port <port_id> uta <mac_addr> on|off)",
9270 (void *)&cmd_set_uc_hash_set,
9271 (void *)&cmd_set_uc_hash_port,
9272 (void *)&cmd_set_uc_hash_portid,
9273 (void *)&cmd_set_uc_hash_what,
9274 (void *)&cmd_set_uc_hash_mac,
9275 (void *)&cmd_set_uc_hash_mode,
9280 struct cmd_set_uc_all_hash_table {
9281 cmdline_fixed_string_t set;
9282 cmdline_fixed_string_t port;
9284 cmdline_fixed_string_t what;
9285 cmdline_fixed_string_t value;
9286 cmdline_fixed_string_t mode;
9290 cmd_set_uc_all_hash_parsed(void *parsed_result,
9291 __rte_unused struct cmdline *cl,
9292 __rte_unused void *data)
9295 struct cmd_set_uc_all_hash_table *res = parsed_result;
9297 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9299 if ((strcmp(res->what, "uta") == 0) &&
9300 (strcmp(res->value, "all") == 0))
9301 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
9304 "bad unicast hash table parameter, return code = %d\n",
9308 static cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
9309 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9311 static cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
9312 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9314 static cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
9315 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
9316 port_id, RTE_UINT16);
9317 static cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
9318 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9320 static cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
9321 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9323 static cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
9324 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9327 static cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
9328 .f = cmd_set_uc_all_hash_parsed,
9330 .help_str = "set port <port_id> uta all on|off",
9332 (void *)&cmd_set_uc_all_hash_set,
9333 (void *)&cmd_set_uc_all_hash_port,
9334 (void *)&cmd_set_uc_all_hash_portid,
9335 (void *)&cmd_set_uc_all_hash_what,
9336 (void *)&cmd_set_uc_all_hash_value,
9337 (void *)&cmd_set_uc_all_hash_mode,
9342 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
9343 struct cmd_set_vf_traffic {
9344 cmdline_fixed_string_t set;
9345 cmdline_fixed_string_t port;
9347 cmdline_fixed_string_t vf;
9349 cmdline_fixed_string_t what;
9350 cmdline_fixed_string_t mode;
9354 cmd_set_vf_traffic_parsed(void *parsed_result,
9355 __rte_unused struct cmdline *cl,
9356 __rte_unused void *data)
9358 struct cmd_set_vf_traffic *res = parsed_result;
9359 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
9360 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9362 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
9365 static cmdline_parse_token_string_t cmd_setvf_traffic_set =
9366 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9368 static cmdline_parse_token_string_t cmd_setvf_traffic_port =
9369 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9371 static cmdline_parse_token_num_t cmd_setvf_traffic_portid =
9372 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9373 port_id, RTE_UINT16);
9374 static cmdline_parse_token_string_t cmd_setvf_traffic_vf =
9375 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9377 static cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
9378 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9380 static cmdline_parse_token_string_t cmd_setvf_traffic_what =
9381 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9383 static cmdline_parse_token_string_t cmd_setvf_traffic_mode =
9384 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9387 static cmdline_parse_inst_t cmd_set_vf_traffic = {
9388 .f = cmd_set_vf_traffic_parsed,
9390 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
9392 (void *)&cmd_setvf_traffic_set,
9393 (void *)&cmd_setvf_traffic_port,
9394 (void *)&cmd_setvf_traffic_portid,
9395 (void *)&cmd_setvf_traffic_vf,
9396 (void *)&cmd_setvf_traffic_vfid,
9397 (void *)&cmd_setvf_traffic_what,
9398 (void *)&cmd_setvf_traffic_mode,
9403 /* *** CONFIGURE VF RECEIVE MODE *** */
9404 struct cmd_set_vf_rxmode {
9405 cmdline_fixed_string_t set;
9406 cmdline_fixed_string_t port;
9408 cmdline_fixed_string_t vf;
9410 cmdline_fixed_string_t what;
9411 cmdline_fixed_string_t mode;
9412 cmdline_fixed_string_t on;
9416 cmd_set_vf_rxmode_parsed(void *parsed_result,
9417 __rte_unused struct cmdline *cl,
9418 __rte_unused void *data)
9421 uint16_t vf_rxmode = 0;
9422 struct cmd_set_vf_rxmode *res = parsed_result;
9424 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
9425 if (!strcmp(res->what,"rxmode")) {
9426 if (!strcmp(res->mode, "AUPE"))
9427 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_UNTAG;
9428 else if (!strcmp(res->mode, "ROPE"))
9429 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_HASH_UC;
9430 else if (!strcmp(res->mode, "BAM"))
9431 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_BROADCAST;
9432 else if (!strncmp(res->mode, "MPE",3))
9433 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_MULTICAST;
9436 RTE_SET_USED(is_on);
9437 RTE_SET_USED(vf_rxmode);
9439 #ifdef RTE_NET_IXGBE
9440 if (ret == -ENOTSUP)
9441 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
9442 vf_rxmode, (uint8_t)is_on);
9445 if (ret == -ENOTSUP)
9446 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
9447 vf_rxmode, (uint8_t)is_on);
9451 "bad VF receive mode parameter, return code = %d\n",
9455 static cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
9456 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9458 static cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
9459 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9461 static cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
9462 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9463 port_id, RTE_UINT16);
9464 static cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
9465 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9467 static cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
9468 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9470 static cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
9471 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9473 static cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
9474 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9475 mode, "AUPE#ROPE#BAM#MPE");
9476 static cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
9477 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9480 static cmdline_parse_inst_t cmd_set_vf_rxmode = {
9481 .f = cmd_set_vf_rxmode_parsed,
9483 .help_str = "set port <port_id> vf <vf_id> rxmode "
9484 "AUPE|ROPE|BAM|MPE on|off",
9486 (void *)&cmd_set_vf_rxmode_set,
9487 (void *)&cmd_set_vf_rxmode_port,
9488 (void *)&cmd_set_vf_rxmode_portid,
9489 (void *)&cmd_set_vf_rxmode_vf,
9490 (void *)&cmd_set_vf_rxmode_vfid,
9491 (void *)&cmd_set_vf_rxmode_what,
9492 (void *)&cmd_set_vf_rxmode_mode,
9493 (void *)&cmd_set_vf_rxmode_on,
9498 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
9499 struct cmd_vf_mac_addr_result {
9500 cmdline_fixed_string_t mac_addr_cmd;
9501 cmdline_fixed_string_t what;
9502 cmdline_fixed_string_t port;
9504 cmdline_fixed_string_t vf;
9506 struct rte_ether_addr address;
9509 static void cmd_vf_mac_addr_parsed(void *parsed_result,
9510 __rte_unused struct cmdline *cl,
9511 __rte_unused void *data)
9513 struct cmd_vf_mac_addr_result *res = parsed_result;
9516 if (strcmp(res->what, "add") != 0)
9520 if (ret == -ENOTSUP)
9521 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
9525 if (ret == -ENOTSUP)
9526 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
9531 fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
9535 static cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
9536 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9537 mac_addr_cmd,"mac_addr");
9538 static cmdline_parse_token_string_t cmd_vf_mac_addr_what =
9539 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9541 static cmdline_parse_token_string_t cmd_vf_mac_addr_port =
9542 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9544 static cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
9545 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9546 port_num, RTE_UINT16);
9547 static cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
9548 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9550 static cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
9551 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9553 static cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
9554 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
9557 static cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
9558 .f = cmd_vf_mac_addr_parsed,
9560 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
9561 "Add MAC address filtering for a VF on port_id",
9563 (void *)&cmd_vf_mac_addr_cmd,
9564 (void *)&cmd_vf_mac_addr_what,
9565 (void *)&cmd_vf_mac_addr_port,
9566 (void *)&cmd_vf_mac_addr_portnum,
9567 (void *)&cmd_vf_mac_addr_vf,
9568 (void *)&cmd_vf_mac_addr_vfnum,
9569 (void *)&cmd_vf_mac_addr_addr,
9574 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
9575 struct cmd_vf_rx_vlan_filter {
9576 cmdline_fixed_string_t rx_vlan;
9577 cmdline_fixed_string_t what;
9579 cmdline_fixed_string_t port;
9581 cmdline_fixed_string_t vf;
9586 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
9587 __rte_unused struct cmdline *cl,
9588 __rte_unused void *data)
9590 struct cmd_vf_rx_vlan_filter *res = parsed_result;
9593 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9595 #ifdef RTE_NET_IXGBE
9596 if (ret == -ENOTSUP)
9597 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9598 res->vlan_id, res->vf_mask, is_add);
9601 if (ret == -ENOTSUP)
9602 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9603 res->vlan_id, res->vf_mask, is_add);
9606 if (ret == -ENOTSUP)
9607 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9608 res->vlan_id, res->vf_mask, is_add);
9615 fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
9616 res->vlan_id, res->vf_mask);
9619 fprintf(stderr, "invalid port_id %d\n", res->port_id);
9622 fprintf(stderr, "function not implemented or supported\n");
9625 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9629 static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9630 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9631 rx_vlan, "rx_vlan");
9632 static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9633 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9635 static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9636 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9637 vlan_id, RTE_UINT16);
9638 static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9639 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9641 static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9642 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9643 port_id, RTE_UINT16);
9644 static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9645 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9647 static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9648 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9649 vf_mask, RTE_UINT64);
9651 static cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9652 .f = cmd_vf_rx_vlan_filter_parsed,
9654 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9655 "(vf_mask = hexadecimal VF mask)",
9657 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9658 (void *)&cmd_vf_rx_vlan_filter_what,
9659 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9660 (void *)&cmd_vf_rx_vlan_filter_port,
9661 (void *)&cmd_vf_rx_vlan_filter_portid,
9662 (void *)&cmd_vf_rx_vlan_filter_vf,
9663 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9668 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9669 struct cmd_queue_rate_limit_result {
9670 cmdline_fixed_string_t set;
9671 cmdline_fixed_string_t port;
9673 cmdline_fixed_string_t queue;
9675 cmdline_fixed_string_t rate;
9679 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9680 __rte_unused struct cmdline *cl,
9681 __rte_unused void *data)
9683 struct cmd_queue_rate_limit_result *res = parsed_result;
9686 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9687 && (strcmp(res->queue, "queue") == 0)
9688 && (strcmp(res->rate, "rate") == 0))
9689 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9692 fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
9697 static cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9698 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9700 static cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9701 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9703 static cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9704 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9705 port_num, RTE_UINT16);
9706 static cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9707 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9709 static cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9710 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9711 queue_num, RTE_UINT8);
9712 static cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9713 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9715 static cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9716 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9717 rate_num, RTE_UINT16);
9719 static cmdline_parse_inst_t cmd_queue_rate_limit = {
9720 .f = cmd_queue_rate_limit_parsed,
9722 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9723 "Set rate limit for a queue on port_id",
9725 (void *)&cmd_queue_rate_limit_set,
9726 (void *)&cmd_queue_rate_limit_port,
9727 (void *)&cmd_queue_rate_limit_portnum,
9728 (void *)&cmd_queue_rate_limit_queue,
9729 (void *)&cmd_queue_rate_limit_queuenum,
9730 (void *)&cmd_queue_rate_limit_rate,
9731 (void *)&cmd_queue_rate_limit_ratenum,
9736 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9737 struct cmd_vf_rate_limit_result {
9738 cmdline_fixed_string_t set;
9739 cmdline_fixed_string_t port;
9741 cmdline_fixed_string_t vf;
9743 cmdline_fixed_string_t rate;
9745 cmdline_fixed_string_t q_msk;
9749 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9750 __rte_unused struct cmdline *cl,
9751 __rte_unused void *data)
9753 struct cmd_vf_rate_limit_result *res = parsed_result;
9756 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9757 && (strcmp(res->vf, "vf") == 0)
9758 && (strcmp(res->rate, "rate") == 0)
9759 && (strcmp(res->q_msk, "queue_mask") == 0))
9760 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9761 res->rate_num, res->q_msk_val);
9763 fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
9768 static cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9769 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9771 static cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9772 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9774 static cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9775 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9776 port_num, RTE_UINT16);
9777 static cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9778 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9780 static cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9781 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9783 static cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9784 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9786 static cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9787 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9788 rate_num, RTE_UINT16);
9789 static cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9790 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9791 q_msk, "queue_mask");
9792 static cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9793 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9794 q_msk_val, RTE_UINT64);
9796 static cmdline_parse_inst_t cmd_vf_rate_limit = {
9797 .f = cmd_vf_rate_limit_parsed,
9799 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9800 "queue_mask <queue_mask_value>: "
9801 "Set rate limit for queues of VF on port_id",
9803 (void *)&cmd_vf_rate_limit_set,
9804 (void *)&cmd_vf_rate_limit_port,
9805 (void *)&cmd_vf_rate_limit_portnum,
9806 (void *)&cmd_vf_rate_limit_vf,
9807 (void *)&cmd_vf_rate_limit_vfnum,
9808 (void *)&cmd_vf_rate_limit_rate,
9809 (void *)&cmd_vf_rate_limit_ratenum,
9810 (void *)&cmd_vf_rate_limit_q_msk,
9811 (void *)&cmd_vf_rate_limit_q_msk_val,
9816 /* *** CONFIGURE TUNNEL UDP PORT *** */
9817 struct cmd_tunnel_udp_config {
9818 cmdline_fixed_string_t rx_vxlan_port;
9819 cmdline_fixed_string_t what;
9825 cmd_tunnel_udp_config_parsed(void *parsed_result,
9826 __rte_unused struct cmdline *cl,
9827 __rte_unused void *data)
9829 struct cmd_tunnel_udp_config *res = parsed_result;
9830 struct rte_eth_udp_tunnel tunnel_udp;
9833 tunnel_udp.udp_port = res->udp_port;
9834 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9836 if (!strcmp(res->what, "add"))
9837 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9840 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9844 fprintf(stderr, "udp tunneling add error: (%s)\n",
9848 static cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9849 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9850 rx_vxlan_port, "rx_vxlan_port");
9851 static cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9852 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9854 static cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9855 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9856 udp_port, RTE_UINT16);
9857 static cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9858 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9859 port_id, RTE_UINT16);
9861 static cmdline_parse_inst_t cmd_tunnel_udp_config = {
9862 .f = cmd_tunnel_udp_config_parsed,
9864 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9865 "Add/Remove a tunneling UDP port filter",
9867 (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9868 (void *)&cmd_tunnel_udp_config_what,
9869 (void *)&cmd_tunnel_udp_config_udp_port,
9870 (void *)&cmd_tunnel_udp_config_port_id,
9875 struct cmd_config_tunnel_udp_port {
9876 cmdline_fixed_string_t port;
9877 cmdline_fixed_string_t config;
9879 cmdline_fixed_string_t udp_tunnel_port;
9880 cmdline_fixed_string_t action;
9881 cmdline_fixed_string_t tunnel_type;
9886 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9887 __rte_unused struct cmdline *cl,
9888 __rte_unused void *data)
9890 struct cmd_config_tunnel_udp_port *res = parsed_result;
9891 struct rte_eth_udp_tunnel tunnel_udp;
9894 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9897 tunnel_udp.udp_port = res->udp_port;
9899 if (!strcmp(res->tunnel_type, "vxlan")) {
9900 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9901 } else if (!strcmp(res->tunnel_type, "geneve")) {
9902 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_GENEVE;
9903 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9904 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN_GPE;
9905 } else if (!strcmp(res->tunnel_type, "ecpri")) {
9906 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_ECPRI;
9908 fprintf(stderr, "Invalid tunnel type\n");
9912 if (!strcmp(res->action, "add"))
9913 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9916 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9920 fprintf(stderr, "udp tunneling port add error: (%s)\n",
9924 static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9925 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9927 static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9928 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9930 static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9931 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9933 static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9934 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9937 static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9938 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9940 static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9941 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9942 "vxlan#geneve#vxlan-gpe#ecpri");
9943 static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9944 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9947 static cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9948 .f = cmd_cfg_tunnel_udp_port_parsed,
9950 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9951 "geneve|vxlan-gpe|ecpri <udp_port>",
9953 (void *)&cmd_config_tunnel_udp_port_port,
9954 (void *)&cmd_config_tunnel_udp_port_config,
9955 (void *)&cmd_config_tunnel_udp_port_port_id,
9956 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9957 (void *)&cmd_config_tunnel_udp_port_action,
9958 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9959 (void *)&cmd_config_tunnel_udp_port_value,
9964 /* ******************************************************************************** */
9966 struct cmd_dump_result {
9967 cmdline_fixed_string_t dump;
9971 dump_struct_sizes(void)
9973 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9974 DUMP_SIZE(struct rte_mbuf);
9975 DUMP_SIZE(struct rte_mempool);
9976 DUMP_SIZE(struct rte_ring);
9981 /* Dump the socket memory statistics on console */
9983 dump_socket_mem(FILE *f)
9985 struct rte_malloc_socket_stats socket_stats;
9990 unsigned int n_alloc = 0;
9991 unsigned int n_free = 0;
9992 static size_t last_allocs;
9993 static size_t last_total;
9996 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9997 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9998 !socket_stats.heap_totalsz_bytes)
10000 total += socket_stats.heap_totalsz_bytes;
10001 alloc += socket_stats.heap_allocsz_bytes;
10002 free += socket_stats.heap_freesz_bytes;
10003 n_alloc += socket_stats.alloc_count;
10004 n_free += socket_stats.free_count;
10006 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
10008 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
10009 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
10010 (double)socket_stats.heap_allocsz_bytes * 100 /
10011 (double)socket_stats.heap_totalsz_bytes,
10012 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
10013 socket_stats.alloc_count,
10014 socket_stats.free_count);
10017 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
10018 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
10019 total ? ((double)alloc * 100 / (double)total) : 0,
10020 (double)free / (1024 * 1024),
10023 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
10024 ((double)total - (double)last_total) / (1024 * 1024),
10025 (double)(alloc - (double)last_allocs) / 1024 / 1024);
10026 last_allocs = alloc;
10027 last_total = total;
10030 static void cmd_dump_parsed(void *parsed_result,
10031 __rte_unused struct cmdline *cl,
10032 __rte_unused void *data)
10034 struct cmd_dump_result *res = parsed_result;
10036 if (!strcmp(res->dump, "dump_physmem"))
10037 rte_dump_physmem_layout(stdout);
10038 else if (!strcmp(res->dump, "dump_socket_mem"))
10039 dump_socket_mem(stdout);
10040 else if (!strcmp(res->dump, "dump_memzone"))
10041 rte_memzone_dump(stdout);
10042 else if (!strcmp(res->dump, "dump_struct_sizes"))
10043 dump_struct_sizes();
10044 else if (!strcmp(res->dump, "dump_ring"))
10045 rte_ring_list_dump(stdout);
10046 else if (!strcmp(res->dump, "dump_mempool"))
10047 rte_mempool_list_dump(stdout);
10048 else if (!strcmp(res->dump, "dump_devargs"))
10049 rte_devargs_dump(stdout);
10050 else if (!strcmp(res->dump, "dump_log_types"))
10051 rte_log_dump(stdout);
10054 static cmdline_parse_token_string_t cmd_dump_dump =
10055 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
10059 "dump_struct_sizes#"
10065 static cmdline_parse_inst_t cmd_dump = {
10066 .f = cmd_dump_parsed, /* function to call */
10067 .data = NULL, /* 2nd arg of func */
10068 .help_str = "Dump status",
10069 .tokens = { /* token list, NULL terminated */
10070 (void *)&cmd_dump_dump,
10075 /* ******************************************************************************** */
10077 struct cmd_dump_one_result {
10078 cmdline_fixed_string_t dump;
10079 cmdline_fixed_string_t name;
10082 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
10083 __rte_unused void *data)
10085 struct cmd_dump_one_result *res = parsed_result;
10087 if (!strcmp(res->dump, "dump_ring")) {
10088 struct rte_ring *r;
10089 r = rte_ring_lookup(res->name);
10091 cmdline_printf(cl, "Cannot find ring\n");
10094 rte_ring_dump(stdout, r);
10095 } else if (!strcmp(res->dump, "dump_mempool")) {
10096 struct rte_mempool *mp;
10097 mp = rte_mempool_lookup(res->name);
10099 cmdline_printf(cl, "Cannot find mempool\n");
10102 rte_mempool_dump(stdout, mp);
10106 static cmdline_parse_token_string_t cmd_dump_one_dump =
10107 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
10108 "dump_ring#dump_mempool");
10110 static cmdline_parse_token_string_t cmd_dump_one_name =
10111 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
10113 static cmdline_parse_inst_t cmd_dump_one = {
10114 .f = cmd_dump_one_parsed, /* function to call */
10115 .data = NULL, /* 2nd arg of func */
10116 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
10117 .tokens = { /* token list, NULL terminated */
10118 (void *)&cmd_dump_one_dump,
10119 (void *)&cmd_dump_one_name,
10124 /* *** queue region set *** */
10125 struct cmd_queue_region_result {
10126 cmdline_fixed_string_t set;
10127 cmdline_fixed_string_t port;
10129 cmdline_fixed_string_t cmd;
10130 cmdline_fixed_string_t region;
10132 cmdline_fixed_string_t queue_start_index;
10134 cmdline_fixed_string_t queue_num;
10135 uint8_t queue_num_value;
10139 cmd_queue_region_parsed(void *parsed_result,
10140 __rte_unused struct cmdline *cl,
10141 __rte_unused void *data)
10143 struct cmd_queue_region_result *res = parsed_result;
10144 int ret = -ENOTSUP;
10145 #ifdef RTE_NET_I40E
10146 struct rte_pmd_i40e_queue_region_conf region_conf;
10147 enum rte_pmd_i40e_queue_region_op op_type;
10150 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10153 #ifdef RTE_NET_I40E
10154 memset(®ion_conf, 0, sizeof(region_conf));
10155 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
10156 region_conf.region_id = res->region_id;
10157 region_conf.queue_num = res->queue_num_value;
10158 region_conf.queue_start_index = res->queue_id;
10160 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10161 op_type, ®ion_conf);
10168 fprintf(stderr, "function not implemented or supported\n");
10171 fprintf(stderr, "queue region config error: (%s)\n",
10176 static cmdline_parse_token_string_t cmd_queue_region_set =
10177 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10179 static cmdline_parse_token_string_t cmd_queue_region_port =
10180 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
10181 static cmdline_parse_token_num_t cmd_queue_region_port_id =
10182 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10183 port_id, RTE_UINT16);
10184 static cmdline_parse_token_string_t cmd_queue_region_cmd =
10185 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10186 cmd, "queue-region");
10187 static cmdline_parse_token_string_t cmd_queue_region_id =
10188 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10189 region, "region_id");
10190 static cmdline_parse_token_num_t cmd_queue_region_index =
10191 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10192 region_id, RTE_UINT8);
10193 static cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
10194 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10195 queue_start_index, "queue_start_index");
10196 static cmdline_parse_token_num_t cmd_queue_region_queue_id =
10197 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10198 queue_id, RTE_UINT8);
10199 static cmdline_parse_token_string_t cmd_queue_region_queue_num =
10200 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10201 queue_num, "queue_num");
10202 static cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
10203 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10204 queue_num_value, RTE_UINT8);
10206 static cmdline_parse_inst_t cmd_queue_region = {
10207 .f = cmd_queue_region_parsed,
10209 .help_str = "set port <port_id> queue-region region_id <value> "
10210 "queue_start_index <value> queue_num <value>: Set a queue region",
10212 (void *)&cmd_queue_region_set,
10213 (void *)&cmd_queue_region_port,
10214 (void *)&cmd_queue_region_port_id,
10215 (void *)&cmd_queue_region_cmd,
10216 (void *)&cmd_queue_region_id,
10217 (void *)&cmd_queue_region_index,
10218 (void *)&cmd_queue_region_queue_start_index,
10219 (void *)&cmd_queue_region_queue_id,
10220 (void *)&cmd_queue_region_queue_num,
10221 (void *)&cmd_queue_region_queue_num_value,
10226 /* *** queue region and flowtype set *** */
10227 struct cmd_region_flowtype_result {
10228 cmdline_fixed_string_t set;
10229 cmdline_fixed_string_t port;
10231 cmdline_fixed_string_t cmd;
10232 cmdline_fixed_string_t region;
10234 cmdline_fixed_string_t flowtype;
10235 uint8_t flowtype_id;
10239 cmd_region_flowtype_parsed(void *parsed_result,
10240 __rte_unused struct cmdline *cl,
10241 __rte_unused void *data)
10243 struct cmd_region_flowtype_result *res = parsed_result;
10244 int ret = -ENOTSUP;
10245 #ifdef RTE_NET_I40E
10246 struct rte_pmd_i40e_queue_region_conf region_conf;
10247 enum rte_pmd_i40e_queue_region_op op_type;
10250 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10253 #ifdef RTE_NET_I40E
10254 memset(®ion_conf, 0, sizeof(region_conf));
10256 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10257 region_conf.region_id = res->region_id;
10258 region_conf.hw_flowtype = res->flowtype_id;
10260 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10261 op_type, ®ion_conf);
10268 fprintf(stderr, "function not implemented or supported\n");
10271 fprintf(stderr, "region flowtype config error: (%s)\n",
10276 static cmdline_parse_token_string_t cmd_region_flowtype_set =
10277 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10279 static cmdline_parse_token_string_t cmd_region_flowtype_port =
10280 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10282 static cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10283 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10284 port_id, RTE_UINT16);
10285 static cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10286 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10287 cmd, "queue-region");
10288 static cmdline_parse_token_string_t cmd_region_flowtype_index =
10289 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10290 region, "region_id");
10291 static cmdline_parse_token_num_t cmd_region_flowtype_id =
10292 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10293 region_id, RTE_UINT8);
10294 static cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10295 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10296 flowtype, "flowtype");
10297 static cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10298 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10299 flowtype_id, RTE_UINT8);
10300 static cmdline_parse_inst_t cmd_region_flowtype = {
10301 .f = cmd_region_flowtype_parsed,
10303 .help_str = "set port <port_id> queue-region region_id <value> "
10304 "flowtype <value>: Set a flowtype region index",
10306 (void *)&cmd_region_flowtype_set,
10307 (void *)&cmd_region_flowtype_port,
10308 (void *)&cmd_region_flowtype_port_index,
10309 (void *)&cmd_region_flowtype_cmd,
10310 (void *)&cmd_region_flowtype_index,
10311 (void *)&cmd_region_flowtype_id,
10312 (void *)&cmd_region_flowtype_flow_index,
10313 (void *)&cmd_region_flowtype_flow_id,
10318 /* *** User Priority (UP) to queue region (region_id) set *** */
10319 struct cmd_user_priority_region_result {
10320 cmdline_fixed_string_t set;
10321 cmdline_fixed_string_t port;
10323 cmdline_fixed_string_t cmd;
10324 cmdline_fixed_string_t user_priority;
10325 uint8_t user_priority_id;
10326 cmdline_fixed_string_t region;
10331 cmd_user_priority_region_parsed(void *parsed_result,
10332 __rte_unused struct cmdline *cl,
10333 __rte_unused void *data)
10335 struct cmd_user_priority_region_result *res = parsed_result;
10336 int ret = -ENOTSUP;
10337 #ifdef RTE_NET_I40E
10338 struct rte_pmd_i40e_queue_region_conf region_conf;
10339 enum rte_pmd_i40e_queue_region_op op_type;
10342 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10345 #ifdef RTE_NET_I40E
10346 memset(®ion_conf, 0, sizeof(region_conf));
10347 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10348 region_conf.user_priority = res->user_priority_id;
10349 region_conf.region_id = res->region_id;
10351 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10352 op_type, ®ion_conf);
10359 fprintf(stderr, "function not implemented or supported\n");
10362 fprintf(stderr, "user_priority region config error: (%s)\n",
10367 static cmdline_parse_token_string_t cmd_user_priority_region_set =
10368 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10370 static cmdline_parse_token_string_t cmd_user_priority_region_port =
10371 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10373 static cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10374 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10375 port_id, RTE_UINT16);
10376 static cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10377 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10378 cmd, "queue-region");
10379 static cmdline_parse_token_string_t cmd_user_priority_region_UP =
10380 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10381 user_priority, "UP");
10382 static cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10383 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10384 user_priority_id, RTE_UINT8);
10385 static cmdline_parse_token_string_t cmd_user_priority_region_region =
10386 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10387 region, "region_id");
10388 static cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10389 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10390 region_id, RTE_UINT8);
10392 static cmdline_parse_inst_t cmd_user_priority_region = {
10393 .f = cmd_user_priority_region_parsed,
10395 .help_str = "set port <port_id> queue-region UP <value> "
10396 "region_id <value>: Set the mapping of User Priority (UP) "
10397 "to queue region (region_id) ",
10399 (void *)&cmd_user_priority_region_set,
10400 (void *)&cmd_user_priority_region_port,
10401 (void *)&cmd_user_priority_region_port_index,
10402 (void *)&cmd_user_priority_region_cmd,
10403 (void *)&cmd_user_priority_region_UP,
10404 (void *)&cmd_user_priority_region_UP_id,
10405 (void *)&cmd_user_priority_region_region,
10406 (void *)&cmd_user_priority_region_region_id,
10411 /* *** flush all queue region related configuration *** */
10412 struct cmd_flush_queue_region_result {
10413 cmdline_fixed_string_t set;
10414 cmdline_fixed_string_t port;
10416 cmdline_fixed_string_t cmd;
10417 cmdline_fixed_string_t flush;
10418 cmdline_fixed_string_t what;
10422 cmd_flush_queue_region_parsed(void *parsed_result,
10423 __rte_unused struct cmdline *cl,
10424 __rte_unused void *data)
10426 struct cmd_flush_queue_region_result *res = parsed_result;
10427 int ret = -ENOTSUP;
10428 #ifdef RTE_NET_I40E
10429 struct rte_pmd_i40e_queue_region_conf region_conf;
10430 enum rte_pmd_i40e_queue_region_op op_type;
10433 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10436 #ifdef RTE_NET_I40E
10437 memset(®ion_conf, 0, sizeof(region_conf));
10439 if (strcmp(res->what, "on") == 0)
10440 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10442 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10444 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10445 op_type, ®ion_conf);
10452 fprintf(stderr, "function not implemented or supported\n");
10455 fprintf(stderr, "queue region config flush error: (%s)\n",
10460 static cmdline_parse_token_string_t cmd_flush_queue_region_set =
10461 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10463 static cmdline_parse_token_string_t cmd_flush_queue_region_port =
10464 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10466 static cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10467 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10468 port_id, RTE_UINT16);
10469 static cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10470 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10471 cmd, "queue-region");
10472 static cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10473 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10475 static cmdline_parse_token_string_t cmd_flush_queue_region_what =
10476 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10479 static cmdline_parse_inst_t cmd_flush_queue_region = {
10480 .f = cmd_flush_queue_region_parsed,
10482 .help_str = "set port <port_id> queue-region flush on|off"
10483 ": flush all queue region related configuration",
10485 (void *)&cmd_flush_queue_region_set,
10486 (void *)&cmd_flush_queue_region_port,
10487 (void *)&cmd_flush_queue_region_port_index,
10488 (void *)&cmd_flush_queue_region_cmd,
10489 (void *)&cmd_flush_queue_region_flush,
10490 (void *)&cmd_flush_queue_region_what,
10495 /* *** get all queue region related configuration info *** */
10496 struct cmd_show_queue_region_info {
10497 cmdline_fixed_string_t show;
10498 cmdline_fixed_string_t port;
10500 cmdline_fixed_string_t cmd;
10504 cmd_show_queue_region_info_parsed(void *parsed_result,
10505 __rte_unused struct cmdline *cl,
10506 __rte_unused void *data)
10508 struct cmd_show_queue_region_info *res = parsed_result;
10509 int ret = -ENOTSUP;
10510 #ifdef RTE_NET_I40E
10511 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10512 enum rte_pmd_i40e_queue_region_op op_type;
10515 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10518 #ifdef RTE_NET_I40E
10519 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10521 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10523 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10524 op_type, &rte_pmd_regions);
10526 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10533 fprintf(stderr, "function not implemented or supported\n");
10536 fprintf(stderr, "queue region config info show error: (%s)\n",
10541 static cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10542 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10544 static cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10545 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10547 static cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10548 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10549 port_id, RTE_UINT16);
10550 static cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10551 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10552 cmd, "queue-region");
10554 static cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10555 .f = cmd_show_queue_region_info_parsed,
10557 .help_str = "show port <port_id> queue-region"
10558 ": show all queue region related configuration info",
10560 (void *)&cmd_show_queue_region_info_get,
10561 (void *)&cmd_show_queue_region_info_port,
10562 (void *)&cmd_show_queue_region_info_port_index,
10563 (void *)&cmd_show_queue_region_info_cmd,
10568 /* *** Filters Control *** */
10570 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10572 if ((ip_addr).family == AF_INET) \
10573 (ip) = (ip_addr).addr.ipv4.s_addr; \
10575 fprintf(stderr, "invalid parameter.\n"); \
10580 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10582 if ((ip_addr).family == AF_INET6) \
10583 rte_memcpy(&(ip), \
10584 &((ip_addr).addr.ipv6), \
10585 sizeof(struct in6_addr)); \
10587 fprintf(stderr, "invalid parameter.\n"); \
10592 #ifdef RTE_NET_I40E
10595 str2flowtype(char *string)
10598 static const struct {
10601 } flowtype_str[] = {
10602 {"raw", RTE_ETH_FLOW_RAW},
10603 {"ipv4", RTE_ETH_FLOW_IPV4},
10604 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10605 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10606 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10607 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10608 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10609 {"ipv6", RTE_ETH_FLOW_IPV6},
10610 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10611 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10612 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10613 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10614 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10615 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10616 {"ipv6-ex", RTE_ETH_FLOW_IPV6_EX},
10617 {"ipv6-tcp-ex", RTE_ETH_FLOW_IPV6_TCP_EX},
10618 {"ipv6-udp-ex", RTE_ETH_FLOW_IPV6_UDP_EX},
10619 {"gtpu", RTE_ETH_FLOW_GTPU},
10622 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10623 if (!strcmp(flowtype_str[i].str, string))
10624 return flowtype_str[i].type;
10627 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10628 return (uint16_t)atoi(string);
10630 return RTE_ETH_FLOW_UNKNOWN;
10633 /* *** deal with flow director filter *** */
10634 struct cmd_flow_director_result {
10635 cmdline_fixed_string_t flow_director_filter;
10637 cmdline_fixed_string_t mode;
10638 cmdline_fixed_string_t mode_value;
10639 cmdline_fixed_string_t ops;
10640 cmdline_fixed_string_t flow;
10641 cmdline_fixed_string_t flow_type;
10642 cmdline_fixed_string_t drop;
10643 cmdline_fixed_string_t queue;
10645 cmdline_fixed_string_t fd_id;
10646 uint32_t fd_id_value;
10647 cmdline_fixed_string_t packet;
10652 cmd_flow_director_filter_parsed(void *parsed_result,
10653 __rte_unused struct cmdline *cl,
10654 __rte_unused void *data)
10656 struct cmd_flow_director_result *res = parsed_result;
10658 struct rte_pmd_i40e_flow_type_mapping
10659 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10660 struct rte_pmd_i40e_pkt_template_conf conf;
10661 uint16_t flow_type = str2flowtype(res->flow_type);
10662 uint16_t i, port = res->port_id;
10665 memset(&conf, 0, sizeof(conf));
10667 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10668 fprintf(stderr, "Invalid flow type specified.\n");
10671 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10675 if (mapping[flow_type].pctype == 0ULL) {
10676 fprintf(stderr, "Invalid flow type specified.\n");
10679 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10680 if (mapping[flow_type].pctype & (1ULL << i)) {
10681 conf.input.pctype = i;
10686 conf.input.packet = open_file(res->filepath,
10687 &conf.input.length);
10688 if (!conf.input.packet)
10690 if (!strcmp(res->drop, "drop"))
10691 conf.action.behavior =
10692 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10694 conf.action.behavior =
10695 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10696 conf.action.report_status =
10697 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10698 conf.action.rx_queue = res->queue_id;
10699 conf.soft_id = res->fd_id_value;
10700 add = strcmp(res->ops, "del") ? 1 : 0;
10701 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10705 fprintf(stderr, "flow director config error: (%s)\n",
10707 close_file(conf.input.packet);
10710 static cmdline_parse_token_string_t cmd_flow_director_filter =
10711 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10712 flow_director_filter, "flow_director_filter");
10713 static cmdline_parse_token_num_t cmd_flow_director_port_id =
10714 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10715 port_id, RTE_UINT16);
10716 static cmdline_parse_token_string_t cmd_flow_director_ops =
10717 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10718 ops, "add#del#update");
10719 static cmdline_parse_token_string_t cmd_flow_director_flow =
10720 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10722 static cmdline_parse_token_string_t cmd_flow_director_flow_type =
10723 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10725 static cmdline_parse_token_string_t cmd_flow_director_drop =
10726 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10728 static cmdline_parse_token_string_t cmd_flow_director_queue =
10729 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10731 static cmdline_parse_token_num_t cmd_flow_director_queue_id =
10732 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10733 queue_id, RTE_UINT16);
10734 static cmdline_parse_token_string_t cmd_flow_director_fd_id =
10735 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10737 static cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10738 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10739 fd_id_value, RTE_UINT32);
10741 static cmdline_parse_token_string_t cmd_flow_director_mode =
10742 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10744 static cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10745 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10746 mode_value, "raw");
10747 static cmdline_parse_token_string_t cmd_flow_director_packet =
10748 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10750 static cmdline_parse_token_string_t cmd_flow_director_filepath =
10751 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10754 static cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10755 .f = cmd_flow_director_filter_parsed,
10757 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10758 "director entry on NIC",
10760 (void *)&cmd_flow_director_filter,
10761 (void *)&cmd_flow_director_port_id,
10762 (void *)&cmd_flow_director_mode,
10763 (void *)&cmd_flow_director_mode_raw,
10764 (void *)&cmd_flow_director_ops,
10765 (void *)&cmd_flow_director_flow,
10766 (void *)&cmd_flow_director_flow_type,
10767 (void *)&cmd_flow_director_drop,
10768 (void *)&cmd_flow_director_queue,
10769 (void *)&cmd_flow_director_queue_id,
10770 (void *)&cmd_flow_director_fd_id,
10771 (void *)&cmd_flow_director_fd_id_value,
10772 (void *)&cmd_flow_director_packet,
10773 (void *)&cmd_flow_director_filepath,
10778 #endif /* RTE_NET_I40E */
10780 /* *** deal with flow director mask *** */
10781 struct cmd_flow_director_mask_result {
10782 cmdline_fixed_string_t flow_director_mask;
10784 cmdline_fixed_string_t mode;
10785 cmdline_fixed_string_t mode_value;
10786 cmdline_fixed_string_t vlan;
10787 uint16_t vlan_mask;
10788 cmdline_fixed_string_t src_mask;
10789 cmdline_ipaddr_t ipv4_src;
10790 cmdline_ipaddr_t ipv6_src;
10792 cmdline_fixed_string_t dst_mask;
10793 cmdline_ipaddr_t ipv4_dst;
10794 cmdline_ipaddr_t ipv6_dst;
10796 cmdline_fixed_string_t mac;
10797 uint8_t mac_addr_byte_mask;
10798 cmdline_fixed_string_t tunnel_id;
10799 uint32_t tunnel_id_mask;
10800 cmdline_fixed_string_t tunnel_type;
10801 uint8_t tunnel_type_mask;
10805 cmd_flow_director_mask_parsed(void *parsed_result,
10806 __rte_unused struct cmdline *cl,
10807 __rte_unused void *data)
10809 struct cmd_flow_director_mask_result *res = parsed_result;
10810 struct rte_eth_fdir_masks *mask;
10811 struct rte_port *port;
10813 port = &ports[res->port_id];
10814 /** Check if the port is not started **/
10815 if (port->port_status != RTE_PORT_STOPPED) {
10816 fprintf(stderr, "Please stop port %d first\n", res->port_id);
10820 mask = &port->dev_conf.fdir_conf.mask;
10822 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10823 if (strcmp(res->mode_value, "MAC-VLAN")) {
10824 fprintf(stderr, "Please set mode to MAC-VLAN.\n");
10828 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10829 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10830 if (strcmp(res->mode_value, "Tunnel")) {
10831 fprintf(stderr, "Please set mode to Tunnel.\n");
10835 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10836 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10837 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10838 mask->tunnel_type_mask = res->tunnel_type_mask;
10840 if (strcmp(res->mode_value, "IP")) {
10841 fprintf(stderr, "Please set mode to IP.\n");
10845 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10846 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10847 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10848 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10849 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10850 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10851 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10854 cmd_reconfig_device_queue(res->port_id, 1, 1);
10857 static cmdline_parse_token_string_t cmd_flow_director_mask =
10858 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10859 flow_director_mask, "flow_director_mask");
10860 static cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10861 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10862 port_id, RTE_UINT16);
10863 static cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10864 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10866 static cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10867 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10868 vlan_mask, RTE_UINT16);
10869 static cmdline_parse_token_string_t cmd_flow_director_mask_src =
10870 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10871 src_mask, "src_mask");
10872 static cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10873 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10875 static cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10876 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10878 static cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10879 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10880 port_src, RTE_UINT16);
10881 static cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10882 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10883 dst_mask, "dst_mask");
10884 static cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10885 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10887 static cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10888 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10890 static cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10891 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10892 port_dst, RTE_UINT16);
10894 static cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10895 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10897 static cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10898 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10900 static cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10901 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10902 mode_value, "MAC-VLAN");
10903 static cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10904 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10905 mode_value, "Tunnel");
10906 static cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10907 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10909 static cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10910 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10911 mac_addr_byte_mask, RTE_UINT8);
10912 static cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10913 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10914 tunnel_type, "tunnel-type");
10915 static cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10916 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10917 tunnel_type_mask, RTE_UINT8);
10918 static cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10919 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10920 tunnel_id, "tunnel-id");
10921 static cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10922 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10923 tunnel_id_mask, RTE_UINT32);
10925 static cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10926 .f = cmd_flow_director_mask_parsed,
10928 .help_str = "flow_director_mask ... : "
10929 "Set IP mode flow director's mask on NIC",
10931 (void *)&cmd_flow_director_mask,
10932 (void *)&cmd_flow_director_mask_port_id,
10933 (void *)&cmd_flow_director_mask_mode,
10934 (void *)&cmd_flow_director_mask_mode_ip,
10935 (void *)&cmd_flow_director_mask_vlan,
10936 (void *)&cmd_flow_director_mask_vlan_value,
10937 (void *)&cmd_flow_director_mask_src,
10938 (void *)&cmd_flow_director_mask_ipv4_src,
10939 (void *)&cmd_flow_director_mask_ipv6_src,
10940 (void *)&cmd_flow_director_mask_port_src,
10941 (void *)&cmd_flow_director_mask_dst,
10942 (void *)&cmd_flow_director_mask_ipv4_dst,
10943 (void *)&cmd_flow_director_mask_ipv6_dst,
10944 (void *)&cmd_flow_director_mask_port_dst,
10949 static cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10950 .f = cmd_flow_director_mask_parsed,
10952 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10953 "flow director's mask on NIC",
10955 (void *)&cmd_flow_director_mask,
10956 (void *)&cmd_flow_director_mask_port_id,
10957 (void *)&cmd_flow_director_mask_mode,
10958 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10959 (void *)&cmd_flow_director_mask_vlan,
10960 (void *)&cmd_flow_director_mask_vlan_value,
10965 static cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10966 .f = cmd_flow_director_mask_parsed,
10968 .help_str = "flow_director_mask ... : Set tunnel mode "
10969 "flow director's mask on NIC",
10971 (void *)&cmd_flow_director_mask,
10972 (void *)&cmd_flow_director_mask_port_id,
10973 (void *)&cmd_flow_director_mask_mode,
10974 (void *)&cmd_flow_director_mask_mode_tunnel,
10975 (void *)&cmd_flow_director_mask_vlan,
10976 (void *)&cmd_flow_director_mask_vlan_value,
10977 (void *)&cmd_flow_director_mask_mac,
10978 (void *)&cmd_flow_director_mask_mac_value,
10979 (void *)&cmd_flow_director_mask_tunnel_type,
10980 (void *)&cmd_flow_director_mask_tunnel_type_value,
10981 (void *)&cmd_flow_director_mask_tunnel_id,
10982 (void *)&cmd_flow_director_mask_tunnel_id_value,
10987 /* *** deal with flow director flexible payload configuration *** */
10988 struct cmd_flow_director_flexpayload_result {
10989 cmdline_fixed_string_t flow_director_flexpayload;
10991 cmdline_fixed_string_t payload_layer;
10992 cmdline_fixed_string_t payload_cfg;
10996 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10999 const char *p, *p0 = q_arg;
11001 unsigned long int_fld;
11002 char *str_fld[max_num];
11007 p = strchr(p0, '(');
11011 p0 = strchr(p, ')');
11016 if (size >= sizeof(s))
11019 snprintf(s, sizeof(s), "%.*s", size, p);
11020 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11021 if (ret < 0 || ret > max_num)
11023 for (i = 0; i < ret; i++) {
11025 int_fld = strtoul(str_fld[i], &end, 0);
11026 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11028 offsets[i] = (uint16_t)int_fld;
11034 cmd_flow_director_flxpld_parsed(void *parsed_result,
11035 __rte_unused struct cmdline *cl,
11036 __rte_unused void *data)
11038 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11039 struct rte_eth_flex_payload_cfg flex_cfg;
11040 struct rte_port *port;
11043 port = &ports[res->port_id];
11044 /** Check if the port is not started **/
11045 if (port->port_status != RTE_PORT_STOPPED) {
11046 fprintf(stderr, "Please stop port %d first\n", res->port_id);
11050 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11052 if (!strcmp(res->payload_layer, "raw"))
11053 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11054 else if (!strcmp(res->payload_layer, "l2"))
11055 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11056 else if (!strcmp(res->payload_layer, "l3"))
11057 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11058 else if (!strcmp(res->payload_layer, "l4"))
11059 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11061 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11062 RTE_ETH_FDIR_MAX_FLEXLEN);
11064 fprintf(stderr, "error: Cannot parse flex payload input.\n");
11068 fdir_set_flex_payload(res->port_id, &flex_cfg);
11069 cmd_reconfig_device_queue(res->port_id, 1, 1);
11072 static cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11073 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11074 flow_director_flexpayload,
11075 "flow_director_flex_payload");
11076 static cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11077 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11078 port_id, RTE_UINT16);
11079 static cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11080 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11081 payload_layer, "raw#l2#l3#l4");
11082 static cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11083 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11084 payload_cfg, NULL);
11086 static cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11087 .f = cmd_flow_director_flxpld_parsed,
11089 .help_str = "flow_director_flexpayload ... : "
11090 "Set flow director's flex payload on NIC",
11092 (void *)&cmd_flow_director_flexpayload,
11093 (void *)&cmd_flow_director_flexpayload_port_id,
11094 (void *)&cmd_flow_director_flexpayload_payload_layer,
11095 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11100 /* Generic flow interface command. */
11101 extern cmdline_parse_inst_t cmd_flow;
11103 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11104 struct cmd_mcast_addr_result {
11105 cmdline_fixed_string_t mcast_addr_cmd;
11106 cmdline_fixed_string_t what;
11108 struct rte_ether_addr mc_addr;
11111 static void cmd_mcast_addr_parsed(void *parsed_result,
11112 __rte_unused struct cmdline *cl,
11113 __rte_unused void *data)
11115 struct cmd_mcast_addr_result *res = parsed_result;
11117 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
11119 "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
11120 RTE_ETHER_ADDR_BYTES(&res->mc_addr));
11123 if (strcmp(res->what, "add") == 0)
11124 mcast_addr_add(res->port_num, &res->mc_addr);
11126 mcast_addr_remove(res->port_num, &res->mc_addr);
11129 static cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11130 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11131 mcast_addr_cmd, "mcast_addr");
11132 static cmdline_parse_token_string_t cmd_mcast_addr_what =
11133 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11135 static cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11136 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
11138 static cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11139 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11141 static cmdline_parse_inst_t cmd_mcast_addr = {
11142 .f = cmd_mcast_addr_parsed,
11144 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11145 "Add/Remove multicast MAC address on port_id",
11147 (void *)&cmd_mcast_addr_cmd,
11148 (void *)&cmd_mcast_addr_what,
11149 (void *)&cmd_mcast_addr_portnum,
11150 (void *)&cmd_mcast_addr_addr,
11155 /* vf vlan anti spoof configuration */
11157 /* Common result structure for vf vlan anti spoof */
11158 struct cmd_vf_vlan_anti_spoof_result {
11159 cmdline_fixed_string_t set;
11160 cmdline_fixed_string_t vf;
11161 cmdline_fixed_string_t vlan;
11162 cmdline_fixed_string_t antispoof;
11165 cmdline_fixed_string_t on_off;
11168 /* Common CLI fields for vf vlan anti spoof enable disable */
11169 static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
11170 TOKEN_STRING_INITIALIZER
11171 (struct cmd_vf_vlan_anti_spoof_result,
11173 static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
11174 TOKEN_STRING_INITIALIZER
11175 (struct cmd_vf_vlan_anti_spoof_result,
11177 static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
11178 TOKEN_STRING_INITIALIZER
11179 (struct cmd_vf_vlan_anti_spoof_result,
11181 static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
11182 TOKEN_STRING_INITIALIZER
11183 (struct cmd_vf_vlan_anti_spoof_result,
11184 antispoof, "antispoof");
11185 static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
11186 TOKEN_NUM_INITIALIZER
11187 (struct cmd_vf_vlan_anti_spoof_result,
11188 port_id, RTE_UINT16);
11189 static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
11190 TOKEN_NUM_INITIALIZER
11191 (struct cmd_vf_vlan_anti_spoof_result,
11192 vf_id, RTE_UINT32);
11193 static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11194 TOKEN_STRING_INITIALIZER
11195 (struct cmd_vf_vlan_anti_spoof_result,
11199 cmd_set_vf_vlan_anti_spoof_parsed(
11200 void *parsed_result,
11201 __rte_unused struct cmdline *cl,
11202 __rte_unused void *data)
11204 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
11205 int ret = -ENOTSUP;
11207 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11209 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11212 #ifdef RTE_NET_IXGBE
11213 if (ret == -ENOTSUP)
11214 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11215 res->vf_id, is_on);
11217 #ifdef RTE_NET_I40E
11218 if (ret == -ENOTSUP)
11219 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11220 res->vf_id, is_on);
11222 #ifdef RTE_NET_BNXT
11223 if (ret == -ENOTSUP)
11224 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11225 res->vf_id, is_on);
11232 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11235 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11238 fprintf(stderr, "function not implemented\n");
11241 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11245 static cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11246 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11248 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11250 (void *)&cmd_vf_vlan_anti_spoof_set,
11251 (void *)&cmd_vf_vlan_anti_spoof_vf,
11252 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11253 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11254 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11255 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11256 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11261 /* vf mac anti spoof configuration */
11263 /* Common result structure for vf mac anti spoof */
11264 struct cmd_vf_mac_anti_spoof_result {
11265 cmdline_fixed_string_t set;
11266 cmdline_fixed_string_t vf;
11267 cmdline_fixed_string_t mac;
11268 cmdline_fixed_string_t antispoof;
11271 cmdline_fixed_string_t on_off;
11274 /* Common CLI fields for vf mac anti spoof enable disable */
11275 static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11276 TOKEN_STRING_INITIALIZER
11277 (struct cmd_vf_mac_anti_spoof_result,
11279 static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11280 TOKEN_STRING_INITIALIZER
11281 (struct cmd_vf_mac_anti_spoof_result,
11283 static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11284 TOKEN_STRING_INITIALIZER
11285 (struct cmd_vf_mac_anti_spoof_result,
11287 static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11288 TOKEN_STRING_INITIALIZER
11289 (struct cmd_vf_mac_anti_spoof_result,
11290 antispoof, "antispoof");
11291 static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11292 TOKEN_NUM_INITIALIZER
11293 (struct cmd_vf_mac_anti_spoof_result,
11294 port_id, RTE_UINT16);
11295 static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11296 TOKEN_NUM_INITIALIZER
11297 (struct cmd_vf_mac_anti_spoof_result,
11298 vf_id, RTE_UINT32);
11299 static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11300 TOKEN_STRING_INITIALIZER
11301 (struct cmd_vf_mac_anti_spoof_result,
11305 cmd_set_vf_mac_anti_spoof_parsed(
11306 void *parsed_result,
11307 __rte_unused struct cmdline *cl,
11308 __rte_unused void *data)
11310 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11311 int ret = -ENOTSUP;
11313 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11315 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11318 #ifdef RTE_NET_IXGBE
11319 if (ret == -ENOTSUP)
11320 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11321 res->vf_id, is_on);
11323 #ifdef RTE_NET_I40E
11324 if (ret == -ENOTSUP)
11325 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11326 res->vf_id, is_on);
11328 #ifdef RTE_NET_BNXT
11329 if (ret == -ENOTSUP)
11330 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11331 res->vf_id, is_on);
11338 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11339 res->vf_id, is_on);
11342 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11345 fprintf(stderr, "function not implemented\n");
11348 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11352 static cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11353 .f = cmd_set_vf_mac_anti_spoof_parsed,
11355 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11357 (void *)&cmd_vf_mac_anti_spoof_set,
11358 (void *)&cmd_vf_mac_anti_spoof_vf,
11359 (void *)&cmd_vf_mac_anti_spoof_mac,
11360 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11361 (void *)&cmd_vf_mac_anti_spoof_port_id,
11362 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11363 (void *)&cmd_vf_mac_anti_spoof_on_off,
11368 /* vf vlan strip queue configuration */
11370 /* Common result structure for vf mac anti spoof */
11371 struct cmd_vf_vlan_stripq_result {
11372 cmdline_fixed_string_t set;
11373 cmdline_fixed_string_t vf;
11374 cmdline_fixed_string_t vlan;
11375 cmdline_fixed_string_t stripq;
11378 cmdline_fixed_string_t on_off;
11381 /* Common CLI fields for vf vlan strip enable disable */
11382 static cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11383 TOKEN_STRING_INITIALIZER
11384 (struct cmd_vf_vlan_stripq_result,
11386 static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11387 TOKEN_STRING_INITIALIZER
11388 (struct cmd_vf_vlan_stripq_result,
11390 static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11391 TOKEN_STRING_INITIALIZER
11392 (struct cmd_vf_vlan_stripq_result,
11394 static cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11395 TOKEN_STRING_INITIALIZER
11396 (struct cmd_vf_vlan_stripq_result,
11398 static cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11399 TOKEN_NUM_INITIALIZER
11400 (struct cmd_vf_vlan_stripq_result,
11401 port_id, RTE_UINT16);
11402 static cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11403 TOKEN_NUM_INITIALIZER
11404 (struct cmd_vf_vlan_stripq_result,
11405 vf_id, RTE_UINT16);
11406 static cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11407 TOKEN_STRING_INITIALIZER
11408 (struct cmd_vf_vlan_stripq_result,
11412 cmd_set_vf_vlan_stripq_parsed(
11413 void *parsed_result,
11414 __rte_unused struct cmdline *cl,
11415 __rte_unused void *data)
11417 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11418 int ret = -ENOTSUP;
11420 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11422 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11425 #ifdef RTE_NET_IXGBE
11426 if (ret == -ENOTSUP)
11427 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11428 res->vf_id, is_on);
11430 #ifdef RTE_NET_I40E
11431 if (ret == -ENOTSUP)
11432 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11433 res->vf_id, is_on);
11435 #ifdef RTE_NET_BNXT
11436 if (ret == -ENOTSUP)
11437 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11438 res->vf_id, is_on);
11445 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11446 res->vf_id, is_on);
11449 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11452 fprintf(stderr, "function not implemented\n");
11455 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11459 static cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11460 .f = cmd_set_vf_vlan_stripq_parsed,
11462 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11464 (void *)&cmd_vf_vlan_stripq_set,
11465 (void *)&cmd_vf_vlan_stripq_vf,
11466 (void *)&cmd_vf_vlan_stripq_vlan,
11467 (void *)&cmd_vf_vlan_stripq_stripq,
11468 (void *)&cmd_vf_vlan_stripq_port_id,
11469 (void *)&cmd_vf_vlan_stripq_vf_id,
11470 (void *)&cmd_vf_vlan_stripq_on_off,
11475 /* vf vlan insert configuration */
11477 /* Common result structure for vf vlan insert */
11478 struct cmd_vf_vlan_insert_result {
11479 cmdline_fixed_string_t set;
11480 cmdline_fixed_string_t vf;
11481 cmdline_fixed_string_t vlan;
11482 cmdline_fixed_string_t insert;
11488 /* Common CLI fields for vf vlan insert enable disable */
11489 static cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11490 TOKEN_STRING_INITIALIZER
11491 (struct cmd_vf_vlan_insert_result,
11493 static cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11494 TOKEN_STRING_INITIALIZER
11495 (struct cmd_vf_vlan_insert_result,
11497 static cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11498 TOKEN_STRING_INITIALIZER
11499 (struct cmd_vf_vlan_insert_result,
11501 static cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11502 TOKEN_STRING_INITIALIZER
11503 (struct cmd_vf_vlan_insert_result,
11505 static cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11506 TOKEN_NUM_INITIALIZER
11507 (struct cmd_vf_vlan_insert_result,
11508 port_id, RTE_UINT16);
11509 static cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11510 TOKEN_NUM_INITIALIZER
11511 (struct cmd_vf_vlan_insert_result,
11512 vf_id, RTE_UINT16);
11513 static cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11514 TOKEN_NUM_INITIALIZER
11515 (struct cmd_vf_vlan_insert_result,
11516 vlan_id, RTE_UINT16);
11519 cmd_set_vf_vlan_insert_parsed(
11520 void *parsed_result,
11521 __rte_unused struct cmdline *cl,
11522 __rte_unused void *data)
11524 struct cmd_vf_vlan_insert_result *res = parsed_result;
11525 int ret = -ENOTSUP;
11527 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11530 #ifdef RTE_NET_IXGBE
11531 if (ret == -ENOTSUP)
11532 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11535 #ifdef RTE_NET_I40E
11536 if (ret == -ENOTSUP)
11537 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11540 #ifdef RTE_NET_BNXT
11541 if (ret == -ENOTSUP)
11542 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11550 fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
11551 res->vf_id, res->vlan_id);
11554 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11557 fprintf(stderr, "function not implemented\n");
11560 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11564 static cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11565 .f = cmd_set_vf_vlan_insert_parsed,
11567 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11569 (void *)&cmd_vf_vlan_insert_set,
11570 (void *)&cmd_vf_vlan_insert_vf,
11571 (void *)&cmd_vf_vlan_insert_vlan,
11572 (void *)&cmd_vf_vlan_insert_insert,
11573 (void *)&cmd_vf_vlan_insert_port_id,
11574 (void *)&cmd_vf_vlan_insert_vf_id,
11575 (void *)&cmd_vf_vlan_insert_vlan_id,
11580 /* tx loopback configuration */
11582 /* Common result structure for tx loopback */
11583 struct cmd_tx_loopback_result {
11584 cmdline_fixed_string_t set;
11585 cmdline_fixed_string_t tx;
11586 cmdline_fixed_string_t loopback;
11588 cmdline_fixed_string_t on_off;
11591 /* Common CLI fields for tx loopback enable disable */
11592 static cmdline_parse_token_string_t cmd_tx_loopback_set =
11593 TOKEN_STRING_INITIALIZER
11594 (struct cmd_tx_loopback_result,
11596 static cmdline_parse_token_string_t cmd_tx_loopback_tx =
11597 TOKEN_STRING_INITIALIZER
11598 (struct cmd_tx_loopback_result,
11600 static cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11601 TOKEN_STRING_INITIALIZER
11602 (struct cmd_tx_loopback_result,
11603 loopback, "loopback");
11604 static cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11605 TOKEN_NUM_INITIALIZER
11606 (struct cmd_tx_loopback_result,
11607 port_id, RTE_UINT16);
11608 static cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11609 TOKEN_STRING_INITIALIZER
11610 (struct cmd_tx_loopback_result,
11614 cmd_set_tx_loopback_parsed(
11615 void *parsed_result,
11616 __rte_unused struct cmdline *cl,
11617 __rte_unused void *data)
11619 struct cmd_tx_loopback_result *res = parsed_result;
11620 int ret = -ENOTSUP;
11622 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11624 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11627 #ifdef RTE_NET_IXGBE
11628 if (ret == -ENOTSUP)
11629 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11631 #ifdef RTE_NET_I40E
11632 if (ret == -ENOTSUP)
11633 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11635 #ifdef RTE_NET_BNXT
11636 if (ret == -ENOTSUP)
11637 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11639 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11640 if (ret == -ENOTSUP)
11641 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11648 fprintf(stderr, "invalid is_on %d\n", is_on);
11651 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11654 fprintf(stderr, "function not implemented\n");
11657 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11661 static cmdline_parse_inst_t cmd_set_tx_loopback = {
11662 .f = cmd_set_tx_loopback_parsed,
11664 .help_str = "set tx loopback <port_id> on|off",
11666 (void *)&cmd_tx_loopback_set,
11667 (void *)&cmd_tx_loopback_tx,
11668 (void *)&cmd_tx_loopback_loopback,
11669 (void *)&cmd_tx_loopback_port_id,
11670 (void *)&cmd_tx_loopback_on_off,
11675 /* all queues drop enable configuration */
11677 /* Common result structure for all queues drop enable */
11678 struct cmd_all_queues_drop_en_result {
11679 cmdline_fixed_string_t set;
11680 cmdline_fixed_string_t all;
11681 cmdline_fixed_string_t queues;
11682 cmdline_fixed_string_t drop;
11684 cmdline_fixed_string_t on_off;
11687 /* Common CLI fields for tx loopback enable disable */
11688 static cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11689 TOKEN_STRING_INITIALIZER
11690 (struct cmd_all_queues_drop_en_result,
11692 static cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11693 TOKEN_STRING_INITIALIZER
11694 (struct cmd_all_queues_drop_en_result,
11696 static cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11697 TOKEN_STRING_INITIALIZER
11698 (struct cmd_all_queues_drop_en_result,
11700 static cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11701 TOKEN_STRING_INITIALIZER
11702 (struct cmd_all_queues_drop_en_result,
11704 static cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11705 TOKEN_NUM_INITIALIZER
11706 (struct cmd_all_queues_drop_en_result,
11707 port_id, RTE_UINT16);
11708 static cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11709 TOKEN_STRING_INITIALIZER
11710 (struct cmd_all_queues_drop_en_result,
11714 cmd_set_all_queues_drop_en_parsed(
11715 void *parsed_result,
11716 __rte_unused struct cmdline *cl,
11717 __rte_unused void *data)
11719 struct cmd_all_queues_drop_en_result *res = parsed_result;
11720 int ret = -ENOTSUP;
11721 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11723 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11726 #ifdef RTE_NET_IXGBE
11727 if (ret == -ENOTSUP)
11728 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11730 #ifdef RTE_NET_BNXT
11731 if (ret == -ENOTSUP)
11732 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11738 fprintf(stderr, "invalid is_on %d\n", is_on);
11741 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11744 fprintf(stderr, "function not implemented\n");
11747 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11751 static cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11752 .f = cmd_set_all_queues_drop_en_parsed,
11754 .help_str = "set all queues drop <port_id> on|off",
11756 (void *)&cmd_all_queues_drop_en_set,
11757 (void *)&cmd_all_queues_drop_en_all,
11758 (void *)&cmd_all_queues_drop_en_queues,
11759 (void *)&cmd_all_queues_drop_en_drop,
11760 (void *)&cmd_all_queues_drop_en_port_id,
11761 (void *)&cmd_all_queues_drop_en_on_off,
11766 /* vf split drop enable configuration */
11768 /* Common result structure for vf split drop enable */
11769 struct cmd_vf_split_drop_en_result {
11770 cmdline_fixed_string_t set;
11771 cmdline_fixed_string_t vf;
11772 cmdline_fixed_string_t split;
11773 cmdline_fixed_string_t drop;
11776 cmdline_fixed_string_t on_off;
11779 /* Common CLI fields for vf split drop enable disable */
11780 static cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11781 TOKEN_STRING_INITIALIZER
11782 (struct cmd_vf_split_drop_en_result,
11784 static cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11785 TOKEN_STRING_INITIALIZER
11786 (struct cmd_vf_split_drop_en_result,
11788 static cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11789 TOKEN_STRING_INITIALIZER
11790 (struct cmd_vf_split_drop_en_result,
11792 static cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11793 TOKEN_STRING_INITIALIZER
11794 (struct cmd_vf_split_drop_en_result,
11796 static cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11797 TOKEN_NUM_INITIALIZER
11798 (struct cmd_vf_split_drop_en_result,
11799 port_id, RTE_UINT16);
11800 static cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11801 TOKEN_NUM_INITIALIZER
11802 (struct cmd_vf_split_drop_en_result,
11803 vf_id, RTE_UINT16);
11804 static cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11805 TOKEN_STRING_INITIALIZER
11806 (struct cmd_vf_split_drop_en_result,
11810 cmd_set_vf_split_drop_en_parsed(
11811 void *parsed_result,
11812 __rte_unused struct cmdline *cl,
11813 __rte_unused void *data)
11815 struct cmd_vf_split_drop_en_result *res = parsed_result;
11816 int ret = -ENOTSUP;
11817 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11819 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11822 #ifdef RTE_NET_IXGBE
11823 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11830 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11831 res->vf_id, is_on);
11834 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11837 fprintf(stderr, "not supported on port %d\n", res->port_id);
11840 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11844 static cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11845 .f = cmd_set_vf_split_drop_en_parsed,
11847 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11849 (void *)&cmd_vf_split_drop_en_set,
11850 (void *)&cmd_vf_split_drop_en_vf,
11851 (void *)&cmd_vf_split_drop_en_split,
11852 (void *)&cmd_vf_split_drop_en_drop,
11853 (void *)&cmd_vf_split_drop_en_port_id,
11854 (void *)&cmd_vf_split_drop_en_vf_id,
11855 (void *)&cmd_vf_split_drop_en_on_off,
11860 /* vf mac address configuration */
11862 /* Common result structure for vf mac address */
11863 struct cmd_set_vf_mac_addr_result {
11864 cmdline_fixed_string_t set;
11865 cmdline_fixed_string_t vf;
11866 cmdline_fixed_string_t mac;
11867 cmdline_fixed_string_t addr;
11870 struct rte_ether_addr mac_addr;
11874 /* Common CLI fields for vf split drop enable disable */
11875 static cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11876 TOKEN_STRING_INITIALIZER
11877 (struct cmd_set_vf_mac_addr_result,
11879 static cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11880 TOKEN_STRING_INITIALIZER
11881 (struct cmd_set_vf_mac_addr_result,
11883 static cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11884 TOKEN_STRING_INITIALIZER
11885 (struct cmd_set_vf_mac_addr_result,
11887 static cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11888 TOKEN_STRING_INITIALIZER
11889 (struct cmd_set_vf_mac_addr_result,
11891 static cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11892 TOKEN_NUM_INITIALIZER
11893 (struct cmd_set_vf_mac_addr_result,
11894 port_id, RTE_UINT16);
11895 static cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11896 TOKEN_NUM_INITIALIZER
11897 (struct cmd_set_vf_mac_addr_result,
11898 vf_id, RTE_UINT16);
11899 static cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11900 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11904 cmd_set_vf_mac_addr_parsed(
11905 void *parsed_result,
11906 __rte_unused struct cmdline *cl,
11907 __rte_unused void *data)
11909 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11910 int ret = -ENOTSUP;
11912 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11915 #ifdef RTE_NET_IXGBE
11916 if (ret == -ENOTSUP)
11917 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11920 #ifdef RTE_NET_I40E
11921 if (ret == -ENOTSUP)
11922 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11925 #ifdef RTE_NET_BNXT
11926 if (ret == -ENOTSUP)
11927 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11935 fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
11938 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11941 fprintf(stderr, "function not implemented\n");
11944 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11948 static cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11949 .f = cmd_set_vf_mac_addr_parsed,
11951 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11953 (void *)&cmd_set_vf_mac_addr_set,
11954 (void *)&cmd_set_vf_mac_addr_vf,
11955 (void *)&cmd_set_vf_mac_addr_mac,
11956 (void *)&cmd_set_vf_mac_addr_addr,
11957 (void *)&cmd_set_vf_mac_addr_port_id,
11958 (void *)&cmd_set_vf_mac_addr_vf_id,
11959 (void *)&cmd_set_vf_mac_addr_mac_addr,
11964 /* MACsec configuration */
11966 /* Common result structure for MACsec offload enable */
11967 struct cmd_macsec_offload_on_result {
11968 cmdline_fixed_string_t set;
11969 cmdline_fixed_string_t macsec;
11970 cmdline_fixed_string_t offload;
11972 cmdline_fixed_string_t on;
11973 cmdline_fixed_string_t encrypt;
11974 cmdline_fixed_string_t en_on_off;
11975 cmdline_fixed_string_t replay_protect;
11976 cmdline_fixed_string_t rp_on_off;
11979 /* Common CLI fields for MACsec offload disable */
11980 static cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11981 TOKEN_STRING_INITIALIZER
11982 (struct cmd_macsec_offload_on_result,
11984 static cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11985 TOKEN_STRING_INITIALIZER
11986 (struct cmd_macsec_offload_on_result,
11988 static cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11989 TOKEN_STRING_INITIALIZER
11990 (struct cmd_macsec_offload_on_result,
11991 offload, "offload");
11992 static cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11993 TOKEN_NUM_INITIALIZER
11994 (struct cmd_macsec_offload_on_result,
11995 port_id, RTE_UINT16);
11996 static cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11997 TOKEN_STRING_INITIALIZER
11998 (struct cmd_macsec_offload_on_result,
12000 static cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
12001 TOKEN_STRING_INITIALIZER
12002 (struct cmd_macsec_offload_on_result,
12003 encrypt, "encrypt");
12004 static cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
12005 TOKEN_STRING_INITIALIZER
12006 (struct cmd_macsec_offload_on_result,
12007 en_on_off, "on#off");
12008 static cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
12009 TOKEN_STRING_INITIALIZER
12010 (struct cmd_macsec_offload_on_result,
12011 replay_protect, "replay-protect");
12012 static cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
12013 TOKEN_STRING_INITIALIZER
12014 (struct cmd_macsec_offload_on_result,
12015 rp_on_off, "on#off");
12018 cmd_set_macsec_offload_on_parsed(
12019 void *parsed_result,
12020 __rte_unused struct cmdline *cl,
12021 __rte_unused void *data)
12023 struct cmd_macsec_offload_on_result *res = parsed_result;
12024 int ret = -ENOTSUP;
12025 portid_t port_id = res->port_id;
12026 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
12027 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
12028 struct rte_eth_dev_info dev_info;
12030 if (port_id_is_invalid(port_id, ENABLED_WARN))
12032 if (!port_is_stopped(port_id)) {
12033 fprintf(stderr, "Please stop port %d first\n", port_id);
12037 ret = eth_dev_info_get_print_err(port_id, &dev_info);
12041 if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) {
12042 #ifdef RTE_NET_IXGBE
12043 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
12051 ports[port_id].dev_conf.txmode.offloads |=
12052 RTE_ETH_TX_OFFLOAD_MACSEC_INSERT;
12053 cmd_reconfig_device_queue(port_id, 1, 1);
12056 fprintf(stderr, "invalid port_id %d\n", port_id);
12059 fprintf(stderr, "not supported on port %d\n", port_id);
12062 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12066 static cmdline_parse_inst_t cmd_set_macsec_offload_on = {
12067 .f = cmd_set_macsec_offload_on_parsed,
12069 .help_str = "set macsec offload <port_id> on "
12070 "encrypt on|off replay-protect on|off",
12072 (void *)&cmd_macsec_offload_on_set,
12073 (void *)&cmd_macsec_offload_on_macsec,
12074 (void *)&cmd_macsec_offload_on_offload,
12075 (void *)&cmd_macsec_offload_on_port_id,
12076 (void *)&cmd_macsec_offload_on_on,
12077 (void *)&cmd_macsec_offload_on_encrypt,
12078 (void *)&cmd_macsec_offload_on_en_on_off,
12079 (void *)&cmd_macsec_offload_on_replay_protect,
12080 (void *)&cmd_macsec_offload_on_rp_on_off,
12085 /* Common result structure for MACsec offload disable */
12086 struct cmd_macsec_offload_off_result {
12087 cmdline_fixed_string_t set;
12088 cmdline_fixed_string_t macsec;
12089 cmdline_fixed_string_t offload;
12091 cmdline_fixed_string_t off;
12094 /* Common CLI fields for MACsec offload disable */
12095 static cmdline_parse_token_string_t cmd_macsec_offload_off_set =
12096 TOKEN_STRING_INITIALIZER
12097 (struct cmd_macsec_offload_off_result,
12099 static cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
12100 TOKEN_STRING_INITIALIZER
12101 (struct cmd_macsec_offload_off_result,
12103 static cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
12104 TOKEN_STRING_INITIALIZER
12105 (struct cmd_macsec_offload_off_result,
12106 offload, "offload");
12107 static cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
12108 TOKEN_NUM_INITIALIZER
12109 (struct cmd_macsec_offload_off_result,
12110 port_id, RTE_UINT16);
12111 static cmdline_parse_token_string_t cmd_macsec_offload_off_off =
12112 TOKEN_STRING_INITIALIZER
12113 (struct cmd_macsec_offload_off_result,
12117 cmd_set_macsec_offload_off_parsed(
12118 void *parsed_result,
12119 __rte_unused struct cmdline *cl,
12120 __rte_unused void *data)
12122 struct cmd_macsec_offload_off_result *res = parsed_result;
12123 int ret = -ENOTSUP;
12124 struct rte_eth_dev_info dev_info;
12125 portid_t port_id = res->port_id;
12127 if (port_id_is_invalid(port_id, ENABLED_WARN))
12129 if (!port_is_stopped(port_id)) {
12130 fprintf(stderr, "Please stop port %d first\n", port_id);
12134 ret = eth_dev_info_get_print_err(port_id, &dev_info);
12138 if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) {
12139 #ifdef RTE_NET_IXGBE
12140 ret = rte_pmd_ixgbe_macsec_disable(port_id);
12145 ports[port_id].dev_conf.txmode.offloads &=
12146 ~RTE_ETH_TX_OFFLOAD_MACSEC_INSERT;
12147 cmd_reconfig_device_queue(port_id, 1, 1);
12150 fprintf(stderr, "invalid port_id %d\n", port_id);
12153 fprintf(stderr, "not supported on port %d\n", port_id);
12156 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12160 static cmdline_parse_inst_t cmd_set_macsec_offload_off = {
12161 .f = cmd_set_macsec_offload_off_parsed,
12163 .help_str = "set macsec offload <port_id> off",
12165 (void *)&cmd_macsec_offload_off_set,
12166 (void *)&cmd_macsec_offload_off_macsec,
12167 (void *)&cmd_macsec_offload_off_offload,
12168 (void *)&cmd_macsec_offload_off_port_id,
12169 (void *)&cmd_macsec_offload_off_off,
12174 /* Common result structure for MACsec secure connection configure */
12175 struct cmd_macsec_sc_result {
12176 cmdline_fixed_string_t set;
12177 cmdline_fixed_string_t macsec;
12178 cmdline_fixed_string_t sc;
12179 cmdline_fixed_string_t tx_rx;
12181 struct rte_ether_addr mac;
12185 /* Common CLI fields for MACsec secure connection configure */
12186 static cmdline_parse_token_string_t cmd_macsec_sc_set =
12187 TOKEN_STRING_INITIALIZER
12188 (struct cmd_macsec_sc_result,
12190 static cmdline_parse_token_string_t cmd_macsec_sc_macsec =
12191 TOKEN_STRING_INITIALIZER
12192 (struct cmd_macsec_sc_result,
12194 static cmdline_parse_token_string_t cmd_macsec_sc_sc =
12195 TOKEN_STRING_INITIALIZER
12196 (struct cmd_macsec_sc_result,
12198 static cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
12199 TOKEN_STRING_INITIALIZER
12200 (struct cmd_macsec_sc_result,
12202 static cmdline_parse_token_num_t cmd_macsec_sc_port_id =
12203 TOKEN_NUM_INITIALIZER
12204 (struct cmd_macsec_sc_result,
12205 port_id, RTE_UINT16);
12206 static cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
12207 TOKEN_ETHERADDR_INITIALIZER
12208 (struct cmd_macsec_sc_result,
12210 static cmdline_parse_token_num_t cmd_macsec_sc_pi =
12211 TOKEN_NUM_INITIALIZER
12212 (struct cmd_macsec_sc_result,
12216 cmd_set_macsec_sc_parsed(
12217 void *parsed_result,
12218 __rte_unused struct cmdline *cl,
12219 __rte_unused void *data)
12221 struct cmd_macsec_sc_result *res = parsed_result;
12222 int ret = -ENOTSUP;
12223 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12225 #ifdef RTE_NET_IXGBE
12227 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12228 res->mac.addr_bytes) :
12229 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12230 res->mac.addr_bytes, res->pi);
12232 RTE_SET_USED(is_tx);
12238 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12241 fprintf(stderr, "not supported on port %d\n", res->port_id);
12244 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12248 static cmdline_parse_inst_t cmd_set_macsec_sc = {
12249 .f = cmd_set_macsec_sc_parsed,
12251 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12253 (void *)&cmd_macsec_sc_set,
12254 (void *)&cmd_macsec_sc_macsec,
12255 (void *)&cmd_macsec_sc_sc,
12256 (void *)&cmd_macsec_sc_tx_rx,
12257 (void *)&cmd_macsec_sc_port_id,
12258 (void *)&cmd_macsec_sc_mac,
12259 (void *)&cmd_macsec_sc_pi,
12264 /* Common result structure for MACsec secure connection configure */
12265 struct cmd_macsec_sa_result {
12266 cmdline_fixed_string_t set;
12267 cmdline_fixed_string_t macsec;
12268 cmdline_fixed_string_t sa;
12269 cmdline_fixed_string_t tx_rx;
12274 cmdline_fixed_string_t key;
12277 /* Common CLI fields for MACsec secure connection configure */
12278 static cmdline_parse_token_string_t cmd_macsec_sa_set =
12279 TOKEN_STRING_INITIALIZER
12280 (struct cmd_macsec_sa_result,
12282 static cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12283 TOKEN_STRING_INITIALIZER
12284 (struct cmd_macsec_sa_result,
12286 static cmdline_parse_token_string_t cmd_macsec_sa_sa =
12287 TOKEN_STRING_INITIALIZER
12288 (struct cmd_macsec_sa_result,
12290 static cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12291 TOKEN_STRING_INITIALIZER
12292 (struct cmd_macsec_sa_result,
12294 static cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12295 TOKEN_NUM_INITIALIZER
12296 (struct cmd_macsec_sa_result,
12297 port_id, RTE_UINT16);
12298 static cmdline_parse_token_num_t cmd_macsec_sa_idx =
12299 TOKEN_NUM_INITIALIZER
12300 (struct cmd_macsec_sa_result,
12302 static cmdline_parse_token_num_t cmd_macsec_sa_an =
12303 TOKEN_NUM_INITIALIZER
12304 (struct cmd_macsec_sa_result,
12306 static cmdline_parse_token_num_t cmd_macsec_sa_pn =
12307 TOKEN_NUM_INITIALIZER
12308 (struct cmd_macsec_sa_result,
12310 static cmdline_parse_token_string_t cmd_macsec_sa_key =
12311 TOKEN_STRING_INITIALIZER
12312 (struct cmd_macsec_sa_result,
12316 cmd_set_macsec_sa_parsed(
12317 void *parsed_result,
12318 __rte_unused struct cmdline *cl,
12319 __rte_unused void *data)
12321 struct cmd_macsec_sa_result *res = parsed_result;
12322 int ret = -ENOTSUP;
12323 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12324 uint8_t key[16] = { 0 };
12330 key_len = strlen(res->key) / 2;
12334 for (i = 0; i < key_len; i++) {
12335 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12338 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12341 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12344 #ifdef RTE_NET_IXGBE
12346 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12347 res->idx, res->an, res->pn, key) :
12348 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12349 res->idx, res->an, res->pn, key);
12351 RTE_SET_USED(is_tx);
12358 fprintf(stderr, "invalid idx %d or an %d\n", res->idx, res->an);
12361 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12364 fprintf(stderr, "not supported on port %d\n", res->port_id);
12367 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12371 static cmdline_parse_inst_t cmd_set_macsec_sa = {
12372 .f = cmd_set_macsec_sa_parsed,
12374 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12376 (void *)&cmd_macsec_sa_set,
12377 (void *)&cmd_macsec_sa_macsec,
12378 (void *)&cmd_macsec_sa_sa,
12379 (void *)&cmd_macsec_sa_tx_rx,
12380 (void *)&cmd_macsec_sa_port_id,
12381 (void *)&cmd_macsec_sa_idx,
12382 (void *)&cmd_macsec_sa_an,
12383 (void *)&cmd_macsec_sa_pn,
12384 (void *)&cmd_macsec_sa_key,
12389 /* VF unicast promiscuous mode configuration */
12391 /* Common result structure for VF unicast promiscuous mode */
12392 struct cmd_vf_promisc_result {
12393 cmdline_fixed_string_t set;
12394 cmdline_fixed_string_t vf;
12395 cmdline_fixed_string_t promisc;
12398 cmdline_fixed_string_t on_off;
12401 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12402 static cmdline_parse_token_string_t cmd_vf_promisc_set =
12403 TOKEN_STRING_INITIALIZER
12404 (struct cmd_vf_promisc_result,
12406 static cmdline_parse_token_string_t cmd_vf_promisc_vf =
12407 TOKEN_STRING_INITIALIZER
12408 (struct cmd_vf_promisc_result,
12410 static cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12411 TOKEN_STRING_INITIALIZER
12412 (struct cmd_vf_promisc_result,
12413 promisc, "promisc");
12414 static cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12415 TOKEN_NUM_INITIALIZER
12416 (struct cmd_vf_promisc_result,
12417 port_id, RTE_UINT16);
12418 static cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12419 TOKEN_NUM_INITIALIZER
12420 (struct cmd_vf_promisc_result,
12421 vf_id, RTE_UINT32);
12422 static cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12423 TOKEN_STRING_INITIALIZER
12424 (struct cmd_vf_promisc_result,
12428 cmd_set_vf_promisc_parsed(
12429 void *parsed_result,
12430 __rte_unused struct cmdline *cl,
12431 __rte_unused void *data)
12433 struct cmd_vf_promisc_result *res = parsed_result;
12434 int ret = -ENOTSUP;
12436 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12438 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12441 #ifdef RTE_NET_I40E
12442 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12443 res->vf_id, is_on);
12450 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12453 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12456 fprintf(stderr, "function not implemented\n");
12459 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12463 static cmdline_parse_inst_t cmd_set_vf_promisc = {
12464 .f = cmd_set_vf_promisc_parsed,
12466 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12467 "Set unicast promiscuous mode for a VF from the PF",
12469 (void *)&cmd_vf_promisc_set,
12470 (void *)&cmd_vf_promisc_vf,
12471 (void *)&cmd_vf_promisc_promisc,
12472 (void *)&cmd_vf_promisc_port_id,
12473 (void *)&cmd_vf_promisc_vf_id,
12474 (void *)&cmd_vf_promisc_on_off,
12479 /* VF multicast promiscuous mode configuration */
12481 /* Common result structure for VF multicast promiscuous mode */
12482 struct cmd_vf_allmulti_result {
12483 cmdline_fixed_string_t set;
12484 cmdline_fixed_string_t vf;
12485 cmdline_fixed_string_t allmulti;
12488 cmdline_fixed_string_t on_off;
12491 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12492 static cmdline_parse_token_string_t cmd_vf_allmulti_set =
12493 TOKEN_STRING_INITIALIZER
12494 (struct cmd_vf_allmulti_result,
12496 static cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12497 TOKEN_STRING_INITIALIZER
12498 (struct cmd_vf_allmulti_result,
12500 static cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12501 TOKEN_STRING_INITIALIZER
12502 (struct cmd_vf_allmulti_result,
12503 allmulti, "allmulti");
12504 static cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12505 TOKEN_NUM_INITIALIZER
12506 (struct cmd_vf_allmulti_result,
12507 port_id, RTE_UINT16);
12508 static cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12509 TOKEN_NUM_INITIALIZER
12510 (struct cmd_vf_allmulti_result,
12511 vf_id, RTE_UINT32);
12512 static cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12513 TOKEN_STRING_INITIALIZER
12514 (struct cmd_vf_allmulti_result,
12518 cmd_set_vf_allmulti_parsed(
12519 void *parsed_result,
12520 __rte_unused struct cmdline *cl,
12521 __rte_unused void *data)
12523 struct cmd_vf_allmulti_result *res = parsed_result;
12524 int ret = -ENOTSUP;
12526 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12528 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12531 #ifdef RTE_NET_I40E
12532 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12533 res->vf_id, is_on);
12540 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12543 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12546 fprintf(stderr, "function not implemented\n");
12549 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12553 static cmdline_parse_inst_t cmd_set_vf_allmulti = {
12554 .f = cmd_set_vf_allmulti_parsed,
12556 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12557 "Set multicast promiscuous mode for a VF from the PF",
12559 (void *)&cmd_vf_allmulti_set,
12560 (void *)&cmd_vf_allmulti_vf,
12561 (void *)&cmd_vf_allmulti_allmulti,
12562 (void *)&cmd_vf_allmulti_port_id,
12563 (void *)&cmd_vf_allmulti_vf_id,
12564 (void *)&cmd_vf_allmulti_on_off,
12569 /* vf broadcast mode configuration */
12571 /* Common result structure for vf broadcast */
12572 struct cmd_set_vf_broadcast_result {
12573 cmdline_fixed_string_t set;
12574 cmdline_fixed_string_t vf;
12575 cmdline_fixed_string_t broadcast;
12578 cmdline_fixed_string_t on_off;
12581 /* Common CLI fields for vf broadcast enable disable */
12582 static cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12583 TOKEN_STRING_INITIALIZER
12584 (struct cmd_set_vf_broadcast_result,
12586 static cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12587 TOKEN_STRING_INITIALIZER
12588 (struct cmd_set_vf_broadcast_result,
12590 static cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12591 TOKEN_STRING_INITIALIZER
12592 (struct cmd_set_vf_broadcast_result,
12593 broadcast, "broadcast");
12594 static cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12595 TOKEN_NUM_INITIALIZER
12596 (struct cmd_set_vf_broadcast_result,
12597 port_id, RTE_UINT16);
12598 static cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12599 TOKEN_NUM_INITIALIZER
12600 (struct cmd_set_vf_broadcast_result,
12601 vf_id, RTE_UINT16);
12602 static cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12603 TOKEN_STRING_INITIALIZER
12604 (struct cmd_set_vf_broadcast_result,
12608 cmd_set_vf_broadcast_parsed(
12609 void *parsed_result,
12610 __rte_unused struct cmdline *cl,
12611 __rte_unused void *data)
12613 struct cmd_set_vf_broadcast_result *res = parsed_result;
12614 int ret = -ENOTSUP;
12616 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12618 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12621 #ifdef RTE_NET_I40E
12622 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12623 res->vf_id, is_on);
12630 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12631 res->vf_id, is_on);
12634 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12637 fprintf(stderr, "function not implemented\n");
12640 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12644 static cmdline_parse_inst_t cmd_set_vf_broadcast = {
12645 .f = cmd_set_vf_broadcast_parsed,
12647 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12649 (void *)&cmd_set_vf_broadcast_set,
12650 (void *)&cmd_set_vf_broadcast_vf,
12651 (void *)&cmd_set_vf_broadcast_broadcast,
12652 (void *)&cmd_set_vf_broadcast_port_id,
12653 (void *)&cmd_set_vf_broadcast_vf_id,
12654 (void *)&cmd_set_vf_broadcast_on_off,
12659 /* vf vlan tag configuration */
12661 /* Common result structure for vf vlan tag */
12662 struct cmd_set_vf_vlan_tag_result {
12663 cmdline_fixed_string_t set;
12664 cmdline_fixed_string_t vf;
12665 cmdline_fixed_string_t vlan;
12666 cmdline_fixed_string_t tag;
12669 cmdline_fixed_string_t on_off;
12672 /* Common CLI fields for vf vlan tag enable disable */
12673 static cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12674 TOKEN_STRING_INITIALIZER
12675 (struct cmd_set_vf_vlan_tag_result,
12677 static cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12678 TOKEN_STRING_INITIALIZER
12679 (struct cmd_set_vf_vlan_tag_result,
12681 static cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12682 TOKEN_STRING_INITIALIZER
12683 (struct cmd_set_vf_vlan_tag_result,
12685 static cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12686 TOKEN_STRING_INITIALIZER
12687 (struct cmd_set_vf_vlan_tag_result,
12689 static cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12690 TOKEN_NUM_INITIALIZER
12691 (struct cmd_set_vf_vlan_tag_result,
12692 port_id, RTE_UINT16);
12693 static cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12694 TOKEN_NUM_INITIALIZER
12695 (struct cmd_set_vf_vlan_tag_result,
12696 vf_id, RTE_UINT16);
12697 static cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12698 TOKEN_STRING_INITIALIZER
12699 (struct cmd_set_vf_vlan_tag_result,
12703 cmd_set_vf_vlan_tag_parsed(
12704 void *parsed_result,
12705 __rte_unused struct cmdline *cl,
12706 __rte_unused void *data)
12708 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12709 int ret = -ENOTSUP;
12711 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12713 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12716 #ifdef RTE_NET_I40E
12717 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12718 res->vf_id, is_on);
12725 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12726 res->vf_id, is_on);
12729 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12732 fprintf(stderr, "function not implemented\n");
12735 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12739 static cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12740 .f = cmd_set_vf_vlan_tag_parsed,
12742 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12744 (void *)&cmd_set_vf_vlan_tag_set,
12745 (void *)&cmd_set_vf_vlan_tag_vf,
12746 (void *)&cmd_set_vf_vlan_tag_vlan,
12747 (void *)&cmd_set_vf_vlan_tag_tag,
12748 (void *)&cmd_set_vf_vlan_tag_port_id,
12749 (void *)&cmd_set_vf_vlan_tag_vf_id,
12750 (void *)&cmd_set_vf_vlan_tag_on_off,
12755 /* Common definition of VF and TC TX bandwidth configuration */
12756 struct cmd_vf_tc_bw_result {
12757 cmdline_fixed_string_t set;
12758 cmdline_fixed_string_t vf;
12759 cmdline_fixed_string_t tc;
12760 cmdline_fixed_string_t tx;
12761 cmdline_fixed_string_t min_bw;
12762 cmdline_fixed_string_t max_bw;
12763 cmdline_fixed_string_t strict_link_prio;
12768 cmdline_fixed_string_t bw_list;
12772 static cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12773 TOKEN_STRING_INITIALIZER
12774 (struct cmd_vf_tc_bw_result,
12776 static cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12777 TOKEN_STRING_INITIALIZER
12778 (struct cmd_vf_tc_bw_result,
12780 static cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12781 TOKEN_STRING_INITIALIZER
12782 (struct cmd_vf_tc_bw_result,
12784 static cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12785 TOKEN_STRING_INITIALIZER
12786 (struct cmd_vf_tc_bw_result,
12788 static cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12789 TOKEN_STRING_INITIALIZER
12790 (struct cmd_vf_tc_bw_result,
12791 strict_link_prio, "strict-link-priority");
12792 static cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12793 TOKEN_STRING_INITIALIZER
12794 (struct cmd_vf_tc_bw_result,
12795 min_bw, "min-bandwidth");
12796 static cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12797 TOKEN_STRING_INITIALIZER
12798 (struct cmd_vf_tc_bw_result,
12799 max_bw, "max-bandwidth");
12800 static cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12801 TOKEN_NUM_INITIALIZER
12802 (struct cmd_vf_tc_bw_result,
12803 port_id, RTE_UINT16);
12804 static cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12805 TOKEN_NUM_INITIALIZER
12806 (struct cmd_vf_tc_bw_result,
12807 vf_id, RTE_UINT16);
12808 static cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12809 TOKEN_NUM_INITIALIZER
12810 (struct cmd_vf_tc_bw_result,
12812 static cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12813 TOKEN_NUM_INITIALIZER
12814 (struct cmd_vf_tc_bw_result,
12816 static cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12817 TOKEN_STRING_INITIALIZER
12818 (struct cmd_vf_tc_bw_result,
12820 static cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12821 TOKEN_NUM_INITIALIZER
12822 (struct cmd_vf_tc_bw_result,
12823 tc_map, RTE_UINT8);
12825 /* VF max bandwidth setting */
12827 cmd_vf_max_bw_parsed(
12828 void *parsed_result,
12829 __rte_unused struct cmdline *cl,
12830 __rte_unused void *data)
12832 struct cmd_vf_tc_bw_result *res = parsed_result;
12833 int ret = -ENOTSUP;
12835 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12838 #ifdef RTE_NET_I40E
12839 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12840 res->vf_id, res->bw);
12847 fprintf(stderr, "invalid vf_id %d or bandwidth %d\n",
12848 res->vf_id, res->bw);
12851 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12854 fprintf(stderr, "function not implemented\n");
12857 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12861 static cmdline_parse_inst_t cmd_vf_max_bw = {
12862 .f = cmd_vf_max_bw_parsed,
12864 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12866 (void *)&cmd_vf_tc_bw_set,
12867 (void *)&cmd_vf_tc_bw_vf,
12868 (void *)&cmd_vf_tc_bw_tx,
12869 (void *)&cmd_vf_tc_bw_max_bw,
12870 (void *)&cmd_vf_tc_bw_port_id,
12871 (void *)&cmd_vf_tc_bw_vf_id,
12872 (void *)&cmd_vf_tc_bw_bw,
12878 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12883 const char *p, *p0 = str;
12890 p = strchr(p0, '(');
12893 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12897 p0 = strchr(p, ')');
12900 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12904 if (size >= sizeof(s)) {
12906 "The string size exceeds the internal buffer size\n");
12909 snprintf(s, sizeof(s), "%.*s", size, p);
12910 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12912 fprintf(stderr, "Failed to get the bandwidth list.\n");
12916 for (i = 0; i < ret; i++)
12917 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12922 /* TC min bandwidth setting */
12924 cmd_vf_tc_min_bw_parsed(
12925 void *parsed_result,
12926 __rte_unused struct cmdline *cl,
12927 __rte_unused void *data)
12929 struct cmd_vf_tc_bw_result *res = parsed_result;
12932 int ret = -ENOTSUP;
12934 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12937 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12941 #ifdef RTE_NET_I40E
12942 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12950 fprintf(stderr, "invalid vf_id %d or bandwidth\n", res->vf_id);
12953 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12956 fprintf(stderr, "function not implemented\n");
12959 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12963 static cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12964 .f = cmd_vf_tc_min_bw_parsed,
12966 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12967 " <bw1, bw2, ...>",
12969 (void *)&cmd_vf_tc_bw_set,
12970 (void *)&cmd_vf_tc_bw_vf,
12971 (void *)&cmd_vf_tc_bw_tc,
12972 (void *)&cmd_vf_tc_bw_tx,
12973 (void *)&cmd_vf_tc_bw_min_bw,
12974 (void *)&cmd_vf_tc_bw_port_id,
12975 (void *)&cmd_vf_tc_bw_vf_id,
12976 (void *)&cmd_vf_tc_bw_bw_list,
12982 cmd_tc_min_bw_parsed(
12983 void *parsed_result,
12984 __rte_unused struct cmdline *cl,
12985 __rte_unused void *data)
12987 struct cmd_vf_tc_bw_result *res = parsed_result;
12988 struct rte_port *port;
12991 int ret = -ENOTSUP;
12993 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12996 port = &ports[res->port_id];
12997 /** Check if the port is not started **/
12998 if (port->port_status != RTE_PORT_STOPPED) {
12999 fprintf(stderr, "Please stop port %d first\n", res->port_id);
13003 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13007 #ifdef RTE_NET_IXGBE
13008 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
13015 fprintf(stderr, "invalid bandwidth\n");
13018 fprintf(stderr, "invalid port_id %d\n", res->port_id);
13021 fprintf(stderr, "function not implemented\n");
13024 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
13028 static cmdline_parse_inst_t cmd_tc_min_bw = {
13029 .f = cmd_tc_min_bw_parsed,
13031 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
13033 (void *)&cmd_vf_tc_bw_set,
13034 (void *)&cmd_vf_tc_bw_tc,
13035 (void *)&cmd_vf_tc_bw_tx,
13036 (void *)&cmd_vf_tc_bw_min_bw,
13037 (void *)&cmd_vf_tc_bw_port_id,
13038 (void *)&cmd_vf_tc_bw_bw_list,
13043 /* TC max bandwidth setting */
13045 cmd_vf_tc_max_bw_parsed(
13046 void *parsed_result,
13047 __rte_unused struct cmdline *cl,
13048 __rte_unused void *data)
13050 struct cmd_vf_tc_bw_result *res = parsed_result;
13051 int ret = -ENOTSUP;
13053 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13056 #ifdef RTE_NET_I40E
13057 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
13058 res->tc_no, res->bw);
13066 "invalid vf_id %d, tc_no %d or bandwidth %d\n",
13067 res->vf_id, res->tc_no, res->bw);
13070 fprintf(stderr, "invalid port_id %d\n", res->port_id);
13073 fprintf(stderr, "function not implemented\n");
13076 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
13080 static cmdline_parse_inst_t cmd_vf_tc_max_bw = {
13081 .f = cmd_vf_tc_max_bw_parsed,
13083 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
13086 (void *)&cmd_vf_tc_bw_set,
13087 (void *)&cmd_vf_tc_bw_vf,
13088 (void *)&cmd_vf_tc_bw_tc,
13089 (void *)&cmd_vf_tc_bw_tx,
13090 (void *)&cmd_vf_tc_bw_max_bw,
13091 (void *)&cmd_vf_tc_bw_port_id,
13092 (void *)&cmd_vf_tc_bw_vf_id,
13093 (void *)&cmd_vf_tc_bw_tc_no,
13094 (void *)&cmd_vf_tc_bw_bw,
13099 /** Set VXLAN encapsulation details */
13100 struct cmd_set_vxlan_result {
13101 cmdline_fixed_string_t set;
13102 cmdline_fixed_string_t vxlan;
13103 cmdline_fixed_string_t pos_token;
13104 cmdline_fixed_string_t ip_version;
13105 uint32_t vlan_present:1;
13109 cmdline_ipaddr_t ip_src;
13110 cmdline_ipaddr_t ip_dst;
13114 struct rte_ether_addr eth_src;
13115 struct rte_ether_addr eth_dst;
13118 static cmdline_parse_token_string_t cmd_set_vxlan_set =
13119 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
13120 static cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
13121 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
13122 static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
13123 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
13125 static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
13126 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
13127 "vxlan-with-vlan");
13128 static cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
13129 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13131 static cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
13132 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
13134 static cmdline_parse_token_string_t cmd_set_vxlan_vni =
13135 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13137 static cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
13138 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
13139 static cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
13140 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13142 static cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
13143 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
13144 static cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
13145 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13147 static cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
13148 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
13149 static cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
13150 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13152 static cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
13153 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
13154 static cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
13155 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13157 static cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
13158 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
13159 static cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
13160 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13162 static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
13163 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
13164 static cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
13165 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13167 static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
13168 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
13169 static cmdline_parse_token_string_t cmd_set_vxlan_vlan =
13170 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13172 static cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
13173 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
13174 static cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
13175 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13177 static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
13178 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
13179 static cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
13180 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13182 static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
13183 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
13185 static void cmd_set_vxlan_parsed(void *parsed_result,
13186 __rte_unused struct cmdline *cl,
13187 __rte_unused void *data)
13189 struct cmd_set_vxlan_result *res = parsed_result;
13194 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
13197 vxlan_encap_conf.select_tos_ttl = 0;
13198 if (strcmp(res->vxlan, "vxlan") == 0)
13199 vxlan_encap_conf.select_vlan = 0;
13200 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
13201 vxlan_encap_conf.select_vlan = 1;
13202 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
13203 vxlan_encap_conf.select_vlan = 0;
13204 vxlan_encap_conf.select_tos_ttl = 1;
13206 if (strcmp(res->ip_version, "ipv4") == 0)
13207 vxlan_encap_conf.select_ipv4 = 1;
13208 else if (strcmp(res->ip_version, "ipv6") == 0)
13209 vxlan_encap_conf.select_ipv4 = 0;
13212 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
13213 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13214 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13215 vxlan_encap_conf.ip_tos = res->tos;
13216 vxlan_encap_conf.ip_ttl = res->ttl;
13217 if (vxlan_encap_conf.select_ipv4) {
13218 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
13219 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
13221 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
13222 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
13224 if (vxlan_encap_conf.select_vlan)
13225 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13226 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
13227 RTE_ETHER_ADDR_LEN);
13228 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13229 RTE_ETHER_ADDR_LEN);
13232 static cmdline_parse_inst_t cmd_set_vxlan = {
13233 .f = cmd_set_vxlan_parsed,
13235 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
13236 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
13237 " eth-src <eth-src> eth-dst <eth-dst>",
13239 (void *)&cmd_set_vxlan_set,
13240 (void *)&cmd_set_vxlan_vxlan,
13241 (void *)&cmd_set_vxlan_ip_version,
13242 (void *)&cmd_set_vxlan_ip_version_value,
13243 (void *)&cmd_set_vxlan_vni,
13244 (void *)&cmd_set_vxlan_vni_value,
13245 (void *)&cmd_set_vxlan_udp_src,
13246 (void *)&cmd_set_vxlan_udp_src_value,
13247 (void *)&cmd_set_vxlan_udp_dst,
13248 (void *)&cmd_set_vxlan_udp_dst_value,
13249 (void *)&cmd_set_vxlan_ip_src,
13250 (void *)&cmd_set_vxlan_ip_src_value,
13251 (void *)&cmd_set_vxlan_ip_dst,
13252 (void *)&cmd_set_vxlan_ip_dst_value,
13253 (void *)&cmd_set_vxlan_eth_src,
13254 (void *)&cmd_set_vxlan_eth_src_value,
13255 (void *)&cmd_set_vxlan_eth_dst,
13256 (void *)&cmd_set_vxlan_eth_dst_value,
13261 static cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
13262 .f = cmd_set_vxlan_parsed,
13264 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
13265 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
13266 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13267 " eth-dst <eth-dst>",
13269 (void *)&cmd_set_vxlan_set,
13270 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
13271 (void *)&cmd_set_vxlan_ip_version,
13272 (void *)&cmd_set_vxlan_ip_version_value,
13273 (void *)&cmd_set_vxlan_vni,
13274 (void *)&cmd_set_vxlan_vni_value,
13275 (void *)&cmd_set_vxlan_udp_src,
13276 (void *)&cmd_set_vxlan_udp_src_value,
13277 (void *)&cmd_set_vxlan_udp_dst,
13278 (void *)&cmd_set_vxlan_udp_dst_value,
13279 (void *)&cmd_set_vxlan_ip_tos,
13280 (void *)&cmd_set_vxlan_ip_tos_value,
13281 (void *)&cmd_set_vxlan_ip_ttl,
13282 (void *)&cmd_set_vxlan_ip_ttl_value,
13283 (void *)&cmd_set_vxlan_ip_src,
13284 (void *)&cmd_set_vxlan_ip_src_value,
13285 (void *)&cmd_set_vxlan_ip_dst,
13286 (void *)&cmd_set_vxlan_ip_dst_value,
13287 (void *)&cmd_set_vxlan_eth_src,
13288 (void *)&cmd_set_vxlan_eth_src_value,
13289 (void *)&cmd_set_vxlan_eth_dst,
13290 (void *)&cmd_set_vxlan_eth_dst_value,
13295 static cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
13296 .f = cmd_set_vxlan_parsed,
13298 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
13299 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
13300 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
13303 (void *)&cmd_set_vxlan_set,
13304 (void *)&cmd_set_vxlan_vxlan_with_vlan,
13305 (void *)&cmd_set_vxlan_ip_version,
13306 (void *)&cmd_set_vxlan_ip_version_value,
13307 (void *)&cmd_set_vxlan_vni,
13308 (void *)&cmd_set_vxlan_vni_value,
13309 (void *)&cmd_set_vxlan_udp_src,
13310 (void *)&cmd_set_vxlan_udp_src_value,
13311 (void *)&cmd_set_vxlan_udp_dst,
13312 (void *)&cmd_set_vxlan_udp_dst_value,
13313 (void *)&cmd_set_vxlan_ip_src,
13314 (void *)&cmd_set_vxlan_ip_src_value,
13315 (void *)&cmd_set_vxlan_ip_dst,
13316 (void *)&cmd_set_vxlan_ip_dst_value,
13317 (void *)&cmd_set_vxlan_vlan,
13318 (void *)&cmd_set_vxlan_vlan_value,
13319 (void *)&cmd_set_vxlan_eth_src,
13320 (void *)&cmd_set_vxlan_eth_src_value,
13321 (void *)&cmd_set_vxlan_eth_dst,
13322 (void *)&cmd_set_vxlan_eth_dst_value,
13327 /** Set NVGRE encapsulation details */
13328 struct cmd_set_nvgre_result {
13329 cmdline_fixed_string_t set;
13330 cmdline_fixed_string_t nvgre;
13331 cmdline_fixed_string_t pos_token;
13332 cmdline_fixed_string_t ip_version;
13334 cmdline_ipaddr_t ip_src;
13335 cmdline_ipaddr_t ip_dst;
13337 struct rte_ether_addr eth_src;
13338 struct rte_ether_addr eth_dst;
13341 static cmdline_parse_token_string_t cmd_set_nvgre_set =
13342 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
13343 static cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
13344 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
13345 static cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
13346 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
13347 "nvgre-with-vlan");
13348 static cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
13349 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13351 static cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
13352 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
13354 static cmdline_parse_token_string_t cmd_set_nvgre_tni =
13355 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13357 static cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
13358 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
13359 static cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
13360 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13362 static cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
13363 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
13364 static cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
13365 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13367 static cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
13368 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
13369 static cmdline_parse_token_string_t cmd_set_nvgre_vlan =
13370 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13372 static cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
13373 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
13374 static cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
13375 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13377 static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
13378 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
13379 static cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
13380 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13382 static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
13383 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
13385 static void cmd_set_nvgre_parsed(void *parsed_result,
13386 __rte_unused struct cmdline *cl,
13387 __rte_unused void *data)
13389 struct cmd_set_nvgre_result *res = parsed_result;
13391 uint32_t nvgre_tni;
13394 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
13397 if (strcmp(res->nvgre, "nvgre") == 0)
13398 nvgre_encap_conf.select_vlan = 0;
13399 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
13400 nvgre_encap_conf.select_vlan = 1;
13401 if (strcmp(res->ip_version, "ipv4") == 0)
13402 nvgre_encap_conf.select_ipv4 = 1;
13403 else if (strcmp(res->ip_version, "ipv6") == 0)
13404 nvgre_encap_conf.select_ipv4 = 0;
13407 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
13408 if (nvgre_encap_conf.select_ipv4) {
13409 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
13410 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
13412 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
13413 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
13415 if (nvgre_encap_conf.select_vlan)
13416 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13417 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
13418 RTE_ETHER_ADDR_LEN);
13419 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13420 RTE_ETHER_ADDR_LEN);
13423 static cmdline_parse_inst_t cmd_set_nvgre = {
13424 .f = cmd_set_nvgre_parsed,
13426 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
13427 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13428 " eth-dst <eth-dst>",
13430 (void *)&cmd_set_nvgre_set,
13431 (void *)&cmd_set_nvgre_nvgre,
13432 (void *)&cmd_set_nvgre_ip_version,
13433 (void *)&cmd_set_nvgre_ip_version_value,
13434 (void *)&cmd_set_nvgre_tni,
13435 (void *)&cmd_set_nvgre_tni_value,
13436 (void *)&cmd_set_nvgre_ip_src,
13437 (void *)&cmd_set_nvgre_ip_src_value,
13438 (void *)&cmd_set_nvgre_ip_dst,
13439 (void *)&cmd_set_nvgre_ip_dst_value,
13440 (void *)&cmd_set_nvgre_eth_src,
13441 (void *)&cmd_set_nvgre_eth_src_value,
13442 (void *)&cmd_set_nvgre_eth_dst,
13443 (void *)&cmd_set_nvgre_eth_dst_value,
13448 static cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
13449 .f = cmd_set_nvgre_parsed,
13451 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
13452 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13453 " eth-src <eth-src> eth-dst <eth-dst>",
13455 (void *)&cmd_set_nvgre_set,
13456 (void *)&cmd_set_nvgre_nvgre_with_vlan,
13457 (void *)&cmd_set_nvgre_ip_version,
13458 (void *)&cmd_set_nvgre_ip_version_value,
13459 (void *)&cmd_set_nvgre_tni,
13460 (void *)&cmd_set_nvgre_tni_value,
13461 (void *)&cmd_set_nvgre_ip_src,
13462 (void *)&cmd_set_nvgre_ip_src_value,
13463 (void *)&cmd_set_nvgre_ip_dst,
13464 (void *)&cmd_set_nvgre_ip_dst_value,
13465 (void *)&cmd_set_nvgre_vlan,
13466 (void *)&cmd_set_nvgre_vlan_value,
13467 (void *)&cmd_set_nvgre_eth_src,
13468 (void *)&cmd_set_nvgre_eth_src_value,
13469 (void *)&cmd_set_nvgre_eth_dst,
13470 (void *)&cmd_set_nvgre_eth_dst_value,
13475 /** Set L2 encapsulation details */
13476 struct cmd_set_l2_encap_result {
13477 cmdline_fixed_string_t set;
13478 cmdline_fixed_string_t l2_encap;
13479 cmdline_fixed_string_t pos_token;
13480 cmdline_fixed_string_t ip_version;
13481 uint32_t vlan_present:1;
13483 struct rte_ether_addr eth_src;
13484 struct rte_ether_addr eth_dst;
13487 static cmdline_parse_token_string_t cmd_set_l2_encap_set =
13488 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13489 static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13490 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13491 static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13492 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13493 "l2_encap-with-vlan");
13494 static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13495 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13497 static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13498 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13500 static cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13501 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13503 static cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13504 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13505 static cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13506 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13508 static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13509 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13510 static cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13511 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13513 static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13514 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13516 static void cmd_set_l2_encap_parsed(void *parsed_result,
13517 __rte_unused struct cmdline *cl,
13518 __rte_unused void *data)
13520 struct cmd_set_l2_encap_result *res = parsed_result;
13522 if (strcmp(res->l2_encap, "l2_encap") == 0)
13523 l2_encap_conf.select_vlan = 0;
13524 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13525 l2_encap_conf.select_vlan = 1;
13526 if (strcmp(res->ip_version, "ipv4") == 0)
13527 l2_encap_conf.select_ipv4 = 1;
13528 else if (strcmp(res->ip_version, "ipv6") == 0)
13529 l2_encap_conf.select_ipv4 = 0;
13532 if (l2_encap_conf.select_vlan)
13533 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13534 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13535 RTE_ETHER_ADDR_LEN);
13536 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13537 RTE_ETHER_ADDR_LEN);
13540 static cmdline_parse_inst_t cmd_set_l2_encap = {
13541 .f = cmd_set_l2_encap_parsed,
13543 .help_str = "set l2_encap ip-version ipv4|ipv6"
13544 " eth-src <eth-src> eth-dst <eth-dst>",
13546 (void *)&cmd_set_l2_encap_set,
13547 (void *)&cmd_set_l2_encap_l2_encap,
13548 (void *)&cmd_set_l2_encap_ip_version,
13549 (void *)&cmd_set_l2_encap_ip_version_value,
13550 (void *)&cmd_set_l2_encap_eth_src,
13551 (void *)&cmd_set_l2_encap_eth_src_value,
13552 (void *)&cmd_set_l2_encap_eth_dst,
13553 (void *)&cmd_set_l2_encap_eth_dst_value,
13558 static cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13559 .f = cmd_set_l2_encap_parsed,
13561 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13562 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13564 (void *)&cmd_set_l2_encap_set,
13565 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13566 (void *)&cmd_set_l2_encap_ip_version,
13567 (void *)&cmd_set_l2_encap_ip_version_value,
13568 (void *)&cmd_set_l2_encap_vlan,
13569 (void *)&cmd_set_l2_encap_vlan_value,
13570 (void *)&cmd_set_l2_encap_eth_src,
13571 (void *)&cmd_set_l2_encap_eth_src_value,
13572 (void *)&cmd_set_l2_encap_eth_dst,
13573 (void *)&cmd_set_l2_encap_eth_dst_value,
13578 /** Set L2 decapsulation details */
13579 struct cmd_set_l2_decap_result {
13580 cmdline_fixed_string_t set;
13581 cmdline_fixed_string_t l2_decap;
13582 cmdline_fixed_string_t pos_token;
13583 uint32_t vlan_present:1;
13586 static cmdline_parse_token_string_t cmd_set_l2_decap_set =
13587 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13588 static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13589 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13591 static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13592 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13593 "l2_decap-with-vlan");
13595 static void cmd_set_l2_decap_parsed(void *parsed_result,
13596 __rte_unused struct cmdline *cl,
13597 __rte_unused void *data)
13599 struct cmd_set_l2_decap_result *res = parsed_result;
13601 if (strcmp(res->l2_decap, "l2_decap") == 0)
13602 l2_decap_conf.select_vlan = 0;
13603 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13604 l2_decap_conf.select_vlan = 1;
13607 static cmdline_parse_inst_t cmd_set_l2_decap = {
13608 .f = cmd_set_l2_decap_parsed,
13610 .help_str = "set l2_decap",
13612 (void *)&cmd_set_l2_decap_set,
13613 (void *)&cmd_set_l2_decap_l2_decap,
13618 static cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13619 .f = cmd_set_l2_decap_parsed,
13621 .help_str = "set l2_decap-with-vlan",
13623 (void *)&cmd_set_l2_decap_set,
13624 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13629 /** Set MPLSoGRE encapsulation details */
13630 struct cmd_set_mplsogre_encap_result {
13631 cmdline_fixed_string_t set;
13632 cmdline_fixed_string_t mplsogre;
13633 cmdline_fixed_string_t pos_token;
13634 cmdline_fixed_string_t ip_version;
13635 uint32_t vlan_present:1;
13637 cmdline_ipaddr_t ip_src;
13638 cmdline_ipaddr_t ip_dst;
13640 struct rte_ether_addr eth_src;
13641 struct rte_ether_addr eth_dst;
13644 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13645 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13647 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13648 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13650 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13651 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13652 mplsogre, "mplsogre_encap-with-vlan");
13653 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13654 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13655 pos_token, "ip-version");
13656 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13657 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13658 ip_version, "ipv4#ipv6");
13659 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13660 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13661 pos_token, "label");
13662 static cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13663 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13665 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13666 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13667 pos_token, "ip-src");
13668 static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13669 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13670 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13671 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13672 pos_token, "ip-dst");
13673 static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13674 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13675 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13676 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13677 pos_token, "vlan-tci");
13678 static cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13679 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13681 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13682 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13683 pos_token, "eth-src");
13684 static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13685 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13687 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13688 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13689 pos_token, "eth-dst");
13690 static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13691 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13694 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13695 __rte_unused struct cmdline *cl,
13696 __rte_unused void *data)
13698 struct cmd_set_mplsogre_encap_result *res = parsed_result;
13700 uint32_t mplsogre_label;
13703 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13706 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13707 mplsogre_encap_conf.select_vlan = 0;
13708 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13709 mplsogre_encap_conf.select_vlan = 1;
13710 if (strcmp(res->ip_version, "ipv4") == 0)
13711 mplsogre_encap_conf.select_ipv4 = 1;
13712 else if (strcmp(res->ip_version, "ipv6") == 0)
13713 mplsogre_encap_conf.select_ipv4 = 0;
13716 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13717 if (mplsogre_encap_conf.select_ipv4) {
13718 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13719 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13721 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13722 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13724 if (mplsogre_encap_conf.select_vlan)
13725 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13726 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13727 RTE_ETHER_ADDR_LEN);
13728 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13729 RTE_ETHER_ADDR_LEN);
13732 static cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13733 .f = cmd_set_mplsogre_encap_parsed,
13735 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13736 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13737 " eth-dst <eth-dst>",
13739 (void *)&cmd_set_mplsogre_encap_set,
13740 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13741 (void *)&cmd_set_mplsogre_encap_ip_version,
13742 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13743 (void *)&cmd_set_mplsogre_encap_label,
13744 (void *)&cmd_set_mplsogre_encap_label_value,
13745 (void *)&cmd_set_mplsogre_encap_ip_src,
13746 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13747 (void *)&cmd_set_mplsogre_encap_ip_dst,
13748 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13749 (void *)&cmd_set_mplsogre_encap_eth_src,
13750 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13751 (void *)&cmd_set_mplsogre_encap_eth_dst,
13752 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13757 static cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13758 .f = cmd_set_mplsogre_encap_parsed,
13760 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13761 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
13762 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13764 (void *)&cmd_set_mplsogre_encap_set,
13765 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13766 (void *)&cmd_set_mplsogre_encap_ip_version,
13767 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13768 (void *)&cmd_set_mplsogre_encap_label,
13769 (void *)&cmd_set_mplsogre_encap_label_value,
13770 (void *)&cmd_set_mplsogre_encap_ip_src,
13771 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13772 (void *)&cmd_set_mplsogre_encap_ip_dst,
13773 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13774 (void *)&cmd_set_mplsogre_encap_vlan,
13775 (void *)&cmd_set_mplsogre_encap_vlan_value,
13776 (void *)&cmd_set_mplsogre_encap_eth_src,
13777 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13778 (void *)&cmd_set_mplsogre_encap_eth_dst,
13779 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13784 /** Set MPLSoGRE decapsulation details */
13785 struct cmd_set_mplsogre_decap_result {
13786 cmdline_fixed_string_t set;
13787 cmdline_fixed_string_t mplsogre;
13788 cmdline_fixed_string_t pos_token;
13789 cmdline_fixed_string_t ip_version;
13790 uint32_t vlan_present:1;
13793 static cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13794 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13796 static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13797 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13799 static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13800 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13801 mplsogre, "mplsogre_decap-with-vlan");
13802 static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13803 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13804 pos_token, "ip-version");
13805 static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13806 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13807 ip_version, "ipv4#ipv6");
13809 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13810 __rte_unused struct cmdline *cl,
13811 __rte_unused void *data)
13813 struct cmd_set_mplsogre_decap_result *res = parsed_result;
13815 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13816 mplsogre_decap_conf.select_vlan = 0;
13817 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13818 mplsogre_decap_conf.select_vlan = 1;
13819 if (strcmp(res->ip_version, "ipv4") == 0)
13820 mplsogre_decap_conf.select_ipv4 = 1;
13821 else if (strcmp(res->ip_version, "ipv6") == 0)
13822 mplsogre_decap_conf.select_ipv4 = 0;
13825 static cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13826 .f = cmd_set_mplsogre_decap_parsed,
13828 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13830 (void *)&cmd_set_mplsogre_decap_set,
13831 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13832 (void *)&cmd_set_mplsogre_decap_ip_version,
13833 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13838 static cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13839 .f = cmd_set_mplsogre_decap_parsed,
13841 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13843 (void *)&cmd_set_mplsogre_decap_set,
13844 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13845 (void *)&cmd_set_mplsogre_decap_ip_version,
13846 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13851 /** Set MPLSoUDP encapsulation details */
13852 struct cmd_set_mplsoudp_encap_result {
13853 cmdline_fixed_string_t set;
13854 cmdline_fixed_string_t mplsoudp;
13855 cmdline_fixed_string_t pos_token;
13856 cmdline_fixed_string_t ip_version;
13857 uint32_t vlan_present:1;
13861 cmdline_ipaddr_t ip_src;
13862 cmdline_ipaddr_t ip_dst;
13864 struct rte_ether_addr eth_src;
13865 struct rte_ether_addr eth_dst;
13868 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13869 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13871 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13872 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13874 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13875 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13876 mplsoudp, "mplsoudp_encap-with-vlan");
13877 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13878 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13879 pos_token, "ip-version");
13880 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13881 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13882 ip_version, "ipv4#ipv6");
13883 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13884 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13885 pos_token, "label");
13886 static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13887 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13889 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13890 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13891 pos_token, "udp-src");
13892 static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13893 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13895 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13896 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13897 pos_token, "udp-dst");
13898 static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13899 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13901 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13902 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13903 pos_token, "ip-src");
13904 static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13905 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13906 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13907 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13908 pos_token, "ip-dst");
13909 static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13910 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13911 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13912 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13913 pos_token, "vlan-tci");
13914 static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13915 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13917 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13918 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13919 pos_token, "eth-src");
13920 static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13921 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13923 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13924 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13925 pos_token, "eth-dst");
13926 static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13927 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13930 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13931 __rte_unused struct cmdline *cl,
13932 __rte_unused void *data)
13934 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13936 uint32_t mplsoudp_label;
13939 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13942 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13943 mplsoudp_encap_conf.select_vlan = 0;
13944 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13945 mplsoudp_encap_conf.select_vlan = 1;
13946 if (strcmp(res->ip_version, "ipv4") == 0)
13947 mplsoudp_encap_conf.select_ipv4 = 1;
13948 else if (strcmp(res->ip_version, "ipv6") == 0)
13949 mplsoudp_encap_conf.select_ipv4 = 0;
13952 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13953 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13954 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13955 if (mplsoudp_encap_conf.select_ipv4) {
13956 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13957 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13959 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13960 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13962 if (mplsoudp_encap_conf.select_vlan)
13963 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13964 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13965 RTE_ETHER_ADDR_LEN);
13966 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13967 RTE_ETHER_ADDR_LEN);
13970 static cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13971 .f = cmd_set_mplsoudp_encap_parsed,
13973 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13974 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13975 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13977 (void *)&cmd_set_mplsoudp_encap_set,
13978 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13979 (void *)&cmd_set_mplsoudp_encap_ip_version,
13980 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13981 (void *)&cmd_set_mplsoudp_encap_label,
13982 (void *)&cmd_set_mplsoudp_encap_label_value,
13983 (void *)&cmd_set_mplsoudp_encap_udp_src,
13984 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13985 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13986 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13987 (void *)&cmd_set_mplsoudp_encap_ip_src,
13988 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13989 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13990 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13991 (void *)&cmd_set_mplsoudp_encap_eth_src,
13992 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13993 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13994 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13999 static cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
14000 .f = cmd_set_mplsoudp_encap_parsed,
14002 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
14003 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
14004 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
14005 " eth-src <eth-src> eth-dst <eth-dst>",
14007 (void *)&cmd_set_mplsoudp_encap_set,
14008 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
14009 (void *)&cmd_set_mplsoudp_encap_ip_version,
14010 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
14011 (void *)&cmd_set_mplsoudp_encap_label,
14012 (void *)&cmd_set_mplsoudp_encap_label_value,
14013 (void *)&cmd_set_mplsoudp_encap_udp_src,
14014 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
14015 (void *)&cmd_set_mplsoudp_encap_udp_dst,
14016 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
14017 (void *)&cmd_set_mplsoudp_encap_ip_src,
14018 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
14019 (void *)&cmd_set_mplsoudp_encap_ip_dst,
14020 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
14021 (void *)&cmd_set_mplsoudp_encap_vlan,
14022 (void *)&cmd_set_mplsoudp_encap_vlan_value,
14023 (void *)&cmd_set_mplsoudp_encap_eth_src,
14024 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
14025 (void *)&cmd_set_mplsoudp_encap_eth_dst,
14026 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
14031 /** Set MPLSoUDP decapsulation details */
14032 struct cmd_set_mplsoudp_decap_result {
14033 cmdline_fixed_string_t set;
14034 cmdline_fixed_string_t mplsoudp;
14035 cmdline_fixed_string_t pos_token;
14036 cmdline_fixed_string_t ip_version;
14037 uint32_t vlan_present:1;
14040 static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
14041 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
14043 static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
14044 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
14046 static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
14047 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
14048 mplsoudp, "mplsoudp_decap-with-vlan");
14049 static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
14050 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
14051 pos_token, "ip-version");
14052 static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
14053 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
14054 ip_version, "ipv4#ipv6");
14056 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
14057 __rte_unused struct cmdline *cl,
14058 __rte_unused void *data)
14060 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
14062 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
14063 mplsoudp_decap_conf.select_vlan = 0;
14064 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
14065 mplsoudp_decap_conf.select_vlan = 1;
14066 if (strcmp(res->ip_version, "ipv4") == 0)
14067 mplsoudp_decap_conf.select_ipv4 = 1;
14068 else if (strcmp(res->ip_version, "ipv6") == 0)
14069 mplsoudp_decap_conf.select_ipv4 = 0;
14072 static cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
14073 .f = cmd_set_mplsoudp_decap_parsed,
14075 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
14077 (void *)&cmd_set_mplsoudp_decap_set,
14078 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
14079 (void *)&cmd_set_mplsoudp_decap_ip_version,
14080 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
14085 static cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
14086 .f = cmd_set_mplsoudp_decap_parsed,
14088 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
14090 (void *)&cmd_set_mplsoudp_decap_set,
14091 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
14092 (void *)&cmd_set_mplsoudp_decap_ip_version,
14093 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
14098 /** Set connection tracking object common details */
14099 struct cmd_set_conntrack_common_result {
14100 cmdline_fixed_string_t set;
14101 cmdline_fixed_string_t conntrack;
14102 cmdline_fixed_string_t common;
14103 cmdline_fixed_string_t peer;
14104 cmdline_fixed_string_t is_orig;
14105 cmdline_fixed_string_t enable;
14106 cmdline_fixed_string_t live;
14107 cmdline_fixed_string_t sack;
14108 cmdline_fixed_string_t cack;
14109 cmdline_fixed_string_t last_dir;
14110 cmdline_fixed_string_t liberal;
14111 cmdline_fixed_string_t state;
14112 cmdline_fixed_string_t max_ack_win;
14113 cmdline_fixed_string_t retrans;
14114 cmdline_fixed_string_t last_win;
14115 cmdline_fixed_string_t last_seq;
14116 cmdline_fixed_string_t last_ack;
14117 cmdline_fixed_string_t last_end;
14118 cmdline_fixed_string_t last_index;
14121 uint16_t peer_port;
14122 uint32_t is_original;
14137 static cmdline_parse_token_string_t cmd_set_conntrack_set =
14138 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14140 static cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
14141 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14142 conntrack, "conntrack");
14143 static cmdline_parse_token_string_t cmd_set_conntrack_common_com =
14144 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14146 static cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
14147 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14149 static cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
14150 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14151 peer_port, RTE_UINT16);
14152 static cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
14153 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14154 is_orig, "is_orig");
14155 static cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
14156 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14157 is_original, RTE_UINT32);
14158 static cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
14159 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14161 static cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
14162 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14164 static cmdline_parse_token_string_t cmd_set_conntrack_common_live =
14165 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14167 static cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
14168 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14169 is_live, RTE_UINT32);
14170 static cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
14171 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14173 static cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
14174 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14175 s_ack, RTE_UINT32);
14176 static cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
14177 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14179 static cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
14180 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14181 c_ack, RTE_UINT32);
14182 static cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
14183 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14184 last_dir, "last_dir");
14185 static cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
14186 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14188 static cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
14189 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14190 liberal, "liberal");
14191 static cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
14192 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14194 static cmdline_parse_token_string_t cmd_set_conntrack_common_state =
14195 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14197 static cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
14198 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14200 static cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
14201 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14202 max_ack_win, "max_ack_win");
14203 static cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
14204 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14205 factor, RTE_UINT8);
14206 static cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
14207 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14209 static cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
14210 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14211 re_num, RTE_UINT8);
14212 static cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
14213 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14214 last_win, "last_win");
14215 static cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
14216 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14218 static cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
14219 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14220 last_seq, "last_seq");
14221 static cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
14222 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14224 static cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
14225 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14226 last_ack, "last_ack");
14227 static cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
14228 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14230 static cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
14231 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14232 last_end, "last_end");
14233 static cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
14234 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14236 static cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
14237 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14238 last_index, "last_index");
14239 static cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
14240 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14243 static void cmd_set_conntrack_common_parsed(void *parsed_result,
14244 __rte_unused struct cmdline *cl,
14245 __rte_unused void *data)
14247 struct cmd_set_conntrack_common_result *res = parsed_result;
14249 /* No need to swap to big endian. */
14250 conntrack_context.peer_port = res->peer_port;
14251 conntrack_context.is_original_dir = res->is_original;
14252 conntrack_context.enable = res->en;
14253 conntrack_context.live_connection = res->is_live;
14254 conntrack_context.selective_ack = res->s_ack;
14255 conntrack_context.challenge_ack_passed = res->c_ack;
14256 conntrack_context.last_direction = res->ld;
14257 conntrack_context.liberal_mode = res->lb;
14258 conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
14259 conntrack_context.max_ack_window = res->factor;
14260 conntrack_context.retransmission_limit = res->re_num;
14261 conntrack_context.last_window = res->lw;
14262 conntrack_context.last_index =
14263 (enum rte_flow_conntrack_tcp_last_index)res->li;
14264 conntrack_context.last_seq = res->ls;
14265 conntrack_context.last_ack = res->la;
14266 conntrack_context.last_end = res->le;
14269 static cmdline_parse_inst_t cmd_set_conntrack_common = {
14270 .f = cmd_set_conntrack_common_parsed,
14272 .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
14273 " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
14274 " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
14275 " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
14276 " last_index <flag>",
14278 (void *)&cmd_set_conntrack_set,
14279 (void *)&cmd_set_conntrack_conntrack,
14280 (void *)&cmd_set_conntrack_common_com,
14281 (void *)&cmd_set_conntrack_common_peer,
14282 (void *)&cmd_set_conntrack_common_peer_value,
14283 (void *)&cmd_set_conntrack_common_is_orig,
14284 (void *)&cmd_set_conntrack_common_is_orig_value,
14285 (void *)&cmd_set_conntrack_common_enable,
14286 (void *)&cmd_set_conntrack_common_enable_value,
14287 (void *)&cmd_set_conntrack_common_live,
14288 (void *)&cmd_set_conntrack_common_live_value,
14289 (void *)&cmd_set_conntrack_common_sack,
14290 (void *)&cmd_set_conntrack_common_sack_value,
14291 (void *)&cmd_set_conntrack_common_cack,
14292 (void *)&cmd_set_conntrack_common_cack_value,
14293 (void *)&cmd_set_conntrack_common_last_dir,
14294 (void *)&cmd_set_conntrack_common_last_dir_value,
14295 (void *)&cmd_set_conntrack_common_liberal,
14296 (void *)&cmd_set_conntrack_common_liberal_value,
14297 (void *)&cmd_set_conntrack_common_state,
14298 (void *)&cmd_set_conntrack_common_state_value,
14299 (void *)&cmd_set_conntrack_common_max_ackwin,
14300 (void *)&cmd_set_conntrack_common_max_ackwin_value,
14301 (void *)&cmd_set_conntrack_common_retrans,
14302 (void *)&cmd_set_conntrack_common_retrans_value,
14303 (void *)&cmd_set_conntrack_common_last_win,
14304 (void *)&cmd_set_conntrack_common_last_win_value,
14305 (void *)&cmd_set_conntrack_common_last_seq,
14306 (void *)&cmd_set_conntrack_common_last_seq_value,
14307 (void *)&cmd_set_conntrack_common_last_ack,
14308 (void *)&cmd_set_conntrack_common_last_ack_value,
14309 (void *)&cmd_set_conntrack_common_last_end,
14310 (void *)&cmd_set_conntrack_common_last_end_value,
14311 (void *)&cmd_set_conntrack_common_last_index,
14312 (void *)&cmd_set_conntrack_common_last_index_value,
14317 /** Set connection tracking object both directions' details */
14318 struct cmd_set_conntrack_dir_result {
14319 cmdline_fixed_string_t set;
14320 cmdline_fixed_string_t conntrack;
14321 cmdline_fixed_string_t dir;
14322 cmdline_fixed_string_t scale;
14323 cmdline_fixed_string_t fin;
14324 cmdline_fixed_string_t ack_seen;
14325 cmdline_fixed_string_t unack;
14326 cmdline_fixed_string_t sent_end;
14327 cmdline_fixed_string_t reply_end;
14328 cmdline_fixed_string_t max_win;
14329 cmdline_fixed_string_t max_ack;
14340 static cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
14341 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14343 static cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
14344 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14346 static cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
14347 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14348 factor, RTE_UINT32);
14349 static cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
14350 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14352 static cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
14353 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14355 static cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
14356 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14357 ack_seen, "acked");
14358 static cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
14359 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14361 static cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
14362 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14363 unack, "unack_data");
14364 static cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
14365 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14367 static cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
14368 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14369 sent_end, "sent_end");
14370 static cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
14371 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14373 static cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
14374 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14375 reply_end, "reply_end");
14376 static cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
14377 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14379 static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
14380 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14381 max_win, "max_win");
14382 static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
14383 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14385 static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
14386 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14387 max_ack, "max_ack");
14388 static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
14389 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14392 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
14393 __rte_unused struct cmdline *cl,
14394 __rte_unused void *data)
14396 struct cmd_set_conntrack_dir_result *res = parsed_result;
14397 struct rte_flow_tcp_dir_param *dir = NULL;
14399 if (strcmp(res->dir, "orig") == 0)
14400 dir = &conntrack_context.original_dir;
14401 else if (strcmp(res->dir, "rply") == 0)
14402 dir = &conntrack_context.reply_dir;
14405 dir->scale = res->factor;
14406 dir->close_initiated = res->f;
14407 dir->last_ack_seen = res->as;
14408 dir->data_unacked = res->un;
14409 dir->sent_end = res->se;
14410 dir->reply_end = res->re;
14411 dir->max_ack = res->ma;
14412 dir->max_win = res->mw;
14415 static cmdline_parse_inst_t cmd_set_conntrack_dir = {
14416 .f = cmd_set_conntrack_dir_parsed,
14418 .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
14419 " acked <seen> unack_data <unack> sent_end <sent>"
14420 " reply_end <reply> max_win <win> max_ack <ack>",
14422 (void *)&cmd_set_conntrack_set,
14423 (void *)&cmd_set_conntrack_conntrack,
14424 (void *)&cmd_set_conntrack_dir_dir,
14425 (void *)&cmd_set_conntrack_dir_scale,
14426 (void *)&cmd_set_conntrack_dir_scale_value,
14427 (void *)&cmd_set_conntrack_dir_fin,
14428 (void *)&cmd_set_conntrack_dir_fin_value,
14429 (void *)&cmd_set_conntrack_dir_ack,
14430 (void *)&cmd_set_conntrack_dir_ack_value,
14431 (void *)&cmd_set_conntrack_dir_unack_data,
14432 (void *)&cmd_set_conntrack_dir_unack_data_value,
14433 (void *)&cmd_set_conntrack_dir_sent_end,
14434 (void *)&cmd_set_conntrack_dir_sent_end_value,
14435 (void *)&cmd_set_conntrack_dir_reply_end,
14436 (void *)&cmd_set_conntrack_dir_reply_end_value,
14437 (void *)&cmd_set_conntrack_dir_max_win,
14438 (void *)&cmd_set_conntrack_dir_max_win_value,
14439 (void *)&cmd_set_conntrack_dir_max_ack,
14440 (void *)&cmd_set_conntrack_dir_max_ack_value,
14445 /* Strict link priority scheduling mode setting */
14447 cmd_strict_link_prio_parsed(
14448 void *parsed_result,
14449 __rte_unused struct cmdline *cl,
14450 __rte_unused void *data)
14452 struct cmd_vf_tc_bw_result *res = parsed_result;
14453 int ret = -ENOTSUP;
14455 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14458 #ifdef RTE_NET_I40E
14459 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14466 fprintf(stderr, "invalid tc_bitmap 0x%x\n", res->tc_map);
14469 fprintf(stderr, "invalid port_id %d\n", res->port_id);
14472 fprintf(stderr, "function not implemented\n");
14475 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
14479 static cmdline_parse_inst_t cmd_strict_link_prio = {
14480 .f = cmd_strict_link_prio_parsed,
14482 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14484 (void *)&cmd_vf_tc_bw_set,
14485 (void *)&cmd_vf_tc_bw_tx,
14486 (void *)&cmd_vf_tc_bw_strict_link_prio,
14487 (void *)&cmd_vf_tc_bw_port_id,
14488 (void *)&cmd_vf_tc_bw_tc_map,
14493 /* Load dynamic device personalization*/
14494 struct cmd_ddp_add_result {
14495 cmdline_fixed_string_t ddp;
14496 cmdline_fixed_string_t add;
14501 static cmdline_parse_token_string_t cmd_ddp_add_ddp =
14502 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14503 static cmdline_parse_token_string_t cmd_ddp_add_add =
14504 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14505 static cmdline_parse_token_num_t cmd_ddp_add_port_id =
14506 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
14508 static cmdline_parse_token_string_t cmd_ddp_add_filepath =
14509 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14512 cmd_ddp_add_parsed(
14513 void *parsed_result,
14514 __rte_unused struct cmdline *cl,
14515 __rte_unused void *data)
14517 struct cmd_ddp_add_result *res = parsed_result;
14523 int ret = -ENOTSUP;
14525 if (!all_ports_stopped()) {
14526 fprintf(stderr, "Please stop all ports first\n");
14530 filepath = strdup(res->filepath);
14531 if (filepath == NULL) {
14532 fprintf(stderr, "Failed to allocate memory\n");
14535 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14537 buff = open_file(file_fld[0], &size);
14539 free((void *)filepath);
14543 #ifdef RTE_NET_I40E
14544 if (ret == -ENOTSUP)
14545 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14547 RTE_PMD_I40E_PKG_OP_WR_ADD);
14550 if (ret == -EEXIST)
14551 fprintf(stderr, "Profile has already existed.\n");
14553 fprintf(stderr, "Failed to load profile.\n");
14554 else if (file_num == 2)
14555 save_file(file_fld[1], buff, size);
14558 free((void *)filepath);
14561 static cmdline_parse_inst_t cmd_ddp_add = {
14562 .f = cmd_ddp_add_parsed,
14564 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14566 (void *)&cmd_ddp_add_ddp,
14567 (void *)&cmd_ddp_add_add,
14568 (void *)&cmd_ddp_add_port_id,
14569 (void *)&cmd_ddp_add_filepath,
14574 /* Delete dynamic device personalization*/
14575 struct cmd_ddp_del_result {
14576 cmdline_fixed_string_t ddp;
14577 cmdline_fixed_string_t del;
14582 static cmdline_parse_token_string_t cmd_ddp_del_ddp =
14583 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14584 static cmdline_parse_token_string_t cmd_ddp_del_del =
14585 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14586 static cmdline_parse_token_num_t cmd_ddp_del_port_id =
14587 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
14588 static cmdline_parse_token_string_t cmd_ddp_del_filepath =
14589 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14592 cmd_ddp_del_parsed(
14593 void *parsed_result,
14594 __rte_unused struct cmdline *cl,
14595 __rte_unused void *data)
14597 struct cmd_ddp_del_result *res = parsed_result;
14600 int ret = -ENOTSUP;
14602 if (!all_ports_stopped()) {
14603 fprintf(stderr, "Please stop all ports first\n");
14607 buff = open_file(res->filepath, &size);
14611 #ifdef RTE_NET_I40E
14612 if (ret == -ENOTSUP)
14613 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14615 RTE_PMD_I40E_PKG_OP_WR_DEL);
14618 if (ret == -EACCES)
14619 fprintf(stderr, "Profile does not exist.\n");
14621 fprintf(stderr, "Failed to delete profile.\n");
14626 static cmdline_parse_inst_t cmd_ddp_del = {
14627 .f = cmd_ddp_del_parsed,
14629 .help_str = "ddp del <port_id> <backup_profile_path>",
14631 (void *)&cmd_ddp_del_ddp,
14632 (void *)&cmd_ddp_del_del,
14633 (void *)&cmd_ddp_del_port_id,
14634 (void *)&cmd_ddp_del_filepath,
14639 /* Get dynamic device personalization profile info */
14640 struct cmd_ddp_info_result {
14641 cmdline_fixed_string_t ddp;
14642 cmdline_fixed_string_t get;
14643 cmdline_fixed_string_t info;
14647 static cmdline_parse_token_string_t cmd_ddp_info_ddp =
14648 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14649 static cmdline_parse_token_string_t cmd_ddp_info_get =
14650 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14651 static cmdline_parse_token_string_t cmd_ddp_info_info =
14652 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14653 static cmdline_parse_token_string_t cmd_ddp_info_filepath =
14654 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14657 cmd_ddp_info_parsed(
14658 void *parsed_result,
14659 __rte_unused struct cmdline *cl,
14660 __rte_unused void *data)
14662 struct cmd_ddp_info_result *res = parsed_result;
14665 int ret = -ENOTSUP;
14666 #ifdef RTE_NET_I40E
14669 uint32_t buff_size = 0;
14670 struct rte_pmd_i40e_profile_info info;
14671 uint32_t dev_num = 0;
14672 struct rte_pmd_i40e_ddp_device_id *devs;
14673 uint32_t proto_num = 0;
14674 struct rte_pmd_i40e_proto_info *proto = NULL;
14675 uint32_t pctype_num = 0;
14676 struct rte_pmd_i40e_ptype_info *pctype;
14677 uint32_t ptype_num = 0;
14678 struct rte_pmd_i40e_ptype_info *ptype;
14683 pkg = open_file(res->filepath, &pkg_size);
14687 #ifdef RTE_NET_I40E
14688 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14689 (uint8_t *)&info, sizeof(info),
14690 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14692 printf("Global Track id: 0x%x\n", info.track_id);
14693 printf("Global Version: %d.%d.%d.%d\n",
14694 info.version.major,
14695 info.version.minor,
14696 info.version.update,
14697 info.version.draft);
14698 printf("Global Package name: %s\n\n", info.name);
14701 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14702 (uint8_t *)&info, sizeof(info),
14703 RTE_PMD_I40E_PKG_INFO_HEADER);
14705 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14706 printf("i40e Profile Version: %d.%d.%d.%d\n",
14707 info.version.major,
14708 info.version.minor,
14709 info.version.update,
14710 info.version.draft);
14711 printf("i40e Profile name: %s\n\n", info.name);
14714 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14715 (uint8_t *)&buff_size, sizeof(buff_size),
14716 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14717 if (!ret && buff_size) {
14718 buff = (uint8_t *)malloc(buff_size);
14720 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14722 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14724 printf("Package Notes:\n%s\n\n", buff);
14729 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14730 (uint8_t *)&dev_num, sizeof(dev_num),
14731 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14732 if (!ret && dev_num) {
14733 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14734 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14736 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14737 (uint8_t *)devs, buff_size,
14738 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14740 printf("List of supported devices:\n");
14741 for (i = 0; i < dev_num; i++) {
14742 printf(" %04X:%04X %04X:%04X\n",
14743 devs[i].vendor_dev_id >> 16,
14744 devs[i].vendor_dev_id & 0xFFFF,
14745 devs[i].sub_vendor_dev_id >> 16,
14746 devs[i].sub_vendor_dev_id & 0xFFFF);
14754 /* get information about protocols and packet types */
14755 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14756 (uint8_t *)&proto_num, sizeof(proto_num),
14757 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14758 if (ret || !proto_num)
14759 goto no_print_return;
14761 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14762 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14764 goto no_print_return;
14766 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14768 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14770 printf("List of used protocols:\n");
14771 for (i = 0; i < proto_num; i++)
14772 printf(" %2u: %s\n", proto[i].proto_id,
14776 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14777 (uint8_t *)&pctype_num, sizeof(pctype_num),
14778 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14779 if (ret || !pctype_num)
14780 goto no_print_pctypes;
14782 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14783 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14785 goto no_print_pctypes;
14787 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14789 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14792 goto no_print_pctypes;
14795 printf("List of defined packet classification types:\n");
14796 for (i = 0; i < pctype_num; i++) {
14797 printf(" %2u:", pctype[i].ptype_id);
14798 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14799 proto_id = pctype[i].protocols[j];
14800 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14801 for (n = 0; n < proto_num; n++) {
14802 if (proto[n].proto_id == proto_id) {
14803 printf(" %s", proto[n].name);
14816 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14818 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14819 if (ret || !ptype_num)
14820 goto no_print_return;
14822 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14823 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14825 goto no_print_return;
14827 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14829 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14832 goto no_print_return;
14834 printf("List of defined packet types:\n");
14835 for (i = 0; i < ptype_num; i++) {
14836 printf(" %2u:", ptype[i].ptype_id);
14837 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14838 proto_id = ptype[i].protocols[j];
14839 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14840 for (n = 0; n < proto_num; n++) {
14841 if (proto[n].proto_id == proto_id) {
14842 printf(" %s", proto[n].name);
14857 if (ret == -ENOTSUP)
14858 fprintf(stderr, "Function not supported in PMD\n");
14862 static cmdline_parse_inst_t cmd_ddp_get_info = {
14863 .f = cmd_ddp_info_parsed,
14865 .help_str = "ddp get info <profile_path>",
14867 (void *)&cmd_ddp_info_ddp,
14868 (void *)&cmd_ddp_info_get,
14869 (void *)&cmd_ddp_info_info,
14870 (void *)&cmd_ddp_info_filepath,
14875 /* Get dynamic device personalization profile info list*/
14876 #define PROFILE_INFO_SIZE 48
14877 #define MAX_PROFILE_NUM 16
14879 struct cmd_ddp_get_list_result {
14880 cmdline_fixed_string_t ddp;
14881 cmdline_fixed_string_t get;
14882 cmdline_fixed_string_t list;
14886 static cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14887 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14888 static cmdline_parse_token_string_t cmd_ddp_get_list_get =
14889 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14890 static cmdline_parse_token_string_t cmd_ddp_get_list_list =
14891 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14892 static cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14893 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14897 cmd_ddp_get_list_parsed(
14898 __rte_unused void *parsed_result,
14899 __rte_unused struct cmdline *cl,
14900 __rte_unused void *data)
14902 #ifdef RTE_NET_I40E
14903 struct cmd_ddp_get_list_result *res = parsed_result;
14904 struct rte_pmd_i40e_profile_list *p_list;
14905 struct rte_pmd_i40e_profile_info *p_info;
14910 int ret = -ENOTSUP;
14912 #ifdef RTE_NET_I40E
14913 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14914 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14916 fprintf(stderr, "%s: Failed to malloc buffer\n", __func__);
14920 if (ret == -ENOTSUP)
14921 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14922 (uint8_t *)p_list, size);
14925 p_num = p_list->p_count;
14926 printf("Profile number is: %d\n\n", p_num);
14928 for (i = 0; i < p_num; i++) {
14929 p_info = &p_list->p_info[i];
14930 printf("Profile %d:\n", i);
14931 printf("Track id: 0x%x\n", p_info->track_id);
14932 printf("Version: %d.%d.%d.%d\n",
14933 p_info->version.major,
14934 p_info->version.minor,
14935 p_info->version.update,
14936 p_info->version.draft);
14937 printf("Profile name: %s\n\n", p_info->name);
14945 fprintf(stderr, "Failed to get ddp list\n");
14948 static cmdline_parse_inst_t cmd_ddp_get_list = {
14949 .f = cmd_ddp_get_list_parsed,
14951 .help_str = "ddp get list <port_id>",
14953 (void *)&cmd_ddp_get_list_ddp,
14954 (void *)&cmd_ddp_get_list_get,
14955 (void *)&cmd_ddp_get_list_list,
14956 (void *)&cmd_ddp_get_list_port_id,
14961 /* Configure input set */
14962 struct cmd_cfg_input_set_result {
14963 cmdline_fixed_string_t port;
14964 cmdline_fixed_string_t cfg;
14966 cmdline_fixed_string_t pctype;
14968 cmdline_fixed_string_t inset_type;
14969 cmdline_fixed_string_t opt;
14970 cmdline_fixed_string_t field;
14975 cmd_cfg_input_set_parsed(
14976 __rte_unused void *parsed_result,
14977 __rte_unused struct cmdline *cl,
14978 __rte_unused void *data)
14980 #ifdef RTE_NET_I40E
14981 struct cmd_cfg_input_set_result *res = parsed_result;
14982 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14983 struct rte_pmd_i40e_inset inset;
14985 int ret = -ENOTSUP;
14987 if (!all_ports_stopped()) {
14988 fprintf(stderr, "Please stop all ports first\n");
14992 #ifdef RTE_NET_I40E
14993 if (!strcmp(res->inset_type, "hash_inset"))
14994 inset_type = INSET_HASH;
14995 else if (!strcmp(res->inset_type, "fdir_inset"))
14996 inset_type = INSET_FDIR;
14997 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14998 inset_type = INSET_FDIR_FLX;
14999 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
15000 &inset, inset_type);
15002 fprintf(stderr, "Failed to get input set.\n");
15006 if (!strcmp(res->opt, "get")) {
15007 ret = rte_pmd_i40e_inset_field_get(inset.inset,
15010 printf("Field index %d is enabled.\n", res->field_idx);
15012 printf("Field index %d is disabled.\n", res->field_idx);
15014 } else if (!strcmp(res->opt, "set"))
15015 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
15017 else if (!strcmp(res->opt, "clear"))
15018 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15021 fprintf(stderr, "Failed to configure input set field.\n");
15025 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15026 &inset, inset_type);
15028 fprintf(stderr, "Failed to set input set.\n");
15033 if (ret == -ENOTSUP)
15034 fprintf(stderr, "Function not supported\n");
15037 static cmdline_parse_token_string_t cmd_cfg_input_set_port =
15038 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15040 static cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15041 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15043 static cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15044 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15045 port_id, RTE_UINT16);
15046 static cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15047 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15049 static cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15050 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15051 pctype_id, RTE_UINT8);
15052 static cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15053 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15055 "hash_inset#fdir_inset#fdir_flx_inset");
15056 static cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15057 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15058 opt, "get#set#clear");
15059 static cmdline_parse_token_string_t cmd_cfg_input_set_field =
15060 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15062 static cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15063 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15064 field_idx, RTE_UINT8);
15066 static cmdline_parse_inst_t cmd_cfg_input_set = {
15067 .f = cmd_cfg_input_set_parsed,
15069 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15070 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15072 (void *)&cmd_cfg_input_set_port,
15073 (void *)&cmd_cfg_input_set_cfg,
15074 (void *)&cmd_cfg_input_set_port_id,
15075 (void *)&cmd_cfg_input_set_pctype,
15076 (void *)&cmd_cfg_input_set_pctype_id,
15077 (void *)&cmd_cfg_input_set_inset_type,
15078 (void *)&cmd_cfg_input_set_opt,
15079 (void *)&cmd_cfg_input_set_field,
15080 (void *)&cmd_cfg_input_set_field_idx,
15085 /* Clear input set */
15086 struct cmd_clear_input_set_result {
15087 cmdline_fixed_string_t port;
15088 cmdline_fixed_string_t cfg;
15090 cmdline_fixed_string_t pctype;
15092 cmdline_fixed_string_t inset_type;
15093 cmdline_fixed_string_t clear;
15094 cmdline_fixed_string_t all;
15098 cmd_clear_input_set_parsed(
15099 __rte_unused void *parsed_result,
15100 __rte_unused struct cmdline *cl,
15101 __rte_unused void *data)
15103 #ifdef RTE_NET_I40E
15104 struct cmd_clear_input_set_result *res = parsed_result;
15105 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15106 struct rte_pmd_i40e_inset inset;
15108 int ret = -ENOTSUP;
15110 if (!all_ports_stopped()) {
15111 fprintf(stderr, "Please stop all ports first\n");
15115 #ifdef RTE_NET_I40E
15116 if (!strcmp(res->inset_type, "hash_inset"))
15117 inset_type = INSET_HASH;
15118 else if (!strcmp(res->inset_type, "fdir_inset"))
15119 inset_type = INSET_FDIR;
15120 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15121 inset_type = INSET_FDIR_FLX;
15123 memset(&inset, 0, sizeof(inset));
15125 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15126 &inset, inset_type);
15128 fprintf(stderr, "Failed to clear input set.\n");
15134 if (ret == -ENOTSUP)
15135 fprintf(stderr, "Function not supported\n");
15138 static cmdline_parse_token_string_t cmd_clear_input_set_port =
15139 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15141 static cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15142 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15144 static cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15145 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15146 port_id, RTE_UINT16);
15147 static cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15148 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15150 static cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15151 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15152 pctype_id, RTE_UINT8);
15153 static cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15154 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15156 "hash_inset#fdir_inset#fdir_flx_inset");
15157 static cmdline_parse_token_string_t cmd_clear_input_set_clear =
15158 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15160 static cmdline_parse_token_string_t cmd_clear_input_set_all =
15161 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15164 static cmdline_parse_inst_t cmd_clear_input_set = {
15165 .f = cmd_clear_input_set_parsed,
15167 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15168 "fdir_inset|fdir_flx_inset clear all",
15170 (void *)&cmd_clear_input_set_port,
15171 (void *)&cmd_clear_input_set_cfg,
15172 (void *)&cmd_clear_input_set_port_id,
15173 (void *)&cmd_clear_input_set_pctype,
15174 (void *)&cmd_clear_input_set_pctype_id,
15175 (void *)&cmd_clear_input_set_inset_type,
15176 (void *)&cmd_clear_input_set_clear,
15177 (void *)&cmd_clear_input_set_all,
15182 /* show vf stats */
15184 /* Common result structure for show vf stats */
15185 struct cmd_show_vf_stats_result {
15186 cmdline_fixed_string_t show;
15187 cmdline_fixed_string_t vf;
15188 cmdline_fixed_string_t stats;
15193 /* Common CLI fields show vf stats*/
15194 static cmdline_parse_token_string_t cmd_show_vf_stats_show =
15195 TOKEN_STRING_INITIALIZER
15196 (struct cmd_show_vf_stats_result,
15198 static cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15199 TOKEN_STRING_INITIALIZER
15200 (struct cmd_show_vf_stats_result,
15202 static cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15203 TOKEN_STRING_INITIALIZER
15204 (struct cmd_show_vf_stats_result,
15206 static cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15207 TOKEN_NUM_INITIALIZER
15208 (struct cmd_show_vf_stats_result,
15209 port_id, RTE_UINT16);
15210 static cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15211 TOKEN_NUM_INITIALIZER
15212 (struct cmd_show_vf_stats_result,
15213 vf_id, RTE_UINT16);
15216 cmd_show_vf_stats_parsed(
15217 void *parsed_result,
15218 __rte_unused struct cmdline *cl,
15219 __rte_unused void *data)
15221 struct cmd_show_vf_stats_result *res = parsed_result;
15222 struct rte_eth_stats stats;
15223 int ret = -ENOTSUP;
15224 static const char *nic_stats_border = "########################";
15226 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15229 memset(&stats, 0, sizeof(stats));
15231 #ifdef RTE_NET_I40E
15232 if (ret == -ENOTSUP)
15233 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15237 #ifdef RTE_NET_BNXT
15238 if (ret == -ENOTSUP)
15239 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15248 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15251 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15254 fprintf(stderr, "function not implemented\n");
15257 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15260 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15261 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15263 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15265 stats.ipackets, stats.imissed, stats.ibytes);
15266 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15267 printf(" RX-nombuf: %-10"PRIu64"\n",
15269 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15271 stats.opackets, stats.oerrors, stats.obytes);
15273 printf(" %s############################%s\n",
15274 nic_stats_border, nic_stats_border);
15277 static cmdline_parse_inst_t cmd_show_vf_stats = {
15278 .f = cmd_show_vf_stats_parsed,
15280 .help_str = "show vf stats <port_id> <vf_id>",
15282 (void *)&cmd_show_vf_stats_show,
15283 (void *)&cmd_show_vf_stats_vf,
15284 (void *)&cmd_show_vf_stats_stats,
15285 (void *)&cmd_show_vf_stats_port_id,
15286 (void *)&cmd_show_vf_stats_vf_id,
15291 /* clear vf stats */
15293 /* Common result structure for clear vf stats */
15294 struct cmd_clear_vf_stats_result {
15295 cmdline_fixed_string_t clear;
15296 cmdline_fixed_string_t vf;
15297 cmdline_fixed_string_t stats;
15302 /* Common CLI fields clear vf stats*/
15303 static cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15304 TOKEN_STRING_INITIALIZER
15305 (struct cmd_clear_vf_stats_result,
15307 static cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15308 TOKEN_STRING_INITIALIZER
15309 (struct cmd_clear_vf_stats_result,
15311 static cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15312 TOKEN_STRING_INITIALIZER
15313 (struct cmd_clear_vf_stats_result,
15315 static cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15316 TOKEN_NUM_INITIALIZER
15317 (struct cmd_clear_vf_stats_result,
15318 port_id, RTE_UINT16);
15319 static cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15320 TOKEN_NUM_INITIALIZER
15321 (struct cmd_clear_vf_stats_result,
15322 vf_id, RTE_UINT16);
15325 cmd_clear_vf_stats_parsed(
15326 void *parsed_result,
15327 __rte_unused struct cmdline *cl,
15328 __rte_unused void *data)
15330 struct cmd_clear_vf_stats_result *res = parsed_result;
15331 int ret = -ENOTSUP;
15333 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15336 #ifdef RTE_NET_I40E
15337 if (ret == -ENOTSUP)
15338 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15341 #ifdef RTE_NET_BNXT
15342 if (ret == -ENOTSUP)
15343 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15351 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15354 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15357 fprintf(stderr, "function not implemented\n");
15360 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15364 static cmdline_parse_inst_t cmd_clear_vf_stats = {
15365 .f = cmd_clear_vf_stats_parsed,
15367 .help_str = "clear vf stats <port_id> <vf_id>",
15369 (void *)&cmd_clear_vf_stats_clear,
15370 (void *)&cmd_clear_vf_stats_vf,
15371 (void *)&cmd_clear_vf_stats_stats,
15372 (void *)&cmd_clear_vf_stats_port_id,
15373 (void *)&cmd_clear_vf_stats_vf_id,
15378 /* port config pctype mapping reset */
15380 /* Common result structure for port config pctype mapping reset */
15381 struct cmd_pctype_mapping_reset_result {
15382 cmdline_fixed_string_t port;
15383 cmdline_fixed_string_t config;
15385 cmdline_fixed_string_t pctype;
15386 cmdline_fixed_string_t mapping;
15387 cmdline_fixed_string_t reset;
15390 /* Common CLI fields for port config pctype mapping reset*/
15391 static cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15392 TOKEN_STRING_INITIALIZER
15393 (struct cmd_pctype_mapping_reset_result,
15395 static cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15396 TOKEN_STRING_INITIALIZER
15397 (struct cmd_pctype_mapping_reset_result,
15399 static cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15400 TOKEN_NUM_INITIALIZER
15401 (struct cmd_pctype_mapping_reset_result,
15402 port_id, RTE_UINT16);
15403 static cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15404 TOKEN_STRING_INITIALIZER
15405 (struct cmd_pctype_mapping_reset_result,
15407 static cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15408 TOKEN_STRING_INITIALIZER
15409 (struct cmd_pctype_mapping_reset_result,
15410 mapping, "mapping");
15411 static cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15412 TOKEN_STRING_INITIALIZER
15413 (struct cmd_pctype_mapping_reset_result,
15417 cmd_pctype_mapping_reset_parsed(
15418 void *parsed_result,
15419 __rte_unused struct cmdline *cl,
15420 __rte_unused void *data)
15422 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15423 int ret = -ENOTSUP;
15425 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15428 #ifdef RTE_NET_I40E
15429 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15436 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15439 fprintf(stderr, "function not implemented\n");
15442 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15446 static cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15447 .f = cmd_pctype_mapping_reset_parsed,
15449 .help_str = "port config <port_id> pctype mapping reset",
15451 (void *)&cmd_pctype_mapping_reset_port,
15452 (void *)&cmd_pctype_mapping_reset_config,
15453 (void *)&cmd_pctype_mapping_reset_port_id,
15454 (void *)&cmd_pctype_mapping_reset_pctype,
15455 (void *)&cmd_pctype_mapping_reset_mapping,
15456 (void *)&cmd_pctype_mapping_reset_reset,
15461 /* show port pctype mapping */
15463 /* Common result structure for show port pctype mapping */
15464 struct cmd_pctype_mapping_get_result {
15465 cmdline_fixed_string_t show;
15466 cmdline_fixed_string_t port;
15468 cmdline_fixed_string_t pctype;
15469 cmdline_fixed_string_t mapping;
15472 /* Common CLI fields for pctype mapping get */
15473 static cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15474 TOKEN_STRING_INITIALIZER
15475 (struct cmd_pctype_mapping_get_result,
15477 static cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15478 TOKEN_STRING_INITIALIZER
15479 (struct cmd_pctype_mapping_get_result,
15481 static cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15482 TOKEN_NUM_INITIALIZER
15483 (struct cmd_pctype_mapping_get_result,
15484 port_id, RTE_UINT16);
15485 static cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15486 TOKEN_STRING_INITIALIZER
15487 (struct cmd_pctype_mapping_get_result,
15489 static cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15490 TOKEN_STRING_INITIALIZER
15491 (struct cmd_pctype_mapping_get_result,
15492 mapping, "mapping");
15495 cmd_pctype_mapping_get_parsed(
15496 void *parsed_result,
15497 __rte_unused struct cmdline *cl,
15498 __rte_unused void *data)
15500 struct cmd_pctype_mapping_get_result *res = parsed_result;
15501 int ret = -ENOTSUP;
15502 #ifdef RTE_NET_I40E
15503 struct rte_pmd_i40e_flow_type_mapping
15504 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15505 int i, j, first_pctype;
15508 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15511 #ifdef RTE_NET_I40E
15512 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15519 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15522 fprintf(stderr, "function not implemented\n");
15525 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15529 #ifdef RTE_NET_I40E
15530 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15531 if (mapping[i].pctype != 0ULL) {
15534 printf("pctype: ");
15535 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15536 if (mapping[i].pctype & (1ULL << j)) {
15537 printf(first_pctype ?
15538 "%02d" : ",%02d", j);
15542 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15548 static cmdline_parse_inst_t cmd_pctype_mapping_get = {
15549 .f = cmd_pctype_mapping_get_parsed,
15551 .help_str = "show port <port_id> pctype mapping",
15553 (void *)&cmd_pctype_mapping_get_show,
15554 (void *)&cmd_pctype_mapping_get_port,
15555 (void *)&cmd_pctype_mapping_get_port_id,
15556 (void *)&cmd_pctype_mapping_get_pctype,
15557 (void *)&cmd_pctype_mapping_get_mapping,
15562 /* port config pctype mapping update */
15564 /* Common result structure for port config pctype mapping update */
15565 struct cmd_pctype_mapping_update_result {
15566 cmdline_fixed_string_t port;
15567 cmdline_fixed_string_t config;
15569 cmdline_fixed_string_t pctype;
15570 cmdline_fixed_string_t mapping;
15571 cmdline_fixed_string_t update;
15572 cmdline_fixed_string_t pctype_list;
15573 uint16_t flow_type;
15576 /* Common CLI fields for pctype mapping update*/
15577 static cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15578 TOKEN_STRING_INITIALIZER
15579 (struct cmd_pctype_mapping_update_result,
15581 static cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15582 TOKEN_STRING_INITIALIZER
15583 (struct cmd_pctype_mapping_update_result,
15585 static cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15586 TOKEN_NUM_INITIALIZER
15587 (struct cmd_pctype_mapping_update_result,
15588 port_id, RTE_UINT16);
15589 static cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15590 TOKEN_STRING_INITIALIZER
15591 (struct cmd_pctype_mapping_update_result,
15593 static cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15594 TOKEN_STRING_INITIALIZER
15595 (struct cmd_pctype_mapping_update_result,
15596 mapping, "mapping");
15597 static cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15598 TOKEN_STRING_INITIALIZER
15599 (struct cmd_pctype_mapping_update_result,
15601 static cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15602 TOKEN_STRING_INITIALIZER
15603 (struct cmd_pctype_mapping_update_result,
15604 pctype_list, NULL);
15605 static cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15606 TOKEN_NUM_INITIALIZER
15607 (struct cmd_pctype_mapping_update_result,
15608 flow_type, RTE_UINT16);
15611 cmd_pctype_mapping_update_parsed(
15612 void *parsed_result,
15613 __rte_unused struct cmdline *cl,
15614 __rte_unused void *data)
15616 struct cmd_pctype_mapping_update_result *res = parsed_result;
15617 int ret = -ENOTSUP;
15618 #ifdef RTE_NET_I40E
15619 struct rte_pmd_i40e_flow_type_mapping mapping;
15621 unsigned int nb_item;
15622 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15625 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15628 #ifdef RTE_NET_I40E
15629 nb_item = parse_item_list(res->pctype_list, "pctypes",
15630 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15631 mapping.flow_type = res->flow_type;
15632 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15633 mapping.pctype |= (1ULL << pctype_list[i]);
15634 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15644 fprintf(stderr, "invalid pctype or flow type\n");
15647 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15650 fprintf(stderr, "function not implemented\n");
15653 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15657 static cmdline_parse_inst_t cmd_pctype_mapping_update = {
15658 .f = cmd_pctype_mapping_update_parsed,
15660 .help_str = "port config <port_id> pctype mapping update"
15661 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15663 (void *)&cmd_pctype_mapping_update_port,
15664 (void *)&cmd_pctype_mapping_update_config,
15665 (void *)&cmd_pctype_mapping_update_port_id,
15666 (void *)&cmd_pctype_mapping_update_pctype,
15667 (void *)&cmd_pctype_mapping_update_mapping,
15668 (void *)&cmd_pctype_mapping_update_update,
15669 (void *)&cmd_pctype_mapping_update_pc_type,
15670 (void *)&cmd_pctype_mapping_update_flow_type,
15675 /* ptype mapping get */
15677 /* Common result structure for ptype mapping get */
15678 struct cmd_ptype_mapping_get_result {
15679 cmdline_fixed_string_t ptype;
15680 cmdline_fixed_string_t mapping;
15681 cmdline_fixed_string_t get;
15683 uint8_t valid_only;
15686 /* Common CLI fields for ptype mapping get */
15687 static cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15688 TOKEN_STRING_INITIALIZER
15689 (struct cmd_ptype_mapping_get_result,
15691 static cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15692 TOKEN_STRING_INITIALIZER
15693 (struct cmd_ptype_mapping_get_result,
15694 mapping, "mapping");
15695 static cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15696 TOKEN_STRING_INITIALIZER
15697 (struct cmd_ptype_mapping_get_result,
15699 static cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15700 TOKEN_NUM_INITIALIZER
15701 (struct cmd_ptype_mapping_get_result,
15702 port_id, RTE_UINT16);
15703 static cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15704 TOKEN_NUM_INITIALIZER
15705 (struct cmd_ptype_mapping_get_result,
15706 valid_only, RTE_UINT8);
15709 cmd_ptype_mapping_get_parsed(
15710 void *parsed_result,
15711 __rte_unused struct cmdline *cl,
15712 __rte_unused void *data)
15714 struct cmd_ptype_mapping_get_result *res = parsed_result;
15715 int ret = -ENOTSUP;
15716 #ifdef RTE_NET_I40E
15717 int max_ptype_num = 256;
15718 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15723 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15726 #ifdef RTE_NET_I40E
15727 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15738 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15741 fprintf(stderr, "function not implemented\n");
15744 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15747 #ifdef RTE_NET_I40E
15749 for (i = 0; i < count; i++)
15750 printf("%3d\t0x%08x\n",
15751 mapping[i].hw_ptype, mapping[i].sw_ptype);
15756 static cmdline_parse_inst_t cmd_ptype_mapping_get = {
15757 .f = cmd_ptype_mapping_get_parsed,
15759 .help_str = "ptype mapping get <port_id> <valid_only>",
15761 (void *)&cmd_ptype_mapping_get_ptype,
15762 (void *)&cmd_ptype_mapping_get_mapping,
15763 (void *)&cmd_ptype_mapping_get_get,
15764 (void *)&cmd_ptype_mapping_get_port_id,
15765 (void *)&cmd_ptype_mapping_get_valid_only,
15770 /* ptype mapping replace */
15772 /* Common result structure for ptype mapping replace */
15773 struct cmd_ptype_mapping_replace_result {
15774 cmdline_fixed_string_t ptype;
15775 cmdline_fixed_string_t mapping;
15776 cmdline_fixed_string_t replace;
15783 /* Common CLI fields for ptype mapping replace */
15784 static cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15785 TOKEN_STRING_INITIALIZER
15786 (struct cmd_ptype_mapping_replace_result,
15788 static cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15789 TOKEN_STRING_INITIALIZER
15790 (struct cmd_ptype_mapping_replace_result,
15791 mapping, "mapping");
15792 static cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15793 TOKEN_STRING_INITIALIZER
15794 (struct cmd_ptype_mapping_replace_result,
15795 replace, "replace");
15796 static cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15797 TOKEN_NUM_INITIALIZER
15798 (struct cmd_ptype_mapping_replace_result,
15799 port_id, RTE_UINT16);
15800 static cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15801 TOKEN_NUM_INITIALIZER
15802 (struct cmd_ptype_mapping_replace_result,
15803 target, RTE_UINT32);
15804 static cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15805 TOKEN_NUM_INITIALIZER
15806 (struct cmd_ptype_mapping_replace_result,
15808 static cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15809 TOKEN_NUM_INITIALIZER
15810 (struct cmd_ptype_mapping_replace_result,
15811 pkt_type, RTE_UINT32);
15814 cmd_ptype_mapping_replace_parsed(
15815 void *parsed_result,
15816 __rte_unused struct cmdline *cl,
15817 __rte_unused void *data)
15819 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15820 int ret = -ENOTSUP;
15822 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15825 #ifdef RTE_NET_I40E
15826 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15836 fprintf(stderr, "invalid ptype 0x%8x or 0x%8x\n",
15837 res->target, res->pkt_type);
15840 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15843 fprintf(stderr, "function not implemented\n");
15846 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15850 static cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15851 .f = cmd_ptype_mapping_replace_parsed,
15854 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15856 (void *)&cmd_ptype_mapping_replace_ptype,
15857 (void *)&cmd_ptype_mapping_replace_mapping,
15858 (void *)&cmd_ptype_mapping_replace_replace,
15859 (void *)&cmd_ptype_mapping_replace_port_id,
15860 (void *)&cmd_ptype_mapping_replace_target,
15861 (void *)&cmd_ptype_mapping_replace_mask,
15862 (void *)&cmd_ptype_mapping_replace_pkt_type,
15867 /* ptype mapping reset */
15869 /* Common result structure for ptype mapping reset */
15870 struct cmd_ptype_mapping_reset_result {
15871 cmdline_fixed_string_t ptype;
15872 cmdline_fixed_string_t mapping;
15873 cmdline_fixed_string_t reset;
15877 /* Common CLI fields for ptype mapping reset*/
15878 static cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15879 TOKEN_STRING_INITIALIZER
15880 (struct cmd_ptype_mapping_reset_result,
15882 static cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15883 TOKEN_STRING_INITIALIZER
15884 (struct cmd_ptype_mapping_reset_result,
15885 mapping, "mapping");
15886 static cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15887 TOKEN_STRING_INITIALIZER
15888 (struct cmd_ptype_mapping_reset_result,
15890 static cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15891 TOKEN_NUM_INITIALIZER
15892 (struct cmd_ptype_mapping_reset_result,
15893 port_id, RTE_UINT16);
15896 cmd_ptype_mapping_reset_parsed(
15897 void *parsed_result,
15898 __rte_unused struct cmdline *cl,
15899 __rte_unused void *data)
15901 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15902 int ret = -ENOTSUP;
15904 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15907 #ifdef RTE_NET_I40E
15908 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15915 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15918 fprintf(stderr, "function not implemented\n");
15921 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15925 static cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15926 .f = cmd_ptype_mapping_reset_parsed,
15928 .help_str = "ptype mapping reset <port_id>",
15930 (void *)&cmd_ptype_mapping_reset_ptype,
15931 (void *)&cmd_ptype_mapping_reset_mapping,
15932 (void *)&cmd_ptype_mapping_reset_reset,
15933 (void *)&cmd_ptype_mapping_reset_port_id,
15938 /* ptype mapping update */
15940 /* Common result structure for ptype mapping update */
15941 struct cmd_ptype_mapping_update_result {
15942 cmdline_fixed_string_t ptype;
15943 cmdline_fixed_string_t mapping;
15944 cmdline_fixed_string_t reset;
15950 /* Common CLI fields for ptype mapping update*/
15951 static cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15952 TOKEN_STRING_INITIALIZER
15953 (struct cmd_ptype_mapping_update_result,
15955 static cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15956 TOKEN_STRING_INITIALIZER
15957 (struct cmd_ptype_mapping_update_result,
15958 mapping, "mapping");
15959 static cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15960 TOKEN_STRING_INITIALIZER
15961 (struct cmd_ptype_mapping_update_result,
15963 static cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15964 TOKEN_NUM_INITIALIZER
15965 (struct cmd_ptype_mapping_update_result,
15966 port_id, RTE_UINT16);
15967 static cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15968 TOKEN_NUM_INITIALIZER
15969 (struct cmd_ptype_mapping_update_result,
15970 hw_ptype, RTE_UINT8);
15971 static cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15972 TOKEN_NUM_INITIALIZER
15973 (struct cmd_ptype_mapping_update_result,
15974 sw_ptype, RTE_UINT32);
15977 cmd_ptype_mapping_update_parsed(
15978 void *parsed_result,
15979 __rte_unused struct cmdline *cl,
15980 __rte_unused void *data)
15982 struct cmd_ptype_mapping_update_result *res = parsed_result;
15983 int ret = -ENOTSUP;
15984 #ifdef RTE_NET_I40E
15985 struct rte_pmd_i40e_ptype_mapping mapping;
15987 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15990 #ifdef RTE_NET_I40E
15991 mapping.hw_ptype = res->hw_ptype;
15992 mapping.sw_ptype = res->sw_ptype;
15993 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
16003 fprintf(stderr, "invalid ptype 0x%8x\n", res->sw_ptype);
16006 fprintf(stderr, "invalid port_id %d\n", res->port_id);
16009 fprintf(stderr, "function not implemented\n");
16012 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
16016 static cmdline_parse_inst_t cmd_ptype_mapping_update = {
16017 .f = cmd_ptype_mapping_update_parsed,
16019 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16021 (void *)&cmd_ptype_mapping_update_ptype,
16022 (void *)&cmd_ptype_mapping_update_mapping,
16023 (void *)&cmd_ptype_mapping_update_update,
16024 (void *)&cmd_ptype_mapping_update_port_id,
16025 (void *)&cmd_ptype_mapping_update_hw_ptype,
16026 (void *)&cmd_ptype_mapping_update_sw_ptype,
16031 /* Common result structure for file commands */
16032 struct cmd_cmdfile_result {
16033 cmdline_fixed_string_t load;
16034 cmdline_fixed_string_t filename;
16037 /* Common CLI fields for file commands */
16038 static cmdline_parse_token_string_t cmd_load_cmdfile =
16039 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16040 static cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16041 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16044 cmd_load_from_file_parsed(
16045 void *parsed_result,
16046 __rte_unused struct cmdline *cl,
16047 __rte_unused void *data)
16049 struct cmd_cmdfile_result *res = parsed_result;
16051 cmdline_read_from_file(res->filename);
16054 static cmdline_parse_inst_t cmd_load_from_file = {
16055 .f = cmd_load_from_file_parsed,
16057 .help_str = "load <filename>",
16059 (void *)&cmd_load_cmdfile,
16060 (void *)&cmd_load_cmdfile_filename,
16065 /* Get Rx offloads capabilities */
16066 struct cmd_rx_offload_get_capa_result {
16067 cmdline_fixed_string_t show;
16068 cmdline_fixed_string_t port;
16070 cmdline_fixed_string_t rx_offload;
16071 cmdline_fixed_string_t capabilities;
16074 static cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
16075 TOKEN_STRING_INITIALIZER
16076 (struct cmd_rx_offload_get_capa_result,
16078 static cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
16079 TOKEN_STRING_INITIALIZER
16080 (struct cmd_rx_offload_get_capa_result,
16082 static cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
16083 TOKEN_NUM_INITIALIZER
16084 (struct cmd_rx_offload_get_capa_result,
16085 port_id, RTE_UINT16);
16086 static cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
16087 TOKEN_STRING_INITIALIZER
16088 (struct cmd_rx_offload_get_capa_result,
16089 rx_offload, "rx_offload");
16090 static cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
16091 TOKEN_STRING_INITIALIZER
16092 (struct cmd_rx_offload_get_capa_result,
16093 capabilities, "capabilities");
16096 print_rx_offloads(uint64_t offloads)
16098 uint64_t single_offload;
16106 begin = __builtin_ctzll(offloads);
16107 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16109 single_offload = 1ULL << begin;
16110 for (bit = begin; bit < end; bit++) {
16111 if (offloads & single_offload)
16113 rte_eth_dev_rx_offload_name(single_offload));
16114 single_offload <<= 1;
16119 cmd_rx_offload_get_capa_parsed(
16120 void *parsed_result,
16121 __rte_unused struct cmdline *cl,
16122 __rte_unused void *data)
16124 struct cmd_rx_offload_get_capa_result *res = parsed_result;
16125 struct rte_eth_dev_info dev_info;
16126 portid_t port_id = res->port_id;
16127 uint64_t queue_offloads;
16128 uint64_t port_offloads;
16131 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16135 queue_offloads = dev_info.rx_queue_offload_capa;
16136 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
16138 printf("Rx Offloading Capabilities of port %d :\n", port_id);
16139 printf(" Per Queue :");
16140 print_rx_offloads(queue_offloads);
16143 printf(" Per Port :");
16144 print_rx_offloads(port_offloads);
16148 static cmdline_parse_inst_t cmd_rx_offload_get_capa = {
16149 .f = cmd_rx_offload_get_capa_parsed,
16151 .help_str = "show port <port_id> rx_offload capabilities",
16153 (void *)&cmd_rx_offload_get_capa_show,
16154 (void *)&cmd_rx_offload_get_capa_port,
16155 (void *)&cmd_rx_offload_get_capa_port_id,
16156 (void *)&cmd_rx_offload_get_capa_rx_offload,
16157 (void *)&cmd_rx_offload_get_capa_capabilities,
16162 /* Get Rx offloads configuration */
16163 struct cmd_rx_offload_get_configuration_result {
16164 cmdline_fixed_string_t show;
16165 cmdline_fixed_string_t port;
16167 cmdline_fixed_string_t rx_offload;
16168 cmdline_fixed_string_t configuration;
16171 static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
16172 TOKEN_STRING_INITIALIZER
16173 (struct cmd_rx_offload_get_configuration_result,
16175 static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
16176 TOKEN_STRING_INITIALIZER
16177 (struct cmd_rx_offload_get_configuration_result,
16179 static cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
16180 TOKEN_NUM_INITIALIZER
16181 (struct cmd_rx_offload_get_configuration_result,
16182 port_id, RTE_UINT16);
16183 static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
16184 TOKEN_STRING_INITIALIZER
16185 (struct cmd_rx_offload_get_configuration_result,
16186 rx_offload, "rx_offload");
16187 static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
16188 TOKEN_STRING_INITIALIZER
16189 (struct cmd_rx_offload_get_configuration_result,
16190 configuration, "configuration");
16193 cmd_rx_offload_get_configuration_parsed(
16194 void *parsed_result,
16195 __rte_unused struct cmdline *cl,
16196 __rte_unused void *data)
16198 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
16199 struct rte_eth_dev_info dev_info;
16200 portid_t port_id = res->port_id;
16201 struct rte_port *port = &ports[port_id];
16202 struct rte_eth_conf dev_conf;
16203 uint64_t port_offloads;
16204 uint64_t queue_offloads;
16205 uint16_t nb_rx_queues;
16209 printf("Rx Offloading Configuration of port %d :\n", port_id);
16211 ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
16215 port_offloads = dev_conf.rxmode.offloads;
16217 print_rx_offloads(port_offloads);
16220 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16224 nb_rx_queues = dev_info.nb_rx_queues;
16225 for (q = 0; q < nb_rx_queues; q++) {
16226 queue_offloads = port->rxq[q].conf.offloads;
16227 printf(" Queue[%2d] :", q);
16228 print_rx_offloads(queue_offloads);
16234 static cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
16235 .f = cmd_rx_offload_get_configuration_parsed,
16237 .help_str = "show port <port_id> rx_offload configuration",
16239 (void *)&cmd_rx_offload_get_configuration_show,
16240 (void *)&cmd_rx_offload_get_configuration_port,
16241 (void *)&cmd_rx_offload_get_configuration_port_id,
16242 (void *)&cmd_rx_offload_get_configuration_rx_offload,
16243 (void *)&cmd_rx_offload_get_configuration_configuration,
16248 /* Enable/Disable a per port offloading */
16249 struct cmd_config_per_port_rx_offload_result {
16250 cmdline_fixed_string_t port;
16251 cmdline_fixed_string_t config;
16253 cmdline_fixed_string_t rx_offload;
16254 cmdline_fixed_string_t offload;
16255 cmdline_fixed_string_t on_off;
16258 static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
16259 TOKEN_STRING_INITIALIZER
16260 (struct cmd_config_per_port_rx_offload_result,
16262 static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
16263 TOKEN_STRING_INITIALIZER
16264 (struct cmd_config_per_port_rx_offload_result,
16266 static cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
16267 TOKEN_NUM_INITIALIZER
16268 (struct cmd_config_per_port_rx_offload_result,
16269 port_id, RTE_UINT16);
16270 static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
16271 TOKEN_STRING_INITIALIZER
16272 (struct cmd_config_per_port_rx_offload_result,
16273 rx_offload, "rx_offload");
16274 static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
16275 TOKEN_STRING_INITIALIZER
16276 (struct cmd_config_per_port_rx_offload_result,
16277 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16278 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16279 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16280 "scatter#buffer_split#timestamp#security#"
16281 "keep_crc#rss_hash");
16282 static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
16283 TOKEN_STRING_INITIALIZER
16284 (struct cmd_config_per_port_rx_offload_result,
16288 search_rx_offload(const char *name)
16290 uint64_t single_offload;
16291 const char *single_name;
16295 single_offload = 1;
16296 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16297 single_name = rte_eth_dev_rx_offload_name(single_offload);
16298 if (!strcasecmp(single_name, name)) {
16302 single_offload <<= 1;
16306 return single_offload;
16312 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16313 __rte_unused struct cmdline *cl,
16314 __rte_unused void *data)
16316 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16317 portid_t port_id = res->port_id;
16318 struct rte_eth_dev_info dev_info;
16319 struct rte_port *port = &ports[port_id];
16320 uint64_t single_offload;
16321 uint16_t nb_rx_queues;
16325 if (port->port_status != RTE_PORT_STOPPED) {
16327 "Error: Can't config offload when Port %d is not stopped\n",
16332 single_offload = search_rx_offload(res->offload);
16333 if (single_offload == 0) {
16334 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16338 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16342 nb_rx_queues = dev_info.nb_rx_queues;
16343 if (!strcmp(res->on_off, "on")) {
16344 port->dev_conf.rxmode.offloads |= single_offload;
16345 for (q = 0; q < nb_rx_queues; q++)
16346 port->rxq[q].conf.offloads |= single_offload;
16348 port->dev_conf.rxmode.offloads &= ~single_offload;
16349 for (q = 0; q < nb_rx_queues; q++)
16350 port->rxq[q].conf.offloads &= ~single_offload;
16353 cmd_reconfig_device_queue(port_id, 1, 1);
16356 static cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16357 .f = cmd_config_per_port_rx_offload_parsed,
16359 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16360 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16361 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16362 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16363 "keep_crc|rss_hash on|off",
16365 (void *)&cmd_config_per_port_rx_offload_result_port,
16366 (void *)&cmd_config_per_port_rx_offload_result_config,
16367 (void *)&cmd_config_per_port_rx_offload_result_port_id,
16368 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16369 (void *)&cmd_config_per_port_rx_offload_result_offload,
16370 (void *)&cmd_config_per_port_rx_offload_result_on_off,
16375 /* Enable/Disable a per queue offloading */
16376 struct cmd_config_per_queue_rx_offload_result {
16377 cmdline_fixed_string_t port;
16379 cmdline_fixed_string_t rxq;
16381 cmdline_fixed_string_t rx_offload;
16382 cmdline_fixed_string_t offload;
16383 cmdline_fixed_string_t on_off;
16386 static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16387 TOKEN_STRING_INITIALIZER
16388 (struct cmd_config_per_queue_rx_offload_result,
16390 static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16391 TOKEN_NUM_INITIALIZER
16392 (struct cmd_config_per_queue_rx_offload_result,
16393 port_id, RTE_UINT16);
16394 static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16395 TOKEN_STRING_INITIALIZER
16396 (struct cmd_config_per_queue_rx_offload_result,
16398 static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16399 TOKEN_NUM_INITIALIZER
16400 (struct cmd_config_per_queue_rx_offload_result,
16401 queue_id, RTE_UINT16);
16402 static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16403 TOKEN_STRING_INITIALIZER
16404 (struct cmd_config_per_queue_rx_offload_result,
16405 rx_offload, "rx_offload");
16406 static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16407 TOKEN_STRING_INITIALIZER
16408 (struct cmd_config_per_queue_rx_offload_result,
16409 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16410 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16411 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16412 "scatter#buffer_split#timestamp#security#keep_crc");
16413 static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16414 TOKEN_STRING_INITIALIZER
16415 (struct cmd_config_per_queue_rx_offload_result,
16419 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16420 __rte_unused struct cmdline *cl,
16421 __rte_unused void *data)
16423 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16424 struct rte_eth_dev_info dev_info;
16425 portid_t port_id = res->port_id;
16426 uint16_t queue_id = res->queue_id;
16427 struct rte_port *port = &ports[port_id];
16428 uint64_t single_offload;
16431 if (port->port_status != RTE_PORT_STOPPED) {
16433 "Error: Can't config offload when Port %d is not stopped\n",
16438 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16442 if (queue_id >= dev_info.nb_rx_queues) {
16444 "Error: input queue_id should be 0 ... %d\n",
16445 dev_info.nb_rx_queues - 1);
16449 single_offload = search_rx_offload(res->offload);
16450 if (single_offload == 0) {
16451 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16455 if (!strcmp(res->on_off, "on"))
16456 port->rxq[queue_id].conf.offloads |= single_offload;
16458 port->rxq[queue_id].conf.offloads &= ~single_offload;
16460 cmd_reconfig_device_queue(port_id, 1, 1);
16463 static cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16464 .f = cmd_config_per_queue_rx_offload_parsed,
16466 .help_str = "port <port_id> rxq <queue_id> rx_offload "
16467 "vlan_strip|ipv4_cksum|"
16468 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16469 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16470 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16473 (void *)&cmd_config_per_queue_rx_offload_result_port,
16474 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
16475 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
16476 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16477 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16478 (void *)&cmd_config_per_queue_rx_offload_result_offload,
16479 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
16484 /* Get Tx offloads capabilities */
16485 struct cmd_tx_offload_get_capa_result {
16486 cmdline_fixed_string_t show;
16487 cmdline_fixed_string_t port;
16489 cmdline_fixed_string_t tx_offload;
16490 cmdline_fixed_string_t capabilities;
16493 static cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16494 TOKEN_STRING_INITIALIZER
16495 (struct cmd_tx_offload_get_capa_result,
16497 static cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16498 TOKEN_STRING_INITIALIZER
16499 (struct cmd_tx_offload_get_capa_result,
16501 static cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16502 TOKEN_NUM_INITIALIZER
16503 (struct cmd_tx_offload_get_capa_result,
16504 port_id, RTE_UINT16);
16505 static cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16506 TOKEN_STRING_INITIALIZER
16507 (struct cmd_tx_offload_get_capa_result,
16508 tx_offload, "tx_offload");
16509 static cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16510 TOKEN_STRING_INITIALIZER
16511 (struct cmd_tx_offload_get_capa_result,
16512 capabilities, "capabilities");
16515 print_tx_offloads(uint64_t offloads)
16517 uint64_t single_offload;
16525 begin = __builtin_ctzll(offloads);
16526 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16528 single_offload = 1ULL << begin;
16529 for (bit = begin; bit < end; bit++) {
16530 if (offloads & single_offload)
16532 rte_eth_dev_tx_offload_name(single_offload));
16533 single_offload <<= 1;
16538 cmd_tx_offload_get_capa_parsed(
16539 void *parsed_result,
16540 __rte_unused struct cmdline *cl,
16541 __rte_unused void *data)
16543 struct cmd_tx_offload_get_capa_result *res = parsed_result;
16544 struct rte_eth_dev_info dev_info;
16545 portid_t port_id = res->port_id;
16546 uint64_t queue_offloads;
16547 uint64_t port_offloads;
16550 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16554 queue_offloads = dev_info.tx_queue_offload_capa;
16555 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16557 printf("Tx Offloading Capabilities of port %d :\n", port_id);
16558 printf(" Per Queue :");
16559 print_tx_offloads(queue_offloads);
16562 printf(" Per Port :");
16563 print_tx_offloads(port_offloads);
16567 static cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16568 .f = cmd_tx_offload_get_capa_parsed,
16570 .help_str = "show port <port_id> tx_offload capabilities",
16572 (void *)&cmd_tx_offload_get_capa_show,
16573 (void *)&cmd_tx_offload_get_capa_port,
16574 (void *)&cmd_tx_offload_get_capa_port_id,
16575 (void *)&cmd_tx_offload_get_capa_tx_offload,
16576 (void *)&cmd_tx_offload_get_capa_capabilities,
16581 /* Get Tx offloads configuration */
16582 struct cmd_tx_offload_get_configuration_result {
16583 cmdline_fixed_string_t show;
16584 cmdline_fixed_string_t port;
16586 cmdline_fixed_string_t tx_offload;
16587 cmdline_fixed_string_t configuration;
16590 static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16591 TOKEN_STRING_INITIALIZER
16592 (struct cmd_tx_offload_get_configuration_result,
16594 static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16595 TOKEN_STRING_INITIALIZER
16596 (struct cmd_tx_offload_get_configuration_result,
16598 static cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16599 TOKEN_NUM_INITIALIZER
16600 (struct cmd_tx_offload_get_configuration_result,
16601 port_id, RTE_UINT16);
16602 static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16603 TOKEN_STRING_INITIALIZER
16604 (struct cmd_tx_offload_get_configuration_result,
16605 tx_offload, "tx_offload");
16606 static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16607 TOKEN_STRING_INITIALIZER
16608 (struct cmd_tx_offload_get_configuration_result,
16609 configuration, "configuration");
16612 cmd_tx_offload_get_configuration_parsed(
16613 void *parsed_result,
16614 __rte_unused struct cmdline *cl,
16615 __rte_unused void *data)
16617 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16618 struct rte_eth_dev_info dev_info;
16619 portid_t port_id = res->port_id;
16620 struct rte_port *port = &ports[port_id];
16621 struct rte_eth_conf dev_conf;
16622 uint64_t port_offloads;
16623 uint64_t queue_offloads;
16624 uint16_t nb_tx_queues;
16628 printf("Tx Offloading Configuration of port %d :\n", port_id);
16630 ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
16634 port_offloads = dev_conf.txmode.offloads;
16636 print_tx_offloads(port_offloads);
16639 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16643 nb_tx_queues = dev_info.nb_tx_queues;
16644 for (q = 0; q < nb_tx_queues; q++) {
16645 queue_offloads = port->txq[q].conf.offloads;
16646 printf(" Queue[%2d] :", q);
16647 print_tx_offloads(queue_offloads);
16653 static cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16654 .f = cmd_tx_offload_get_configuration_parsed,
16656 .help_str = "show port <port_id> tx_offload configuration",
16658 (void *)&cmd_tx_offload_get_configuration_show,
16659 (void *)&cmd_tx_offload_get_configuration_port,
16660 (void *)&cmd_tx_offload_get_configuration_port_id,
16661 (void *)&cmd_tx_offload_get_configuration_tx_offload,
16662 (void *)&cmd_tx_offload_get_configuration_configuration,
16667 /* Enable/Disable a per port offloading */
16668 struct cmd_config_per_port_tx_offload_result {
16669 cmdline_fixed_string_t port;
16670 cmdline_fixed_string_t config;
16672 cmdline_fixed_string_t tx_offload;
16673 cmdline_fixed_string_t offload;
16674 cmdline_fixed_string_t on_off;
16677 static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16678 TOKEN_STRING_INITIALIZER
16679 (struct cmd_config_per_port_tx_offload_result,
16681 static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16682 TOKEN_STRING_INITIALIZER
16683 (struct cmd_config_per_port_tx_offload_result,
16685 static cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16686 TOKEN_NUM_INITIALIZER
16687 (struct cmd_config_per_port_tx_offload_result,
16688 port_id, RTE_UINT16);
16689 static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16690 TOKEN_STRING_INITIALIZER
16691 (struct cmd_config_per_port_tx_offload_result,
16692 tx_offload, "tx_offload");
16693 static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16694 TOKEN_STRING_INITIALIZER
16695 (struct cmd_config_per_port_tx_offload_result,
16696 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16697 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16698 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16699 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16700 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16701 "send_on_timestamp");
16702 static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16703 TOKEN_STRING_INITIALIZER
16704 (struct cmd_config_per_port_tx_offload_result,
16708 search_tx_offload(const char *name)
16710 uint64_t single_offload;
16711 const char *single_name;
16715 single_offload = 1;
16716 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16717 single_name = rte_eth_dev_tx_offload_name(single_offload);
16718 if (single_name == NULL)
16720 if (!strcasecmp(single_name, name)) {
16723 } else if (!strcasecmp(single_name, "UNKNOWN"))
16725 single_offload <<= 1;
16729 return single_offload;
16735 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16736 __rte_unused struct cmdline *cl,
16737 __rte_unused void *data)
16739 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16740 portid_t port_id = res->port_id;
16741 struct rte_eth_dev_info dev_info;
16742 struct rte_port *port = &ports[port_id];
16743 uint64_t single_offload;
16744 uint16_t nb_tx_queues;
16748 if (port->port_status != RTE_PORT_STOPPED) {
16750 "Error: Can't config offload when Port %d is not stopped\n",
16755 single_offload = search_tx_offload(res->offload);
16756 if (single_offload == 0) {
16757 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16761 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16765 nb_tx_queues = dev_info.nb_tx_queues;
16766 if (!strcmp(res->on_off, "on")) {
16767 port->dev_conf.txmode.offloads |= single_offload;
16768 for (q = 0; q < nb_tx_queues; q++)
16769 port->txq[q].conf.offloads |= single_offload;
16771 port->dev_conf.txmode.offloads &= ~single_offload;
16772 for (q = 0; q < nb_tx_queues; q++)
16773 port->txq[q].conf.offloads &= ~single_offload;
16776 cmd_reconfig_device_queue(port_id, 1, 1);
16779 static cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16780 .f = cmd_config_per_port_tx_offload_parsed,
16782 .help_str = "port config <port_id> tx_offload "
16783 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16784 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16785 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16786 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16787 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16788 "send_on_timestamp on|off",
16790 (void *)&cmd_config_per_port_tx_offload_result_port,
16791 (void *)&cmd_config_per_port_tx_offload_result_config,
16792 (void *)&cmd_config_per_port_tx_offload_result_port_id,
16793 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16794 (void *)&cmd_config_per_port_tx_offload_result_offload,
16795 (void *)&cmd_config_per_port_tx_offload_result_on_off,
16800 /* Enable/Disable a per queue offloading */
16801 struct cmd_config_per_queue_tx_offload_result {
16802 cmdline_fixed_string_t port;
16804 cmdline_fixed_string_t txq;
16806 cmdline_fixed_string_t tx_offload;
16807 cmdline_fixed_string_t offload;
16808 cmdline_fixed_string_t on_off;
16811 static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16812 TOKEN_STRING_INITIALIZER
16813 (struct cmd_config_per_queue_tx_offload_result,
16815 static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16816 TOKEN_NUM_INITIALIZER
16817 (struct cmd_config_per_queue_tx_offload_result,
16818 port_id, RTE_UINT16);
16819 static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16820 TOKEN_STRING_INITIALIZER
16821 (struct cmd_config_per_queue_tx_offload_result,
16823 static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16824 TOKEN_NUM_INITIALIZER
16825 (struct cmd_config_per_queue_tx_offload_result,
16826 queue_id, RTE_UINT16);
16827 static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16828 TOKEN_STRING_INITIALIZER
16829 (struct cmd_config_per_queue_tx_offload_result,
16830 tx_offload, "tx_offload");
16831 static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16832 TOKEN_STRING_INITIALIZER
16833 (struct cmd_config_per_queue_tx_offload_result,
16834 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16835 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16836 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16837 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16838 "mt_lockfree#multi_segs#mbuf_fast_free#security");
16839 static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16840 TOKEN_STRING_INITIALIZER
16841 (struct cmd_config_per_queue_tx_offload_result,
16845 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16846 __rte_unused struct cmdline *cl,
16847 __rte_unused void *data)
16849 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16850 struct rte_eth_dev_info dev_info;
16851 portid_t port_id = res->port_id;
16852 uint16_t queue_id = res->queue_id;
16853 struct rte_port *port = &ports[port_id];
16854 uint64_t single_offload;
16857 if (port->port_status != RTE_PORT_STOPPED) {
16859 "Error: Can't config offload when Port %d is not stopped\n",
16864 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16868 if (queue_id >= dev_info.nb_tx_queues) {
16870 "Error: input queue_id should be 0 ... %d\n",
16871 dev_info.nb_tx_queues - 1);
16875 single_offload = search_tx_offload(res->offload);
16876 if (single_offload == 0) {
16877 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16881 if (!strcmp(res->on_off, "on"))
16882 port->txq[queue_id].conf.offloads |= single_offload;
16884 port->txq[queue_id].conf.offloads &= ~single_offload;
16886 cmd_reconfig_device_queue(port_id, 1, 1);
16889 static cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16890 .f = cmd_config_per_queue_tx_offload_parsed,
16892 .help_str = "port <port_id> txq <queue_id> tx_offload "
16893 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16894 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16895 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16896 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16897 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16900 (void *)&cmd_config_per_queue_tx_offload_result_port,
16901 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16902 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16903 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16904 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16905 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16906 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16911 /* *** configure tx_metadata for specific port *** */
16912 struct cmd_config_tx_metadata_specific_result {
16913 cmdline_fixed_string_t port;
16914 cmdline_fixed_string_t keyword;
16916 cmdline_fixed_string_t item;
16921 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16922 __rte_unused struct cmdline *cl,
16923 __rte_unused void *data)
16925 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16927 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16929 ports[res->port_id].tx_metadata = res->value;
16930 /* Add/remove callback to insert valid metadata in every Tx packet. */
16931 if (ports[res->port_id].tx_metadata)
16932 add_tx_md_callback(res->port_id);
16934 remove_tx_md_callback(res->port_id);
16935 rte_flow_dynf_metadata_register();
16938 static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16939 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16941 static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16942 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16943 keyword, "config");
16944 static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16945 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16946 port_id, RTE_UINT16);
16947 static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16948 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16949 item, "tx_metadata");
16950 static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16951 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16952 value, RTE_UINT32);
16954 static cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16955 .f = cmd_config_tx_metadata_specific_parsed,
16957 .help_str = "port config <port_id> tx_metadata <value>",
16959 (void *)&cmd_config_tx_metadata_specific_port,
16960 (void *)&cmd_config_tx_metadata_specific_keyword,
16961 (void *)&cmd_config_tx_metadata_specific_id,
16962 (void *)&cmd_config_tx_metadata_specific_item,
16963 (void *)&cmd_config_tx_metadata_specific_value,
16968 /* *** set dynf *** */
16969 struct cmd_config_tx_dynf_specific_result {
16970 cmdline_fixed_string_t port;
16971 cmdline_fixed_string_t keyword;
16973 cmdline_fixed_string_t item;
16974 cmdline_fixed_string_t name;
16975 cmdline_fixed_string_t value;
16979 cmd_config_dynf_specific_parsed(void *parsed_result,
16980 __rte_unused struct cmdline *cl,
16981 __rte_unused void *data)
16983 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16984 struct rte_mbuf_dynflag desc_flag;
16986 uint64_t old_port_flags;
16988 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16990 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16992 if (strlcpy(desc_flag.name, res->name,
16993 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16994 fprintf(stderr, "Flag name too long\n");
16997 desc_flag.flags = 0;
16998 flag = rte_mbuf_dynflag_register(&desc_flag);
17000 fprintf(stderr, "Can't register flag\n");
17003 strcpy(dynf_names[flag], desc_flag.name);
17005 old_port_flags = ports[res->port_id].mbuf_dynf;
17006 if (!strcmp(res->value, "set")) {
17007 ports[res->port_id].mbuf_dynf |= 1UL << flag;
17008 if (old_port_flags == 0)
17009 add_tx_dynf_callback(res->port_id);
17011 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
17012 if (ports[res->port_id].mbuf_dynf == 0)
17013 remove_tx_dynf_callback(res->port_id);
17017 static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
17018 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17020 static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
17021 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17022 keyword, "config");
17023 static cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
17024 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17025 port_id, RTE_UINT16);
17026 static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
17027 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17029 static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
17030 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17032 static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
17033 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17034 value, "set#clear");
17036 static cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
17037 .f = cmd_config_dynf_specific_parsed,
17039 .help_str = "port config <port id> dynf <name> set|clear",
17041 (void *)&cmd_config_tx_dynf_specific_port,
17042 (void *)&cmd_config_tx_dynf_specific_keyword,
17043 (void *)&cmd_config_tx_dynf_specific_port_id,
17044 (void *)&cmd_config_tx_dynf_specific_item,
17045 (void *)&cmd_config_tx_dynf_specific_name,
17046 (void *)&cmd_config_tx_dynf_specific_value,
17051 /* *** display tx_metadata per port configuration *** */
17052 struct cmd_show_tx_metadata_result {
17053 cmdline_fixed_string_t cmd_show;
17054 cmdline_fixed_string_t cmd_port;
17055 cmdline_fixed_string_t cmd_keyword;
17060 cmd_show_tx_metadata_parsed(void *parsed_result,
17061 __rte_unused struct cmdline *cl,
17062 __rte_unused void *data)
17064 struct cmd_show_tx_metadata_result *res = parsed_result;
17066 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17067 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17070 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
17071 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
17072 ports[res->cmd_pid].tx_metadata);
17076 static cmdline_parse_token_string_t cmd_show_tx_metadata_show =
17077 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17079 static cmdline_parse_token_string_t cmd_show_tx_metadata_port =
17080 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17082 static cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
17083 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
17084 cmd_pid, RTE_UINT16);
17085 static cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
17086 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17087 cmd_keyword, "tx_metadata");
17089 static cmdline_parse_inst_t cmd_show_tx_metadata = {
17090 .f = cmd_show_tx_metadata_parsed,
17092 .help_str = "show port <port_id> tx_metadata",
17094 (void *)&cmd_show_tx_metadata_show,
17095 (void *)&cmd_show_tx_metadata_port,
17096 (void *)&cmd_show_tx_metadata_pid,
17097 (void *)&cmd_show_tx_metadata_keyword,
17102 /* *** show fec capability per port configuration *** */
17103 struct cmd_show_fec_capability_result {
17104 cmdline_fixed_string_t cmd_show;
17105 cmdline_fixed_string_t cmd_port;
17106 cmdline_fixed_string_t cmd_fec;
17107 cmdline_fixed_string_t cmd_keyword;
17112 cmd_show_fec_capability_parsed(void *parsed_result,
17113 __rte_unused struct cmdline *cl,
17114 __rte_unused void *data)
17116 struct cmd_show_fec_capability_result *res = parsed_result;
17117 struct rte_eth_fec_capa *speed_fec_capa;
17121 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17122 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
17126 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
17127 if (ret == -ENOTSUP) {
17128 fprintf(stderr, "Function not implemented\n");
17130 } else if (ret < 0) {
17131 fprintf(stderr, "Get FEC capability failed: %d\n", ret);
17135 num = (unsigned int)ret;
17136 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
17137 if (speed_fec_capa == NULL) {
17138 fprintf(stderr, "Failed to alloc FEC capability buffer\n");
17142 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
17144 fprintf(stderr, "Error getting FEC capability: %d\n", ret);
17148 show_fec_capability(num, speed_fec_capa);
17150 free(speed_fec_capa);
17153 static cmdline_parse_token_string_t cmd_show_fec_capability_show =
17154 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17156 static cmdline_parse_token_string_t cmd_show_fec_capability_port =
17157 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17159 static cmdline_parse_token_num_t cmd_show_fec_capability_pid =
17160 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
17161 cmd_pid, RTE_UINT16);
17162 static cmdline_parse_token_string_t cmd_show_fec_capability_fec =
17163 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17165 static cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
17166 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17167 cmd_keyword, "capabilities");
17169 static cmdline_parse_inst_t cmd_show_capability = {
17170 .f = cmd_show_fec_capability_parsed,
17172 .help_str = "show port <port_id> fec capabilities",
17174 (void *)&cmd_show_fec_capability_show,
17175 (void *)&cmd_show_fec_capability_port,
17176 (void *)&cmd_show_fec_capability_pid,
17177 (void *)&cmd_show_fec_capability_fec,
17178 (void *)&cmd_show_fec_capability_keyword,
17183 /* *** show fec mode per port configuration *** */
17184 struct cmd_show_fec_metadata_result {
17185 cmdline_fixed_string_t cmd_show;
17186 cmdline_fixed_string_t cmd_port;
17187 cmdline_fixed_string_t cmd_keyword;
17192 cmd_show_fec_mode_parsed(void *parsed_result,
17193 __rte_unused struct cmdline *cl,
17194 __rte_unused void *data)
17196 #define FEC_NAME_SIZE 16
17197 struct cmd_show_fec_metadata_result *res = parsed_result;
17199 char buf[FEC_NAME_SIZE];
17202 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17203 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
17206 ret = rte_eth_fec_get(res->cmd_pid, &mode);
17207 if (ret == -ENOTSUP) {
17208 fprintf(stderr, "Function not implemented\n");
17210 } else if (ret < 0) {
17211 fprintf(stderr, "Get FEC mode failed\n");
17216 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
17217 strlcpy(buf, "off", sizeof(buf));
17219 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
17220 strlcpy(buf, "auto", sizeof(buf));
17222 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
17223 strlcpy(buf, "baser", sizeof(buf));
17225 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
17226 strlcpy(buf, "rs", sizeof(buf));
17232 printf("%s\n", buf);
17235 static cmdline_parse_token_string_t cmd_show_fec_mode_show =
17236 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17238 static cmdline_parse_token_string_t cmd_show_fec_mode_port =
17239 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17241 static cmdline_parse_token_num_t cmd_show_fec_mode_pid =
17242 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
17243 cmd_pid, RTE_UINT16);
17244 static cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
17245 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17246 cmd_keyword, "fec_mode");
17248 static cmdline_parse_inst_t cmd_show_fec_mode = {
17249 .f = cmd_show_fec_mode_parsed,
17251 .help_str = "show port <port_id> fec_mode",
17253 (void *)&cmd_show_fec_mode_show,
17254 (void *)&cmd_show_fec_mode_port,
17255 (void *)&cmd_show_fec_mode_pid,
17256 (void *)&cmd_show_fec_mode_keyword,
17261 /* *** set fec mode per port configuration *** */
17262 struct cmd_set_port_fec_mode {
17263 cmdline_fixed_string_t set;
17264 cmdline_fixed_string_t port;
17266 cmdline_fixed_string_t fec_mode;
17267 cmdline_fixed_string_t fec_value;
17270 /* Common CLI fields for set fec mode */
17271 static cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
17272 TOKEN_STRING_INITIALIZER
17273 (struct cmd_set_port_fec_mode,
17275 static cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
17276 TOKEN_STRING_INITIALIZER
17277 (struct cmd_set_port_fec_mode,
17279 static cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
17280 TOKEN_NUM_INITIALIZER
17281 (struct cmd_set_port_fec_mode,
17282 port_id, RTE_UINT16);
17283 static cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
17284 TOKEN_STRING_INITIALIZER
17285 (struct cmd_set_port_fec_mode,
17286 fec_mode, "fec_mode");
17287 static cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
17288 TOKEN_STRING_INITIALIZER
17289 (struct cmd_set_port_fec_mode,
17293 cmd_set_port_fec_mode_parsed(
17294 void *parsed_result,
17295 __rte_unused struct cmdline *cl,
17296 __rte_unused void *data)
17298 struct cmd_set_port_fec_mode *res = parsed_result;
17299 uint16_t port_id = res->port_id;
17303 ret = parse_fec_mode(res->fec_value, &fec_capa);
17305 fprintf(stderr, "Unknown fec mode: %s for port %d\n",
17306 res->fec_value, port_id);
17310 ret = rte_eth_fec_set(port_id, fec_capa);
17311 if (ret == -ENOTSUP) {
17312 fprintf(stderr, "Function not implemented\n");
17314 } else if (ret < 0) {
17315 fprintf(stderr, "Set FEC mode failed\n");
17320 static cmdline_parse_inst_t cmd_set_fec_mode = {
17321 .f = cmd_set_port_fec_mode_parsed,
17323 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
17325 (void *)&cmd_set_port_fec_mode_set,
17326 (void *)&cmd_set_port_fec_mode_port,
17327 (void *)&cmd_set_port_fec_mode_port_id,
17328 (void *)&cmd_set_port_fec_mode_str,
17329 (void *)&cmd_set_port_fec_mode_value,
17334 /* show port supported ptypes */
17336 /* Common result structure for show port ptypes */
17337 struct cmd_show_port_supported_ptypes_result {
17338 cmdline_fixed_string_t show;
17339 cmdline_fixed_string_t port;
17341 cmdline_fixed_string_t ptypes;
17344 /* Common CLI fields for show port ptypes */
17345 static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
17346 TOKEN_STRING_INITIALIZER
17347 (struct cmd_show_port_supported_ptypes_result,
17349 static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
17350 TOKEN_STRING_INITIALIZER
17351 (struct cmd_show_port_supported_ptypes_result,
17353 static cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
17354 TOKEN_NUM_INITIALIZER
17355 (struct cmd_show_port_supported_ptypes_result,
17356 port_id, RTE_UINT16);
17357 static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
17358 TOKEN_STRING_INITIALIZER
17359 (struct cmd_show_port_supported_ptypes_result,
17363 cmd_show_port_supported_ptypes_parsed(
17364 void *parsed_result,
17365 __rte_unused struct cmdline *cl,
17366 __rte_unused void *data)
17368 #define RSVD_PTYPE_MASK 0xf0000000
17369 #define MAX_PTYPES_PER_LAYER 16
17370 #define LTYPE_NAMESIZE 32
17371 #define PTYPE_NAMESIZE 256
17372 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
17373 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
17374 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
17375 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
17376 uint16_t port_id = res->port_id;
17379 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
17383 while (ptype_mask != RSVD_PTYPE_MASK) {
17385 switch (ptype_mask) {
17386 case RTE_PTYPE_L2_MASK:
17387 strlcpy(ltype, "L2", sizeof(ltype));
17389 case RTE_PTYPE_L3_MASK:
17390 strlcpy(ltype, "L3", sizeof(ltype));
17392 case RTE_PTYPE_L4_MASK:
17393 strlcpy(ltype, "L4", sizeof(ltype));
17395 case RTE_PTYPE_TUNNEL_MASK:
17396 strlcpy(ltype, "Tunnel", sizeof(ltype));
17398 case RTE_PTYPE_INNER_L2_MASK:
17399 strlcpy(ltype, "Inner L2", sizeof(ltype));
17401 case RTE_PTYPE_INNER_L3_MASK:
17402 strlcpy(ltype, "Inner L3", sizeof(ltype));
17404 case RTE_PTYPE_INNER_L4_MASK:
17405 strlcpy(ltype, "Inner L4", sizeof(ltype));
17411 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
17412 ptype_mask, ptypes,
17413 MAX_PTYPES_PER_LAYER);
17416 printf("Supported %s ptypes:\n", ltype);
17418 printf("%s ptypes unsupported\n", ltype);
17420 for (i = 0; i < ret; ++i) {
17421 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
17422 printf("%s\n", buf);
17429 static cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
17430 .f = cmd_show_port_supported_ptypes_parsed,
17432 .help_str = "show port <port_id> ptypes",
17434 (void *)&cmd_show_port_supported_ptypes_show,
17435 (void *)&cmd_show_port_supported_ptypes_port,
17436 (void *)&cmd_show_port_supported_ptypes_port_id,
17437 (void *)&cmd_show_port_supported_ptypes_ptypes,
17442 /* *** display rx/tx descriptor status *** */
17443 struct cmd_show_rx_tx_desc_status_result {
17444 cmdline_fixed_string_t cmd_show;
17445 cmdline_fixed_string_t cmd_port;
17446 cmdline_fixed_string_t cmd_keyword;
17447 cmdline_fixed_string_t cmd_desc;
17448 cmdline_fixed_string_t cmd_status;
17455 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
17456 __rte_unused struct cmdline *cl,
17457 __rte_unused void *data)
17459 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
17462 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17463 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17467 if (!strcmp(res->cmd_keyword, "rxq")) {
17468 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
17472 "Invalid input: queue id = %d, desc id = %d\n",
17473 res->cmd_qid, res->cmd_did);
17476 if (rc == RTE_ETH_RX_DESC_AVAIL)
17477 printf("Desc status = AVAILABLE\n");
17478 else if (rc == RTE_ETH_RX_DESC_DONE)
17479 printf("Desc status = DONE\n");
17481 printf("Desc status = UNAVAILABLE\n");
17482 } else if (!strcmp(res->cmd_keyword, "txq")) {
17483 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17487 "Invalid input: queue id = %d, desc id = %d\n",
17488 res->cmd_qid, res->cmd_did);
17491 if (rc == RTE_ETH_TX_DESC_FULL)
17492 printf("Desc status = FULL\n");
17493 else if (rc == RTE_ETH_TX_DESC_DONE)
17494 printf("Desc status = DONE\n");
17496 printf("Desc status = UNAVAILABLE\n");
17500 static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17501 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17503 static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17504 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17506 static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17507 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17508 cmd_pid, RTE_UINT16);
17509 static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17510 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17511 cmd_keyword, "rxq#txq");
17512 static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17513 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17514 cmd_qid, RTE_UINT16);
17515 static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17516 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17518 static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17519 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17520 cmd_did, RTE_UINT16);
17521 static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17522 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17523 cmd_status, "status");
17524 static cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17525 .f = cmd_show_rx_tx_desc_status_parsed,
17527 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17530 (void *)&cmd_show_rx_tx_desc_status_show,
17531 (void *)&cmd_show_rx_tx_desc_status_port,
17532 (void *)&cmd_show_rx_tx_desc_status_pid,
17533 (void *)&cmd_show_rx_tx_desc_status_keyword,
17534 (void *)&cmd_show_rx_tx_desc_status_qid,
17535 (void *)&cmd_show_rx_tx_desc_status_desc,
17536 (void *)&cmd_show_rx_tx_desc_status_did,
17537 (void *)&cmd_show_rx_tx_desc_status_status,
17542 /* *** display rx queue desc used count *** */
17543 struct cmd_show_rx_queue_desc_used_count_result {
17544 cmdline_fixed_string_t cmd_show;
17545 cmdline_fixed_string_t cmd_port;
17546 cmdline_fixed_string_t cmd_rxq;
17547 cmdline_fixed_string_t cmd_desc;
17548 cmdline_fixed_string_t cmd_used;
17549 cmdline_fixed_string_t cmd_count;
17555 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17556 __rte_unused struct cmdline *cl,
17557 __rte_unused void *data)
17559 struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17562 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17563 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17567 rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17569 fprintf(stderr, "Invalid queueid = %d\n", res->cmd_qid);
17572 printf("Used desc count = %d\n", rc);
17575 static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17576 TOKEN_STRING_INITIALIZER
17577 (struct cmd_show_rx_queue_desc_used_count_result,
17579 static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17580 TOKEN_STRING_INITIALIZER
17581 (struct cmd_show_rx_queue_desc_used_count_result,
17583 static cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17584 TOKEN_NUM_INITIALIZER
17585 (struct cmd_show_rx_queue_desc_used_count_result,
17586 cmd_pid, RTE_UINT16);
17587 static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17588 TOKEN_STRING_INITIALIZER
17589 (struct cmd_show_rx_queue_desc_used_count_result,
17591 static cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17592 TOKEN_NUM_INITIALIZER
17593 (struct cmd_show_rx_queue_desc_used_count_result,
17594 cmd_qid, RTE_UINT16);
17595 static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17596 TOKEN_STRING_INITIALIZER
17597 (struct cmd_show_rx_queue_desc_used_count_result,
17598 cmd_count, "desc");
17599 static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17600 TOKEN_STRING_INITIALIZER
17601 (struct cmd_show_rx_queue_desc_used_count_result,
17602 cmd_count, "used");
17603 static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17604 TOKEN_STRING_INITIALIZER
17605 (struct cmd_show_rx_queue_desc_used_count_result,
17606 cmd_count, "count");
17607 static cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17608 .f = cmd_show_rx_queue_desc_used_count_parsed,
17610 .help_str = "show port <port_id> rxq <queue_id> desc used count",
17612 (void *)&cmd_show_rx_queue_desc_used_count_show,
17613 (void *)&cmd_show_rx_queue_desc_used_count_port,
17614 (void *)&cmd_show_rx_queue_desc_used_count_pid,
17615 (void *)&cmd_show_rx_queue_desc_used_count_rxq,
17616 (void *)&cmd_show_rx_queue_desc_used_count_qid,
17617 (void *)&cmd_show_rx_queue_desc_used_count_desc,
17618 (void *)&cmd_show_rx_queue_desc_used_count_used,
17619 (void *)&cmd_show_rx_queue_desc_used_count_count,
17624 /* Common result structure for set port ptypes */
17625 struct cmd_set_port_ptypes_result {
17626 cmdline_fixed_string_t set;
17627 cmdline_fixed_string_t port;
17629 cmdline_fixed_string_t ptype_mask;
17633 /* Common CLI fields for set port ptypes */
17634 static cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17635 TOKEN_STRING_INITIALIZER
17636 (struct cmd_set_port_ptypes_result,
17638 static cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17639 TOKEN_STRING_INITIALIZER
17640 (struct cmd_set_port_ptypes_result,
17642 static cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17643 TOKEN_NUM_INITIALIZER
17644 (struct cmd_set_port_ptypes_result,
17645 port_id, RTE_UINT16);
17646 static cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17647 TOKEN_STRING_INITIALIZER
17648 (struct cmd_set_port_ptypes_result,
17649 ptype_mask, "ptype_mask");
17650 static cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17651 TOKEN_NUM_INITIALIZER
17652 (struct cmd_set_port_ptypes_result,
17656 cmd_set_port_ptypes_parsed(
17657 void *parsed_result,
17658 __rte_unused struct cmdline *cl,
17659 __rte_unused void *data)
17661 struct cmd_set_port_ptypes_result *res = parsed_result;
17662 #define PTYPE_NAMESIZE 256
17663 char ptype_name[PTYPE_NAMESIZE];
17664 uint16_t port_id = res->port_id;
17665 uint32_t ptype_mask = res->mask;
17668 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17671 fprintf(stderr, "Port %d doesn't support any ptypes.\n",
17676 uint32_t ptypes[ret];
17678 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17680 fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
17685 printf("Successfully set following ptypes for Port %d\n", port_id);
17686 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17687 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17688 printf("%s\n", ptype_name);
17691 clear_ptypes = false;
17694 static cmdline_parse_inst_t cmd_set_port_ptypes = {
17695 .f = cmd_set_port_ptypes_parsed,
17697 .help_str = "set port <port_id> ptype_mask <mask>",
17699 (void *)&cmd_set_port_ptypes_set,
17700 (void *)&cmd_set_port_ptypes_port,
17701 (void *)&cmd_set_port_ptypes_port_id,
17702 (void *)&cmd_set_port_ptypes_mask_str,
17703 (void *)&cmd_set_port_ptypes_mask_u32,
17708 /* *** display mac addresses added to a port *** */
17709 struct cmd_showport_macs_result {
17710 cmdline_fixed_string_t cmd_show;
17711 cmdline_fixed_string_t cmd_port;
17712 cmdline_fixed_string_t cmd_keyword;
17717 cmd_showport_macs_parsed(void *parsed_result,
17718 __rte_unused struct cmdline *cl,
17719 __rte_unused void *data)
17721 struct cmd_showport_macs_result *res = parsed_result;
17723 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17726 if (!strcmp(res->cmd_keyword, "macs"))
17727 show_macs(res->cmd_pid);
17728 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17729 show_mcast_macs(res->cmd_pid);
17732 static cmdline_parse_token_string_t cmd_showport_macs_show =
17733 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17735 static cmdline_parse_token_string_t cmd_showport_macs_port =
17736 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17738 static cmdline_parse_token_num_t cmd_showport_macs_pid =
17739 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17740 cmd_pid, RTE_UINT16);
17741 static cmdline_parse_token_string_t cmd_showport_macs_keyword =
17742 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17743 cmd_keyword, "macs#mcast_macs");
17745 static cmdline_parse_inst_t cmd_showport_macs = {
17746 .f = cmd_showport_macs_parsed,
17748 .help_str = "show port <port_id> macs|mcast_macs",
17750 (void *)&cmd_showport_macs_show,
17751 (void *)&cmd_showport_macs_port,
17752 (void *)&cmd_showport_macs_pid,
17753 (void *)&cmd_showport_macs_keyword,
17758 /* *** show flow transfer proxy port ID for the given port *** */
17759 struct cmd_show_port_flow_transfer_proxy_result {
17760 cmdline_fixed_string_t show;
17761 cmdline_fixed_string_t port;
17763 cmdline_fixed_string_t flow;
17764 cmdline_fixed_string_t transfer;
17765 cmdline_fixed_string_t proxy;
17768 static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_show =
17769 TOKEN_STRING_INITIALIZER
17770 (struct cmd_show_port_flow_transfer_proxy_result,
17772 static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_port =
17773 TOKEN_STRING_INITIALIZER
17774 (struct cmd_show_port_flow_transfer_proxy_result,
17776 static cmdline_parse_token_num_t cmd_show_port_flow_transfer_proxy_port_id =
17777 TOKEN_NUM_INITIALIZER
17778 (struct cmd_show_port_flow_transfer_proxy_result,
17779 port_id, RTE_UINT16);
17780 static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_flow =
17781 TOKEN_STRING_INITIALIZER
17782 (struct cmd_show_port_flow_transfer_proxy_result,
17784 static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_transfer =
17785 TOKEN_STRING_INITIALIZER
17786 (struct cmd_show_port_flow_transfer_proxy_result,
17787 transfer, "transfer");
17788 static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_proxy =
17789 TOKEN_STRING_INITIALIZER
17790 (struct cmd_show_port_flow_transfer_proxy_result,
17794 cmd_show_port_flow_transfer_proxy_parsed(void *parsed_result,
17795 __rte_unused struct cmdline *cl,
17796 __rte_unused void *data)
17798 struct cmd_show_port_flow_transfer_proxy_result *res = parsed_result;
17799 portid_t proxy_port_id;
17804 ret = rte_flow_pick_transfer_proxy(res->port_id, &proxy_port_id, NULL);
17806 fprintf(stderr, "Failed to pick transfer proxy: %s\n",
17807 rte_strerror(-ret));
17811 printf("Transfer proxy port ID: %u\n\n", proxy_port_id);
17814 static cmdline_parse_inst_t cmd_show_port_flow_transfer_proxy = {
17815 .f = cmd_show_port_flow_transfer_proxy_parsed,
17817 .help_str = "show port <port_id> flow transfer proxy",
17819 (void *)&cmd_show_port_flow_transfer_proxy_show,
17820 (void *)&cmd_show_port_flow_transfer_proxy_port,
17821 (void *)&cmd_show_port_flow_transfer_proxy_port_id,
17822 (void *)&cmd_show_port_flow_transfer_proxy_flow,
17823 (void *)&cmd_show_port_flow_transfer_proxy_transfer,
17824 (void *)&cmd_show_port_flow_transfer_proxy_proxy,
17829 /* ******************************************************************************** */
17831 /* list of instructions */
17832 static cmdline_parse_ctx_t builtin_ctx[] = {
17833 (cmdline_parse_inst_t *)&cmd_help_brief,
17834 (cmdline_parse_inst_t *)&cmd_help_long,
17835 (cmdline_parse_inst_t *)&cmd_quit,
17836 (cmdline_parse_inst_t *)&cmd_load_from_file,
17837 (cmdline_parse_inst_t *)&cmd_showport,
17838 (cmdline_parse_inst_t *)&cmd_showqueue,
17839 (cmdline_parse_inst_t *)&cmd_showeeprom,
17840 (cmdline_parse_inst_t *)&cmd_showportall,
17841 (cmdline_parse_inst_t *)&cmd_representor_info,
17842 (cmdline_parse_inst_t *)&cmd_showdevice,
17843 (cmdline_parse_inst_t *)&cmd_showcfg,
17844 (cmdline_parse_inst_t *)&cmd_showfwdall,
17845 (cmdline_parse_inst_t *)&cmd_start,
17846 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17847 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17848 (cmdline_parse_inst_t *)&cmd_set_link_up,
17849 (cmdline_parse_inst_t *)&cmd_set_link_down,
17850 (cmdline_parse_inst_t *)&cmd_reset,
17851 (cmdline_parse_inst_t *)&cmd_set_numbers,
17852 (cmdline_parse_inst_t *)&cmd_set_log,
17853 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
17854 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
17855 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17856 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17857 (cmdline_parse_inst_t *)&cmd_set_txtimes,
17858 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17859 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17860 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17861 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17862 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17863 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17864 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17865 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17866 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17867 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17868 (cmdline_parse_inst_t *)&cmd_set_link_check,
17869 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17870 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17871 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17872 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17873 #ifdef RTE_NET_BOND
17874 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17875 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17876 (cmdline_parse_inst_t *) &cmd_show_bonding_lacp_info,
17877 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17878 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17879 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17880 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17881 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17882 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17883 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17884 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17885 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17887 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17888 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17889 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17890 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17891 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17892 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17893 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17894 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17895 (cmdline_parse_inst_t *)&cmd_csum_set,
17896 (cmdline_parse_inst_t *)&cmd_csum_show,
17897 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17898 (cmdline_parse_inst_t *)&cmd_tso_set,
17899 (cmdline_parse_inst_t *)&cmd_tso_show,
17900 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17901 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17903 (cmdline_parse_inst_t *)&cmd_gro_enable,
17904 (cmdline_parse_inst_t *)&cmd_gro_flush,
17905 (cmdline_parse_inst_t *)&cmd_gro_show,
17908 (cmdline_parse_inst_t *)&cmd_gso_enable,
17909 (cmdline_parse_inst_t *)&cmd_gso_size,
17910 (cmdline_parse_inst_t *)&cmd_gso_show,
17912 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17913 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17914 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17915 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17916 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17917 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17918 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17919 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17920 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17921 (cmdline_parse_inst_t *)&cmd_link_flow_control_show,
17922 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17923 (cmdline_parse_inst_t *)&cmd_queue_priority_flow_control_set,
17924 (cmdline_parse_inst_t *)&cmd_config_dcb,
17925 (cmdline_parse_inst_t *)&cmd_read_reg,
17926 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17927 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17928 (cmdline_parse_inst_t *)&cmd_write_reg,
17929 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17930 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17931 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17932 (cmdline_parse_inst_t *)&cmd_stop,
17933 (cmdline_parse_inst_t *)&cmd_mac_addr,
17934 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17935 (cmdline_parse_inst_t *)&cmd_set_qmap,
17936 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17937 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17938 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17939 (cmdline_parse_inst_t *)&cmd_operate_port,
17940 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17941 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17942 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17943 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
17944 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17945 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17946 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17947 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17948 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17949 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17950 (cmdline_parse_inst_t *)&cmd_config_mtu,
17951 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17952 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17953 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17954 (cmdline_parse_inst_t *)&cmd_config_rss,
17955 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17956 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17957 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17958 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17959 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17960 (cmdline_parse_inst_t *)&cmd_showport_reta,
17961 (cmdline_parse_inst_t *)&cmd_showport_macs,
17962 (cmdline_parse_inst_t *)&cmd_show_port_flow_transfer_proxy,
17963 (cmdline_parse_inst_t *)&cmd_config_burst,
17964 (cmdline_parse_inst_t *)&cmd_config_thresh,
17965 (cmdline_parse_inst_t *)&cmd_config_threshold,
17966 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17967 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17968 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17969 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17970 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17971 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17972 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17973 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17974 (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
17975 (cmdline_parse_inst_t *)&cmd_dump,
17976 (cmdline_parse_inst_t *)&cmd_dump_one,
17977 #ifdef RTE_NET_I40E
17978 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17980 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17981 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17982 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17983 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17984 (cmdline_parse_inst_t *)&cmd_flow,
17985 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17986 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17987 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17988 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm_rfc4115,
17989 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17990 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17991 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17992 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17993 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17994 (cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
17995 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17996 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17997 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17998 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17999 (cmdline_parse_inst_t *)&cmd_mcast_addr,
18000 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
18001 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
18002 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
18003 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
18004 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
18005 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
18006 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
18007 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
18008 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
18009 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
18010 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
18011 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
18012 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
18013 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
18014 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
18015 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
18016 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
18017 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
18018 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
18019 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
18020 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
18021 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
18022 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
18023 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
18024 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
18025 (cmdline_parse_inst_t *)&cmd_set_vxlan,
18026 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
18027 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
18028 (cmdline_parse_inst_t *)&cmd_set_nvgre,
18029 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
18030 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
18031 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
18032 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
18033 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
18034 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
18035 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
18036 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
18037 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
18038 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
18039 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
18040 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
18041 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
18042 (cmdline_parse_inst_t *)&cmd_set_conntrack_common,
18043 (cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
18044 (cmdline_parse_inst_t *)&cmd_ddp_add,
18045 (cmdline_parse_inst_t *)&cmd_ddp_del,
18046 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
18047 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
18048 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
18049 (cmdline_parse_inst_t *)&cmd_clear_input_set,
18050 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
18051 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
18052 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
18053 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
18054 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
18055 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
18056 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
18057 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
18059 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
18060 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
18061 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
18062 (cmdline_parse_inst_t *)&cmd_queue_region,
18063 (cmdline_parse_inst_t *)&cmd_region_flowtype,
18064 (cmdline_parse_inst_t *)&cmd_user_priority_region,
18065 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
18066 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
18067 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
18068 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
18069 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
18070 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
18071 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
18072 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
18073 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
18074 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
18075 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
18076 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
18077 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
18078 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
18079 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
18080 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
18081 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
18082 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
18083 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
18084 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
18085 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
18086 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
18087 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
18088 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
18089 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
18090 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
18091 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
18092 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
18093 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
18094 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
18095 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
18096 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
18097 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
18098 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
18100 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
18101 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
18103 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
18104 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
18105 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
18106 (cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
18107 (cmdline_parse_inst_t *)&cmd_set_raw,
18108 (cmdline_parse_inst_t *)&cmd_show_set_raw,
18109 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
18110 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
18111 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
18112 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
18113 (cmdline_parse_inst_t *)&cmd_show_capability,
18114 (cmdline_parse_inst_t *)&cmd_set_flex_is_pattern,
18115 (cmdline_parse_inst_t *)&cmd_set_flex_spec_pattern,
18120 testpmd_add_driver_commands(struct testpmd_driver_commands *c)
18122 TAILQ_INSERT_TAIL(&driver_commands_head, c, next);
18128 struct testpmd_driver_commands *c;
18129 unsigned int count;
18132 /* initialize non-constant commands */
18133 cmd_set_fwd_mode_init();
18134 cmd_set_fwd_retry_mode_init();
18137 for (i = 0; builtin_ctx[i] != NULL; i++)
18139 TAILQ_FOREACH(c, &driver_commands_head, next) {
18140 for (i = 0; c->commands[i].ctx != NULL; i++)
18144 /* cmdline expects a NULL terminated array */
18145 main_ctx = calloc(count + 1, sizeof(main_ctx[0]));
18146 if (main_ctx == NULL)
18150 for (i = 0; builtin_ctx[i] != NULL; i++, count++)
18151 main_ctx[count] = builtin_ctx[i];
18152 TAILQ_FOREACH(c, &driver_commands_head, next) {
18153 for (i = 0; c->commands[i].ctx != NULL; i++, count++)
18154 main_ctx[count] = c->commands[i].ctx;
18160 /* read cmdline commands from file */
18162 cmdline_read_from_file(const char *filename)
18164 struct cmdline *cl;
18166 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
18169 "Failed to create file based cmdline context: %s\n",
18174 cmdline_interact(cl);
18179 printf("Read CLI commands from %s\n", filename);
18182 /* prompt function, called from main on MAIN lcore */
18188 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
18189 if (testpmd_cl == NULL)
18192 ret = atexit(prompt_exit);
18194 fprintf(stderr, "Cannot set exit function for cmdline\n");
18196 cmdline_interact(testpmd_cl);
18198 cmdline_stdin_exit(testpmd_cl);
18204 if (testpmd_cl != NULL) {
18205 cmdline_quit(testpmd_cl);
18206 cmdline_stdin_exit(testpmd_cl);
18211 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
18213 if (id == (portid_t)RTE_PORT_ALL) {
18216 RTE_ETH_FOREACH_DEV(pid) {
18217 /* check if need_reconfig has been set to 1 */
18218 if (ports[pid].need_reconfig == 0)
18219 ports[pid].need_reconfig = dev;
18220 /* check if need_reconfig_queues has been set to 1 */
18221 if (ports[pid].need_reconfig_queues == 0)
18222 ports[pid].need_reconfig_queues = queue;
18224 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
18225 /* check if need_reconfig has been set to 1 */
18226 if (ports[id].need_reconfig == 0)
18227 ports[id].need_reconfig = dev;
18228 /* check if need_reconfig_queues has been set to 1 */
18229 if (ports[id].need_reconfig_queues == 0)
18230 ports[id].need_reconfig_queues = queue;