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 port (port_id) rxq (queue_id) avail_thresh (0..99)>\n "
557 " set available descriptors threshold for Rx queue\n\n"
559 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
560 " Set statistics mapping (qmapping 0..15) for RX/TX"
562 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
563 " on port 0 to mapping 5.\n\n"
565 "set xstats-hide-zero on|off\n"
566 " Set the option to hide the zero values"
567 " for xstats display.\n"
569 "set record-core-cycles on|off\n"
570 " Set the option to enable measurement of CPU cycles.\n"
572 "set record-burst-stats on|off\n"
573 " Set the option to enable display of RX and TX bursts.\n"
575 "set port (port_id) vf (vf_id) rx|tx on|off\n"
576 " Enable/Disable a VF receive/transmit from a port\n\n"
578 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
580 " AUPE:accepts untagged VLAN;"
581 "ROPE:accept unicast hash\n\n"
582 " BAM:accepts broadcast packets;"
583 "MPE:accepts all multicast packets\n\n"
584 " Enable/Disable a VF receive mode of a port\n\n"
586 "set port (port_id) queue (queue_id) rate (rate_num)\n"
587 " Set rate limit for a queue of a port\n\n"
589 "set port (port_id) vf (vf_id) rate (rate_num) "
590 "queue_mask (queue_mask_value)\n"
591 " Set rate limit for queues in VF of a port\n\n"
593 "set flush_rx (on|off)\n"
594 " Flush (default) or don't flush RX streams before"
595 " forwarding. Mainly used with PCAP drivers.\n\n"
597 "set bypass mode (normal|bypass|isolate) (port_id)\n"
598 " Set the bypass mode for the lowest port on bypass enabled"
601 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
602 "mode (normal|bypass|isolate) (port_id)\n"
603 " Set the event required to initiate specified bypass mode for"
604 " the lowest port on a bypass enabled NIC where:\n"
605 " timeout = enable bypass after watchdog timeout.\n"
606 " os_on = enable bypass when OS/board is powered on.\n"
607 " os_off = enable bypass when OS/board is powered off.\n"
608 " power_on = enable bypass when power supply is turned on.\n"
609 " power_off = enable bypass when power supply is turned off."
612 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
613 " Set the bypass watchdog timeout to 'n' seconds"
614 " where 0 = instant.\n\n"
616 "show bypass config (port_id)\n"
617 " Show the bypass configuration for a bypass enabled NIC"
618 " using the lowest port on the NIC.\n\n"
621 "create bonded device (mode) (socket)\n"
622 " Create a new bonded device with specific bonding mode and socket.\n\n"
624 "add bonding slave (slave_id) (port_id)\n"
625 " Add a slave device to a bonded device.\n\n"
627 "remove bonding slave (slave_id) (port_id)\n"
628 " Remove a slave device from a bonded device.\n\n"
630 "set bonding mode (value) (port_id)\n"
631 " Set the bonding mode on a bonded device.\n\n"
633 "set bonding primary (slave_id) (port_id)\n"
634 " Set the primary slave for a bonded device.\n\n"
636 "show bonding config (port_id)\n"
637 " Show the bonding config for port_id.\n\n"
639 "show bonding lacp info (port_id)\n"
640 " Show the bonding lacp information for port_id.\n\n"
642 "set bonding mac_addr (port_id) (address)\n"
643 " Set the MAC address of a bonded device.\n\n"
645 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
646 " Set Aggregation mode for IEEE802.3AD (mode 4)"
648 "set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
649 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
651 "set bonding mon_period (port_id) (value)\n"
652 " Set the bonding link status monitoring polling period in ms.\n\n"
654 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
655 " Enable/disable dedicated queues for LACP control traffic.\n\n"
658 "set link-up port (port_id)\n"
659 " Set link up for a port.\n\n"
661 "set link-down port (port_id)\n"
662 " Set link down for a port.\n\n"
664 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
665 " Load a profile package on a port\n\n"
667 "ddp del (port_id) (backup_profile_path)\n"
668 " Delete a profile package from a port\n\n"
670 "ptype mapping get (port_id) (valid_only)\n"
671 " Get ptype mapping on a port\n\n"
673 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
674 " Replace target with the pkt_type in ptype mapping\n\n"
676 "ptype mapping reset (port_id)\n"
677 " Reset ptype mapping on a port\n\n"
679 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
680 " Update a ptype mapping item on a port\n\n"
682 "set port (port_id) ptype_mask (ptype_mask)\n"
683 " set packet types classification for a specific port\n\n"
685 "set port (port_id) queue-region region_id (value) "
686 "queue_start_index (value) queue_num (value)\n"
687 " Set a queue region on a port\n\n"
689 "set port (port_id) queue-region region_id (value) "
691 " Set a flowtype region index on a port\n\n"
693 "set port (port_id) queue-region UP (value) region_id (value)\n"
694 " Set the mapping of User Priority to "
695 "queue region on a port\n\n"
697 "set port (port_id) queue-region flush (on|off)\n"
698 " flush all queue region related configuration\n\n"
700 "show port meter cap (port_id)\n"
701 " Show port meter capability information\n\n"
703 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
704 " meter profile add - srtcm rfc 2697\n\n"
706 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
707 " meter profile add - trtcm rfc 2698\n\n"
709 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
710 " meter profile add - trtcm rfc 4115\n\n"
712 "del port meter profile (port_id) (profile_id)\n"
713 " meter profile delete\n\n"
715 "create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
716 "(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
717 "(dscp_tbl_entry63)]\n"
720 "enable port meter (port_id) (mtr_id)\n"
723 "disable port meter (port_id) (mtr_id)\n"
726 "del port meter (port_id) (mtr_id)\n"
729 "add port meter policy (port_id) (policy_id) g_actions (actions)\n"
730 "y_actions (actions) r_actions (actions)\n"
731 " meter policy add\n\n"
733 "del port meter policy (port_id) (policy_id)\n"
734 " meter policy delete\n\n"
736 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
737 " meter update meter profile\n\n"
739 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
740 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
741 " update meter dscp table entries\n\n"
743 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
744 "(action0) [(action1) (action2)]\n"
745 " meter update policer action\n\n"
747 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
748 " meter update stats\n\n"
750 "show port (port_id) queue-region\n"
751 " show all queue region related configuration info\n\n"
753 "set port (port_id) fec_mode auto|off|rs|baser\n"
754 " set fec mode for a specific port\n\n"
756 , list_pkt_forwarding_modes()
760 if (show_all || !strcmp(res->section, "ports")) {
766 "----------------\n\n"
768 "port start (port_id|all)\n"
769 " Start all ports or port_id.\n\n"
771 "port stop (port_id|all)\n"
772 " Stop all ports or port_id.\n\n"
774 "port close (port_id|all)\n"
775 " Close all ports or port_id.\n\n"
777 "port reset (port_id|all)\n"
778 " Reset all ports or port_id.\n\n"
780 "port attach (ident)\n"
781 " Attach physical or virtual dev by pci address or virtual device name\n\n"
783 "port detach (port_id)\n"
784 " Detach physical or virtual dev by port_id\n\n"
786 "port config (port_id|all)"
787 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
788 " duplex (half|full|auto)\n"
789 " Set speed and duplex for all ports or port_id\n\n"
791 "port config (port_id|all) loopback (mode)\n"
792 " Set loopback mode for all ports or port_id\n\n"
794 "port config all (rxq|txq|rxd|txd) (value)\n"
795 " Set number for rxq/txq/rxd/txd.\n\n"
797 "port config all max-pkt-len (value)\n"
798 " Set the max packet length.\n\n"
800 "port config all max-lro-pkt-size (value)\n"
801 " Set the max LRO aggregated packet size.\n\n"
803 "port config all drop-en (on|off)\n"
804 " Enable or disable packet drop on all RX queues of all ports when no "
805 "receive buffers available.\n\n"
807 "port config all rss (all|default|ip|tcp|udp|sctp|"
808 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|ipv4-chksum|l2tpv2|"
809 "none|level-default|level-outer|level-inner|<flowtype_id>)\n"
810 " Set the RSS mode.\n\n"
812 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
813 " Set the RSS redirection table.\n\n"
815 "port config (port_id) dcb vt (on|off) (traffic_class)"
817 " Set the DCB mode.\n\n"
819 "port config all burst (value)\n"
820 " Set the number of packets per burst.\n\n"
822 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
824 " Set the ring prefetch/host/writeback threshold"
825 " for tx/rx queue.\n\n"
827 "port config all (txfreet|txrst|rxfreet) (value)\n"
828 " Set free threshold for rx/tx, or set"
829 " tx rs bit threshold.\n\n"
830 "port config mtu X value\n"
831 " Set the MTU of port X to a given value\n\n"
833 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
834 " Set a rx/tx queue's ring size configuration, the new"
835 " value will take effect after command that (re-)start the port"
836 " or command that setup the specific queue\n\n"
838 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
839 " Start/stop a rx/tx queue of port X. Only take effect"
840 " when port X is started\n\n"
842 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
843 " Switch on/off a deferred start of port X rx/tx queue. Only"
844 " take effect when port X is stopped.\n\n"
846 "port (port_id) (rxq|txq) (queue_id) setup\n"
847 " Setup a rx/tx queue of port X.\n\n"
849 "port config (port_id) pctype mapping reset\n"
850 " Reset flow type to pctype mapping on a port\n\n"
852 "port config (port_id) pctype mapping update"
853 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
854 " Update a flow type to pctype mapping item on a port\n\n"
856 "port config (port_id) pctype (pctype_id) hash_inset|"
857 "fdir_inset|fdir_flx_inset get|set|clear field\n"
859 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
861 "port config (port_id) pctype (pctype_id) hash_inset|"
862 "fdir_inset|fdir_flx_inset clear all"
863 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
865 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
866 " Add/remove UDP tunnel port for tunneling offload\n\n"
868 "port config <port_id> rx_offload vlan_strip|"
869 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
870 "outer_ipv4_cksum|macsec_strip|header_split|"
871 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
872 "buffer_split|timestamp|security|keep_crc on|off\n"
873 " Enable or disable a per port Rx offloading"
874 " on all Rx queues of a port\n\n"
876 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
877 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
878 "outer_ipv4_cksum|macsec_strip|header_split|"
879 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
880 "buffer_split|timestamp|security|keep_crc on|off\n"
881 " Enable or disable a per queue Rx offloading"
882 " only on a specific Rx queue\n\n"
884 "port config (port_id) tx_offload vlan_insert|"
885 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
886 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
887 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
888 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
890 " Enable or disable a per port Tx offloading"
891 " on all Tx queues of a port\n\n"
893 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
894 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
895 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
896 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
897 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
899 " Enable or disable a per queue Tx offloading"
900 " only on a specific Tx queue\n\n"
902 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
903 " Load an eBPF program as a callback"
904 " for particular RX/TX queue\n\n"
906 "bpf-unload rx|tx (port) (queue)\n"
907 " Unload previously loaded eBPF program"
908 " for particular RX/TX queue\n\n"
910 "port config (port_id) tx_metadata (value)\n"
911 " Set Tx metadata value per port. Testpmd will add this value"
912 " to any Tx packet sent from this port\n\n"
914 "port config (port_id) dynf (name) set|clear\n"
915 " Register a dynf and Set/clear this flag on Tx. "
916 "Testpmd will set this value to any Tx packet "
917 "sent from this port\n\n"
919 "port cleanup (port_id) txq (queue_id) (free_cnt)\n"
920 " Cleanup txq mbufs for a specific Tx queue\n\n"
924 if (show_all || !strcmp(res->section, "registers")) {
932 "read reg (port_id) (address)\n"
933 " Display value of a port register.\n\n"
935 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
936 " Display a port register bit field.\n\n"
938 "read regbit (port_id) (address) (bit_x)\n"
939 " Display a single port register bit.\n\n"
941 "write reg (port_id) (address) (value)\n"
942 " Set value of a port register.\n\n"
944 "write regfield (port_id) (address) (bit_x) (bit_y)"
946 " Set bit field of a port register.\n\n"
948 "write regbit (port_id) (address) (bit_x) (value)\n"
949 " Set single bit value of a port register.\n\n"
952 if (show_all || !strcmp(res->section, "filters")) {
961 "flow_director_filter (port_id) mode raw (add|del|update)"
962 " flow (flow_id) (drop|fwd) queue (queue_id)"
963 " fd_id (fd_id_value) packet (packet file name)\n"
964 " Add/Del a raw type flow director filter.\n\n"
967 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
968 " src_mask (ipv4_src) (ipv6_src) (src_port)"
969 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
970 " Set flow director IP mask.\n\n"
972 "flow_director_mask (port_id) mode MAC-VLAN"
973 " vlan (vlan_value)\n"
974 " Set flow director MAC-VLAN mask.\n\n"
976 "flow_director_mask (port_id) mode Tunnel"
977 " vlan (vlan_value) mac (mac_value)"
978 " tunnel-type (tunnel_type_value)"
979 " tunnel-id (tunnel_id_value)\n"
980 " Set flow director Tunnel mask.\n\n"
982 "flow_director_flex_payload (port_id)"
983 " (raw|l2|l3|l4) (config)\n"
984 " Configure flex payload selection.\n\n"
986 "flow validate {port_id}"
987 " [group {group_id}] [priority {level}]"
988 " [ingress] [egress]"
989 " pattern {item} [/ {item} [...]] / end"
990 " actions {action} [/ {action} [...]] / end\n"
991 " Check whether a flow rule can be created.\n\n"
993 "flow create {port_id}"
994 " [group {group_id}] [priority {level}]"
995 " [ingress] [egress]"
996 " pattern {item} [/ {item} [...]] / end"
997 " actions {action} [/ {action} [...]] / end\n"
998 " Create a flow rule.\n\n"
1000 "flow destroy {port_id} rule {rule_id} [...]\n"
1001 " Destroy specific flow rules.\n\n"
1003 "flow flush {port_id}\n"
1004 " Destroy all flow rules.\n\n"
1006 "flow query {port_id} {rule_id} {action}\n"
1007 " Query an existing flow rule.\n\n"
1009 "flow list {port_id} [group {group_id}] [...]\n"
1010 " List existing flow rules sorted by priority,"
1011 " filtered by group identifiers.\n\n"
1013 "flow isolate {port_id} {boolean}\n"
1014 " Restrict ingress traffic to the defined"
1017 "flow aged {port_id} [destroy]\n"
1018 " List and destroy aged flows"
1021 "flow indirect_action {port_id} create"
1022 " [action_id {indirect_action_id}]"
1023 " [ingress] [egress]"
1024 " action {action} / end\n"
1025 " Create indirect action.\n\n"
1027 "flow indirect_action {port_id} update"
1028 " {indirect_action_id} action {action} / end\n"
1029 " Update indirect action.\n\n"
1031 "flow indirect_action {port_id} destroy"
1032 " action_id {indirect_action_id} [...]\n"
1033 " Destroy specific indirect actions.\n\n"
1035 "flow indirect_action {port_id} query"
1036 " {indirect_action_id}\n"
1037 " Query an existing indirect action.\n\n"
1039 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1040 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1041 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1042 " Configure the VXLAN encapsulation for flows.\n\n"
1044 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1045 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1046 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1047 " eth-dst (eth-dst)\n"
1048 " Configure the VXLAN encapsulation for flows.\n\n"
1050 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1051 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1052 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1053 " eth-dst (eth-dst)\n"
1054 " Configure the VXLAN encapsulation for flows.\n\n"
1056 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1057 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1059 " Configure the NVGRE encapsulation for flows.\n\n"
1061 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1062 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1063 " eth-src (eth-src) eth-dst (eth-dst)\n"
1064 " Configure the NVGRE encapsulation for flows.\n\n"
1066 "set raw_encap {flow items}\n"
1067 " Configure the encapsulation with raw data.\n\n"
1069 "set raw_decap {flow items}\n"
1070 " Configure the decapsulation with raw data.\n\n"
1075 if (show_all || !strcmp(res->section, "traffic_management")) {
1079 "Traffic Management:\n"
1081 "show port tm cap (port_id)\n"
1082 " Display the port TM capability.\n\n"
1084 "show port tm level cap (port_id) (level_id)\n"
1085 " Display the port TM hierarchical level capability.\n\n"
1087 "show port tm node cap (port_id) (node_id)\n"
1088 " Display the port TM node capability.\n\n"
1090 "show port tm node type (port_id) (node_id)\n"
1091 " Display the port TM node type.\n\n"
1093 "show port tm node stats (port_id) (node_id) (clear)\n"
1094 " Display the port TM node stats.\n\n"
1096 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1097 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1098 " (packet_length_adjust) (packet_mode)\n"
1099 " Add port tm node private shaper profile.\n\n"
1101 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1102 " Delete port tm node private shaper profile.\n\n"
1104 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1105 " (shaper_profile_id)\n"
1106 " Add/update port tm node shared shaper.\n\n"
1108 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1109 " Delete port tm node shared shaper.\n\n"
1111 "set port tm node shaper profile (port_id) (node_id)"
1112 " (shaper_profile_id)\n"
1113 " Set port tm node shaper profile.\n\n"
1115 "add port tm node wred profile (port_id) (wred_profile_id)"
1116 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1117 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1118 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1119 " Add port tm node wred profile.\n\n"
1121 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1122 " Delete port tm node wred profile.\n\n"
1124 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1125 " (priority) (weight) (level_id) (shaper_profile_id)"
1126 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1127 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1128 " Add port tm nonleaf node.\n\n"
1130 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1131 " (priority) (weight) (level_id) (shaper_profile_id)"
1132 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1133 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1134 " Add port tm nonleaf node with pkt mode enabled.\n\n"
1136 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1137 " (priority) (weight) (level_id) (shaper_profile_id)"
1138 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1139 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1140 " Add port tm leaf node.\n\n"
1142 "del port tm node (port_id) (node_id)\n"
1143 " Delete port tm node.\n\n"
1145 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1146 " (priority) (weight)\n"
1147 " Set port tm node parent.\n\n"
1149 "suspend port tm node (port_id) (node_id)"
1150 " Suspend tm node.\n\n"
1152 "resume port tm node (port_id) (node_id)"
1153 " Resume tm node.\n\n"
1155 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1156 " Commit tm hierarchy.\n\n"
1158 "set port tm mark ip_ecn (port) (green) (yellow)"
1160 " Enables/Disables the traffic management marking"
1161 " for IP ECN (Explicit Congestion Notification)"
1162 " packets on a given port\n\n"
1164 "set port tm mark ip_dscp (port) (green) (yellow)"
1166 " Enables/Disables the traffic management marking"
1167 " on the port for IP dscp packets\n\n"
1169 "set port tm mark vlan_dei (port) (green) (yellow)"
1171 " Enables/Disables the traffic management marking"
1172 " on the port for VLAN packets with DEI enabled\n\n"
1176 if (show_all || !strcmp(res->section, "devices")) {
1180 "Device Operations:\n"
1182 "device detach (identifier)\n"
1183 " Detach device by identifier.\n\n"
1187 if (show_all || !strcmp(res->section, "drivers")) {
1188 struct testpmd_driver_commands *c;
1194 "Driver specific:\n"
1195 "----------------\n"
1197 TAILQ_FOREACH(c, &driver_commands_head, next) {
1198 for (i = 0; c->commands[i].ctx != NULL; i++)
1199 cmdline_printf(cl, "%s\n", c->commands[i].help);
1204 static cmdline_parse_token_string_t cmd_help_long_help =
1205 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1207 static cmdline_parse_token_string_t cmd_help_long_section =
1208 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1209 "all#control#display#config#ports#registers#"
1210 "filters#traffic_management#devices#drivers");
1212 static cmdline_parse_inst_t cmd_help_long = {
1213 .f = cmd_help_long_parsed,
1215 .help_str = "help all|control|display|config|ports|register|"
1216 "filters|traffic_management|devices|drivers: "
1219 (void *)&cmd_help_long_help,
1220 (void *)&cmd_help_long_section,
1226 /* *** start/stop/close all ports *** */
1227 struct cmd_operate_port_result {
1228 cmdline_fixed_string_t keyword;
1229 cmdline_fixed_string_t name;
1230 cmdline_fixed_string_t value;
1233 static void cmd_operate_port_parsed(void *parsed_result,
1234 __rte_unused struct cmdline *cl,
1235 __rte_unused void *data)
1237 struct cmd_operate_port_result *res = parsed_result;
1239 if (!strcmp(res->name, "start"))
1240 start_port(RTE_PORT_ALL);
1241 else if (!strcmp(res->name, "stop"))
1242 stop_port(RTE_PORT_ALL);
1243 else if (!strcmp(res->name, "close"))
1244 close_port(RTE_PORT_ALL);
1245 else if (!strcmp(res->name, "reset"))
1246 reset_port(RTE_PORT_ALL);
1248 fprintf(stderr, "Unknown parameter\n");
1251 static cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1252 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1254 static cmdline_parse_token_string_t cmd_operate_port_all_port =
1255 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1256 "start#stop#close#reset");
1257 static cmdline_parse_token_string_t cmd_operate_port_all_all =
1258 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1260 static cmdline_parse_inst_t cmd_operate_port = {
1261 .f = cmd_operate_port_parsed,
1263 .help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports",
1265 (void *)&cmd_operate_port_all_cmd,
1266 (void *)&cmd_operate_port_all_port,
1267 (void *)&cmd_operate_port_all_all,
1272 /* *** start/stop/close specific port *** */
1273 struct cmd_operate_specific_port_result {
1274 cmdline_fixed_string_t keyword;
1275 cmdline_fixed_string_t name;
1279 static void cmd_operate_specific_port_parsed(void *parsed_result,
1280 __rte_unused struct cmdline *cl,
1281 __rte_unused void *data)
1283 struct cmd_operate_specific_port_result *res = parsed_result;
1285 if (!strcmp(res->name, "start"))
1286 start_port(res->value);
1287 else if (!strcmp(res->name, "stop"))
1288 stop_port(res->value);
1289 else if (!strcmp(res->name, "close"))
1290 close_port(res->value);
1291 else if (!strcmp(res->name, "reset"))
1292 reset_port(res->value);
1294 fprintf(stderr, "Unknown parameter\n");
1297 static cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1298 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1300 static cmdline_parse_token_string_t cmd_operate_specific_port_port =
1301 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1302 name, "start#stop#close#reset");
1303 static cmdline_parse_token_num_t cmd_operate_specific_port_id =
1304 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1307 static cmdline_parse_inst_t cmd_operate_specific_port = {
1308 .f = cmd_operate_specific_port_parsed,
1310 .help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id",
1312 (void *)&cmd_operate_specific_port_cmd,
1313 (void *)&cmd_operate_specific_port_port,
1314 (void *)&cmd_operate_specific_port_id,
1319 /* *** enable port setup (after attach) via iterator or event *** */
1320 struct cmd_set_port_setup_on_result {
1321 cmdline_fixed_string_t set;
1322 cmdline_fixed_string_t port;
1323 cmdline_fixed_string_t setup;
1324 cmdline_fixed_string_t on;
1325 cmdline_fixed_string_t mode;
1328 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1329 __rte_unused struct cmdline *cl,
1330 __rte_unused void *data)
1332 struct cmd_set_port_setup_on_result *res = parsed_result;
1334 if (strcmp(res->mode, "event") == 0)
1335 setup_on_probe_event = true;
1336 else if (strcmp(res->mode, "iterator") == 0)
1337 setup_on_probe_event = false;
1339 fprintf(stderr, "Unknown mode\n");
1342 static cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1343 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1345 static cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1346 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1348 static cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1349 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1351 static cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1352 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1354 static cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1355 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1356 mode, "iterator#event");
1358 static cmdline_parse_inst_t cmd_set_port_setup_on = {
1359 .f = cmd_set_port_setup_on_parsed,
1361 .help_str = "set port setup on iterator|event",
1363 (void *)&cmd_set_port_setup_on_set,
1364 (void *)&cmd_set_port_setup_on_port,
1365 (void *)&cmd_set_port_setup_on_setup,
1366 (void *)&cmd_set_port_setup_on_on,
1367 (void *)&cmd_set_port_setup_on_mode,
1372 /* *** attach a specified port *** */
1373 struct cmd_operate_attach_port_result {
1374 cmdline_fixed_string_t port;
1375 cmdline_fixed_string_t keyword;
1376 cmdline_multi_string_t identifier;
1379 static void cmd_operate_attach_port_parsed(void *parsed_result,
1380 __rte_unused struct cmdline *cl,
1381 __rte_unused void *data)
1383 struct cmd_operate_attach_port_result *res = parsed_result;
1385 if (!strcmp(res->keyword, "attach"))
1386 attach_port(res->identifier);
1388 fprintf(stderr, "Unknown parameter\n");
1391 static cmdline_parse_token_string_t cmd_operate_attach_port_port =
1392 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1394 static cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1395 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1397 static cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1398 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1399 identifier, TOKEN_STRING_MULTI);
1401 static cmdline_parse_inst_t cmd_operate_attach_port = {
1402 .f = cmd_operate_attach_port_parsed,
1404 .help_str = "port attach <identifier>: "
1405 "(identifier: pci address or virtual dev name)",
1407 (void *)&cmd_operate_attach_port_port,
1408 (void *)&cmd_operate_attach_port_keyword,
1409 (void *)&cmd_operate_attach_port_identifier,
1414 /* *** detach a specified port *** */
1415 struct cmd_operate_detach_port_result {
1416 cmdline_fixed_string_t port;
1417 cmdline_fixed_string_t keyword;
1421 static void cmd_operate_detach_port_parsed(void *parsed_result,
1422 __rte_unused struct cmdline *cl,
1423 __rte_unused void *data)
1425 struct cmd_operate_detach_port_result *res = parsed_result;
1427 if (!strcmp(res->keyword, "detach")) {
1428 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1429 detach_port_device(res->port_id);
1431 fprintf(stderr, "Unknown parameter\n");
1435 static cmdline_parse_token_string_t cmd_operate_detach_port_port =
1436 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1438 static cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1439 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1441 static cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1442 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1443 port_id, RTE_UINT16);
1445 static cmdline_parse_inst_t cmd_operate_detach_port = {
1446 .f = cmd_operate_detach_port_parsed,
1448 .help_str = "port detach <port_id>",
1450 (void *)&cmd_operate_detach_port_port,
1451 (void *)&cmd_operate_detach_port_keyword,
1452 (void *)&cmd_operate_detach_port_port_id,
1457 /* *** detach device by identifier *** */
1458 struct cmd_operate_detach_device_result {
1459 cmdline_fixed_string_t device;
1460 cmdline_fixed_string_t keyword;
1461 cmdline_fixed_string_t identifier;
1464 static void cmd_operate_detach_device_parsed(void *parsed_result,
1465 __rte_unused struct cmdline *cl,
1466 __rte_unused void *data)
1468 struct cmd_operate_detach_device_result *res = parsed_result;
1470 if (!strcmp(res->keyword, "detach"))
1471 detach_devargs(res->identifier);
1473 fprintf(stderr, "Unknown parameter\n");
1476 static cmdline_parse_token_string_t cmd_operate_detach_device_device =
1477 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1479 static cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1480 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1482 static cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1483 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1486 static cmdline_parse_inst_t cmd_operate_detach_device = {
1487 .f = cmd_operate_detach_device_parsed,
1489 .help_str = "device detach <identifier>:"
1490 "(identifier: pci address or virtual dev name)",
1492 (void *)&cmd_operate_detach_device_device,
1493 (void *)&cmd_operate_detach_device_keyword,
1494 (void *)&cmd_operate_detach_device_identifier,
1498 /* *** configure speed for all ports *** */
1499 struct cmd_config_speed_all {
1500 cmdline_fixed_string_t port;
1501 cmdline_fixed_string_t keyword;
1502 cmdline_fixed_string_t all;
1503 cmdline_fixed_string_t item1;
1504 cmdline_fixed_string_t item2;
1505 cmdline_fixed_string_t value1;
1506 cmdline_fixed_string_t value2;
1510 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1515 if (!strcmp(duplexstr, "half")) {
1516 duplex = RTE_ETH_LINK_HALF_DUPLEX;
1517 } else if (!strcmp(duplexstr, "full")) {
1518 duplex = RTE_ETH_LINK_FULL_DUPLEX;
1519 } else if (!strcmp(duplexstr, "auto")) {
1520 duplex = RTE_ETH_LINK_FULL_DUPLEX;
1522 fprintf(stderr, "Unknown duplex parameter\n");
1526 if (!strcmp(speedstr, "10")) {
1527 *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1528 RTE_ETH_LINK_SPEED_10M_HD : RTE_ETH_LINK_SPEED_10M;
1529 } else if (!strcmp(speedstr, "100")) {
1530 *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1531 RTE_ETH_LINK_SPEED_100M_HD : RTE_ETH_LINK_SPEED_100M;
1533 if (duplex != RTE_ETH_LINK_FULL_DUPLEX) {
1534 fprintf(stderr, "Invalid speed/duplex parameters\n");
1537 if (!strcmp(speedstr, "1000")) {
1538 *speed = RTE_ETH_LINK_SPEED_1G;
1539 } else if (!strcmp(speedstr, "10000")) {
1540 *speed = RTE_ETH_LINK_SPEED_10G;
1541 } else if (!strcmp(speedstr, "25000")) {
1542 *speed = RTE_ETH_LINK_SPEED_25G;
1543 } else if (!strcmp(speedstr, "40000")) {
1544 *speed = RTE_ETH_LINK_SPEED_40G;
1545 } else if (!strcmp(speedstr, "50000")) {
1546 *speed = RTE_ETH_LINK_SPEED_50G;
1547 } else if (!strcmp(speedstr, "100000")) {
1548 *speed = RTE_ETH_LINK_SPEED_100G;
1549 } else if (!strcmp(speedstr, "200000")) {
1550 *speed = RTE_ETH_LINK_SPEED_200G;
1551 } else if (!strcmp(speedstr, "auto")) {
1552 *speed = RTE_ETH_LINK_SPEED_AUTONEG;
1554 fprintf(stderr, "Unknown speed parameter\n");
1559 if (*speed != RTE_ETH_LINK_SPEED_AUTONEG)
1560 *speed |= RTE_ETH_LINK_SPEED_FIXED;
1566 cmd_config_speed_all_parsed(void *parsed_result,
1567 __rte_unused struct cmdline *cl,
1568 __rte_unused void *data)
1570 struct cmd_config_speed_all *res = parsed_result;
1571 uint32_t link_speed;
1574 if (!all_ports_stopped()) {
1575 fprintf(stderr, "Please stop all ports first\n");
1579 if (parse_and_check_speed_duplex(res->value1, res->value2,
1583 RTE_ETH_FOREACH_DEV(pid) {
1584 ports[pid].dev_conf.link_speeds = link_speed;
1587 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1590 static cmdline_parse_token_string_t cmd_config_speed_all_port =
1591 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1592 static cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1593 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1595 static cmdline_parse_token_string_t cmd_config_speed_all_all =
1596 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1597 static cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1598 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1599 static cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1600 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1601 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1602 static cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1603 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1604 static cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1605 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1608 static cmdline_parse_inst_t cmd_config_speed_all = {
1609 .f = cmd_config_speed_all_parsed,
1611 .help_str = "port config all speed "
1612 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1615 (void *)&cmd_config_speed_all_port,
1616 (void *)&cmd_config_speed_all_keyword,
1617 (void *)&cmd_config_speed_all_all,
1618 (void *)&cmd_config_speed_all_item1,
1619 (void *)&cmd_config_speed_all_value1,
1620 (void *)&cmd_config_speed_all_item2,
1621 (void *)&cmd_config_speed_all_value2,
1626 /* *** configure speed for specific port *** */
1627 struct cmd_config_speed_specific {
1628 cmdline_fixed_string_t port;
1629 cmdline_fixed_string_t keyword;
1631 cmdline_fixed_string_t item1;
1632 cmdline_fixed_string_t item2;
1633 cmdline_fixed_string_t value1;
1634 cmdline_fixed_string_t value2;
1638 cmd_config_speed_specific_parsed(void *parsed_result,
1639 __rte_unused struct cmdline *cl,
1640 __rte_unused void *data)
1642 struct cmd_config_speed_specific *res = parsed_result;
1643 uint32_t link_speed;
1645 if (port_id_is_invalid(res->id, ENABLED_WARN))
1648 if (!port_is_stopped(res->id)) {
1649 fprintf(stderr, "Please stop port %d first\n", res->id);
1653 if (parse_and_check_speed_duplex(res->value1, res->value2,
1657 ports[res->id].dev_conf.link_speeds = link_speed;
1659 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1663 static cmdline_parse_token_string_t cmd_config_speed_specific_port =
1664 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1666 static cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1667 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1669 static cmdline_parse_token_num_t cmd_config_speed_specific_id =
1670 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1671 static cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1672 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1674 static cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1675 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1676 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1677 static cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1678 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1680 static cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1681 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1684 static cmdline_parse_inst_t cmd_config_speed_specific = {
1685 .f = cmd_config_speed_specific_parsed,
1687 .help_str = "port config <port_id> speed "
1688 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1691 (void *)&cmd_config_speed_specific_port,
1692 (void *)&cmd_config_speed_specific_keyword,
1693 (void *)&cmd_config_speed_specific_id,
1694 (void *)&cmd_config_speed_specific_item1,
1695 (void *)&cmd_config_speed_specific_value1,
1696 (void *)&cmd_config_speed_specific_item2,
1697 (void *)&cmd_config_speed_specific_value2,
1702 /* *** configure loopback for all ports *** */
1703 struct cmd_config_loopback_all {
1704 cmdline_fixed_string_t port;
1705 cmdline_fixed_string_t keyword;
1706 cmdline_fixed_string_t all;
1707 cmdline_fixed_string_t item;
1712 cmd_config_loopback_all_parsed(void *parsed_result,
1713 __rte_unused struct cmdline *cl,
1714 __rte_unused void *data)
1716 struct cmd_config_loopback_all *res = parsed_result;
1719 if (!all_ports_stopped()) {
1720 fprintf(stderr, "Please stop all ports first\n");
1724 RTE_ETH_FOREACH_DEV(pid) {
1725 ports[pid].dev_conf.lpbk_mode = res->mode;
1728 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1731 static cmdline_parse_token_string_t cmd_config_loopback_all_port =
1732 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1733 static cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1734 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1736 static cmdline_parse_token_string_t cmd_config_loopback_all_all =
1737 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1738 static cmdline_parse_token_string_t cmd_config_loopback_all_item =
1739 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1741 static cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1742 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1744 static cmdline_parse_inst_t cmd_config_loopback_all = {
1745 .f = cmd_config_loopback_all_parsed,
1747 .help_str = "port config all loopback <mode>",
1749 (void *)&cmd_config_loopback_all_port,
1750 (void *)&cmd_config_loopback_all_keyword,
1751 (void *)&cmd_config_loopback_all_all,
1752 (void *)&cmd_config_loopback_all_item,
1753 (void *)&cmd_config_loopback_all_mode,
1758 /* *** configure loopback for specific port *** */
1759 struct cmd_config_loopback_specific {
1760 cmdline_fixed_string_t port;
1761 cmdline_fixed_string_t keyword;
1763 cmdline_fixed_string_t item;
1768 cmd_config_loopback_specific_parsed(void *parsed_result,
1769 __rte_unused struct cmdline *cl,
1770 __rte_unused void *data)
1772 struct cmd_config_loopback_specific *res = parsed_result;
1774 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1777 if (!port_is_stopped(res->port_id)) {
1778 fprintf(stderr, "Please stop port %u first\n", res->port_id);
1782 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1784 cmd_reconfig_device_queue(res->port_id, 1, 1);
1788 static cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1789 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1791 static cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1792 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1794 static cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1795 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1797 static cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1798 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1800 static cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1801 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1804 static cmdline_parse_inst_t cmd_config_loopback_specific = {
1805 .f = cmd_config_loopback_specific_parsed,
1807 .help_str = "port config <port_id> loopback <mode>",
1809 (void *)&cmd_config_loopback_specific_port,
1810 (void *)&cmd_config_loopback_specific_keyword,
1811 (void *)&cmd_config_loopback_specific_id,
1812 (void *)&cmd_config_loopback_specific_item,
1813 (void *)&cmd_config_loopback_specific_mode,
1818 /* *** configure txq/rxq, txd/rxd *** */
1819 struct cmd_config_rx_tx {
1820 cmdline_fixed_string_t port;
1821 cmdline_fixed_string_t keyword;
1822 cmdline_fixed_string_t all;
1823 cmdline_fixed_string_t name;
1828 cmd_config_rx_tx_parsed(void *parsed_result,
1829 __rte_unused struct cmdline *cl,
1830 __rte_unused void *data)
1832 struct cmd_config_rx_tx *res = parsed_result;
1834 if (!all_ports_stopped()) {
1835 fprintf(stderr, "Please stop all ports first\n");
1838 if (!strcmp(res->name, "rxq")) {
1839 if (!res->value && !nb_txq) {
1840 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1843 if (check_nb_rxq(res->value) != 0)
1845 nb_rxq = res->value;
1847 else if (!strcmp(res->name, "txq")) {
1848 if (!res->value && !nb_rxq) {
1849 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1852 if (check_nb_txq(res->value) != 0)
1854 nb_txq = res->value;
1856 else if (!strcmp(res->name, "rxd")) {
1857 if (check_nb_rxd(res->value) != 0)
1859 nb_rxd = res->value;
1860 } else if (!strcmp(res->name, "txd")) {
1861 if (check_nb_txd(res->value) != 0)
1864 nb_txd = res->value;
1866 fprintf(stderr, "Unknown parameter\n");
1874 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1877 static cmdline_parse_token_string_t cmd_config_rx_tx_port =
1878 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1879 static cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1880 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1881 static cmdline_parse_token_string_t cmd_config_rx_tx_all =
1882 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1883 static cmdline_parse_token_string_t cmd_config_rx_tx_name =
1884 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1886 static cmdline_parse_token_num_t cmd_config_rx_tx_value =
1887 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
1889 static cmdline_parse_inst_t cmd_config_rx_tx = {
1890 .f = cmd_config_rx_tx_parsed,
1892 .help_str = "port config all rxq|txq|rxd|txd <value>",
1894 (void *)&cmd_config_rx_tx_port,
1895 (void *)&cmd_config_rx_tx_keyword,
1896 (void *)&cmd_config_rx_tx_all,
1897 (void *)&cmd_config_rx_tx_name,
1898 (void *)&cmd_config_rx_tx_value,
1903 /* *** config max packet length *** */
1904 struct cmd_config_max_pkt_len_result {
1905 cmdline_fixed_string_t port;
1906 cmdline_fixed_string_t keyword;
1907 cmdline_fixed_string_t all;
1908 cmdline_fixed_string_t name;
1913 cmd_config_max_pkt_len_parsed(void *parsed_result,
1914 __rte_unused struct cmdline *cl,
1915 __rte_unused void *data)
1917 struct cmd_config_max_pkt_len_result *res = parsed_result;
1921 if (strcmp(res->name, "max-pkt-len") != 0) {
1922 printf("Unknown parameter\n");
1926 if (!all_ports_stopped()) {
1927 fprintf(stderr, "Please stop all ports first\n");
1931 RTE_ETH_FOREACH_DEV(port_id) {
1932 struct rte_port *port = &ports[port_id];
1934 if (res->value < RTE_ETHER_MIN_LEN) {
1936 "max-pkt-len can not be less than %d\n",
1941 ret = eth_dev_info_get_print_err(port_id, &port->dev_info);
1944 "rte_eth_dev_info_get() failed for port %u\n",
1949 update_mtu_from_frame_size(port_id, res->value);
1954 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1957 static cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1958 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1960 static cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1961 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1963 static cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1964 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1966 static cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1967 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1969 static cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1970 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1973 static cmdline_parse_inst_t cmd_config_max_pkt_len = {
1974 .f = cmd_config_max_pkt_len_parsed,
1976 .help_str = "port config all max-pkt-len <value>",
1978 (void *)&cmd_config_max_pkt_len_port,
1979 (void *)&cmd_config_max_pkt_len_keyword,
1980 (void *)&cmd_config_max_pkt_len_all,
1981 (void *)&cmd_config_max_pkt_len_name,
1982 (void *)&cmd_config_max_pkt_len_value,
1987 /* *** config max LRO aggregated packet size *** */
1988 struct cmd_config_max_lro_pkt_size_result {
1989 cmdline_fixed_string_t port;
1990 cmdline_fixed_string_t keyword;
1991 cmdline_fixed_string_t all;
1992 cmdline_fixed_string_t name;
1997 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1998 __rte_unused struct cmdline *cl,
1999 __rte_unused void *data)
2001 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2004 if (!all_ports_stopped()) {
2005 fprintf(stderr, "Please stop all ports first\n");
2009 RTE_ETH_FOREACH_DEV(pid) {
2010 struct rte_port *port = &ports[pid];
2012 if (!strcmp(res->name, "max-lro-pkt-size")) {
2014 port->dev_conf.rxmode.max_lro_pkt_size)
2017 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2019 fprintf(stderr, "Unknown parameter\n");
2026 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2029 static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
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_keyword =
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_all =
2036 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2038 static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2039 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2040 name, "max-lro-pkt-size");
2041 static cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2042 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2045 static cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2046 .f = cmd_config_max_lro_pkt_size_parsed,
2048 .help_str = "port config all max-lro-pkt-size <value>",
2050 (void *)&cmd_config_max_lro_pkt_size_port,
2051 (void *)&cmd_config_max_lro_pkt_size_keyword,
2052 (void *)&cmd_config_max_lro_pkt_size_all,
2053 (void *)&cmd_config_max_lro_pkt_size_name,
2054 (void *)&cmd_config_max_lro_pkt_size_value,
2059 /* *** configure port MTU *** */
2060 struct cmd_config_mtu_result {
2061 cmdline_fixed_string_t port;
2062 cmdline_fixed_string_t keyword;
2063 cmdline_fixed_string_t mtu;
2069 cmd_config_mtu_parsed(void *parsed_result,
2070 __rte_unused struct cmdline *cl,
2071 __rte_unused void *data)
2073 struct cmd_config_mtu_result *res = parsed_result;
2075 port_mtu_set(res->port_id, res->value);
2078 static cmdline_parse_token_string_t cmd_config_mtu_port =
2079 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2081 static cmdline_parse_token_string_t cmd_config_mtu_keyword =
2082 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2084 static cmdline_parse_token_string_t cmd_config_mtu_mtu =
2085 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2087 static cmdline_parse_token_num_t cmd_config_mtu_port_id =
2088 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2090 static cmdline_parse_token_num_t cmd_config_mtu_value =
2091 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2094 static cmdline_parse_inst_t cmd_config_mtu = {
2095 .f = cmd_config_mtu_parsed,
2097 .help_str = "port config mtu <port_id> <value>",
2099 (void *)&cmd_config_mtu_port,
2100 (void *)&cmd_config_mtu_keyword,
2101 (void *)&cmd_config_mtu_mtu,
2102 (void *)&cmd_config_mtu_port_id,
2103 (void *)&cmd_config_mtu_value,
2108 /* *** configure rx mode *** */
2109 struct cmd_config_rx_mode_flag {
2110 cmdline_fixed_string_t port;
2111 cmdline_fixed_string_t keyword;
2112 cmdline_fixed_string_t all;
2113 cmdline_fixed_string_t name;
2114 cmdline_fixed_string_t value;
2118 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2119 __rte_unused struct cmdline *cl,
2120 __rte_unused void *data)
2122 struct cmd_config_rx_mode_flag *res = parsed_result;
2124 if (!all_ports_stopped()) {
2125 fprintf(stderr, "Please stop all ports first\n");
2129 if (!strcmp(res->name, "drop-en")) {
2130 if (!strcmp(res->value, "on"))
2132 else if (!strcmp(res->value, "off"))
2135 fprintf(stderr, "Unknown parameter\n");
2139 fprintf(stderr, "Unknown parameter\n");
2145 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2148 static cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2149 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2150 static cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2151 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2153 static cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2154 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2155 static cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2156 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2158 static cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2159 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2162 static cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2163 .f = cmd_config_rx_mode_flag_parsed,
2165 .help_str = "port config all drop-en on|off",
2167 (void *)&cmd_config_rx_mode_flag_port,
2168 (void *)&cmd_config_rx_mode_flag_keyword,
2169 (void *)&cmd_config_rx_mode_flag_all,
2170 (void *)&cmd_config_rx_mode_flag_name,
2171 (void *)&cmd_config_rx_mode_flag_value,
2176 /* *** configure rss *** */
2177 struct cmd_config_rss {
2178 cmdline_fixed_string_t port;
2179 cmdline_fixed_string_t keyword;
2180 cmdline_fixed_string_t all;
2181 cmdline_fixed_string_t name;
2182 cmdline_fixed_string_t value;
2186 cmd_config_rss_parsed(void *parsed_result,
2187 __rte_unused struct cmdline *cl,
2188 __rte_unused void *data)
2190 struct cmd_config_rss *res = parsed_result;
2191 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2192 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2193 int use_default = 0;
2194 int all_updated = 1;
2199 if (!strcmp(res->value, "all"))
2200 rss_conf.rss_hf = RTE_ETH_RSS_ETH | RTE_ETH_RSS_VLAN | RTE_ETH_RSS_IP |
2201 RTE_ETH_RSS_TCP | RTE_ETH_RSS_UDP | RTE_ETH_RSS_SCTP |
2202 RTE_ETH_RSS_L2_PAYLOAD | RTE_ETH_RSS_L2TPV3 | RTE_ETH_RSS_ESP |
2203 RTE_ETH_RSS_AH | RTE_ETH_RSS_PFCP | RTE_ETH_RSS_GTPU |
2204 RTE_ETH_RSS_ECPRI | RTE_ETH_RSS_L2TPV2;
2205 else if (!strcmp(res->value, "eth"))
2206 rss_conf.rss_hf = RTE_ETH_RSS_ETH;
2207 else if (!strcmp(res->value, "vlan"))
2208 rss_conf.rss_hf = RTE_ETH_RSS_VLAN;
2209 else if (!strcmp(res->value, "ip"))
2210 rss_conf.rss_hf = RTE_ETH_RSS_IP;
2211 else if (!strcmp(res->value, "udp"))
2212 rss_conf.rss_hf = RTE_ETH_RSS_UDP;
2213 else if (!strcmp(res->value, "tcp"))
2214 rss_conf.rss_hf = RTE_ETH_RSS_TCP;
2215 else if (!strcmp(res->value, "sctp"))
2216 rss_conf.rss_hf = RTE_ETH_RSS_SCTP;
2217 else if (!strcmp(res->value, "ether"))
2218 rss_conf.rss_hf = RTE_ETH_RSS_L2_PAYLOAD;
2219 else if (!strcmp(res->value, "port"))
2220 rss_conf.rss_hf = RTE_ETH_RSS_PORT;
2221 else if (!strcmp(res->value, "vxlan"))
2222 rss_conf.rss_hf = RTE_ETH_RSS_VXLAN;
2223 else if (!strcmp(res->value, "geneve"))
2224 rss_conf.rss_hf = RTE_ETH_RSS_GENEVE;
2225 else if (!strcmp(res->value, "nvgre"))
2226 rss_conf.rss_hf = RTE_ETH_RSS_NVGRE;
2227 else if (!strcmp(res->value, "l3-pre32"))
2228 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2229 else if (!strcmp(res->value, "l3-pre40"))
2230 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2231 else if (!strcmp(res->value, "l3-pre48"))
2232 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2233 else if (!strcmp(res->value, "l3-pre56"))
2234 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2235 else if (!strcmp(res->value, "l3-pre64"))
2236 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2237 else if (!strcmp(res->value, "l3-pre96"))
2238 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2239 else if (!strcmp(res->value, "l3-src-only"))
2240 rss_conf.rss_hf = RTE_ETH_RSS_L3_SRC_ONLY;
2241 else if (!strcmp(res->value, "l3-dst-only"))
2242 rss_conf.rss_hf = RTE_ETH_RSS_L3_DST_ONLY;
2243 else if (!strcmp(res->value, "l4-src-only"))
2244 rss_conf.rss_hf = RTE_ETH_RSS_L4_SRC_ONLY;
2245 else if (!strcmp(res->value, "l4-dst-only"))
2246 rss_conf.rss_hf = RTE_ETH_RSS_L4_DST_ONLY;
2247 else if (!strcmp(res->value, "l2-src-only"))
2248 rss_conf.rss_hf = RTE_ETH_RSS_L2_SRC_ONLY;
2249 else if (!strcmp(res->value, "l2-dst-only"))
2250 rss_conf.rss_hf = RTE_ETH_RSS_L2_DST_ONLY;
2251 else if (!strcmp(res->value, "l2tpv3"))
2252 rss_conf.rss_hf = RTE_ETH_RSS_L2TPV3;
2253 else if (!strcmp(res->value, "esp"))
2254 rss_conf.rss_hf = RTE_ETH_RSS_ESP;
2255 else if (!strcmp(res->value, "ah"))
2256 rss_conf.rss_hf = RTE_ETH_RSS_AH;
2257 else if (!strcmp(res->value, "pfcp"))
2258 rss_conf.rss_hf = RTE_ETH_RSS_PFCP;
2259 else if (!strcmp(res->value, "pppoe"))
2260 rss_conf.rss_hf = RTE_ETH_RSS_PPPOE;
2261 else if (!strcmp(res->value, "gtpu"))
2262 rss_conf.rss_hf = RTE_ETH_RSS_GTPU;
2263 else if (!strcmp(res->value, "ecpri"))
2264 rss_conf.rss_hf = RTE_ETH_RSS_ECPRI;
2265 else if (!strcmp(res->value, "mpls"))
2266 rss_conf.rss_hf = RTE_ETH_RSS_MPLS;
2267 else if (!strcmp(res->value, "ipv4-chksum"))
2268 rss_conf.rss_hf = RTE_ETH_RSS_IPV4_CHKSUM;
2269 else if (!strcmp(res->value, "l2tpv2"))
2270 rss_conf.rss_hf = RTE_ETH_RSS_L2TPV2;
2271 else if (!strcmp(res->value, "none"))
2272 rss_conf.rss_hf = 0;
2273 else if (!strcmp(res->value, "level-default")) {
2274 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2275 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_PMD_DEFAULT);
2276 } else if (!strcmp(res->value, "level-outer")) {
2277 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2278 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_OUTERMOST);
2279 } else if (!strcmp(res->value, "level-inner")) {
2280 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2281 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_INNERMOST);
2282 } else if (!strcmp(res->value, "default"))
2284 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2285 atoi(res->value) < 64)
2286 rss_conf.rss_hf = 1ULL << atoi(res->value);
2288 fprintf(stderr, "Unknown parameter\n");
2291 rss_conf.rss_key = NULL;
2292 /* Update global configuration for RSS types. */
2293 RTE_ETH_FOREACH_DEV(i) {
2294 struct rte_eth_rss_conf local_rss_conf;
2296 ret = eth_dev_info_get_print_err(i, &dev_info);
2301 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2303 local_rss_conf = rss_conf;
2304 local_rss_conf.rss_hf = rss_conf.rss_hf &
2305 dev_info.flow_type_rss_offloads;
2306 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2307 printf("Port %u modified RSS hash function based on hardware support,"
2308 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2309 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2311 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2315 "Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n",
2316 i, -diag, strerror(-diag));
2319 if (all_updated && !use_default) {
2320 rss_hf = rss_conf.rss_hf;
2321 printf("rss_hf %#"PRIx64"\n", rss_hf);
2325 static cmdline_parse_token_string_t cmd_config_rss_port =
2326 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2327 static cmdline_parse_token_string_t cmd_config_rss_keyword =
2328 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2329 static cmdline_parse_token_string_t cmd_config_rss_all =
2330 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2331 static cmdline_parse_token_string_t cmd_config_rss_name =
2332 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2333 static cmdline_parse_token_string_t cmd_config_rss_value =
2334 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2336 static cmdline_parse_inst_t cmd_config_rss = {
2337 .f = cmd_config_rss_parsed,
2339 .help_str = "port config all rss "
2340 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2341 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|ipv4-chksum|l2tpv2|"
2342 "none|level-default|level-outer|level-inner|<flowtype_id>",
2344 (void *)&cmd_config_rss_port,
2345 (void *)&cmd_config_rss_keyword,
2346 (void *)&cmd_config_rss_all,
2347 (void *)&cmd_config_rss_name,
2348 (void *)&cmd_config_rss_value,
2353 /* *** configure rss hash key *** */
2354 struct cmd_config_rss_hash_key {
2355 cmdline_fixed_string_t port;
2356 cmdline_fixed_string_t config;
2358 cmdline_fixed_string_t rss_hash_key;
2359 cmdline_fixed_string_t rss_type;
2360 cmdline_fixed_string_t key;
2364 hexa_digit_to_value(char hexa_digit)
2366 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2367 return (uint8_t) (hexa_digit - '0');
2368 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2369 return (uint8_t) ((hexa_digit - 'a') + 10);
2370 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2371 return (uint8_t) ((hexa_digit - 'A') + 10);
2372 /* Invalid hexa digit */
2377 parse_and_check_key_hexa_digit(char *key, int idx)
2381 hexa_v = hexa_digit_to_value(key[idx]);
2384 "invalid key: character %c at position %d is not a valid hexa digit\n",
2390 cmd_config_rss_hash_key_parsed(void *parsed_result,
2391 __rte_unused struct cmdline *cl,
2392 __rte_unused void *data)
2394 struct cmd_config_rss_hash_key *res = parsed_result;
2395 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2399 struct rte_eth_dev_info dev_info;
2400 uint8_t hash_key_size;
2404 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2408 if (dev_info.hash_key_size > 0 &&
2409 dev_info.hash_key_size <= sizeof(hash_key))
2410 hash_key_size = dev_info.hash_key_size;
2413 "dev_info did not provide a valid hash key size\n");
2416 /* Check the length of the RSS hash key */
2417 key_len = strlen(res->key);
2418 if (key_len != (hash_key_size * 2)) {
2420 "key length: %d invalid - key must be a string of %d hexa-decimal numbers\n",
2421 (int)key_len, hash_key_size * 2);
2424 /* Translate RSS hash key into binary representation */
2425 for (i = 0; i < hash_key_size; i++) {
2426 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2429 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2432 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2434 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2438 static cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2439 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2440 static cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2441 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2443 static cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2444 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2446 static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2447 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2448 rss_hash_key, "rss-hash-key");
2449 static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2450 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2451 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2452 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2453 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2454 "ipv6-tcp-ex#ipv6-udp-ex#"
2455 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2456 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2457 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls#l2tpv2");
2458 static cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2459 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2461 static cmdline_parse_inst_t cmd_config_rss_hash_key = {
2462 .f = cmd_config_rss_hash_key_parsed,
2464 .help_str = "port config <port_id> rss-hash-key "
2465 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2466 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2467 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2468 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2469 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2470 "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls|l2tpv2 "
2471 "<string of hex digits (variable length, NIC dependent)>",
2473 (void *)&cmd_config_rss_hash_key_port,
2474 (void *)&cmd_config_rss_hash_key_config,
2475 (void *)&cmd_config_rss_hash_key_port_id,
2476 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2477 (void *)&cmd_config_rss_hash_key_rss_type,
2478 (void *)&cmd_config_rss_hash_key_value,
2483 /* *** cleanup txq mbufs *** */
2484 struct cmd_cleanup_txq_mbufs_result {
2485 cmdline_fixed_string_t port;
2486 cmdline_fixed_string_t keyword;
2487 cmdline_fixed_string_t name;
2494 cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2495 __rte_unused struct cmdline *cl,
2496 __rte_unused void *data)
2498 struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2499 uint16_t port_id = res->port_id;
2500 uint16_t queue_id = res->queue_id;
2501 uint32_t free_cnt = res->free_cnt;
2502 struct rte_eth_txq_info qinfo;
2505 if (test_done == 0) {
2506 fprintf(stderr, "Please stop forwarding first\n");
2510 if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2511 fprintf(stderr, "Failed to get port %u Tx queue %u info\n",
2516 if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2517 fprintf(stderr, "Tx queue %u not started\n", queue_id);
2521 ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2524 "Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n",
2525 port_id, queue_id, strerror(-ret), ret);
2529 printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2530 port_id, queue_id, ret);
2533 static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2534 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2536 static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2537 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2539 static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2540 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2542 static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2543 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2545 static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2546 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2548 static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2549 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2552 static cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2553 .f = cmd_cleanup_txq_mbufs_parsed,
2555 .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2557 (void *)&cmd_cleanup_txq_mbufs_port,
2558 (void *)&cmd_cleanup_txq_mbufs_cleanup,
2559 (void *)&cmd_cleanup_txq_mbufs_port_id,
2560 (void *)&cmd_cleanup_txq_mbufs_txq,
2561 (void *)&cmd_cleanup_txq_mbufs_queue_id,
2562 (void *)&cmd_cleanup_txq_mbufs_free_cnt,
2567 /* *** configure port rxq/txq ring size *** */
2568 struct cmd_config_rxtx_ring_size {
2569 cmdline_fixed_string_t port;
2570 cmdline_fixed_string_t config;
2572 cmdline_fixed_string_t rxtxq;
2574 cmdline_fixed_string_t rsize;
2579 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2580 __rte_unused struct cmdline *cl,
2581 __rte_unused void *data)
2583 struct cmd_config_rxtx_ring_size *res = parsed_result;
2584 struct rte_port *port;
2587 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2590 if (res->portid == (portid_t)RTE_PORT_ALL) {
2591 fprintf(stderr, "Invalid port id\n");
2595 port = &ports[res->portid];
2597 if (!strcmp(res->rxtxq, "rxq"))
2599 else if (!strcmp(res->rxtxq, "txq"))
2602 fprintf(stderr, "Unknown parameter\n");
2606 if (isrx && rx_queue_id_is_invalid(res->qid))
2608 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2611 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2613 "Invalid rx ring_size, must > rx_free_thresh: %d\n",
2619 port->nb_rx_desc[res->qid] = res->size;
2621 port->nb_tx_desc[res->qid] = res->size;
2623 cmd_reconfig_device_queue(res->portid, 0, 1);
2626 static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2627 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2629 static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2630 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2632 static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2633 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2634 portid, RTE_UINT16);
2635 static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2636 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2638 static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2639 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2641 static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2642 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2643 rsize, "ring_size");
2644 static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2645 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2648 static cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2649 .f = cmd_config_rxtx_ring_size_parsed,
2651 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2653 (void *)&cmd_config_rxtx_ring_size_port,
2654 (void *)&cmd_config_rxtx_ring_size_config,
2655 (void *)&cmd_config_rxtx_ring_size_portid,
2656 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2657 (void *)&cmd_config_rxtx_ring_size_qid,
2658 (void *)&cmd_config_rxtx_ring_size_rsize,
2659 (void *)&cmd_config_rxtx_ring_size_size,
2664 /* *** configure port rxq/txq start/stop *** */
2665 struct cmd_config_rxtx_queue {
2666 cmdline_fixed_string_t port;
2668 cmdline_fixed_string_t rxtxq;
2670 cmdline_fixed_string_t opname;
2674 cmd_config_rxtx_queue_parsed(void *parsed_result,
2675 __rte_unused struct cmdline *cl,
2676 __rte_unused void *data)
2678 struct cmd_config_rxtx_queue *res = parsed_result;
2679 struct rte_port *port;
2685 if (test_done == 0) {
2686 fprintf(stderr, "Please stop forwarding first\n");
2690 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2693 if (port_is_started(res->portid) != 1) {
2694 fprintf(stderr, "Please start port %u first\n", res->portid);
2698 if (!strcmp(res->rxtxq, "rxq"))
2700 else if (!strcmp(res->rxtxq, "txq"))
2703 fprintf(stderr, "Unknown parameter\n");
2707 if (isrx && rx_queue_id_is_invalid(res->qid))
2709 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2712 if (!strcmp(res->opname, "start"))
2714 else if (!strcmp(res->opname, "stop"))
2717 fprintf(stderr, "Unknown parameter\n");
2721 if (isstart && isrx)
2722 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2723 else if (!isstart && isrx)
2724 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2725 else if (isstart && !isrx)
2726 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2728 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2730 if (ret == -ENOTSUP) {
2731 fprintf(stderr, "Function not supported in PMD\n");
2735 port = &ports[res->portid];
2736 state = isrx ? &port->rxq[res->qid].state : &port->txq[res->qid].state;
2737 *state = isstart ? RTE_ETH_QUEUE_STATE_STARTED :
2738 RTE_ETH_QUEUE_STATE_STOPPED;
2741 static cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2742 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2743 static cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2744 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2745 static cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2746 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2747 static cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2748 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2749 static cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2750 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2753 static cmdline_parse_inst_t cmd_config_rxtx_queue = {
2754 .f = cmd_config_rxtx_queue_parsed,
2756 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2758 (void *)&cmd_config_rxtx_queue_port,
2759 (void *)&cmd_config_rxtx_queue_portid,
2760 (void *)&cmd_config_rxtx_queue_rxtxq,
2761 (void *)&cmd_config_rxtx_queue_qid,
2762 (void *)&cmd_config_rxtx_queue_opname,
2767 /* *** configure port rxq/txq deferred start on/off *** */
2768 struct cmd_config_deferred_start_rxtx_queue {
2769 cmdline_fixed_string_t port;
2771 cmdline_fixed_string_t rxtxq;
2773 cmdline_fixed_string_t opname;
2774 cmdline_fixed_string_t state;
2778 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2779 __rte_unused struct cmdline *cl,
2780 __rte_unused void *data)
2782 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2783 struct rte_port *port;
2786 uint8_t needreconfig = 0;
2788 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2791 if (port_is_started(res->port_id) != 0) {
2792 fprintf(stderr, "Please stop port %u first\n", res->port_id);
2796 port = &ports[res->port_id];
2798 isrx = !strcmp(res->rxtxq, "rxq");
2800 if (isrx && rx_queue_id_is_invalid(res->qid))
2802 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2805 ison = !strcmp(res->state, "on");
2807 if (isrx && port->rxq[res->qid].conf.rx_deferred_start != ison) {
2808 port->rxq[res->qid].conf.rx_deferred_start = ison;
2810 } else if (!isrx && port->txq[res->qid].conf.tx_deferred_start != ison) {
2811 port->txq[res->qid].conf.tx_deferred_start = ison;
2816 cmd_reconfig_device_queue(res->port_id, 0, 1);
2819 static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2820 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2822 static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2823 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2824 port_id, RTE_UINT16);
2825 static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2826 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2828 static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2829 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2831 static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2832 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2833 opname, "deferred_start");
2834 static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2835 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2838 static cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2839 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2841 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2843 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2844 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2845 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2846 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2847 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2848 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2853 /* *** configure port rxq/txq setup *** */
2854 struct cmd_setup_rxtx_queue {
2855 cmdline_fixed_string_t port;
2857 cmdline_fixed_string_t rxtxq;
2859 cmdline_fixed_string_t setup;
2862 /* Common CLI fields for queue setup */
2863 static cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2864 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2865 static cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2866 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2867 static cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2868 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2869 static cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2870 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2871 static cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2872 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2875 cmd_setup_rxtx_queue_parsed(
2876 void *parsed_result,
2877 __rte_unused struct cmdline *cl,
2878 __rte_unused void *data)
2880 struct cmd_setup_rxtx_queue *res = parsed_result;
2881 struct rte_port *port;
2882 struct rte_mempool *mp;
2883 unsigned int socket_id;
2887 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2890 if (res->portid == (portid_t)RTE_PORT_ALL) {
2891 fprintf(stderr, "Invalid port id\n");
2895 if (!strcmp(res->rxtxq, "rxq"))
2897 else if (!strcmp(res->rxtxq, "txq"))
2900 fprintf(stderr, "Unknown parameter\n");
2904 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2905 fprintf(stderr, "Invalid rx queue\n");
2907 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2908 fprintf(stderr, "Invalid tx queue\n");
2912 port = &ports[res->portid];
2914 socket_id = rxring_numa[res->portid];
2915 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2916 socket_id = port->socket_id;
2918 mp = mbuf_pool_find(socket_id, 0);
2921 "Failed to setup RX queue: No mempool allocation on the socket %d\n",
2922 rxring_numa[res->portid]);
2925 ret = rx_queue_setup(res->portid,
2927 port->nb_rx_desc[res->qid],
2929 &port->rxq[res->qid].conf,
2932 fprintf(stderr, "Failed to setup RX queue\n");
2934 socket_id = txring_numa[res->portid];
2935 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2936 socket_id = port->socket_id;
2938 if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
2940 "Failed to setup TX queue: not enough descriptors\n");
2943 ret = rte_eth_tx_queue_setup(res->portid,
2945 port->nb_tx_desc[res->qid],
2947 &port->txq[res->qid].conf);
2949 fprintf(stderr, "Failed to setup TX queue\n");
2953 static cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2954 .f = cmd_setup_rxtx_queue_parsed,
2956 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2958 (void *)&cmd_setup_rxtx_queue_port,
2959 (void *)&cmd_setup_rxtx_queue_portid,
2960 (void *)&cmd_setup_rxtx_queue_rxtxq,
2961 (void *)&cmd_setup_rxtx_queue_qid,
2962 (void *)&cmd_setup_rxtx_queue_setup,
2968 /* *** Configure RSS RETA *** */
2969 struct cmd_config_rss_reta {
2970 cmdline_fixed_string_t port;
2971 cmdline_fixed_string_t keyword;
2973 cmdline_fixed_string_t name;
2974 cmdline_fixed_string_t list_name;
2975 cmdline_fixed_string_t list_of_items;
2979 parse_reta_config(const char *str,
2980 struct rte_eth_rss_reta_entry64 *reta_conf,
2981 uint16_t nb_entries)
2985 uint16_t hash_index, idx, shift;
2988 const char *p, *p0 = str;
2995 unsigned long int_fld[_NUM_FLD];
2996 char *str_fld[_NUM_FLD];
2998 while ((p = strchr(p0,'(')) != NULL) {
3000 if((p0 = strchr(p,')')) == NULL)
3004 if(size >= sizeof(s))
3007 snprintf(s, sizeof(s), "%.*s", size, p);
3008 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
3010 for (i = 0; i < _NUM_FLD; i++) {
3012 int_fld[i] = strtoul(str_fld[i], &end, 0);
3013 if (errno != 0 || end == str_fld[i] ||
3018 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
3019 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
3021 if (hash_index >= nb_entries) {
3022 fprintf(stderr, "Invalid RETA hash index=%d\n",
3027 idx = hash_index / RTE_ETH_RETA_GROUP_SIZE;
3028 shift = hash_index % RTE_ETH_RETA_GROUP_SIZE;
3029 reta_conf[idx].mask |= (1ULL << shift);
3030 reta_conf[idx].reta[shift] = nb_queue;
3037 cmd_set_rss_reta_parsed(void *parsed_result,
3038 __rte_unused struct cmdline *cl,
3039 __rte_unused void *data)
3042 struct rte_eth_dev_info dev_info;
3043 struct rte_eth_rss_reta_entry64 reta_conf[8];
3044 struct cmd_config_rss_reta *res = parsed_result;
3046 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3050 if (dev_info.reta_size == 0) {
3052 "Redirection table size is 0 which is invalid for RSS\n");
3055 printf("The reta size of port %d is %u\n",
3056 res->port_id, dev_info.reta_size);
3057 if (dev_info.reta_size > RTE_ETH_RSS_RETA_SIZE_512) {
3059 "Currently do not support more than %u entries of redirection table\n",
3060 RTE_ETH_RSS_RETA_SIZE_512);
3064 memset(reta_conf, 0, sizeof(reta_conf));
3065 if (!strcmp(res->list_name, "reta")) {
3066 if (parse_reta_config(res->list_of_items, reta_conf,
3067 dev_info.reta_size)) {
3069 "Invalid RSS Redirection Table config entered\n");
3072 ret = rte_eth_dev_rss_reta_update(res->port_id,
3073 reta_conf, dev_info.reta_size);
3076 "Bad redirection table parameter, return code = %d\n",
3081 static cmdline_parse_token_string_t cmd_config_rss_reta_port =
3082 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3083 static cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3084 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3085 static cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3086 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3087 static cmdline_parse_token_string_t cmd_config_rss_reta_name =
3088 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3089 static cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3090 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3091 static cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3092 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3094 static cmdline_parse_inst_t cmd_config_rss_reta = {
3095 .f = cmd_set_rss_reta_parsed,
3097 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3099 (void *)&cmd_config_rss_reta_port,
3100 (void *)&cmd_config_rss_reta_keyword,
3101 (void *)&cmd_config_rss_reta_port_id,
3102 (void *)&cmd_config_rss_reta_name,
3103 (void *)&cmd_config_rss_reta_list_name,
3104 (void *)&cmd_config_rss_reta_list_of_items,
3109 /* *** SHOW PORT RETA INFO *** */
3110 struct cmd_showport_reta {
3111 cmdline_fixed_string_t show;
3112 cmdline_fixed_string_t port;
3114 cmdline_fixed_string_t rss;
3115 cmdline_fixed_string_t reta;
3117 cmdline_fixed_string_t list_of_items;
3121 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3122 uint16_t nb_entries,
3126 const char *p, *p0 = str;
3131 uint16_t num = (nb_entries + RTE_ETH_RETA_GROUP_SIZE - 1) /
3132 RTE_ETH_RETA_GROUP_SIZE;
3135 p = strchr(p0, '(');
3139 p0 = strchr(p, ')');
3143 if (size >= sizeof(s)) {
3145 "The string size exceeds the internal buffer size\n");
3148 snprintf(s, sizeof(s), "%.*s", size, p);
3149 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3150 if (ret <= 0 || ret != num) {
3152 "The bits of masks do not match the number of reta entries: %u\n",
3156 for (i = 0; i < ret; i++)
3157 conf[i].mask = (uint64_t)strtoull(str_fld[i], &end, 0);
3163 cmd_showport_reta_parsed(void *parsed_result,
3164 __rte_unused struct cmdline *cl,
3165 __rte_unused void *data)
3167 struct cmd_showport_reta *res = parsed_result;
3168 struct rte_eth_rss_reta_entry64 reta_conf[8];
3169 struct rte_eth_dev_info dev_info;
3170 uint16_t max_reta_size;
3173 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3177 max_reta_size = RTE_MIN(dev_info.reta_size, RTE_ETH_RSS_RETA_SIZE_512);
3178 if (res->size == 0 || res->size > max_reta_size) {
3179 fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n",
3180 res->size, max_reta_size);
3184 memset(reta_conf, 0, sizeof(reta_conf));
3185 if (showport_parse_reta_config(reta_conf, res->size,
3186 res->list_of_items) < 0) {
3187 fprintf(stderr, "Invalid string: %s for reta masks\n",
3188 res->list_of_items);
3191 port_rss_reta_info(res->port_id, reta_conf, res->size);
3194 static cmdline_parse_token_string_t cmd_showport_reta_show =
3195 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3196 static cmdline_parse_token_string_t cmd_showport_reta_port =
3197 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3198 static cmdline_parse_token_num_t cmd_showport_reta_port_id =
3199 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3200 static cmdline_parse_token_string_t cmd_showport_reta_rss =
3201 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3202 static cmdline_parse_token_string_t cmd_showport_reta_reta =
3203 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3204 static cmdline_parse_token_num_t cmd_showport_reta_size =
3205 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3206 static cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3207 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3208 list_of_items, NULL);
3210 static cmdline_parse_inst_t cmd_showport_reta = {
3211 .f = cmd_showport_reta_parsed,
3213 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3215 (void *)&cmd_showport_reta_show,
3216 (void *)&cmd_showport_reta_port,
3217 (void *)&cmd_showport_reta_port_id,
3218 (void *)&cmd_showport_reta_rss,
3219 (void *)&cmd_showport_reta_reta,
3220 (void *)&cmd_showport_reta_size,
3221 (void *)&cmd_showport_reta_list_of_items,
3226 /* *** Show RSS hash configuration *** */
3227 struct cmd_showport_rss_hash {
3228 cmdline_fixed_string_t show;
3229 cmdline_fixed_string_t port;
3231 cmdline_fixed_string_t rss_hash;
3232 cmdline_fixed_string_t rss_type;
3233 cmdline_fixed_string_t key; /* optional argument */
3236 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3237 __rte_unused struct cmdline *cl,
3240 struct cmd_showport_rss_hash *res = parsed_result;
3242 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3245 static cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3246 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3247 static cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3248 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3249 static cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3250 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3252 static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3253 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3255 static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3256 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3258 static cmdline_parse_inst_t cmd_showport_rss_hash = {
3259 .f = cmd_showport_rss_hash_parsed,
3261 .help_str = "show port <port_id> rss-hash",
3263 (void *)&cmd_showport_rss_hash_show,
3264 (void *)&cmd_showport_rss_hash_port,
3265 (void *)&cmd_showport_rss_hash_port_id,
3266 (void *)&cmd_showport_rss_hash_rss_hash,
3271 static cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3272 .f = cmd_showport_rss_hash_parsed,
3274 .help_str = "show port <port_id> rss-hash key",
3276 (void *)&cmd_showport_rss_hash_show,
3277 (void *)&cmd_showport_rss_hash_port,
3278 (void *)&cmd_showport_rss_hash_port_id,
3279 (void *)&cmd_showport_rss_hash_rss_hash,
3280 (void *)&cmd_showport_rss_hash_rss_key,
3285 /* *** Configure DCB *** */
3286 struct cmd_config_dcb {
3287 cmdline_fixed_string_t port;
3288 cmdline_fixed_string_t config;
3290 cmdline_fixed_string_t dcb;
3291 cmdline_fixed_string_t vt;
3292 cmdline_fixed_string_t vt_en;
3294 cmdline_fixed_string_t pfc;
3295 cmdline_fixed_string_t pfc_en;
3299 cmd_config_dcb_parsed(void *parsed_result,
3300 __rte_unused struct cmdline *cl,
3301 __rte_unused void *data)
3303 struct cmd_config_dcb *res = parsed_result;
3304 struct rte_eth_dcb_info dcb_info;
3305 portid_t port_id = res->port_id;
3306 struct rte_port *port;
3310 port = &ports[port_id];
3311 /** Check if the port is not started **/
3312 if (port->port_status != RTE_PORT_STOPPED) {
3313 fprintf(stderr, "Please stop port %d first\n", port_id);
3317 if ((res->num_tcs != RTE_ETH_4_TCS) && (res->num_tcs != RTE_ETH_8_TCS)) {
3319 "The invalid number of traffic class, only 4 or 8 allowed.\n");
3323 if (nb_fwd_lcores < res->num_tcs) {
3325 "nb_cores shouldn't be less than number of TCs.\n");
3329 /* Check whether the port supports the report of DCB info. */
3330 ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3331 if (ret == -ENOTSUP) {
3332 fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n");
3336 if (!strncmp(res->pfc_en, "on", 2))
3341 /* DCB in VT mode */
3342 if (!strncmp(res->vt_en, "on", 2))
3343 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3344 (enum rte_eth_nb_tcs)res->num_tcs,
3347 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3348 (enum rte_eth_nb_tcs)res->num_tcs,
3351 fprintf(stderr, "Cannot initialize network ports.\n");
3357 cmd_reconfig_device_queue(port_id, 1, 1);
3360 static cmdline_parse_token_string_t cmd_config_dcb_port =
3361 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3362 static cmdline_parse_token_string_t cmd_config_dcb_config =
3363 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3364 static cmdline_parse_token_num_t cmd_config_dcb_port_id =
3365 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3366 static cmdline_parse_token_string_t cmd_config_dcb_dcb =
3367 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3368 static cmdline_parse_token_string_t cmd_config_dcb_vt =
3369 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3370 static cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3371 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3372 static cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3373 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3374 static cmdline_parse_token_string_t cmd_config_dcb_pfc =
3375 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3376 static cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3377 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3379 static cmdline_parse_inst_t cmd_config_dcb = {
3380 .f = cmd_config_dcb_parsed,
3382 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3384 (void *)&cmd_config_dcb_port,
3385 (void *)&cmd_config_dcb_config,
3386 (void *)&cmd_config_dcb_port_id,
3387 (void *)&cmd_config_dcb_dcb,
3388 (void *)&cmd_config_dcb_vt,
3389 (void *)&cmd_config_dcb_vt_en,
3390 (void *)&cmd_config_dcb_num_tcs,
3391 (void *)&cmd_config_dcb_pfc,
3392 (void *)&cmd_config_dcb_pfc_en,
3397 /* *** configure number of packets per burst *** */
3398 struct cmd_config_burst {
3399 cmdline_fixed_string_t port;
3400 cmdline_fixed_string_t keyword;
3401 cmdline_fixed_string_t all;
3402 cmdline_fixed_string_t name;
3407 cmd_config_burst_parsed(void *parsed_result,
3408 __rte_unused struct cmdline *cl,
3409 __rte_unused void *data)
3411 struct cmd_config_burst *res = parsed_result;
3412 struct rte_eth_dev_info dev_info;
3413 uint16_t rec_nb_pkts;
3416 if (!all_ports_stopped()) {
3417 fprintf(stderr, "Please stop all ports first\n");
3421 if (!strcmp(res->name, "burst")) {
3422 if (res->value == 0) {
3423 /* If user gives a value of zero, query the PMD for
3424 * its recommended Rx burst size. Testpmd uses a single
3425 * size for all ports, so assume all ports are the same
3426 * NIC model and use the values from Port 0.
3428 ret = eth_dev_info_get_print_err(0, &dev_info);
3432 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3434 if (rec_nb_pkts == 0) {
3435 printf("PMD does not recommend a burst size.\n"
3436 "User provided value must be between"
3437 " 1 and %d\n", MAX_PKT_BURST);
3439 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3440 printf("PMD recommended burst size of %d"
3441 " exceeds maximum value of %d\n",
3442 rec_nb_pkts, MAX_PKT_BURST);
3445 printf("Using PMD-provided burst value of %d\n",
3447 nb_pkt_per_burst = rec_nb_pkts;
3448 } else if (res->value > MAX_PKT_BURST) {
3449 fprintf(stderr, "burst must be >= 1 && <= %d\n",
3453 nb_pkt_per_burst = res->value;
3455 fprintf(stderr, "Unknown parameter\n");
3461 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3464 static cmdline_parse_token_string_t cmd_config_burst_port =
3465 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3466 static cmdline_parse_token_string_t cmd_config_burst_keyword =
3467 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3468 static cmdline_parse_token_string_t cmd_config_burst_all =
3469 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3470 static cmdline_parse_token_string_t cmd_config_burst_name =
3471 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3472 static cmdline_parse_token_num_t cmd_config_burst_value =
3473 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3475 static cmdline_parse_inst_t cmd_config_burst = {
3476 .f = cmd_config_burst_parsed,
3478 .help_str = "port config all burst <value>",
3480 (void *)&cmd_config_burst_port,
3481 (void *)&cmd_config_burst_keyword,
3482 (void *)&cmd_config_burst_all,
3483 (void *)&cmd_config_burst_name,
3484 (void *)&cmd_config_burst_value,
3489 /* *** configure rx/tx queues *** */
3490 struct cmd_config_thresh {
3491 cmdline_fixed_string_t port;
3492 cmdline_fixed_string_t keyword;
3493 cmdline_fixed_string_t all;
3494 cmdline_fixed_string_t name;
3499 cmd_config_thresh_parsed(void *parsed_result,
3500 __rte_unused struct cmdline *cl,
3501 __rte_unused void *data)
3503 struct cmd_config_thresh *res = parsed_result;
3505 if (!all_ports_stopped()) {
3506 fprintf(stderr, "Please stop all ports first\n");
3510 if (!strcmp(res->name, "txpt"))
3511 tx_pthresh = res->value;
3512 else if(!strcmp(res->name, "txht"))
3513 tx_hthresh = res->value;
3514 else if(!strcmp(res->name, "txwt"))
3515 tx_wthresh = res->value;
3516 else if(!strcmp(res->name, "rxpt"))
3517 rx_pthresh = res->value;
3518 else if(!strcmp(res->name, "rxht"))
3519 rx_hthresh = res->value;
3520 else if(!strcmp(res->name, "rxwt"))
3521 rx_wthresh = res->value;
3523 fprintf(stderr, "Unknown parameter\n");
3529 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3532 static cmdline_parse_token_string_t cmd_config_thresh_port =
3533 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3534 static cmdline_parse_token_string_t cmd_config_thresh_keyword =
3535 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3536 static cmdline_parse_token_string_t cmd_config_thresh_all =
3537 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3538 static cmdline_parse_token_string_t cmd_config_thresh_name =
3539 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3540 "txpt#txht#txwt#rxpt#rxht#rxwt");
3541 static cmdline_parse_token_num_t cmd_config_thresh_value =
3542 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3544 static cmdline_parse_inst_t cmd_config_thresh = {
3545 .f = cmd_config_thresh_parsed,
3547 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3549 (void *)&cmd_config_thresh_port,
3550 (void *)&cmd_config_thresh_keyword,
3551 (void *)&cmd_config_thresh_all,
3552 (void *)&cmd_config_thresh_name,
3553 (void *)&cmd_config_thresh_value,
3558 /* *** configure free/rs threshold *** */
3559 struct cmd_config_threshold {
3560 cmdline_fixed_string_t port;
3561 cmdline_fixed_string_t keyword;
3562 cmdline_fixed_string_t all;
3563 cmdline_fixed_string_t name;
3568 cmd_config_threshold_parsed(void *parsed_result,
3569 __rte_unused struct cmdline *cl,
3570 __rte_unused void *data)
3572 struct cmd_config_threshold *res = parsed_result;
3574 if (!all_ports_stopped()) {
3575 fprintf(stderr, "Please stop all ports first\n");
3579 if (!strcmp(res->name, "txfreet"))
3580 tx_free_thresh = res->value;
3581 else if (!strcmp(res->name, "txrst"))
3582 tx_rs_thresh = res->value;
3583 else if (!strcmp(res->name, "rxfreet"))
3584 rx_free_thresh = res->value;
3586 fprintf(stderr, "Unknown parameter\n");
3592 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3595 static cmdline_parse_token_string_t cmd_config_threshold_port =
3596 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3597 static cmdline_parse_token_string_t cmd_config_threshold_keyword =
3598 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3600 static cmdline_parse_token_string_t cmd_config_threshold_all =
3601 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3602 static cmdline_parse_token_string_t cmd_config_threshold_name =
3603 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3604 "txfreet#txrst#rxfreet");
3605 static cmdline_parse_token_num_t cmd_config_threshold_value =
3606 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3608 static cmdline_parse_inst_t cmd_config_threshold = {
3609 .f = cmd_config_threshold_parsed,
3611 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3613 (void *)&cmd_config_threshold_port,
3614 (void *)&cmd_config_threshold_keyword,
3615 (void *)&cmd_config_threshold_all,
3616 (void *)&cmd_config_threshold_name,
3617 (void *)&cmd_config_threshold_value,
3623 struct cmd_stop_result {
3624 cmdline_fixed_string_t stop;
3627 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3628 __rte_unused struct cmdline *cl,
3629 __rte_unused void *data)
3631 stop_packet_forwarding();
3634 static cmdline_parse_token_string_t cmd_stop_stop =
3635 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3637 static cmdline_parse_inst_t cmd_stop = {
3638 .f = cmd_stop_parsed,
3640 .help_str = "stop: Stop packet forwarding",
3642 (void *)&cmd_stop_stop,
3647 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3650 parse_item_list(const char *str, const char *item_name, unsigned int max_items,
3651 unsigned int *parsed_items, int check_unique_values)
3653 unsigned int nb_item;
3661 * First parse all items in the list and store their value.
3666 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3668 if ((c >= '0') && (c <= '9')) {
3669 value = (unsigned int) (value * 10 + (c - '0'));
3674 fprintf(stderr, "character %c is not a decimal digit\n", c);
3678 fprintf(stderr, "No valid value before comma\n");
3681 if (nb_item < max_items) {
3682 parsed_items[nb_item] = value;
3688 if (nb_item >= max_items) {
3689 fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
3690 item_name, nb_item + 1, max_items);
3693 parsed_items[nb_item++] = value;
3694 if (! check_unique_values)
3698 * Then, check that all values in the list are different.
3699 * No optimization here...
3701 for (i = 0; i < nb_item; i++) {
3702 for (j = i + 1; j < nb_item; j++) {
3703 if (parsed_items[j] == parsed_items[i]) {
3705 "duplicated %s %u at index %u and %u\n",
3706 item_name, parsed_items[i], i, j);
3714 struct cmd_set_list_result {
3715 cmdline_fixed_string_t cmd_keyword;
3716 cmdline_fixed_string_t list_name;
3717 cmdline_fixed_string_t list_of_items;
3720 static void cmd_set_list_parsed(void *parsed_result,
3721 __rte_unused struct cmdline *cl,
3722 __rte_unused void *data)
3724 struct cmd_set_list_result *res;
3726 unsigned int lcorelist[RTE_MAX_LCORE];
3727 unsigned int portlist[RTE_MAX_ETHPORTS];
3729 unsigned int nb_item;
3731 if (test_done == 0) {
3732 fprintf(stderr, "Please stop forwarding first\n");
3736 res = parsed_result;
3737 if (!strcmp(res->list_name, "corelist")) {
3738 nb_item = parse_item_list(res->list_of_items, "core",
3740 parsed_items.lcorelist, 1);
3742 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3747 if (!strcmp(res->list_name, "portlist")) {
3748 nb_item = parse_item_list(res->list_of_items, "port",
3750 parsed_items.portlist, 1);
3752 set_fwd_ports_list(parsed_items.portlist, nb_item);
3758 static cmdline_parse_token_string_t cmd_set_list_keyword =
3759 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3761 static cmdline_parse_token_string_t cmd_set_list_name =
3762 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3763 "corelist#portlist");
3764 static cmdline_parse_token_string_t cmd_set_list_of_items =
3765 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3768 static cmdline_parse_inst_t cmd_set_fwd_list = {
3769 .f = cmd_set_list_parsed,
3771 .help_str = "set corelist|portlist <list0[,list1]*>",
3773 (void *)&cmd_set_list_keyword,
3774 (void *)&cmd_set_list_name,
3775 (void *)&cmd_set_list_of_items,
3780 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3782 struct cmd_setmask_result {
3783 cmdline_fixed_string_t set;
3784 cmdline_fixed_string_t mask;
3788 static void cmd_set_mask_parsed(void *parsed_result,
3789 __rte_unused struct cmdline *cl,
3790 __rte_unused void *data)
3792 struct cmd_setmask_result *res = parsed_result;
3794 if (test_done == 0) {
3795 fprintf(stderr, "Please stop forwarding first\n");
3798 if (!strcmp(res->mask, "coremask")) {
3799 set_fwd_lcores_mask(res->hexavalue);
3801 } else if (!strcmp(res->mask, "portmask")) {
3802 set_fwd_ports_mask(res->hexavalue);
3807 static cmdline_parse_token_string_t cmd_setmask_set =
3808 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3809 static cmdline_parse_token_string_t cmd_setmask_mask =
3810 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3811 "coremask#portmask");
3812 static cmdline_parse_token_num_t cmd_setmask_value =
3813 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3815 static cmdline_parse_inst_t cmd_set_fwd_mask = {
3816 .f = cmd_set_mask_parsed,
3818 .help_str = "set coremask|portmask <hexadecimal value>",
3820 (void *)&cmd_setmask_set,
3821 (void *)&cmd_setmask_mask,
3822 (void *)&cmd_setmask_value,
3828 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3830 struct cmd_set_result {
3831 cmdline_fixed_string_t set;
3832 cmdline_fixed_string_t what;
3836 static void cmd_set_parsed(void *parsed_result,
3837 __rte_unused struct cmdline *cl,
3838 __rte_unused void *data)
3840 struct cmd_set_result *res = parsed_result;
3841 if (!strcmp(res->what, "nbport")) {
3842 set_fwd_ports_number(res->value);
3844 } else if (!strcmp(res->what, "nbcore")) {
3845 set_fwd_lcores_number(res->value);
3847 } else if (!strcmp(res->what, "burst"))
3848 set_nb_pkt_per_burst(res->value);
3849 else if (!strcmp(res->what, "verbose"))
3850 set_verbose_level(res->value);
3853 static cmdline_parse_token_string_t cmd_set_set =
3854 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3855 static cmdline_parse_token_string_t cmd_set_what =
3856 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3857 "nbport#nbcore#burst#verbose");
3858 static cmdline_parse_token_num_t cmd_set_value =
3859 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3861 static cmdline_parse_inst_t cmd_set_numbers = {
3862 .f = cmd_set_parsed,
3864 .help_str = "set nbport|nbcore|burst|verbose <value>",
3866 (void *)&cmd_set_set,
3867 (void *)&cmd_set_what,
3868 (void *)&cmd_set_value,
3873 /* *** SET LOG LEVEL CONFIGURATION *** */
3875 struct cmd_set_log_result {
3876 cmdline_fixed_string_t set;
3877 cmdline_fixed_string_t log;
3878 cmdline_fixed_string_t type;
3883 cmd_set_log_parsed(void *parsed_result,
3884 __rte_unused struct cmdline *cl,
3885 __rte_unused void *data)
3887 struct cmd_set_log_result *res;
3890 res = parsed_result;
3891 if (!strcmp(res->type, "global"))
3892 rte_log_set_global_level(res->level);
3894 ret = rte_log_set_level_regexp(res->type, res->level);
3896 fprintf(stderr, "Unable to set log level\n");
3900 static cmdline_parse_token_string_t cmd_set_log_set =
3901 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3902 static cmdline_parse_token_string_t cmd_set_log_log =
3903 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3904 static cmdline_parse_token_string_t cmd_set_log_type =
3905 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3906 static cmdline_parse_token_num_t cmd_set_log_level =
3907 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3909 static cmdline_parse_inst_t cmd_set_log = {
3910 .f = cmd_set_log_parsed,
3912 .help_str = "set log global|<type> <level>",
3914 (void *)&cmd_set_log_set,
3915 (void *)&cmd_set_log_log,
3916 (void *)&cmd_set_log_type,
3917 (void *)&cmd_set_log_level,
3922 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3924 struct cmd_set_rxoffs_result {
3925 cmdline_fixed_string_t cmd_keyword;
3926 cmdline_fixed_string_t rxoffs;
3927 cmdline_fixed_string_t seg_offsets;
3931 cmd_set_rxoffs_parsed(void *parsed_result,
3932 __rte_unused struct cmdline *cl,
3933 __rte_unused void *data)
3935 struct cmd_set_rxoffs_result *res;
3936 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3937 unsigned int nb_segs;
3939 res = parsed_result;
3940 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3941 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3943 set_rx_pkt_offsets(seg_offsets, nb_segs);
3944 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3947 static cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3948 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3949 cmd_keyword, "set");
3950 static cmdline_parse_token_string_t cmd_set_rxoffs_name =
3951 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3953 static cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3954 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3957 static cmdline_parse_inst_t cmd_set_rxoffs = {
3958 .f = cmd_set_rxoffs_parsed,
3960 .help_str = "set rxoffs <len0[,len1]*>",
3962 (void *)&cmd_set_rxoffs_keyword,
3963 (void *)&cmd_set_rxoffs_name,
3964 (void *)&cmd_set_rxoffs_offsets,
3969 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3971 struct cmd_set_rxpkts_result {
3972 cmdline_fixed_string_t cmd_keyword;
3973 cmdline_fixed_string_t rxpkts;
3974 cmdline_fixed_string_t seg_lengths;
3978 cmd_set_rxpkts_parsed(void *parsed_result,
3979 __rte_unused struct cmdline *cl,
3980 __rte_unused void *data)
3982 struct cmd_set_rxpkts_result *res;
3983 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3984 unsigned int nb_segs;
3986 res = parsed_result;
3987 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3988 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3990 set_rx_pkt_segments(seg_lengths, nb_segs);
3991 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3994 static cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3995 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3996 cmd_keyword, "set");
3997 static cmdline_parse_token_string_t cmd_set_rxpkts_name =
3998 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4000 static cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
4001 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4004 static cmdline_parse_inst_t cmd_set_rxpkts = {
4005 .f = cmd_set_rxpkts_parsed,
4007 .help_str = "set rxpkts <len0[,len1]*>",
4009 (void *)&cmd_set_rxpkts_keyword,
4010 (void *)&cmd_set_rxpkts_name,
4011 (void *)&cmd_set_rxpkts_lengths,
4016 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
4018 struct cmd_set_txpkts_result {
4019 cmdline_fixed_string_t cmd_keyword;
4020 cmdline_fixed_string_t txpkts;
4021 cmdline_fixed_string_t seg_lengths;
4025 cmd_set_txpkts_parsed(void *parsed_result,
4026 __rte_unused struct cmdline *cl,
4027 __rte_unused void *data)
4029 struct cmd_set_txpkts_result *res;
4030 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
4031 unsigned int nb_segs;
4033 res = parsed_result;
4034 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4035 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4037 set_tx_pkt_segments(seg_lengths, nb_segs);
4040 static cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4041 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4042 cmd_keyword, "set");
4043 static cmdline_parse_token_string_t cmd_set_txpkts_name =
4044 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4046 static cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4047 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4050 static cmdline_parse_inst_t cmd_set_txpkts = {
4051 .f = cmd_set_txpkts_parsed,
4053 .help_str = "set txpkts <len0[,len1]*>",
4055 (void *)&cmd_set_txpkts_keyword,
4056 (void *)&cmd_set_txpkts_name,
4057 (void *)&cmd_set_txpkts_lengths,
4062 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4064 struct cmd_set_txsplit_result {
4065 cmdline_fixed_string_t cmd_keyword;
4066 cmdline_fixed_string_t txsplit;
4067 cmdline_fixed_string_t mode;
4071 cmd_set_txsplit_parsed(void *parsed_result,
4072 __rte_unused struct cmdline *cl,
4073 __rte_unused void *data)
4075 struct cmd_set_txsplit_result *res;
4077 res = parsed_result;
4078 set_tx_pkt_split(res->mode);
4081 static cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4082 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4083 cmd_keyword, "set");
4084 static cmdline_parse_token_string_t cmd_set_txsplit_name =
4085 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4086 txsplit, "txsplit");
4087 static cmdline_parse_token_string_t cmd_set_txsplit_mode =
4088 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4091 static cmdline_parse_inst_t cmd_set_txsplit = {
4092 .f = cmd_set_txsplit_parsed,
4094 .help_str = "set txsplit on|off|rand",
4096 (void *)&cmd_set_txsplit_keyword,
4097 (void *)&cmd_set_txsplit_name,
4098 (void *)&cmd_set_txsplit_mode,
4103 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4105 struct cmd_set_txtimes_result {
4106 cmdline_fixed_string_t cmd_keyword;
4107 cmdline_fixed_string_t txtimes;
4108 cmdline_fixed_string_t tx_times;
4112 cmd_set_txtimes_parsed(void *parsed_result,
4113 __rte_unused struct cmdline *cl,
4114 __rte_unused void *data)
4116 struct cmd_set_txtimes_result *res;
4117 unsigned int tx_times[2] = {0, 0};
4118 unsigned int n_times;
4120 res = parsed_result;
4121 n_times = parse_item_list(res->tx_times, "tx times",
4124 set_tx_pkt_times(tx_times);
4127 static cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4128 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4129 cmd_keyword, "set");
4130 static cmdline_parse_token_string_t cmd_set_txtimes_name =
4131 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4132 txtimes, "txtimes");
4133 static cmdline_parse_token_string_t cmd_set_txtimes_value =
4134 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4137 static cmdline_parse_inst_t cmd_set_txtimes = {
4138 .f = cmd_set_txtimes_parsed,
4140 .help_str = "set txtimes <inter_burst>,<intra_burst>",
4142 (void *)&cmd_set_txtimes_keyword,
4143 (void *)&cmd_set_txtimes_name,
4144 (void *)&cmd_set_txtimes_value,
4149 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4150 struct cmd_rx_vlan_filter_all_result {
4151 cmdline_fixed_string_t rx_vlan;
4152 cmdline_fixed_string_t what;
4153 cmdline_fixed_string_t all;
4158 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4159 __rte_unused struct cmdline *cl,
4160 __rte_unused void *data)
4162 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4164 if (!strcmp(res->what, "add"))
4165 rx_vlan_all_filter_set(res->port_id, 1);
4167 rx_vlan_all_filter_set(res->port_id, 0);
4170 static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4171 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4172 rx_vlan, "rx_vlan");
4173 static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4174 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4176 static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4177 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4179 static cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4180 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4181 port_id, RTE_UINT16);
4183 static cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4184 .f = cmd_rx_vlan_filter_all_parsed,
4186 .help_str = "rx_vlan add|rm all <port_id>: "
4187 "Add/Remove all identifiers to/from the set of VLAN "
4188 "identifiers filtered by a port",
4190 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4191 (void *)&cmd_rx_vlan_filter_all_what,
4192 (void *)&cmd_rx_vlan_filter_all_all,
4193 (void *)&cmd_rx_vlan_filter_all_portid,
4198 /* *** VLAN OFFLOAD SET ON A PORT *** */
4199 struct cmd_vlan_offload_result {
4200 cmdline_fixed_string_t vlan;
4201 cmdline_fixed_string_t set;
4202 cmdline_fixed_string_t vlan_type;
4203 cmdline_fixed_string_t what;
4204 cmdline_fixed_string_t on;
4205 cmdline_fixed_string_t port_id;
4209 cmd_vlan_offload_parsed(void *parsed_result,
4210 __rte_unused struct cmdline *cl,
4211 __rte_unused void *data)
4214 struct cmd_vlan_offload_result *res = parsed_result;
4217 portid_t port_id = 0;
4221 len = strnlen(str, STR_TOKEN_SIZE);
4223 /* Get port_id first */
4231 tmp = strtoul(str, NULL, 0);
4232 /* If port_id greater that what portid_t can represent, return */
4233 if(tmp >= RTE_MAX_ETHPORTS)
4235 port_id = (portid_t)tmp;
4237 if (!strcmp(res->on, "on"))
4242 if (!strcmp(res->what, "strip"))
4243 rx_vlan_strip_set(port_id, on);
4244 else if(!strcmp(res->what, "stripq")){
4245 uint16_t queue_id = 0;
4247 /* No queue_id, return */
4249 fprintf(stderr, "must specify (port,queue_id)\n");
4252 tmp = strtoul(str + i + 1, NULL, 0);
4253 /* If queue_id greater that what 16-bits can represent, return */
4257 queue_id = (uint16_t)tmp;
4258 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4260 else if (!strcmp(res->what, "filter"))
4261 rx_vlan_filter_set(port_id, on);
4262 else if (!strcmp(res->what, "qinq_strip"))
4263 rx_vlan_qinq_strip_set(port_id, on);
4265 vlan_extend_set(port_id, on);
4270 static cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4271 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4273 static cmdline_parse_token_string_t cmd_vlan_offload_set =
4274 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4276 static cmdline_parse_token_string_t cmd_vlan_offload_what =
4277 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4278 what, "strip#filter#qinq_strip#extend#stripq");
4279 static cmdline_parse_token_string_t cmd_vlan_offload_on =
4280 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4282 static cmdline_parse_token_string_t cmd_vlan_offload_portid =
4283 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4286 static cmdline_parse_inst_t cmd_vlan_offload = {
4287 .f = cmd_vlan_offload_parsed,
4289 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4290 "<port_id[,queue_id]>: "
4291 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4293 (void *)&cmd_vlan_offload_vlan,
4294 (void *)&cmd_vlan_offload_set,
4295 (void *)&cmd_vlan_offload_what,
4296 (void *)&cmd_vlan_offload_on,
4297 (void *)&cmd_vlan_offload_portid,
4302 /* *** VLAN TPID SET ON A PORT *** */
4303 struct cmd_vlan_tpid_result {
4304 cmdline_fixed_string_t vlan;
4305 cmdline_fixed_string_t set;
4306 cmdline_fixed_string_t vlan_type;
4307 cmdline_fixed_string_t what;
4313 cmd_vlan_tpid_parsed(void *parsed_result,
4314 __rte_unused struct cmdline *cl,
4315 __rte_unused void *data)
4317 struct cmd_vlan_tpid_result *res = parsed_result;
4318 enum rte_vlan_type vlan_type;
4320 if (!strcmp(res->vlan_type, "inner"))
4321 vlan_type = RTE_ETH_VLAN_TYPE_INNER;
4322 else if (!strcmp(res->vlan_type, "outer"))
4323 vlan_type = RTE_ETH_VLAN_TYPE_OUTER;
4325 fprintf(stderr, "Unknown vlan type\n");
4328 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4331 static cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4332 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4334 static cmdline_parse_token_string_t cmd_vlan_tpid_set =
4335 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4337 static cmdline_parse_token_string_t cmd_vlan_type =
4338 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4339 vlan_type, "inner#outer");
4340 static cmdline_parse_token_string_t cmd_vlan_tpid_what =
4341 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4343 static cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4344 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4346 static cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4347 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4348 port_id, RTE_UINT16);
4350 static cmdline_parse_inst_t cmd_vlan_tpid = {
4351 .f = cmd_vlan_tpid_parsed,
4353 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4354 "Set the VLAN Ether type",
4356 (void *)&cmd_vlan_tpid_vlan,
4357 (void *)&cmd_vlan_tpid_set,
4358 (void *)&cmd_vlan_type,
4359 (void *)&cmd_vlan_tpid_what,
4360 (void *)&cmd_vlan_tpid_tpid,
4361 (void *)&cmd_vlan_tpid_portid,
4366 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4367 struct cmd_rx_vlan_filter_result {
4368 cmdline_fixed_string_t rx_vlan;
4369 cmdline_fixed_string_t what;
4375 cmd_rx_vlan_filter_parsed(void *parsed_result,
4376 __rte_unused struct cmdline *cl,
4377 __rte_unused void *data)
4379 struct cmd_rx_vlan_filter_result *res = parsed_result;
4381 if (!strcmp(res->what, "add"))
4382 rx_vft_set(res->port_id, res->vlan_id, 1);
4384 rx_vft_set(res->port_id, res->vlan_id, 0);
4387 static cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4388 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4389 rx_vlan, "rx_vlan");
4390 static cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4391 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4393 static cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4394 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4395 vlan_id, RTE_UINT16);
4396 static cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4397 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4398 port_id, RTE_UINT16);
4400 static cmdline_parse_inst_t cmd_rx_vlan_filter = {
4401 .f = cmd_rx_vlan_filter_parsed,
4403 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4404 "Add/Remove a VLAN identifier to/from the set of VLAN "
4405 "identifiers filtered by a port",
4407 (void *)&cmd_rx_vlan_filter_rx_vlan,
4408 (void *)&cmd_rx_vlan_filter_what,
4409 (void *)&cmd_rx_vlan_filter_vlanid,
4410 (void *)&cmd_rx_vlan_filter_portid,
4415 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4416 struct cmd_tx_vlan_set_result {
4417 cmdline_fixed_string_t tx_vlan;
4418 cmdline_fixed_string_t set;
4424 cmd_tx_vlan_set_parsed(void *parsed_result,
4425 __rte_unused struct cmdline *cl,
4426 __rte_unused void *data)
4428 struct cmd_tx_vlan_set_result *res = parsed_result;
4430 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4433 if (!port_is_stopped(res->port_id)) {
4434 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4438 tx_vlan_set(res->port_id, res->vlan_id);
4440 cmd_reconfig_device_queue(res->port_id, 1, 1);
4443 static cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4444 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4445 tx_vlan, "tx_vlan");
4446 static cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4447 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4449 static cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4450 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4451 port_id, RTE_UINT16);
4452 static cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4453 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4454 vlan_id, RTE_UINT16);
4456 static cmdline_parse_inst_t cmd_tx_vlan_set = {
4457 .f = cmd_tx_vlan_set_parsed,
4459 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4460 "Enable hardware insertion of a single VLAN header "
4461 "with a given TAG Identifier in packets sent on a port",
4463 (void *)&cmd_tx_vlan_set_tx_vlan,
4464 (void *)&cmd_tx_vlan_set_set,
4465 (void *)&cmd_tx_vlan_set_portid,
4466 (void *)&cmd_tx_vlan_set_vlanid,
4471 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4472 struct cmd_tx_vlan_set_qinq_result {
4473 cmdline_fixed_string_t tx_vlan;
4474 cmdline_fixed_string_t set;
4477 uint16_t vlan_id_outer;
4481 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4482 __rte_unused struct cmdline *cl,
4483 __rte_unused void *data)
4485 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4487 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4490 if (!port_is_stopped(res->port_id)) {
4491 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4495 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4497 cmd_reconfig_device_queue(res->port_id, 1, 1);
4500 static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4501 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4502 tx_vlan, "tx_vlan");
4503 static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4504 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4506 static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4507 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4508 port_id, RTE_UINT16);
4509 static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4510 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4511 vlan_id, RTE_UINT16);
4512 static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4513 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4514 vlan_id_outer, RTE_UINT16);
4516 static cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4517 .f = cmd_tx_vlan_set_qinq_parsed,
4519 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4520 "Enable hardware insertion of double VLAN header "
4521 "with given TAG Identifiers in packets sent on a port",
4523 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4524 (void *)&cmd_tx_vlan_set_qinq_set,
4525 (void *)&cmd_tx_vlan_set_qinq_portid,
4526 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4527 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4532 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4533 struct cmd_tx_vlan_set_pvid_result {
4534 cmdline_fixed_string_t tx_vlan;
4535 cmdline_fixed_string_t set;
4536 cmdline_fixed_string_t pvid;
4539 cmdline_fixed_string_t mode;
4543 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4544 __rte_unused struct cmdline *cl,
4545 __rte_unused void *data)
4547 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4549 if (strcmp(res->mode, "on") == 0)
4550 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4552 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4555 static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4556 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4557 tx_vlan, "tx_vlan");
4558 static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4559 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4561 static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4562 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4564 static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4565 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4566 port_id, RTE_UINT16);
4567 static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4568 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4569 vlan_id, RTE_UINT16);
4570 static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4571 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4574 static cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4575 .f = cmd_tx_vlan_set_pvid_parsed,
4577 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4579 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4580 (void *)&cmd_tx_vlan_set_pvid_set,
4581 (void *)&cmd_tx_vlan_set_pvid_pvid,
4582 (void *)&cmd_tx_vlan_set_pvid_port_id,
4583 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4584 (void *)&cmd_tx_vlan_set_pvid_mode,
4589 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4590 struct cmd_tx_vlan_reset_result {
4591 cmdline_fixed_string_t tx_vlan;
4592 cmdline_fixed_string_t reset;
4597 cmd_tx_vlan_reset_parsed(void *parsed_result,
4598 __rte_unused struct cmdline *cl,
4599 __rte_unused void *data)
4601 struct cmd_tx_vlan_reset_result *res = parsed_result;
4603 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4606 if (!port_is_stopped(res->port_id)) {
4607 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4611 tx_vlan_reset(res->port_id);
4613 cmd_reconfig_device_queue(res->port_id, 1, 1);
4616 static cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4617 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4618 tx_vlan, "tx_vlan");
4619 static cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4620 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4622 static cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4623 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4624 port_id, RTE_UINT16);
4626 static cmdline_parse_inst_t cmd_tx_vlan_reset = {
4627 .f = cmd_tx_vlan_reset_parsed,
4629 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4630 "VLAN header in packets sent on a port",
4632 (void *)&cmd_tx_vlan_reset_tx_vlan,
4633 (void *)&cmd_tx_vlan_reset_reset,
4634 (void *)&cmd_tx_vlan_reset_portid,
4640 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4641 struct cmd_csum_result {
4642 cmdline_fixed_string_t csum;
4643 cmdline_fixed_string_t mode;
4644 cmdline_fixed_string_t proto;
4645 cmdline_fixed_string_t hwsw;
4650 csum_show(int port_id)
4652 struct rte_eth_dev_info dev_info;
4653 uint64_t tx_offloads;
4656 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4657 printf("Parse tunnel is %s\n",
4658 (ports[port_id].parse_tunnel) ? "on" : "off");
4659 printf("IP checksum offload is %s\n",
4660 (tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4661 printf("UDP checksum offload is %s\n",
4662 (tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4663 printf("TCP checksum offload is %s\n",
4664 (tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4665 printf("SCTP checksum offload is %s\n",
4666 (tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4667 printf("Outer-Ip checksum offload is %s\n",
4668 (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4669 printf("Outer-Udp checksum offload is %s\n",
4670 (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4672 /* display warnings if configuration is not supported by the NIC */
4673 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4677 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) &&
4678 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4680 "Warning: hardware IP checksum enabled but not supported by port %d\n",
4683 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) &&
4684 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) == 0) {
4686 "Warning: hardware UDP checksum enabled but not supported by port %d\n",
4689 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) &&
4690 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) == 0) {
4692 "Warning: hardware TCP checksum enabled but not supported by port %d\n",
4695 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) &&
4696 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4698 "Warning: hardware SCTP checksum enabled but not supported by port %d\n",
4701 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4702 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4704 "Warning: hardware outer IP checksum enabled but not supported by port %d\n",
4707 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4708 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)
4711 "Warning: hardware outer UDP checksum enabled but not supported by port %d\n",
4717 cmd_config_queue_tx_offloads(struct rte_port *port)
4721 /* Apply queue tx offloads configuration */
4722 for (k = 0; k < port->dev_info.max_tx_queues; k++)
4723 port->txq[k].conf.offloads =
4724 port->dev_conf.txmode.offloads;
4728 cmd_csum_parsed(void *parsed_result,
4729 __rte_unused struct cmdline *cl,
4730 __rte_unused void *data)
4732 struct cmd_csum_result *res = parsed_result;
4734 uint64_t csum_offloads = 0;
4735 struct rte_eth_dev_info dev_info;
4738 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4739 fprintf(stderr, "invalid port %d\n", res->port_id);
4742 if (!port_is_stopped(res->port_id)) {
4743 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4747 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4751 if (!strcmp(res->mode, "set")) {
4753 if (!strcmp(res->hwsw, "hw"))
4756 if (!strcmp(res->proto, "ip")) {
4757 if (hw == 0 || (dev_info.tx_offload_capa &
4758 RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)) {
4759 csum_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
4762 "IP checksum offload is not supported by port %u\n",
4765 } else if (!strcmp(res->proto, "udp")) {
4766 if (hw == 0 || (dev_info.tx_offload_capa &
4767 RTE_ETH_TX_OFFLOAD_UDP_CKSUM)) {
4768 csum_offloads |= RTE_ETH_TX_OFFLOAD_UDP_CKSUM;
4771 "UDP checksum offload is not supported by port %u\n",
4774 } else if (!strcmp(res->proto, "tcp")) {
4775 if (hw == 0 || (dev_info.tx_offload_capa &
4776 RTE_ETH_TX_OFFLOAD_TCP_CKSUM)) {
4777 csum_offloads |= RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
4780 "TCP checksum offload is not supported by port %u\n",
4783 } else if (!strcmp(res->proto, "sctp")) {
4784 if (hw == 0 || (dev_info.tx_offload_capa &
4785 RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) {
4786 csum_offloads |= RTE_ETH_TX_OFFLOAD_SCTP_CKSUM;
4789 "SCTP checksum offload is not supported by port %u\n",
4792 } else if (!strcmp(res->proto, "outer-ip")) {
4793 if (hw == 0 || (dev_info.tx_offload_capa &
4794 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4796 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4799 "Outer IP checksum offload is not supported by port %u\n",
4802 } else if (!strcmp(res->proto, "outer-udp")) {
4803 if (hw == 0 || (dev_info.tx_offload_capa &
4804 RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4806 RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM;
4809 "Outer UDP checksum offload is not supported by port %u\n",
4815 ports[res->port_id].dev_conf.txmode.offloads |=
4818 ports[res->port_id].dev_conf.txmode.offloads &=
4821 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4823 csum_show(res->port_id);
4825 cmd_reconfig_device_queue(res->port_id, 1, 1);
4828 static cmdline_parse_token_string_t cmd_csum_csum =
4829 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4831 static cmdline_parse_token_string_t cmd_csum_mode =
4832 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4834 static cmdline_parse_token_string_t cmd_csum_proto =
4835 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4836 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4837 static cmdline_parse_token_string_t cmd_csum_hwsw =
4838 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4840 static cmdline_parse_token_num_t cmd_csum_portid =
4841 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4842 port_id, RTE_UINT16);
4844 static cmdline_parse_inst_t cmd_csum_set = {
4845 .f = cmd_csum_parsed,
4847 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4848 "Enable/Disable hardware calculation of L3/L4 checksum when "
4849 "using csum forward engine",
4851 (void *)&cmd_csum_csum,
4852 (void *)&cmd_csum_mode,
4853 (void *)&cmd_csum_proto,
4854 (void *)&cmd_csum_hwsw,
4855 (void *)&cmd_csum_portid,
4860 static cmdline_parse_token_string_t cmd_csum_mode_show =
4861 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4864 static cmdline_parse_inst_t cmd_csum_show = {
4865 .f = cmd_csum_parsed,
4867 .help_str = "csum show <port_id>: Show checksum offload configuration",
4869 (void *)&cmd_csum_csum,
4870 (void *)&cmd_csum_mode_show,
4871 (void *)&cmd_csum_portid,
4876 /* Enable/disable tunnel parsing */
4877 struct cmd_csum_tunnel_result {
4878 cmdline_fixed_string_t csum;
4879 cmdline_fixed_string_t parse;
4880 cmdline_fixed_string_t onoff;
4885 cmd_csum_tunnel_parsed(void *parsed_result,
4886 __rte_unused struct cmdline *cl,
4887 __rte_unused void *data)
4889 struct cmd_csum_tunnel_result *res = parsed_result;
4891 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4894 if (!strcmp(res->onoff, "on"))
4895 ports[res->port_id].parse_tunnel = 1;
4897 ports[res->port_id].parse_tunnel = 0;
4899 csum_show(res->port_id);
4902 static cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4903 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4905 static cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4906 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4907 parse, "parse-tunnel");
4908 static cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4909 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4911 static cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4912 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4913 port_id, RTE_UINT16);
4915 static cmdline_parse_inst_t cmd_csum_tunnel = {
4916 .f = cmd_csum_tunnel_parsed,
4918 .help_str = "csum parse-tunnel on|off <port_id>: "
4919 "Enable/Disable parsing of tunnels for csum engine",
4921 (void *)&cmd_csum_tunnel_csum,
4922 (void *)&cmd_csum_tunnel_parse,
4923 (void *)&cmd_csum_tunnel_onoff,
4924 (void *)&cmd_csum_tunnel_portid,
4929 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4930 struct cmd_tso_set_result {
4931 cmdline_fixed_string_t tso;
4932 cmdline_fixed_string_t mode;
4938 cmd_tso_set_parsed(void *parsed_result,
4939 __rte_unused struct cmdline *cl,
4940 __rte_unused void *data)
4942 struct cmd_tso_set_result *res = parsed_result;
4943 struct rte_eth_dev_info dev_info;
4946 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4948 if (!port_is_stopped(res->port_id)) {
4949 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4953 if (!strcmp(res->mode, "set"))
4954 ports[res->port_id].tso_segsz = res->tso_segsz;
4956 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4960 if ((ports[res->port_id].tso_segsz != 0) &&
4961 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) {
4962 fprintf(stderr, "Error: TSO is not supported by port %d\n",
4967 if (ports[res->port_id].tso_segsz == 0) {
4968 ports[res->port_id].dev_conf.txmode.offloads &=
4969 ~RTE_ETH_TX_OFFLOAD_TCP_TSO;
4970 printf("TSO for non-tunneled packets is disabled\n");
4972 ports[res->port_id].dev_conf.txmode.offloads |=
4973 RTE_ETH_TX_OFFLOAD_TCP_TSO;
4974 printf("TSO segment size for non-tunneled packets is %d\n",
4975 ports[res->port_id].tso_segsz);
4977 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4979 /* display warnings if configuration is not supported by the NIC */
4980 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4984 if ((ports[res->port_id].tso_segsz != 0) &&
4985 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) {
4987 "Warning: TSO enabled but not supported by port %d\n",
4991 cmd_reconfig_device_queue(res->port_id, 1, 1);
4994 static cmdline_parse_token_string_t cmd_tso_set_tso =
4995 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4997 static cmdline_parse_token_string_t cmd_tso_set_mode =
4998 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5000 static cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
5001 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
5002 tso_segsz, RTE_UINT16);
5003 static cmdline_parse_token_num_t cmd_tso_set_portid =
5004 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
5005 port_id, RTE_UINT16);
5007 static cmdline_parse_inst_t cmd_tso_set = {
5008 .f = cmd_tso_set_parsed,
5010 .help_str = "tso set <tso_segsz> <port_id>: "
5011 "Set TSO segment size of non-tunneled packets for csum engine "
5014 (void *)&cmd_tso_set_tso,
5015 (void *)&cmd_tso_set_mode,
5016 (void *)&cmd_tso_set_tso_segsz,
5017 (void *)&cmd_tso_set_portid,
5022 static cmdline_parse_token_string_t cmd_tso_show_mode =
5023 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5027 static cmdline_parse_inst_t cmd_tso_show = {
5028 .f = cmd_tso_set_parsed,
5030 .help_str = "tso show <port_id>: "
5031 "Show TSO segment size of non-tunneled packets for csum engine",
5033 (void *)&cmd_tso_set_tso,
5034 (void *)&cmd_tso_show_mode,
5035 (void *)&cmd_tso_set_portid,
5040 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5041 struct cmd_tunnel_tso_set_result {
5042 cmdline_fixed_string_t tso;
5043 cmdline_fixed_string_t mode;
5048 static struct rte_eth_dev_info
5049 check_tunnel_tso_nic_support(portid_t port_id)
5051 struct rte_eth_dev_info dev_info;
5053 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
5056 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO))
5058 "Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n",
5060 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO))
5062 "Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n",
5064 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO))
5066 "Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n",
5068 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO))
5070 "Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n",
5072 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IP_TNL_TSO))
5074 "Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n",
5076 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO))
5078 "Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n",
5084 cmd_tunnel_tso_set_parsed(void *parsed_result,
5085 __rte_unused struct cmdline *cl,
5086 __rte_unused void *data)
5088 struct cmd_tunnel_tso_set_result *res = parsed_result;
5089 struct rte_eth_dev_info dev_info;
5091 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5093 if (!port_is_stopped(res->port_id)) {
5094 fprintf(stderr, "Please stop port %d first\n", res->port_id);
5098 if (!strcmp(res->mode, "set"))
5099 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5101 dev_info = check_tunnel_tso_nic_support(res->port_id);
5102 if (ports[res->port_id].tunnel_tso_segsz == 0) {
5103 ports[res->port_id].dev_conf.txmode.offloads &=
5104 ~(RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5105 RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5106 RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5107 RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5108 RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5109 RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO);
5110 printf("TSO for tunneled packets is disabled\n");
5112 uint64_t tso_offloads = (RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5113 RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5114 RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5115 RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5116 RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5117 RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO);
5119 ports[res->port_id].dev_conf.txmode.offloads |=
5120 (tso_offloads & dev_info.tx_offload_capa);
5121 printf("TSO segment size for tunneled packets is %d\n",
5122 ports[res->port_id].tunnel_tso_segsz);
5124 /* Below conditions are needed to make it work:
5125 * (1) tunnel TSO is supported by the NIC;
5126 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5128 * (3) for tunneled pkts with outer L3 of IPv4,
5129 * "csum set outer-ip" must be set to hw, because after tso,
5130 * total_len of outer IP header is changed, and the checksum
5131 * of outer IP header calculated by sw should be wrong; that
5132 * is not necessary for IPv6 tunneled pkts because there's no
5133 * checksum in IP header anymore.
5136 if (!ports[res->port_id].parse_tunnel)
5138 "Warning: csum parse_tunnel must be set so that tunneled packets are recognized\n");
5139 if (!(ports[res->port_id].dev_conf.txmode.offloads &
5140 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5142 "Warning: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n");
5145 cmd_config_queue_tx_offloads(&ports[res->port_id]);
5146 cmd_reconfig_device_queue(res->port_id, 1, 1);
5149 static cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5150 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5152 static cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5153 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5155 static cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5156 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5157 tso_segsz, RTE_UINT16);
5158 static cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5159 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5160 port_id, RTE_UINT16);
5162 static cmdline_parse_inst_t cmd_tunnel_tso_set = {
5163 .f = cmd_tunnel_tso_set_parsed,
5165 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5166 "Set TSO segment size of tunneled packets for csum engine "
5169 (void *)&cmd_tunnel_tso_set_tso,
5170 (void *)&cmd_tunnel_tso_set_mode,
5171 (void *)&cmd_tunnel_tso_set_tso_segsz,
5172 (void *)&cmd_tunnel_tso_set_portid,
5177 static cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5178 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5182 static cmdline_parse_inst_t cmd_tunnel_tso_show = {
5183 .f = cmd_tunnel_tso_set_parsed,
5185 .help_str = "tunnel_tso show <port_id> "
5186 "Show TSO segment size of tunneled packets for csum engine",
5188 (void *)&cmd_tunnel_tso_set_tso,
5189 (void *)&cmd_tunnel_tso_show_mode,
5190 (void *)&cmd_tunnel_tso_set_portid,
5196 /* *** SET GRO FOR A PORT *** */
5197 struct cmd_gro_enable_result {
5198 cmdline_fixed_string_t cmd_set;
5199 cmdline_fixed_string_t cmd_port;
5200 cmdline_fixed_string_t cmd_keyword;
5201 cmdline_fixed_string_t cmd_onoff;
5206 cmd_gro_enable_parsed(void *parsed_result,
5207 __rte_unused struct cmdline *cl,
5208 __rte_unused void *data)
5210 struct cmd_gro_enable_result *res;
5212 res = parsed_result;
5213 if (!strcmp(res->cmd_keyword, "gro"))
5214 setup_gro(res->cmd_onoff, res->cmd_pid);
5217 static cmdline_parse_token_string_t cmd_gro_enable_set =
5218 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5220 static cmdline_parse_token_string_t cmd_gro_enable_port =
5221 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5222 cmd_keyword, "port");
5223 static cmdline_parse_token_num_t cmd_gro_enable_pid =
5224 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5225 cmd_pid, RTE_UINT16);
5226 static cmdline_parse_token_string_t cmd_gro_enable_keyword =
5227 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5228 cmd_keyword, "gro");
5229 static cmdline_parse_token_string_t cmd_gro_enable_onoff =
5230 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5231 cmd_onoff, "on#off");
5233 static cmdline_parse_inst_t cmd_gro_enable = {
5234 .f = cmd_gro_enable_parsed,
5236 .help_str = "set port <port_id> gro on|off",
5238 (void *)&cmd_gro_enable_set,
5239 (void *)&cmd_gro_enable_port,
5240 (void *)&cmd_gro_enable_pid,
5241 (void *)&cmd_gro_enable_keyword,
5242 (void *)&cmd_gro_enable_onoff,
5247 /* *** DISPLAY GRO CONFIGURATION *** */
5248 struct cmd_gro_show_result {
5249 cmdline_fixed_string_t cmd_show;
5250 cmdline_fixed_string_t cmd_port;
5251 cmdline_fixed_string_t cmd_keyword;
5256 cmd_gro_show_parsed(void *parsed_result,
5257 __rte_unused struct cmdline *cl,
5258 __rte_unused void *data)
5260 struct cmd_gro_show_result *res;
5262 res = parsed_result;
5263 if (!strcmp(res->cmd_keyword, "gro"))
5264 show_gro(res->cmd_pid);
5267 static cmdline_parse_token_string_t cmd_gro_show_show =
5268 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5270 static cmdline_parse_token_string_t cmd_gro_show_port =
5271 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5273 static cmdline_parse_token_num_t cmd_gro_show_pid =
5274 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5275 cmd_pid, RTE_UINT16);
5276 static cmdline_parse_token_string_t cmd_gro_show_keyword =
5277 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5278 cmd_keyword, "gro");
5280 static cmdline_parse_inst_t cmd_gro_show = {
5281 .f = cmd_gro_show_parsed,
5283 .help_str = "show port <port_id> gro",
5285 (void *)&cmd_gro_show_show,
5286 (void *)&cmd_gro_show_port,
5287 (void *)&cmd_gro_show_pid,
5288 (void *)&cmd_gro_show_keyword,
5293 /* *** SET FLUSH CYCLES FOR GRO *** */
5294 struct cmd_gro_flush_result {
5295 cmdline_fixed_string_t cmd_set;
5296 cmdline_fixed_string_t cmd_keyword;
5297 cmdline_fixed_string_t cmd_flush;
5302 cmd_gro_flush_parsed(void *parsed_result,
5303 __rte_unused struct cmdline *cl,
5304 __rte_unused void *data)
5306 struct cmd_gro_flush_result *res;
5308 res = parsed_result;
5309 if ((!strcmp(res->cmd_keyword, "gro")) &&
5310 (!strcmp(res->cmd_flush, "flush")))
5311 setup_gro_flush_cycles(res->cmd_cycles);
5314 static cmdline_parse_token_string_t cmd_gro_flush_set =
5315 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5317 static cmdline_parse_token_string_t cmd_gro_flush_keyword =
5318 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5319 cmd_keyword, "gro");
5320 static cmdline_parse_token_string_t cmd_gro_flush_flush =
5321 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5322 cmd_flush, "flush");
5323 static cmdline_parse_token_num_t cmd_gro_flush_cycles =
5324 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5325 cmd_cycles, RTE_UINT8);
5327 static cmdline_parse_inst_t cmd_gro_flush = {
5328 .f = cmd_gro_flush_parsed,
5330 .help_str = "set gro flush <cycles>",
5332 (void *)&cmd_gro_flush_set,
5333 (void *)&cmd_gro_flush_keyword,
5334 (void *)&cmd_gro_flush_flush,
5335 (void *)&cmd_gro_flush_cycles,
5339 #endif /* RTE_LIB_GRO */
5342 /* *** ENABLE/DISABLE GSO *** */
5343 struct cmd_gso_enable_result {
5344 cmdline_fixed_string_t cmd_set;
5345 cmdline_fixed_string_t cmd_port;
5346 cmdline_fixed_string_t cmd_keyword;
5347 cmdline_fixed_string_t cmd_mode;
5352 cmd_gso_enable_parsed(void *parsed_result,
5353 __rte_unused struct cmdline *cl,
5354 __rte_unused void *data)
5356 struct cmd_gso_enable_result *res;
5358 res = parsed_result;
5359 if (!strcmp(res->cmd_keyword, "gso"))
5360 setup_gso(res->cmd_mode, res->cmd_pid);
5363 static cmdline_parse_token_string_t cmd_gso_enable_set =
5364 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5366 static cmdline_parse_token_string_t cmd_gso_enable_port =
5367 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5369 static cmdline_parse_token_string_t cmd_gso_enable_keyword =
5370 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5371 cmd_keyword, "gso");
5372 static cmdline_parse_token_string_t cmd_gso_enable_mode =
5373 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5374 cmd_mode, "on#off");
5375 static cmdline_parse_token_num_t cmd_gso_enable_pid =
5376 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5377 cmd_pid, RTE_UINT16);
5379 static cmdline_parse_inst_t cmd_gso_enable = {
5380 .f = cmd_gso_enable_parsed,
5382 .help_str = "set port <port_id> gso on|off",
5384 (void *)&cmd_gso_enable_set,
5385 (void *)&cmd_gso_enable_port,
5386 (void *)&cmd_gso_enable_pid,
5387 (void *)&cmd_gso_enable_keyword,
5388 (void *)&cmd_gso_enable_mode,
5393 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5394 struct cmd_gso_size_result {
5395 cmdline_fixed_string_t cmd_set;
5396 cmdline_fixed_string_t cmd_keyword;
5397 cmdline_fixed_string_t cmd_segsz;
5402 cmd_gso_size_parsed(void *parsed_result,
5403 __rte_unused struct cmdline *cl,
5404 __rte_unused void *data)
5406 struct cmd_gso_size_result *res = parsed_result;
5408 if (test_done == 0) {
5410 "Before setting GSO segsz, please first stop forwarding\n");
5414 if (!strcmp(res->cmd_keyword, "gso") &&
5415 !strcmp(res->cmd_segsz, "segsz")) {
5416 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5418 "gso_size should be larger than %zu. Please input a legal value\n",
5419 RTE_GSO_SEG_SIZE_MIN);
5421 gso_max_segment_size = res->cmd_size;
5425 static cmdline_parse_token_string_t cmd_gso_size_set =
5426 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5428 static cmdline_parse_token_string_t cmd_gso_size_keyword =
5429 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5430 cmd_keyword, "gso");
5431 static cmdline_parse_token_string_t cmd_gso_size_segsz =
5432 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5433 cmd_segsz, "segsz");
5434 static cmdline_parse_token_num_t cmd_gso_size_size =
5435 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5436 cmd_size, RTE_UINT16);
5438 static cmdline_parse_inst_t cmd_gso_size = {
5439 .f = cmd_gso_size_parsed,
5441 .help_str = "set gso segsz <length>",
5443 (void *)&cmd_gso_size_set,
5444 (void *)&cmd_gso_size_keyword,
5445 (void *)&cmd_gso_size_segsz,
5446 (void *)&cmd_gso_size_size,
5451 /* *** SHOW GSO CONFIGURATION *** */
5452 struct cmd_gso_show_result {
5453 cmdline_fixed_string_t cmd_show;
5454 cmdline_fixed_string_t cmd_port;
5455 cmdline_fixed_string_t cmd_keyword;
5460 cmd_gso_show_parsed(void *parsed_result,
5461 __rte_unused struct cmdline *cl,
5462 __rte_unused void *data)
5464 struct cmd_gso_show_result *res = parsed_result;
5466 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5467 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
5470 if (!strcmp(res->cmd_keyword, "gso")) {
5471 if (gso_ports[res->cmd_pid].enable) {
5472 printf("Max GSO'd packet size: %uB\n"
5473 "Supported GSO types: TCP/IPv4, "
5474 "UDP/IPv4, VxLAN with inner "
5475 "TCP/IPv4 packet, GRE with inner "
5476 "TCP/IPv4 packet\n",
5477 gso_max_segment_size);
5479 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5483 static cmdline_parse_token_string_t cmd_gso_show_show =
5484 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5486 static cmdline_parse_token_string_t cmd_gso_show_port =
5487 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5489 static cmdline_parse_token_string_t cmd_gso_show_keyword =
5490 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5491 cmd_keyword, "gso");
5492 static cmdline_parse_token_num_t cmd_gso_show_pid =
5493 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5494 cmd_pid, RTE_UINT16);
5496 static cmdline_parse_inst_t cmd_gso_show = {
5497 .f = cmd_gso_show_parsed,
5499 .help_str = "show port <port_id> gso",
5501 (void *)&cmd_gso_show_show,
5502 (void *)&cmd_gso_show_port,
5503 (void *)&cmd_gso_show_pid,
5504 (void *)&cmd_gso_show_keyword,
5508 #endif /* RTE_LIB_GSO */
5510 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5511 struct cmd_set_flush_rx {
5512 cmdline_fixed_string_t set;
5513 cmdline_fixed_string_t flush_rx;
5514 cmdline_fixed_string_t mode;
5518 cmd_set_flush_rx_parsed(void *parsed_result,
5519 __rte_unused struct cmdline *cl,
5520 __rte_unused void *data)
5522 struct cmd_set_flush_rx *res = parsed_result;
5524 if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) {
5525 printf("multi-process doesn't support to flush Rx queues.\n");
5529 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5532 static cmdline_parse_token_string_t cmd_setflushrx_set =
5533 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5535 static cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5536 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5537 flush_rx, "flush_rx");
5538 static cmdline_parse_token_string_t cmd_setflushrx_mode =
5539 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5543 static cmdline_parse_inst_t cmd_set_flush_rx = {
5544 .f = cmd_set_flush_rx_parsed,
5545 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5548 (void *)&cmd_setflushrx_set,
5549 (void *)&cmd_setflushrx_flush_rx,
5550 (void *)&cmd_setflushrx_mode,
5555 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5556 struct cmd_set_link_check {
5557 cmdline_fixed_string_t set;
5558 cmdline_fixed_string_t link_check;
5559 cmdline_fixed_string_t mode;
5563 cmd_set_link_check_parsed(void *parsed_result,
5564 __rte_unused struct cmdline *cl,
5565 __rte_unused void *data)
5567 struct cmd_set_link_check *res = parsed_result;
5568 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5571 static cmdline_parse_token_string_t cmd_setlinkcheck_set =
5572 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5574 static cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5575 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5576 link_check, "link_check");
5577 static cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5578 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5582 static cmdline_parse_inst_t cmd_set_link_check = {
5583 .f = cmd_set_link_check_parsed,
5584 .help_str = "set link_check on|off: Enable/Disable link status check "
5585 "when starting/stopping a port",
5588 (void *)&cmd_setlinkcheck_set,
5589 (void *)&cmd_setlinkcheck_link_check,
5590 (void *)&cmd_setlinkcheck_mode,
5595 /* *** SET NIC BYPASS MODE *** */
5596 struct cmd_set_bypass_mode_result {
5597 cmdline_fixed_string_t set;
5598 cmdline_fixed_string_t bypass;
5599 cmdline_fixed_string_t mode;
5600 cmdline_fixed_string_t value;
5605 cmd_set_bypass_mode_parsed(void *parsed_result,
5606 __rte_unused struct cmdline *cl,
5607 __rte_unused void *data)
5609 struct cmd_set_bypass_mode_result *res = parsed_result;
5610 portid_t port_id = res->port_id;
5611 int32_t rc = -EINVAL;
5613 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5614 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5616 if (!strcmp(res->value, "bypass"))
5617 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5618 else if (!strcmp(res->value, "isolate"))
5619 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5621 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5623 /* Set the bypass mode for the relevant port. */
5624 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5627 fprintf(stderr, "\t Failed to set bypass mode for port = %d.\n",
5631 static cmdline_parse_token_string_t cmd_setbypass_mode_set =
5632 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5634 static cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5635 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5637 static cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5638 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5640 static cmdline_parse_token_string_t cmd_setbypass_mode_value =
5641 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5642 value, "normal#bypass#isolate");
5643 static cmdline_parse_token_num_t cmd_setbypass_mode_port =
5644 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5645 port_id, RTE_UINT16);
5647 static cmdline_parse_inst_t cmd_set_bypass_mode = {
5648 .f = cmd_set_bypass_mode_parsed,
5649 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5650 "Set the NIC bypass mode for port_id",
5653 (void *)&cmd_setbypass_mode_set,
5654 (void *)&cmd_setbypass_mode_bypass,
5655 (void *)&cmd_setbypass_mode_mode,
5656 (void *)&cmd_setbypass_mode_value,
5657 (void *)&cmd_setbypass_mode_port,
5662 /* *** SET NIC BYPASS EVENT *** */
5663 struct cmd_set_bypass_event_result {
5664 cmdline_fixed_string_t set;
5665 cmdline_fixed_string_t bypass;
5666 cmdline_fixed_string_t event;
5667 cmdline_fixed_string_t event_value;
5668 cmdline_fixed_string_t mode;
5669 cmdline_fixed_string_t mode_value;
5674 cmd_set_bypass_event_parsed(void *parsed_result,
5675 __rte_unused struct cmdline *cl,
5676 __rte_unused void *data)
5678 int32_t rc = -EINVAL;
5679 struct cmd_set_bypass_event_result *res = parsed_result;
5680 portid_t port_id = res->port_id;
5682 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5683 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5684 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5686 if (!strcmp(res->event_value, "timeout"))
5687 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5688 else if (!strcmp(res->event_value, "os_on"))
5689 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5690 else if (!strcmp(res->event_value, "os_off"))
5691 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5692 else if (!strcmp(res->event_value, "power_on"))
5693 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5694 else if (!strcmp(res->event_value, "power_off"))
5695 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5697 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5699 if (!strcmp(res->mode_value, "bypass"))
5700 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5701 else if (!strcmp(res->mode_value, "isolate"))
5702 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5704 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5706 /* Set the watchdog timeout. */
5707 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5710 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5711 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5716 "Failed to set timeout value %u for port %d, errto code: %d.\n",
5717 bypass_timeout, port_id, rc);
5721 /* Set the bypass event to transition to bypass mode. */
5722 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5727 fprintf(stderr, "\t Failed to set bypass event for port = %d.\n",
5731 static cmdline_parse_token_string_t cmd_setbypass_event_set =
5732 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5734 static cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5735 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5737 static cmdline_parse_token_string_t cmd_setbypass_event_event =
5738 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5740 static cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5741 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5742 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5743 static cmdline_parse_token_string_t cmd_setbypass_event_mode =
5744 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5746 static cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5747 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5748 mode_value, "normal#bypass#isolate");
5749 static cmdline_parse_token_num_t cmd_setbypass_event_port =
5750 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5751 port_id, RTE_UINT16);
5753 static cmdline_parse_inst_t cmd_set_bypass_event = {
5754 .f = cmd_set_bypass_event_parsed,
5755 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5756 "power_off mode normal|bypass|isolate <port_id>: "
5757 "Set the NIC bypass event mode for port_id",
5760 (void *)&cmd_setbypass_event_set,
5761 (void *)&cmd_setbypass_event_bypass,
5762 (void *)&cmd_setbypass_event_event,
5763 (void *)&cmd_setbypass_event_event_value,
5764 (void *)&cmd_setbypass_event_mode,
5765 (void *)&cmd_setbypass_event_mode_value,
5766 (void *)&cmd_setbypass_event_port,
5772 /* *** SET NIC BYPASS TIMEOUT *** */
5773 struct cmd_set_bypass_timeout_result {
5774 cmdline_fixed_string_t set;
5775 cmdline_fixed_string_t bypass;
5776 cmdline_fixed_string_t timeout;
5777 cmdline_fixed_string_t value;
5781 cmd_set_bypass_timeout_parsed(void *parsed_result,
5782 __rte_unused struct cmdline *cl,
5783 __rte_unused void *data)
5785 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5787 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5788 if (!strcmp(res->value, "1.5"))
5789 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5790 else if (!strcmp(res->value, "2"))
5791 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5792 else if (!strcmp(res->value, "3"))
5793 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5794 else if (!strcmp(res->value, "4"))
5795 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5796 else if (!strcmp(res->value, "8"))
5797 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5798 else if (!strcmp(res->value, "16"))
5799 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5800 else if (!strcmp(res->value, "32"))
5801 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5803 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5807 static cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5808 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5810 static cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5811 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5813 static cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5814 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5815 timeout, "timeout");
5816 static cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5817 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5818 value, "0#1.5#2#3#4#8#16#32");
5820 static cmdline_parse_inst_t cmd_set_bypass_timeout = {
5821 .f = cmd_set_bypass_timeout_parsed,
5822 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5823 "Set the NIC bypass watchdog timeout in seconds",
5826 (void *)&cmd_setbypass_timeout_set,
5827 (void *)&cmd_setbypass_timeout_bypass,
5828 (void *)&cmd_setbypass_timeout_timeout,
5829 (void *)&cmd_setbypass_timeout_value,
5834 /* *** SHOW NIC BYPASS MODE *** */
5835 struct cmd_show_bypass_config_result {
5836 cmdline_fixed_string_t show;
5837 cmdline_fixed_string_t bypass;
5838 cmdline_fixed_string_t config;
5843 cmd_show_bypass_config_parsed(void *parsed_result,
5844 __rte_unused struct cmdline *cl,
5845 __rte_unused void *data)
5847 struct cmd_show_bypass_config_result *res = parsed_result;
5848 portid_t port_id = res->port_id;
5850 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5851 uint32_t event_mode;
5852 uint32_t bypass_mode;
5853 uint32_t timeout = bypass_timeout;
5856 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5857 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5858 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5859 {"UNKNOWN", "normal", "bypass", "isolate"};
5860 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5868 /* Display the bypass mode.*/
5869 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5870 fprintf(stderr, "\tFailed to get bypass mode for port = %d\n",
5875 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5876 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5878 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5881 /* Display the bypass timeout.*/
5882 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5883 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5885 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5887 /* Display the bypass events and associated modes. */
5888 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5890 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5892 "\tFailed to get bypass mode for event = %s\n",
5895 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5896 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5898 printf("\tbypass event: %-16s = %s\n", events[i],
5905 "\tFailed to get bypass configuration for port = %d\n",
5909 static cmdline_parse_token_string_t cmd_showbypass_config_show =
5910 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5912 static cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5913 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5915 static cmdline_parse_token_string_t cmd_showbypass_config_config =
5916 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5918 static cmdline_parse_token_num_t cmd_showbypass_config_port =
5919 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5920 port_id, RTE_UINT16);
5922 static cmdline_parse_inst_t cmd_show_bypass_config = {
5923 .f = cmd_show_bypass_config_parsed,
5924 .help_str = "show bypass config <port_id>: "
5925 "Show the NIC bypass config for port_id",
5928 (void *)&cmd_showbypass_config_show,
5929 (void *)&cmd_showbypass_config_bypass,
5930 (void *)&cmd_showbypass_config_config,
5931 (void *)&cmd_showbypass_config_port,
5937 /* *** SET BONDING MODE *** */
5938 struct cmd_set_bonding_mode_result {
5939 cmdline_fixed_string_t set;
5940 cmdline_fixed_string_t bonding;
5941 cmdline_fixed_string_t mode;
5946 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5947 __rte_unused struct cmdline *cl,
5948 __rte_unused void *data)
5950 struct cmd_set_bonding_mode_result *res = parsed_result;
5951 portid_t port_id = res->port_id;
5952 struct rte_port *port = &ports[port_id];
5955 * Bonding mode changed means resources of device changed, like whether
5956 * started rte timer or not. Device should be restarted when resources
5957 * of device changed.
5959 if (port->port_status != RTE_PORT_STOPPED) {
5961 "\t Error: Can't set bonding mode when port %d is not stopped\n",
5966 /* Set the bonding mode for the relevant port. */
5967 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5968 fprintf(stderr, "\t Failed to set bonding mode for port = %d.\n",
5972 static cmdline_parse_token_string_t cmd_setbonding_mode_set =
5973 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5975 static cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5976 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5977 bonding, "bonding");
5978 static cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5979 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5981 static cmdline_parse_token_num_t cmd_setbonding_mode_value =
5982 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5984 static cmdline_parse_token_num_t cmd_setbonding_mode_port =
5985 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5986 port_id, RTE_UINT16);
5988 static cmdline_parse_inst_t cmd_set_bonding_mode = {
5989 .f = cmd_set_bonding_mode_parsed,
5990 .help_str = "set bonding mode <mode_value> <port_id>: "
5991 "Set the bonding mode for port_id",
5994 (void *) &cmd_setbonding_mode_set,
5995 (void *) &cmd_setbonding_mode_bonding,
5996 (void *) &cmd_setbonding_mode_mode,
5997 (void *) &cmd_setbonding_mode_value,
5998 (void *) &cmd_setbonding_mode_port,
6003 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
6004 struct cmd_set_bonding_lacp_dedicated_queues_result {
6005 cmdline_fixed_string_t set;
6006 cmdline_fixed_string_t bonding;
6007 cmdline_fixed_string_t lacp;
6008 cmdline_fixed_string_t dedicated_queues;
6010 cmdline_fixed_string_t mode;
6013 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
6014 __rte_unused struct cmdline *cl,
6015 __rte_unused void *data)
6017 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
6018 portid_t port_id = res->port_id;
6019 struct rte_port *port;
6021 port = &ports[port_id];
6023 /** Check if the port is not started **/
6024 if (port->port_status != RTE_PORT_STOPPED) {
6025 fprintf(stderr, "Please stop port %d first\n", port_id);
6029 if (!strcmp(res->mode, "enable")) {
6030 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
6031 printf("Dedicate queues for LACP control packets"
6034 printf("Enabling dedicate queues for LACP control "
6035 "packets on port %d failed\n", port_id);
6036 } else if (!strcmp(res->mode, "disable")) {
6037 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
6038 printf("Dedicated queues for LACP control packets "
6041 printf("Disabling dedicated queues for LACP control "
6042 "traffic on port %d failed\n", port_id);
6046 static cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
6047 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6049 static cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
6050 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6051 bonding, "bonding");
6052 static cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
6053 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6055 static cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
6056 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6057 dedicated_queues, "dedicated_queues");
6058 static cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
6059 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6060 port_id, RTE_UINT16);
6061 static cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
6062 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6063 mode, "enable#disable");
6065 static cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
6066 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
6067 .help_str = "set bonding lacp dedicated_queues <port_id> "
6069 "Enable/disable dedicated queues for LACP control traffic for port_id",
6072 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
6073 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
6074 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
6075 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
6076 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
6077 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
6082 /* *** SET BALANCE XMIT POLICY *** */
6083 struct cmd_set_bonding_balance_xmit_policy_result {
6084 cmdline_fixed_string_t set;
6085 cmdline_fixed_string_t bonding;
6086 cmdline_fixed_string_t balance_xmit_policy;
6088 cmdline_fixed_string_t policy;
6091 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
6092 __rte_unused struct cmdline *cl,
6093 __rte_unused void *data)
6095 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6096 portid_t port_id = res->port_id;
6099 if (!strcmp(res->policy, "l2")) {
6100 policy = BALANCE_XMIT_POLICY_LAYER2;
6101 } else if (!strcmp(res->policy, "l23")) {
6102 policy = BALANCE_XMIT_POLICY_LAYER23;
6103 } else if (!strcmp(res->policy, "l34")) {
6104 policy = BALANCE_XMIT_POLICY_LAYER34;
6106 fprintf(stderr, "\t Invalid xmit policy selection");
6110 /* Set the bonding mode for the relevant port. */
6111 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6113 "\t Failed to set bonding balance xmit policy for port = %d.\n",
6118 static cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6119 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6121 static cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6122 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6123 bonding, "bonding");
6124 static cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6125 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6126 balance_xmit_policy, "balance_xmit_policy");
6127 static cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6128 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6129 port_id, RTE_UINT16);
6130 static cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6131 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6132 policy, "l2#l23#l34");
6134 static cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6135 .f = cmd_set_bonding_balance_xmit_policy_parsed,
6136 .help_str = "set bonding balance_xmit_policy <port_id> "
6138 "Set the bonding balance_xmit_policy for port_id",
6141 (void *)&cmd_setbonding_balance_xmit_policy_set,
6142 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
6143 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6144 (void *)&cmd_setbonding_balance_xmit_policy_port,
6145 (void *)&cmd_setbonding_balance_xmit_policy_policy,
6150 /* *** SHOW IEEE802.3 BONDING INFORMATION *** */
6151 struct cmd_show_bonding_lacp_info_result {
6152 cmdline_fixed_string_t show;
6153 cmdline_fixed_string_t bonding;
6154 cmdline_fixed_string_t lacp;
6155 cmdline_fixed_string_t info;
6159 static void port_param_show(struct port_params *params)
6161 char buf[RTE_ETHER_ADDR_FMT_SIZE];
6163 printf("\t\tsystem priority: %u\n", params->system_priority);
6164 rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, ¶ms->system);
6165 printf("\t\tsystem mac address: %s\n", buf);
6166 printf("\t\tport key: %u\n", params->key);
6167 printf("\t\tport priority: %u\n", params->port_priority);
6168 printf("\t\tport number: %u\n", params->port_number);
6171 static void lacp_slave_info_show(struct rte_eth_bond_8023ad_slave_info *info)
6173 char a_state[256] = { 0 };
6174 char p_state[256] = { 0 };
6179 static const char * const state[] = {
6189 static const char * const selection[] = {
6195 for (i = 0; i < RTE_DIM(state); i++) {
6196 if ((info->actor_state >> i) & 1)
6197 a_len += snprintf(&a_state[a_len],
6198 RTE_DIM(a_state) - a_len, "%s ",
6201 if ((info->partner_state >> i) & 1)
6202 p_len += snprintf(&p_state[p_len],
6203 RTE_DIM(p_state) - p_len, "%s ",
6206 printf("\tAggregator port id: %u\n", info->agg_port_id);
6207 printf("\tselection: %s\n", selection[info->selected]);
6208 printf("\tActor detail info:\n");
6209 port_param_show(&info->actor);
6210 printf("\t\tport state: %s\n", a_state);
6211 printf("\tPartner detail info:\n");
6212 port_param_show(&info->partner);
6213 printf("\t\tport state: %s\n", p_state);
6217 static void lacp_conf_show(struct rte_eth_bond_8023ad_conf *conf)
6219 printf("\tfast period: %u ms\n", conf->fast_periodic_ms);
6220 printf("\tslow period: %u ms\n", conf->slow_periodic_ms);
6221 printf("\tshort timeout: %u ms\n", conf->short_timeout_ms);
6222 printf("\tlong timeout: %u ms\n", conf->long_timeout_ms);
6223 printf("\taggregate wait timeout: %u ms\n",
6224 conf->aggregate_wait_timeout_ms);
6225 printf("\ttx period: %u ms\n", conf->tx_period_ms);
6226 printf("\trx marker period: %u ms\n", conf->rx_marker_period_ms);
6227 printf("\tupdate timeout: %u ms\n", conf->update_timeout_ms);
6228 switch (conf->agg_selection) {
6230 printf("\taggregation mode: bandwidth\n");
6233 printf("\taggregation mode: stable\n");
6236 printf("\taggregation mode: count\n");
6239 printf("\taggregation mode: invalid\n");
6246 static void cmd_show_bonding_lacp_info_parsed(void *parsed_result,
6247 __rte_unused struct cmdline *cl,
6248 __rte_unused void *data)
6250 struct cmd_show_bonding_lacp_info_result *res = parsed_result;
6251 struct rte_eth_bond_8023ad_slave_info slave_info;
6252 struct rte_eth_bond_8023ad_conf port_conf;
6253 portid_t slaves[RTE_MAX_ETHPORTS];
6254 portid_t port_id = res->port_id;
6255 int num_active_slaves;
6260 bonding_mode = rte_eth_bond_mode_get(port_id);
6261 if (bonding_mode != BONDING_MODE_8023AD) {
6262 fprintf(stderr, "\tBonding mode is not mode 4\n");
6266 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6268 if (num_active_slaves < 0) {
6269 fprintf(stderr, "\tFailed to get active slave list for port = %u\n",
6273 if (num_active_slaves == 0)
6274 fprintf(stderr, "\tIEEE802.3 port %u has no active slave\n",
6277 printf("\tIEEE802.3 port: %u\n", port_id);
6278 ret = rte_eth_bond_8023ad_conf_get(port_id, &port_conf);
6280 fprintf(stderr, "\tGet bonded device %u info failed\n",
6284 lacp_conf_show(&port_conf);
6286 for (i = 0; i < num_active_slaves; i++) {
6287 ret = rte_eth_bond_8023ad_slave_info(port_id, slaves[i],
6290 fprintf(stderr, "\tGet slave device %u info failed\n",
6294 printf("\tSlave Port: %u\n", slaves[i]);
6295 lacp_slave_info_show(&slave_info);
6299 static cmdline_parse_token_string_t cmd_show_bonding_lacp_info_show =
6300 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6302 static cmdline_parse_token_string_t cmd_show_bonding_lacp_info_bonding =
6303 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6304 bonding, "bonding");
6305 static cmdline_parse_token_string_t cmd_show_bonding_lacp_info_lacp =
6306 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6308 static cmdline_parse_token_string_t cmd_show_bonding_lacp_info_info =
6309 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6311 static cmdline_parse_token_num_t cmd_show_bonding_lacp_info_port_id =
6312 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6313 port_id, RTE_UINT16);
6315 static cmdline_parse_inst_t cmd_show_bonding_lacp_info = {
6316 .f = cmd_show_bonding_lacp_info_parsed,
6317 .help_str = "show bonding lacp info <port_id> : "
6318 "Show bonding IEEE802.3 information for port_id",
6321 (void *)&cmd_show_bonding_lacp_info_show,
6322 (void *)&cmd_show_bonding_lacp_info_bonding,
6323 (void *)&cmd_show_bonding_lacp_info_lacp,
6324 (void *)&cmd_show_bonding_lacp_info_info,
6325 (void *)&cmd_show_bonding_lacp_info_port_id,
6330 /* *** SHOW NIC BONDING CONFIGURATION *** */
6331 struct cmd_show_bonding_config_result {
6332 cmdline_fixed_string_t show;
6333 cmdline_fixed_string_t bonding;
6334 cmdline_fixed_string_t config;
6338 static void cmd_show_bonding_config_parsed(void *parsed_result,
6339 __rte_unused struct cmdline *cl,
6340 __rte_unused void *data)
6342 struct cmd_show_bonding_config_result *res = parsed_result;
6343 int bonding_mode, agg_mode;
6344 portid_t slaves[RTE_MAX_ETHPORTS];
6345 int num_slaves, num_active_slaves;
6348 portid_t port_id = res->port_id;
6350 /* Display the bonding mode.*/
6351 bonding_mode = rte_eth_bond_mode_get(port_id);
6352 if (bonding_mode < 0) {
6353 fprintf(stderr, "\tFailed to get bonding mode for port = %d\n",
6357 printf("\tBonding mode: %d\n", bonding_mode);
6359 if (bonding_mode == BONDING_MODE_BALANCE ||
6360 bonding_mode == BONDING_MODE_8023AD) {
6361 int balance_xmit_policy;
6363 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6364 if (balance_xmit_policy < 0) {
6366 "\tFailed to get balance xmit policy for port = %d\n",
6370 printf("\tBalance Xmit Policy: ");
6372 switch (balance_xmit_policy) {
6373 case BALANCE_XMIT_POLICY_LAYER2:
6374 printf("BALANCE_XMIT_POLICY_LAYER2");
6376 case BALANCE_XMIT_POLICY_LAYER23:
6377 printf("BALANCE_XMIT_POLICY_LAYER23");
6379 case BALANCE_XMIT_POLICY_LAYER34:
6380 printf("BALANCE_XMIT_POLICY_LAYER34");
6387 if (bonding_mode == BONDING_MODE_8023AD) {
6388 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6389 printf("\tIEEE802.3AD Aggregator Mode: ");
6392 printf("bandwidth");
6404 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6406 if (num_slaves < 0) {
6407 fprintf(stderr, "\tFailed to get slave list for port = %d\n",
6411 if (num_slaves > 0) {
6412 printf("\tSlaves (%d): [", num_slaves);
6413 for (i = 0; i < num_slaves - 1; i++)
6414 printf("%d ", slaves[i]);
6416 printf("%d]\n", slaves[num_slaves - 1]);
6418 printf("\tSlaves: []\n");
6422 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6425 if (num_active_slaves < 0) {
6427 "\tFailed to get active slave list for port = %d\n",
6431 if (num_active_slaves > 0) {
6432 printf("\tActive Slaves (%d): [", num_active_slaves);
6433 for (i = 0; i < num_active_slaves - 1; i++)
6434 printf("%d ", slaves[i]);
6436 printf("%d]\n", slaves[num_active_slaves - 1]);
6439 printf("\tActive Slaves: []\n");
6443 primary_id = rte_eth_bond_primary_get(port_id);
6444 if (primary_id < 0) {
6445 fprintf(stderr, "\tFailed to get primary slave for port = %d\n",
6449 printf("\tPrimary: [%d]\n", primary_id);
6453 static cmdline_parse_token_string_t cmd_showbonding_config_show =
6454 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6456 static cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6457 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6458 bonding, "bonding");
6459 static cmdline_parse_token_string_t cmd_showbonding_config_config =
6460 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6462 static cmdline_parse_token_num_t cmd_showbonding_config_port =
6463 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6464 port_id, RTE_UINT16);
6466 static cmdline_parse_inst_t cmd_show_bonding_config = {
6467 .f = cmd_show_bonding_config_parsed,
6468 .help_str = "show bonding config <port_id>: "
6469 "Show the bonding config for port_id",
6472 (void *)&cmd_showbonding_config_show,
6473 (void *)&cmd_showbonding_config_bonding,
6474 (void *)&cmd_showbonding_config_config,
6475 (void *)&cmd_showbonding_config_port,
6480 /* *** SET BONDING PRIMARY *** */
6481 struct cmd_set_bonding_primary_result {
6482 cmdline_fixed_string_t set;
6483 cmdline_fixed_string_t bonding;
6484 cmdline_fixed_string_t primary;
6489 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6490 __rte_unused struct cmdline *cl,
6491 __rte_unused void *data)
6493 struct cmd_set_bonding_primary_result *res = parsed_result;
6494 portid_t master_port_id = res->port_id;
6495 portid_t slave_port_id = res->slave_id;
6497 /* Set the primary slave for a bonded device. */
6498 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6499 fprintf(stderr, "\t Failed to set primary slave for port = %d.\n",
6506 static cmdline_parse_token_string_t cmd_setbonding_primary_set =
6507 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6509 static cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6510 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6511 bonding, "bonding");
6512 static cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6513 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6514 primary, "primary");
6515 static cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6516 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6517 slave_id, RTE_UINT16);
6518 static cmdline_parse_token_num_t cmd_setbonding_primary_port =
6519 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6520 port_id, RTE_UINT16);
6522 static cmdline_parse_inst_t cmd_set_bonding_primary = {
6523 .f = cmd_set_bonding_primary_parsed,
6524 .help_str = "set bonding primary <slave_id> <port_id>: "
6525 "Set the primary slave for port_id",
6528 (void *)&cmd_setbonding_primary_set,
6529 (void *)&cmd_setbonding_primary_bonding,
6530 (void *)&cmd_setbonding_primary_primary,
6531 (void *)&cmd_setbonding_primary_slave,
6532 (void *)&cmd_setbonding_primary_port,
6537 /* *** ADD SLAVE *** */
6538 struct cmd_add_bonding_slave_result {
6539 cmdline_fixed_string_t add;
6540 cmdline_fixed_string_t bonding;
6541 cmdline_fixed_string_t slave;
6546 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6547 __rte_unused struct cmdline *cl,
6548 __rte_unused void *data)
6550 struct cmd_add_bonding_slave_result *res = parsed_result;
6551 portid_t master_port_id = res->port_id;
6552 portid_t slave_port_id = res->slave_id;
6554 /* add the slave for a bonded device. */
6555 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6557 "\t Failed to add slave %d to master port = %d.\n",
6558 slave_port_id, master_port_id);
6562 set_port_slave_flag(slave_port_id);
6565 static cmdline_parse_token_string_t cmd_addbonding_slave_add =
6566 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6568 static cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6569 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6570 bonding, "bonding");
6571 static cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6572 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6574 static cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6575 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6576 slave_id, RTE_UINT16);
6577 static cmdline_parse_token_num_t cmd_addbonding_slave_port =
6578 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6579 port_id, RTE_UINT16);
6581 static cmdline_parse_inst_t cmd_add_bonding_slave = {
6582 .f = cmd_add_bonding_slave_parsed,
6583 .help_str = "add bonding slave <slave_id> <port_id>: "
6584 "Add a slave device to a bonded device",
6587 (void *)&cmd_addbonding_slave_add,
6588 (void *)&cmd_addbonding_slave_bonding,
6589 (void *)&cmd_addbonding_slave_slave,
6590 (void *)&cmd_addbonding_slave_slaveid,
6591 (void *)&cmd_addbonding_slave_port,
6596 /* *** REMOVE SLAVE *** */
6597 struct cmd_remove_bonding_slave_result {
6598 cmdline_fixed_string_t remove;
6599 cmdline_fixed_string_t bonding;
6600 cmdline_fixed_string_t slave;
6605 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6606 __rte_unused struct cmdline *cl,
6607 __rte_unused void *data)
6609 struct cmd_remove_bonding_slave_result *res = parsed_result;
6610 portid_t master_port_id = res->port_id;
6611 portid_t slave_port_id = res->slave_id;
6613 /* remove the slave from a bonded device. */
6614 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6616 "\t Failed to remove slave %d from master port = %d.\n",
6617 slave_port_id, master_port_id);
6621 clear_port_slave_flag(slave_port_id);
6624 static cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6625 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6627 static cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6628 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6629 bonding, "bonding");
6630 static cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6631 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6633 static cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6634 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6635 slave_id, RTE_UINT16);
6636 static cmdline_parse_token_num_t cmd_removebonding_slave_port =
6637 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6638 port_id, RTE_UINT16);
6640 static cmdline_parse_inst_t cmd_remove_bonding_slave = {
6641 .f = cmd_remove_bonding_slave_parsed,
6642 .help_str = "remove bonding slave <slave_id> <port_id>: "
6643 "Remove a slave device from a bonded device",
6646 (void *)&cmd_removebonding_slave_remove,
6647 (void *)&cmd_removebonding_slave_bonding,
6648 (void *)&cmd_removebonding_slave_slave,
6649 (void *)&cmd_removebonding_slave_slaveid,
6650 (void *)&cmd_removebonding_slave_port,
6655 /* *** CREATE BONDED DEVICE *** */
6656 struct cmd_create_bonded_device_result {
6657 cmdline_fixed_string_t create;
6658 cmdline_fixed_string_t bonded;
6659 cmdline_fixed_string_t device;
6664 static int bond_dev_num = 0;
6666 static void cmd_create_bonded_device_parsed(void *parsed_result,
6667 __rte_unused struct cmdline *cl,
6668 __rte_unused void *data)
6670 struct cmd_create_bonded_device_result *res = parsed_result;
6671 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6675 if (test_done == 0) {
6676 fprintf(stderr, "Please stop forwarding first\n");
6680 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6683 /* Create a new bonded device. */
6684 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6686 fprintf(stderr, "\t Failed to create bonded device.\n");
6689 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6692 /* Update number of ports */
6693 nb_ports = rte_eth_dev_count_avail();
6694 reconfig(port_id, res->socket);
6695 ret = rte_eth_promiscuous_enable(port_id);
6698 "Failed to enable promiscuous mode for port %u: %s - ignore\n",
6699 port_id, rte_strerror(-ret));
6701 ports[port_id].bond_flag = 1;
6702 ports[port_id].need_setup = 0;
6703 ports[port_id].port_status = RTE_PORT_STOPPED;
6708 static cmdline_parse_token_string_t cmd_createbonded_device_create =
6709 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6711 static cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6712 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6714 static cmdline_parse_token_string_t cmd_createbonded_device_device =
6715 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6717 static cmdline_parse_token_num_t cmd_createbonded_device_mode =
6718 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6720 static cmdline_parse_token_num_t cmd_createbonded_device_socket =
6721 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6724 static cmdline_parse_inst_t cmd_create_bonded_device = {
6725 .f = cmd_create_bonded_device_parsed,
6726 .help_str = "create bonded device <mode> <socket>: "
6727 "Create a new bonded device with specific bonding mode and socket",
6730 (void *)&cmd_createbonded_device_create,
6731 (void *)&cmd_createbonded_device_bonded,
6732 (void *)&cmd_createbonded_device_device,
6733 (void *)&cmd_createbonded_device_mode,
6734 (void *)&cmd_createbonded_device_socket,
6739 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6740 struct cmd_set_bond_mac_addr_result {
6741 cmdline_fixed_string_t set;
6742 cmdline_fixed_string_t bonding;
6743 cmdline_fixed_string_t mac_addr;
6745 struct rte_ether_addr address;
6748 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6749 __rte_unused struct cmdline *cl,
6750 __rte_unused void *data)
6752 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6755 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6758 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6760 /* check the return value and print it if is < 0 */
6762 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6766 static cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6767 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6768 static cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6769 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6771 static cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6772 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6774 static cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6775 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6776 port_num, RTE_UINT16);
6777 static cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6778 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6780 static cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6781 .f = cmd_set_bond_mac_addr_parsed,
6783 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6785 (void *)&cmd_set_bond_mac_addr_set,
6786 (void *)&cmd_set_bond_mac_addr_bonding,
6787 (void *)&cmd_set_bond_mac_addr_mac,
6788 (void *)&cmd_set_bond_mac_addr_portnum,
6789 (void *)&cmd_set_bond_mac_addr_addr,
6795 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6796 struct cmd_set_bond_mon_period_result {
6797 cmdline_fixed_string_t set;
6798 cmdline_fixed_string_t bonding;
6799 cmdline_fixed_string_t mon_period;
6804 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6805 __rte_unused struct cmdline *cl,
6806 __rte_unused void *data)
6808 struct cmd_set_bond_mon_period_result *res = parsed_result;
6811 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6813 /* check the return value and print it if is < 0 */
6815 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6819 static cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6820 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6822 static cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6823 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6824 bonding, "bonding");
6825 static cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6826 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6827 mon_period, "mon_period");
6828 static cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6829 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6830 port_num, RTE_UINT16);
6831 static cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6832 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6833 period_ms, RTE_UINT32);
6835 static cmdline_parse_inst_t cmd_set_bond_mon_period = {
6836 .f = cmd_set_bond_mon_period_parsed,
6838 .help_str = "set bonding mon_period <port_id> <period_ms>",
6840 (void *)&cmd_set_bond_mon_period_set,
6841 (void *)&cmd_set_bond_mon_period_bonding,
6842 (void *)&cmd_set_bond_mon_period_mon_period,
6843 (void *)&cmd_set_bond_mon_period_portnum,
6844 (void *)&cmd_set_bond_mon_period_period_ms,
6851 struct cmd_set_bonding_agg_mode_policy_result {
6852 cmdline_fixed_string_t set;
6853 cmdline_fixed_string_t bonding;
6854 cmdline_fixed_string_t agg_mode;
6856 cmdline_fixed_string_t policy;
6861 cmd_set_bonding_agg_mode(void *parsed_result,
6862 __rte_unused struct cmdline *cl,
6863 __rte_unused void *data)
6865 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6866 uint8_t policy = AGG_BANDWIDTH;
6868 if (!strcmp(res->policy, "bandwidth"))
6869 policy = AGG_BANDWIDTH;
6870 else if (!strcmp(res->policy, "stable"))
6871 policy = AGG_STABLE;
6872 else if (!strcmp(res->policy, "count"))
6875 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6879 static cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6880 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6882 static cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6883 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6884 bonding, "bonding");
6886 static cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6887 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6888 agg_mode, "agg_mode");
6890 static cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6891 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6892 port_num, RTE_UINT16);
6894 static cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6895 TOKEN_STRING_INITIALIZER(
6896 struct cmd_set_bonding_balance_xmit_policy_result,
6897 policy, "stable#bandwidth#count");
6899 static cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6900 .f = cmd_set_bonding_agg_mode,
6902 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6904 (void *)&cmd_set_bonding_agg_mode_set,
6905 (void *)&cmd_set_bonding_agg_mode_bonding,
6906 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6907 (void *)&cmd_set_bonding_agg_mode_portnum,
6908 (void *)&cmd_set_bonding_agg_mode_policy_string,
6914 #endif /* RTE_NET_BOND */
6916 /* *** SET FORWARDING MODE *** */
6917 struct cmd_set_fwd_mode_result {
6918 cmdline_fixed_string_t set;
6919 cmdline_fixed_string_t fwd;
6920 cmdline_fixed_string_t mode;
6923 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6924 __rte_unused struct cmdline *cl,
6925 __rte_unused void *data)
6927 struct cmd_set_fwd_mode_result *res = parsed_result;
6930 set_pkt_forwarding_mode(res->mode);
6933 static cmdline_parse_token_string_t cmd_setfwd_set =
6934 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6935 static cmdline_parse_token_string_t cmd_setfwd_fwd =
6936 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6937 static cmdline_parse_token_string_t cmd_setfwd_mode =
6938 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6939 "" /* defined at init */);
6941 static cmdline_parse_inst_t cmd_set_fwd_mode = {
6942 .f = cmd_set_fwd_mode_parsed,
6944 .help_str = NULL, /* defined at init */
6946 (void *)&cmd_setfwd_set,
6947 (void *)&cmd_setfwd_fwd,
6948 (void *)&cmd_setfwd_mode,
6953 static void cmd_set_fwd_mode_init(void)
6956 static char token[128];
6957 static char help[256];
6958 cmdline_parse_token_string_t *token_struct;
6960 modes = list_pkt_forwarding_modes();
6961 snprintf(help, sizeof(help), "set fwd %s: "
6962 "Set packet forwarding mode", modes);
6963 cmd_set_fwd_mode.help_str = help;
6965 /* string token separator is # */
6966 for (c = token; *modes != '\0'; modes++)
6971 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6972 token_struct->string_data.str = token;
6975 /* *** SET RETRY FORWARDING MODE *** */
6976 struct cmd_set_fwd_retry_mode_result {
6977 cmdline_fixed_string_t set;
6978 cmdline_fixed_string_t fwd;
6979 cmdline_fixed_string_t mode;
6980 cmdline_fixed_string_t retry;
6983 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6984 __rte_unused struct cmdline *cl,
6985 __rte_unused void *data)
6987 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6990 set_pkt_forwarding_mode(res->mode);
6993 static cmdline_parse_token_string_t cmd_setfwd_retry_set =
6994 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6996 static cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6997 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6999 static cmdline_parse_token_string_t cmd_setfwd_retry_mode =
7000 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
7002 "" /* defined at init */);
7003 static cmdline_parse_token_string_t cmd_setfwd_retry_retry =
7004 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
7007 static cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
7008 .f = cmd_set_fwd_retry_mode_parsed,
7010 .help_str = NULL, /* defined at init */
7012 (void *)&cmd_setfwd_retry_set,
7013 (void *)&cmd_setfwd_retry_fwd,
7014 (void *)&cmd_setfwd_retry_mode,
7015 (void *)&cmd_setfwd_retry_retry,
7020 static void cmd_set_fwd_retry_mode_init(void)
7023 static char token[128];
7024 static char help[256];
7025 cmdline_parse_token_string_t *token_struct;
7027 modes = list_pkt_forwarding_retry_modes();
7028 snprintf(help, sizeof(help), "set fwd %s retry: "
7029 "Set packet forwarding mode with retry", modes);
7030 cmd_set_fwd_retry_mode.help_str = help;
7032 /* string token separator is # */
7033 for (c = token; *modes != '\0'; modes++)
7038 token_struct = (cmdline_parse_token_string_t *)
7039 cmd_set_fwd_retry_mode.tokens[2];
7040 token_struct->string_data.str = token;
7043 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
7044 struct cmd_set_burst_tx_retry_result {
7045 cmdline_fixed_string_t set;
7046 cmdline_fixed_string_t burst;
7047 cmdline_fixed_string_t tx;
7048 cmdline_fixed_string_t delay;
7050 cmdline_fixed_string_t retry;
7054 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
7055 __rte_unused struct cmdline *cl,
7056 __rte_unused void *data)
7058 struct cmd_set_burst_tx_retry_result *res = parsed_result;
7060 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
7061 && !strcmp(res->tx, "tx")) {
7062 if (!strcmp(res->delay, "delay"))
7063 burst_tx_delay_time = res->time;
7064 if (!strcmp(res->retry, "retry"))
7065 burst_tx_retry_num = res->retry_num;
7070 static cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
7071 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
7072 static cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
7073 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
7075 static cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
7076 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
7077 static cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
7078 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
7079 static cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
7080 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
7082 static cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
7083 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
7084 static cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
7085 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
7088 static cmdline_parse_inst_t cmd_set_burst_tx_retry = {
7089 .f = cmd_set_burst_tx_retry_parsed,
7090 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
7092 (void *)&cmd_set_burst_tx_retry_set,
7093 (void *)&cmd_set_burst_tx_retry_burst,
7094 (void *)&cmd_set_burst_tx_retry_tx,
7095 (void *)&cmd_set_burst_tx_retry_delay,
7096 (void *)&cmd_set_burst_tx_retry_time,
7097 (void *)&cmd_set_burst_tx_retry_retry,
7098 (void *)&cmd_set_burst_tx_retry_retry_num,
7103 /* *** SET PROMISC MODE *** */
7104 struct cmd_set_promisc_mode_result {
7105 cmdline_fixed_string_t set;
7106 cmdline_fixed_string_t promisc;
7107 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
7108 uint16_t port_num; /* valid if "allports" argument == 0 */
7109 cmdline_fixed_string_t mode;
7112 static void cmd_set_promisc_mode_parsed(void *parsed_result,
7113 __rte_unused struct cmdline *cl,
7116 struct cmd_set_promisc_mode_result *res = parsed_result;
7120 if (!strcmp(res->mode, "on"))
7127 RTE_ETH_FOREACH_DEV(i)
7128 eth_set_promisc_mode(i, enable);
7130 eth_set_promisc_mode(res->port_num, enable);
7134 static cmdline_parse_token_string_t cmd_setpromisc_set =
7135 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
7136 static cmdline_parse_token_string_t cmd_setpromisc_promisc =
7137 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
7139 static cmdline_parse_token_string_t cmd_setpromisc_portall =
7140 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
7142 static cmdline_parse_token_num_t cmd_setpromisc_portnum =
7143 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
7145 static cmdline_parse_token_string_t cmd_setpromisc_mode =
7146 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
7149 static cmdline_parse_inst_t cmd_set_promisc_mode_all = {
7150 .f = cmd_set_promisc_mode_parsed,
7152 .help_str = "set promisc all on|off: Set promisc mode for all ports",
7154 (void *)&cmd_setpromisc_set,
7155 (void *)&cmd_setpromisc_promisc,
7156 (void *)&cmd_setpromisc_portall,
7157 (void *)&cmd_setpromisc_mode,
7162 static cmdline_parse_inst_t cmd_set_promisc_mode_one = {
7163 .f = cmd_set_promisc_mode_parsed,
7165 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
7167 (void *)&cmd_setpromisc_set,
7168 (void *)&cmd_setpromisc_promisc,
7169 (void *)&cmd_setpromisc_portnum,
7170 (void *)&cmd_setpromisc_mode,
7175 /* *** SET ALLMULTI MODE *** */
7176 struct cmd_set_allmulti_mode_result {
7177 cmdline_fixed_string_t set;
7178 cmdline_fixed_string_t allmulti;
7179 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
7180 uint16_t port_num; /* valid if "allports" argument == 0 */
7181 cmdline_fixed_string_t mode;
7184 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
7185 __rte_unused struct cmdline *cl,
7188 struct cmd_set_allmulti_mode_result *res = parsed_result;
7192 if (!strcmp(res->mode, "on"))
7199 RTE_ETH_FOREACH_DEV(i) {
7200 eth_set_allmulticast_mode(i, enable);
7204 eth_set_allmulticast_mode(res->port_num, enable);
7208 static cmdline_parse_token_string_t cmd_setallmulti_set =
7209 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
7210 static cmdline_parse_token_string_t cmd_setallmulti_allmulti =
7211 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
7213 static cmdline_parse_token_string_t cmd_setallmulti_portall =
7214 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
7216 static cmdline_parse_token_num_t cmd_setallmulti_portnum =
7217 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
7219 static cmdline_parse_token_string_t cmd_setallmulti_mode =
7220 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
7223 static cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
7224 .f = cmd_set_allmulti_mode_parsed,
7226 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
7228 (void *)&cmd_setallmulti_set,
7229 (void *)&cmd_setallmulti_allmulti,
7230 (void *)&cmd_setallmulti_portall,
7231 (void *)&cmd_setallmulti_mode,
7236 static cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
7237 .f = cmd_set_allmulti_mode_parsed,
7239 .help_str = "set allmulti <port_id> on|off: "
7240 "Set allmulti mode on port_id",
7242 (void *)&cmd_setallmulti_set,
7243 (void *)&cmd_setallmulti_allmulti,
7244 (void *)&cmd_setallmulti_portnum,
7245 (void *)&cmd_setallmulti_mode,
7250 /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
7251 struct cmd_link_flow_ctrl_show {
7252 cmdline_fixed_string_t show;
7253 cmdline_fixed_string_t port;
7255 cmdline_fixed_string_t flow_ctrl;
7258 static cmdline_parse_token_string_t cmd_lfc_show_show =
7259 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7261 static cmdline_parse_token_string_t cmd_lfc_show_port =
7262 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7264 static cmdline_parse_token_num_t cmd_lfc_show_portid =
7265 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
7266 port_id, RTE_UINT16);
7267 static cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
7268 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7269 flow_ctrl, "flow_ctrl");
7272 cmd_link_flow_ctrl_show_parsed(void *parsed_result,
7273 __rte_unused struct cmdline *cl,
7274 __rte_unused void *data)
7276 struct cmd_link_flow_ctrl_show *res = parsed_result;
7277 static const char *info_border = "*********************";
7278 struct rte_eth_fc_conf fc_conf;
7279 bool rx_fc_en = false;
7280 bool tx_fc_en = false;
7283 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7286 "Failed to get current flow ctrl information: err = %d\n",
7291 if (fc_conf.mode == RTE_ETH_FC_RX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
7293 if (fc_conf.mode == RTE_ETH_FC_TX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
7296 printf("\n%s Flow control infos for port %-2d %s\n",
7297 info_border, res->port_id, info_border);
7298 printf("FC mode:\n");
7299 printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
7300 printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
7301 printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
7302 printf("Pause time: 0x%x\n", fc_conf.pause_time);
7303 printf("High waterline: 0x%x\n", fc_conf.high_water);
7304 printf("Low waterline: 0x%x\n", fc_conf.low_water);
7305 printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
7306 printf("Forward MAC control frames: %s\n",
7307 fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
7308 printf("\n%s************** End ***********%s\n",
7309 info_border, info_border);
7312 static cmdline_parse_inst_t cmd_link_flow_control_show = {
7313 .f = cmd_link_flow_ctrl_show_parsed,
7315 .help_str = "show port <port_id> flow_ctrl",
7317 (void *)&cmd_lfc_show_show,
7318 (void *)&cmd_lfc_show_port,
7319 (void *)&cmd_lfc_show_portid,
7320 (void *)&cmd_lfc_show_flow_ctrl,
7325 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
7326 struct cmd_link_flow_ctrl_set_result {
7327 cmdline_fixed_string_t set;
7328 cmdline_fixed_string_t flow_ctrl;
7329 cmdline_fixed_string_t rx;
7330 cmdline_fixed_string_t rx_lfc_mode;
7331 cmdline_fixed_string_t tx;
7332 cmdline_fixed_string_t tx_lfc_mode;
7333 cmdline_fixed_string_t mac_ctrl_frame_fwd;
7334 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
7335 cmdline_fixed_string_t autoneg_str;
7336 cmdline_fixed_string_t autoneg;
7337 cmdline_fixed_string_t hw_str;
7338 uint32_t high_water;
7339 cmdline_fixed_string_t lw_str;
7341 cmdline_fixed_string_t pt_str;
7342 uint16_t pause_time;
7343 cmdline_fixed_string_t xon_str;
7348 static cmdline_parse_token_string_t cmd_lfc_set_set =
7349 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7351 static cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
7352 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7353 flow_ctrl, "flow_ctrl");
7354 static cmdline_parse_token_string_t cmd_lfc_set_rx =
7355 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7357 static cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
7358 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7359 rx_lfc_mode, "on#off");
7360 static cmdline_parse_token_string_t cmd_lfc_set_tx =
7361 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7363 static cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7364 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7365 tx_lfc_mode, "on#off");
7366 static cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7367 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7368 hw_str, "high_water");
7369 static cmdline_parse_token_num_t cmd_lfc_set_high_water =
7370 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7371 high_water, RTE_UINT32);
7372 static cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7373 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7374 lw_str, "low_water");
7375 static cmdline_parse_token_num_t cmd_lfc_set_low_water =
7376 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7377 low_water, RTE_UINT32);
7378 static cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7379 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7380 pt_str, "pause_time");
7381 static cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7382 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7383 pause_time, RTE_UINT16);
7384 static cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7385 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7386 xon_str, "send_xon");
7387 static cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7388 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7389 send_xon, RTE_UINT16);
7390 static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7391 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7392 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7393 static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7394 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7395 mac_ctrl_frame_fwd_mode, "on#off");
7396 static cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7397 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7398 autoneg_str, "autoneg");
7399 static cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7400 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7402 static cmdline_parse_token_num_t cmd_lfc_set_portid =
7403 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7404 port_id, RTE_UINT16);
7406 /* forward declaration */
7408 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7411 static cmdline_parse_inst_t cmd_link_flow_control_set = {
7412 .f = cmd_link_flow_ctrl_set_parsed,
7414 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7415 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7416 "autoneg on|off <port_id>: Configure the Ethernet flow control",
7418 (void *)&cmd_lfc_set_set,
7419 (void *)&cmd_lfc_set_flow_ctrl,
7420 (void *)&cmd_lfc_set_rx,
7421 (void *)&cmd_lfc_set_rx_mode,
7422 (void *)&cmd_lfc_set_tx,
7423 (void *)&cmd_lfc_set_tx_mode,
7424 (void *)&cmd_lfc_set_high_water,
7425 (void *)&cmd_lfc_set_low_water,
7426 (void *)&cmd_lfc_set_pause_time,
7427 (void *)&cmd_lfc_set_send_xon,
7428 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7429 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7430 (void *)&cmd_lfc_set_autoneg_str,
7431 (void *)&cmd_lfc_set_autoneg,
7432 (void *)&cmd_lfc_set_portid,
7437 static cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7438 .f = cmd_link_flow_ctrl_set_parsed,
7439 .data = (void *)&cmd_link_flow_control_set_rx,
7440 .help_str = "set flow_ctrl rx on|off <port_id>: "
7441 "Change rx flow control parameter",
7443 (void *)&cmd_lfc_set_set,
7444 (void *)&cmd_lfc_set_flow_ctrl,
7445 (void *)&cmd_lfc_set_rx,
7446 (void *)&cmd_lfc_set_rx_mode,
7447 (void *)&cmd_lfc_set_portid,
7452 static cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7453 .f = cmd_link_flow_ctrl_set_parsed,
7454 .data = (void *)&cmd_link_flow_control_set_tx,
7455 .help_str = "set flow_ctrl tx on|off <port_id>: "
7456 "Change tx flow control parameter",
7458 (void *)&cmd_lfc_set_set,
7459 (void *)&cmd_lfc_set_flow_ctrl,
7460 (void *)&cmd_lfc_set_tx,
7461 (void *)&cmd_lfc_set_tx_mode,
7462 (void *)&cmd_lfc_set_portid,
7467 static cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7468 .f = cmd_link_flow_ctrl_set_parsed,
7469 .data = (void *)&cmd_link_flow_control_set_hw,
7470 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7471 "Change high water flow control parameter",
7473 (void *)&cmd_lfc_set_set,
7474 (void *)&cmd_lfc_set_flow_ctrl,
7475 (void *)&cmd_lfc_set_high_water_str,
7476 (void *)&cmd_lfc_set_high_water,
7477 (void *)&cmd_lfc_set_portid,
7482 static cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7483 .f = cmd_link_flow_ctrl_set_parsed,
7484 .data = (void *)&cmd_link_flow_control_set_lw,
7485 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7486 "Change low water flow control parameter",
7488 (void *)&cmd_lfc_set_set,
7489 (void *)&cmd_lfc_set_flow_ctrl,
7490 (void *)&cmd_lfc_set_low_water_str,
7491 (void *)&cmd_lfc_set_low_water,
7492 (void *)&cmd_lfc_set_portid,
7497 static cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7498 .f = cmd_link_flow_ctrl_set_parsed,
7499 .data = (void *)&cmd_link_flow_control_set_pt,
7500 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7501 "Change pause time flow control parameter",
7503 (void *)&cmd_lfc_set_set,
7504 (void *)&cmd_lfc_set_flow_ctrl,
7505 (void *)&cmd_lfc_set_pause_time_str,
7506 (void *)&cmd_lfc_set_pause_time,
7507 (void *)&cmd_lfc_set_portid,
7512 static cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7513 .f = cmd_link_flow_ctrl_set_parsed,
7514 .data = (void *)&cmd_link_flow_control_set_xon,
7515 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7516 "Change send_xon flow control parameter",
7518 (void *)&cmd_lfc_set_set,
7519 (void *)&cmd_lfc_set_flow_ctrl,
7520 (void *)&cmd_lfc_set_send_xon_str,
7521 (void *)&cmd_lfc_set_send_xon,
7522 (void *)&cmd_lfc_set_portid,
7527 static cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7528 .f = cmd_link_flow_ctrl_set_parsed,
7529 .data = (void *)&cmd_link_flow_control_set_macfwd,
7530 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7531 "Change mac ctrl fwd flow control parameter",
7533 (void *)&cmd_lfc_set_set,
7534 (void *)&cmd_lfc_set_flow_ctrl,
7535 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7536 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7537 (void *)&cmd_lfc_set_portid,
7542 static cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7543 .f = cmd_link_flow_ctrl_set_parsed,
7544 .data = (void *)&cmd_link_flow_control_set_autoneg,
7545 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7546 "Change autoneg flow control parameter",
7548 (void *)&cmd_lfc_set_set,
7549 (void *)&cmd_lfc_set_flow_ctrl,
7550 (void *)&cmd_lfc_set_autoneg_str,
7551 (void *)&cmd_lfc_set_autoneg,
7552 (void *)&cmd_lfc_set_portid,
7558 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7559 __rte_unused struct cmdline *cl,
7562 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7563 cmdline_parse_inst_t *cmd = data;
7564 struct rte_eth_fc_conf fc_conf;
7570 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7571 * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7572 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7573 * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7575 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7576 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7579 /* Partial command line, retrieve current configuration */
7581 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7584 "cannot get current flow ctrl parameters, return code = %d\n",
7589 if ((fc_conf.mode == RTE_ETH_FC_RX_PAUSE) ||
7590 (fc_conf.mode == RTE_ETH_FC_FULL))
7592 if ((fc_conf.mode == RTE_ETH_FC_TX_PAUSE) ||
7593 (fc_conf.mode == RTE_ETH_FC_FULL))
7597 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7598 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7600 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7601 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7603 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7605 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7606 fc_conf.high_water = res->high_water;
7608 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7609 fc_conf.low_water = res->low_water;
7611 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7612 fc_conf.pause_time = res->pause_time;
7614 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7615 fc_conf.send_xon = res->send_xon;
7617 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7618 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7619 fc_conf.mac_ctrl_frame_fwd = 1;
7621 fc_conf.mac_ctrl_frame_fwd = 0;
7624 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7625 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7627 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7630 "bad flow control parameter, return code = %d\n",
7634 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7635 struct cmd_priority_flow_ctrl_set_result {
7636 cmdline_fixed_string_t set;
7637 cmdline_fixed_string_t pfc_ctrl;
7638 cmdline_fixed_string_t rx;
7639 cmdline_fixed_string_t rx_pfc_mode;
7640 cmdline_fixed_string_t tx;
7641 cmdline_fixed_string_t tx_pfc_mode;
7642 uint32_t high_water;
7644 uint16_t pause_time;
7650 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7651 __rte_unused struct cmdline *cl,
7652 __rte_unused void *data)
7654 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7655 struct rte_eth_pfc_conf pfc_conf;
7656 int rx_fc_enable, tx_fc_enable;
7660 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7661 * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7662 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7663 * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7665 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7666 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7669 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7670 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7671 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7672 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7673 pfc_conf.fc.high_water = res->high_water;
7674 pfc_conf.fc.low_water = res->low_water;
7675 pfc_conf.fc.pause_time = res->pause_time;
7676 pfc_conf.priority = res->priority;
7678 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7681 "bad priority flow control parameter, return code = %d\n",
7685 static cmdline_parse_token_string_t cmd_pfc_set_set =
7686 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7688 static cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7689 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7690 pfc_ctrl, "pfc_ctrl");
7691 static cmdline_parse_token_string_t cmd_pfc_set_rx =
7692 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7694 static cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7695 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7696 rx_pfc_mode, "on#off");
7697 static cmdline_parse_token_string_t cmd_pfc_set_tx =
7698 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7700 static cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7701 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7702 tx_pfc_mode, "on#off");
7703 static cmdline_parse_token_num_t cmd_pfc_set_high_water =
7704 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7705 high_water, RTE_UINT32);
7706 static cmdline_parse_token_num_t cmd_pfc_set_low_water =
7707 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7708 low_water, RTE_UINT32);
7709 static cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7710 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7711 pause_time, RTE_UINT16);
7712 static cmdline_parse_token_num_t cmd_pfc_set_priority =
7713 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7714 priority, RTE_UINT8);
7715 static cmdline_parse_token_num_t cmd_pfc_set_portid =
7716 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7717 port_id, RTE_UINT16);
7719 static cmdline_parse_inst_t cmd_priority_flow_control_set = {
7720 .f = cmd_priority_flow_ctrl_set_parsed,
7722 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7723 "<pause_time> <priority> <port_id>: "
7724 "Configure the Ethernet priority flow control",
7726 (void *)&cmd_pfc_set_set,
7727 (void *)&cmd_pfc_set_flow_ctrl,
7728 (void *)&cmd_pfc_set_rx,
7729 (void *)&cmd_pfc_set_rx_mode,
7730 (void *)&cmd_pfc_set_tx,
7731 (void *)&cmd_pfc_set_tx_mode,
7732 (void *)&cmd_pfc_set_high_water,
7733 (void *)&cmd_pfc_set_low_water,
7734 (void *)&cmd_pfc_set_pause_time,
7735 (void *)&cmd_pfc_set_priority,
7736 (void *)&cmd_pfc_set_portid,
7741 struct cmd_queue_priority_flow_ctrl_set_result {
7742 cmdline_fixed_string_t set;
7743 cmdline_fixed_string_t pfc_queue_ctrl;
7745 cmdline_fixed_string_t rx;
7746 cmdline_fixed_string_t rx_pfc_mode;
7749 cmdline_fixed_string_t tx;
7750 cmdline_fixed_string_t tx_pfc_mode;
7753 uint16_t pause_time;
7757 cmd_queue_priority_flow_ctrl_set_parsed(void *parsed_result,
7758 __rte_unused struct cmdline *cl,
7759 __rte_unused void *data)
7761 struct cmd_queue_priority_flow_ctrl_set_result *res = parsed_result;
7762 struct rte_eth_pfc_queue_conf pfc_queue_conf;
7763 int rx_fc_enable, tx_fc_enable;
7767 * Rx on/off, flow control is enabled/disabled on RX side. This can
7768 * indicate the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx
7769 * side. Tx on/off, flow control is enabled/disabled on TX side. This
7770 * can indicate the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at
7773 static enum rte_eth_fc_mode rx_tx_onoff_2_mode[2][2] = {
7774 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE},
7775 {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7778 memset(&pfc_queue_conf, 0, sizeof(struct rte_eth_pfc_queue_conf));
7779 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on", 2)) ? 1 : 0;
7780 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on", 2)) ? 1 : 0;
7781 pfc_queue_conf.mode = rx_tx_onoff_2_mode[rx_fc_enable][tx_fc_enable];
7782 pfc_queue_conf.rx_pause.tc = res->tx_tc;
7783 pfc_queue_conf.rx_pause.tx_qid = res->tx_qid;
7784 pfc_queue_conf.tx_pause.tc = res->rx_tc;
7785 pfc_queue_conf.tx_pause.rx_qid = res->rx_qid;
7786 pfc_queue_conf.tx_pause.pause_time = res->pause_time;
7788 ret = rte_eth_dev_priority_flow_ctrl_queue_configure(res->port_id,
7792 "bad queue priority flow control parameter, rc = %d\n",
7797 static cmdline_parse_token_string_t cmd_q_pfc_set_set =
7798 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7800 static cmdline_parse_token_string_t cmd_q_pfc_set_flow_ctrl =
7801 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7802 pfc_queue_ctrl, "pfc_queue_ctrl");
7803 static cmdline_parse_token_num_t cmd_q_pfc_set_portid =
7804 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7805 port_id, RTE_UINT16);
7806 static cmdline_parse_token_string_t cmd_q_pfc_set_rx =
7807 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7809 static cmdline_parse_token_string_t cmd_q_pfc_set_rx_mode =
7810 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7811 rx_pfc_mode, "on#off");
7812 static cmdline_parse_token_num_t cmd_q_pfc_set_tx_qid =
7813 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7814 tx_qid, RTE_UINT16);
7815 static cmdline_parse_token_num_t cmd_q_pfc_set_tx_tc =
7816 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7818 static cmdline_parse_token_string_t cmd_q_pfc_set_tx =
7819 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7821 static cmdline_parse_token_string_t cmd_q_pfc_set_tx_mode =
7822 TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7823 tx_pfc_mode, "on#off");
7824 static cmdline_parse_token_num_t cmd_q_pfc_set_rx_qid =
7825 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7826 rx_qid, RTE_UINT16);
7827 static cmdline_parse_token_num_t cmd_q_pfc_set_rx_tc =
7828 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7830 static cmdline_parse_token_num_t cmd_q_pfc_set_pause_time =
7831 TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7832 pause_time, RTE_UINT16);
7834 static cmdline_parse_inst_t cmd_queue_priority_flow_control_set = {
7835 .f = cmd_queue_priority_flow_ctrl_set_parsed,
7837 .help_str = "set pfc_queue_ctrl <port_id> rx <on|off> <tx_qid> <tx_tc> "
7838 "tx <on|off> <rx_qid> <rx_tc> <pause_time>: "
7839 "Configure the Ethernet queue priority flow control",
7841 (void *)&cmd_q_pfc_set_set,
7842 (void *)&cmd_q_pfc_set_flow_ctrl,
7843 (void *)&cmd_q_pfc_set_portid,
7844 (void *)&cmd_q_pfc_set_rx,
7845 (void *)&cmd_q_pfc_set_rx_mode,
7846 (void *)&cmd_q_pfc_set_tx_qid,
7847 (void *)&cmd_q_pfc_set_tx_tc,
7848 (void *)&cmd_q_pfc_set_tx,
7849 (void *)&cmd_q_pfc_set_tx_mode,
7850 (void *)&cmd_q_pfc_set_rx_qid,
7851 (void *)&cmd_q_pfc_set_rx_tc,
7852 (void *)&cmd_q_pfc_set_pause_time,
7857 /* *** RESET CONFIGURATION *** */
7858 struct cmd_reset_result {
7859 cmdline_fixed_string_t reset;
7860 cmdline_fixed_string_t def;
7863 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7865 __rte_unused void *data)
7867 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7868 set_def_fwd_config();
7871 static cmdline_parse_token_string_t cmd_reset_set =
7872 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7873 static cmdline_parse_token_string_t cmd_reset_def =
7874 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7877 static cmdline_parse_inst_t cmd_reset = {
7878 .f = cmd_reset_parsed,
7880 .help_str = "set default: Reset default forwarding configuration",
7882 (void *)&cmd_reset_set,
7883 (void *)&cmd_reset_def,
7888 /* *** START FORWARDING *** */
7889 struct cmd_start_result {
7890 cmdline_fixed_string_t start;
7893 static cmdline_parse_token_string_t cmd_start_start =
7894 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7896 static void cmd_start_parsed(__rte_unused void *parsed_result,
7897 __rte_unused struct cmdline *cl,
7898 __rte_unused void *data)
7900 start_packet_forwarding(0);
7903 static cmdline_parse_inst_t cmd_start = {
7904 .f = cmd_start_parsed,
7906 .help_str = "start: Start packet forwarding",
7908 (void *)&cmd_start_start,
7913 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7914 struct cmd_start_tx_first_result {
7915 cmdline_fixed_string_t start;
7916 cmdline_fixed_string_t tx_first;
7920 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7921 __rte_unused struct cmdline *cl,
7922 __rte_unused void *data)
7924 start_packet_forwarding(1);
7927 static cmdline_parse_token_string_t cmd_start_tx_first_start =
7928 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7930 static cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7931 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7932 tx_first, "tx_first");
7934 static cmdline_parse_inst_t cmd_start_tx_first = {
7935 .f = cmd_start_tx_first_parsed,
7937 .help_str = "start tx_first: Start packet forwarding, "
7938 "after sending 1 burst of packets",
7940 (void *)&cmd_start_tx_first_start,
7941 (void *)&cmd_start_tx_first_tx_first,
7946 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7947 struct cmd_start_tx_first_n_result {
7948 cmdline_fixed_string_t start;
7949 cmdline_fixed_string_t tx_first;
7954 cmd_start_tx_first_n_parsed(void *parsed_result,
7955 __rte_unused struct cmdline *cl,
7956 __rte_unused void *data)
7958 struct cmd_start_tx_first_n_result *res = parsed_result;
7960 start_packet_forwarding(res->tx_num);
7963 static cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7964 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7966 static cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7967 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7968 tx_first, "tx_first");
7969 static cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7970 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7971 tx_num, RTE_UINT32);
7973 static cmdline_parse_inst_t cmd_start_tx_first_n = {
7974 .f = cmd_start_tx_first_n_parsed,
7976 .help_str = "start tx_first <num>: "
7977 "packet forwarding, after sending <num> bursts of packets",
7979 (void *)&cmd_start_tx_first_n_start,
7980 (void *)&cmd_start_tx_first_n_tx_first,
7981 (void *)&cmd_start_tx_first_n_tx_num,
7986 /* *** SET LINK UP *** */
7987 struct cmd_set_link_up_result {
7988 cmdline_fixed_string_t set;
7989 cmdline_fixed_string_t link_up;
7990 cmdline_fixed_string_t port;
7994 static cmdline_parse_token_string_t cmd_set_link_up_set =
7995 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7996 static cmdline_parse_token_string_t cmd_set_link_up_link_up =
7997 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7999 static cmdline_parse_token_string_t cmd_set_link_up_port =
8000 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
8001 static cmdline_parse_token_num_t cmd_set_link_up_port_id =
8002 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
8005 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
8006 __rte_unused struct cmdline *cl,
8007 __rte_unused void *data)
8009 struct cmd_set_link_up_result *res = parsed_result;
8010 dev_set_link_up(res->port_id);
8013 static cmdline_parse_inst_t cmd_set_link_up = {
8014 .f = cmd_set_link_up_parsed,
8016 .help_str = "set link-up port <port id>",
8018 (void *)&cmd_set_link_up_set,
8019 (void *)&cmd_set_link_up_link_up,
8020 (void *)&cmd_set_link_up_port,
8021 (void *)&cmd_set_link_up_port_id,
8026 /* *** SET LINK DOWN *** */
8027 struct cmd_set_link_down_result {
8028 cmdline_fixed_string_t set;
8029 cmdline_fixed_string_t link_down;
8030 cmdline_fixed_string_t port;
8034 static cmdline_parse_token_string_t cmd_set_link_down_set =
8035 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
8036 static cmdline_parse_token_string_t cmd_set_link_down_link_down =
8037 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
8039 static cmdline_parse_token_string_t cmd_set_link_down_port =
8040 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
8041 static cmdline_parse_token_num_t cmd_set_link_down_port_id =
8042 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
8045 static void cmd_set_link_down_parsed(
8046 __rte_unused void *parsed_result,
8047 __rte_unused struct cmdline *cl,
8048 __rte_unused void *data)
8050 struct cmd_set_link_down_result *res = parsed_result;
8051 dev_set_link_down(res->port_id);
8054 static cmdline_parse_inst_t cmd_set_link_down = {
8055 .f = cmd_set_link_down_parsed,
8057 .help_str = "set link-down port <port id>",
8059 (void *)&cmd_set_link_down_set,
8060 (void *)&cmd_set_link_down_link_down,
8061 (void *)&cmd_set_link_down_port,
8062 (void *)&cmd_set_link_down_port_id,
8067 /* *** SHOW CFG *** */
8068 struct cmd_showcfg_result {
8069 cmdline_fixed_string_t show;
8070 cmdline_fixed_string_t cfg;
8071 cmdline_fixed_string_t what;
8074 static void cmd_showcfg_parsed(void *parsed_result,
8075 __rte_unused struct cmdline *cl,
8076 __rte_unused void *data)
8078 struct cmd_showcfg_result *res = parsed_result;
8079 if (!strcmp(res->what, "rxtx"))
8080 rxtx_config_display();
8081 else if (!strcmp(res->what, "cores"))
8082 fwd_lcores_config_display();
8083 else if (!strcmp(res->what, "fwd"))
8084 pkt_fwd_config_display(&cur_fwd_config);
8085 else if (!strcmp(res->what, "rxoffs"))
8086 show_rx_pkt_offsets();
8087 else if (!strcmp(res->what, "rxpkts"))
8088 show_rx_pkt_segments();
8089 else if (!strcmp(res->what, "txpkts"))
8090 show_tx_pkt_segments();
8091 else if (!strcmp(res->what, "txtimes"))
8092 show_tx_pkt_times();
8095 static cmdline_parse_token_string_t cmd_showcfg_show =
8096 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
8097 static cmdline_parse_token_string_t cmd_showcfg_port =
8098 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
8099 static cmdline_parse_token_string_t cmd_showcfg_what =
8100 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
8101 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
8103 static cmdline_parse_inst_t cmd_showcfg = {
8104 .f = cmd_showcfg_parsed,
8106 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
8108 (void *)&cmd_showcfg_show,
8109 (void *)&cmd_showcfg_port,
8110 (void *)&cmd_showcfg_what,
8115 /* *** SHOW ALL PORT INFO *** */
8116 struct cmd_showportall_result {
8117 cmdline_fixed_string_t show;
8118 cmdline_fixed_string_t port;
8119 cmdline_fixed_string_t what;
8120 cmdline_fixed_string_t all;
8123 static void cmd_showportall_parsed(void *parsed_result,
8124 __rte_unused struct cmdline *cl,
8125 __rte_unused void *data)
8129 struct cmd_showportall_result *res = parsed_result;
8130 if (!strcmp(res->show, "clear")) {
8131 if (!strcmp(res->what, "stats"))
8132 RTE_ETH_FOREACH_DEV(i)
8134 else if (!strcmp(res->what, "xstats"))
8135 RTE_ETH_FOREACH_DEV(i)
8136 nic_xstats_clear(i);
8137 } else if (!strcmp(res->what, "info"))
8138 RTE_ETH_FOREACH_DEV(i)
8139 port_infos_display(i);
8140 else if (!strcmp(res->what, "summary")) {
8141 port_summary_header_display();
8142 RTE_ETH_FOREACH_DEV(i)
8143 port_summary_display(i);
8145 else if (!strcmp(res->what, "stats"))
8146 RTE_ETH_FOREACH_DEV(i)
8147 nic_stats_display(i);
8148 else if (!strcmp(res->what, "xstats"))
8149 RTE_ETH_FOREACH_DEV(i)
8150 nic_xstats_display(i);
8151 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
8152 else if (!strcmp(res->what, "fdir"))
8153 RTE_ETH_FOREACH_DEV(i)
8156 else if (!strcmp(res->what, "dcb_tc"))
8157 RTE_ETH_FOREACH_DEV(i)
8158 port_dcb_info_display(i);
8161 static cmdline_parse_token_string_t cmd_showportall_show =
8162 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
8164 static cmdline_parse_token_string_t cmd_showportall_port =
8165 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
8166 static cmdline_parse_token_string_t cmd_showportall_what =
8167 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
8168 "info#summary#stats#xstats#fdir#dcb_tc");
8169 static cmdline_parse_token_string_t cmd_showportall_all =
8170 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
8171 static cmdline_parse_inst_t cmd_showportall = {
8172 .f = cmd_showportall_parsed,
8174 .help_str = "show|clear port "
8175 "info|summary|stats|xstats|fdir|dcb_tc all",
8177 (void *)&cmd_showportall_show,
8178 (void *)&cmd_showportall_port,
8179 (void *)&cmd_showportall_what,
8180 (void *)&cmd_showportall_all,
8185 /* *** SHOW PORT INFO *** */
8186 struct cmd_showport_result {
8187 cmdline_fixed_string_t show;
8188 cmdline_fixed_string_t port;
8189 cmdline_fixed_string_t what;
8193 static void cmd_showport_parsed(void *parsed_result,
8194 __rte_unused struct cmdline *cl,
8195 __rte_unused void *data)
8197 struct cmd_showport_result *res = parsed_result;
8198 if (!strcmp(res->show, "clear")) {
8199 if (!strcmp(res->what, "stats"))
8200 nic_stats_clear(res->portnum);
8201 else if (!strcmp(res->what, "xstats"))
8202 nic_xstats_clear(res->portnum);
8203 } else if (!strcmp(res->what, "info"))
8204 port_infos_display(res->portnum);
8205 else if (!strcmp(res->what, "summary")) {
8206 port_summary_header_display();
8207 port_summary_display(res->portnum);
8209 else if (!strcmp(res->what, "stats"))
8210 nic_stats_display(res->portnum);
8211 else if (!strcmp(res->what, "xstats"))
8212 nic_xstats_display(res->portnum);
8213 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
8214 else if (!strcmp(res->what, "fdir"))
8215 fdir_get_infos(res->portnum);
8217 else if (!strcmp(res->what, "dcb_tc"))
8218 port_dcb_info_display(res->portnum);
8221 static cmdline_parse_token_string_t cmd_showport_show =
8222 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
8224 static cmdline_parse_token_string_t cmd_showport_port =
8225 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
8226 static cmdline_parse_token_string_t cmd_showport_what =
8227 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
8228 "info#summary#stats#xstats#fdir#dcb_tc");
8229 static cmdline_parse_token_num_t cmd_showport_portnum =
8230 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
8232 static cmdline_parse_inst_t cmd_showport = {
8233 .f = cmd_showport_parsed,
8235 .help_str = "show|clear port "
8236 "info|summary|stats|xstats|fdir|dcb_tc "
8239 (void *)&cmd_showport_show,
8240 (void *)&cmd_showport_port,
8241 (void *)&cmd_showport_what,
8242 (void *)&cmd_showport_portnum,
8247 /* *** show port representors information *** */
8248 struct cmd_representor_info_result {
8249 cmdline_fixed_string_t cmd_show;
8250 cmdline_fixed_string_t cmd_port;
8251 cmdline_fixed_string_t cmd_info;
8252 cmdline_fixed_string_t cmd_keyword;
8257 cmd_representor_info_parsed(void *parsed_result,
8258 __rte_unused struct cmdline *cl,
8259 __rte_unused void *data)
8261 struct cmd_representor_info_result *res = parsed_result;
8262 struct rte_eth_representor_info *info;
8263 struct rte_eth_representor_range *range;
8264 uint32_t range_diff;
8269 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
8270 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
8274 ret = rte_eth_representor_info_get(res->cmd_pid, NULL);
8277 "Failed to get the number of representor info ranges for port %hu: %s\n",
8278 res->cmd_pid, rte_strerror(-ret));
8283 info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0]));
8286 "Failed to allocate memory for representor info for port %hu\n",
8290 info->nb_ranges_alloc = num;
8292 ret = rte_eth_representor_info_get(res->cmd_pid, info);
8295 "Failed to get the representor info for port %hu: %s\n",
8296 res->cmd_pid, rte_strerror(-ret));
8301 printf("Port controller: %hu\n", info->controller);
8302 printf("Port PF: %hu\n", info->pf);
8304 printf("Ranges: %u\n", info->nb_ranges);
8305 for (i = 0; i < info->nb_ranges; i++) {
8306 range = &info->ranges[i];
8307 range_diff = range->id_end - range->id_base;
8309 printf("%u. ", i + 1);
8310 printf("'%s' ", range->name);
8312 printf("[%u-%u]: ", range->id_base, range->id_end);
8314 printf("[%u]: ", range->id_base);
8316 printf("Controller %d, PF %d", range->controller, range->pf);
8318 switch (range->type) {
8319 case RTE_ETH_REPRESENTOR_NONE:
8322 case RTE_ETH_REPRESENTOR_VF:
8324 printf(", VF %d..%d\n", range->vf,
8325 range->vf + range_diff);
8327 printf(", VF %d\n", range->vf);
8329 case RTE_ETH_REPRESENTOR_SF:
8330 printf(", SF %d\n", range->sf);
8332 case RTE_ETH_REPRESENTOR_PF:
8334 printf("..%d\n", range->pf + range_diff);
8339 printf(", UNKNOWN TYPE %d\n", range->type);
8347 static cmdline_parse_token_string_t cmd_representor_info_show =
8348 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8350 static cmdline_parse_token_string_t cmd_representor_info_port =
8351 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8353 static cmdline_parse_token_string_t cmd_representor_info_info =
8354 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8356 static cmdline_parse_token_num_t cmd_representor_info_pid =
8357 TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result,
8358 cmd_pid, RTE_UINT16);
8359 static cmdline_parse_token_string_t cmd_representor_info_keyword =
8360 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8361 cmd_keyword, "representor");
8363 static cmdline_parse_inst_t cmd_representor_info = {
8364 .f = cmd_representor_info_parsed,
8366 .help_str = "show port info <port_id> representor",
8368 (void *)&cmd_representor_info_show,
8369 (void *)&cmd_representor_info_port,
8370 (void *)&cmd_representor_info_info,
8371 (void *)&cmd_representor_info_pid,
8372 (void *)&cmd_representor_info_keyword,
8378 /* *** SHOW DEVICE INFO *** */
8379 struct cmd_showdevice_result {
8380 cmdline_fixed_string_t show;
8381 cmdline_fixed_string_t device;
8382 cmdline_fixed_string_t what;
8383 cmdline_fixed_string_t identifier;
8386 static void cmd_showdevice_parsed(void *parsed_result,
8387 __rte_unused struct cmdline *cl,
8388 __rte_unused void *data)
8390 struct cmd_showdevice_result *res = parsed_result;
8391 if (!strcmp(res->what, "info")) {
8392 if (!strcmp(res->identifier, "all"))
8393 device_infos_display(NULL);
8395 device_infos_display(res->identifier);
8399 static cmdline_parse_token_string_t cmd_showdevice_show =
8400 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
8402 static cmdline_parse_token_string_t cmd_showdevice_device =
8403 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
8404 static cmdline_parse_token_string_t cmd_showdevice_what =
8405 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
8407 static cmdline_parse_token_string_t cmd_showdevice_identifier =
8408 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
8411 static cmdline_parse_inst_t cmd_showdevice = {
8412 .f = cmd_showdevice_parsed,
8414 .help_str = "show device info <identifier>|all",
8416 (void *)&cmd_showdevice_show,
8417 (void *)&cmd_showdevice_device,
8418 (void *)&cmd_showdevice_what,
8419 (void *)&cmd_showdevice_identifier,
8424 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
8425 struct cmd_showeeprom_result {
8426 cmdline_fixed_string_t show;
8427 cmdline_fixed_string_t port;
8429 cmdline_fixed_string_t type;
8432 static void cmd_showeeprom_parsed(void *parsed_result,
8433 __rte_unused struct cmdline *cl,
8434 __rte_unused void *data)
8436 struct cmd_showeeprom_result *res = parsed_result;
8438 if (!strcmp(res->type, "eeprom"))
8439 port_eeprom_display(res->portnum);
8440 else if (!strcmp(res->type, "module_eeprom"))
8441 port_module_eeprom_display(res->portnum);
8443 fprintf(stderr, "Unknown argument\n");
8446 static cmdline_parse_token_string_t cmd_showeeprom_show =
8447 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
8448 static cmdline_parse_token_string_t cmd_showeeprom_port =
8449 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
8450 static cmdline_parse_token_num_t cmd_showeeprom_portnum =
8451 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
8453 static cmdline_parse_token_string_t cmd_showeeprom_type =
8454 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
8456 static cmdline_parse_inst_t cmd_showeeprom = {
8457 .f = cmd_showeeprom_parsed,
8459 .help_str = "show port <port_id> module_eeprom|eeprom",
8461 (void *)&cmd_showeeprom_show,
8462 (void *)&cmd_showeeprom_port,
8463 (void *)&cmd_showeeprom_portnum,
8464 (void *)&cmd_showeeprom_type,
8469 /* *** SHOW QUEUE INFO *** */
8470 struct cmd_showqueue_result {
8471 cmdline_fixed_string_t show;
8472 cmdline_fixed_string_t type;
8473 cmdline_fixed_string_t what;
8479 cmd_showqueue_parsed(void *parsed_result,
8480 __rte_unused struct cmdline *cl,
8481 __rte_unused void *data)
8483 struct cmd_showqueue_result *res = parsed_result;
8485 if (!strcmp(res->type, "rxq"))
8486 rx_queue_infos_display(res->portnum, res->queuenum);
8487 else if (!strcmp(res->type, "txq"))
8488 tx_queue_infos_display(res->portnum, res->queuenum);
8491 static cmdline_parse_token_string_t cmd_showqueue_show =
8492 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
8493 static cmdline_parse_token_string_t cmd_showqueue_type =
8494 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
8495 static cmdline_parse_token_string_t cmd_showqueue_what =
8496 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
8497 static cmdline_parse_token_num_t cmd_showqueue_portnum =
8498 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
8500 static cmdline_parse_token_num_t cmd_showqueue_queuenum =
8501 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
8504 static cmdline_parse_inst_t cmd_showqueue = {
8505 .f = cmd_showqueue_parsed,
8507 .help_str = "show rxq|txq info <port_id> <queue_id>",
8509 (void *)&cmd_showqueue_show,
8510 (void *)&cmd_showqueue_type,
8511 (void *)&cmd_showqueue_what,
8512 (void *)&cmd_showqueue_portnum,
8513 (void *)&cmd_showqueue_queuenum,
8518 /* show/clear fwd engine statistics */
8520 cmdline_fixed_string_t action;
8521 cmdline_fixed_string_t fwd;
8522 cmdline_fixed_string_t stats;
8523 cmdline_fixed_string_t all;
8526 static cmdline_parse_token_string_t cmd_fwd_action =
8527 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
8528 static cmdline_parse_token_string_t cmd_fwd_fwd =
8529 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
8530 static cmdline_parse_token_string_t cmd_fwd_stats =
8531 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
8532 static cmdline_parse_token_string_t cmd_fwd_all =
8533 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
8536 cmd_showfwdall_parsed(void *parsed_result,
8537 __rte_unused struct cmdline *cl,
8538 __rte_unused void *data)
8540 struct fwd_result *res = parsed_result;
8542 if (!strcmp(res->action, "show"))
8543 fwd_stats_display();
8548 static cmdline_parse_inst_t cmd_showfwdall = {
8549 .f = cmd_showfwdall_parsed,
8551 .help_str = "show|clear fwd stats all",
8553 (void *)&cmd_fwd_action,
8554 (void *)&cmd_fwd_fwd,
8555 (void *)&cmd_fwd_stats,
8556 (void *)&cmd_fwd_all,
8561 /* *** READ PORT REGISTER *** */
8562 struct cmd_read_reg_result {
8563 cmdline_fixed_string_t read;
8564 cmdline_fixed_string_t reg;
8570 cmd_read_reg_parsed(void *parsed_result,
8571 __rte_unused struct cmdline *cl,
8572 __rte_unused void *data)
8574 struct cmd_read_reg_result *res = parsed_result;
8575 port_reg_display(res->port_id, res->reg_off);
8578 static cmdline_parse_token_string_t cmd_read_reg_read =
8579 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
8580 static cmdline_parse_token_string_t cmd_read_reg_reg =
8581 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
8582 static cmdline_parse_token_num_t cmd_read_reg_port_id =
8583 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
8584 static cmdline_parse_token_num_t cmd_read_reg_reg_off =
8585 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
8587 static cmdline_parse_inst_t cmd_read_reg = {
8588 .f = cmd_read_reg_parsed,
8590 .help_str = "read reg <port_id> <reg_off>",
8592 (void *)&cmd_read_reg_read,
8593 (void *)&cmd_read_reg_reg,
8594 (void *)&cmd_read_reg_port_id,
8595 (void *)&cmd_read_reg_reg_off,
8600 /* *** READ PORT REGISTER BIT FIELD *** */
8601 struct cmd_read_reg_bit_field_result {
8602 cmdline_fixed_string_t read;
8603 cmdline_fixed_string_t regfield;
8611 cmd_read_reg_bit_field_parsed(void *parsed_result,
8612 __rte_unused struct cmdline *cl,
8613 __rte_unused void *data)
8615 struct cmd_read_reg_bit_field_result *res = parsed_result;
8616 port_reg_bit_field_display(res->port_id, res->reg_off,
8617 res->bit1_pos, res->bit2_pos);
8620 static cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8621 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8623 static cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8624 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8625 regfield, "regfield");
8626 static cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8627 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8629 static cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8630 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8632 static cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8633 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8635 static cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8636 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8639 static cmdline_parse_inst_t cmd_read_reg_bit_field = {
8640 .f = cmd_read_reg_bit_field_parsed,
8642 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8643 "Read register bit field between bit_x and bit_y included",
8645 (void *)&cmd_read_reg_bit_field_read,
8646 (void *)&cmd_read_reg_bit_field_regfield,
8647 (void *)&cmd_read_reg_bit_field_port_id,
8648 (void *)&cmd_read_reg_bit_field_reg_off,
8649 (void *)&cmd_read_reg_bit_field_bit1_pos,
8650 (void *)&cmd_read_reg_bit_field_bit2_pos,
8655 /* *** READ PORT REGISTER BIT *** */
8656 struct cmd_read_reg_bit_result {
8657 cmdline_fixed_string_t read;
8658 cmdline_fixed_string_t regbit;
8665 cmd_read_reg_bit_parsed(void *parsed_result,
8666 __rte_unused struct cmdline *cl,
8667 __rte_unused void *data)
8669 struct cmd_read_reg_bit_result *res = parsed_result;
8670 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8673 static cmdline_parse_token_string_t cmd_read_reg_bit_read =
8674 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8675 static cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8676 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8678 static cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8679 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
8681 static cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8682 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
8684 static cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8685 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
8688 static cmdline_parse_inst_t cmd_read_reg_bit = {
8689 .f = cmd_read_reg_bit_parsed,
8691 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8693 (void *)&cmd_read_reg_bit_read,
8694 (void *)&cmd_read_reg_bit_regbit,
8695 (void *)&cmd_read_reg_bit_port_id,
8696 (void *)&cmd_read_reg_bit_reg_off,
8697 (void *)&cmd_read_reg_bit_bit_pos,
8702 /* *** WRITE PORT REGISTER *** */
8703 struct cmd_write_reg_result {
8704 cmdline_fixed_string_t write;
8705 cmdline_fixed_string_t reg;
8712 cmd_write_reg_parsed(void *parsed_result,
8713 __rte_unused struct cmdline *cl,
8714 __rte_unused void *data)
8716 struct cmd_write_reg_result *res = parsed_result;
8717 port_reg_set(res->port_id, res->reg_off, res->value);
8720 static cmdline_parse_token_string_t cmd_write_reg_write =
8721 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8722 static cmdline_parse_token_string_t cmd_write_reg_reg =
8723 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8724 static cmdline_parse_token_num_t cmd_write_reg_port_id =
8725 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8726 static cmdline_parse_token_num_t cmd_write_reg_reg_off =
8727 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8728 static cmdline_parse_token_num_t cmd_write_reg_value =
8729 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8731 static cmdline_parse_inst_t cmd_write_reg = {
8732 .f = cmd_write_reg_parsed,
8734 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8736 (void *)&cmd_write_reg_write,
8737 (void *)&cmd_write_reg_reg,
8738 (void *)&cmd_write_reg_port_id,
8739 (void *)&cmd_write_reg_reg_off,
8740 (void *)&cmd_write_reg_value,
8745 /* *** WRITE PORT REGISTER BIT FIELD *** */
8746 struct cmd_write_reg_bit_field_result {
8747 cmdline_fixed_string_t write;
8748 cmdline_fixed_string_t regfield;
8757 cmd_write_reg_bit_field_parsed(void *parsed_result,
8758 __rte_unused struct cmdline *cl,
8759 __rte_unused void *data)
8761 struct cmd_write_reg_bit_field_result *res = parsed_result;
8762 port_reg_bit_field_set(res->port_id, res->reg_off,
8763 res->bit1_pos, res->bit2_pos, res->value);
8766 static cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8767 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8769 static cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8770 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8771 regfield, "regfield");
8772 static cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8773 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8775 static cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8776 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8778 static cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8779 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8781 static cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8782 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8784 static cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8785 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8788 static cmdline_parse_inst_t cmd_write_reg_bit_field = {
8789 .f = cmd_write_reg_bit_field_parsed,
8791 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8793 "Set register bit field between bit_x and bit_y included",
8795 (void *)&cmd_write_reg_bit_field_write,
8796 (void *)&cmd_write_reg_bit_field_regfield,
8797 (void *)&cmd_write_reg_bit_field_port_id,
8798 (void *)&cmd_write_reg_bit_field_reg_off,
8799 (void *)&cmd_write_reg_bit_field_bit1_pos,
8800 (void *)&cmd_write_reg_bit_field_bit2_pos,
8801 (void *)&cmd_write_reg_bit_field_value,
8806 /* *** WRITE PORT REGISTER BIT *** */
8807 struct cmd_write_reg_bit_result {
8808 cmdline_fixed_string_t write;
8809 cmdline_fixed_string_t regbit;
8817 cmd_write_reg_bit_parsed(void *parsed_result,
8818 __rte_unused struct cmdline *cl,
8819 __rte_unused void *data)
8821 struct cmd_write_reg_bit_result *res = parsed_result;
8822 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8825 static cmdline_parse_token_string_t cmd_write_reg_bit_write =
8826 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8828 static cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8829 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8831 static cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8832 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8834 static cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8835 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8837 static cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8838 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8840 static cmdline_parse_token_num_t cmd_write_reg_bit_value =
8841 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8844 static cmdline_parse_inst_t cmd_write_reg_bit = {
8845 .f = cmd_write_reg_bit_parsed,
8847 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8850 (void *)&cmd_write_reg_bit_write,
8851 (void *)&cmd_write_reg_bit_regbit,
8852 (void *)&cmd_write_reg_bit_port_id,
8853 (void *)&cmd_write_reg_bit_reg_off,
8854 (void *)&cmd_write_reg_bit_bit_pos,
8855 (void *)&cmd_write_reg_bit_value,
8860 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8861 struct cmd_read_rxd_txd_result {
8862 cmdline_fixed_string_t read;
8863 cmdline_fixed_string_t rxd_txd;
8870 cmd_read_rxd_txd_parsed(void *parsed_result,
8871 __rte_unused struct cmdline *cl,
8872 __rte_unused void *data)
8874 struct cmd_read_rxd_txd_result *res = parsed_result;
8876 if (!strcmp(res->rxd_txd, "rxd"))
8877 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8878 else if (!strcmp(res->rxd_txd, "txd"))
8879 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8882 static cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8883 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8884 static cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8885 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8887 static cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8888 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8890 static cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8891 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8893 static cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8894 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8897 static cmdline_parse_inst_t cmd_read_rxd_txd = {
8898 .f = cmd_read_rxd_txd_parsed,
8900 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8902 (void *)&cmd_read_rxd_txd_read,
8903 (void *)&cmd_read_rxd_txd_rxd_txd,
8904 (void *)&cmd_read_rxd_txd_port_id,
8905 (void *)&cmd_read_rxd_txd_queue_id,
8906 (void *)&cmd_read_rxd_txd_desc_id,
8912 struct cmd_quit_result {
8913 cmdline_fixed_string_t quit;
8916 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8918 __rte_unused void *data)
8923 static cmdline_parse_token_string_t cmd_quit_quit =
8924 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8926 static cmdline_parse_inst_t cmd_quit = {
8927 .f = cmd_quit_parsed,
8929 .help_str = "quit: Exit application",
8931 (void *)&cmd_quit_quit,
8936 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8937 struct cmd_mac_addr_result {
8938 cmdline_fixed_string_t mac_addr_cmd;
8939 cmdline_fixed_string_t what;
8941 struct rte_ether_addr address;
8944 static void cmd_mac_addr_parsed(void *parsed_result,
8945 __rte_unused struct cmdline *cl,
8946 __rte_unused void *data)
8948 struct cmd_mac_addr_result *res = parsed_result;
8951 if (strcmp(res->what, "add") == 0)
8952 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8953 else if (strcmp(res->what, "set") == 0)
8954 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8957 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8959 /* check the return value and print it if is < 0 */
8961 fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
8965 static cmdline_parse_token_string_t cmd_mac_addr_cmd =
8966 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8968 static cmdline_parse_token_string_t cmd_mac_addr_what =
8969 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8971 static cmdline_parse_token_num_t cmd_mac_addr_portnum =
8972 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8974 static cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8975 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8977 static cmdline_parse_inst_t cmd_mac_addr = {
8978 .f = cmd_mac_addr_parsed,
8980 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8981 "Add/Remove/Set MAC address on port_id",
8983 (void *)&cmd_mac_addr_cmd,
8984 (void *)&cmd_mac_addr_what,
8985 (void *)&cmd_mac_addr_portnum,
8986 (void *)&cmd_mac_addr_addr,
8991 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8992 struct cmd_eth_peer_result {
8993 cmdline_fixed_string_t set;
8994 cmdline_fixed_string_t eth_peer;
8996 cmdline_fixed_string_t peer_addr;
8999 static void cmd_set_eth_peer_parsed(void *parsed_result,
9000 __rte_unused struct cmdline *cl,
9001 __rte_unused void *data)
9003 struct cmd_eth_peer_result *res = parsed_result;
9005 if (test_done == 0) {
9006 fprintf(stderr, "Please stop forwarding first\n");
9009 if (!strcmp(res->eth_peer, "eth-peer")) {
9010 set_fwd_eth_peer(res->port_id, res->peer_addr);
9014 static cmdline_parse_token_string_t cmd_eth_peer_set =
9015 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
9016 static cmdline_parse_token_string_t cmd_eth_peer =
9017 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
9018 static cmdline_parse_token_num_t cmd_eth_peer_port_id =
9019 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
9021 static cmdline_parse_token_string_t cmd_eth_peer_addr =
9022 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
9024 static cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
9025 .f = cmd_set_eth_peer_parsed,
9027 .help_str = "set eth-peer <port_id> <peer_mac>",
9029 (void *)&cmd_eth_peer_set,
9030 (void *)&cmd_eth_peer,
9031 (void *)&cmd_eth_peer_port_id,
9032 (void *)&cmd_eth_peer_addr,
9037 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
9038 struct cmd_set_qmap_result {
9039 cmdline_fixed_string_t set;
9040 cmdline_fixed_string_t qmap;
9041 cmdline_fixed_string_t what;
9048 cmd_set_qmap_parsed(void *parsed_result,
9049 __rte_unused struct cmdline *cl,
9050 __rte_unused void *data)
9052 struct cmd_set_qmap_result *res = parsed_result;
9053 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
9055 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
9058 static cmdline_parse_token_string_t cmd_setqmap_set =
9059 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
9061 static cmdline_parse_token_string_t cmd_setqmap_qmap =
9062 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
9064 static cmdline_parse_token_string_t cmd_setqmap_what =
9065 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
9067 static cmdline_parse_token_num_t cmd_setqmap_portid =
9068 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
9069 port_id, RTE_UINT16);
9070 static cmdline_parse_token_num_t cmd_setqmap_queueid =
9071 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
9072 queue_id, RTE_UINT16);
9073 static cmdline_parse_token_num_t cmd_setqmap_mapvalue =
9074 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
9075 map_value, RTE_UINT8);
9077 static cmdline_parse_inst_t cmd_set_qmap = {
9078 .f = cmd_set_qmap_parsed,
9080 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
9081 "Set statistics mapping value on tx|rx queue_id of port_id",
9083 (void *)&cmd_setqmap_set,
9084 (void *)&cmd_setqmap_qmap,
9085 (void *)&cmd_setqmap_what,
9086 (void *)&cmd_setqmap_portid,
9087 (void *)&cmd_setqmap_queueid,
9088 (void *)&cmd_setqmap_mapvalue,
9093 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
9094 struct cmd_set_xstats_hide_zero_result {
9095 cmdline_fixed_string_t keyword;
9096 cmdline_fixed_string_t name;
9097 cmdline_fixed_string_t on_off;
9101 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
9102 __rte_unused struct cmdline *cl,
9103 __rte_unused void *data)
9105 struct cmd_set_xstats_hide_zero_result *res;
9106 uint16_t on_off = 0;
9108 res = parsed_result;
9109 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9110 set_xstats_hide_zero(on_off);
9113 static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
9114 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
9116 static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
9117 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
9118 name, "xstats-hide-zero");
9119 static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
9120 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
9123 static cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
9124 .f = cmd_set_xstats_hide_zero_parsed,
9126 .help_str = "set xstats-hide-zero on|off",
9128 (void *)&cmd_set_xstats_hide_zero_keyword,
9129 (void *)&cmd_set_xstats_hide_zero_name,
9130 (void *)&cmd_set_xstats_hide_zero_on_off,
9135 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
9136 struct cmd_set_record_core_cycles_result {
9137 cmdline_fixed_string_t keyword;
9138 cmdline_fixed_string_t name;
9139 cmdline_fixed_string_t on_off;
9143 cmd_set_record_core_cycles_parsed(void *parsed_result,
9144 __rte_unused struct cmdline *cl,
9145 __rte_unused void *data)
9147 struct cmd_set_record_core_cycles_result *res;
9148 uint16_t on_off = 0;
9150 res = parsed_result;
9151 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9152 set_record_core_cycles(on_off);
9155 static cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
9156 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9158 static cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
9159 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9160 name, "record-core-cycles");
9161 static cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
9162 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9165 static cmdline_parse_inst_t cmd_set_record_core_cycles = {
9166 .f = cmd_set_record_core_cycles_parsed,
9168 .help_str = "set record-core-cycles on|off",
9170 (void *)&cmd_set_record_core_cycles_keyword,
9171 (void *)&cmd_set_record_core_cycles_name,
9172 (void *)&cmd_set_record_core_cycles_on_off,
9177 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
9178 struct cmd_set_record_burst_stats_result {
9179 cmdline_fixed_string_t keyword;
9180 cmdline_fixed_string_t name;
9181 cmdline_fixed_string_t on_off;
9185 cmd_set_record_burst_stats_parsed(void *parsed_result,
9186 __rte_unused struct cmdline *cl,
9187 __rte_unused void *data)
9189 struct cmd_set_record_burst_stats_result *res;
9190 uint16_t on_off = 0;
9192 res = parsed_result;
9193 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9194 set_record_burst_stats(on_off);
9197 static cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
9198 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9200 static cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
9201 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9202 name, "record-burst-stats");
9203 static cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
9204 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9207 static cmdline_parse_inst_t cmd_set_record_burst_stats = {
9208 .f = cmd_set_record_burst_stats_parsed,
9210 .help_str = "set record-burst-stats on|off",
9212 (void *)&cmd_set_record_burst_stats_keyword,
9213 (void *)&cmd_set_record_burst_stats_name,
9214 (void *)&cmd_set_record_burst_stats_on_off,
9219 /* *** CONFIGURE UNICAST HASH TABLE *** */
9220 struct cmd_set_uc_hash_table {
9221 cmdline_fixed_string_t set;
9222 cmdline_fixed_string_t port;
9224 cmdline_fixed_string_t what;
9225 struct rte_ether_addr address;
9226 cmdline_fixed_string_t mode;
9230 cmd_set_uc_hash_parsed(void *parsed_result,
9231 __rte_unused struct cmdline *cl,
9232 __rte_unused void *data)
9235 struct cmd_set_uc_hash_table *res = parsed_result;
9237 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9239 if (strcmp(res->what, "uta") == 0)
9240 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
9241 &res->address,(uint8_t)is_on);
9244 "bad unicast hash table parameter, return code = %d\n",
9249 static cmdline_parse_token_string_t cmd_set_uc_hash_set =
9250 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9252 static cmdline_parse_token_string_t cmd_set_uc_hash_port =
9253 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9255 static cmdline_parse_token_num_t cmd_set_uc_hash_portid =
9256 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
9257 port_id, RTE_UINT16);
9258 static cmdline_parse_token_string_t cmd_set_uc_hash_what =
9259 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9261 static cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
9262 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
9264 static cmdline_parse_token_string_t cmd_set_uc_hash_mode =
9265 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9268 static cmdline_parse_inst_t cmd_set_uc_hash_filter = {
9269 .f = cmd_set_uc_hash_parsed,
9271 .help_str = "set port <port_id> uta <mac_addr> on|off)",
9273 (void *)&cmd_set_uc_hash_set,
9274 (void *)&cmd_set_uc_hash_port,
9275 (void *)&cmd_set_uc_hash_portid,
9276 (void *)&cmd_set_uc_hash_what,
9277 (void *)&cmd_set_uc_hash_mac,
9278 (void *)&cmd_set_uc_hash_mode,
9283 struct cmd_set_uc_all_hash_table {
9284 cmdline_fixed_string_t set;
9285 cmdline_fixed_string_t port;
9287 cmdline_fixed_string_t what;
9288 cmdline_fixed_string_t value;
9289 cmdline_fixed_string_t mode;
9293 cmd_set_uc_all_hash_parsed(void *parsed_result,
9294 __rte_unused struct cmdline *cl,
9295 __rte_unused void *data)
9298 struct cmd_set_uc_all_hash_table *res = parsed_result;
9300 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9302 if ((strcmp(res->what, "uta") == 0) &&
9303 (strcmp(res->value, "all") == 0))
9304 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
9307 "bad unicast hash table parameter, return code = %d\n",
9311 static cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
9312 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9314 static cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
9315 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9317 static cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
9318 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
9319 port_id, RTE_UINT16);
9320 static cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
9321 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9323 static cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
9324 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9326 static cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
9327 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9330 static cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
9331 .f = cmd_set_uc_all_hash_parsed,
9333 .help_str = "set port <port_id> uta all on|off",
9335 (void *)&cmd_set_uc_all_hash_set,
9336 (void *)&cmd_set_uc_all_hash_port,
9337 (void *)&cmd_set_uc_all_hash_portid,
9338 (void *)&cmd_set_uc_all_hash_what,
9339 (void *)&cmd_set_uc_all_hash_value,
9340 (void *)&cmd_set_uc_all_hash_mode,
9345 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
9346 struct cmd_set_vf_traffic {
9347 cmdline_fixed_string_t set;
9348 cmdline_fixed_string_t port;
9350 cmdline_fixed_string_t vf;
9352 cmdline_fixed_string_t what;
9353 cmdline_fixed_string_t mode;
9357 cmd_set_vf_traffic_parsed(void *parsed_result,
9358 __rte_unused struct cmdline *cl,
9359 __rte_unused void *data)
9361 struct cmd_set_vf_traffic *res = parsed_result;
9362 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
9363 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9365 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
9368 static cmdline_parse_token_string_t cmd_setvf_traffic_set =
9369 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9371 static cmdline_parse_token_string_t cmd_setvf_traffic_port =
9372 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9374 static cmdline_parse_token_num_t cmd_setvf_traffic_portid =
9375 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9376 port_id, RTE_UINT16);
9377 static cmdline_parse_token_string_t cmd_setvf_traffic_vf =
9378 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9380 static cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
9381 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9383 static cmdline_parse_token_string_t cmd_setvf_traffic_what =
9384 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9386 static cmdline_parse_token_string_t cmd_setvf_traffic_mode =
9387 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9390 static cmdline_parse_inst_t cmd_set_vf_traffic = {
9391 .f = cmd_set_vf_traffic_parsed,
9393 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
9395 (void *)&cmd_setvf_traffic_set,
9396 (void *)&cmd_setvf_traffic_port,
9397 (void *)&cmd_setvf_traffic_portid,
9398 (void *)&cmd_setvf_traffic_vf,
9399 (void *)&cmd_setvf_traffic_vfid,
9400 (void *)&cmd_setvf_traffic_what,
9401 (void *)&cmd_setvf_traffic_mode,
9406 /* *** CONFIGURE VF RECEIVE MODE *** */
9407 struct cmd_set_vf_rxmode {
9408 cmdline_fixed_string_t set;
9409 cmdline_fixed_string_t port;
9411 cmdline_fixed_string_t vf;
9413 cmdline_fixed_string_t what;
9414 cmdline_fixed_string_t mode;
9415 cmdline_fixed_string_t on;
9419 cmd_set_vf_rxmode_parsed(void *parsed_result,
9420 __rte_unused struct cmdline *cl,
9421 __rte_unused void *data)
9424 uint16_t vf_rxmode = 0;
9425 struct cmd_set_vf_rxmode *res = parsed_result;
9427 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
9428 if (!strcmp(res->what,"rxmode")) {
9429 if (!strcmp(res->mode, "AUPE"))
9430 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_UNTAG;
9431 else if (!strcmp(res->mode, "ROPE"))
9432 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_HASH_UC;
9433 else if (!strcmp(res->mode, "BAM"))
9434 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_BROADCAST;
9435 else if (!strncmp(res->mode, "MPE",3))
9436 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_MULTICAST;
9439 RTE_SET_USED(is_on);
9440 RTE_SET_USED(vf_rxmode);
9442 #ifdef RTE_NET_IXGBE
9443 if (ret == -ENOTSUP)
9444 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
9445 vf_rxmode, (uint8_t)is_on);
9448 if (ret == -ENOTSUP)
9449 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
9450 vf_rxmode, (uint8_t)is_on);
9454 "bad VF receive mode parameter, return code = %d\n",
9458 static cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
9459 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9461 static cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
9462 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9464 static cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
9465 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9466 port_id, RTE_UINT16);
9467 static cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
9468 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9470 static cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
9471 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9473 static cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
9474 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9476 static cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
9477 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9478 mode, "AUPE#ROPE#BAM#MPE");
9479 static cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
9480 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9483 static cmdline_parse_inst_t cmd_set_vf_rxmode = {
9484 .f = cmd_set_vf_rxmode_parsed,
9486 .help_str = "set port <port_id> vf <vf_id> rxmode "
9487 "AUPE|ROPE|BAM|MPE on|off",
9489 (void *)&cmd_set_vf_rxmode_set,
9490 (void *)&cmd_set_vf_rxmode_port,
9491 (void *)&cmd_set_vf_rxmode_portid,
9492 (void *)&cmd_set_vf_rxmode_vf,
9493 (void *)&cmd_set_vf_rxmode_vfid,
9494 (void *)&cmd_set_vf_rxmode_what,
9495 (void *)&cmd_set_vf_rxmode_mode,
9496 (void *)&cmd_set_vf_rxmode_on,
9501 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
9502 struct cmd_vf_mac_addr_result {
9503 cmdline_fixed_string_t mac_addr_cmd;
9504 cmdline_fixed_string_t what;
9505 cmdline_fixed_string_t port;
9507 cmdline_fixed_string_t vf;
9509 struct rte_ether_addr address;
9512 static void cmd_vf_mac_addr_parsed(void *parsed_result,
9513 __rte_unused struct cmdline *cl,
9514 __rte_unused void *data)
9516 struct cmd_vf_mac_addr_result *res = parsed_result;
9519 if (strcmp(res->what, "add") != 0)
9523 if (ret == -ENOTSUP)
9524 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
9528 if (ret == -ENOTSUP)
9529 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
9534 fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
9538 static cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
9539 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9540 mac_addr_cmd,"mac_addr");
9541 static cmdline_parse_token_string_t cmd_vf_mac_addr_what =
9542 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9544 static cmdline_parse_token_string_t cmd_vf_mac_addr_port =
9545 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9547 static cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
9548 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9549 port_num, RTE_UINT16);
9550 static cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
9551 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9553 static cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
9554 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9556 static cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
9557 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
9560 static cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
9561 .f = cmd_vf_mac_addr_parsed,
9563 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
9564 "Add MAC address filtering for a VF on port_id",
9566 (void *)&cmd_vf_mac_addr_cmd,
9567 (void *)&cmd_vf_mac_addr_what,
9568 (void *)&cmd_vf_mac_addr_port,
9569 (void *)&cmd_vf_mac_addr_portnum,
9570 (void *)&cmd_vf_mac_addr_vf,
9571 (void *)&cmd_vf_mac_addr_vfnum,
9572 (void *)&cmd_vf_mac_addr_addr,
9577 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
9578 struct cmd_vf_rx_vlan_filter {
9579 cmdline_fixed_string_t rx_vlan;
9580 cmdline_fixed_string_t what;
9582 cmdline_fixed_string_t port;
9584 cmdline_fixed_string_t vf;
9589 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
9590 __rte_unused struct cmdline *cl,
9591 __rte_unused void *data)
9593 struct cmd_vf_rx_vlan_filter *res = parsed_result;
9596 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9598 #ifdef RTE_NET_IXGBE
9599 if (ret == -ENOTSUP)
9600 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9601 res->vlan_id, res->vf_mask, is_add);
9604 if (ret == -ENOTSUP)
9605 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9606 res->vlan_id, res->vf_mask, is_add);
9609 if (ret == -ENOTSUP)
9610 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9611 res->vlan_id, res->vf_mask, is_add);
9618 fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
9619 res->vlan_id, res->vf_mask);
9622 fprintf(stderr, "invalid port_id %d\n", res->port_id);
9625 fprintf(stderr, "function not implemented or supported\n");
9628 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9632 static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9633 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9634 rx_vlan, "rx_vlan");
9635 static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9636 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9638 static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9639 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9640 vlan_id, RTE_UINT16);
9641 static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9642 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9644 static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9645 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9646 port_id, RTE_UINT16);
9647 static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9648 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9650 static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9651 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9652 vf_mask, RTE_UINT64);
9654 static cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9655 .f = cmd_vf_rx_vlan_filter_parsed,
9657 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9658 "(vf_mask = hexadecimal VF mask)",
9660 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9661 (void *)&cmd_vf_rx_vlan_filter_what,
9662 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9663 (void *)&cmd_vf_rx_vlan_filter_port,
9664 (void *)&cmd_vf_rx_vlan_filter_portid,
9665 (void *)&cmd_vf_rx_vlan_filter_vf,
9666 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9671 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9672 struct cmd_queue_rate_limit_result {
9673 cmdline_fixed_string_t set;
9674 cmdline_fixed_string_t port;
9676 cmdline_fixed_string_t queue;
9678 cmdline_fixed_string_t rate;
9682 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9683 __rte_unused struct cmdline *cl,
9684 __rte_unused void *data)
9686 struct cmd_queue_rate_limit_result *res = parsed_result;
9689 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9690 && (strcmp(res->queue, "queue") == 0)
9691 && (strcmp(res->rate, "rate") == 0))
9692 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9695 fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
9700 static cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9701 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9703 static cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9704 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9706 static cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9707 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9708 port_num, RTE_UINT16);
9709 static cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9710 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9712 static cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9713 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9714 queue_num, RTE_UINT8);
9715 static cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9716 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9718 static cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9719 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9720 rate_num, RTE_UINT16);
9722 static cmdline_parse_inst_t cmd_queue_rate_limit = {
9723 .f = cmd_queue_rate_limit_parsed,
9725 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9726 "Set rate limit for a queue on port_id",
9728 (void *)&cmd_queue_rate_limit_set,
9729 (void *)&cmd_queue_rate_limit_port,
9730 (void *)&cmd_queue_rate_limit_portnum,
9731 (void *)&cmd_queue_rate_limit_queue,
9732 (void *)&cmd_queue_rate_limit_queuenum,
9733 (void *)&cmd_queue_rate_limit_rate,
9734 (void *)&cmd_queue_rate_limit_ratenum,
9739 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9740 struct cmd_vf_rate_limit_result {
9741 cmdline_fixed_string_t set;
9742 cmdline_fixed_string_t port;
9744 cmdline_fixed_string_t vf;
9746 cmdline_fixed_string_t rate;
9748 cmdline_fixed_string_t q_msk;
9752 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9753 __rte_unused struct cmdline *cl,
9754 __rte_unused void *data)
9756 struct cmd_vf_rate_limit_result *res = parsed_result;
9759 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9760 && (strcmp(res->vf, "vf") == 0)
9761 && (strcmp(res->rate, "rate") == 0)
9762 && (strcmp(res->q_msk, "queue_mask") == 0))
9763 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9764 res->rate_num, res->q_msk_val);
9766 fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
9771 static cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9772 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9774 static cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9775 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9777 static cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9778 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9779 port_num, RTE_UINT16);
9780 static cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9781 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9783 static cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9784 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9786 static cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9787 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9789 static cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9790 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9791 rate_num, RTE_UINT16);
9792 static cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9793 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9794 q_msk, "queue_mask");
9795 static cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9796 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9797 q_msk_val, RTE_UINT64);
9799 static cmdline_parse_inst_t cmd_vf_rate_limit = {
9800 .f = cmd_vf_rate_limit_parsed,
9802 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9803 "queue_mask <queue_mask_value>: "
9804 "Set rate limit for queues of VF on port_id",
9806 (void *)&cmd_vf_rate_limit_set,
9807 (void *)&cmd_vf_rate_limit_port,
9808 (void *)&cmd_vf_rate_limit_portnum,
9809 (void *)&cmd_vf_rate_limit_vf,
9810 (void *)&cmd_vf_rate_limit_vfnum,
9811 (void *)&cmd_vf_rate_limit_rate,
9812 (void *)&cmd_vf_rate_limit_ratenum,
9813 (void *)&cmd_vf_rate_limit_q_msk,
9814 (void *)&cmd_vf_rate_limit_q_msk_val,
9819 /* *** CONFIGURE TUNNEL UDP PORT *** */
9820 struct cmd_tunnel_udp_config {
9821 cmdline_fixed_string_t rx_vxlan_port;
9822 cmdline_fixed_string_t what;
9828 cmd_tunnel_udp_config_parsed(void *parsed_result,
9829 __rte_unused struct cmdline *cl,
9830 __rte_unused void *data)
9832 struct cmd_tunnel_udp_config *res = parsed_result;
9833 struct rte_eth_udp_tunnel tunnel_udp;
9836 tunnel_udp.udp_port = res->udp_port;
9837 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9839 if (!strcmp(res->what, "add"))
9840 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9843 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9847 fprintf(stderr, "udp tunneling add error: (%s)\n",
9851 static cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9852 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9853 rx_vxlan_port, "rx_vxlan_port");
9854 static cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9855 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9857 static cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9858 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9859 udp_port, RTE_UINT16);
9860 static cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9861 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9862 port_id, RTE_UINT16);
9864 static cmdline_parse_inst_t cmd_tunnel_udp_config = {
9865 .f = cmd_tunnel_udp_config_parsed,
9867 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9868 "Add/Remove a tunneling UDP port filter",
9870 (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9871 (void *)&cmd_tunnel_udp_config_what,
9872 (void *)&cmd_tunnel_udp_config_udp_port,
9873 (void *)&cmd_tunnel_udp_config_port_id,
9878 struct cmd_config_tunnel_udp_port {
9879 cmdline_fixed_string_t port;
9880 cmdline_fixed_string_t config;
9882 cmdline_fixed_string_t udp_tunnel_port;
9883 cmdline_fixed_string_t action;
9884 cmdline_fixed_string_t tunnel_type;
9889 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9890 __rte_unused struct cmdline *cl,
9891 __rte_unused void *data)
9893 struct cmd_config_tunnel_udp_port *res = parsed_result;
9894 struct rte_eth_udp_tunnel tunnel_udp;
9897 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9900 tunnel_udp.udp_port = res->udp_port;
9902 if (!strcmp(res->tunnel_type, "vxlan")) {
9903 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9904 } else if (!strcmp(res->tunnel_type, "geneve")) {
9905 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_GENEVE;
9906 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9907 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN_GPE;
9908 } else if (!strcmp(res->tunnel_type, "ecpri")) {
9909 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_ECPRI;
9911 fprintf(stderr, "Invalid tunnel type\n");
9915 if (!strcmp(res->action, "add"))
9916 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9919 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9923 fprintf(stderr, "udp tunneling port add error: (%s)\n",
9927 static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9928 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9930 static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9931 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9933 static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9934 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9936 static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9937 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9940 static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9941 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9943 static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9944 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9945 "vxlan#geneve#vxlan-gpe#ecpri");
9946 static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9947 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9950 static cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9951 .f = cmd_cfg_tunnel_udp_port_parsed,
9953 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9954 "geneve|vxlan-gpe|ecpri <udp_port>",
9956 (void *)&cmd_config_tunnel_udp_port_port,
9957 (void *)&cmd_config_tunnel_udp_port_config,
9958 (void *)&cmd_config_tunnel_udp_port_port_id,
9959 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9960 (void *)&cmd_config_tunnel_udp_port_action,
9961 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9962 (void *)&cmd_config_tunnel_udp_port_value,
9967 /* ******************************************************************************** */
9969 struct cmd_dump_result {
9970 cmdline_fixed_string_t dump;
9974 dump_struct_sizes(void)
9976 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9977 DUMP_SIZE(struct rte_mbuf);
9978 DUMP_SIZE(struct rte_mempool);
9979 DUMP_SIZE(struct rte_ring);
9984 /* Dump the socket memory statistics on console */
9986 dump_socket_mem(FILE *f)
9988 struct rte_malloc_socket_stats socket_stats;
9993 unsigned int n_alloc = 0;
9994 unsigned int n_free = 0;
9995 static size_t last_allocs;
9996 static size_t last_total;
9999 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
10000 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
10001 !socket_stats.heap_totalsz_bytes)
10003 total += socket_stats.heap_totalsz_bytes;
10004 alloc += socket_stats.heap_allocsz_bytes;
10005 free += socket_stats.heap_freesz_bytes;
10006 n_alloc += socket_stats.alloc_count;
10007 n_free += socket_stats.free_count;
10009 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
10011 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
10012 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
10013 (double)socket_stats.heap_allocsz_bytes * 100 /
10014 (double)socket_stats.heap_totalsz_bytes,
10015 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
10016 socket_stats.alloc_count,
10017 socket_stats.free_count);
10020 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
10021 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
10022 total ? ((double)alloc * 100 / (double)total) : 0,
10023 (double)free / (1024 * 1024),
10026 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
10027 ((double)total - (double)last_total) / (1024 * 1024),
10028 (double)(alloc - (double)last_allocs) / 1024 / 1024);
10029 last_allocs = alloc;
10030 last_total = total;
10033 static void cmd_dump_parsed(void *parsed_result,
10034 __rte_unused struct cmdline *cl,
10035 __rte_unused void *data)
10037 struct cmd_dump_result *res = parsed_result;
10039 if (!strcmp(res->dump, "dump_physmem"))
10040 rte_dump_physmem_layout(stdout);
10041 else if (!strcmp(res->dump, "dump_socket_mem"))
10042 dump_socket_mem(stdout);
10043 else if (!strcmp(res->dump, "dump_memzone"))
10044 rte_memzone_dump(stdout);
10045 else if (!strcmp(res->dump, "dump_struct_sizes"))
10046 dump_struct_sizes();
10047 else if (!strcmp(res->dump, "dump_ring"))
10048 rte_ring_list_dump(stdout);
10049 else if (!strcmp(res->dump, "dump_mempool"))
10050 rte_mempool_list_dump(stdout);
10051 else if (!strcmp(res->dump, "dump_devargs"))
10052 rte_devargs_dump(stdout);
10053 else if (!strcmp(res->dump, "dump_log_types"))
10054 rte_log_dump(stdout);
10057 static cmdline_parse_token_string_t cmd_dump_dump =
10058 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
10062 "dump_struct_sizes#"
10068 static cmdline_parse_inst_t cmd_dump = {
10069 .f = cmd_dump_parsed, /* function to call */
10070 .data = NULL, /* 2nd arg of func */
10071 .help_str = "Dump status",
10072 .tokens = { /* token list, NULL terminated */
10073 (void *)&cmd_dump_dump,
10078 /* ******************************************************************************** */
10080 struct cmd_dump_one_result {
10081 cmdline_fixed_string_t dump;
10082 cmdline_fixed_string_t name;
10085 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
10086 __rte_unused void *data)
10088 struct cmd_dump_one_result *res = parsed_result;
10090 if (!strcmp(res->dump, "dump_ring")) {
10091 struct rte_ring *r;
10092 r = rte_ring_lookup(res->name);
10094 cmdline_printf(cl, "Cannot find ring\n");
10097 rte_ring_dump(stdout, r);
10098 } else if (!strcmp(res->dump, "dump_mempool")) {
10099 struct rte_mempool *mp;
10100 mp = rte_mempool_lookup(res->name);
10102 cmdline_printf(cl, "Cannot find mempool\n");
10105 rte_mempool_dump(stdout, mp);
10109 static cmdline_parse_token_string_t cmd_dump_one_dump =
10110 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
10111 "dump_ring#dump_mempool");
10113 static cmdline_parse_token_string_t cmd_dump_one_name =
10114 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
10116 static cmdline_parse_inst_t cmd_dump_one = {
10117 .f = cmd_dump_one_parsed, /* function to call */
10118 .data = NULL, /* 2nd arg of func */
10119 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
10120 .tokens = { /* token list, NULL terminated */
10121 (void *)&cmd_dump_one_dump,
10122 (void *)&cmd_dump_one_name,
10127 /* *** queue region set *** */
10128 struct cmd_queue_region_result {
10129 cmdline_fixed_string_t set;
10130 cmdline_fixed_string_t port;
10132 cmdline_fixed_string_t cmd;
10133 cmdline_fixed_string_t region;
10135 cmdline_fixed_string_t queue_start_index;
10137 cmdline_fixed_string_t queue_num;
10138 uint8_t queue_num_value;
10142 cmd_queue_region_parsed(void *parsed_result,
10143 __rte_unused struct cmdline *cl,
10144 __rte_unused void *data)
10146 struct cmd_queue_region_result *res = parsed_result;
10147 int ret = -ENOTSUP;
10148 #ifdef RTE_NET_I40E
10149 struct rte_pmd_i40e_queue_region_conf region_conf;
10150 enum rte_pmd_i40e_queue_region_op op_type;
10153 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10156 #ifdef RTE_NET_I40E
10157 memset(®ion_conf, 0, sizeof(region_conf));
10158 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
10159 region_conf.region_id = res->region_id;
10160 region_conf.queue_num = res->queue_num_value;
10161 region_conf.queue_start_index = res->queue_id;
10163 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10164 op_type, ®ion_conf);
10171 fprintf(stderr, "function not implemented or supported\n");
10174 fprintf(stderr, "queue region config error: (%s)\n",
10179 static cmdline_parse_token_string_t cmd_queue_region_set =
10180 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10182 static cmdline_parse_token_string_t cmd_queue_region_port =
10183 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
10184 static cmdline_parse_token_num_t cmd_queue_region_port_id =
10185 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10186 port_id, RTE_UINT16);
10187 static cmdline_parse_token_string_t cmd_queue_region_cmd =
10188 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10189 cmd, "queue-region");
10190 static cmdline_parse_token_string_t cmd_queue_region_id =
10191 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10192 region, "region_id");
10193 static cmdline_parse_token_num_t cmd_queue_region_index =
10194 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10195 region_id, RTE_UINT8);
10196 static cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
10197 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10198 queue_start_index, "queue_start_index");
10199 static cmdline_parse_token_num_t cmd_queue_region_queue_id =
10200 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10201 queue_id, RTE_UINT8);
10202 static cmdline_parse_token_string_t cmd_queue_region_queue_num =
10203 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10204 queue_num, "queue_num");
10205 static cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
10206 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10207 queue_num_value, RTE_UINT8);
10209 static cmdline_parse_inst_t cmd_queue_region = {
10210 .f = cmd_queue_region_parsed,
10212 .help_str = "set port <port_id> queue-region region_id <value> "
10213 "queue_start_index <value> queue_num <value>: Set a queue region",
10215 (void *)&cmd_queue_region_set,
10216 (void *)&cmd_queue_region_port,
10217 (void *)&cmd_queue_region_port_id,
10218 (void *)&cmd_queue_region_cmd,
10219 (void *)&cmd_queue_region_id,
10220 (void *)&cmd_queue_region_index,
10221 (void *)&cmd_queue_region_queue_start_index,
10222 (void *)&cmd_queue_region_queue_id,
10223 (void *)&cmd_queue_region_queue_num,
10224 (void *)&cmd_queue_region_queue_num_value,
10229 /* *** queue region and flowtype set *** */
10230 struct cmd_region_flowtype_result {
10231 cmdline_fixed_string_t set;
10232 cmdline_fixed_string_t port;
10234 cmdline_fixed_string_t cmd;
10235 cmdline_fixed_string_t region;
10237 cmdline_fixed_string_t flowtype;
10238 uint8_t flowtype_id;
10242 cmd_region_flowtype_parsed(void *parsed_result,
10243 __rte_unused struct cmdline *cl,
10244 __rte_unused void *data)
10246 struct cmd_region_flowtype_result *res = parsed_result;
10247 int ret = -ENOTSUP;
10248 #ifdef RTE_NET_I40E
10249 struct rte_pmd_i40e_queue_region_conf region_conf;
10250 enum rte_pmd_i40e_queue_region_op op_type;
10253 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10256 #ifdef RTE_NET_I40E
10257 memset(®ion_conf, 0, sizeof(region_conf));
10259 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10260 region_conf.region_id = res->region_id;
10261 region_conf.hw_flowtype = res->flowtype_id;
10263 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10264 op_type, ®ion_conf);
10271 fprintf(stderr, "function not implemented or supported\n");
10274 fprintf(stderr, "region flowtype config error: (%s)\n",
10279 static cmdline_parse_token_string_t cmd_region_flowtype_set =
10280 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10282 static cmdline_parse_token_string_t cmd_region_flowtype_port =
10283 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10285 static cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10286 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10287 port_id, RTE_UINT16);
10288 static cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10289 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10290 cmd, "queue-region");
10291 static cmdline_parse_token_string_t cmd_region_flowtype_index =
10292 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10293 region, "region_id");
10294 static cmdline_parse_token_num_t cmd_region_flowtype_id =
10295 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10296 region_id, RTE_UINT8);
10297 static cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10298 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10299 flowtype, "flowtype");
10300 static cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10301 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10302 flowtype_id, RTE_UINT8);
10303 static cmdline_parse_inst_t cmd_region_flowtype = {
10304 .f = cmd_region_flowtype_parsed,
10306 .help_str = "set port <port_id> queue-region region_id <value> "
10307 "flowtype <value>: Set a flowtype region index",
10309 (void *)&cmd_region_flowtype_set,
10310 (void *)&cmd_region_flowtype_port,
10311 (void *)&cmd_region_flowtype_port_index,
10312 (void *)&cmd_region_flowtype_cmd,
10313 (void *)&cmd_region_flowtype_index,
10314 (void *)&cmd_region_flowtype_id,
10315 (void *)&cmd_region_flowtype_flow_index,
10316 (void *)&cmd_region_flowtype_flow_id,
10321 /* *** User Priority (UP) to queue region (region_id) set *** */
10322 struct cmd_user_priority_region_result {
10323 cmdline_fixed_string_t set;
10324 cmdline_fixed_string_t port;
10326 cmdline_fixed_string_t cmd;
10327 cmdline_fixed_string_t user_priority;
10328 uint8_t user_priority_id;
10329 cmdline_fixed_string_t region;
10334 cmd_user_priority_region_parsed(void *parsed_result,
10335 __rte_unused struct cmdline *cl,
10336 __rte_unused void *data)
10338 struct cmd_user_priority_region_result *res = parsed_result;
10339 int ret = -ENOTSUP;
10340 #ifdef RTE_NET_I40E
10341 struct rte_pmd_i40e_queue_region_conf region_conf;
10342 enum rte_pmd_i40e_queue_region_op op_type;
10345 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10348 #ifdef RTE_NET_I40E
10349 memset(®ion_conf, 0, sizeof(region_conf));
10350 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10351 region_conf.user_priority = res->user_priority_id;
10352 region_conf.region_id = res->region_id;
10354 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10355 op_type, ®ion_conf);
10362 fprintf(stderr, "function not implemented or supported\n");
10365 fprintf(stderr, "user_priority region config error: (%s)\n",
10370 static cmdline_parse_token_string_t cmd_user_priority_region_set =
10371 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10373 static cmdline_parse_token_string_t cmd_user_priority_region_port =
10374 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10376 static cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10377 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10378 port_id, RTE_UINT16);
10379 static cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10380 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10381 cmd, "queue-region");
10382 static cmdline_parse_token_string_t cmd_user_priority_region_UP =
10383 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10384 user_priority, "UP");
10385 static cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10386 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10387 user_priority_id, RTE_UINT8);
10388 static cmdline_parse_token_string_t cmd_user_priority_region_region =
10389 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10390 region, "region_id");
10391 static cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10392 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10393 region_id, RTE_UINT8);
10395 static cmdline_parse_inst_t cmd_user_priority_region = {
10396 .f = cmd_user_priority_region_parsed,
10398 .help_str = "set port <port_id> queue-region UP <value> "
10399 "region_id <value>: Set the mapping of User Priority (UP) "
10400 "to queue region (region_id) ",
10402 (void *)&cmd_user_priority_region_set,
10403 (void *)&cmd_user_priority_region_port,
10404 (void *)&cmd_user_priority_region_port_index,
10405 (void *)&cmd_user_priority_region_cmd,
10406 (void *)&cmd_user_priority_region_UP,
10407 (void *)&cmd_user_priority_region_UP_id,
10408 (void *)&cmd_user_priority_region_region,
10409 (void *)&cmd_user_priority_region_region_id,
10414 /* *** flush all queue region related configuration *** */
10415 struct cmd_flush_queue_region_result {
10416 cmdline_fixed_string_t set;
10417 cmdline_fixed_string_t port;
10419 cmdline_fixed_string_t cmd;
10420 cmdline_fixed_string_t flush;
10421 cmdline_fixed_string_t what;
10425 cmd_flush_queue_region_parsed(void *parsed_result,
10426 __rte_unused struct cmdline *cl,
10427 __rte_unused void *data)
10429 struct cmd_flush_queue_region_result *res = parsed_result;
10430 int ret = -ENOTSUP;
10431 #ifdef RTE_NET_I40E
10432 struct rte_pmd_i40e_queue_region_conf region_conf;
10433 enum rte_pmd_i40e_queue_region_op op_type;
10436 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10439 #ifdef RTE_NET_I40E
10440 memset(®ion_conf, 0, sizeof(region_conf));
10442 if (strcmp(res->what, "on") == 0)
10443 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10445 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10447 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10448 op_type, ®ion_conf);
10455 fprintf(stderr, "function not implemented or supported\n");
10458 fprintf(stderr, "queue region config flush error: (%s)\n",
10463 static cmdline_parse_token_string_t cmd_flush_queue_region_set =
10464 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10466 static cmdline_parse_token_string_t cmd_flush_queue_region_port =
10467 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10469 static cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10470 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10471 port_id, RTE_UINT16);
10472 static cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10473 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10474 cmd, "queue-region");
10475 static cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10476 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10478 static cmdline_parse_token_string_t cmd_flush_queue_region_what =
10479 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10482 static cmdline_parse_inst_t cmd_flush_queue_region = {
10483 .f = cmd_flush_queue_region_parsed,
10485 .help_str = "set port <port_id> queue-region flush on|off"
10486 ": flush all queue region related configuration",
10488 (void *)&cmd_flush_queue_region_set,
10489 (void *)&cmd_flush_queue_region_port,
10490 (void *)&cmd_flush_queue_region_port_index,
10491 (void *)&cmd_flush_queue_region_cmd,
10492 (void *)&cmd_flush_queue_region_flush,
10493 (void *)&cmd_flush_queue_region_what,
10498 /* *** get all queue region related configuration info *** */
10499 struct cmd_show_queue_region_info {
10500 cmdline_fixed_string_t show;
10501 cmdline_fixed_string_t port;
10503 cmdline_fixed_string_t cmd;
10507 cmd_show_queue_region_info_parsed(void *parsed_result,
10508 __rte_unused struct cmdline *cl,
10509 __rte_unused void *data)
10511 struct cmd_show_queue_region_info *res = parsed_result;
10512 int ret = -ENOTSUP;
10513 #ifdef RTE_NET_I40E
10514 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10515 enum rte_pmd_i40e_queue_region_op op_type;
10518 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10521 #ifdef RTE_NET_I40E
10522 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10524 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10526 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10527 op_type, &rte_pmd_regions);
10529 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10536 fprintf(stderr, "function not implemented or supported\n");
10539 fprintf(stderr, "queue region config info show error: (%s)\n",
10544 static cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10545 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10547 static cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10548 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10550 static cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10551 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10552 port_id, RTE_UINT16);
10553 static cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10554 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10555 cmd, "queue-region");
10557 static cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10558 .f = cmd_show_queue_region_info_parsed,
10560 .help_str = "show port <port_id> queue-region"
10561 ": show all queue region related configuration info",
10563 (void *)&cmd_show_queue_region_info_get,
10564 (void *)&cmd_show_queue_region_info_port,
10565 (void *)&cmd_show_queue_region_info_port_index,
10566 (void *)&cmd_show_queue_region_info_cmd,
10571 /* *** Filters Control *** */
10573 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10575 if ((ip_addr).family == AF_INET) \
10576 (ip) = (ip_addr).addr.ipv4.s_addr; \
10578 fprintf(stderr, "invalid parameter.\n"); \
10583 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10585 if ((ip_addr).family == AF_INET6) \
10586 rte_memcpy(&(ip), \
10587 &((ip_addr).addr.ipv6), \
10588 sizeof(struct in6_addr)); \
10590 fprintf(stderr, "invalid parameter.\n"); \
10595 #ifdef RTE_NET_I40E
10598 str2flowtype(char *string)
10601 static const struct {
10604 } flowtype_str[] = {
10605 {"raw", RTE_ETH_FLOW_RAW},
10606 {"ipv4", RTE_ETH_FLOW_IPV4},
10607 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10608 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10609 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10610 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10611 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10612 {"ipv6", RTE_ETH_FLOW_IPV6},
10613 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10614 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10615 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10616 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10617 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10618 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10619 {"ipv6-ex", RTE_ETH_FLOW_IPV6_EX},
10620 {"ipv6-tcp-ex", RTE_ETH_FLOW_IPV6_TCP_EX},
10621 {"ipv6-udp-ex", RTE_ETH_FLOW_IPV6_UDP_EX},
10622 {"gtpu", RTE_ETH_FLOW_GTPU},
10625 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10626 if (!strcmp(flowtype_str[i].str, string))
10627 return flowtype_str[i].type;
10630 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10631 return (uint16_t)atoi(string);
10633 return RTE_ETH_FLOW_UNKNOWN;
10636 /* *** deal with flow director filter *** */
10637 struct cmd_flow_director_result {
10638 cmdline_fixed_string_t flow_director_filter;
10640 cmdline_fixed_string_t mode;
10641 cmdline_fixed_string_t mode_value;
10642 cmdline_fixed_string_t ops;
10643 cmdline_fixed_string_t flow;
10644 cmdline_fixed_string_t flow_type;
10645 cmdline_fixed_string_t drop;
10646 cmdline_fixed_string_t queue;
10648 cmdline_fixed_string_t fd_id;
10649 uint32_t fd_id_value;
10650 cmdline_fixed_string_t packet;
10655 cmd_flow_director_filter_parsed(void *parsed_result,
10656 __rte_unused struct cmdline *cl,
10657 __rte_unused void *data)
10659 struct cmd_flow_director_result *res = parsed_result;
10661 struct rte_pmd_i40e_flow_type_mapping
10662 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10663 struct rte_pmd_i40e_pkt_template_conf conf;
10664 uint16_t flow_type = str2flowtype(res->flow_type);
10665 uint16_t i, port = res->port_id;
10668 memset(&conf, 0, sizeof(conf));
10670 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10671 fprintf(stderr, "Invalid flow type specified.\n");
10674 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10678 if (mapping[flow_type].pctype == 0ULL) {
10679 fprintf(stderr, "Invalid flow type specified.\n");
10682 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10683 if (mapping[flow_type].pctype & (1ULL << i)) {
10684 conf.input.pctype = i;
10689 conf.input.packet = open_file(res->filepath,
10690 &conf.input.length);
10691 if (!conf.input.packet)
10693 if (!strcmp(res->drop, "drop"))
10694 conf.action.behavior =
10695 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10697 conf.action.behavior =
10698 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10699 conf.action.report_status =
10700 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10701 conf.action.rx_queue = res->queue_id;
10702 conf.soft_id = res->fd_id_value;
10703 add = strcmp(res->ops, "del") ? 1 : 0;
10704 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10708 fprintf(stderr, "flow director config error: (%s)\n",
10710 close_file(conf.input.packet);
10713 static cmdline_parse_token_string_t cmd_flow_director_filter =
10714 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10715 flow_director_filter, "flow_director_filter");
10716 static cmdline_parse_token_num_t cmd_flow_director_port_id =
10717 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10718 port_id, RTE_UINT16);
10719 static cmdline_parse_token_string_t cmd_flow_director_ops =
10720 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10721 ops, "add#del#update");
10722 static cmdline_parse_token_string_t cmd_flow_director_flow =
10723 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10725 static cmdline_parse_token_string_t cmd_flow_director_flow_type =
10726 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10728 static cmdline_parse_token_string_t cmd_flow_director_drop =
10729 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10731 static cmdline_parse_token_string_t cmd_flow_director_queue =
10732 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10734 static cmdline_parse_token_num_t cmd_flow_director_queue_id =
10735 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10736 queue_id, RTE_UINT16);
10737 static cmdline_parse_token_string_t cmd_flow_director_fd_id =
10738 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10740 static cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10741 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10742 fd_id_value, RTE_UINT32);
10744 static cmdline_parse_token_string_t cmd_flow_director_mode =
10745 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10747 static cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10748 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10749 mode_value, "raw");
10750 static cmdline_parse_token_string_t cmd_flow_director_packet =
10751 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10753 static cmdline_parse_token_string_t cmd_flow_director_filepath =
10754 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10757 static cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10758 .f = cmd_flow_director_filter_parsed,
10760 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10761 "director entry on NIC",
10763 (void *)&cmd_flow_director_filter,
10764 (void *)&cmd_flow_director_port_id,
10765 (void *)&cmd_flow_director_mode,
10766 (void *)&cmd_flow_director_mode_raw,
10767 (void *)&cmd_flow_director_ops,
10768 (void *)&cmd_flow_director_flow,
10769 (void *)&cmd_flow_director_flow_type,
10770 (void *)&cmd_flow_director_drop,
10771 (void *)&cmd_flow_director_queue,
10772 (void *)&cmd_flow_director_queue_id,
10773 (void *)&cmd_flow_director_fd_id,
10774 (void *)&cmd_flow_director_fd_id_value,
10775 (void *)&cmd_flow_director_packet,
10776 (void *)&cmd_flow_director_filepath,
10781 #endif /* RTE_NET_I40E */
10783 /* *** deal with flow director mask *** */
10784 struct cmd_flow_director_mask_result {
10785 cmdline_fixed_string_t flow_director_mask;
10787 cmdline_fixed_string_t mode;
10788 cmdline_fixed_string_t mode_value;
10789 cmdline_fixed_string_t vlan;
10790 uint16_t vlan_mask;
10791 cmdline_fixed_string_t src_mask;
10792 cmdline_ipaddr_t ipv4_src;
10793 cmdline_ipaddr_t ipv6_src;
10795 cmdline_fixed_string_t dst_mask;
10796 cmdline_ipaddr_t ipv4_dst;
10797 cmdline_ipaddr_t ipv6_dst;
10799 cmdline_fixed_string_t mac;
10800 uint8_t mac_addr_byte_mask;
10801 cmdline_fixed_string_t tunnel_id;
10802 uint32_t tunnel_id_mask;
10803 cmdline_fixed_string_t tunnel_type;
10804 uint8_t tunnel_type_mask;
10808 cmd_flow_director_mask_parsed(void *parsed_result,
10809 __rte_unused struct cmdline *cl,
10810 __rte_unused void *data)
10812 struct cmd_flow_director_mask_result *res = parsed_result;
10813 struct rte_eth_fdir_masks *mask;
10814 struct rte_port *port;
10816 port = &ports[res->port_id];
10817 /** Check if the port is not started **/
10818 if (port->port_status != RTE_PORT_STOPPED) {
10819 fprintf(stderr, "Please stop port %d first\n", res->port_id);
10823 mask = &port->dev_conf.fdir_conf.mask;
10825 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10826 if (strcmp(res->mode_value, "MAC-VLAN")) {
10827 fprintf(stderr, "Please set mode to MAC-VLAN.\n");
10831 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10832 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10833 if (strcmp(res->mode_value, "Tunnel")) {
10834 fprintf(stderr, "Please set mode to Tunnel.\n");
10838 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10839 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10840 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10841 mask->tunnel_type_mask = res->tunnel_type_mask;
10843 if (strcmp(res->mode_value, "IP")) {
10844 fprintf(stderr, "Please set mode to IP.\n");
10848 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10849 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10850 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10851 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10852 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10853 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10854 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10857 cmd_reconfig_device_queue(res->port_id, 1, 1);
10860 static cmdline_parse_token_string_t cmd_flow_director_mask =
10861 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10862 flow_director_mask, "flow_director_mask");
10863 static cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10864 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10865 port_id, RTE_UINT16);
10866 static cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10867 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10869 static cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10870 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10871 vlan_mask, RTE_UINT16);
10872 static cmdline_parse_token_string_t cmd_flow_director_mask_src =
10873 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10874 src_mask, "src_mask");
10875 static cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10876 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10878 static cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10879 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10881 static cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10882 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10883 port_src, RTE_UINT16);
10884 static cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10885 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10886 dst_mask, "dst_mask");
10887 static cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10888 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10890 static cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10891 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10893 static cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10894 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10895 port_dst, RTE_UINT16);
10897 static cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10898 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10900 static cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10901 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10903 static cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10904 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10905 mode_value, "MAC-VLAN");
10906 static cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10907 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10908 mode_value, "Tunnel");
10909 static cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10910 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10912 static cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10913 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10914 mac_addr_byte_mask, RTE_UINT8);
10915 static cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10916 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10917 tunnel_type, "tunnel-type");
10918 static cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10919 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10920 tunnel_type_mask, RTE_UINT8);
10921 static cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10922 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10923 tunnel_id, "tunnel-id");
10924 static cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10925 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10926 tunnel_id_mask, RTE_UINT32);
10928 static cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10929 .f = cmd_flow_director_mask_parsed,
10931 .help_str = "flow_director_mask ... : "
10932 "Set IP mode flow director's mask on NIC",
10934 (void *)&cmd_flow_director_mask,
10935 (void *)&cmd_flow_director_mask_port_id,
10936 (void *)&cmd_flow_director_mask_mode,
10937 (void *)&cmd_flow_director_mask_mode_ip,
10938 (void *)&cmd_flow_director_mask_vlan,
10939 (void *)&cmd_flow_director_mask_vlan_value,
10940 (void *)&cmd_flow_director_mask_src,
10941 (void *)&cmd_flow_director_mask_ipv4_src,
10942 (void *)&cmd_flow_director_mask_ipv6_src,
10943 (void *)&cmd_flow_director_mask_port_src,
10944 (void *)&cmd_flow_director_mask_dst,
10945 (void *)&cmd_flow_director_mask_ipv4_dst,
10946 (void *)&cmd_flow_director_mask_ipv6_dst,
10947 (void *)&cmd_flow_director_mask_port_dst,
10952 static cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10953 .f = cmd_flow_director_mask_parsed,
10955 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10956 "flow director's mask on NIC",
10958 (void *)&cmd_flow_director_mask,
10959 (void *)&cmd_flow_director_mask_port_id,
10960 (void *)&cmd_flow_director_mask_mode,
10961 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10962 (void *)&cmd_flow_director_mask_vlan,
10963 (void *)&cmd_flow_director_mask_vlan_value,
10968 static cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10969 .f = cmd_flow_director_mask_parsed,
10971 .help_str = "flow_director_mask ... : Set tunnel mode "
10972 "flow director's mask on NIC",
10974 (void *)&cmd_flow_director_mask,
10975 (void *)&cmd_flow_director_mask_port_id,
10976 (void *)&cmd_flow_director_mask_mode,
10977 (void *)&cmd_flow_director_mask_mode_tunnel,
10978 (void *)&cmd_flow_director_mask_vlan,
10979 (void *)&cmd_flow_director_mask_vlan_value,
10980 (void *)&cmd_flow_director_mask_mac,
10981 (void *)&cmd_flow_director_mask_mac_value,
10982 (void *)&cmd_flow_director_mask_tunnel_type,
10983 (void *)&cmd_flow_director_mask_tunnel_type_value,
10984 (void *)&cmd_flow_director_mask_tunnel_id,
10985 (void *)&cmd_flow_director_mask_tunnel_id_value,
10990 /* *** deal with flow director flexible payload configuration *** */
10991 struct cmd_flow_director_flexpayload_result {
10992 cmdline_fixed_string_t flow_director_flexpayload;
10994 cmdline_fixed_string_t payload_layer;
10995 cmdline_fixed_string_t payload_cfg;
10999 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11002 const char *p, *p0 = q_arg;
11004 unsigned long int_fld;
11005 char *str_fld[max_num];
11010 p = strchr(p0, '(');
11014 p0 = strchr(p, ')');
11019 if (size >= sizeof(s))
11022 snprintf(s, sizeof(s), "%.*s", size, p);
11023 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11024 if (ret < 0 || ret > max_num)
11026 for (i = 0; i < ret; i++) {
11028 int_fld = strtoul(str_fld[i], &end, 0);
11029 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11031 offsets[i] = (uint16_t)int_fld;
11037 cmd_flow_director_flxpld_parsed(void *parsed_result,
11038 __rte_unused struct cmdline *cl,
11039 __rte_unused void *data)
11041 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11042 struct rte_eth_flex_payload_cfg flex_cfg;
11043 struct rte_port *port;
11046 port = &ports[res->port_id];
11047 /** Check if the port is not started **/
11048 if (port->port_status != RTE_PORT_STOPPED) {
11049 fprintf(stderr, "Please stop port %d first\n", res->port_id);
11053 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11055 if (!strcmp(res->payload_layer, "raw"))
11056 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11057 else if (!strcmp(res->payload_layer, "l2"))
11058 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11059 else if (!strcmp(res->payload_layer, "l3"))
11060 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11061 else if (!strcmp(res->payload_layer, "l4"))
11062 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11064 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11065 RTE_ETH_FDIR_MAX_FLEXLEN);
11067 fprintf(stderr, "error: Cannot parse flex payload input.\n");
11071 fdir_set_flex_payload(res->port_id, &flex_cfg);
11072 cmd_reconfig_device_queue(res->port_id, 1, 1);
11075 static cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11076 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11077 flow_director_flexpayload,
11078 "flow_director_flex_payload");
11079 static cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11080 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11081 port_id, RTE_UINT16);
11082 static cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11083 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11084 payload_layer, "raw#l2#l3#l4");
11085 static cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11086 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11087 payload_cfg, NULL);
11089 static cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11090 .f = cmd_flow_director_flxpld_parsed,
11092 .help_str = "flow_director_flexpayload ... : "
11093 "Set flow director's flex payload on NIC",
11095 (void *)&cmd_flow_director_flexpayload,
11096 (void *)&cmd_flow_director_flexpayload_port_id,
11097 (void *)&cmd_flow_director_flexpayload_payload_layer,
11098 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11103 /* Generic flow interface command. */
11104 extern cmdline_parse_inst_t cmd_flow;
11106 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11107 struct cmd_mcast_addr_result {
11108 cmdline_fixed_string_t mcast_addr_cmd;
11109 cmdline_fixed_string_t what;
11111 struct rte_ether_addr mc_addr;
11114 static void cmd_mcast_addr_parsed(void *parsed_result,
11115 __rte_unused struct cmdline *cl,
11116 __rte_unused void *data)
11118 struct cmd_mcast_addr_result *res = parsed_result;
11120 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
11122 "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
11123 RTE_ETHER_ADDR_BYTES(&res->mc_addr));
11126 if (strcmp(res->what, "add") == 0)
11127 mcast_addr_add(res->port_num, &res->mc_addr);
11129 mcast_addr_remove(res->port_num, &res->mc_addr);
11132 static cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11133 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11134 mcast_addr_cmd, "mcast_addr");
11135 static cmdline_parse_token_string_t cmd_mcast_addr_what =
11136 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11138 static cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11139 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
11141 static cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11142 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11144 static cmdline_parse_inst_t cmd_mcast_addr = {
11145 .f = cmd_mcast_addr_parsed,
11147 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11148 "Add/Remove multicast MAC address on port_id",
11150 (void *)&cmd_mcast_addr_cmd,
11151 (void *)&cmd_mcast_addr_what,
11152 (void *)&cmd_mcast_addr_portnum,
11153 (void *)&cmd_mcast_addr_addr,
11158 /* vf vlan anti spoof configuration */
11160 /* Common result structure for vf vlan anti spoof */
11161 struct cmd_vf_vlan_anti_spoof_result {
11162 cmdline_fixed_string_t set;
11163 cmdline_fixed_string_t vf;
11164 cmdline_fixed_string_t vlan;
11165 cmdline_fixed_string_t antispoof;
11168 cmdline_fixed_string_t on_off;
11171 /* Common CLI fields for vf vlan anti spoof enable disable */
11172 static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
11173 TOKEN_STRING_INITIALIZER
11174 (struct cmd_vf_vlan_anti_spoof_result,
11176 static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
11177 TOKEN_STRING_INITIALIZER
11178 (struct cmd_vf_vlan_anti_spoof_result,
11180 static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
11181 TOKEN_STRING_INITIALIZER
11182 (struct cmd_vf_vlan_anti_spoof_result,
11184 static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
11185 TOKEN_STRING_INITIALIZER
11186 (struct cmd_vf_vlan_anti_spoof_result,
11187 antispoof, "antispoof");
11188 static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
11189 TOKEN_NUM_INITIALIZER
11190 (struct cmd_vf_vlan_anti_spoof_result,
11191 port_id, RTE_UINT16);
11192 static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
11193 TOKEN_NUM_INITIALIZER
11194 (struct cmd_vf_vlan_anti_spoof_result,
11195 vf_id, RTE_UINT32);
11196 static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11197 TOKEN_STRING_INITIALIZER
11198 (struct cmd_vf_vlan_anti_spoof_result,
11202 cmd_set_vf_vlan_anti_spoof_parsed(
11203 void *parsed_result,
11204 __rte_unused struct cmdline *cl,
11205 __rte_unused void *data)
11207 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
11208 int ret = -ENOTSUP;
11210 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11212 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11215 #ifdef RTE_NET_IXGBE
11216 if (ret == -ENOTSUP)
11217 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11218 res->vf_id, is_on);
11220 #ifdef RTE_NET_I40E
11221 if (ret == -ENOTSUP)
11222 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11223 res->vf_id, is_on);
11225 #ifdef RTE_NET_BNXT
11226 if (ret == -ENOTSUP)
11227 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11228 res->vf_id, is_on);
11235 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11238 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11241 fprintf(stderr, "function not implemented\n");
11244 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11248 static cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11249 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11251 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11253 (void *)&cmd_vf_vlan_anti_spoof_set,
11254 (void *)&cmd_vf_vlan_anti_spoof_vf,
11255 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11256 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11257 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11258 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11259 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11264 /* vf mac anti spoof configuration */
11266 /* Common result structure for vf mac anti spoof */
11267 struct cmd_vf_mac_anti_spoof_result {
11268 cmdline_fixed_string_t set;
11269 cmdline_fixed_string_t vf;
11270 cmdline_fixed_string_t mac;
11271 cmdline_fixed_string_t antispoof;
11274 cmdline_fixed_string_t on_off;
11277 /* Common CLI fields for vf mac anti spoof enable disable */
11278 static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11279 TOKEN_STRING_INITIALIZER
11280 (struct cmd_vf_mac_anti_spoof_result,
11282 static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11283 TOKEN_STRING_INITIALIZER
11284 (struct cmd_vf_mac_anti_spoof_result,
11286 static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11287 TOKEN_STRING_INITIALIZER
11288 (struct cmd_vf_mac_anti_spoof_result,
11290 static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11291 TOKEN_STRING_INITIALIZER
11292 (struct cmd_vf_mac_anti_spoof_result,
11293 antispoof, "antispoof");
11294 static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11295 TOKEN_NUM_INITIALIZER
11296 (struct cmd_vf_mac_anti_spoof_result,
11297 port_id, RTE_UINT16);
11298 static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11299 TOKEN_NUM_INITIALIZER
11300 (struct cmd_vf_mac_anti_spoof_result,
11301 vf_id, RTE_UINT32);
11302 static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11303 TOKEN_STRING_INITIALIZER
11304 (struct cmd_vf_mac_anti_spoof_result,
11308 cmd_set_vf_mac_anti_spoof_parsed(
11309 void *parsed_result,
11310 __rte_unused struct cmdline *cl,
11311 __rte_unused void *data)
11313 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11314 int ret = -ENOTSUP;
11316 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11318 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11321 #ifdef RTE_NET_IXGBE
11322 if (ret == -ENOTSUP)
11323 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11324 res->vf_id, is_on);
11326 #ifdef RTE_NET_I40E
11327 if (ret == -ENOTSUP)
11328 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11329 res->vf_id, is_on);
11331 #ifdef RTE_NET_BNXT
11332 if (ret == -ENOTSUP)
11333 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11334 res->vf_id, is_on);
11341 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11342 res->vf_id, is_on);
11345 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11348 fprintf(stderr, "function not implemented\n");
11351 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11355 static cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11356 .f = cmd_set_vf_mac_anti_spoof_parsed,
11358 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11360 (void *)&cmd_vf_mac_anti_spoof_set,
11361 (void *)&cmd_vf_mac_anti_spoof_vf,
11362 (void *)&cmd_vf_mac_anti_spoof_mac,
11363 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11364 (void *)&cmd_vf_mac_anti_spoof_port_id,
11365 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11366 (void *)&cmd_vf_mac_anti_spoof_on_off,
11371 /* vf vlan strip queue configuration */
11373 /* Common result structure for vf mac anti spoof */
11374 struct cmd_vf_vlan_stripq_result {
11375 cmdline_fixed_string_t set;
11376 cmdline_fixed_string_t vf;
11377 cmdline_fixed_string_t vlan;
11378 cmdline_fixed_string_t stripq;
11381 cmdline_fixed_string_t on_off;
11384 /* Common CLI fields for vf vlan strip enable disable */
11385 static cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11386 TOKEN_STRING_INITIALIZER
11387 (struct cmd_vf_vlan_stripq_result,
11389 static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11390 TOKEN_STRING_INITIALIZER
11391 (struct cmd_vf_vlan_stripq_result,
11393 static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11394 TOKEN_STRING_INITIALIZER
11395 (struct cmd_vf_vlan_stripq_result,
11397 static cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11398 TOKEN_STRING_INITIALIZER
11399 (struct cmd_vf_vlan_stripq_result,
11401 static cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11402 TOKEN_NUM_INITIALIZER
11403 (struct cmd_vf_vlan_stripq_result,
11404 port_id, RTE_UINT16);
11405 static cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11406 TOKEN_NUM_INITIALIZER
11407 (struct cmd_vf_vlan_stripq_result,
11408 vf_id, RTE_UINT16);
11409 static cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11410 TOKEN_STRING_INITIALIZER
11411 (struct cmd_vf_vlan_stripq_result,
11415 cmd_set_vf_vlan_stripq_parsed(
11416 void *parsed_result,
11417 __rte_unused struct cmdline *cl,
11418 __rte_unused void *data)
11420 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11421 int ret = -ENOTSUP;
11423 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11425 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11428 #ifdef RTE_NET_IXGBE
11429 if (ret == -ENOTSUP)
11430 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11431 res->vf_id, is_on);
11433 #ifdef RTE_NET_I40E
11434 if (ret == -ENOTSUP)
11435 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11436 res->vf_id, is_on);
11438 #ifdef RTE_NET_BNXT
11439 if (ret == -ENOTSUP)
11440 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11441 res->vf_id, is_on);
11448 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11449 res->vf_id, is_on);
11452 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11455 fprintf(stderr, "function not implemented\n");
11458 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11462 static cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11463 .f = cmd_set_vf_vlan_stripq_parsed,
11465 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11467 (void *)&cmd_vf_vlan_stripq_set,
11468 (void *)&cmd_vf_vlan_stripq_vf,
11469 (void *)&cmd_vf_vlan_stripq_vlan,
11470 (void *)&cmd_vf_vlan_stripq_stripq,
11471 (void *)&cmd_vf_vlan_stripq_port_id,
11472 (void *)&cmd_vf_vlan_stripq_vf_id,
11473 (void *)&cmd_vf_vlan_stripq_on_off,
11478 /* vf vlan insert configuration */
11480 /* Common result structure for vf vlan insert */
11481 struct cmd_vf_vlan_insert_result {
11482 cmdline_fixed_string_t set;
11483 cmdline_fixed_string_t vf;
11484 cmdline_fixed_string_t vlan;
11485 cmdline_fixed_string_t insert;
11491 /* Common CLI fields for vf vlan insert enable disable */
11492 static cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11493 TOKEN_STRING_INITIALIZER
11494 (struct cmd_vf_vlan_insert_result,
11496 static cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11497 TOKEN_STRING_INITIALIZER
11498 (struct cmd_vf_vlan_insert_result,
11500 static cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11501 TOKEN_STRING_INITIALIZER
11502 (struct cmd_vf_vlan_insert_result,
11504 static cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11505 TOKEN_STRING_INITIALIZER
11506 (struct cmd_vf_vlan_insert_result,
11508 static cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11509 TOKEN_NUM_INITIALIZER
11510 (struct cmd_vf_vlan_insert_result,
11511 port_id, RTE_UINT16);
11512 static cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11513 TOKEN_NUM_INITIALIZER
11514 (struct cmd_vf_vlan_insert_result,
11515 vf_id, RTE_UINT16);
11516 static cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11517 TOKEN_NUM_INITIALIZER
11518 (struct cmd_vf_vlan_insert_result,
11519 vlan_id, RTE_UINT16);
11522 cmd_set_vf_vlan_insert_parsed(
11523 void *parsed_result,
11524 __rte_unused struct cmdline *cl,
11525 __rte_unused void *data)
11527 struct cmd_vf_vlan_insert_result *res = parsed_result;
11528 int ret = -ENOTSUP;
11530 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11533 #ifdef RTE_NET_IXGBE
11534 if (ret == -ENOTSUP)
11535 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11538 #ifdef RTE_NET_I40E
11539 if (ret == -ENOTSUP)
11540 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11543 #ifdef RTE_NET_BNXT
11544 if (ret == -ENOTSUP)
11545 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11553 fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
11554 res->vf_id, res->vlan_id);
11557 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11560 fprintf(stderr, "function not implemented\n");
11563 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11567 static cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11568 .f = cmd_set_vf_vlan_insert_parsed,
11570 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11572 (void *)&cmd_vf_vlan_insert_set,
11573 (void *)&cmd_vf_vlan_insert_vf,
11574 (void *)&cmd_vf_vlan_insert_vlan,
11575 (void *)&cmd_vf_vlan_insert_insert,
11576 (void *)&cmd_vf_vlan_insert_port_id,
11577 (void *)&cmd_vf_vlan_insert_vf_id,
11578 (void *)&cmd_vf_vlan_insert_vlan_id,
11583 /* tx loopback configuration */
11585 /* Common result structure for tx loopback */
11586 struct cmd_tx_loopback_result {
11587 cmdline_fixed_string_t set;
11588 cmdline_fixed_string_t tx;
11589 cmdline_fixed_string_t loopback;
11591 cmdline_fixed_string_t on_off;
11594 /* Common CLI fields for tx loopback enable disable */
11595 static cmdline_parse_token_string_t cmd_tx_loopback_set =
11596 TOKEN_STRING_INITIALIZER
11597 (struct cmd_tx_loopback_result,
11599 static cmdline_parse_token_string_t cmd_tx_loopback_tx =
11600 TOKEN_STRING_INITIALIZER
11601 (struct cmd_tx_loopback_result,
11603 static cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11604 TOKEN_STRING_INITIALIZER
11605 (struct cmd_tx_loopback_result,
11606 loopback, "loopback");
11607 static cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11608 TOKEN_NUM_INITIALIZER
11609 (struct cmd_tx_loopback_result,
11610 port_id, RTE_UINT16);
11611 static cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11612 TOKEN_STRING_INITIALIZER
11613 (struct cmd_tx_loopback_result,
11617 cmd_set_tx_loopback_parsed(
11618 void *parsed_result,
11619 __rte_unused struct cmdline *cl,
11620 __rte_unused void *data)
11622 struct cmd_tx_loopback_result *res = parsed_result;
11623 int ret = -ENOTSUP;
11625 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11627 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11630 #ifdef RTE_NET_IXGBE
11631 if (ret == -ENOTSUP)
11632 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11634 #ifdef RTE_NET_I40E
11635 if (ret == -ENOTSUP)
11636 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11638 #ifdef RTE_NET_BNXT
11639 if (ret == -ENOTSUP)
11640 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11642 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11643 if (ret == -ENOTSUP)
11644 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11651 fprintf(stderr, "invalid is_on %d\n", is_on);
11654 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11657 fprintf(stderr, "function not implemented\n");
11660 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11664 static cmdline_parse_inst_t cmd_set_tx_loopback = {
11665 .f = cmd_set_tx_loopback_parsed,
11667 .help_str = "set tx loopback <port_id> on|off",
11669 (void *)&cmd_tx_loopback_set,
11670 (void *)&cmd_tx_loopback_tx,
11671 (void *)&cmd_tx_loopback_loopback,
11672 (void *)&cmd_tx_loopback_port_id,
11673 (void *)&cmd_tx_loopback_on_off,
11678 /* all queues drop enable configuration */
11680 /* Common result structure for all queues drop enable */
11681 struct cmd_all_queues_drop_en_result {
11682 cmdline_fixed_string_t set;
11683 cmdline_fixed_string_t all;
11684 cmdline_fixed_string_t queues;
11685 cmdline_fixed_string_t drop;
11687 cmdline_fixed_string_t on_off;
11690 /* Common CLI fields for tx loopback enable disable */
11691 static cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11692 TOKEN_STRING_INITIALIZER
11693 (struct cmd_all_queues_drop_en_result,
11695 static cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11696 TOKEN_STRING_INITIALIZER
11697 (struct cmd_all_queues_drop_en_result,
11699 static cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11700 TOKEN_STRING_INITIALIZER
11701 (struct cmd_all_queues_drop_en_result,
11703 static cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11704 TOKEN_STRING_INITIALIZER
11705 (struct cmd_all_queues_drop_en_result,
11707 static cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11708 TOKEN_NUM_INITIALIZER
11709 (struct cmd_all_queues_drop_en_result,
11710 port_id, RTE_UINT16);
11711 static cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11712 TOKEN_STRING_INITIALIZER
11713 (struct cmd_all_queues_drop_en_result,
11717 cmd_set_all_queues_drop_en_parsed(
11718 void *parsed_result,
11719 __rte_unused struct cmdline *cl,
11720 __rte_unused void *data)
11722 struct cmd_all_queues_drop_en_result *res = parsed_result;
11723 int ret = -ENOTSUP;
11724 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11726 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11729 #ifdef RTE_NET_IXGBE
11730 if (ret == -ENOTSUP)
11731 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11733 #ifdef RTE_NET_BNXT
11734 if (ret == -ENOTSUP)
11735 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11741 fprintf(stderr, "invalid is_on %d\n", is_on);
11744 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11747 fprintf(stderr, "function not implemented\n");
11750 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11754 static cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11755 .f = cmd_set_all_queues_drop_en_parsed,
11757 .help_str = "set all queues drop <port_id> on|off",
11759 (void *)&cmd_all_queues_drop_en_set,
11760 (void *)&cmd_all_queues_drop_en_all,
11761 (void *)&cmd_all_queues_drop_en_queues,
11762 (void *)&cmd_all_queues_drop_en_drop,
11763 (void *)&cmd_all_queues_drop_en_port_id,
11764 (void *)&cmd_all_queues_drop_en_on_off,
11769 /* vf split drop enable configuration */
11771 /* Common result structure for vf split drop enable */
11772 struct cmd_vf_split_drop_en_result {
11773 cmdline_fixed_string_t set;
11774 cmdline_fixed_string_t vf;
11775 cmdline_fixed_string_t split;
11776 cmdline_fixed_string_t drop;
11779 cmdline_fixed_string_t on_off;
11782 /* Common CLI fields for vf split drop enable disable */
11783 static cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11784 TOKEN_STRING_INITIALIZER
11785 (struct cmd_vf_split_drop_en_result,
11787 static cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11788 TOKEN_STRING_INITIALIZER
11789 (struct cmd_vf_split_drop_en_result,
11791 static cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11792 TOKEN_STRING_INITIALIZER
11793 (struct cmd_vf_split_drop_en_result,
11795 static cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11796 TOKEN_STRING_INITIALIZER
11797 (struct cmd_vf_split_drop_en_result,
11799 static cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11800 TOKEN_NUM_INITIALIZER
11801 (struct cmd_vf_split_drop_en_result,
11802 port_id, RTE_UINT16);
11803 static cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11804 TOKEN_NUM_INITIALIZER
11805 (struct cmd_vf_split_drop_en_result,
11806 vf_id, RTE_UINT16);
11807 static cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11808 TOKEN_STRING_INITIALIZER
11809 (struct cmd_vf_split_drop_en_result,
11813 cmd_set_vf_split_drop_en_parsed(
11814 void *parsed_result,
11815 __rte_unused struct cmdline *cl,
11816 __rte_unused void *data)
11818 struct cmd_vf_split_drop_en_result *res = parsed_result;
11819 int ret = -ENOTSUP;
11820 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11822 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11825 #ifdef RTE_NET_IXGBE
11826 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11833 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11834 res->vf_id, is_on);
11837 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11840 fprintf(stderr, "not supported on port %d\n", res->port_id);
11843 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11847 static cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11848 .f = cmd_set_vf_split_drop_en_parsed,
11850 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11852 (void *)&cmd_vf_split_drop_en_set,
11853 (void *)&cmd_vf_split_drop_en_vf,
11854 (void *)&cmd_vf_split_drop_en_split,
11855 (void *)&cmd_vf_split_drop_en_drop,
11856 (void *)&cmd_vf_split_drop_en_port_id,
11857 (void *)&cmd_vf_split_drop_en_vf_id,
11858 (void *)&cmd_vf_split_drop_en_on_off,
11863 /* vf mac address configuration */
11865 /* Common result structure for vf mac address */
11866 struct cmd_set_vf_mac_addr_result {
11867 cmdline_fixed_string_t set;
11868 cmdline_fixed_string_t vf;
11869 cmdline_fixed_string_t mac;
11870 cmdline_fixed_string_t addr;
11873 struct rte_ether_addr mac_addr;
11877 /* Common CLI fields for vf split drop enable disable */
11878 static cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11879 TOKEN_STRING_INITIALIZER
11880 (struct cmd_set_vf_mac_addr_result,
11882 static cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11883 TOKEN_STRING_INITIALIZER
11884 (struct cmd_set_vf_mac_addr_result,
11886 static cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11887 TOKEN_STRING_INITIALIZER
11888 (struct cmd_set_vf_mac_addr_result,
11890 static cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11891 TOKEN_STRING_INITIALIZER
11892 (struct cmd_set_vf_mac_addr_result,
11894 static cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11895 TOKEN_NUM_INITIALIZER
11896 (struct cmd_set_vf_mac_addr_result,
11897 port_id, RTE_UINT16);
11898 static cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11899 TOKEN_NUM_INITIALIZER
11900 (struct cmd_set_vf_mac_addr_result,
11901 vf_id, RTE_UINT16);
11902 static cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11903 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11907 cmd_set_vf_mac_addr_parsed(
11908 void *parsed_result,
11909 __rte_unused struct cmdline *cl,
11910 __rte_unused void *data)
11912 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11913 int ret = -ENOTSUP;
11915 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11918 #ifdef RTE_NET_IXGBE
11919 if (ret == -ENOTSUP)
11920 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11923 #ifdef RTE_NET_I40E
11924 if (ret == -ENOTSUP)
11925 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11928 #ifdef RTE_NET_BNXT
11929 if (ret == -ENOTSUP)
11930 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11938 fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
11941 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11944 fprintf(stderr, "function not implemented\n");
11947 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11951 static cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11952 .f = cmd_set_vf_mac_addr_parsed,
11954 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11956 (void *)&cmd_set_vf_mac_addr_set,
11957 (void *)&cmd_set_vf_mac_addr_vf,
11958 (void *)&cmd_set_vf_mac_addr_mac,
11959 (void *)&cmd_set_vf_mac_addr_addr,
11960 (void *)&cmd_set_vf_mac_addr_port_id,
11961 (void *)&cmd_set_vf_mac_addr_vf_id,
11962 (void *)&cmd_set_vf_mac_addr_mac_addr,
11967 /* MACsec configuration */
11969 /* Common result structure for MACsec offload enable */
11970 struct cmd_macsec_offload_on_result {
11971 cmdline_fixed_string_t set;
11972 cmdline_fixed_string_t macsec;
11973 cmdline_fixed_string_t offload;
11975 cmdline_fixed_string_t on;
11976 cmdline_fixed_string_t encrypt;
11977 cmdline_fixed_string_t en_on_off;
11978 cmdline_fixed_string_t replay_protect;
11979 cmdline_fixed_string_t rp_on_off;
11982 /* Common CLI fields for MACsec offload disable */
11983 static cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11984 TOKEN_STRING_INITIALIZER
11985 (struct cmd_macsec_offload_on_result,
11987 static cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11988 TOKEN_STRING_INITIALIZER
11989 (struct cmd_macsec_offload_on_result,
11991 static cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11992 TOKEN_STRING_INITIALIZER
11993 (struct cmd_macsec_offload_on_result,
11994 offload, "offload");
11995 static cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11996 TOKEN_NUM_INITIALIZER
11997 (struct cmd_macsec_offload_on_result,
11998 port_id, RTE_UINT16);
11999 static cmdline_parse_token_string_t cmd_macsec_offload_on_on =
12000 TOKEN_STRING_INITIALIZER
12001 (struct cmd_macsec_offload_on_result,
12003 static cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
12004 TOKEN_STRING_INITIALIZER
12005 (struct cmd_macsec_offload_on_result,
12006 encrypt, "encrypt");
12007 static cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
12008 TOKEN_STRING_INITIALIZER
12009 (struct cmd_macsec_offload_on_result,
12010 en_on_off, "on#off");
12011 static cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
12012 TOKEN_STRING_INITIALIZER
12013 (struct cmd_macsec_offload_on_result,
12014 replay_protect, "replay-protect");
12015 static cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
12016 TOKEN_STRING_INITIALIZER
12017 (struct cmd_macsec_offload_on_result,
12018 rp_on_off, "on#off");
12021 cmd_set_macsec_offload_on_parsed(
12022 void *parsed_result,
12023 __rte_unused struct cmdline *cl,
12024 __rte_unused void *data)
12026 struct cmd_macsec_offload_on_result *res = parsed_result;
12027 int ret = -ENOTSUP;
12028 portid_t port_id = res->port_id;
12029 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
12030 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
12031 struct rte_eth_dev_info dev_info;
12033 if (port_id_is_invalid(port_id, ENABLED_WARN))
12035 if (!port_is_stopped(port_id)) {
12036 fprintf(stderr, "Please stop port %d first\n", port_id);
12040 ret = eth_dev_info_get_print_err(port_id, &dev_info);
12044 if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) {
12045 #ifdef RTE_NET_IXGBE
12046 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
12054 ports[port_id].dev_conf.txmode.offloads |=
12055 RTE_ETH_TX_OFFLOAD_MACSEC_INSERT;
12056 cmd_reconfig_device_queue(port_id, 1, 1);
12059 fprintf(stderr, "invalid port_id %d\n", port_id);
12062 fprintf(stderr, "not supported on port %d\n", port_id);
12065 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12069 static cmdline_parse_inst_t cmd_set_macsec_offload_on = {
12070 .f = cmd_set_macsec_offload_on_parsed,
12072 .help_str = "set macsec offload <port_id> on "
12073 "encrypt on|off replay-protect on|off",
12075 (void *)&cmd_macsec_offload_on_set,
12076 (void *)&cmd_macsec_offload_on_macsec,
12077 (void *)&cmd_macsec_offload_on_offload,
12078 (void *)&cmd_macsec_offload_on_port_id,
12079 (void *)&cmd_macsec_offload_on_on,
12080 (void *)&cmd_macsec_offload_on_encrypt,
12081 (void *)&cmd_macsec_offload_on_en_on_off,
12082 (void *)&cmd_macsec_offload_on_replay_protect,
12083 (void *)&cmd_macsec_offload_on_rp_on_off,
12088 /* Common result structure for MACsec offload disable */
12089 struct cmd_macsec_offload_off_result {
12090 cmdline_fixed_string_t set;
12091 cmdline_fixed_string_t macsec;
12092 cmdline_fixed_string_t offload;
12094 cmdline_fixed_string_t off;
12097 /* Common CLI fields for MACsec offload disable */
12098 static cmdline_parse_token_string_t cmd_macsec_offload_off_set =
12099 TOKEN_STRING_INITIALIZER
12100 (struct cmd_macsec_offload_off_result,
12102 static cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
12103 TOKEN_STRING_INITIALIZER
12104 (struct cmd_macsec_offload_off_result,
12106 static cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
12107 TOKEN_STRING_INITIALIZER
12108 (struct cmd_macsec_offload_off_result,
12109 offload, "offload");
12110 static cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
12111 TOKEN_NUM_INITIALIZER
12112 (struct cmd_macsec_offload_off_result,
12113 port_id, RTE_UINT16);
12114 static cmdline_parse_token_string_t cmd_macsec_offload_off_off =
12115 TOKEN_STRING_INITIALIZER
12116 (struct cmd_macsec_offload_off_result,
12120 cmd_set_macsec_offload_off_parsed(
12121 void *parsed_result,
12122 __rte_unused struct cmdline *cl,
12123 __rte_unused void *data)
12125 struct cmd_macsec_offload_off_result *res = parsed_result;
12126 int ret = -ENOTSUP;
12127 struct rte_eth_dev_info dev_info;
12128 portid_t port_id = res->port_id;
12130 if (port_id_is_invalid(port_id, ENABLED_WARN))
12132 if (!port_is_stopped(port_id)) {
12133 fprintf(stderr, "Please stop port %d first\n", port_id);
12137 ret = eth_dev_info_get_print_err(port_id, &dev_info);
12141 if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) {
12142 #ifdef RTE_NET_IXGBE
12143 ret = rte_pmd_ixgbe_macsec_disable(port_id);
12148 ports[port_id].dev_conf.txmode.offloads &=
12149 ~RTE_ETH_TX_OFFLOAD_MACSEC_INSERT;
12150 cmd_reconfig_device_queue(port_id, 1, 1);
12153 fprintf(stderr, "invalid port_id %d\n", port_id);
12156 fprintf(stderr, "not supported on port %d\n", port_id);
12159 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12163 static cmdline_parse_inst_t cmd_set_macsec_offload_off = {
12164 .f = cmd_set_macsec_offload_off_parsed,
12166 .help_str = "set macsec offload <port_id> off",
12168 (void *)&cmd_macsec_offload_off_set,
12169 (void *)&cmd_macsec_offload_off_macsec,
12170 (void *)&cmd_macsec_offload_off_offload,
12171 (void *)&cmd_macsec_offload_off_port_id,
12172 (void *)&cmd_macsec_offload_off_off,
12177 /* Common result structure for MACsec secure connection configure */
12178 struct cmd_macsec_sc_result {
12179 cmdline_fixed_string_t set;
12180 cmdline_fixed_string_t macsec;
12181 cmdline_fixed_string_t sc;
12182 cmdline_fixed_string_t tx_rx;
12184 struct rte_ether_addr mac;
12188 /* Common CLI fields for MACsec secure connection configure */
12189 static cmdline_parse_token_string_t cmd_macsec_sc_set =
12190 TOKEN_STRING_INITIALIZER
12191 (struct cmd_macsec_sc_result,
12193 static cmdline_parse_token_string_t cmd_macsec_sc_macsec =
12194 TOKEN_STRING_INITIALIZER
12195 (struct cmd_macsec_sc_result,
12197 static cmdline_parse_token_string_t cmd_macsec_sc_sc =
12198 TOKEN_STRING_INITIALIZER
12199 (struct cmd_macsec_sc_result,
12201 static cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
12202 TOKEN_STRING_INITIALIZER
12203 (struct cmd_macsec_sc_result,
12205 static cmdline_parse_token_num_t cmd_macsec_sc_port_id =
12206 TOKEN_NUM_INITIALIZER
12207 (struct cmd_macsec_sc_result,
12208 port_id, RTE_UINT16);
12209 static cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
12210 TOKEN_ETHERADDR_INITIALIZER
12211 (struct cmd_macsec_sc_result,
12213 static cmdline_parse_token_num_t cmd_macsec_sc_pi =
12214 TOKEN_NUM_INITIALIZER
12215 (struct cmd_macsec_sc_result,
12219 cmd_set_macsec_sc_parsed(
12220 void *parsed_result,
12221 __rte_unused struct cmdline *cl,
12222 __rte_unused void *data)
12224 struct cmd_macsec_sc_result *res = parsed_result;
12225 int ret = -ENOTSUP;
12226 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12228 #ifdef RTE_NET_IXGBE
12230 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12231 res->mac.addr_bytes) :
12232 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12233 res->mac.addr_bytes, res->pi);
12235 RTE_SET_USED(is_tx);
12241 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12244 fprintf(stderr, "not supported on port %d\n", res->port_id);
12247 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12251 static cmdline_parse_inst_t cmd_set_macsec_sc = {
12252 .f = cmd_set_macsec_sc_parsed,
12254 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12256 (void *)&cmd_macsec_sc_set,
12257 (void *)&cmd_macsec_sc_macsec,
12258 (void *)&cmd_macsec_sc_sc,
12259 (void *)&cmd_macsec_sc_tx_rx,
12260 (void *)&cmd_macsec_sc_port_id,
12261 (void *)&cmd_macsec_sc_mac,
12262 (void *)&cmd_macsec_sc_pi,
12267 /* Common result structure for MACsec secure connection configure */
12268 struct cmd_macsec_sa_result {
12269 cmdline_fixed_string_t set;
12270 cmdline_fixed_string_t macsec;
12271 cmdline_fixed_string_t sa;
12272 cmdline_fixed_string_t tx_rx;
12277 cmdline_fixed_string_t key;
12280 /* Common CLI fields for MACsec secure connection configure */
12281 static cmdline_parse_token_string_t cmd_macsec_sa_set =
12282 TOKEN_STRING_INITIALIZER
12283 (struct cmd_macsec_sa_result,
12285 static cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12286 TOKEN_STRING_INITIALIZER
12287 (struct cmd_macsec_sa_result,
12289 static cmdline_parse_token_string_t cmd_macsec_sa_sa =
12290 TOKEN_STRING_INITIALIZER
12291 (struct cmd_macsec_sa_result,
12293 static cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12294 TOKEN_STRING_INITIALIZER
12295 (struct cmd_macsec_sa_result,
12297 static cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12298 TOKEN_NUM_INITIALIZER
12299 (struct cmd_macsec_sa_result,
12300 port_id, RTE_UINT16);
12301 static cmdline_parse_token_num_t cmd_macsec_sa_idx =
12302 TOKEN_NUM_INITIALIZER
12303 (struct cmd_macsec_sa_result,
12305 static cmdline_parse_token_num_t cmd_macsec_sa_an =
12306 TOKEN_NUM_INITIALIZER
12307 (struct cmd_macsec_sa_result,
12309 static cmdline_parse_token_num_t cmd_macsec_sa_pn =
12310 TOKEN_NUM_INITIALIZER
12311 (struct cmd_macsec_sa_result,
12313 static cmdline_parse_token_string_t cmd_macsec_sa_key =
12314 TOKEN_STRING_INITIALIZER
12315 (struct cmd_macsec_sa_result,
12319 cmd_set_macsec_sa_parsed(
12320 void *parsed_result,
12321 __rte_unused struct cmdline *cl,
12322 __rte_unused void *data)
12324 struct cmd_macsec_sa_result *res = parsed_result;
12325 int ret = -ENOTSUP;
12326 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12327 uint8_t key[16] = { 0 };
12333 key_len = strlen(res->key) / 2;
12337 for (i = 0; i < key_len; i++) {
12338 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12341 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12344 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12347 #ifdef RTE_NET_IXGBE
12349 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12350 res->idx, res->an, res->pn, key) :
12351 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12352 res->idx, res->an, res->pn, key);
12354 RTE_SET_USED(is_tx);
12361 fprintf(stderr, "invalid idx %d or an %d\n", res->idx, res->an);
12364 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12367 fprintf(stderr, "not supported on port %d\n", res->port_id);
12370 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12374 static cmdline_parse_inst_t cmd_set_macsec_sa = {
12375 .f = cmd_set_macsec_sa_parsed,
12377 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12379 (void *)&cmd_macsec_sa_set,
12380 (void *)&cmd_macsec_sa_macsec,
12381 (void *)&cmd_macsec_sa_sa,
12382 (void *)&cmd_macsec_sa_tx_rx,
12383 (void *)&cmd_macsec_sa_port_id,
12384 (void *)&cmd_macsec_sa_idx,
12385 (void *)&cmd_macsec_sa_an,
12386 (void *)&cmd_macsec_sa_pn,
12387 (void *)&cmd_macsec_sa_key,
12392 /* VF unicast promiscuous mode configuration */
12394 /* Common result structure for VF unicast promiscuous mode */
12395 struct cmd_vf_promisc_result {
12396 cmdline_fixed_string_t set;
12397 cmdline_fixed_string_t vf;
12398 cmdline_fixed_string_t promisc;
12401 cmdline_fixed_string_t on_off;
12404 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12405 static cmdline_parse_token_string_t cmd_vf_promisc_set =
12406 TOKEN_STRING_INITIALIZER
12407 (struct cmd_vf_promisc_result,
12409 static cmdline_parse_token_string_t cmd_vf_promisc_vf =
12410 TOKEN_STRING_INITIALIZER
12411 (struct cmd_vf_promisc_result,
12413 static cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12414 TOKEN_STRING_INITIALIZER
12415 (struct cmd_vf_promisc_result,
12416 promisc, "promisc");
12417 static cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12418 TOKEN_NUM_INITIALIZER
12419 (struct cmd_vf_promisc_result,
12420 port_id, RTE_UINT16);
12421 static cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12422 TOKEN_NUM_INITIALIZER
12423 (struct cmd_vf_promisc_result,
12424 vf_id, RTE_UINT32);
12425 static cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12426 TOKEN_STRING_INITIALIZER
12427 (struct cmd_vf_promisc_result,
12431 cmd_set_vf_promisc_parsed(
12432 void *parsed_result,
12433 __rte_unused struct cmdline *cl,
12434 __rte_unused void *data)
12436 struct cmd_vf_promisc_result *res = parsed_result;
12437 int ret = -ENOTSUP;
12439 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12441 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12444 #ifdef RTE_NET_I40E
12445 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12446 res->vf_id, is_on);
12453 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12456 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12459 fprintf(stderr, "function not implemented\n");
12462 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12466 static cmdline_parse_inst_t cmd_set_vf_promisc = {
12467 .f = cmd_set_vf_promisc_parsed,
12469 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12470 "Set unicast promiscuous mode for a VF from the PF",
12472 (void *)&cmd_vf_promisc_set,
12473 (void *)&cmd_vf_promisc_vf,
12474 (void *)&cmd_vf_promisc_promisc,
12475 (void *)&cmd_vf_promisc_port_id,
12476 (void *)&cmd_vf_promisc_vf_id,
12477 (void *)&cmd_vf_promisc_on_off,
12482 /* VF multicast promiscuous mode configuration */
12484 /* Common result structure for VF multicast promiscuous mode */
12485 struct cmd_vf_allmulti_result {
12486 cmdline_fixed_string_t set;
12487 cmdline_fixed_string_t vf;
12488 cmdline_fixed_string_t allmulti;
12491 cmdline_fixed_string_t on_off;
12494 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12495 static cmdline_parse_token_string_t cmd_vf_allmulti_set =
12496 TOKEN_STRING_INITIALIZER
12497 (struct cmd_vf_allmulti_result,
12499 static cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12500 TOKEN_STRING_INITIALIZER
12501 (struct cmd_vf_allmulti_result,
12503 static cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12504 TOKEN_STRING_INITIALIZER
12505 (struct cmd_vf_allmulti_result,
12506 allmulti, "allmulti");
12507 static cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12508 TOKEN_NUM_INITIALIZER
12509 (struct cmd_vf_allmulti_result,
12510 port_id, RTE_UINT16);
12511 static cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12512 TOKEN_NUM_INITIALIZER
12513 (struct cmd_vf_allmulti_result,
12514 vf_id, RTE_UINT32);
12515 static cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12516 TOKEN_STRING_INITIALIZER
12517 (struct cmd_vf_allmulti_result,
12521 cmd_set_vf_allmulti_parsed(
12522 void *parsed_result,
12523 __rte_unused struct cmdline *cl,
12524 __rte_unused void *data)
12526 struct cmd_vf_allmulti_result *res = parsed_result;
12527 int ret = -ENOTSUP;
12529 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12531 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12534 #ifdef RTE_NET_I40E
12535 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12536 res->vf_id, is_on);
12543 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12546 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12549 fprintf(stderr, "function not implemented\n");
12552 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12556 static cmdline_parse_inst_t cmd_set_vf_allmulti = {
12557 .f = cmd_set_vf_allmulti_parsed,
12559 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12560 "Set multicast promiscuous mode for a VF from the PF",
12562 (void *)&cmd_vf_allmulti_set,
12563 (void *)&cmd_vf_allmulti_vf,
12564 (void *)&cmd_vf_allmulti_allmulti,
12565 (void *)&cmd_vf_allmulti_port_id,
12566 (void *)&cmd_vf_allmulti_vf_id,
12567 (void *)&cmd_vf_allmulti_on_off,
12572 /* vf broadcast mode configuration */
12574 /* Common result structure for vf broadcast */
12575 struct cmd_set_vf_broadcast_result {
12576 cmdline_fixed_string_t set;
12577 cmdline_fixed_string_t vf;
12578 cmdline_fixed_string_t broadcast;
12581 cmdline_fixed_string_t on_off;
12584 /* Common CLI fields for vf broadcast enable disable */
12585 static cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12586 TOKEN_STRING_INITIALIZER
12587 (struct cmd_set_vf_broadcast_result,
12589 static cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12590 TOKEN_STRING_INITIALIZER
12591 (struct cmd_set_vf_broadcast_result,
12593 static cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12594 TOKEN_STRING_INITIALIZER
12595 (struct cmd_set_vf_broadcast_result,
12596 broadcast, "broadcast");
12597 static cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12598 TOKEN_NUM_INITIALIZER
12599 (struct cmd_set_vf_broadcast_result,
12600 port_id, RTE_UINT16);
12601 static cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12602 TOKEN_NUM_INITIALIZER
12603 (struct cmd_set_vf_broadcast_result,
12604 vf_id, RTE_UINT16);
12605 static cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12606 TOKEN_STRING_INITIALIZER
12607 (struct cmd_set_vf_broadcast_result,
12611 cmd_set_vf_broadcast_parsed(
12612 void *parsed_result,
12613 __rte_unused struct cmdline *cl,
12614 __rte_unused void *data)
12616 struct cmd_set_vf_broadcast_result *res = parsed_result;
12617 int ret = -ENOTSUP;
12619 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12621 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12624 #ifdef RTE_NET_I40E
12625 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12626 res->vf_id, is_on);
12633 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12634 res->vf_id, is_on);
12637 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12640 fprintf(stderr, "function not implemented\n");
12643 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12647 static cmdline_parse_inst_t cmd_set_vf_broadcast = {
12648 .f = cmd_set_vf_broadcast_parsed,
12650 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12652 (void *)&cmd_set_vf_broadcast_set,
12653 (void *)&cmd_set_vf_broadcast_vf,
12654 (void *)&cmd_set_vf_broadcast_broadcast,
12655 (void *)&cmd_set_vf_broadcast_port_id,
12656 (void *)&cmd_set_vf_broadcast_vf_id,
12657 (void *)&cmd_set_vf_broadcast_on_off,
12662 /* vf vlan tag configuration */
12664 /* Common result structure for vf vlan tag */
12665 struct cmd_set_vf_vlan_tag_result {
12666 cmdline_fixed_string_t set;
12667 cmdline_fixed_string_t vf;
12668 cmdline_fixed_string_t vlan;
12669 cmdline_fixed_string_t tag;
12672 cmdline_fixed_string_t on_off;
12675 /* Common CLI fields for vf vlan tag enable disable */
12676 static cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12677 TOKEN_STRING_INITIALIZER
12678 (struct cmd_set_vf_vlan_tag_result,
12680 static cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12681 TOKEN_STRING_INITIALIZER
12682 (struct cmd_set_vf_vlan_tag_result,
12684 static cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12685 TOKEN_STRING_INITIALIZER
12686 (struct cmd_set_vf_vlan_tag_result,
12688 static cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12689 TOKEN_STRING_INITIALIZER
12690 (struct cmd_set_vf_vlan_tag_result,
12692 static cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12693 TOKEN_NUM_INITIALIZER
12694 (struct cmd_set_vf_vlan_tag_result,
12695 port_id, RTE_UINT16);
12696 static cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12697 TOKEN_NUM_INITIALIZER
12698 (struct cmd_set_vf_vlan_tag_result,
12699 vf_id, RTE_UINT16);
12700 static cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12701 TOKEN_STRING_INITIALIZER
12702 (struct cmd_set_vf_vlan_tag_result,
12706 cmd_set_vf_vlan_tag_parsed(
12707 void *parsed_result,
12708 __rte_unused struct cmdline *cl,
12709 __rte_unused void *data)
12711 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12712 int ret = -ENOTSUP;
12714 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12716 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12719 #ifdef RTE_NET_I40E
12720 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12721 res->vf_id, is_on);
12728 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12729 res->vf_id, is_on);
12732 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12735 fprintf(stderr, "function not implemented\n");
12738 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12742 static cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12743 .f = cmd_set_vf_vlan_tag_parsed,
12745 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12747 (void *)&cmd_set_vf_vlan_tag_set,
12748 (void *)&cmd_set_vf_vlan_tag_vf,
12749 (void *)&cmd_set_vf_vlan_tag_vlan,
12750 (void *)&cmd_set_vf_vlan_tag_tag,
12751 (void *)&cmd_set_vf_vlan_tag_port_id,
12752 (void *)&cmd_set_vf_vlan_tag_vf_id,
12753 (void *)&cmd_set_vf_vlan_tag_on_off,
12758 /* Common definition of VF and TC TX bandwidth configuration */
12759 struct cmd_vf_tc_bw_result {
12760 cmdline_fixed_string_t set;
12761 cmdline_fixed_string_t vf;
12762 cmdline_fixed_string_t tc;
12763 cmdline_fixed_string_t tx;
12764 cmdline_fixed_string_t min_bw;
12765 cmdline_fixed_string_t max_bw;
12766 cmdline_fixed_string_t strict_link_prio;
12771 cmdline_fixed_string_t bw_list;
12775 static cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12776 TOKEN_STRING_INITIALIZER
12777 (struct cmd_vf_tc_bw_result,
12779 static cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12780 TOKEN_STRING_INITIALIZER
12781 (struct cmd_vf_tc_bw_result,
12783 static cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12784 TOKEN_STRING_INITIALIZER
12785 (struct cmd_vf_tc_bw_result,
12787 static cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12788 TOKEN_STRING_INITIALIZER
12789 (struct cmd_vf_tc_bw_result,
12791 static cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12792 TOKEN_STRING_INITIALIZER
12793 (struct cmd_vf_tc_bw_result,
12794 strict_link_prio, "strict-link-priority");
12795 static cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12796 TOKEN_STRING_INITIALIZER
12797 (struct cmd_vf_tc_bw_result,
12798 min_bw, "min-bandwidth");
12799 static cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12800 TOKEN_STRING_INITIALIZER
12801 (struct cmd_vf_tc_bw_result,
12802 max_bw, "max-bandwidth");
12803 static cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12804 TOKEN_NUM_INITIALIZER
12805 (struct cmd_vf_tc_bw_result,
12806 port_id, RTE_UINT16);
12807 static cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12808 TOKEN_NUM_INITIALIZER
12809 (struct cmd_vf_tc_bw_result,
12810 vf_id, RTE_UINT16);
12811 static cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12812 TOKEN_NUM_INITIALIZER
12813 (struct cmd_vf_tc_bw_result,
12815 static cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12816 TOKEN_NUM_INITIALIZER
12817 (struct cmd_vf_tc_bw_result,
12819 static cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12820 TOKEN_STRING_INITIALIZER
12821 (struct cmd_vf_tc_bw_result,
12823 static cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12824 TOKEN_NUM_INITIALIZER
12825 (struct cmd_vf_tc_bw_result,
12826 tc_map, RTE_UINT8);
12828 /* VF max bandwidth setting */
12830 cmd_vf_max_bw_parsed(
12831 void *parsed_result,
12832 __rte_unused struct cmdline *cl,
12833 __rte_unused void *data)
12835 struct cmd_vf_tc_bw_result *res = parsed_result;
12836 int ret = -ENOTSUP;
12838 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12841 #ifdef RTE_NET_I40E
12842 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12843 res->vf_id, res->bw);
12850 fprintf(stderr, "invalid vf_id %d or bandwidth %d\n",
12851 res->vf_id, res->bw);
12854 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12857 fprintf(stderr, "function not implemented\n");
12860 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12864 static cmdline_parse_inst_t cmd_vf_max_bw = {
12865 .f = cmd_vf_max_bw_parsed,
12867 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12869 (void *)&cmd_vf_tc_bw_set,
12870 (void *)&cmd_vf_tc_bw_vf,
12871 (void *)&cmd_vf_tc_bw_tx,
12872 (void *)&cmd_vf_tc_bw_max_bw,
12873 (void *)&cmd_vf_tc_bw_port_id,
12874 (void *)&cmd_vf_tc_bw_vf_id,
12875 (void *)&cmd_vf_tc_bw_bw,
12881 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12886 const char *p, *p0 = str;
12893 p = strchr(p0, '(');
12896 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12900 p0 = strchr(p, ')');
12903 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12907 if (size >= sizeof(s)) {
12909 "The string size exceeds the internal buffer size\n");
12912 snprintf(s, sizeof(s), "%.*s", size, p);
12913 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12915 fprintf(stderr, "Failed to get the bandwidth list.\n");
12919 for (i = 0; i < ret; i++)
12920 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12925 /* TC min bandwidth setting */
12927 cmd_vf_tc_min_bw_parsed(
12928 void *parsed_result,
12929 __rte_unused struct cmdline *cl,
12930 __rte_unused void *data)
12932 struct cmd_vf_tc_bw_result *res = parsed_result;
12935 int ret = -ENOTSUP;
12937 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12940 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12944 #ifdef RTE_NET_I40E
12945 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12953 fprintf(stderr, "invalid vf_id %d or bandwidth\n", res->vf_id);
12956 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12959 fprintf(stderr, "function not implemented\n");
12962 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12966 static cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12967 .f = cmd_vf_tc_min_bw_parsed,
12969 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12970 " <bw1, bw2, ...>",
12972 (void *)&cmd_vf_tc_bw_set,
12973 (void *)&cmd_vf_tc_bw_vf,
12974 (void *)&cmd_vf_tc_bw_tc,
12975 (void *)&cmd_vf_tc_bw_tx,
12976 (void *)&cmd_vf_tc_bw_min_bw,
12977 (void *)&cmd_vf_tc_bw_port_id,
12978 (void *)&cmd_vf_tc_bw_vf_id,
12979 (void *)&cmd_vf_tc_bw_bw_list,
12985 cmd_tc_min_bw_parsed(
12986 void *parsed_result,
12987 __rte_unused struct cmdline *cl,
12988 __rte_unused void *data)
12990 struct cmd_vf_tc_bw_result *res = parsed_result;
12991 struct rte_port *port;
12994 int ret = -ENOTSUP;
12996 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12999 port = &ports[res->port_id];
13000 /** Check if the port is not started **/
13001 if (port->port_status != RTE_PORT_STOPPED) {
13002 fprintf(stderr, "Please stop port %d first\n", res->port_id);
13006 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13010 #ifdef RTE_NET_IXGBE
13011 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
13018 fprintf(stderr, "invalid bandwidth\n");
13021 fprintf(stderr, "invalid port_id %d\n", res->port_id);
13024 fprintf(stderr, "function not implemented\n");
13027 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
13031 static cmdline_parse_inst_t cmd_tc_min_bw = {
13032 .f = cmd_tc_min_bw_parsed,
13034 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
13036 (void *)&cmd_vf_tc_bw_set,
13037 (void *)&cmd_vf_tc_bw_tc,
13038 (void *)&cmd_vf_tc_bw_tx,
13039 (void *)&cmd_vf_tc_bw_min_bw,
13040 (void *)&cmd_vf_tc_bw_port_id,
13041 (void *)&cmd_vf_tc_bw_bw_list,
13046 /* TC max bandwidth setting */
13048 cmd_vf_tc_max_bw_parsed(
13049 void *parsed_result,
13050 __rte_unused struct cmdline *cl,
13051 __rte_unused void *data)
13053 struct cmd_vf_tc_bw_result *res = parsed_result;
13054 int ret = -ENOTSUP;
13056 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13059 #ifdef RTE_NET_I40E
13060 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
13061 res->tc_no, res->bw);
13069 "invalid vf_id %d, tc_no %d or bandwidth %d\n",
13070 res->vf_id, res->tc_no, res->bw);
13073 fprintf(stderr, "invalid port_id %d\n", res->port_id);
13076 fprintf(stderr, "function not implemented\n");
13079 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
13083 static cmdline_parse_inst_t cmd_vf_tc_max_bw = {
13084 .f = cmd_vf_tc_max_bw_parsed,
13086 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
13089 (void *)&cmd_vf_tc_bw_set,
13090 (void *)&cmd_vf_tc_bw_vf,
13091 (void *)&cmd_vf_tc_bw_tc,
13092 (void *)&cmd_vf_tc_bw_tx,
13093 (void *)&cmd_vf_tc_bw_max_bw,
13094 (void *)&cmd_vf_tc_bw_port_id,
13095 (void *)&cmd_vf_tc_bw_vf_id,
13096 (void *)&cmd_vf_tc_bw_tc_no,
13097 (void *)&cmd_vf_tc_bw_bw,
13102 /** Set VXLAN encapsulation details */
13103 struct cmd_set_vxlan_result {
13104 cmdline_fixed_string_t set;
13105 cmdline_fixed_string_t vxlan;
13106 cmdline_fixed_string_t pos_token;
13107 cmdline_fixed_string_t ip_version;
13108 uint32_t vlan_present:1;
13112 cmdline_ipaddr_t ip_src;
13113 cmdline_ipaddr_t ip_dst;
13117 struct rte_ether_addr eth_src;
13118 struct rte_ether_addr eth_dst;
13121 static cmdline_parse_token_string_t cmd_set_vxlan_set =
13122 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
13123 static cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
13124 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
13125 static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
13126 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
13128 static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
13129 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
13130 "vxlan-with-vlan");
13131 static cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
13132 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13134 static cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
13135 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
13137 static cmdline_parse_token_string_t cmd_set_vxlan_vni =
13138 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13140 static cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
13141 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
13142 static cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
13143 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13145 static cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
13146 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
13147 static cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
13148 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13150 static cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
13151 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
13152 static cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
13153 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13155 static cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
13156 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
13157 static cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
13158 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13160 static cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
13161 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
13162 static cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
13163 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13165 static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
13166 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
13167 static cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
13168 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13170 static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
13171 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
13172 static cmdline_parse_token_string_t cmd_set_vxlan_vlan =
13173 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13175 static cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
13176 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
13177 static cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
13178 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13180 static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
13181 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
13182 static cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
13183 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13185 static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
13186 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
13188 static void cmd_set_vxlan_parsed(void *parsed_result,
13189 __rte_unused struct cmdline *cl,
13190 __rte_unused void *data)
13192 struct cmd_set_vxlan_result *res = parsed_result;
13197 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
13200 vxlan_encap_conf.select_tos_ttl = 0;
13201 if (strcmp(res->vxlan, "vxlan") == 0)
13202 vxlan_encap_conf.select_vlan = 0;
13203 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
13204 vxlan_encap_conf.select_vlan = 1;
13205 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
13206 vxlan_encap_conf.select_vlan = 0;
13207 vxlan_encap_conf.select_tos_ttl = 1;
13209 if (strcmp(res->ip_version, "ipv4") == 0)
13210 vxlan_encap_conf.select_ipv4 = 1;
13211 else if (strcmp(res->ip_version, "ipv6") == 0)
13212 vxlan_encap_conf.select_ipv4 = 0;
13215 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
13216 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13217 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13218 vxlan_encap_conf.ip_tos = res->tos;
13219 vxlan_encap_conf.ip_ttl = res->ttl;
13220 if (vxlan_encap_conf.select_ipv4) {
13221 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
13222 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
13224 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
13225 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
13227 if (vxlan_encap_conf.select_vlan)
13228 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13229 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
13230 RTE_ETHER_ADDR_LEN);
13231 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13232 RTE_ETHER_ADDR_LEN);
13235 static cmdline_parse_inst_t cmd_set_vxlan = {
13236 .f = cmd_set_vxlan_parsed,
13238 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
13239 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
13240 " eth-src <eth-src> eth-dst <eth-dst>",
13242 (void *)&cmd_set_vxlan_set,
13243 (void *)&cmd_set_vxlan_vxlan,
13244 (void *)&cmd_set_vxlan_ip_version,
13245 (void *)&cmd_set_vxlan_ip_version_value,
13246 (void *)&cmd_set_vxlan_vni,
13247 (void *)&cmd_set_vxlan_vni_value,
13248 (void *)&cmd_set_vxlan_udp_src,
13249 (void *)&cmd_set_vxlan_udp_src_value,
13250 (void *)&cmd_set_vxlan_udp_dst,
13251 (void *)&cmd_set_vxlan_udp_dst_value,
13252 (void *)&cmd_set_vxlan_ip_src,
13253 (void *)&cmd_set_vxlan_ip_src_value,
13254 (void *)&cmd_set_vxlan_ip_dst,
13255 (void *)&cmd_set_vxlan_ip_dst_value,
13256 (void *)&cmd_set_vxlan_eth_src,
13257 (void *)&cmd_set_vxlan_eth_src_value,
13258 (void *)&cmd_set_vxlan_eth_dst,
13259 (void *)&cmd_set_vxlan_eth_dst_value,
13264 static cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
13265 .f = cmd_set_vxlan_parsed,
13267 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
13268 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
13269 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13270 " eth-dst <eth-dst>",
13272 (void *)&cmd_set_vxlan_set,
13273 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
13274 (void *)&cmd_set_vxlan_ip_version,
13275 (void *)&cmd_set_vxlan_ip_version_value,
13276 (void *)&cmd_set_vxlan_vni,
13277 (void *)&cmd_set_vxlan_vni_value,
13278 (void *)&cmd_set_vxlan_udp_src,
13279 (void *)&cmd_set_vxlan_udp_src_value,
13280 (void *)&cmd_set_vxlan_udp_dst,
13281 (void *)&cmd_set_vxlan_udp_dst_value,
13282 (void *)&cmd_set_vxlan_ip_tos,
13283 (void *)&cmd_set_vxlan_ip_tos_value,
13284 (void *)&cmd_set_vxlan_ip_ttl,
13285 (void *)&cmd_set_vxlan_ip_ttl_value,
13286 (void *)&cmd_set_vxlan_ip_src,
13287 (void *)&cmd_set_vxlan_ip_src_value,
13288 (void *)&cmd_set_vxlan_ip_dst,
13289 (void *)&cmd_set_vxlan_ip_dst_value,
13290 (void *)&cmd_set_vxlan_eth_src,
13291 (void *)&cmd_set_vxlan_eth_src_value,
13292 (void *)&cmd_set_vxlan_eth_dst,
13293 (void *)&cmd_set_vxlan_eth_dst_value,
13298 static cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
13299 .f = cmd_set_vxlan_parsed,
13301 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
13302 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
13303 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
13306 (void *)&cmd_set_vxlan_set,
13307 (void *)&cmd_set_vxlan_vxlan_with_vlan,
13308 (void *)&cmd_set_vxlan_ip_version,
13309 (void *)&cmd_set_vxlan_ip_version_value,
13310 (void *)&cmd_set_vxlan_vni,
13311 (void *)&cmd_set_vxlan_vni_value,
13312 (void *)&cmd_set_vxlan_udp_src,
13313 (void *)&cmd_set_vxlan_udp_src_value,
13314 (void *)&cmd_set_vxlan_udp_dst,
13315 (void *)&cmd_set_vxlan_udp_dst_value,
13316 (void *)&cmd_set_vxlan_ip_src,
13317 (void *)&cmd_set_vxlan_ip_src_value,
13318 (void *)&cmd_set_vxlan_ip_dst,
13319 (void *)&cmd_set_vxlan_ip_dst_value,
13320 (void *)&cmd_set_vxlan_vlan,
13321 (void *)&cmd_set_vxlan_vlan_value,
13322 (void *)&cmd_set_vxlan_eth_src,
13323 (void *)&cmd_set_vxlan_eth_src_value,
13324 (void *)&cmd_set_vxlan_eth_dst,
13325 (void *)&cmd_set_vxlan_eth_dst_value,
13330 /** Set NVGRE encapsulation details */
13331 struct cmd_set_nvgre_result {
13332 cmdline_fixed_string_t set;
13333 cmdline_fixed_string_t nvgre;
13334 cmdline_fixed_string_t pos_token;
13335 cmdline_fixed_string_t ip_version;
13337 cmdline_ipaddr_t ip_src;
13338 cmdline_ipaddr_t ip_dst;
13340 struct rte_ether_addr eth_src;
13341 struct rte_ether_addr eth_dst;
13344 static cmdline_parse_token_string_t cmd_set_nvgre_set =
13345 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
13346 static cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
13347 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
13348 static cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
13349 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
13350 "nvgre-with-vlan");
13351 static cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
13352 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13354 static cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
13355 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
13357 static cmdline_parse_token_string_t cmd_set_nvgre_tni =
13358 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13360 static cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
13361 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
13362 static cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
13363 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13365 static cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
13366 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
13367 static cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
13368 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13370 static cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
13371 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
13372 static cmdline_parse_token_string_t cmd_set_nvgre_vlan =
13373 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13375 static cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
13376 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
13377 static cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
13378 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13380 static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
13381 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
13382 static cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
13383 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13385 static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
13386 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
13388 static void cmd_set_nvgre_parsed(void *parsed_result,
13389 __rte_unused struct cmdline *cl,
13390 __rte_unused void *data)
13392 struct cmd_set_nvgre_result *res = parsed_result;
13394 uint32_t nvgre_tni;
13397 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
13400 if (strcmp(res->nvgre, "nvgre") == 0)
13401 nvgre_encap_conf.select_vlan = 0;
13402 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
13403 nvgre_encap_conf.select_vlan = 1;
13404 if (strcmp(res->ip_version, "ipv4") == 0)
13405 nvgre_encap_conf.select_ipv4 = 1;
13406 else if (strcmp(res->ip_version, "ipv6") == 0)
13407 nvgre_encap_conf.select_ipv4 = 0;
13410 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
13411 if (nvgre_encap_conf.select_ipv4) {
13412 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
13413 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
13415 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
13416 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
13418 if (nvgre_encap_conf.select_vlan)
13419 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13420 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
13421 RTE_ETHER_ADDR_LEN);
13422 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13423 RTE_ETHER_ADDR_LEN);
13426 static cmdline_parse_inst_t cmd_set_nvgre = {
13427 .f = cmd_set_nvgre_parsed,
13429 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
13430 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13431 " eth-dst <eth-dst>",
13433 (void *)&cmd_set_nvgre_set,
13434 (void *)&cmd_set_nvgre_nvgre,
13435 (void *)&cmd_set_nvgre_ip_version,
13436 (void *)&cmd_set_nvgre_ip_version_value,
13437 (void *)&cmd_set_nvgre_tni,
13438 (void *)&cmd_set_nvgre_tni_value,
13439 (void *)&cmd_set_nvgre_ip_src,
13440 (void *)&cmd_set_nvgre_ip_src_value,
13441 (void *)&cmd_set_nvgre_ip_dst,
13442 (void *)&cmd_set_nvgre_ip_dst_value,
13443 (void *)&cmd_set_nvgre_eth_src,
13444 (void *)&cmd_set_nvgre_eth_src_value,
13445 (void *)&cmd_set_nvgre_eth_dst,
13446 (void *)&cmd_set_nvgre_eth_dst_value,
13451 static cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
13452 .f = cmd_set_nvgre_parsed,
13454 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
13455 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13456 " eth-src <eth-src> eth-dst <eth-dst>",
13458 (void *)&cmd_set_nvgre_set,
13459 (void *)&cmd_set_nvgre_nvgre_with_vlan,
13460 (void *)&cmd_set_nvgre_ip_version,
13461 (void *)&cmd_set_nvgre_ip_version_value,
13462 (void *)&cmd_set_nvgre_tni,
13463 (void *)&cmd_set_nvgre_tni_value,
13464 (void *)&cmd_set_nvgre_ip_src,
13465 (void *)&cmd_set_nvgre_ip_src_value,
13466 (void *)&cmd_set_nvgre_ip_dst,
13467 (void *)&cmd_set_nvgre_ip_dst_value,
13468 (void *)&cmd_set_nvgre_vlan,
13469 (void *)&cmd_set_nvgre_vlan_value,
13470 (void *)&cmd_set_nvgre_eth_src,
13471 (void *)&cmd_set_nvgre_eth_src_value,
13472 (void *)&cmd_set_nvgre_eth_dst,
13473 (void *)&cmd_set_nvgre_eth_dst_value,
13478 /** Set L2 encapsulation details */
13479 struct cmd_set_l2_encap_result {
13480 cmdline_fixed_string_t set;
13481 cmdline_fixed_string_t l2_encap;
13482 cmdline_fixed_string_t pos_token;
13483 cmdline_fixed_string_t ip_version;
13484 uint32_t vlan_present:1;
13486 struct rte_ether_addr eth_src;
13487 struct rte_ether_addr eth_dst;
13490 static cmdline_parse_token_string_t cmd_set_l2_encap_set =
13491 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13492 static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13493 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13494 static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13495 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13496 "l2_encap-with-vlan");
13497 static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13498 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13500 static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13501 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13503 static cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13504 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13506 static cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13507 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13508 static cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13509 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13511 static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13512 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13513 static cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13514 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13516 static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13517 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13519 static void cmd_set_l2_encap_parsed(void *parsed_result,
13520 __rte_unused struct cmdline *cl,
13521 __rte_unused void *data)
13523 struct cmd_set_l2_encap_result *res = parsed_result;
13525 if (strcmp(res->l2_encap, "l2_encap") == 0)
13526 l2_encap_conf.select_vlan = 0;
13527 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13528 l2_encap_conf.select_vlan = 1;
13529 if (strcmp(res->ip_version, "ipv4") == 0)
13530 l2_encap_conf.select_ipv4 = 1;
13531 else if (strcmp(res->ip_version, "ipv6") == 0)
13532 l2_encap_conf.select_ipv4 = 0;
13535 if (l2_encap_conf.select_vlan)
13536 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13537 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13538 RTE_ETHER_ADDR_LEN);
13539 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13540 RTE_ETHER_ADDR_LEN);
13543 static cmdline_parse_inst_t cmd_set_l2_encap = {
13544 .f = cmd_set_l2_encap_parsed,
13546 .help_str = "set l2_encap ip-version ipv4|ipv6"
13547 " eth-src <eth-src> eth-dst <eth-dst>",
13549 (void *)&cmd_set_l2_encap_set,
13550 (void *)&cmd_set_l2_encap_l2_encap,
13551 (void *)&cmd_set_l2_encap_ip_version,
13552 (void *)&cmd_set_l2_encap_ip_version_value,
13553 (void *)&cmd_set_l2_encap_eth_src,
13554 (void *)&cmd_set_l2_encap_eth_src_value,
13555 (void *)&cmd_set_l2_encap_eth_dst,
13556 (void *)&cmd_set_l2_encap_eth_dst_value,
13561 static cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13562 .f = cmd_set_l2_encap_parsed,
13564 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13565 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13567 (void *)&cmd_set_l2_encap_set,
13568 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13569 (void *)&cmd_set_l2_encap_ip_version,
13570 (void *)&cmd_set_l2_encap_ip_version_value,
13571 (void *)&cmd_set_l2_encap_vlan,
13572 (void *)&cmd_set_l2_encap_vlan_value,
13573 (void *)&cmd_set_l2_encap_eth_src,
13574 (void *)&cmd_set_l2_encap_eth_src_value,
13575 (void *)&cmd_set_l2_encap_eth_dst,
13576 (void *)&cmd_set_l2_encap_eth_dst_value,
13581 /** Set L2 decapsulation details */
13582 struct cmd_set_l2_decap_result {
13583 cmdline_fixed_string_t set;
13584 cmdline_fixed_string_t l2_decap;
13585 cmdline_fixed_string_t pos_token;
13586 uint32_t vlan_present:1;
13589 static cmdline_parse_token_string_t cmd_set_l2_decap_set =
13590 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13591 static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13592 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13594 static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13595 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13596 "l2_decap-with-vlan");
13598 static void cmd_set_l2_decap_parsed(void *parsed_result,
13599 __rte_unused struct cmdline *cl,
13600 __rte_unused void *data)
13602 struct cmd_set_l2_decap_result *res = parsed_result;
13604 if (strcmp(res->l2_decap, "l2_decap") == 0)
13605 l2_decap_conf.select_vlan = 0;
13606 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13607 l2_decap_conf.select_vlan = 1;
13610 static cmdline_parse_inst_t cmd_set_l2_decap = {
13611 .f = cmd_set_l2_decap_parsed,
13613 .help_str = "set l2_decap",
13615 (void *)&cmd_set_l2_decap_set,
13616 (void *)&cmd_set_l2_decap_l2_decap,
13621 static cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13622 .f = cmd_set_l2_decap_parsed,
13624 .help_str = "set l2_decap-with-vlan",
13626 (void *)&cmd_set_l2_decap_set,
13627 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13632 /** Set MPLSoGRE encapsulation details */
13633 struct cmd_set_mplsogre_encap_result {
13634 cmdline_fixed_string_t set;
13635 cmdline_fixed_string_t mplsogre;
13636 cmdline_fixed_string_t pos_token;
13637 cmdline_fixed_string_t ip_version;
13638 uint32_t vlan_present:1;
13640 cmdline_ipaddr_t ip_src;
13641 cmdline_ipaddr_t ip_dst;
13643 struct rte_ether_addr eth_src;
13644 struct rte_ether_addr eth_dst;
13647 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13648 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13650 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13651 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13653 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13654 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13655 mplsogre, "mplsogre_encap-with-vlan");
13656 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13657 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13658 pos_token, "ip-version");
13659 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13660 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13661 ip_version, "ipv4#ipv6");
13662 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13663 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13664 pos_token, "label");
13665 static cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13666 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13668 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13669 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13670 pos_token, "ip-src");
13671 static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13672 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13673 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13674 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13675 pos_token, "ip-dst");
13676 static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13677 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13678 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13679 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13680 pos_token, "vlan-tci");
13681 static cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13682 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13684 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13685 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13686 pos_token, "eth-src");
13687 static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13688 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13690 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13691 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13692 pos_token, "eth-dst");
13693 static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13694 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13697 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13698 __rte_unused struct cmdline *cl,
13699 __rte_unused void *data)
13701 struct cmd_set_mplsogre_encap_result *res = parsed_result;
13703 uint32_t mplsogre_label;
13706 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13709 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13710 mplsogre_encap_conf.select_vlan = 0;
13711 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13712 mplsogre_encap_conf.select_vlan = 1;
13713 if (strcmp(res->ip_version, "ipv4") == 0)
13714 mplsogre_encap_conf.select_ipv4 = 1;
13715 else if (strcmp(res->ip_version, "ipv6") == 0)
13716 mplsogre_encap_conf.select_ipv4 = 0;
13719 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13720 if (mplsogre_encap_conf.select_ipv4) {
13721 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13722 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13724 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13725 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13727 if (mplsogre_encap_conf.select_vlan)
13728 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13729 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13730 RTE_ETHER_ADDR_LEN);
13731 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13732 RTE_ETHER_ADDR_LEN);
13735 static cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13736 .f = cmd_set_mplsogre_encap_parsed,
13738 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13739 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13740 " eth-dst <eth-dst>",
13742 (void *)&cmd_set_mplsogre_encap_set,
13743 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13744 (void *)&cmd_set_mplsogre_encap_ip_version,
13745 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13746 (void *)&cmd_set_mplsogre_encap_label,
13747 (void *)&cmd_set_mplsogre_encap_label_value,
13748 (void *)&cmd_set_mplsogre_encap_ip_src,
13749 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13750 (void *)&cmd_set_mplsogre_encap_ip_dst,
13751 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13752 (void *)&cmd_set_mplsogre_encap_eth_src,
13753 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13754 (void *)&cmd_set_mplsogre_encap_eth_dst,
13755 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13760 static cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13761 .f = cmd_set_mplsogre_encap_parsed,
13763 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13764 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
13765 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13767 (void *)&cmd_set_mplsogre_encap_set,
13768 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13769 (void *)&cmd_set_mplsogre_encap_ip_version,
13770 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13771 (void *)&cmd_set_mplsogre_encap_label,
13772 (void *)&cmd_set_mplsogre_encap_label_value,
13773 (void *)&cmd_set_mplsogre_encap_ip_src,
13774 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13775 (void *)&cmd_set_mplsogre_encap_ip_dst,
13776 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13777 (void *)&cmd_set_mplsogre_encap_vlan,
13778 (void *)&cmd_set_mplsogre_encap_vlan_value,
13779 (void *)&cmd_set_mplsogre_encap_eth_src,
13780 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13781 (void *)&cmd_set_mplsogre_encap_eth_dst,
13782 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13787 /** Set MPLSoGRE decapsulation details */
13788 struct cmd_set_mplsogre_decap_result {
13789 cmdline_fixed_string_t set;
13790 cmdline_fixed_string_t mplsogre;
13791 cmdline_fixed_string_t pos_token;
13792 cmdline_fixed_string_t ip_version;
13793 uint32_t vlan_present:1;
13796 static cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13797 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13799 static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13800 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13802 static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13803 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13804 mplsogre, "mplsogre_decap-with-vlan");
13805 static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13806 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13807 pos_token, "ip-version");
13808 static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13809 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13810 ip_version, "ipv4#ipv6");
13812 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13813 __rte_unused struct cmdline *cl,
13814 __rte_unused void *data)
13816 struct cmd_set_mplsogre_decap_result *res = parsed_result;
13818 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13819 mplsogre_decap_conf.select_vlan = 0;
13820 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13821 mplsogre_decap_conf.select_vlan = 1;
13822 if (strcmp(res->ip_version, "ipv4") == 0)
13823 mplsogre_decap_conf.select_ipv4 = 1;
13824 else if (strcmp(res->ip_version, "ipv6") == 0)
13825 mplsogre_decap_conf.select_ipv4 = 0;
13828 static cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13829 .f = cmd_set_mplsogre_decap_parsed,
13831 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13833 (void *)&cmd_set_mplsogre_decap_set,
13834 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13835 (void *)&cmd_set_mplsogre_decap_ip_version,
13836 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13841 static cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13842 .f = cmd_set_mplsogre_decap_parsed,
13844 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13846 (void *)&cmd_set_mplsogre_decap_set,
13847 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13848 (void *)&cmd_set_mplsogre_decap_ip_version,
13849 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13854 /** Set MPLSoUDP encapsulation details */
13855 struct cmd_set_mplsoudp_encap_result {
13856 cmdline_fixed_string_t set;
13857 cmdline_fixed_string_t mplsoudp;
13858 cmdline_fixed_string_t pos_token;
13859 cmdline_fixed_string_t ip_version;
13860 uint32_t vlan_present:1;
13864 cmdline_ipaddr_t ip_src;
13865 cmdline_ipaddr_t ip_dst;
13867 struct rte_ether_addr eth_src;
13868 struct rte_ether_addr eth_dst;
13871 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13872 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13874 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13875 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13877 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13878 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13879 mplsoudp, "mplsoudp_encap-with-vlan");
13880 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13881 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13882 pos_token, "ip-version");
13883 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13884 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13885 ip_version, "ipv4#ipv6");
13886 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13887 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13888 pos_token, "label");
13889 static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13890 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13892 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13893 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13894 pos_token, "udp-src");
13895 static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13896 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13898 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13899 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13900 pos_token, "udp-dst");
13901 static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13902 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13904 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13905 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13906 pos_token, "ip-src");
13907 static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13908 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13909 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13910 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13911 pos_token, "ip-dst");
13912 static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13913 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13914 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13915 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13916 pos_token, "vlan-tci");
13917 static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13918 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13920 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13921 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13922 pos_token, "eth-src");
13923 static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13924 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13926 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13927 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13928 pos_token, "eth-dst");
13929 static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13930 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13933 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13934 __rte_unused struct cmdline *cl,
13935 __rte_unused void *data)
13937 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13939 uint32_t mplsoudp_label;
13942 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13945 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13946 mplsoudp_encap_conf.select_vlan = 0;
13947 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13948 mplsoudp_encap_conf.select_vlan = 1;
13949 if (strcmp(res->ip_version, "ipv4") == 0)
13950 mplsoudp_encap_conf.select_ipv4 = 1;
13951 else if (strcmp(res->ip_version, "ipv6") == 0)
13952 mplsoudp_encap_conf.select_ipv4 = 0;
13955 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13956 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13957 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13958 if (mplsoudp_encap_conf.select_ipv4) {
13959 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13960 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13962 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13963 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13965 if (mplsoudp_encap_conf.select_vlan)
13966 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13967 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13968 RTE_ETHER_ADDR_LEN);
13969 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13970 RTE_ETHER_ADDR_LEN);
13973 static cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13974 .f = cmd_set_mplsoudp_encap_parsed,
13976 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13977 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13978 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13980 (void *)&cmd_set_mplsoudp_encap_set,
13981 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13982 (void *)&cmd_set_mplsoudp_encap_ip_version,
13983 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13984 (void *)&cmd_set_mplsoudp_encap_label,
13985 (void *)&cmd_set_mplsoudp_encap_label_value,
13986 (void *)&cmd_set_mplsoudp_encap_udp_src,
13987 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13988 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13989 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13990 (void *)&cmd_set_mplsoudp_encap_ip_src,
13991 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13992 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13993 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13994 (void *)&cmd_set_mplsoudp_encap_eth_src,
13995 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13996 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13997 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
14002 static cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
14003 .f = cmd_set_mplsoudp_encap_parsed,
14005 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
14006 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
14007 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
14008 " eth-src <eth-src> eth-dst <eth-dst>",
14010 (void *)&cmd_set_mplsoudp_encap_set,
14011 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
14012 (void *)&cmd_set_mplsoudp_encap_ip_version,
14013 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
14014 (void *)&cmd_set_mplsoudp_encap_label,
14015 (void *)&cmd_set_mplsoudp_encap_label_value,
14016 (void *)&cmd_set_mplsoudp_encap_udp_src,
14017 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
14018 (void *)&cmd_set_mplsoudp_encap_udp_dst,
14019 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
14020 (void *)&cmd_set_mplsoudp_encap_ip_src,
14021 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
14022 (void *)&cmd_set_mplsoudp_encap_ip_dst,
14023 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
14024 (void *)&cmd_set_mplsoudp_encap_vlan,
14025 (void *)&cmd_set_mplsoudp_encap_vlan_value,
14026 (void *)&cmd_set_mplsoudp_encap_eth_src,
14027 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
14028 (void *)&cmd_set_mplsoudp_encap_eth_dst,
14029 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
14034 /** Set MPLSoUDP decapsulation details */
14035 struct cmd_set_mplsoudp_decap_result {
14036 cmdline_fixed_string_t set;
14037 cmdline_fixed_string_t mplsoudp;
14038 cmdline_fixed_string_t pos_token;
14039 cmdline_fixed_string_t ip_version;
14040 uint32_t vlan_present:1;
14043 static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
14044 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
14046 static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
14047 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
14049 static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
14050 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
14051 mplsoudp, "mplsoudp_decap-with-vlan");
14052 static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
14053 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
14054 pos_token, "ip-version");
14055 static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
14056 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
14057 ip_version, "ipv4#ipv6");
14059 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
14060 __rte_unused struct cmdline *cl,
14061 __rte_unused void *data)
14063 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
14065 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
14066 mplsoudp_decap_conf.select_vlan = 0;
14067 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
14068 mplsoudp_decap_conf.select_vlan = 1;
14069 if (strcmp(res->ip_version, "ipv4") == 0)
14070 mplsoudp_decap_conf.select_ipv4 = 1;
14071 else if (strcmp(res->ip_version, "ipv6") == 0)
14072 mplsoudp_decap_conf.select_ipv4 = 0;
14075 static cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
14076 .f = cmd_set_mplsoudp_decap_parsed,
14078 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
14080 (void *)&cmd_set_mplsoudp_decap_set,
14081 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
14082 (void *)&cmd_set_mplsoudp_decap_ip_version,
14083 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
14088 static cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
14089 .f = cmd_set_mplsoudp_decap_parsed,
14091 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
14093 (void *)&cmd_set_mplsoudp_decap_set,
14094 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
14095 (void *)&cmd_set_mplsoudp_decap_ip_version,
14096 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
14101 /** Set connection tracking object common details */
14102 struct cmd_set_conntrack_common_result {
14103 cmdline_fixed_string_t set;
14104 cmdline_fixed_string_t conntrack;
14105 cmdline_fixed_string_t common;
14106 cmdline_fixed_string_t peer;
14107 cmdline_fixed_string_t is_orig;
14108 cmdline_fixed_string_t enable;
14109 cmdline_fixed_string_t live;
14110 cmdline_fixed_string_t sack;
14111 cmdline_fixed_string_t cack;
14112 cmdline_fixed_string_t last_dir;
14113 cmdline_fixed_string_t liberal;
14114 cmdline_fixed_string_t state;
14115 cmdline_fixed_string_t max_ack_win;
14116 cmdline_fixed_string_t retrans;
14117 cmdline_fixed_string_t last_win;
14118 cmdline_fixed_string_t last_seq;
14119 cmdline_fixed_string_t last_ack;
14120 cmdline_fixed_string_t last_end;
14121 cmdline_fixed_string_t last_index;
14124 uint16_t peer_port;
14125 uint32_t is_original;
14140 static cmdline_parse_token_string_t cmd_set_conntrack_set =
14141 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14143 static cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
14144 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14145 conntrack, "conntrack");
14146 static cmdline_parse_token_string_t cmd_set_conntrack_common_com =
14147 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14149 static cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
14150 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14152 static cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
14153 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14154 peer_port, RTE_UINT16);
14155 static cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
14156 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14157 is_orig, "is_orig");
14158 static cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
14159 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14160 is_original, RTE_UINT32);
14161 static cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
14162 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14164 static cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
14165 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14167 static cmdline_parse_token_string_t cmd_set_conntrack_common_live =
14168 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14170 static cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
14171 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14172 is_live, RTE_UINT32);
14173 static cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
14174 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14176 static cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
14177 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14178 s_ack, RTE_UINT32);
14179 static cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
14180 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14182 static cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
14183 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14184 c_ack, RTE_UINT32);
14185 static cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
14186 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14187 last_dir, "last_dir");
14188 static cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
14189 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14191 static cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
14192 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14193 liberal, "liberal");
14194 static cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
14195 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14197 static cmdline_parse_token_string_t cmd_set_conntrack_common_state =
14198 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14200 static cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
14201 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14203 static cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
14204 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14205 max_ack_win, "max_ack_win");
14206 static cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
14207 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14208 factor, RTE_UINT8);
14209 static cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
14210 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14212 static cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
14213 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14214 re_num, RTE_UINT8);
14215 static cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
14216 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14217 last_win, "last_win");
14218 static cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
14219 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14221 static cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
14222 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14223 last_seq, "last_seq");
14224 static cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
14225 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14227 static cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
14228 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14229 last_ack, "last_ack");
14230 static cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
14231 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14233 static cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
14234 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14235 last_end, "last_end");
14236 static cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
14237 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14239 static cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
14240 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14241 last_index, "last_index");
14242 static cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
14243 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14246 static void cmd_set_conntrack_common_parsed(void *parsed_result,
14247 __rte_unused struct cmdline *cl,
14248 __rte_unused void *data)
14250 struct cmd_set_conntrack_common_result *res = parsed_result;
14252 /* No need to swap to big endian. */
14253 conntrack_context.peer_port = res->peer_port;
14254 conntrack_context.is_original_dir = res->is_original;
14255 conntrack_context.enable = res->en;
14256 conntrack_context.live_connection = res->is_live;
14257 conntrack_context.selective_ack = res->s_ack;
14258 conntrack_context.challenge_ack_passed = res->c_ack;
14259 conntrack_context.last_direction = res->ld;
14260 conntrack_context.liberal_mode = res->lb;
14261 conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
14262 conntrack_context.max_ack_window = res->factor;
14263 conntrack_context.retransmission_limit = res->re_num;
14264 conntrack_context.last_window = res->lw;
14265 conntrack_context.last_index =
14266 (enum rte_flow_conntrack_tcp_last_index)res->li;
14267 conntrack_context.last_seq = res->ls;
14268 conntrack_context.last_ack = res->la;
14269 conntrack_context.last_end = res->le;
14272 static cmdline_parse_inst_t cmd_set_conntrack_common = {
14273 .f = cmd_set_conntrack_common_parsed,
14275 .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
14276 " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
14277 " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
14278 " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
14279 " last_index <flag>",
14281 (void *)&cmd_set_conntrack_set,
14282 (void *)&cmd_set_conntrack_conntrack,
14283 (void *)&cmd_set_conntrack_common_com,
14284 (void *)&cmd_set_conntrack_common_peer,
14285 (void *)&cmd_set_conntrack_common_peer_value,
14286 (void *)&cmd_set_conntrack_common_is_orig,
14287 (void *)&cmd_set_conntrack_common_is_orig_value,
14288 (void *)&cmd_set_conntrack_common_enable,
14289 (void *)&cmd_set_conntrack_common_enable_value,
14290 (void *)&cmd_set_conntrack_common_live,
14291 (void *)&cmd_set_conntrack_common_live_value,
14292 (void *)&cmd_set_conntrack_common_sack,
14293 (void *)&cmd_set_conntrack_common_sack_value,
14294 (void *)&cmd_set_conntrack_common_cack,
14295 (void *)&cmd_set_conntrack_common_cack_value,
14296 (void *)&cmd_set_conntrack_common_last_dir,
14297 (void *)&cmd_set_conntrack_common_last_dir_value,
14298 (void *)&cmd_set_conntrack_common_liberal,
14299 (void *)&cmd_set_conntrack_common_liberal_value,
14300 (void *)&cmd_set_conntrack_common_state,
14301 (void *)&cmd_set_conntrack_common_state_value,
14302 (void *)&cmd_set_conntrack_common_max_ackwin,
14303 (void *)&cmd_set_conntrack_common_max_ackwin_value,
14304 (void *)&cmd_set_conntrack_common_retrans,
14305 (void *)&cmd_set_conntrack_common_retrans_value,
14306 (void *)&cmd_set_conntrack_common_last_win,
14307 (void *)&cmd_set_conntrack_common_last_win_value,
14308 (void *)&cmd_set_conntrack_common_last_seq,
14309 (void *)&cmd_set_conntrack_common_last_seq_value,
14310 (void *)&cmd_set_conntrack_common_last_ack,
14311 (void *)&cmd_set_conntrack_common_last_ack_value,
14312 (void *)&cmd_set_conntrack_common_last_end,
14313 (void *)&cmd_set_conntrack_common_last_end_value,
14314 (void *)&cmd_set_conntrack_common_last_index,
14315 (void *)&cmd_set_conntrack_common_last_index_value,
14320 /** Set connection tracking object both directions' details */
14321 struct cmd_set_conntrack_dir_result {
14322 cmdline_fixed_string_t set;
14323 cmdline_fixed_string_t conntrack;
14324 cmdline_fixed_string_t dir;
14325 cmdline_fixed_string_t scale;
14326 cmdline_fixed_string_t fin;
14327 cmdline_fixed_string_t ack_seen;
14328 cmdline_fixed_string_t unack;
14329 cmdline_fixed_string_t sent_end;
14330 cmdline_fixed_string_t reply_end;
14331 cmdline_fixed_string_t max_win;
14332 cmdline_fixed_string_t max_ack;
14343 static cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
14344 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14346 static cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
14347 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14349 static cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
14350 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14351 factor, RTE_UINT32);
14352 static cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
14353 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14355 static cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
14356 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14358 static cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
14359 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14360 ack_seen, "acked");
14361 static cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
14362 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14364 static cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
14365 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14366 unack, "unack_data");
14367 static cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
14368 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14370 static cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
14371 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14372 sent_end, "sent_end");
14373 static cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
14374 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14376 static cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
14377 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14378 reply_end, "reply_end");
14379 static cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
14380 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14382 static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
14383 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14384 max_win, "max_win");
14385 static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
14386 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14388 static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
14389 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14390 max_ack, "max_ack");
14391 static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
14392 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14395 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
14396 __rte_unused struct cmdline *cl,
14397 __rte_unused void *data)
14399 struct cmd_set_conntrack_dir_result *res = parsed_result;
14400 struct rte_flow_tcp_dir_param *dir = NULL;
14402 if (strcmp(res->dir, "orig") == 0)
14403 dir = &conntrack_context.original_dir;
14404 else if (strcmp(res->dir, "rply") == 0)
14405 dir = &conntrack_context.reply_dir;
14408 dir->scale = res->factor;
14409 dir->close_initiated = res->f;
14410 dir->last_ack_seen = res->as;
14411 dir->data_unacked = res->un;
14412 dir->sent_end = res->se;
14413 dir->reply_end = res->re;
14414 dir->max_ack = res->ma;
14415 dir->max_win = res->mw;
14418 static cmdline_parse_inst_t cmd_set_conntrack_dir = {
14419 .f = cmd_set_conntrack_dir_parsed,
14421 .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
14422 " acked <seen> unack_data <unack> sent_end <sent>"
14423 " reply_end <reply> max_win <win> max_ack <ack>",
14425 (void *)&cmd_set_conntrack_set,
14426 (void *)&cmd_set_conntrack_conntrack,
14427 (void *)&cmd_set_conntrack_dir_dir,
14428 (void *)&cmd_set_conntrack_dir_scale,
14429 (void *)&cmd_set_conntrack_dir_scale_value,
14430 (void *)&cmd_set_conntrack_dir_fin,
14431 (void *)&cmd_set_conntrack_dir_fin_value,
14432 (void *)&cmd_set_conntrack_dir_ack,
14433 (void *)&cmd_set_conntrack_dir_ack_value,
14434 (void *)&cmd_set_conntrack_dir_unack_data,
14435 (void *)&cmd_set_conntrack_dir_unack_data_value,
14436 (void *)&cmd_set_conntrack_dir_sent_end,
14437 (void *)&cmd_set_conntrack_dir_sent_end_value,
14438 (void *)&cmd_set_conntrack_dir_reply_end,
14439 (void *)&cmd_set_conntrack_dir_reply_end_value,
14440 (void *)&cmd_set_conntrack_dir_max_win,
14441 (void *)&cmd_set_conntrack_dir_max_win_value,
14442 (void *)&cmd_set_conntrack_dir_max_ack,
14443 (void *)&cmd_set_conntrack_dir_max_ack_value,
14448 /* Strict link priority scheduling mode setting */
14450 cmd_strict_link_prio_parsed(
14451 void *parsed_result,
14452 __rte_unused struct cmdline *cl,
14453 __rte_unused void *data)
14455 struct cmd_vf_tc_bw_result *res = parsed_result;
14456 int ret = -ENOTSUP;
14458 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14461 #ifdef RTE_NET_I40E
14462 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14469 fprintf(stderr, "invalid tc_bitmap 0x%x\n", res->tc_map);
14472 fprintf(stderr, "invalid port_id %d\n", res->port_id);
14475 fprintf(stderr, "function not implemented\n");
14478 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
14482 static cmdline_parse_inst_t cmd_strict_link_prio = {
14483 .f = cmd_strict_link_prio_parsed,
14485 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14487 (void *)&cmd_vf_tc_bw_set,
14488 (void *)&cmd_vf_tc_bw_tx,
14489 (void *)&cmd_vf_tc_bw_strict_link_prio,
14490 (void *)&cmd_vf_tc_bw_port_id,
14491 (void *)&cmd_vf_tc_bw_tc_map,
14496 /* Load dynamic device personalization*/
14497 struct cmd_ddp_add_result {
14498 cmdline_fixed_string_t ddp;
14499 cmdline_fixed_string_t add;
14504 static cmdline_parse_token_string_t cmd_ddp_add_ddp =
14505 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14506 static cmdline_parse_token_string_t cmd_ddp_add_add =
14507 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14508 static cmdline_parse_token_num_t cmd_ddp_add_port_id =
14509 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
14511 static cmdline_parse_token_string_t cmd_ddp_add_filepath =
14512 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14515 cmd_ddp_add_parsed(
14516 void *parsed_result,
14517 __rte_unused struct cmdline *cl,
14518 __rte_unused void *data)
14520 struct cmd_ddp_add_result *res = parsed_result;
14526 int ret = -ENOTSUP;
14528 if (!all_ports_stopped()) {
14529 fprintf(stderr, "Please stop all ports first\n");
14533 filepath = strdup(res->filepath);
14534 if (filepath == NULL) {
14535 fprintf(stderr, "Failed to allocate memory\n");
14538 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14540 buff = open_file(file_fld[0], &size);
14542 free((void *)filepath);
14546 #ifdef RTE_NET_I40E
14547 if (ret == -ENOTSUP)
14548 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14550 RTE_PMD_I40E_PKG_OP_WR_ADD);
14553 if (ret == -EEXIST)
14554 fprintf(stderr, "Profile has already existed.\n");
14556 fprintf(stderr, "Failed to load profile.\n");
14557 else if (file_num == 2)
14558 save_file(file_fld[1], buff, size);
14561 free((void *)filepath);
14564 static cmdline_parse_inst_t cmd_ddp_add = {
14565 .f = cmd_ddp_add_parsed,
14567 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14569 (void *)&cmd_ddp_add_ddp,
14570 (void *)&cmd_ddp_add_add,
14571 (void *)&cmd_ddp_add_port_id,
14572 (void *)&cmd_ddp_add_filepath,
14577 /* Delete dynamic device personalization*/
14578 struct cmd_ddp_del_result {
14579 cmdline_fixed_string_t ddp;
14580 cmdline_fixed_string_t del;
14585 static cmdline_parse_token_string_t cmd_ddp_del_ddp =
14586 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14587 static cmdline_parse_token_string_t cmd_ddp_del_del =
14588 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14589 static cmdline_parse_token_num_t cmd_ddp_del_port_id =
14590 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
14591 static cmdline_parse_token_string_t cmd_ddp_del_filepath =
14592 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14595 cmd_ddp_del_parsed(
14596 void *parsed_result,
14597 __rte_unused struct cmdline *cl,
14598 __rte_unused void *data)
14600 struct cmd_ddp_del_result *res = parsed_result;
14603 int ret = -ENOTSUP;
14605 if (!all_ports_stopped()) {
14606 fprintf(stderr, "Please stop all ports first\n");
14610 buff = open_file(res->filepath, &size);
14614 #ifdef RTE_NET_I40E
14615 if (ret == -ENOTSUP)
14616 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14618 RTE_PMD_I40E_PKG_OP_WR_DEL);
14621 if (ret == -EACCES)
14622 fprintf(stderr, "Profile does not exist.\n");
14624 fprintf(stderr, "Failed to delete profile.\n");
14629 static cmdline_parse_inst_t cmd_ddp_del = {
14630 .f = cmd_ddp_del_parsed,
14632 .help_str = "ddp del <port_id> <backup_profile_path>",
14634 (void *)&cmd_ddp_del_ddp,
14635 (void *)&cmd_ddp_del_del,
14636 (void *)&cmd_ddp_del_port_id,
14637 (void *)&cmd_ddp_del_filepath,
14642 /* Get dynamic device personalization profile info */
14643 struct cmd_ddp_info_result {
14644 cmdline_fixed_string_t ddp;
14645 cmdline_fixed_string_t get;
14646 cmdline_fixed_string_t info;
14650 static cmdline_parse_token_string_t cmd_ddp_info_ddp =
14651 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14652 static cmdline_parse_token_string_t cmd_ddp_info_get =
14653 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14654 static cmdline_parse_token_string_t cmd_ddp_info_info =
14655 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14656 static cmdline_parse_token_string_t cmd_ddp_info_filepath =
14657 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14660 cmd_ddp_info_parsed(
14661 void *parsed_result,
14662 __rte_unused struct cmdline *cl,
14663 __rte_unused void *data)
14665 struct cmd_ddp_info_result *res = parsed_result;
14668 int ret = -ENOTSUP;
14669 #ifdef RTE_NET_I40E
14672 uint32_t buff_size = 0;
14673 struct rte_pmd_i40e_profile_info info;
14674 uint32_t dev_num = 0;
14675 struct rte_pmd_i40e_ddp_device_id *devs;
14676 uint32_t proto_num = 0;
14677 struct rte_pmd_i40e_proto_info *proto = NULL;
14678 uint32_t pctype_num = 0;
14679 struct rte_pmd_i40e_ptype_info *pctype;
14680 uint32_t ptype_num = 0;
14681 struct rte_pmd_i40e_ptype_info *ptype;
14686 pkg = open_file(res->filepath, &pkg_size);
14690 #ifdef RTE_NET_I40E
14691 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14692 (uint8_t *)&info, sizeof(info),
14693 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14695 printf("Global Track id: 0x%x\n", info.track_id);
14696 printf("Global Version: %d.%d.%d.%d\n",
14697 info.version.major,
14698 info.version.minor,
14699 info.version.update,
14700 info.version.draft);
14701 printf("Global Package name: %s\n\n", info.name);
14704 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14705 (uint8_t *)&info, sizeof(info),
14706 RTE_PMD_I40E_PKG_INFO_HEADER);
14708 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14709 printf("i40e Profile Version: %d.%d.%d.%d\n",
14710 info.version.major,
14711 info.version.minor,
14712 info.version.update,
14713 info.version.draft);
14714 printf("i40e Profile name: %s\n\n", info.name);
14717 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14718 (uint8_t *)&buff_size, sizeof(buff_size),
14719 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14720 if (!ret && buff_size) {
14721 buff = (uint8_t *)malloc(buff_size);
14723 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14725 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14727 printf("Package Notes:\n%s\n\n", buff);
14732 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14733 (uint8_t *)&dev_num, sizeof(dev_num),
14734 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14735 if (!ret && dev_num) {
14736 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14737 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14739 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14740 (uint8_t *)devs, buff_size,
14741 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14743 printf("List of supported devices:\n");
14744 for (i = 0; i < dev_num; i++) {
14745 printf(" %04X:%04X %04X:%04X\n",
14746 devs[i].vendor_dev_id >> 16,
14747 devs[i].vendor_dev_id & 0xFFFF,
14748 devs[i].sub_vendor_dev_id >> 16,
14749 devs[i].sub_vendor_dev_id & 0xFFFF);
14757 /* get information about protocols and packet types */
14758 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14759 (uint8_t *)&proto_num, sizeof(proto_num),
14760 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14761 if (ret || !proto_num)
14762 goto no_print_return;
14764 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14765 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14767 goto no_print_return;
14769 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14771 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14773 printf("List of used protocols:\n");
14774 for (i = 0; i < proto_num; i++)
14775 printf(" %2u: %s\n", proto[i].proto_id,
14779 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14780 (uint8_t *)&pctype_num, sizeof(pctype_num),
14781 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14782 if (ret || !pctype_num)
14783 goto no_print_pctypes;
14785 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14786 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14788 goto no_print_pctypes;
14790 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14792 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14795 goto no_print_pctypes;
14798 printf("List of defined packet classification types:\n");
14799 for (i = 0; i < pctype_num; i++) {
14800 printf(" %2u:", pctype[i].ptype_id);
14801 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14802 proto_id = pctype[i].protocols[j];
14803 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14804 for (n = 0; n < proto_num; n++) {
14805 if (proto[n].proto_id == proto_id) {
14806 printf(" %s", proto[n].name);
14819 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14821 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14822 if (ret || !ptype_num)
14823 goto no_print_return;
14825 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14826 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14828 goto no_print_return;
14830 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14832 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14835 goto no_print_return;
14837 printf("List of defined packet types:\n");
14838 for (i = 0; i < ptype_num; i++) {
14839 printf(" %2u:", ptype[i].ptype_id);
14840 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14841 proto_id = ptype[i].protocols[j];
14842 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14843 for (n = 0; n < proto_num; n++) {
14844 if (proto[n].proto_id == proto_id) {
14845 printf(" %s", proto[n].name);
14860 if (ret == -ENOTSUP)
14861 fprintf(stderr, "Function not supported in PMD\n");
14865 static cmdline_parse_inst_t cmd_ddp_get_info = {
14866 .f = cmd_ddp_info_parsed,
14868 .help_str = "ddp get info <profile_path>",
14870 (void *)&cmd_ddp_info_ddp,
14871 (void *)&cmd_ddp_info_get,
14872 (void *)&cmd_ddp_info_info,
14873 (void *)&cmd_ddp_info_filepath,
14878 /* Get dynamic device personalization profile info list*/
14879 #define PROFILE_INFO_SIZE 48
14880 #define MAX_PROFILE_NUM 16
14882 struct cmd_ddp_get_list_result {
14883 cmdline_fixed_string_t ddp;
14884 cmdline_fixed_string_t get;
14885 cmdline_fixed_string_t list;
14889 static cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14890 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14891 static cmdline_parse_token_string_t cmd_ddp_get_list_get =
14892 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14893 static cmdline_parse_token_string_t cmd_ddp_get_list_list =
14894 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14895 static cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14896 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14900 cmd_ddp_get_list_parsed(
14901 __rte_unused void *parsed_result,
14902 __rte_unused struct cmdline *cl,
14903 __rte_unused void *data)
14905 #ifdef RTE_NET_I40E
14906 struct cmd_ddp_get_list_result *res = parsed_result;
14907 struct rte_pmd_i40e_profile_list *p_list;
14908 struct rte_pmd_i40e_profile_info *p_info;
14913 int ret = -ENOTSUP;
14915 #ifdef RTE_NET_I40E
14916 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14917 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14919 fprintf(stderr, "%s: Failed to malloc buffer\n", __func__);
14923 if (ret == -ENOTSUP)
14924 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14925 (uint8_t *)p_list, size);
14928 p_num = p_list->p_count;
14929 printf("Profile number is: %d\n\n", p_num);
14931 for (i = 0; i < p_num; i++) {
14932 p_info = &p_list->p_info[i];
14933 printf("Profile %d:\n", i);
14934 printf("Track id: 0x%x\n", p_info->track_id);
14935 printf("Version: %d.%d.%d.%d\n",
14936 p_info->version.major,
14937 p_info->version.minor,
14938 p_info->version.update,
14939 p_info->version.draft);
14940 printf("Profile name: %s\n\n", p_info->name);
14948 fprintf(stderr, "Failed to get ddp list\n");
14951 static cmdline_parse_inst_t cmd_ddp_get_list = {
14952 .f = cmd_ddp_get_list_parsed,
14954 .help_str = "ddp get list <port_id>",
14956 (void *)&cmd_ddp_get_list_ddp,
14957 (void *)&cmd_ddp_get_list_get,
14958 (void *)&cmd_ddp_get_list_list,
14959 (void *)&cmd_ddp_get_list_port_id,
14964 /* Configure input set */
14965 struct cmd_cfg_input_set_result {
14966 cmdline_fixed_string_t port;
14967 cmdline_fixed_string_t cfg;
14969 cmdline_fixed_string_t pctype;
14971 cmdline_fixed_string_t inset_type;
14972 cmdline_fixed_string_t opt;
14973 cmdline_fixed_string_t field;
14978 cmd_cfg_input_set_parsed(
14979 __rte_unused void *parsed_result,
14980 __rte_unused struct cmdline *cl,
14981 __rte_unused void *data)
14983 #ifdef RTE_NET_I40E
14984 struct cmd_cfg_input_set_result *res = parsed_result;
14985 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14986 struct rte_pmd_i40e_inset inset;
14988 int ret = -ENOTSUP;
14990 if (!all_ports_stopped()) {
14991 fprintf(stderr, "Please stop all ports first\n");
14995 #ifdef RTE_NET_I40E
14996 if (!strcmp(res->inset_type, "hash_inset"))
14997 inset_type = INSET_HASH;
14998 else if (!strcmp(res->inset_type, "fdir_inset"))
14999 inset_type = INSET_FDIR;
15000 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15001 inset_type = INSET_FDIR_FLX;
15002 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
15003 &inset, inset_type);
15005 fprintf(stderr, "Failed to get input set.\n");
15009 if (!strcmp(res->opt, "get")) {
15010 ret = rte_pmd_i40e_inset_field_get(inset.inset,
15013 printf("Field index %d is enabled.\n", res->field_idx);
15015 printf("Field index %d is disabled.\n", res->field_idx);
15017 } else if (!strcmp(res->opt, "set"))
15018 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
15020 else if (!strcmp(res->opt, "clear"))
15021 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15024 fprintf(stderr, "Failed to configure input set field.\n");
15028 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15029 &inset, inset_type);
15031 fprintf(stderr, "Failed to set input set.\n");
15036 if (ret == -ENOTSUP)
15037 fprintf(stderr, "Function not supported\n");
15040 static cmdline_parse_token_string_t cmd_cfg_input_set_port =
15041 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15043 static cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15044 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15046 static cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15047 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15048 port_id, RTE_UINT16);
15049 static cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15050 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15052 static cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15053 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15054 pctype_id, RTE_UINT8);
15055 static cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15056 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15058 "hash_inset#fdir_inset#fdir_flx_inset");
15059 static cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15060 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15061 opt, "get#set#clear");
15062 static cmdline_parse_token_string_t cmd_cfg_input_set_field =
15063 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15065 static cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15066 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15067 field_idx, RTE_UINT8);
15069 static cmdline_parse_inst_t cmd_cfg_input_set = {
15070 .f = cmd_cfg_input_set_parsed,
15072 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15073 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15075 (void *)&cmd_cfg_input_set_port,
15076 (void *)&cmd_cfg_input_set_cfg,
15077 (void *)&cmd_cfg_input_set_port_id,
15078 (void *)&cmd_cfg_input_set_pctype,
15079 (void *)&cmd_cfg_input_set_pctype_id,
15080 (void *)&cmd_cfg_input_set_inset_type,
15081 (void *)&cmd_cfg_input_set_opt,
15082 (void *)&cmd_cfg_input_set_field,
15083 (void *)&cmd_cfg_input_set_field_idx,
15088 /* Clear input set */
15089 struct cmd_clear_input_set_result {
15090 cmdline_fixed_string_t port;
15091 cmdline_fixed_string_t cfg;
15093 cmdline_fixed_string_t pctype;
15095 cmdline_fixed_string_t inset_type;
15096 cmdline_fixed_string_t clear;
15097 cmdline_fixed_string_t all;
15101 cmd_clear_input_set_parsed(
15102 __rte_unused void *parsed_result,
15103 __rte_unused struct cmdline *cl,
15104 __rte_unused void *data)
15106 #ifdef RTE_NET_I40E
15107 struct cmd_clear_input_set_result *res = parsed_result;
15108 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15109 struct rte_pmd_i40e_inset inset;
15111 int ret = -ENOTSUP;
15113 if (!all_ports_stopped()) {
15114 fprintf(stderr, "Please stop all ports first\n");
15118 #ifdef RTE_NET_I40E
15119 if (!strcmp(res->inset_type, "hash_inset"))
15120 inset_type = INSET_HASH;
15121 else if (!strcmp(res->inset_type, "fdir_inset"))
15122 inset_type = INSET_FDIR;
15123 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15124 inset_type = INSET_FDIR_FLX;
15126 memset(&inset, 0, sizeof(inset));
15128 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15129 &inset, inset_type);
15131 fprintf(stderr, "Failed to clear input set.\n");
15137 if (ret == -ENOTSUP)
15138 fprintf(stderr, "Function not supported\n");
15141 static cmdline_parse_token_string_t cmd_clear_input_set_port =
15142 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15144 static cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15145 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15147 static cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15148 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15149 port_id, RTE_UINT16);
15150 static cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15151 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15153 static cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15154 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15155 pctype_id, RTE_UINT8);
15156 static cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15157 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15159 "hash_inset#fdir_inset#fdir_flx_inset");
15160 static cmdline_parse_token_string_t cmd_clear_input_set_clear =
15161 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15163 static cmdline_parse_token_string_t cmd_clear_input_set_all =
15164 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15167 static cmdline_parse_inst_t cmd_clear_input_set = {
15168 .f = cmd_clear_input_set_parsed,
15170 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15171 "fdir_inset|fdir_flx_inset clear all",
15173 (void *)&cmd_clear_input_set_port,
15174 (void *)&cmd_clear_input_set_cfg,
15175 (void *)&cmd_clear_input_set_port_id,
15176 (void *)&cmd_clear_input_set_pctype,
15177 (void *)&cmd_clear_input_set_pctype_id,
15178 (void *)&cmd_clear_input_set_inset_type,
15179 (void *)&cmd_clear_input_set_clear,
15180 (void *)&cmd_clear_input_set_all,
15185 /* show vf stats */
15187 /* Common result structure for show vf stats */
15188 struct cmd_show_vf_stats_result {
15189 cmdline_fixed_string_t show;
15190 cmdline_fixed_string_t vf;
15191 cmdline_fixed_string_t stats;
15196 /* Common CLI fields show vf stats*/
15197 static cmdline_parse_token_string_t cmd_show_vf_stats_show =
15198 TOKEN_STRING_INITIALIZER
15199 (struct cmd_show_vf_stats_result,
15201 static cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15202 TOKEN_STRING_INITIALIZER
15203 (struct cmd_show_vf_stats_result,
15205 static cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15206 TOKEN_STRING_INITIALIZER
15207 (struct cmd_show_vf_stats_result,
15209 static cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15210 TOKEN_NUM_INITIALIZER
15211 (struct cmd_show_vf_stats_result,
15212 port_id, RTE_UINT16);
15213 static cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15214 TOKEN_NUM_INITIALIZER
15215 (struct cmd_show_vf_stats_result,
15216 vf_id, RTE_UINT16);
15219 cmd_show_vf_stats_parsed(
15220 void *parsed_result,
15221 __rte_unused struct cmdline *cl,
15222 __rte_unused void *data)
15224 struct cmd_show_vf_stats_result *res = parsed_result;
15225 struct rte_eth_stats stats;
15226 int ret = -ENOTSUP;
15227 static const char *nic_stats_border = "########################";
15229 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15232 memset(&stats, 0, sizeof(stats));
15234 #ifdef RTE_NET_I40E
15235 if (ret == -ENOTSUP)
15236 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15240 #ifdef RTE_NET_BNXT
15241 if (ret == -ENOTSUP)
15242 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15251 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15254 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15257 fprintf(stderr, "function not implemented\n");
15260 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15263 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15264 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15266 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15268 stats.ipackets, stats.imissed, stats.ibytes);
15269 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15270 printf(" RX-nombuf: %-10"PRIu64"\n",
15272 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15274 stats.opackets, stats.oerrors, stats.obytes);
15276 printf(" %s############################%s\n",
15277 nic_stats_border, nic_stats_border);
15280 static cmdline_parse_inst_t cmd_show_vf_stats = {
15281 .f = cmd_show_vf_stats_parsed,
15283 .help_str = "show vf stats <port_id> <vf_id>",
15285 (void *)&cmd_show_vf_stats_show,
15286 (void *)&cmd_show_vf_stats_vf,
15287 (void *)&cmd_show_vf_stats_stats,
15288 (void *)&cmd_show_vf_stats_port_id,
15289 (void *)&cmd_show_vf_stats_vf_id,
15294 /* clear vf stats */
15296 /* Common result structure for clear vf stats */
15297 struct cmd_clear_vf_stats_result {
15298 cmdline_fixed_string_t clear;
15299 cmdline_fixed_string_t vf;
15300 cmdline_fixed_string_t stats;
15305 /* Common CLI fields clear vf stats*/
15306 static cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15307 TOKEN_STRING_INITIALIZER
15308 (struct cmd_clear_vf_stats_result,
15310 static cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15311 TOKEN_STRING_INITIALIZER
15312 (struct cmd_clear_vf_stats_result,
15314 static cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15315 TOKEN_STRING_INITIALIZER
15316 (struct cmd_clear_vf_stats_result,
15318 static cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15319 TOKEN_NUM_INITIALIZER
15320 (struct cmd_clear_vf_stats_result,
15321 port_id, RTE_UINT16);
15322 static cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15323 TOKEN_NUM_INITIALIZER
15324 (struct cmd_clear_vf_stats_result,
15325 vf_id, RTE_UINT16);
15328 cmd_clear_vf_stats_parsed(
15329 void *parsed_result,
15330 __rte_unused struct cmdline *cl,
15331 __rte_unused void *data)
15333 struct cmd_clear_vf_stats_result *res = parsed_result;
15334 int ret = -ENOTSUP;
15336 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15339 #ifdef RTE_NET_I40E
15340 if (ret == -ENOTSUP)
15341 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15344 #ifdef RTE_NET_BNXT
15345 if (ret == -ENOTSUP)
15346 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15354 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15357 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15360 fprintf(stderr, "function not implemented\n");
15363 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15367 static cmdline_parse_inst_t cmd_clear_vf_stats = {
15368 .f = cmd_clear_vf_stats_parsed,
15370 .help_str = "clear vf stats <port_id> <vf_id>",
15372 (void *)&cmd_clear_vf_stats_clear,
15373 (void *)&cmd_clear_vf_stats_vf,
15374 (void *)&cmd_clear_vf_stats_stats,
15375 (void *)&cmd_clear_vf_stats_port_id,
15376 (void *)&cmd_clear_vf_stats_vf_id,
15381 /* port config pctype mapping reset */
15383 /* Common result structure for port config pctype mapping reset */
15384 struct cmd_pctype_mapping_reset_result {
15385 cmdline_fixed_string_t port;
15386 cmdline_fixed_string_t config;
15388 cmdline_fixed_string_t pctype;
15389 cmdline_fixed_string_t mapping;
15390 cmdline_fixed_string_t reset;
15393 /* Common CLI fields for port config pctype mapping reset*/
15394 static cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15395 TOKEN_STRING_INITIALIZER
15396 (struct cmd_pctype_mapping_reset_result,
15398 static cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15399 TOKEN_STRING_INITIALIZER
15400 (struct cmd_pctype_mapping_reset_result,
15402 static cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15403 TOKEN_NUM_INITIALIZER
15404 (struct cmd_pctype_mapping_reset_result,
15405 port_id, RTE_UINT16);
15406 static cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15407 TOKEN_STRING_INITIALIZER
15408 (struct cmd_pctype_mapping_reset_result,
15410 static cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15411 TOKEN_STRING_INITIALIZER
15412 (struct cmd_pctype_mapping_reset_result,
15413 mapping, "mapping");
15414 static cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15415 TOKEN_STRING_INITIALIZER
15416 (struct cmd_pctype_mapping_reset_result,
15420 cmd_pctype_mapping_reset_parsed(
15421 void *parsed_result,
15422 __rte_unused struct cmdline *cl,
15423 __rte_unused void *data)
15425 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15426 int ret = -ENOTSUP;
15428 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15431 #ifdef RTE_NET_I40E
15432 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15439 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15442 fprintf(stderr, "function not implemented\n");
15445 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15449 static cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15450 .f = cmd_pctype_mapping_reset_parsed,
15452 .help_str = "port config <port_id> pctype mapping reset",
15454 (void *)&cmd_pctype_mapping_reset_port,
15455 (void *)&cmd_pctype_mapping_reset_config,
15456 (void *)&cmd_pctype_mapping_reset_port_id,
15457 (void *)&cmd_pctype_mapping_reset_pctype,
15458 (void *)&cmd_pctype_mapping_reset_mapping,
15459 (void *)&cmd_pctype_mapping_reset_reset,
15464 /* show port pctype mapping */
15466 /* Common result structure for show port pctype mapping */
15467 struct cmd_pctype_mapping_get_result {
15468 cmdline_fixed_string_t show;
15469 cmdline_fixed_string_t port;
15471 cmdline_fixed_string_t pctype;
15472 cmdline_fixed_string_t mapping;
15475 /* Common CLI fields for pctype mapping get */
15476 static cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15477 TOKEN_STRING_INITIALIZER
15478 (struct cmd_pctype_mapping_get_result,
15480 static cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15481 TOKEN_STRING_INITIALIZER
15482 (struct cmd_pctype_mapping_get_result,
15484 static cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15485 TOKEN_NUM_INITIALIZER
15486 (struct cmd_pctype_mapping_get_result,
15487 port_id, RTE_UINT16);
15488 static cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15489 TOKEN_STRING_INITIALIZER
15490 (struct cmd_pctype_mapping_get_result,
15492 static cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15493 TOKEN_STRING_INITIALIZER
15494 (struct cmd_pctype_mapping_get_result,
15495 mapping, "mapping");
15498 cmd_pctype_mapping_get_parsed(
15499 void *parsed_result,
15500 __rte_unused struct cmdline *cl,
15501 __rte_unused void *data)
15503 struct cmd_pctype_mapping_get_result *res = parsed_result;
15504 int ret = -ENOTSUP;
15505 #ifdef RTE_NET_I40E
15506 struct rte_pmd_i40e_flow_type_mapping
15507 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15508 int i, j, first_pctype;
15511 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15514 #ifdef RTE_NET_I40E
15515 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15522 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15525 fprintf(stderr, "function not implemented\n");
15528 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15532 #ifdef RTE_NET_I40E
15533 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15534 if (mapping[i].pctype != 0ULL) {
15537 printf("pctype: ");
15538 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15539 if (mapping[i].pctype & (1ULL << j)) {
15540 printf(first_pctype ?
15541 "%02d" : ",%02d", j);
15545 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15551 static cmdline_parse_inst_t cmd_pctype_mapping_get = {
15552 .f = cmd_pctype_mapping_get_parsed,
15554 .help_str = "show port <port_id> pctype mapping",
15556 (void *)&cmd_pctype_mapping_get_show,
15557 (void *)&cmd_pctype_mapping_get_port,
15558 (void *)&cmd_pctype_mapping_get_port_id,
15559 (void *)&cmd_pctype_mapping_get_pctype,
15560 (void *)&cmd_pctype_mapping_get_mapping,
15565 /* port config pctype mapping update */
15567 /* Common result structure for port config pctype mapping update */
15568 struct cmd_pctype_mapping_update_result {
15569 cmdline_fixed_string_t port;
15570 cmdline_fixed_string_t config;
15572 cmdline_fixed_string_t pctype;
15573 cmdline_fixed_string_t mapping;
15574 cmdline_fixed_string_t update;
15575 cmdline_fixed_string_t pctype_list;
15576 uint16_t flow_type;
15579 /* Common CLI fields for pctype mapping update*/
15580 static cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15581 TOKEN_STRING_INITIALIZER
15582 (struct cmd_pctype_mapping_update_result,
15584 static cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15585 TOKEN_STRING_INITIALIZER
15586 (struct cmd_pctype_mapping_update_result,
15588 static cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15589 TOKEN_NUM_INITIALIZER
15590 (struct cmd_pctype_mapping_update_result,
15591 port_id, RTE_UINT16);
15592 static cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15593 TOKEN_STRING_INITIALIZER
15594 (struct cmd_pctype_mapping_update_result,
15596 static cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15597 TOKEN_STRING_INITIALIZER
15598 (struct cmd_pctype_mapping_update_result,
15599 mapping, "mapping");
15600 static cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15601 TOKEN_STRING_INITIALIZER
15602 (struct cmd_pctype_mapping_update_result,
15604 static cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15605 TOKEN_STRING_INITIALIZER
15606 (struct cmd_pctype_mapping_update_result,
15607 pctype_list, NULL);
15608 static cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15609 TOKEN_NUM_INITIALIZER
15610 (struct cmd_pctype_mapping_update_result,
15611 flow_type, RTE_UINT16);
15614 cmd_pctype_mapping_update_parsed(
15615 void *parsed_result,
15616 __rte_unused struct cmdline *cl,
15617 __rte_unused void *data)
15619 struct cmd_pctype_mapping_update_result *res = parsed_result;
15620 int ret = -ENOTSUP;
15621 #ifdef RTE_NET_I40E
15622 struct rte_pmd_i40e_flow_type_mapping mapping;
15624 unsigned int nb_item;
15625 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15628 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15631 #ifdef RTE_NET_I40E
15632 nb_item = parse_item_list(res->pctype_list, "pctypes",
15633 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15634 mapping.flow_type = res->flow_type;
15635 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15636 mapping.pctype |= (1ULL << pctype_list[i]);
15637 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15647 fprintf(stderr, "invalid pctype or flow type\n");
15650 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15653 fprintf(stderr, "function not implemented\n");
15656 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15660 static cmdline_parse_inst_t cmd_pctype_mapping_update = {
15661 .f = cmd_pctype_mapping_update_parsed,
15663 .help_str = "port config <port_id> pctype mapping update"
15664 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15666 (void *)&cmd_pctype_mapping_update_port,
15667 (void *)&cmd_pctype_mapping_update_config,
15668 (void *)&cmd_pctype_mapping_update_port_id,
15669 (void *)&cmd_pctype_mapping_update_pctype,
15670 (void *)&cmd_pctype_mapping_update_mapping,
15671 (void *)&cmd_pctype_mapping_update_update,
15672 (void *)&cmd_pctype_mapping_update_pc_type,
15673 (void *)&cmd_pctype_mapping_update_flow_type,
15678 /* ptype mapping get */
15680 /* Common result structure for ptype mapping get */
15681 struct cmd_ptype_mapping_get_result {
15682 cmdline_fixed_string_t ptype;
15683 cmdline_fixed_string_t mapping;
15684 cmdline_fixed_string_t get;
15686 uint8_t valid_only;
15689 /* Common CLI fields for ptype mapping get */
15690 static cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15691 TOKEN_STRING_INITIALIZER
15692 (struct cmd_ptype_mapping_get_result,
15694 static cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15695 TOKEN_STRING_INITIALIZER
15696 (struct cmd_ptype_mapping_get_result,
15697 mapping, "mapping");
15698 static cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15699 TOKEN_STRING_INITIALIZER
15700 (struct cmd_ptype_mapping_get_result,
15702 static cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15703 TOKEN_NUM_INITIALIZER
15704 (struct cmd_ptype_mapping_get_result,
15705 port_id, RTE_UINT16);
15706 static cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15707 TOKEN_NUM_INITIALIZER
15708 (struct cmd_ptype_mapping_get_result,
15709 valid_only, RTE_UINT8);
15712 cmd_ptype_mapping_get_parsed(
15713 void *parsed_result,
15714 __rte_unused struct cmdline *cl,
15715 __rte_unused void *data)
15717 struct cmd_ptype_mapping_get_result *res = parsed_result;
15718 int ret = -ENOTSUP;
15719 #ifdef RTE_NET_I40E
15720 int max_ptype_num = 256;
15721 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15726 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15729 #ifdef RTE_NET_I40E
15730 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15741 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15744 fprintf(stderr, "function not implemented\n");
15747 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15750 #ifdef RTE_NET_I40E
15752 for (i = 0; i < count; i++)
15753 printf("%3d\t0x%08x\n",
15754 mapping[i].hw_ptype, mapping[i].sw_ptype);
15759 static cmdline_parse_inst_t cmd_ptype_mapping_get = {
15760 .f = cmd_ptype_mapping_get_parsed,
15762 .help_str = "ptype mapping get <port_id> <valid_only>",
15764 (void *)&cmd_ptype_mapping_get_ptype,
15765 (void *)&cmd_ptype_mapping_get_mapping,
15766 (void *)&cmd_ptype_mapping_get_get,
15767 (void *)&cmd_ptype_mapping_get_port_id,
15768 (void *)&cmd_ptype_mapping_get_valid_only,
15773 /* ptype mapping replace */
15775 /* Common result structure for ptype mapping replace */
15776 struct cmd_ptype_mapping_replace_result {
15777 cmdline_fixed_string_t ptype;
15778 cmdline_fixed_string_t mapping;
15779 cmdline_fixed_string_t replace;
15786 /* Common CLI fields for ptype mapping replace */
15787 static cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15788 TOKEN_STRING_INITIALIZER
15789 (struct cmd_ptype_mapping_replace_result,
15791 static cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15792 TOKEN_STRING_INITIALIZER
15793 (struct cmd_ptype_mapping_replace_result,
15794 mapping, "mapping");
15795 static cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15796 TOKEN_STRING_INITIALIZER
15797 (struct cmd_ptype_mapping_replace_result,
15798 replace, "replace");
15799 static cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15800 TOKEN_NUM_INITIALIZER
15801 (struct cmd_ptype_mapping_replace_result,
15802 port_id, RTE_UINT16);
15803 static cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15804 TOKEN_NUM_INITIALIZER
15805 (struct cmd_ptype_mapping_replace_result,
15806 target, RTE_UINT32);
15807 static cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15808 TOKEN_NUM_INITIALIZER
15809 (struct cmd_ptype_mapping_replace_result,
15811 static cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15812 TOKEN_NUM_INITIALIZER
15813 (struct cmd_ptype_mapping_replace_result,
15814 pkt_type, RTE_UINT32);
15817 cmd_ptype_mapping_replace_parsed(
15818 void *parsed_result,
15819 __rte_unused struct cmdline *cl,
15820 __rte_unused void *data)
15822 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15823 int ret = -ENOTSUP;
15825 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15828 #ifdef RTE_NET_I40E
15829 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15839 fprintf(stderr, "invalid ptype 0x%8x or 0x%8x\n",
15840 res->target, res->pkt_type);
15843 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15846 fprintf(stderr, "function not implemented\n");
15849 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15853 static cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15854 .f = cmd_ptype_mapping_replace_parsed,
15857 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15859 (void *)&cmd_ptype_mapping_replace_ptype,
15860 (void *)&cmd_ptype_mapping_replace_mapping,
15861 (void *)&cmd_ptype_mapping_replace_replace,
15862 (void *)&cmd_ptype_mapping_replace_port_id,
15863 (void *)&cmd_ptype_mapping_replace_target,
15864 (void *)&cmd_ptype_mapping_replace_mask,
15865 (void *)&cmd_ptype_mapping_replace_pkt_type,
15870 /* ptype mapping reset */
15872 /* Common result structure for ptype mapping reset */
15873 struct cmd_ptype_mapping_reset_result {
15874 cmdline_fixed_string_t ptype;
15875 cmdline_fixed_string_t mapping;
15876 cmdline_fixed_string_t reset;
15880 /* Common CLI fields for ptype mapping reset*/
15881 static cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15882 TOKEN_STRING_INITIALIZER
15883 (struct cmd_ptype_mapping_reset_result,
15885 static cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15886 TOKEN_STRING_INITIALIZER
15887 (struct cmd_ptype_mapping_reset_result,
15888 mapping, "mapping");
15889 static cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15890 TOKEN_STRING_INITIALIZER
15891 (struct cmd_ptype_mapping_reset_result,
15893 static cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15894 TOKEN_NUM_INITIALIZER
15895 (struct cmd_ptype_mapping_reset_result,
15896 port_id, RTE_UINT16);
15899 cmd_ptype_mapping_reset_parsed(
15900 void *parsed_result,
15901 __rte_unused struct cmdline *cl,
15902 __rte_unused void *data)
15904 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15905 int ret = -ENOTSUP;
15907 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15910 #ifdef RTE_NET_I40E
15911 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15918 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15921 fprintf(stderr, "function not implemented\n");
15924 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15928 static cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15929 .f = cmd_ptype_mapping_reset_parsed,
15931 .help_str = "ptype mapping reset <port_id>",
15933 (void *)&cmd_ptype_mapping_reset_ptype,
15934 (void *)&cmd_ptype_mapping_reset_mapping,
15935 (void *)&cmd_ptype_mapping_reset_reset,
15936 (void *)&cmd_ptype_mapping_reset_port_id,
15941 /* ptype mapping update */
15943 /* Common result structure for ptype mapping update */
15944 struct cmd_ptype_mapping_update_result {
15945 cmdline_fixed_string_t ptype;
15946 cmdline_fixed_string_t mapping;
15947 cmdline_fixed_string_t reset;
15953 /* Common CLI fields for ptype mapping update*/
15954 static cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15955 TOKEN_STRING_INITIALIZER
15956 (struct cmd_ptype_mapping_update_result,
15958 static cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15959 TOKEN_STRING_INITIALIZER
15960 (struct cmd_ptype_mapping_update_result,
15961 mapping, "mapping");
15962 static cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15963 TOKEN_STRING_INITIALIZER
15964 (struct cmd_ptype_mapping_update_result,
15966 static cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15967 TOKEN_NUM_INITIALIZER
15968 (struct cmd_ptype_mapping_update_result,
15969 port_id, RTE_UINT16);
15970 static cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15971 TOKEN_NUM_INITIALIZER
15972 (struct cmd_ptype_mapping_update_result,
15973 hw_ptype, RTE_UINT8);
15974 static cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15975 TOKEN_NUM_INITIALIZER
15976 (struct cmd_ptype_mapping_update_result,
15977 sw_ptype, RTE_UINT32);
15980 cmd_ptype_mapping_update_parsed(
15981 void *parsed_result,
15982 __rte_unused struct cmdline *cl,
15983 __rte_unused void *data)
15985 struct cmd_ptype_mapping_update_result *res = parsed_result;
15986 int ret = -ENOTSUP;
15987 #ifdef RTE_NET_I40E
15988 struct rte_pmd_i40e_ptype_mapping mapping;
15990 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15993 #ifdef RTE_NET_I40E
15994 mapping.hw_ptype = res->hw_ptype;
15995 mapping.sw_ptype = res->sw_ptype;
15996 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
16006 fprintf(stderr, "invalid ptype 0x%8x\n", res->sw_ptype);
16009 fprintf(stderr, "invalid port_id %d\n", res->port_id);
16012 fprintf(stderr, "function not implemented\n");
16015 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
16019 static cmdline_parse_inst_t cmd_ptype_mapping_update = {
16020 .f = cmd_ptype_mapping_update_parsed,
16022 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16024 (void *)&cmd_ptype_mapping_update_ptype,
16025 (void *)&cmd_ptype_mapping_update_mapping,
16026 (void *)&cmd_ptype_mapping_update_update,
16027 (void *)&cmd_ptype_mapping_update_port_id,
16028 (void *)&cmd_ptype_mapping_update_hw_ptype,
16029 (void *)&cmd_ptype_mapping_update_sw_ptype,
16034 /* Common result structure for file commands */
16035 struct cmd_cmdfile_result {
16036 cmdline_fixed_string_t load;
16037 cmdline_fixed_string_t filename;
16040 /* Common CLI fields for file commands */
16041 static cmdline_parse_token_string_t cmd_load_cmdfile =
16042 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16043 static cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16044 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16047 cmd_load_from_file_parsed(
16048 void *parsed_result,
16049 __rte_unused struct cmdline *cl,
16050 __rte_unused void *data)
16052 struct cmd_cmdfile_result *res = parsed_result;
16054 cmdline_read_from_file(res->filename);
16057 static cmdline_parse_inst_t cmd_load_from_file = {
16058 .f = cmd_load_from_file_parsed,
16060 .help_str = "load <filename>",
16062 (void *)&cmd_load_cmdfile,
16063 (void *)&cmd_load_cmdfile_filename,
16068 /* Get Rx offloads capabilities */
16069 struct cmd_rx_offload_get_capa_result {
16070 cmdline_fixed_string_t show;
16071 cmdline_fixed_string_t port;
16073 cmdline_fixed_string_t rx_offload;
16074 cmdline_fixed_string_t capabilities;
16077 static cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
16078 TOKEN_STRING_INITIALIZER
16079 (struct cmd_rx_offload_get_capa_result,
16081 static cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
16082 TOKEN_STRING_INITIALIZER
16083 (struct cmd_rx_offload_get_capa_result,
16085 static cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
16086 TOKEN_NUM_INITIALIZER
16087 (struct cmd_rx_offload_get_capa_result,
16088 port_id, RTE_UINT16);
16089 static cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
16090 TOKEN_STRING_INITIALIZER
16091 (struct cmd_rx_offload_get_capa_result,
16092 rx_offload, "rx_offload");
16093 static cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
16094 TOKEN_STRING_INITIALIZER
16095 (struct cmd_rx_offload_get_capa_result,
16096 capabilities, "capabilities");
16099 print_rx_offloads(uint64_t offloads)
16101 uint64_t single_offload;
16109 begin = __builtin_ctzll(offloads);
16110 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16112 single_offload = 1ULL << begin;
16113 for (bit = begin; bit < end; bit++) {
16114 if (offloads & single_offload)
16116 rte_eth_dev_rx_offload_name(single_offload));
16117 single_offload <<= 1;
16122 cmd_rx_offload_get_capa_parsed(
16123 void *parsed_result,
16124 __rte_unused struct cmdline *cl,
16125 __rte_unused void *data)
16127 struct cmd_rx_offload_get_capa_result *res = parsed_result;
16128 struct rte_eth_dev_info dev_info;
16129 portid_t port_id = res->port_id;
16130 uint64_t queue_offloads;
16131 uint64_t port_offloads;
16134 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16138 queue_offloads = dev_info.rx_queue_offload_capa;
16139 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
16141 printf("Rx Offloading Capabilities of port %d :\n", port_id);
16142 printf(" Per Queue :");
16143 print_rx_offloads(queue_offloads);
16146 printf(" Per Port :");
16147 print_rx_offloads(port_offloads);
16151 static cmdline_parse_inst_t cmd_rx_offload_get_capa = {
16152 .f = cmd_rx_offload_get_capa_parsed,
16154 .help_str = "show port <port_id> rx_offload capabilities",
16156 (void *)&cmd_rx_offload_get_capa_show,
16157 (void *)&cmd_rx_offload_get_capa_port,
16158 (void *)&cmd_rx_offload_get_capa_port_id,
16159 (void *)&cmd_rx_offload_get_capa_rx_offload,
16160 (void *)&cmd_rx_offload_get_capa_capabilities,
16165 /* Get Rx offloads configuration */
16166 struct cmd_rx_offload_get_configuration_result {
16167 cmdline_fixed_string_t show;
16168 cmdline_fixed_string_t port;
16170 cmdline_fixed_string_t rx_offload;
16171 cmdline_fixed_string_t configuration;
16174 static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
16175 TOKEN_STRING_INITIALIZER
16176 (struct cmd_rx_offload_get_configuration_result,
16178 static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
16179 TOKEN_STRING_INITIALIZER
16180 (struct cmd_rx_offload_get_configuration_result,
16182 static cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
16183 TOKEN_NUM_INITIALIZER
16184 (struct cmd_rx_offload_get_configuration_result,
16185 port_id, RTE_UINT16);
16186 static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
16187 TOKEN_STRING_INITIALIZER
16188 (struct cmd_rx_offload_get_configuration_result,
16189 rx_offload, "rx_offload");
16190 static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
16191 TOKEN_STRING_INITIALIZER
16192 (struct cmd_rx_offload_get_configuration_result,
16193 configuration, "configuration");
16196 cmd_rx_offload_get_configuration_parsed(
16197 void *parsed_result,
16198 __rte_unused struct cmdline *cl,
16199 __rte_unused void *data)
16201 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
16202 struct rte_eth_dev_info dev_info;
16203 portid_t port_id = res->port_id;
16204 struct rte_port *port = &ports[port_id];
16205 struct rte_eth_conf dev_conf;
16206 uint64_t port_offloads;
16207 uint64_t queue_offloads;
16208 uint16_t nb_rx_queues;
16212 printf("Rx Offloading Configuration of port %d :\n", port_id);
16214 ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
16218 port_offloads = dev_conf.rxmode.offloads;
16220 print_rx_offloads(port_offloads);
16223 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16227 nb_rx_queues = dev_info.nb_rx_queues;
16228 for (q = 0; q < nb_rx_queues; q++) {
16229 queue_offloads = port->rxq[q].conf.offloads;
16230 printf(" Queue[%2d] :", q);
16231 print_rx_offloads(queue_offloads);
16237 static cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
16238 .f = cmd_rx_offload_get_configuration_parsed,
16240 .help_str = "show port <port_id> rx_offload configuration",
16242 (void *)&cmd_rx_offload_get_configuration_show,
16243 (void *)&cmd_rx_offload_get_configuration_port,
16244 (void *)&cmd_rx_offload_get_configuration_port_id,
16245 (void *)&cmd_rx_offload_get_configuration_rx_offload,
16246 (void *)&cmd_rx_offload_get_configuration_configuration,
16251 /* Enable/Disable a per port offloading */
16252 struct cmd_config_per_port_rx_offload_result {
16253 cmdline_fixed_string_t port;
16254 cmdline_fixed_string_t config;
16256 cmdline_fixed_string_t rx_offload;
16257 cmdline_fixed_string_t offload;
16258 cmdline_fixed_string_t on_off;
16261 static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
16262 TOKEN_STRING_INITIALIZER
16263 (struct cmd_config_per_port_rx_offload_result,
16265 static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
16266 TOKEN_STRING_INITIALIZER
16267 (struct cmd_config_per_port_rx_offload_result,
16269 static cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
16270 TOKEN_NUM_INITIALIZER
16271 (struct cmd_config_per_port_rx_offload_result,
16272 port_id, RTE_UINT16);
16273 static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
16274 TOKEN_STRING_INITIALIZER
16275 (struct cmd_config_per_port_rx_offload_result,
16276 rx_offload, "rx_offload");
16277 static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
16278 TOKEN_STRING_INITIALIZER
16279 (struct cmd_config_per_port_rx_offload_result,
16280 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16281 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16282 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16283 "scatter#buffer_split#timestamp#security#"
16284 "keep_crc#rss_hash");
16285 static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
16286 TOKEN_STRING_INITIALIZER
16287 (struct cmd_config_per_port_rx_offload_result,
16291 search_rx_offload(const char *name)
16293 uint64_t single_offload;
16294 const char *single_name;
16298 single_offload = 1;
16299 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16300 single_name = rte_eth_dev_rx_offload_name(single_offload);
16301 if (!strcasecmp(single_name, name)) {
16305 single_offload <<= 1;
16309 return single_offload;
16315 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16316 __rte_unused struct cmdline *cl,
16317 __rte_unused void *data)
16319 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16320 portid_t port_id = res->port_id;
16321 struct rte_eth_dev_info dev_info;
16322 struct rte_port *port = &ports[port_id];
16323 uint64_t single_offload;
16324 uint16_t nb_rx_queues;
16328 if (port->port_status != RTE_PORT_STOPPED) {
16330 "Error: Can't config offload when Port %d is not stopped\n",
16335 single_offload = search_rx_offload(res->offload);
16336 if (single_offload == 0) {
16337 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16341 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16345 nb_rx_queues = dev_info.nb_rx_queues;
16346 if (!strcmp(res->on_off, "on")) {
16347 port->dev_conf.rxmode.offloads |= single_offload;
16348 for (q = 0; q < nb_rx_queues; q++)
16349 port->rxq[q].conf.offloads |= single_offload;
16351 port->dev_conf.rxmode.offloads &= ~single_offload;
16352 for (q = 0; q < nb_rx_queues; q++)
16353 port->rxq[q].conf.offloads &= ~single_offload;
16356 cmd_reconfig_device_queue(port_id, 1, 1);
16359 static cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16360 .f = cmd_config_per_port_rx_offload_parsed,
16362 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16363 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16364 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16365 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16366 "keep_crc|rss_hash on|off",
16368 (void *)&cmd_config_per_port_rx_offload_result_port,
16369 (void *)&cmd_config_per_port_rx_offload_result_config,
16370 (void *)&cmd_config_per_port_rx_offload_result_port_id,
16371 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16372 (void *)&cmd_config_per_port_rx_offload_result_offload,
16373 (void *)&cmd_config_per_port_rx_offload_result_on_off,
16378 /* Enable/Disable a per queue offloading */
16379 struct cmd_config_per_queue_rx_offload_result {
16380 cmdline_fixed_string_t port;
16382 cmdline_fixed_string_t rxq;
16384 cmdline_fixed_string_t rx_offload;
16385 cmdline_fixed_string_t offload;
16386 cmdline_fixed_string_t on_off;
16389 static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16390 TOKEN_STRING_INITIALIZER
16391 (struct cmd_config_per_queue_rx_offload_result,
16393 static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16394 TOKEN_NUM_INITIALIZER
16395 (struct cmd_config_per_queue_rx_offload_result,
16396 port_id, RTE_UINT16);
16397 static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16398 TOKEN_STRING_INITIALIZER
16399 (struct cmd_config_per_queue_rx_offload_result,
16401 static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16402 TOKEN_NUM_INITIALIZER
16403 (struct cmd_config_per_queue_rx_offload_result,
16404 queue_id, RTE_UINT16);
16405 static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16406 TOKEN_STRING_INITIALIZER
16407 (struct cmd_config_per_queue_rx_offload_result,
16408 rx_offload, "rx_offload");
16409 static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16410 TOKEN_STRING_INITIALIZER
16411 (struct cmd_config_per_queue_rx_offload_result,
16412 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16413 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16414 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16415 "scatter#buffer_split#timestamp#security#keep_crc");
16416 static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16417 TOKEN_STRING_INITIALIZER
16418 (struct cmd_config_per_queue_rx_offload_result,
16422 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16423 __rte_unused struct cmdline *cl,
16424 __rte_unused void *data)
16426 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16427 struct rte_eth_dev_info dev_info;
16428 portid_t port_id = res->port_id;
16429 uint16_t queue_id = res->queue_id;
16430 struct rte_port *port = &ports[port_id];
16431 uint64_t single_offload;
16434 if (port->port_status != RTE_PORT_STOPPED) {
16436 "Error: Can't config offload when Port %d is not stopped\n",
16441 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16445 if (queue_id >= dev_info.nb_rx_queues) {
16447 "Error: input queue_id should be 0 ... %d\n",
16448 dev_info.nb_rx_queues - 1);
16452 single_offload = search_rx_offload(res->offload);
16453 if (single_offload == 0) {
16454 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16458 if (!strcmp(res->on_off, "on"))
16459 port->rxq[queue_id].conf.offloads |= single_offload;
16461 port->rxq[queue_id].conf.offloads &= ~single_offload;
16463 cmd_reconfig_device_queue(port_id, 1, 1);
16466 static cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16467 .f = cmd_config_per_queue_rx_offload_parsed,
16469 .help_str = "port <port_id> rxq <queue_id> rx_offload "
16470 "vlan_strip|ipv4_cksum|"
16471 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16472 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16473 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16476 (void *)&cmd_config_per_queue_rx_offload_result_port,
16477 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
16478 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
16479 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16480 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16481 (void *)&cmd_config_per_queue_rx_offload_result_offload,
16482 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
16487 /* Get Tx offloads capabilities */
16488 struct cmd_tx_offload_get_capa_result {
16489 cmdline_fixed_string_t show;
16490 cmdline_fixed_string_t port;
16492 cmdline_fixed_string_t tx_offload;
16493 cmdline_fixed_string_t capabilities;
16496 static cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16497 TOKEN_STRING_INITIALIZER
16498 (struct cmd_tx_offload_get_capa_result,
16500 static cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16501 TOKEN_STRING_INITIALIZER
16502 (struct cmd_tx_offload_get_capa_result,
16504 static cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16505 TOKEN_NUM_INITIALIZER
16506 (struct cmd_tx_offload_get_capa_result,
16507 port_id, RTE_UINT16);
16508 static cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16509 TOKEN_STRING_INITIALIZER
16510 (struct cmd_tx_offload_get_capa_result,
16511 tx_offload, "tx_offload");
16512 static cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16513 TOKEN_STRING_INITIALIZER
16514 (struct cmd_tx_offload_get_capa_result,
16515 capabilities, "capabilities");
16518 print_tx_offloads(uint64_t offloads)
16520 uint64_t single_offload;
16528 begin = __builtin_ctzll(offloads);
16529 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16531 single_offload = 1ULL << begin;
16532 for (bit = begin; bit < end; bit++) {
16533 if (offloads & single_offload)
16535 rte_eth_dev_tx_offload_name(single_offload));
16536 single_offload <<= 1;
16541 cmd_tx_offload_get_capa_parsed(
16542 void *parsed_result,
16543 __rte_unused struct cmdline *cl,
16544 __rte_unused void *data)
16546 struct cmd_tx_offload_get_capa_result *res = parsed_result;
16547 struct rte_eth_dev_info dev_info;
16548 portid_t port_id = res->port_id;
16549 uint64_t queue_offloads;
16550 uint64_t port_offloads;
16553 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16557 queue_offloads = dev_info.tx_queue_offload_capa;
16558 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16560 printf("Tx Offloading Capabilities of port %d :\n", port_id);
16561 printf(" Per Queue :");
16562 print_tx_offloads(queue_offloads);
16565 printf(" Per Port :");
16566 print_tx_offloads(port_offloads);
16570 static cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16571 .f = cmd_tx_offload_get_capa_parsed,
16573 .help_str = "show port <port_id> tx_offload capabilities",
16575 (void *)&cmd_tx_offload_get_capa_show,
16576 (void *)&cmd_tx_offload_get_capa_port,
16577 (void *)&cmd_tx_offload_get_capa_port_id,
16578 (void *)&cmd_tx_offload_get_capa_tx_offload,
16579 (void *)&cmd_tx_offload_get_capa_capabilities,
16584 /* Get Tx offloads configuration */
16585 struct cmd_tx_offload_get_configuration_result {
16586 cmdline_fixed_string_t show;
16587 cmdline_fixed_string_t port;
16589 cmdline_fixed_string_t tx_offload;
16590 cmdline_fixed_string_t configuration;
16593 static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16594 TOKEN_STRING_INITIALIZER
16595 (struct cmd_tx_offload_get_configuration_result,
16597 static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16598 TOKEN_STRING_INITIALIZER
16599 (struct cmd_tx_offload_get_configuration_result,
16601 static cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16602 TOKEN_NUM_INITIALIZER
16603 (struct cmd_tx_offload_get_configuration_result,
16604 port_id, RTE_UINT16);
16605 static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16606 TOKEN_STRING_INITIALIZER
16607 (struct cmd_tx_offload_get_configuration_result,
16608 tx_offload, "tx_offload");
16609 static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16610 TOKEN_STRING_INITIALIZER
16611 (struct cmd_tx_offload_get_configuration_result,
16612 configuration, "configuration");
16615 cmd_tx_offload_get_configuration_parsed(
16616 void *parsed_result,
16617 __rte_unused struct cmdline *cl,
16618 __rte_unused void *data)
16620 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16621 struct rte_eth_dev_info dev_info;
16622 portid_t port_id = res->port_id;
16623 struct rte_port *port = &ports[port_id];
16624 struct rte_eth_conf dev_conf;
16625 uint64_t port_offloads;
16626 uint64_t queue_offloads;
16627 uint16_t nb_tx_queues;
16631 printf("Tx Offloading Configuration of port %d :\n", port_id);
16633 ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
16637 port_offloads = dev_conf.txmode.offloads;
16639 print_tx_offloads(port_offloads);
16642 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16646 nb_tx_queues = dev_info.nb_tx_queues;
16647 for (q = 0; q < nb_tx_queues; q++) {
16648 queue_offloads = port->txq[q].conf.offloads;
16649 printf(" Queue[%2d] :", q);
16650 print_tx_offloads(queue_offloads);
16656 static cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16657 .f = cmd_tx_offload_get_configuration_parsed,
16659 .help_str = "show port <port_id> tx_offload configuration",
16661 (void *)&cmd_tx_offload_get_configuration_show,
16662 (void *)&cmd_tx_offload_get_configuration_port,
16663 (void *)&cmd_tx_offload_get_configuration_port_id,
16664 (void *)&cmd_tx_offload_get_configuration_tx_offload,
16665 (void *)&cmd_tx_offload_get_configuration_configuration,
16670 /* Enable/Disable a per port offloading */
16671 struct cmd_config_per_port_tx_offload_result {
16672 cmdline_fixed_string_t port;
16673 cmdline_fixed_string_t config;
16675 cmdline_fixed_string_t tx_offload;
16676 cmdline_fixed_string_t offload;
16677 cmdline_fixed_string_t on_off;
16680 static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16681 TOKEN_STRING_INITIALIZER
16682 (struct cmd_config_per_port_tx_offload_result,
16684 static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16685 TOKEN_STRING_INITIALIZER
16686 (struct cmd_config_per_port_tx_offload_result,
16688 static cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16689 TOKEN_NUM_INITIALIZER
16690 (struct cmd_config_per_port_tx_offload_result,
16691 port_id, RTE_UINT16);
16692 static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16693 TOKEN_STRING_INITIALIZER
16694 (struct cmd_config_per_port_tx_offload_result,
16695 tx_offload, "tx_offload");
16696 static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16697 TOKEN_STRING_INITIALIZER
16698 (struct cmd_config_per_port_tx_offload_result,
16699 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16700 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16701 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16702 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16703 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16704 "send_on_timestamp");
16705 static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16706 TOKEN_STRING_INITIALIZER
16707 (struct cmd_config_per_port_tx_offload_result,
16711 search_tx_offload(const char *name)
16713 uint64_t single_offload;
16714 const char *single_name;
16718 single_offload = 1;
16719 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16720 single_name = rte_eth_dev_tx_offload_name(single_offload);
16721 if (single_name == NULL)
16723 if (!strcasecmp(single_name, name)) {
16726 } else if (!strcasecmp(single_name, "UNKNOWN"))
16728 single_offload <<= 1;
16732 return single_offload;
16738 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16739 __rte_unused struct cmdline *cl,
16740 __rte_unused void *data)
16742 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16743 portid_t port_id = res->port_id;
16744 struct rte_eth_dev_info dev_info;
16745 struct rte_port *port = &ports[port_id];
16746 uint64_t single_offload;
16747 uint16_t nb_tx_queues;
16751 if (port->port_status != RTE_PORT_STOPPED) {
16753 "Error: Can't config offload when Port %d is not stopped\n",
16758 single_offload = search_tx_offload(res->offload);
16759 if (single_offload == 0) {
16760 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16764 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16768 nb_tx_queues = dev_info.nb_tx_queues;
16769 if (!strcmp(res->on_off, "on")) {
16770 port->dev_conf.txmode.offloads |= single_offload;
16771 for (q = 0; q < nb_tx_queues; q++)
16772 port->txq[q].conf.offloads |= single_offload;
16774 port->dev_conf.txmode.offloads &= ~single_offload;
16775 for (q = 0; q < nb_tx_queues; q++)
16776 port->txq[q].conf.offloads &= ~single_offload;
16779 cmd_reconfig_device_queue(port_id, 1, 1);
16782 static cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16783 .f = cmd_config_per_port_tx_offload_parsed,
16785 .help_str = "port config <port_id> tx_offload "
16786 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16787 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16788 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16789 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16790 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16791 "send_on_timestamp on|off",
16793 (void *)&cmd_config_per_port_tx_offload_result_port,
16794 (void *)&cmd_config_per_port_tx_offload_result_config,
16795 (void *)&cmd_config_per_port_tx_offload_result_port_id,
16796 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16797 (void *)&cmd_config_per_port_tx_offload_result_offload,
16798 (void *)&cmd_config_per_port_tx_offload_result_on_off,
16803 /* Enable/Disable a per queue offloading */
16804 struct cmd_config_per_queue_tx_offload_result {
16805 cmdline_fixed_string_t port;
16807 cmdline_fixed_string_t txq;
16809 cmdline_fixed_string_t tx_offload;
16810 cmdline_fixed_string_t offload;
16811 cmdline_fixed_string_t on_off;
16814 static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16815 TOKEN_STRING_INITIALIZER
16816 (struct cmd_config_per_queue_tx_offload_result,
16818 static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16819 TOKEN_NUM_INITIALIZER
16820 (struct cmd_config_per_queue_tx_offload_result,
16821 port_id, RTE_UINT16);
16822 static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16823 TOKEN_STRING_INITIALIZER
16824 (struct cmd_config_per_queue_tx_offload_result,
16826 static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16827 TOKEN_NUM_INITIALIZER
16828 (struct cmd_config_per_queue_tx_offload_result,
16829 queue_id, RTE_UINT16);
16830 static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16831 TOKEN_STRING_INITIALIZER
16832 (struct cmd_config_per_queue_tx_offload_result,
16833 tx_offload, "tx_offload");
16834 static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16835 TOKEN_STRING_INITIALIZER
16836 (struct cmd_config_per_queue_tx_offload_result,
16837 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16838 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16839 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16840 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16841 "mt_lockfree#multi_segs#mbuf_fast_free#security");
16842 static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16843 TOKEN_STRING_INITIALIZER
16844 (struct cmd_config_per_queue_tx_offload_result,
16848 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16849 __rte_unused struct cmdline *cl,
16850 __rte_unused void *data)
16852 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16853 struct rte_eth_dev_info dev_info;
16854 portid_t port_id = res->port_id;
16855 uint16_t queue_id = res->queue_id;
16856 struct rte_port *port = &ports[port_id];
16857 uint64_t single_offload;
16860 if (port->port_status != RTE_PORT_STOPPED) {
16862 "Error: Can't config offload when Port %d is not stopped\n",
16867 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16871 if (queue_id >= dev_info.nb_tx_queues) {
16873 "Error: input queue_id should be 0 ... %d\n",
16874 dev_info.nb_tx_queues - 1);
16878 single_offload = search_tx_offload(res->offload);
16879 if (single_offload == 0) {
16880 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16884 if (!strcmp(res->on_off, "on"))
16885 port->txq[queue_id].conf.offloads |= single_offload;
16887 port->txq[queue_id].conf.offloads &= ~single_offload;
16889 cmd_reconfig_device_queue(port_id, 1, 1);
16892 static cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16893 .f = cmd_config_per_queue_tx_offload_parsed,
16895 .help_str = "port <port_id> txq <queue_id> tx_offload "
16896 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16897 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16898 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16899 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16900 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16903 (void *)&cmd_config_per_queue_tx_offload_result_port,
16904 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16905 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16906 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16907 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16908 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16909 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16914 /* *** configure tx_metadata for specific port *** */
16915 struct cmd_config_tx_metadata_specific_result {
16916 cmdline_fixed_string_t port;
16917 cmdline_fixed_string_t keyword;
16919 cmdline_fixed_string_t item;
16924 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16925 __rte_unused struct cmdline *cl,
16926 __rte_unused void *data)
16928 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16930 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16932 ports[res->port_id].tx_metadata = res->value;
16933 /* Add/remove callback to insert valid metadata in every Tx packet. */
16934 if (ports[res->port_id].tx_metadata)
16935 add_tx_md_callback(res->port_id);
16937 remove_tx_md_callback(res->port_id);
16938 rte_flow_dynf_metadata_register();
16941 static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16942 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16944 static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16945 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16946 keyword, "config");
16947 static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16948 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16949 port_id, RTE_UINT16);
16950 static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16951 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16952 item, "tx_metadata");
16953 static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16954 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16955 value, RTE_UINT32);
16957 static cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16958 .f = cmd_config_tx_metadata_specific_parsed,
16960 .help_str = "port config <port_id> tx_metadata <value>",
16962 (void *)&cmd_config_tx_metadata_specific_port,
16963 (void *)&cmd_config_tx_metadata_specific_keyword,
16964 (void *)&cmd_config_tx_metadata_specific_id,
16965 (void *)&cmd_config_tx_metadata_specific_item,
16966 (void *)&cmd_config_tx_metadata_specific_value,
16971 /* *** set dynf *** */
16972 struct cmd_config_tx_dynf_specific_result {
16973 cmdline_fixed_string_t port;
16974 cmdline_fixed_string_t keyword;
16976 cmdline_fixed_string_t item;
16977 cmdline_fixed_string_t name;
16978 cmdline_fixed_string_t value;
16982 cmd_config_dynf_specific_parsed(void *parsed_result,
16983 __rte_unused struct cmdline *cl,
16984 __rte_unused void *data)
16986 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16987 struct rte_mbuf_dynflag desc_flag;
16989 uint64_t old_port_flags;
16991 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16993 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16995 if (strlcpy(desc_flag.name, res->name,
16996 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16997 fprintf(stderr, "Flag name too long\n");
17000 desc_flag.flags = 0;
17001 flag = rte_mbuf_dynflag_register(&desc_flag);
17003 fprintf(stderr, "Can't register flag\n");
17006 strcpy(dynf_names[flag], desc_flag.name);
17008 old_port_flags = ports[res->port_id].mbuf_dynf;
17009 if (!strcmp(res->value, "set")) {
17010 ports[res->port_id].mbuf_dynf |= 1UL << flag;
17011 if (old_port_flags == 0)
17012 add_tx_dynf_callback(res->port_id);
17014 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
17015 if (ports[res->port_id].mbuf_dynf == 0)
17016 remove_tx_dynf_callback(res->port_id);
17020 static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
17021 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17023 static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
17024 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17025 keyword, "config");
17026 static cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
17027 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17028 port_id, RTE_UINT16);
17029 static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
17030 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17032 static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
17033 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17035 static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
17036 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17037 value, "set#clear");
17039 static cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
17040 .f = cmd_config_dynf_specific_parsed,
17042 .help_str = "port config <port id> dynf <name> set|clear",
17044 (void *)&cmd_config_tx_dynf_specific_port,
17045 (void *)&cmd_config_tx_dynf_specific_keyword,
17046 (void *)&cmd_config_tx_dynf_specific_port_id,
17047 (void *)&cmd_config_tx_dynf_specific_item,
17048 (void *)&cmd_config_tx_dynf_specific_name,
17049 (void *)&cmd_config_tx_dynf_specific_value,
17054 /* *** display tx_metadata per port configuration *** */
17055 struct cmd_show_tx_metadata_result {
17056 cmdline_fixed_string_t cmd_show;
17057 cmdline_fixed_string_t cmd_port;
17058 cmdline_fixed_string_t cmd_keyword;
17063 cmd_show_tx_metadata_parsed(void *parsed_result,
17064 __rte_unused struct cmdline *cl,
17065 __rte_unused void *data)
17067 struct cmd_show_tx_metadata_result *res = parsed_result;
17069 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17070 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17073 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
17074 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
17075 ports[res->cmd_pid].tx_metadata);
17079 static cmdline_parse_token_string_t cmd_show_tx_metadata_show =
17080 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17082 static cmdline_parse_token_string_t cmd_show_tx_metadata_port =
17083 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17085 static cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
17086 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
17087 cmd_pid, RTE_UINT16);
17088 static cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
17089 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17090 cmd_keyword, "tx_metadata");
17092 static cmdline_parse_inst_t cmd_show_tx_metadata = {
17093 .f = cmd_show_tx_metadata_parsed,
17095 .help_str = "show port <port_id> tx_metadata",
17097 (void *)&cmd_show_tx_metadata_show,
17098 (void *)&cmd_show_tx_metadata_port,
17099 (void *)&cmd_show_tx_metadata_pid,
17100 (void *)&cmd_show_tx_metadata_keyword,
17105 /* *** show fec capability per port configuration *** */
17106 struct cmd_show_fec_capability_result {
17107 cmdline_fixed_string_t cmd_show;
17108 cmdline_fixed_string_t cmd_port;
17109 cmdline_fixed_string_t cmd_fec;
17110 cmdline_fixed_string_t cmd_keyword;
17115 cmd_show_fec_capability_parsed(void *parsed_result,
17116 __rte_unused struct cmdline *cl,
17117 __rte_unused void *data)
17119 struct cmd_show_fec_capability_result *res = parsed_result;
17120 struct rte_eth_fec_capa *speed_fec_capa;
17124 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17125 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
17129 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
17130 if (ret == -ENOTSUP) {
17131 fprintf(stderr, "Function not implemented\n");
17133 } else if (ret < 0) {
17134 fprintf(stderr, "Get FEC capability failed: %d\n", ret);
17138 num = (unsigned int)ret;
17139 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
17140 if (speed_fec_capa == NULL) {
17141 fprintf(stderr, "Failed to alloc FEC capability buffer\n");
17145 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
17147 fprintf(stderr, "Error getting FEC capability: %d\n", ret);
17151 show_fec_capability(num, speed_fec_capa);
17153 free(speed_fec_capa);
17156 static cmdline_parse_token_string_t cmd_show_fec_capability_show =
17157 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17159 static cmdline_parse_token_string_t cmd_show_fec_capability_port =
17160 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17162 static cmdline_parse_token_num_t cmd_show_fec_capability_pid =
17163 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
17164 cmd_pid, RTE_UINT16);
17165 static cmdline_parse_token_string_t cmd_show_fec_capability_fec =
17166 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17168 static cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
17169 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17170 cmd_keyword, "capabilities");
17172 static cmdline_parse_inst_t cmd_show_capability = {
17173 .f = cmd_show_fec_capability_parsed,
17175 .help_str = "show port <port_id> fec capabilities",
17177 (void *)&cmd_show_fec_capability_show,
17178 (void *)&cmd_show_fec_capability_port,
17179 (void *)&cmd_show_fec_capability_pid,
17180 (void *)&cmd_show_fec_capability_fec,
17181 (void *)&cmd_show_fec_capability_keyword,
17186 /* *** show fec mode per port configuration *** */
17187 struct cmd_show_fec_metadata_result {
17188 cmdline_fixed_string_t cmd_show;
17189 cmdline_fixed_string_t cmd_port;
17190 cmdline_fixed_string_t cmd_keyword;
17195 cmd_show_fec_mode_parsed(void *parsed_result,
17196 __rte_unused struct cmdline *cl,
17197 __rte_unused void *data)
17199 #define FEC_NAME_SIZE 16
17200 struct cmd_show_fec_metadata_result *res = parsed_result;
17202 char buf[FEC_NAME_SIZE];
17205 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17206 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
17209 ret = rte_eth_fec_get(res->cmd_pid, &mode);
17210 if (ret == -ENOTSUP) {
17211 fprintf(stderr, "Function not implemented\n");
17213 } else if (ret < 0) {
17214 fprintf(stderr, "Get FEC mode failed\n");
17219 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
17220 strlcpy(buf, "off", sizeof(buf));
17222 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
17223 strlcpy(buf, "auto", sizeof(buf));
17225 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
17226 strlcpy(buf, "baser", sizeof(buf));
17228 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
17229 strlcpy(buf, "rs", sizeof(buf));
17235 printf("%s\n", buf);
17238 static cmdline_parse_token_string_t cmd_show_fec_mode_show =
17239 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17241 static cmdline_parse_token_string_t cmd_show_fec_mode_port =
17242 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17244 static cmdline_parse_token_num_t cmd_show_fec_mode_pid =
17245 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
17246 cmd_pid, RTE_UINT16);
17247 static cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
17248 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17249 cmd_keyword, "fec_mode");
17251 static cmdline_parse_inst_t cmd_show_fec_mode = {
17252 .f = cmd_show_fec_mode_parsed,
17254 .help_str = "show port <port_id> fec_mode",
17256 (void *)&cmd_show_fec_mode_show,
17257 (void *)&cmd_show_fec_mode_port,
17258 (void *)&cmd_show_fec_mode_pid,
17259 (void *)&cmd_show_fec_mode_keyword,
17264 /* *** set fec mode per port configuration *** */
17265 struct cmd_set_port_fec_mode {
17266 cmdline_fixed_string_t set;
17267 cmdline_fixed_string_t port;
17269 cmdline_fixed_string_t fec_mode;
17270 cmdline_fixed_string_t fec_value;
17273 /* Common CLI fields for set fec mode */
17274 static cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
17275 TOKEN_STRING_INITIALIZER
17276 (struct cmd_set_port_fec_mode,
17278 static cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
17279 TOKEN_STRING_INITIALIZER
17280 (struct cmd_set_port_fec_mode,
17282 static cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
17283 TOKEN_NUM_INITIALIZER
17284 (struct cmd_set_port_fec_mode,
17285 port_id, RTE_UINT16);
17286 static cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
17287 TOKEN_STRING_INITIALIZER
17288 (struct cmd_set_port_fec_mode,
17289 fec_mode, "fec_mode");
17290 static cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
17291 TOKEN_STRING_INITIALIZER
17292 (struct cmd_set_port_fec_mode,
17296 cmd_set_port_fec_mode_parsed(
17297 void *parsed_result,
17298 __rte_unused struct cmdline *cl,
17299 __rte_unused void *data)
17301 struct cmd_set_port_fec_mode *res = parsed_result;
17302 uint16_t port_id = res->port_id;
17306 ret = parse_fec_mode(res->fec_value, &fec_capa);
17308 fprintf(stderr, "Unknown fec mode: %s for port %d\n",
17309 res->fec_value, port_id);
17313 ret = rte_eth_fec_set(port_id, fec_capa);
17314 if (ret == -ENOTSUP) {
17315 fprintf(stderr, "Function not implemented\n");
17317 } else if (ret < 0) {
17318 fprintf(stderr, "Set FEC mode failed\n");
17323 static cmdline_parse_inst_t cmd_set_fec_mode = {
17324 .f = cmd_set_port_fec_mode_parsed,
17326 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
17328 (void *)&cmd_set_port_fec_mode_set,
17329 (void *)&cmd_set_port_fec_mode_port,
17330 (void *)&cmd_set_port_fec_mode_port_id,
17331 (void *)&cmd_set_port_fec_mode_str,
17332 (void *)&cmd_set_port_fec_mode_value,
17337 /* *** set available descriptors threshold for an RxQ of a port *** */
17338 struct cmd_set_rxq_avail_thresh_result {
17339 cmdline_fixed_string_t set;
17340 cmdline_fixed_string_t port;
17342 cmdline_fixed_string_t rxq;
17344 cmdline_fixed_string_t avail_thresh;
17345 uint8_t avail_thresh_num;
17348 static void cmd_set_rxq_avail_thresh_parsed(void *parsed_result,
17349 __rte_unused struct cmdline *cl,
17350 __rte_unused void *data)
17352 struct cmd_set_rxq_avail_thresh_result *res = parsed_result;
17355 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
17356 && (strcmp(res->rxq, "rxq") == 0)
17357 && (strcmp(res->avail_thresh, "avail_thresh") == 0))
17358 ret = set_rxq_avail_thresh(res->port_num, res->rxq_num,
17359 res->avail_thresh_num);
17361 printf("rxq_avail_thresh_cmd error: (%s)\n", strerror(-ret));
17365 static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_set =
17366 TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
17368 static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_port =
17369 TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
17371 static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_portnum =
17372 TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
17373 port_num, RTE_UINT16);
17374 static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_rxq =
17375 TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
17377 static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_rxqnum =
17378 TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
17379 rxq_num, RTE_UINT16);
17380 static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_avail_thresh =
17381 TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
17382 avail_thresh, "avail_thresh");
17383 static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_avail_threshnum =
17384 TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
17385 avail_thresh_num, RTE_UINT8);
17387 static cmdline_parse_inst_t cmd_set_rxq_avail_thresh = {
17388 .f = cmd_set_rxq_avail_thresh_parsed,
17391 "set port <port_id> rxq <queue_id> avail_thresh <0..99>: "
17392 "Set available descriptors threshold for Rx queue",
17394 (void *)&cmd_set_rxq_avail_thresh_set,
17395 (void *)&cmd_set_rxq_avail_thresh_port,
17396 (void *)&cmd_set_rxq_avail_thresh_portnum,
17397 (void *)&cmd_set_rxq_avail_thresh_rxq,
17398 (void *)&cmd_set_rxq_avail_thresh_rxqnum,
17399 (void *)&cmd_set_rxq_avail_thresh_avail_thresh,
17400 (void *)&cmd_set_rxq_avail_thresh_avail_threshnum,
17405 /* show port supported ptypes */
17407 /* Common result structure for show port ptypes */
17408 struct cmd_show_port_supported_ptypes_result {
17409 cmdline_fixed_string_t show;
17410 cmdline_fixed_string_t port;
17412 cmdline_fixed_string_t ptypes;
17415 /* Common CLI fields for show port ptypes */
17416 static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
17417 TOKEN_STRING_INITIALIZER
17418 (struct cmd_show_port_supported_ptypes_result,
17420 static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
17421 TOKEN_STRING_INITIALIZER
17422 (struct cmd_show_port_supported_ptypes_result,
17424 static cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
17425 TOKEN_NUM_INITIALIZER
17426 (struct cmd_show_port_supported_ptypes_result,
17427 port_id, RTE_UINT16);
17428 static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
17429 TOKEN_STRING_INITIALIZER
17430 (struct cmd_show_port_supported_ptypes_result,
17434 cmd_show_port_supported_ptypes_parsed(
17435 void *parsed_result,
17436 __rte_unused struct cmdline *cl,
17437 __rte_unused void *data)
17439 #define RSVD_PTYPE_MASK 0xf0000000
17440 #define MAX_PTYPES_PER_LAYER 16
17441 #define LTYPE_NAMESIZE 32
17442 #define PTYPE_NAMESIZE 256
17443 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
17444 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
17445 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
17446 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
17447 uint16_t port_id = res->port_id;
17450 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
17454 while (ptype_mask != RSVD_PTYPE_MASK) {
17456 switch (ptype_mask) {
17457 case RTE_PTYPE_L2_MASK:
17458 strlcpy(ltype, "L2", sizeof(ltype));
17460 case RTE_PTYPE_L3_MASK:
17461 strlcpy(ltype, "L3", sizeof(ltype));
17463 case RTE_PTYPE_L4_MASK:
17464 strlcpy(ltype, "L4", sizeof(ltype));
17466 case RTE_PTYPE_TUNNEL_MASK:
17467 strlcpy(ltype, "Tunnel", sizeof(ltype));
17469 case RTE_PTYPE_INNER_L2_MASK:
17470 strlcpy(ltype, "Inner L2", sizeof(ltype));
17472 case RTE_PTYPE_INNER_L3_MASK:
17473 strlcpy(ltype, "Inner L3", sizeof(ltype));
17475 case RTE_PTYPE_INNER_L4_MASK:
17476 strlcpy(ltype, "Inner L4", sizeof(ltype));
17482 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
17483 ptype_mask, ptypes,
17484 MAX_PTYPES_PER_LAYER);
17487 printf("Supported %s ptypes:\n", ltype);
17489 printf("%s ptypes unsupported\n", ltype);
17491 for (i = 0; i < ret; ++i) {
17492 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
17493 printf("%s\n", buf);
17500 static cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
17501 .f = cmd_show_port_supported_ptypes_parsed,
17503 .help_str = "show port <port_id> ptypes",
17505 (void *)&cmd_show_port_supported_ptypes_show,
17506 (void *)&cmd_show_port_supported_ptypes_port,
17507 (void *)&cmd_show_port_supported_ptypes_port_id,
17508 (void *)&cmd_show_port_supported_ptypes_ptypes,
17513 /* *** display rx/tx descriptor status *** */
17514 struct cmd_show_rx_tx_desc_status_result {
17515 cmdline_fixed_string_t cmd_show;
17516 cmdline_fixed_string_t cmd_port;
17517 cmdline_fixed_string_t cmd_keyword;
17518 cmdline_fixed_string_t cmd_desc;
17519 cmdline_fixed_string_t cmd_status;
17526 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
17527 __rte_unused struct cmdline *cl,
17528 __rte_unused void *data)
17530 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
17533 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17534 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17538 if (!strcmp(res->cmd_keyword, "rxq")) {
17539 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
17543 "Invalid input: queue id = %d, desc id = %d\n",
17544 res->cmd_qid, res->cmd_did);
17547 if (rc == RTE_ETH_RX_DESC_AVAIL)
17548 printf("Desc status = AVAILABLE\n");
17549 else if (rc == RTE_ETH_RX_DESC_DONE)
17550 printf("Desc status = DONE\n");
17552 printf("Desc status = UNAVAILABLE\n");
17553 } else if (!strcmp(res->cmd_keyword, "txq")) {
17554 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17558 "Invalid input: queue id = %d, desc id = %d\n",
17559 res->cmd_qid, res->cmd_did);
17562 if (rc == RTE_ETH_TX_DESC_FULL)
17563 printf("Desc status = FULL\n");
17564 else if (rc == RTE_ETH_TX_DESC_DONE)
17565 printf("Desc status = DONE\n");
17567 printf("Desc status = UNAVAILABLE\n");
17571 static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17572 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17574 static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17575 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17577 static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17578 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17579 cmd_pid, RTE_UINT16);
17580 static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17581 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17582 cmd_keyword, "rxq#txq");
17583 static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17584 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17585 cmd_qid, RTE_UINT16);
17586 static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17587 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17589 static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17590 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17591 cmd_did, RTE_UINT16);
17592 static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17593 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17594 cmd_status, "status");
17595 static cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17596 .f = cmd_show_rx_tx_desc_status_parsed,
17598 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17601 (void *)&cmd_show_rx_tx_desc_status_show,
17602 (void *)&cmd_show_rx_tx_desc_status_port,
17603 (void *)&cmd_show_rx_tx_desc_status_pid,
17604 (void *)&cmd_show_rx_tx_desc_status_keyword,
17605 (void *)&cmd_show_rx_tx_desc_status_qid,
17606 (void *)&cmd_show_rx_tx_desc_status_desc,
17607 (void *)&cmd_show_rx_tx_desc_status_did,
17608 (void *)&cmd_show_rx_tx_desc_status_status,
17613 /* *** display rx queue desc used count *** */
17614 struct cmd_show_rx_queue_desc_used_count_result {
17615 cmdline_fixed_string_t cmd_show;
17616 cmdline_fixed_string_t cmd_port;
17617 cmdline_fixed_string_t cmd_rxq;
17618 cmdline_fixed_string_t cmd_desc;
17619 cmdline_fixed_string_t cmd_used;
17620 cmdline_fixed_string_t cmd_count;
17626 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17627 __rte_unused struct cmdline *cl,
17628 __rte_unused void *data)
17630 struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17633 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17634 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17638 rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17640 fprintf(stderr, "Invalid queueid = %d\n", res->cmd_qid);
17643 printf("Used desc count = %d\n", rc);
17646 static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17647 TOKEN_STRING_INITIALIZER
17648 (struct cmd_show_rx_queue_desc_used_count_result,
17650 static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17651 TOKEN_STRING_INITIALIZER
17652 (struct cmd_show_rx_queue_desc_used_count_result,
17654 static cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17655 TOKEN_NUM_INITIALIZER
17656 (struct cmd_show_rx_queue_desc_used_count_result,
17657 cmd_pid, RTE_UINT16);
17658 static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17659 TOKEN_STRING_INITIALIZER
17660 (struct cmd_show_rx_queue_desc_used_count_result,
17662 static cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17663 TOKEN_NUM_INITIALIZER
17664 (struct cmd_show_rx_queue_desc_used_count_result,
17665 cmd_qid, RTE_UINT16);
17666 static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17667 TOKEN_STRING_INITIALIZER
17668 (struct cmd_show_rx_queue_desc_used_count_result,
17669 cmd_count, "desc");
17670 static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17671 TOKEN_STRING_INITIALIZER
17672 (struct cmd_show_rx_queue_desc_used_count_result,
17673 cmd_count, "used");
17674 static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17675 TOKEN_STRING_INITIALIZER
17676 (struct cmd_show_rx_queue_desc_used_count_result,
17677 cmd_count, "count");
17678 static cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17679 .f = cmd_show_rx_queue_desc_used_count_parsed,
17681 .help_str = "show port <port_id> rxq <queue_id> desc used count",
17683 (void *)&cmd_show_rx_queue_desc_used_count_show,
17684 (void *)&cmd_show_rx_queue_desc_used_count_port,
17685 (void *)&cmd_show_rx_queue_desc_used_count_pid,
17686 (void *)&cmd_show_rx_queue_desc_used_count_rxq,
17687 (void *)&cmd_show_rx_queue_desc_used_count_qid,
17688 (void *)&cmd_show_rx_queue_desc_used_count_desc,
17689 (void *)&cmd_show_rx_queue_desc_used_count_used,
17690 (void *)&cmd_show_rx_queue_desc_used_count_count,
17695 /* Common result structure for set port ptypes */
17696 struct cmd_set_port_ptypes_result {
17697 cmdline_fixed_string_t set;
17698 cmdline_fixed_string_t port;
17700 cmdline_fixed_string_t ptype_mask;
17704 /* Common CLI fields for set port ptypes */
17705 static cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17706 TOKEN_STRING_INITIALIZER
17707 (struct cmd_set_port_ptypes_result,
17709 static cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17710 TOKEN_STRING_INITIALIZER
17711 (struct cmd_set_port_ptypes_result,
17713 static cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17714 TOKEN_NUM_INITIALIZER
17715 (struct cmd_set_port_ptypes_result,
17716 port_id, RTE_UINT16);
17717 static cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17718 TOKEN_STRING_INITIALIZER
17719 (struct cmd_set_port_ptypes_result,
17720 ptype_mask, "ptype_mask");
17721 static cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17722 TOKEN_NUM_INITIALIZER
17723 (struct cmd_set_port_ptypes_result,
17727 cmd_set_port_ptypes_parsed(
17728 void *parsed_result,
17729 __rte_unused struct cmdline *cl,
17730 __rte_unused void *data)
17732 struct cmd_set_port_ptypes_result *res = parsed_result;
17733 #define PTYPE_NAMESIZE 256
17734 char ptype_name[PTYPE_NAMESIZE];
17735 uint16_t port_id = res->port_id;
17736 uint32_t ptype_mask = res->mask;
17739 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17742 fprintf(stderr, "Port %d doesn't support any ptypes.\n",
17747 uint32_t ptypes[ret];
17749 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17751 fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
17756 printf("Successfully set following ptypes for Port %d\n", port_id);
17757 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17758 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17759 printf("%s\n", ptype_name);
17762 clear_ptypes = false;
17765 static cmdline_parse_inst_t cmd_set_port_ptypes = {
17766 .f = cmd_set_port_ptypes_parsed,
17768 .help_str = "set port <port_id> ptype_mask <mask>",
17770 (void *)&cmd_set_port_ptypes_set,
17771 (void *)&cmd_set_port_ptypes_port,
17772 (void *)&cmd_set_port_ptypes_port_id,
17773 (void *)&cmd_set_port_ptypes_mask_str,
17774 (void *)&cmd_set_port_ptypes_mask_u32,
17779 /* *** display mac addresses added to a port *** */
17780 struct cmd_showport_macs_result {
17781 cmdline_fixed_string_t cmd_show;
17782 cmdline_fixed_string_t cmd_port;
17783 cmdline_fixed_string_t cmd_keyword;
17788 cmd_showport_macs_parsed(void *parsed_result,
17789 __rte_unused struct cmdline *cl,
17790 __rte_unused void *data)
17792 struct cmd_showport_macs_result *res = parsed_result;
17794 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17797 if (!strcmp(res->cmd_keyword, "macs"))
17798 show_macs(res->cmd_pid);
17799 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17800 show_mcast_macs(res->cmd_pid);
17803 static cmdline_parse_token_string_t cmd_showport_macs_show =
17804 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17806 static cmdline_parse_token_string_t cmd_showport_macs_port =
17807 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17809 static cmdline_parse_token_num_t cmd_showport_macs_pid =
17810 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17811 cmd_pid, RTE_UINT16);
17812 static cmdline_parse_token_string_t cmd_showport_macs_keyword =
17813 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17814 cmd_keyword, "macs#mcast_macs");
17816 static cmdline_parse_inst_t cmd_showport_macs = {
17817 .f = cmd_showport_macs_parsed,
17819 .help_str = "show port <port_id> macs|mcast_macs",
17821 (void *)&cmd_showport_macs_show,
17822 (void *)&cmd_showport_macs_port,
17823 (void *)&cmd_showport_macs_pid,
17824 (void *)&cmd_showport_macs_keyword,
17829 /* *** show flow transfer proxy port ID for the given port *** */
17830 struct cmd_show_port_flow_transfer_proxy_result {
17831 cmdline_fixed_string_t show;
17832 cmdline_fixed_string_t port;
17834 cmdline_fixed_string_t flow;
17835 cmdline_fixed_string_t transfer;
17836 cmdline_fixed_string_t proxy;
17839 static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_show =
17840 TOKEN_STRING_INITIALIZER
17841 (struct cmd_show_port_flow_transfer_proxy_result,
17843 static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_port =
17844 TOKEN_STRING_INITIALIZER
17845 (struct cmd_show_port_flow_transfer_proxy_result,
17847 static cmdline_parse_token_num_t cmd_show_port_flow_transfer_proxy_port_id =
17848 TOKEN_NUM_INITIALIZER
17849 (struct cmd_show_port_flow_transfer_proxy_result,
17850 port_id, RTE_UINT16);
17851 static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_flow =
17852 TOKEN_STRING_INITIALIZER
17853 (struct cmd_show_port_flow_transfer_proxy_result,
17855 static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_transfer =
17856 TOKEN_STRING_INITIALIZER
17857 (struct cmd_show_port_flow_transfer_proxy_result,
17858 transfer, "transfer");
17859 static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_proxy =
17860 TOKEN_STRING_INITIALIZER
17861 (struct cmd_show_port_flow_transfer_proxy_result,
17865 cmd_show_port_flow_transfer_proxy_parsed(void *parsed_result,
17866 __rte_unused struct cmdline *cl,
17867 __rte_unused void *data)
17869 struct cmd_show_port_flow_transfer_proxy_result *res = parsed_result;
17870 portid_t proxy_port_id;
17875 ret = rte_flow_pick_transfer_proxy(res->port_id, &proxy_port_id, NULL);
17877 fprintf(stderr, "Failed to pick transfer proxy: %s\n",
17878 rte_strerror(-ret));
17882 printf("Transfer proxy port ID: %u\n\n", proxy_port_id);
17885 static cmdline_parse_inst_t cmd_show_port_flow_transfer_proxy = {
17886 .f = cmd_show_port_flow_transfer_proxy_parsed,
17888 .help_str = "show port <port_id> flow transfer proxy",
17890 (void *)&cmd_show_port_flow_transfer_proxy_show,
17891 (void *)&cmd_show_port_flow_transfer_proxy_port,
17892 (void *)&cmd_show_port_flow_transfer_proxy_port_id,
17893 (void *)&cmd_show_port_flow_transfer_proxy_flow,
17894 (void *)&cmd_show_port_flow_transfer_proxy_transfer,
17895 (void *)&cmd_show_port_flow_transfer_proxy_proxy,
17900 /* ******************************************************************************** */
17902 /* list of instructions */
17903 static cmdline_parse_ctx_t builtin_ctx[] = {
17904 (cmdline_parse_inst_t *)&cmd_help_brief,
17905 (cmdline_parse_inst_t *)&cmd_help_long,
17906 (cmdline_parse_inst_t *)&cmd_quit,
17907 (cmdline_parse_inst_t *)&cmd_load_from_file,
17908 (cmdline_parse_inst_t *)&cmd_showport,
17909 (cmdline_parse_inst_t *)&cmd_showqueue,
17910 (cmdline_parse_inst_t *)&cmd_showeeprom,
17911 (cmdline_parse_inst_t *)&cmd_showportall,
17912 (cmdline_parse_inst_t *)&cmd_representor_info,
17913 (cmdline_parse_inst_t *)&cmd_showdevice,
17914 (cmdline_parse_inst_t *)&cmd_showcfg,
17915 (cmdline_parse_inst_t *)&cmd_showfwdall,
17916 (cmdline_parse_inst_t *)&cmd_start,
17917 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17918 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17919 (cmdline_parse_inst_t *)&cmd_set_link_up,
17920 (cmdline_parse_inst_t *)&cmd_set_link_down,
17921 (cmdline_parse_inst_t *)&cmd_reset,
17922 (cmdline_parse_inst_t *)&cmd_set_numbers,
17923 (cmdline_parse_inst_t *)&cmd_set_log,
17924 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
17925 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
17926 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17927 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17928 (cmdline_parse_inst_t *)&cmd_set_txtimes,
17929 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17930 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17931 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17932 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17933 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17934 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17935 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17936 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17937 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17938 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17939 (cmdline_parse_inst_t *)&cmd_set_link_check,
17940 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17941 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17942 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17943 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17944 #ifdef RTE_NET_BOND
17945 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17946 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17947 (cmdline_parse_inst_t *) &cmd_show_bonding_lacp_info,
17948 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17949 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17950 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17951 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17952 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17953 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17954 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17955 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17956 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17958 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17959 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17960 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17961 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17962 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17963 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17964 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17965 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17966 (cmdline_parse_inst_t *)&cmd_csum_set,
17967 (cmdline_parse_inst_t *)&cmd_csum_show,
17968 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17969 (cmdline_parse_inst_t *)&cmd_tso_set,
17970 (cmdline_parse_inst_t *)&cmd_tso_show,
17971 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17972 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17974 (cmdline_parse_inst_t *)&cmd_gro_enable,
17975 (cmdline_parse_inst_t *)&cmd_gro_flush,
17976 (cmdline_parse_inst_t *)&cmd_gro_show,
17979 (cmdline_parse_inst_t *)&cmd_gso_enable,
17980 (cmdline_parse_inst_t *)&cmd_gso_size,
17981 (cmdline_parse_inst_t *)&cmd_gso_show,
17983 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17984 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17985 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17986 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17987 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17988 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17989 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17990 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17991 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17992 (cmdline_parse_inst_t *)&cmd_link_flow_control_show,
17993 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17994 (cmdline_parse_inst_t *)&cmd_queue_priority_flow_control_set,
17995 (cmdline_parse_inst_t *)&cmd_config_dcb,
17996 (cmdline_parse_inst_t *)&cmd_read_reg,
17997 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17998 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17999 (cmdline_parse_inst_t *)&cmd_write_reg,
18000 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
18001 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
18002 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
18003 (cmdline_parse_inst_t *)&cmd_stop,
18004 (cmdline_parse_inst_t *)&cmd_mac_addr,
18005 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
18006 (cmdline_parse_inst_t *)&cmd_set_qmap,
18007 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
18008 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
18009 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
18010 (cmdline_parse_inst_t *)&cmd_operate_port,
18011 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
18012 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
18013 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
18014 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
18015 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
18016 (cmdline_parse_inst_t *)&cmd_config_speed_all,
18017 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
18018 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
18019 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
18020 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
18021 (cmdline_parse_inst_t *)&cmd_config_mtu,
18022 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
18023 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
18024 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
18025 (cmdline_parse_inst_t *)&cmd_config_rss,
18026 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
18027 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
18028 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
18029 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
18030 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
18031 (cmdline_parse_inst_t *)&cmd_showport_reta,
18032 (cmdline_parse_inst_t *)&cmd_showport_macs,
18033 (cmdline_parse_inst_t *)&cmd_show_port_flow_transfer_proxy,
18034 (cmdline_parse_inst_t *)&cmd_config_burst,
18035 (cmdline_parse_inst_t *)&cmd_config_thresh,
18036 (cmdline_parse_inst_t *)&cmd_config_threshold,
18037 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
18038 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
18039 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
18040 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
18041 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
18042 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
18043 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
18044 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
18045 (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
18046 (cmdline_parse_inst_t *)&cmd_dump,
18047 (cmdline_parse_inst_t *)&cmd_dump_one,
18048 #ifdef RTE_NET_I40E
18049 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
18051 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
18052 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
18053 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
18054 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
18055 (cmdline_parse_inst_t *)&cmd_flow,
18056 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
18057 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
18058 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
18059 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm_rfc4115,
18060 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
18061 (cmdline_parse_inst_t *)&cmd_create_port_meter,
18062 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
18063 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
18064 (cmdline_parse_inst_t *)&cmd_del_port_meter,
18065 (cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
18066 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
18067 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
18068 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
18069 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
18070 (cmdline_parse_inst_t *)&cmd_mcast_addr,
18071 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
18072 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
18073 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
18074 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
18075 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
18076 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
18077 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
18078 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
18079 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
18080 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
18081 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
18082 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
18083 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
18084 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
18085 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
18086 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
18087 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
18088 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
18089 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
18090 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
18091 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
18092 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
18093 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
18094 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
18095 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
18096 (cmdline_parse_inst_t *)&cmd_set_vxlan,
18097 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
18098 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
18099 (cmdline_parse_inst_t *)&cmd_set_nvgre,
18100 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
18101 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
18102 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
18103 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
18104 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
18105 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
18106 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
18107 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
18108 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
18109 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
18110 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
18111 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
18112 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
18113 (cmdline_parse_inst_t *)&cmd_set_conntrack_common,
18114 (cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
18115 (cmdline_parse_inst_t *)&cmd_ddp_add,
18116 (cmdline_parse_inst_t *)&cmd_ddp_del,
18117 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
18118 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
18119 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
18120 (cmdline_parse_inst_t *)&cmd_clear_input_set,
18121 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
18122 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
18123 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
18124 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
18125 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
18126 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
18127 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
18128 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
18130 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
18131 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
18132 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
18133 (cmdline_parse_inst_t *)&cmd_queue_region,
18134 (cmdline_parse_inst_t *)&cmd_region_flowtype,
18135 (cmdline_parse_inst_t *)&cmd_user_priority_region,
18136 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
18137 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
18138 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
18139 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
18140 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
18141 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
18142 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
18143 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
18144 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
18145 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
18146 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
18147 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
18148 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
18149 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
18150 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
18151 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
18152 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
18153 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
18154 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
18155 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
18156 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
18157 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
18158 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
18159 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
18160 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
18161 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
18162 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
18163 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
18164 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
18165 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
18166 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
18167 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
18168 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
18169 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
18171 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
18172 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
18174 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
18175 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
18176 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
18177 (cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
18178 (cmdline_parse_inst_t *)&cmd_set_raw,
18179 (cmdline_parse_inst_t *)&cmd_show_set_raw,
18180 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
18181 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
18182 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
18183 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
18184 (cmdline_parse_inst_t *)&cmd_set_rxq_avail_thresh,
18185 (cmdline_parse_inst_t *)&cmd_show_capability,
18186 (cmdline_parse_inst_t *)&cmd_set_flex_is_pattern,
18187 (cmdline_parse_inst_t *)&cmd_set_flex_spec_pattern,
18192 testpmd_add_driver_commands(struct testpmd_driver_commands *c)
18194 TAILQ_INSERT_TAIL(&driver_commands_head, c, next);
18200 struct testpmd_driver_commands *c;
18201 unsigned int count;
18204 /* initialize non-constant commands */
18205 cmd_set_fwd_mode_init();
18206 cmd_set_fwd_retry_mode_init();
18209 for (i = 0; builtin_ctx[i] != NULL; i++)
18211 TAILQ_FOREACH(c, &driver_commands_head, next) {
18212 for (i = 0; c->commands[i].ctx != NULL; i++)
18216 /* cmdline expects a NULL terminated array */
18217 main_ctx = calloc(count + 1, sizeof(main_ctx[0]));
18218 if (main_ctx == NULL)
18222 for (i = 0; builtin_ctx[i] != NULL; i++, count++)
18223 main_ctx[count] = builtin_ctx[i];
18224 TAILQ_FOREACH(c, &driver_commands_head, next) {
18225 for (i = 0; c->commands[i].ctx != NULL; i++, count++)
18226 main_ctx[count] = c->commands[i].ctx;
18232 /* read cmdline commands from file */
18234 cmdline_read_from_file(const char *filename)
18236 struct cmdline *cl;
18238 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
18241 "Failed to create file based cmdline context: %s\n",
18246 cmdline_interact(cl);
18251 printf("Read CLI commands from %s\n", filename);
18254 /* prompt function, called from main on MAIN lcore */
18260 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
18261 if (testpmd_cl == NULL)
18264 ret = atexit(prompt_exit);
18266 fprintf(stderr, "Cannot set exit function for cmdline\n");
18268 cmdline_interact(testpmd_cl);
18270 cmdline_stdin_exit(testpmd_cl);
18276 if (testpmd_cl != NULL) {
18277 cmdline_quit(testpmd_cl);
18278 cmdline_stdin_exit(testpmd_cl);
18283 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
18285 if (id == (portid_t)RTE_PORT_ALL) {
18288 RTE_ETH_FOREACH_DEV(pid) {
18289 /* check if need_reconfig has been set to 1 */
18290 if (ports[pid].need_reconfig == 0)
18291 ports[pid].need_reconfig = dev;
18292 /* check if need_reconfig_queues has been set to 1 */
18293 if (ports[pid].need_reconfig_queues == 0)
18294 ports[pid].need_reconfig_queues = queue;
18296 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
18297 /* check if need_reconfig has been set to 1 */
18298 if (ports[id].need_reconfig == 0)
18299 ports[id].need_reconfig = dev;
18300 /* check if need_reconfig_queues has been set to 1 */
18301 if (ports[id].need_reconfig_queues == 0)
18302 ports[id].need_reconfig_queues = queue;