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)
8924 static cmdline_parse_token_string_t cmd_quit_quit =
8925 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8927 static cmdline_parse_inst_t cmd_quit = {
8928 .f = cmd_quit_parsed,
8930 .help_str = "quit: Exit application",
8932 (void *)&cmd_quit_quit,
8937 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8938 struct cmd_mac_addr_result {
8939 cmdline_fixed_string_t mac_addr_cmd;
8940 cmdline_fixed_string_t what;
8942 struct rte_ether_addr address;
8945 static void cmd_mac_addr_parsed(void *parsed_result,
8946 __rte_unused struct cmdline *cl,
8947 __rte_unused void *data)
8949 struct cmd_mac_addr_result *res = parsed_result;
8952 if (strcmp(res->what, "add") == 0)
8953 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8954 else if (strcmp(res->what, "set") == 0)
8955 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8958 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8960 /* check the return value and print it if is < 0 */
8962 fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
8966 static cmdline_parse_token_string_t cmd_mac_addr_cmd =
8967 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8969 static cmdline_parse_token_string_t cmd_mac_addr_what =
8970 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8972 static cmdline_parse_token_num_t cmd_mac_addr_portnum =
8973 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8975 static cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8976 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8978 static cmdline_parse_inst_t cmd_mac_addr = {
8979 .f = cmd_mac_addr_parsed,
8981 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8982 "Add/Remove/Set MAC address on port_id",
8984 (void *)&cmd_mac_addr_cmd,
8985 (void *)&cmd_mac_addr_what,
8986 (void *)&cmd_mac_addr_portnum,
8987 (void *)&cmd_mac_addr_addr,
8992 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8993 struct cmd_eth_peer_result {
8994 cmdline_fixed_string_t set;
8995 cmdline_fixed_string_t eth_peer;
8997 cmdline_fixed_string_t peer_addr;
9000 static void cmd_set_eth_peer_parsed(void *parsed_result,
9001 __rte_unused struct cmdline *cl,
9002 __rte_unused void *data)
9004 struct cmd_eth_peer_result *res = parsed_result;
9006 if (test_done == 0) {
9007 fprintf(stderr, "Please stop forwarding first\n");
9010 if (!strcmp(res->eth_peer, "eth-peer")) {
9011 set_fwd_eth_peer(res->port_id, res->peer_addr);
9015 static cmdline_parse_token_string_t cmd_eth_peer_set =
9016 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
9017 static cmdline_parse_token_string_t cmd_eth_peer =
9018 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
9019 static cmdline_parse_token_num_t cmd_eth_peer_port_id =
9020 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
9022 static cmdline_parse_token_string_t cmd_eth_peer_addr =
9023 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
9025 static cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
9026 .f = cmd_set_eth_peer_parsed,
9028 .help_str = "set eth-peer <port_id> <peer_mac>",
9030 (void *)&cmd_eth_peer_set,
9031 (void *)&cmd_eth_peer,
9032 (void *)&cmd_eth_peer_port_id,
9033 (void *)&cmd_eth_peer_addr,
9038 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
9039 struct cmd_set_qmap_result {
9040 cmdline_fixed_string_t set;
9041 cmdline_fixed_string_t qmap;
9042 cmdline_fixed_string_t what;
9049 cmd_set_qmap_parsed(void *parsed_result,
9050 __rte_unused struct cmdline *cl,
9051 __rte_unused void *data)
9053 struct cmd_set_qmap_result *res = parsed_result;
9054 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
9056 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
9059 static cmdline_parse_token_string_t cmd_setqmap_set =
9060 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
9062 static cmdline_parse_token_string_t cmd_setqmap_qmap =
9063 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
9065 static cmdline_parse_token_string_t cmd_setqmap_what =
9066 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
9068 static cmdline_parse_token_num_t cmd_setqmap_portid =
9069 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
9070 port_id, RTE_UINT16);
9071 static cmdline_parse_token_num_t cmd_setqmap_queueid =
9072 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
9073 queue_id, RTE_UINT16);
9074 static cmdline_parse_token_num_t cmd_setqmap_mapvalue =
9075 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
9076 map_value, RTE_UINT8);
9078 static cmdline_parse_inst_t cmd_set_qmap = {
9079 .f = cmd_set_qmap_parsed,
9081 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
9082 "Set statistics mapping value on tx|rx queue_id of port_id",
9084 (void *)&cmd_setqmap_set,
9085 (void *)&cmd_setqmap_qmap,
9086 (void *)&cmd_setqmap_what,
9087 (void *)&cmd_setqmap_portid,
9088 (void *)&cmd_setqmap_queueid,
9089 (void *)&cmd_setqmap_mapvalue,
9094 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
9095 struct cmd_set_xstats_hide_zero_result {
9096 cmdline_fixed_string_t keyword;
9097 cmdline_fixed_string_t name;
9098 cmdline_fixed_string_t on_off;
9102 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
9103 __rte_unused struct cmdline *cl,
9104 __rte_unused void *data)
9106 struct cmd_set_xstats_hide_zero_result *res;
9107 uint16_t on_off = 0;
9109 res = parsed_result;
9110 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9111 set_xstats_hide_zero(on_off);
9114 static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
9115 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
9117 static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
9118 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
9119 name, "xstats-hide-zero");
9120 static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
9121 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
9124 static cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
9125 .f = cmd_set_xstats_hide_zero_parsed,
9127 .help_str = "set xstats-hide-zero on|off",
9129 (void *)&cmd_set_xstats_hide_zero_keyword,
9130 (void *)&cmd_set_xstats_hide_zero_name,
9131 (void *)&cmd_set_xstats_hide_zero_on_off,
9136 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
9137 struct cmd_set_record_core_cycles_result {
9138 cmdline_fixed_string_t keyword;
9139 cmdline_fixed_string_t name;
9140 cmdline_fixed_string_t on_off;
9144 cmd_set_record_core_cycles_parsed(void *parsed_result,
9145 __rte_unused struct cmdline *cl,
9146 __rte_unused void *data)
9148 struct cmd_set_record_core_cycles_result *res;
9149 uint16_t on_off = 0;
9151 res = parsed_result;
9152 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9153 set_record_core_cycles(on_off);
9156 static cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
9157 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9159 static cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
9160 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9161 name, "record-core-cycles");
9162 static cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
9163 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9166 static cmdline_parse_inst_t cmd_set_record_core_cycles = {
9167 .f = cmd_set_record_core_cycles_parsed,
9169 .help_str = "set record-core-cycles on|off",
9171 (void *)&cmd_set_record_core_cycles_keyword,
9172 (void *)&cmd_set_record_core_cycles_name,
9173 (void *)&cmd_set_record_core_cycles_on_off,
9178 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
9179 struct cmd_set_record_burst_stats_result {
9180 cmdline_fixed_string_t keyword;
9181 cmdline_fixed_string_t name;
9182 cmdline_fixed_string_t on_off;
9186 cmd_set_record_burst_stats_parsed(void *parsed_result,
9187 __rte_unused struct cmdline *cl,
9188 __rte_unused void *data)
9190 struct cmd_set_record_burst_stats_result *res;
9191 uint16_t on_off = 0;
9193 res = parsed_result;
9194 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9195 set_record_burst_stats(on_off);
9198 static cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
9199 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9201 static cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
9202 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9203 name, "record-burst-stats");
9204 static cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
9205 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9208 static cmdline_parse_inst_t cmd_set_record_burst_stats = {
9209 .f = cmd_set_record_burst_stats_parsed,
9211 .help_str = "set record-burst-stats on|off",
9213 (void *)&cmd_set_record_burst_stats_keyword,
9214 (void *)&cmd_set_record_burst_stats_name,
9215 (void *)&cmd_set_record_burst_stats_on_off,
9220 /* *** CONFIGURE UNICAST HASH TABLE *** */
9221 struct cmd_set_uc_hash_table {
9222 cmdline_fixed_string_t set;
9223 cmdline_fixed_string_t port;
9225 cmdline_fixed_string_t what;
9226 struct rte_ether_addr address;
9227 cmdline_fixed_string_t mode;
9231 cmd_set_uc_hash_parsed(void *parsed_result,
9232 __rte_unused struct cmdline *cl,
9233 __rte_unused void *data)
9236 struct cmd_set_uc_hash_table *res = parsed_result;
9238 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9240 if (strcmp(res->what, "uta") == 0)
9241 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
9242 &res->address,(uint8_t)is_on);
9245 "bad unicast hash table parameter, return code = %d\n",
9250 static cmdline_parse_token_string_t cmd_set_uc_hash_set =
9251 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9253 static cmdline_parse_token_string_t cmd_set_uc_hash_port =
9254 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9256 static cmdline_parse_token_num_t cmd_set_uc_hash_portid =
9257 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
9258 port_id, RTE_UINT16);
9259 static cmdline_parse_token_string_t cmd_set_uc_hash_what =
9260 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9262 static cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
9263 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
9265 static cmdline_parse_token_string_t cmd_set_uc_hash_mode =
9266 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9269 static cmdline_parse_inst_t cmd_set_uc_hash_filter = {
9270 .f = cmd_set_uc_hash_parsed,
9272 .help_str = "set port <port_id> uta <mac_addr> on|off)",
9274 (void *)&cmd_set_uc_hash_set,
9275 (void *)&cmd_set_uc_hash_port,
9276 (void *)&cmd_set_uc_hash_portid,
9277 (void *)&cmd_set_uc_hash_what,
9278 (void *)&cmd_set_uc_hash_mac,
9279 (void *)&cmd_set_uc_hash_mode,
9284 struct cmd_set_uc_all_hash_table {
9285 cmdline_fixed_string_t set;
9286 cmdline_fixed_string_t port;
9288 cmdline_fixed_string_t what;
9289 cmdline_fixed_string_t value;
9290 cmdline_fixed_string_t mode;
9294 cmd_set_uc_all_hash_parsed(void *parsed_result,
9295 __rte_unused struct cmdline *cl,
9296 __rte_unused void *data)
9299 struct cmd_set_uc_all_hash_table *res = parsed_result;
9301 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9303 if ((strcmp(res->what, "uta") == 0) &&
9304 (strcmp(res->value, "all") == 0))
9305 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
9308 "bad unicast hash table parameter, return code = %d\n",
9312 static cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
9313 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9315 static cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
9316 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9318 static cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
9319 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
9320 port_id, RTE_UINT16);
9321 static cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
9322 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9324 static cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
9325 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9327 static cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
9328 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9331 static cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
9332 .f = cmd_set_uc_all_hash_parsed,
9334 .help_str = "set port <port_id> uta all on|off",
9336 (void *)&cmd_set_uc_all_hash_set,
9337 (void *)&cmd_set_uc_all_hash_port,
9338 (void *)&cmd_set_uc_all_hash_portid,
9339 (void *)&cmd_set_uc_all_hash_what,
9340 (void *)&cmd_set_uc_all_hash_value,
9341 (void *)&cmd_set_uc_all_hash_mode,
9346 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
9347 struct cmd_set_vf_traffic {
9348 cmdline_fixed_string_t set;
9349 cmdline_fixed_string_t port;
9351 cmdline_fixed_string_t vf;
9353 cmdline_fixed_string_t what;
9354 cmdline_fixed_string_t mode;
9358 cmd_set_vf_traffic_parsed(void *parsed_result,
9359 __rte_unused struct cmdline *cl,
9360 __rte_unused void *data)
9362 struct cmd_set_vf_traffic *res = parsed_result;
9363 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
9364 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9366 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
9369 static cmdline_parse_token_string_t cmd_setvf_traffic_set =
9370 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9372 static cmdline_parse_token_string_t cmd_setvf_traffic_port =
9373 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9375 static cmdline_parse_token_num_t cmd_setvf_traffic_portid =
9376 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9377 port_id, RTE_UINT16);
9378 static cmdline_parse_token_string_t cmd_setvf_traffic_vf =
9379 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9381 static cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
9382 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9384 static cmdline_parse_token_string_t cmd_setvf_traffic_what =
9385 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9387 static cmdline_parse_token_string_t cmd_setvf_traffic_mode =
9388 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9391 static cmdline_parse_inst_t cmd_set_vf_traffic = {
9392 .f = cmd_set_vf_traffic_parsed,
9394 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
9396 (void *)&cmd_setvf_traffic_set,
9397 (void *)&cmd_setvf_traffic_port,
9398 (void *)&cmd_setvf_traffic_portid,
9399 (void *)&cmd_setvf_traffic_vf,
9400 (void *)&cmd_setvf_traffic_vfid,
9401 (void *)&cmd_setvf_traffic_what,
9402 (void *)&cmd_setvf_traffic_mode,
9407 /* *** CONFIGURE VF RECEIVE MODE *** */
9408 struct cmd_set_vf_rxmode {
9409 cmdline_fixed_string_t set;
9410 cmdline_fixed_string_t port;
9412 cmdline_fixed_string_t vf;
9414 cmdline_fixed_string_t what;
9415 cmdline_fixed_string_t mode;
9416 cmdline_fixed_string_t on;
9420 cmd_set_vf_rxmode_parsed(void *parsed_result,
9421 __rte_unused struct cmdline *cl,
9422 __rte_unused void *data)
9425 uint16_t vf_rxmode = 0;
9426 struct cmd_set_vf_rxmode *res = parsed_result;
9428 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
9429 if (!strcmp(res->what,"rxmode")) {
9430 if (!strcmp(res->mode, "AUPE"))
9431 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_UNTAG;
9432 else if (!strcmp(res->mode, "ROPE"))
9433 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_HASH_UC;
9434 else if (!strcmp(res->mode, "BAM"))
9435 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_BROADCAST;
9436 else if (!strncmp(res->mode, "MPE",3))
9437 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_MULTICAST;
9440 RTE_SET_USED(is_on);
9441 RTE_SET_USED(vf_rxmode);
9443 #ifdef RTE_NET_IXGBE
9444 if (ret == -ENOTSUP)
9445 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
9446 vf_rxmode, (uint8_t)is_on);
9449 if (ret == -ENOTSUP)
9450 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
9451 vf_rxmode, (uint8_t)is_on);
9455 "bad VF receive mode parameter, return code = %d\n",
9459 static cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
9460 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9462 static cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
9463 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9465 static cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
9466 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9467 port_id, RTE_UINT16);
9468 static cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
9469 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9471 static cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
9472 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9474 static cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
9475 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9477 static cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
9478 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9479 mode, "AUPE#ROPE#BAM#MPE");
9480 static cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
9481 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9484 static cmdline_parse_inst_t cmd_set_vf_rxmode = {
9485 .f = cmd_set_vf_rxmode_parsed,
9487 .help_str = "set port <port_id> vf <vf_id> rxmode "
9488 "AUPE|ROPE|BAM|MPE on|off",
9490 (void *)&cmd_set_vf_rxmode_set,
9491 (void *)&cmd_set_vf_rxmode_port,
9492 (void *)&cmd_set_vf_rxmode_portid,
9493 (void *)&cmd_set_vf_rxmode_vf,
9494 (void *)&cmd_set_vf_rxmode_vfid,
9495 (void *)&cmd_set_vf_rxmode_what,
9496 (void *)&cmd_set_vf_rxmode_mode,
9497 (void *)&cmd_set_vf_rxmode_on,
9502 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
9503 struct cmd_vf_mac_addr_result {
9504 cmdline_fixed_string_t mac_addr_cmd;
9505 cmdline_fixed_string_t what;
9506 cmdline_fixed_string_t port;
9508 cmdline_fixed_string_t vf;
9510 struct rte_ether_addr address;
9513 static void cmd_vf_mac_addr_parsed(void *parsed_result,
9514 __rte_unused struct cmdline *cl,
9515 __rte_unused void *data)
9517 struct cmd_vf_mac_addr_result *res = parsed_result;
9520 if (strcmp(res->what, "add") != 0)
9524 if (ret == -ENOTSUP)
9525 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
9529 if (ret == -ENOTSUP)
9530 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
9535 fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
9539 static cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
9540 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9541 mac_addr_cmd,"mac_addr");
9542 static cmdline_parse_token_string_t cmd_vf_mac_addr_what =
9543 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9545 static cmdline_parse_token_string_t cmd_vf_mac_addr_port =
9546 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9548 static cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
9549 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9550 port_num, RTE_UINT16);
9551 static cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
9552 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9554 static cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
9555 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9557 static cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
9558 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
9561 static cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
9562 .f = cmd_vf_mac_addr_parsed,
9564 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
9565 "Add MAC address filtering for a VF on port_id",
9567 (void *)&cmd_vf_mac_addr_cmd,
9568 (void *)&cmd_vf_mac_addr_what,
9569 (void *)&cmd_vf_mac_addr_port,
9570 (void *)&cmd_vf_mac_addr_portnum,
9571 (void *)&cmd_vf_mac_addr_vf,
9572 (void *)&cmd_vf_mac_addr_vfnum,
9573 (void *)&cmd_vf_mac_addr_addr,
9578 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
9579 struct cmd_vf_rx_vlan_filter {
9580 cmdline_fixed_string_t rx_vlan;
9581 cmdline_fixed_string_t what;
9583 cmdline_fixed_string_t port;
9585 cmdline_fixed_string_t vf;
9590 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
9591 __rte_unused struct cmdline *cl,
9592 __rte_unused void *data)
9594 struct cmd_vf_rx_vlan_filter *res = parsed_result;
9597 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9599 #ifdef RTE_NET_IXGBE
9600 if (ret == -ENOTSUP)
9601 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9602 res->vlan_id, res->vf_mask, is_add);
9605 if (ret == -ENOTSUP)
9606 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9607 res->vlan_id, res->vf_mask, is_add);
9610 if (ret == -ENOTSUP)
9611 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9612 res->vlan_id, res->vf_mask, is_add);
9619 fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
9620 res->vlan_id, res->vf_mask);
9623 fprintf(stderr, "invalid port_id %d\n", res->port_id);
9626 fprintf(stderr, "function not implemented or supported\n");
9629 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9633 static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9634 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9635 rx_vlan, "rx_vlan");
9636 static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9637 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9639 static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9640 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9641 vlan_id, RTE_UINT16);
9642 static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9643 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9645 static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9646 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9647 port_id, RTE_UINT16);
9648 static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9649 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9651 static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9652 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9653 vf_mask, RTE_UINT64);
9655 static cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9656 .f = cmd_vf_rx_vlan_filter_parsed,
9658 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9659 "(vf_mask = hexadecimal VF mask)",
9661 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9662 (void *)&cmd_vf_rx_vlan_filter_what,
9663 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9664 (void *)&cmd_vf_rx_vlan_filter_port,
9665 (void *)&cmd_vf_rx_vlan_filter_portid,
9666 (void *)&cmd_vf_rx_vlan_filter_vf,
9667 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9672 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9673 struct cmd_queue_rate_limit_result {
9674 cmdline_fixed_string_t set;
9675 cmdline_fixed_string_t port;
9677 cmdline_fixed_string_t queue;
9679 cmdline_fixed_string_t rate;
9683 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9684 __rte_unused struct cmdline *cl,
9685 __rte_unused void *data)
9687 struct cmd_queue_rate_limit_result *res = parsed_result;
9690 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9691 && (strcmp(res->queue, "queue") == 0)
9692 && (strcmp(res->rate, "rate") == 0))
9693 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9696 fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
9701 static cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9702 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9704 static cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9705 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9707 static cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9708 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9709 port_num, RTE_UINT16);
9710 static cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9711 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9713 static cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9714 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9715 queue_num, RTE_UINT8);
9716 static cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9717 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9719 static cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9720 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9721 rate_num, RTE_UINT16);
9723 static cmdline_parse_inst_t cmd_queue_rate_limit = {
9724 .f = cmd_queue_rate_limit_parsed,
9726 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9727 "Set rate limit for a queue on port_id",
9729 (void *)&cmd_queue_rate_limit_set,
9730 (void *)&cmd_queue_rate_limit_port,
9731 (void *)&cmd_queue_rate_limit_portnum,
9732 (void *)&cmd_queue_rate_limit_queue,
9733 (void *)&cmd_queue_rate_limit_queuenum,
9734 (void *)&cmd_queue_rate_limit_rate,
9735 (void *)&cmd_queue_rate_limit_ratenum,
9740 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9741 struct cmd_vf_rate_limit_result {
9742 cmdline_fixed_string_t set;
9743 cmdline_fixed_string_t port;
9745 cmdline_fixed_string_t vf;
9747 cmdline_fixed_string_t rate;
9749 cmdline_fixed_string_t q_msk;
9753 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9754 __rte_unused struct cmdline *cl,
9755 __rte_unused void *data)
9757 struct cmd_vf_rate_limit_result *res = parsed_result;
9760 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9761 && (strcmp(res->vf, "vf") == 0)
9762 && (strcmp(res->rate, "rate") == 0)
9763 && (strcmp(res->q_msk, "queue_mask") == 0))
9764 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9765 res->rate_num, res->q_msk_val);
9767 fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
9772 static cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9773 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9775 static cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9776 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9778 static cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9779 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9780 port_num, RTE_UINT16);
9781 static cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9782 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9784 static cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9785 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9787 static cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9788 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9790 static cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9791 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9792 rate_num, RTE_UINT16);
9793 static cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9794 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9795 q_msk, "queue_mask");
9796 static cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9797 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9798 q_msk_val, RTE_UINT64);
9800 static cmdline_parse_inst_t cmd_vf_rate_limit = {
9801 .f = cmd_vf_rate_limit_parsed,
9803 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9804 "queue_mask <queue_mask_value>: "
9805 "Set rate limit for queues of VF on port_id",
9807 (void *)&cmd_vf_rate_limit_set,
9808 (void *)&cmd_vf_rate_limit_port,
9809 (void *)&cmd_vf_rate_limit_portnum,
9810 (void *)&cmd_vf_rate_limit_vf,
9811 (void *)&cmd_vf_rate_limit_vfnum,
9812 (void *)&cmd_vf_rate_limit_rate,
9813 (void *)&cmd_vf_rate_limit_ratenum,
9814 (void *)&cmd_vf_rate_limit_q_msk,
9815 (void *)&cmd_vf_rate_limit_q_msk_val,
9820 /* *** CONFIGURE TUNNEL UDP PORT *** */
9821 struct cmd_tunnel_udp_config {
9822 cmdline_fixed_string_t rx_vxlan_port;
9823 cmdline_fixed_string_t what;
9829 cmd_tunnel_udp_config_parsed(void *parsed_result,
9830 __rte_unused struct cmdline *cl,
9831 __rte_unused void *data)
9833 struct cmd_tunnel_udp_config *res = parsed_result;
9834 struct rte_eth_udp_tunnel tunnel_udp;
9837 tunnel_udp.udp_port = res->udp_port;
9838 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9840 if (!strcmp(res->what, "add"))
9841 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9844 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9848 fprintf(stderr, "udp tunneling add error: (%s)\n",
9852 static cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9853 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9854 rx_vxlan_port, "rx_vxlan_port");
9855 static cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9856 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9858 static cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9859 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9860 udp_port, RTE_UINT16);
9861 static cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9862 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9863 port_id, RTE_UINT16);
9865 static cmdline_parse_inst_t cmd_tunnel_udp_config = {
9866 .f = cmd_tunnel_udp_config_parsed,
9868 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9869 "Add/Remove a tunneling UDP port filter",
9871 (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9872 (void *)&cmd_tunnel_udp_config_what,
9873 (void *)&cmd_tunnel_udp_config_udp_port,
9874 (void *)&cmd_tunnel_udp_config_port_id,
9879 struct cmd_config_tunnel_udp_port {
9880 cmdline_fixed_string_t port;
9881 cmdline_fixed_string_t config;
9883 cmdline_fixed_string_t udp_tunnel_port;
9884 cmdline_fixed_string_t action;
9885 cmdline_fixed_string_t tunnel_type;
9890 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9891 __rte_unused struct cmdline *cl,
9892 __rte_unused void *data)
9894 struct cmd_config_tunnel_udp_port *res = parsed_result;
9895 struct rte_eth_udp_tunnel tunnel_udp;
9898 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9901 tunnel_udp.udp_port = res->udp_port;
9903 if (!strcmp(res->tunnel_type, "vxlan")) {
9904 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9905 } else if (!strcmp(res->tunnel_type, "geneve")) {
9906 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_GENEVE;
9907 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9908 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN_GPE;
9909 } else if (!strcmp(res->tunnel_type, "ecpri")) {
9910 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_ECPRI;
9912 fprintf(stderr, "Invalid tunnel type\n");
9916 if (!strcmp(res->action, "add"))
9917 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9920 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9924 fprintf(stderr, "udp tunneling port add error: (%s)\n",
9928 static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9929 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9931 static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9932 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9934 static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9935 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9937 static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9938 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9941 static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9942 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9944 static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9945 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9946 "vxlan#geneve#vxlan-gpe#ecpri");
9947 static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9948 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9951 static cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9952 .f = cmd_cfg_tunnel_udp_port_parsed,
9954 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9955 "geneve|vxlan-gpe|ecpri <udp_port>",
9957 (void *)&cmd_config_tunnel_udp_port_port,
9958 (void *)&cmd_config_tunnel_udp_port_config,
9959 (void *)&cmd_config_tunnel_udp_port_port_id,
9960 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9961 (void *)&cmd_config_tunnel_udp_port_action,
9962 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9963 (void *)&cmd_config_tunnel_udp_port_value,
9968 /* ******************************************************************************** */
9970 struct cmd_dump_result {
9971 cmdline_fixed_string_t dump;
9975 dump_struct_sizes(void)
9977 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9978 DUMP_SIZE(struct rte_mbuf);
9979 DUMP_SIZE(struct rte_mempool);
9980 DUMP_SIZE(struct rte_ring);
9985 /* Dump the socket memory statistics on console */
9987 dump_socket_mem(FILE *f)
9989 struct rte_malloc_socket_stats socket_stats;
9994 unsigned int n_alloc = 0;
9995 unsigned int n_free = 0;
9996 static size_t last_allocs;
9997 static size_t last_total;
10000 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
10001 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
10002 !socket_stats.heap_totalsz_bytes)
10004 total += socket_stats.heap_totalsz_bytes;
10005 alloc += socket_stats.heap_allocsz_bytes;
10006 free += socket_stats.heap_freesz_bytes;
10007 n_alloc += socket_stats.alloc_count;
10008 n_free += socket_stats.free_count;
10010 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
10012 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
10013 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
10014 (double)socket_stats.heap_allocsz_bytes * 100 /
10015 (double)socket_stats.heap_totalsz_bytes,
10016 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
10017 socket_stats.alloc_count,
10018 socket_stats.free_count);
10021 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
10022 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
10023 total ? ((double)alloc * 100 / (double)total) : 0,
10024 (double)free / (1024 * 1024),
10027 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
10028 ((double)total - (double)last_total) / (1024 * 1024),
10029 (double)(alloc - (double)last_allocs) / 1024 / 1024);
10030 last_allocs = alloc;
10031 last_total = total;
10034 static void cmd_dump_parsed(void *parsed_result,
10035 __rte_unused struct cmdline *cl,
10036 __rte_unused void *data)
10038 struct cmd_dump_result *res = parsed_result;
10040 if (!strcmp(res->dump, "dump_physmem"))
10041 rte_dump_physmem_layout(stdout);
10042 else if (!strcmp(res->dump, "dump_socket_mem"))
10043 dump_socket_mem(stdout);
10044 else if (!strcmp(res->dump, "dump_memzone"))
10045 rte_memzone_dump(stdout);
10046 else if (!strcmp(res->dump, "dump_struct_sizes"))
10047 dump_struct_sizes();
10048 else if (!strcmp(res->dump, "dump_ring"))
10049 rte_ring_list_dump(stdout);
10050 else if (!strcmp(res->dump, "dump_mempool"))
10051 rte_mempool_list_dump(stdout);
10052 else if (!strcmp(res->dump, "dump_devargs"))
10053 rte_devargs_dump(stdout);
10054 else if (!strcmp(res->dump, "dump_log_types"))
10055 rte_log_dump(stdout);
10058 static cmdline_parse_token_string_t cmd_dump_dump =
10059 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
10063 "dump_struct_sizes#"
10069 static cmdline_parse_inst_t cmd_dump = {
10070 .f = cmd_dump_parsed, /* function to call */
10071 .data = NULL, /* 2nd arg of func */
10072 .help_str = "Dump status",
10073 .tokens = { /* token list, NULL terminated */
10074 (void *)&cmd_dump_dump,
10079 /* ******************************************************************************** */
10081 struct cmd_dump_one_result {
10082 cmdline_fixed_string_t dump;
10083 cmdline_fixed_string_t name;
10086 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
10087 __rte_unused void *data)
10089 struct cmd_dump_one_result *res = parsed_result;
10091 if (!strcmp(res->dump, "dump_ring")) {
10092 struct rte_ring *r;
10093 r = rte_ring_lookup(res->name);
10095 cmdline_printf(cl, "Cannot find ring\n");
10098 rte_ring_dump(stdout, r);
10099 } else if (!strcmp(res->dump, "dump_mempool")) {
10100 struct rte_mempool *mp;
10101 mp = rte_mempool_lookup(res->name);
10103 cmdline_printf(cl, "Cannot find mempool\n");
10106 rte_mempool_dump(stdout, mp);
10110 static cmdline_parse_token_string_t cmd_dump_one_dump =
10111 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
10112 "dump_ring#dump_mempool");
10114 static cmdline_parse_token_string_t cmd_dump_one_name =
10115 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
10117 static cmdline_parse_inst_t cmd_dump_one = {
10118 .f = cmd_dump_one_parsed, /* function to call */
10119 .data = NULL, /* 2nd arg of func */
10120 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
10121 .tokens = { /* token list, NULL terminated */
10122 (void *)&cmd_dump_one_dump,
10123 (void *)&cmd_dump_one_name,
10128 /* *** queue region set *** */
10129 struct cmd_queue_region_result {
10130 cmdline_fixed_string_t set;
10131 cmdline_fixed_string_t port;
10133 cmdline_fixed_string_t cmd;
10134 cmdline_fixed_string_t region;
10136 cmdline_fixed_string_t queue_start_index;
10138 cmdline_fixed_string_t queue_num;
10139 uint8_t queue_num_value;
10143 cmd_queue_region_parsed(void *parsed_result,
10144 __rte_unused struct cmdline *cl,
10145 __rte_unused void *data)
10147 struct cmd_queue_region_result *res = parsed_result;
10148 int ret = -ENOTSUP;
10149 #ifdef RTE_NET_I40E
10150 struct rte_pmd_i40e_queue_region_conf region_conf;
10151 enum rte_pmd_i40e_queue_region_op op_type;
10154 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10157 #ifdef RTE_NET_I40E
10158 memset(®ion_conf, 0, sizeof(region_conf));
10159 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
10160 region_conf.region_id = res->region_id;
10161 region_conf.queue_num = res->queue_num_value;
10162 region_conf.queue_start_index = res->queue_id;
10164 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10165 op_type, ®ion_conf);
10172 fprintf(stderr, "function not implemented or supported\n");
10175 fprintf(stderr, "queue region config error: (%s)\n",
10180 static cmdline_parse_token_string_t cmd_queue_region_set =
10181 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10183 static cmdline_parse_token_string_t cmd_queue_region_port =
10184 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
10185 static cmdline_parse_token_num_t cmd_queue_region_port_id =
10186 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10187 port_id, RTE_UINT16);
10188 static cmdline_parse_token_string_t cmd_queue_region_cmd =
10189 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10190 cmd, "queue-region");
10191 static cmdline_parse_token_string_t cmd_queue_region_id =
10192 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10193 region, "region_id");
10194 static cmdline_parse_token_num_t cmd_queue_region_index =
10195 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10196 region_id, RTE_UINT8);
10197 static cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
10198 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10199 queue_start_index, "queue_start_index");
10200 static cmdline_parse_token_num_t cmd_queue_region_queue_id =
10201 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10202 queue_id, RTE_UINT8);
10203 static cmdline_parse_token_string_t cmd_queue_region_queue_num =
10204 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10205 queue_num, "queue_num");
10206 static cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
10207 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10208 queue_num_value, RTE_UINT8);
10210 static cmdline_parse_inst_t cmd_queue_region = {
10211 .f = cmd_queue_region_parsed,
10213 .help_str = "set port <port_id> queue-region region_id <value> "
10214 "queue_start_index <value> queue_num <value>: Set a queue region",
10216 (void *)&cmd_queue_region_set,
10217 (void *)&cmd_queue_region_port,
10218 (void *)&cmd_queue_region_port_id,
10219 (void *)&cmd_queue_region_cmd,
10220 (void *)&cmd_queue_region_id,
10221 (void *)&cmd_queue_region_index,
10222 (void *)&cmd_queue_region_queue_start_index,
10223 (void *)&cmd_queue_region_queue_id,
10224 (void *)&cmd_queue_region_queue_num,
10225 (void *)&cmd_queue_region_queue_num_value,
10230 /* *** queue region and flowtype set *** */
10231 struct cmd_region_flowtype_result {
10232 cmdline_fixed_string_t set;
10233 cmdline_fixed_string_t port;
10235 cmdline_fixed_string_t cmd;
10236 cmdline_fixed_string_t region;
10238 cmdline_fixed_string_t flowtype;
10239 uint8_t flowtype_id;
10243 cmd_region_flowtype_parsed(void *parsed_result,
10244 __rte_unused struct cmdline *cl,
10245 __rte_unused void *data)
10247 struct cmd_region_flowtype_result *res = parsed_result;
10248 int ret = -ENOTSUP;
10249 #ifdef RTE_NET_I40E
10250 struct rte_pmd_i40e_queue_region_conf region_conf;
10251 enum rte_pmd_i40e_queue_region_op op_type;
10254 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10257 #ifdef RTE_NET_I40E
10258 memset(®ion_conf, 0, sizeof(region_conf));
10260 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10261 region_conf.region_id = res->region_id;
10262 region_conf.hw_flowtype = res->flowtype_id;
10264 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10265 op_type, ®ion_conf);
10272 fprintf(stderr, "function not implemented or supported\n");
10275 fprintf(stderr, "region flowtype config error: (%s)\n",
10280 static cmdline_parse_token_string_t cmd_region_flowtype_set =
10281 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10283 static cmdline_parse_token_string_t cmd_region_flowtype_port =
10284 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10286 static cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10287 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10288 port_id, RTE_UINT16);
10289 static cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10290 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10291 cmd, "queue-region");
10292 static cmdline_parse_token_string_t cmd_region_flowtype_index =
10293 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10294 region, "region_id");
10295 static cmdline_parse_token_num_t cmd_region_flowtype_id =
10296 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10297 region_id, RTE_UINT8);
10298 static cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10299 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10300 flowtype, "flowtype");
10301 static cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10302 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10303 flowtype_id, RTE_UINT8);
10304 static cmdline_parse_inst_t cmd_region_flowtype = {
10305 .f = cmd_region_flowtype_parsed,
10307 .help_str = "set port <port_id> queue-region region_id <value> "
10308 "flowtype <value>: Set a flowtype region index",
10310 (void *)&cmd_region_flowtype_set,
10311 (void *)&cmd_region_flowtype_port,
10312 (void *)&cmd_region_flowtype_port_index,
10313 (void *)&cmd_region_flowtype_cmd,
10314 (void *)&cmd_region_flowtype_index,
10315 (void *)&cmd_region_flowtype_id,
10316 (void *)&cmd_region_flowtype_flow_index,
10317 (void *)&cmd_region_flowtype_flow_id,
10322 /* *** User Priority (UP) to queue region (region_id) set *** */
10323 struct cmd_user_priority_region_result {
10324 cmdline_fixed_string_t set;
10325 cmdline_fixed_string_t port;
10327 cmdline_fixed_string_t cmd;
10328 cmdline_fixed_string_t user_priority;
10329 uint8_t user_priority_id;
10330 cmdline_fixed_string_t region;
10335 cmd_user_priority_region_parsed(void *parsed_result,
10336 __rte_unused struct cmdline *cl,
10337 __rte_unused void *data)
10339 struct cmd_user_priority_region_result *res = parsed_result;
10340 int ret = -ENOTSUP;
10341 #ifdef RTE_NET_I40E
10342 struct rte_pmd_i40e_queue_region_conf region_conf;
10343 enum rte_pmd_i40e_queue_region_op op_type;
10346 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10349 #ifdef RTE_NET_I40E
10350 memset(®ion_conf, 0, sizeof(region_conf));
10351 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10352 region_conf.user_priority = res->user_priority_id;
10353 region_conf.region_id = res->region_id;
10355 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10356 op_type, ®ion_conf);
10363 fprintf(stderr, "function not implemented or supported\n");
10366 fprintf(stderr, "user_priority region config error: (%s)\n",
10371 static cmdline_parse_token_string_t cmd_user_priority_region_set =
10372 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10374 static cmdline_parse_token_string_t cmd_user_priority_region_port =
10375 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10377 static cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10378 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10379 port_id, RTE_UINT16);
10380 static cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10381 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10382 cmd, "queue-region");
10383 static cmdline_parse_token_string_t cmd_user_priority_region_UP =
10384 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10385 user_priority, "UP");
10386 static cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10387 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10388 user_priority_id, RTE_UINT8);
10389 static cmdline_parse_token_string_t cmd_user_priority_region_region =
10390 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10391 region, "region_id");
10392 static cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10393 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10394 region_id, RTE_UINT8);
10396 static cmdline_parse_inst_t cmd_user_priority_region = {
10397 .f = cmd_user_priority_region_parsed,
10399 .help_str = "set port <port_id> queue-region UP <value> "
10400 "region_id <value>: Set the mapping of User Priority (UP) "
10401 "to queue region (region_id) ",
10403 (void *)&cmd_user_priority_region_set,
10404 (void *)&cmd_user_priority_region_port,
10405 (void *)&cmd_user_priority_region_port_index,
10406 (void *)&cmd_user_priority_region_cmd,
10407 (void *)&cmd_user_priority_region_UP,
10408 (void *)&cmd_user_priority_region_UP_id,
10409 (void *)&cmd_user_priority_region_region,
10410 (void *)&cmd_user_priority_region_region_id,
10415 /* *** flush all queue region related configuration *** */
10416 struct cmd_flush_queue_region_result {
10417 cmdline_fixed_string_t set;
10418 cmdline_fixed_string_t port;
10420 cmdline_fixed_string_t cmd;
10421 cmdline_fixed_string_t flush;
10422 cmdline_fixed_string_t what;
10426 cmd_flush_queue_region_parsed(void *parsed_result,
10427 __rte_unused struct cmdline *cl,
10428 __rte_unused void *data)
10430 struct cmd_flush_queue_region_result *res = parsed_result;
10431 int ret = -ENOTSUP;
10432 #ifdef RTE_NET_I40E
10433 struct rte_pmd_i40e_queue_region_conf region_conf;
10434 enum rte_pmd_i40e_queue_region_op op_type;
10437 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10440 #ifdef RTE_NET_I40E
10441 memset(®ion_conf, 0, sizeof(region_conf));
10443 if (strcmp(res->what, "on") == 0)
10444 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10446 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10448 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10449 op_type, ®ion_conf);
10456 fprintf(stderr, "function not implemented or supported\n");
10459 fprintf(stderr, "queue region config flush error: (%s)\n",
10464 static cmdline_parse_token_string_t cmd_flush_queue_region_set =
10465 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10467 static cmdline_parse_token_string_t cmd_flush_queue_region_port =
10468 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10470 static cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10471 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10472 port_id, RTE_UINT16);
10473 static cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10474 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10475 cmd, "queue-region");
10476 static cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10477 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10479 static cmdline_parse_token_string_t cmd_flush_queue_region_what =
10480 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10483 static cmdline_parse_inst_t cmd_flush_queue_region = {
10484 .f = cmd_flush_queue_region_parsed,
10486 .help_str = "set port <port_id> queue-region flush on|off"
10487 ": flush all queue region related configuration",
10489 (void *)&cmd_flush_queue_region_set,
10490 (void *)&cmd_flush_queue_region_port,
10491 (void *)&cmd_flush_queue_region_port_index,
10492 (void *)&cmd_flush_queue_region_cmd,
10493 (void *)&cmd_flush_queue_region_flush,
10494 (void *)&cmd_flush_queue_region_what,
10499 /* *** get all queue region related configuration info *** */
10500 struct cmd_show_queue_region_info {
10501 cmdline_fixed_string_t show;
10502 cmdline_fixed_string_t port;
10504 cmdline_fixed_string_t cmd;
10508 cmd_show_queue_region_info_parsed(void *parsed_result,
10509 __rte_unused struct cmdline *cl,
10510 __rte_unused void *data)
10512 struct cmd_show_queue_region_info *res = parsed_result;
10513 int ret = -ENOTSUP;
10514 #ifdef RTE_NET_I40E
10515 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10516 enum rte_pmd_i40e_queue_region_op op_type;
10519 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10522 #ifdef RTE_NET_I40E
10523 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10525 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10527 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10528 op_type, &rte_pmd_regions);
10530 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10537 fprintf(stderr, "function not implemented or supported\n");
10540 fprintf(stderr, "queue region config info show error: (%s)\n",
10545 static cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10546 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10548 static cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10549 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10551 static cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10552 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10553 port_id, RTE_UINT16);
10554 static cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10555 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10556 cmd, "queue-region");
10558 static cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10559 .f = cmd_show_queue_region_info_parsed,
10561 .help_str = "show port <port_id> queue-region"
10562 ": show all queue region related configuration info",
10564 (void *)&cmd_show_queue_region_info_get,
10565 (void *)&cmd_show_queue_region_info_port,
10566 (void *)&cmd_show_queue_region_info_port_index,
10567 (void *)&cmd_show_queue_region_info_cmd,
10572 /* *** Filters Control *** */
10574 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10576 if ((ip_addr).family == AF_INET) \
10577 (ip) = (ip_addr).addr.ipv4.s_addr; \
10579 fprintf(stderr, "invalid parameter.\n"); \
10584 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10586 if ((ip_addr).family == AF_INET6) \
10587 rte_memcpy(&(ip), \
10588 &((ip_addr).addr.ipv6), \
10589 sizeof(struct in6_addr)); \
10591 fprintf(stderr, "invalid parameter.\n"); \
10596 #ifdef RTE_NET_I40E
10599 str2flowtype(char *string)
10602 static const struct {
10605 } flowtype_str[] = {
10606 {"raw", RTE_ETH_FLOW_RAW},
10607 {"ipv4", RTE_ETH_FLOW_IPV4},
10608 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10609 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10610 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10611 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10612 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10613 {"ipv6", RTE_ETH_FLOW_IPV6},
10614 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10615 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10616 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10617 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10618 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10619 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10620 {"ipv6-ex", RTE_ETH_FLOW_IPV6_EX},
10621 {"ipv6-tcp-ex", RTE_ETH_FLOW_IPV6_TCP_EX},
10622 {"ipv6-udp-ex", RTE_ETH_FLOW_IPV6_UDP_EX},
10623 {"gtpu", RTE_ETH_FLOW_GTPU},
10626 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10627 if (!strcmp(flowtype_str[i].str, string))
10628 return flowtype_str[i].type;
10631 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10632 return (uint16_t)atoi(string);
10634 return RTE_ETH_FLOW_UNKNOWN;
10637 /* *** deal with flow director filter *** */
10638 struct cmd_flow_director_result {
10639 cmdline_fixed_string_t flow_director_filter;
10641 cmdline_fixed_string_t mode;
10642 cmdline_fixed_string_t mode_value;
10643 cmdline_fixed_string_t ops;
10644 cmdline_fixed_string_t flow;
10645 cmdline_fixed_string_t flow_type;
10646 cmdline_fixed_string_t drop;
10647 cmdline_fixed_string_t queue;
10649 cmdline_fixed_string_t fd_id;
10650 uint32_t fd_id_value;
10651 cmdline_fixed_string_t packet;
10656 cmd_flow_director_filter_parsed(void *parsed_result,
10657 __rte_unused struct cmdline *cl,
10658 __rte_unused void *data)
10660 struct cmd_flow_director_result *res = parsed_result;
10662 struct rte_pmd_i40e_flow_type_mapping
10663 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10664 struct rte_pmd_i40e_pkt_template_conf conf;
10665 uint16_t flow_type = str2flowtype(res->flow_type);
10666 uint16_t i, port = res->port_id;
10669 memset(&conf, 0, sizeof(conf));
10671 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10672 fprintf(stderr, "Invalid flow type specified.\n");
10675 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10679 if (mapping[flow_type].pctype == 0ULL) {
10680 fprintf(stderr, "Invalid flow type specified.\n");
10683 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10684 if (mapping[flow_type].pctype & (1ULL << i)) {
10685 conf.input.pctype = i;
10690 conf.input.packet = open_file(res->filepath,
10691 &conf.input.length);
10692 if (!conf.input.packet)
10694 if (!strcmp(res->drop, "drop"))
10695 conf.action.behavior =
10696 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10698 conf.action.behavior =
10699 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10700 conf.action.report_status =
10701 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10702 conf.action.rx_queue = res->queue_id;
10703 conf.soft_id = res->fd_id_value;
10704 add = strcmp(res->ops, "del") ? 1 : 0;
10705 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10709 fprintf(stderr, "flow director config error: (%s)\n",
10711 close_file(conf.input.packet);
10714 static cmdline_parse_token_string_t cmd_flow_director_filter =
10715 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10716 flow_director_filter, "flow_director_filter");
10717 static cmdline_parse_token_num_t cmd_flow_director_port_id =
10718 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10719 port_id, RTE_UINT16);
10720 static cmdline_parse_token_string_t cmd_flow_director_ops =
10721 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10722 ops, "add#del#update");
10723 static cmdline_parse_token_string_t cmd_flow_director_flow =
10724 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10726 static cmdline_parse_token_string_t cmd_flow_director_flow_type =
10727 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10729 static cmdline_parse_token_string_t cmd_flow_director_drop =
10730 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10732 static cmdline_parse_token_string_t cmd_flow_director_queue =
10733 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10735 static cmdline_parse_token_num_t cmd_flow_director_queue_id =
10736 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10737 queue_id, RTE_UINT16);
10738 static cmdline_parse_token_string_t cmd_flow_director_fd_id =
10739 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10741 static cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10742 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10743 fd_id_value, RTE_UINT32);
10745 static cmdline_parse_token_string_t cmd_flow_director_mode =
10746 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10748 static cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10749 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10750 mode_value, "raw");
10751 static cmdline_parse_token_string_t cmd_flow_director_packet =
10752 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10754 static cmdline_parse_token_string_t cmd_flow_director_filepath =
10755 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10758 static cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10759 .f = cmd_flow_director_filter_parsed,
10761 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10762 "director entry on NIC",
10764 (void *)&cmd_flow_director_filter,
10765 (void *)&cmd_flow_director_port_id,
10766 (void *)&cmd_flow_director_mode,
10767 (void *)&cmd_flow_director_mode_raw,
10768 (void *)&cmd_flow_director_ops,
10769 (void *)&cmd_flow_director_flow,
10770 (void *)&cmd_flow_director_flow_type,
10771 (void *)&cmd_flow_director_drop,
10772 (void *)&cmd_flow_director_queue,
10773 (void *)&cmd_flow_director_queue_id,
10774 (void *)&cmd_flow_director_fd_id,
10775 (void *)&cmd_flow_director_fd_id_value,
10776 (void *)&cmd_flow_director_packet,
10777 (void *)&cmd_flow_director_filepath,
10782 #endif /* RTE_NET_I40E */
10784 /* *** deal with flow director mask *** */
10785 struct cmd_flow_director_mask_result {
10786 cmdline_fixed_string_t flow_director_mask;
10788 cmdline_fixed_string_t mode;
10789 cmdline_fixed_string_t mode_value;
10790 cmdline_fixed_string_t vlan;
10791 uint16_t vlan_mask;
10792 cmdline_fixed_string_t src_mask;
10793 cmdline_ipaddr_t ipv4_src;
10794 cmdline_ipaddr_t ipv6_src;
10796 cmdline_fixed_string_t dst_mask;
10797 cmdline_ipaddr_t ipv4_dst;
10798 cmdline_ipaddr_t ipv6_dst;
10800 cmdline_fixed_string_t mac;
10801 uint8_t mac_addr_byte_mask;
10802 cmdline_fixed_string_t tunnel_id;
10803 uint32_t tunnel_id_mask;
10804 cmdline_fixed_string_t tunnel_type;
10805 uint8_t tunnel_type_mask;
10809 cmd_flow_director_mask_parsed(void *parsed_result,
10810 __rte_unused struct cmdline *cl,
10811 __rte_unused void *data)
10813 struct cmd_flow_director_mask_result *res = parsed_result;
10814 struct rte_eth_fdir_masks *mask;
10815 struct rte_port *port;
10817 port = &ports[res->port_id];
10818 /** Check if the port is not started **/
10819 if (port->port_status != RTE_PORT_STOPPED) {
10820 fprintf(stderr, "Please stop port %d first\n", res->port_id);
10824 mask = &port->dev_conf.fdir_conf.mask;
10826 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10827 if (strcmp(res->mode_value, "MAC-VLAN")) {
10828 fprintf(stderr, "Please set mode to MAC-VLAN.\n");
10832 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10833 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10834 if (strcmp(res->mode_value, "Tunnel")) {
10835 fprintf(stderr, "Please set mode to Tunnel.\n");
10839 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10840 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10841 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10842 mask->tunnel_type_mask = res->tunnel_type_mask;
10844 if (strcmp(res->mode_value, "IP")) {
10845 fprintf(stderr, "Please set mode to IP.\n");
10849 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10850 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10851 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10852 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10853 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10854 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10855 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10858 cmd_reconfig_device_queue(res->port_id, 1, 1);
10861 static cmdline_parse_token_string_t cmd_flow_director_mask =
10862 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10863 flow_director_mask, "flow_director_mask");
10864 static cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10865 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10866 port_id, RTE_UINT16);
10867 static cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10868 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10870 static cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10871 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10872 vlan_mask, RTE_UINT16);
10873 static cmdline_parse_token_string_t cmd_flow_director_mask_src =
10874 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10875 src_mask, "src_mask");
10876 static cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10877 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10879 static cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10880 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10882 static cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10883 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10884 port_src, RTE_UINT16);
10885 static cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10886 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10887 dst_mask, "dst_mask");
10888 static cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10889 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10891 static cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10892 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10894 static cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10895 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10896 port_dst, RTE_UINT16);
10898 static cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10899 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10901 static cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10902 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10904 static cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10905 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10906 mode_value, "MAC-VLAN");
10907 static cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10908 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10909 mode_value, "Tunnel");
10910 static cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10911 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10913 static cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10914 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10915 mac_addr_byte_mask, RTE_UINT8);
10916 static cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10917 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10918 tunnel_type, "tunnel-type");
10919 static cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10920 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10921 tunnel_type_mask, RTE_UINT8);
10922 static cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10923 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10924 tunnel_id, "tunnel-id");
10925 static cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10926 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10927 tunnel_id_mask, RTE_UINT32);
10929 static cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10930 .f = cmd_flow_director_mask_parsed,
10932 .help_str = "flow_director_mask ... : "
10933 "Set IP mode flow director's mask on NIC",
10935 (void *)&cmd_flow_director_mask,
10936 (void *)&cmd_flow_director_mask_port_id,
10937 (void *)&cmd_flow_director_mask_mode,
10938 (void *)&cmd_flow_director_mask_mode_ip,
10939 (void *)&cmd_flow_director_mask_vlan,
10940 (void *)&cmd_flow_director_mask_vlan_value,
10941 (void *)&cmd_flow_director_mask_src,
10942 (void *)&cmd_flow_director_mask_ipv4_src,
10943 (void *)&cmd_flow_director_mask_ipv6_src,
10944 (void *)&cmd_flow_director_mask_port_src,
10945 (void *)&cmd_flow_director_mask_dst,
10946 (void *)&cmd_flow_director_mask_ipv4_dst,
10947 (void *)&cmd_flow_director_mask_ipv6_dst,
10948 (void *)&cmd_flow_director_mask_port_dst,
10953 static cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10954 .f = cmd_flow_director_mask_parsed,
10956 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10957 "flow director's mask on NIC",
10959 (void *)&cmd_flow_director_mask,
10960 (void *)&cmd_flow_director_mask_port_id,
10961 (void *)&cmd_flow_director_mask_mode,
10962 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10963 (void *)&cmd_flow_director_mask_vlan,
10964 (void *)&cmd_flow_director_mask_vlan_value,
10969 static cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10970 .f = cmd_flow_director_mask_parsed,
10972 .help_str = "flow_director_mask ... : Set tunnel mode "
10973 "flow director's mask on NIC",
10975 (void *)&cmd_flow_director_mask,
10976 (void *)&cmd_flow_director_mask_port_id,
10977 (void *)&cmd_flow_director_mask_mode,
10978 (void *)&cmd_flow_director_mask_mode_tunnel,
10979 (void *)&cmd_flow_director_mask_vlan,
10980 (void *)&cmd_flow_director_mask_vlan_value,
10981 (void *)&cmd_flow_director_mask_mac,
10982 (void *)&cmd_flow_director_mask_mac_value,
10983 (void *)&cmd_flow_director_mask_tunnel_type,
10984 (void *)&cmd_flow_director_mask_tunnel_type_value,
10985 (void *)&cmd_flow_director_mask_tunnel_id,
10986 (void *)&cmd_flow_director_mask_tunnel_id_value,
10991 /* *** deal with flow director flexible payload configuration *** */
10992 struct cmd_flow_director_flexpayload_result {
10993 cmdline_fixed_string_t flow_director_flexpayload;
10995 cmdline_fixed_string_t payload_layer;
10996 cmdline_fixed_string_t payload_cfg;
11000 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11003 const char *p, *p0 = q_arg;
11005 unsigned long int_fld;
11006 char *str_fld[max_num];
11011 p = strchr(p0, '(');
11015 p0 = strchr(p, ')');
11020 if (size >= sizeof(s))
11023 snprintf(s, sizeof(s), "%.*s", size, p);
11024 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11025 if (ret < 0 || ret > max_num)
11027 for (i = 0; i < ret; i++) {
11029 int_fld = strtoul(str_fld[i], &end, 0);
11030 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11032 offsets[i] = (uint16_t)int_fld;
11038 cmd_flow_director_flxpld_parsed(void *parsed_result,
11039 __rte_unused struct cmdline *cl,
11040 __rte_unused void *data)
11042 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11043 struct rte_eth_flex_payload_cfg flex_cfg;
11044 struct rte_port *port;
11047 port = &ports[res->port_id];
11048 /** Check if the port is not started **/
11049 if (port->port_status != RTE_PORT_STOPPED) {
11050 fprintf(stderr, "Please stop port %d first\n", res->port_id);
11054 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11056 if (!strcmp(res->payload_layer, "raw"))
11057 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11058 else if (!strcmp(res->payload_layer, "l2"))
11059 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11060 else if (!strcmp(res->payload_layer, "l3"))
11061 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11062 else if (!strcmp(res->payload_layer, "l4"))
11063 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11065 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11066 RTE_ETH_FDIR_MAX_FLEXLEN);
11068 fprintf(stderr, "error: Cannot parse flex payload input.\n");
11072 fdir_set_flex_payload(res->port_id, &flex_cfg);
11073 cmd_reconfig_device_queue(res->port_id, 1, 1);
11076 static cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11077 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11078 flow_director_flexpayload,
11079 "flow_director_flex_payload");
11080 static cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11081 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11082 port_id, RTE_UINT16);
11083 static cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11084 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11085 payload_layer, "raw#l2#l3#l4");
11086 static cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11087 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11088 payload_cfg, NULL);
11090 static cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11091 .f = cmd_flow_director_flxpld_parsed,
11093 .help_str = "flow_director_flexpayload ... : "
11094 "Set flow director's flex payload on NIC",
11096 (void *)&cmd_flow_director_flexpayload,
11097 (void *)&cmd_flow_director_flexpayload_port_id,
11098 (void *)&cmd_flow_director_flexpayload_payload_layer,
11099 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11104 /* Generic flow interface command. */
11105 extern cmdline_parse_inst_t cmd_flow;
11107 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
11108 struct cmd_mcast_addr_result {
11109 cmdline_fixed_string_t mcast_addr_cmd;
11110 cmdline_fixed_string_t what;
11112 struct rte_ether_addr mc_addr;
11115 static void cmd_mcast_addr_parsed(void *parsed_result,
11116 __rte_unused struct cmdline *cl,
11117 __rte_unused void *data)
11119 struct cmd_mcast_addr_result *res = parsed_result;
11121 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
11123 "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
11124 RTE_ETHER_ADDR_BYTES(&res->mc_addr));
11127 if (strcmp(res->what, "add") == 0)
11128 mcast_addr_add(res->port_num, &res->mc_addr);
11130 mcast_addr_remove(res->port_num, &res->mc_addr);
11133 static cmdline_parse_token_string_t cmd_mcast_addr_cmd =
11134 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
11135 mcast_addr_cmd, "mcast_addr");
11136 static cmdline_parse_token_string_t cmd_mcast_addr_what =
11137 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
11139 static cmdline_parse_token_num_t cmd_mcast_addr_portnum =
11140 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
11142 static cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
11143 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
11145 static cmdline_parse_inst_t cmd_mcast_addr = {
11146 .f = cmd_mcast_addr_parsed,
11148 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
11149 "Add/Remove multicast MAC address on port_id",
11151 (void *)&cmd_mcast_addr_cmd,
11152 (void *)&cmd_mcast_addr_what,
11153 (void *)&cmd_mcast_addr_portnum,
11154 (void *)&cmd_mcast_addr_addr,
11159 /* vf vlan anti spoof configuration */
11161 /* Common result structure for vf vlan anti spoof */
11162 struct cmd_vf_vlan_anti_spoof_result {
11163 cmdline_fixed_string_t set;
11164 cmdline_fixed_string_t vf;
11165 cmdline_fixed_string_t vlan;
11166 cmdline_fixed_string_t antispoof;
11169 cmdline_fixed_string_t on_off;
11172 /* Common CLI fields for vf vlan anti spoof enable disable */
11173 static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
11174 TOKEN_STRING_INITIALIZER
11175 (struct cmd_vf_vlan_anti_spoof_result,
11177 static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
11178 TOKEN_STRING_INITIALIZER
11179 (struct cmd_vf_vlan_anti_spoof_result,
11181 static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
11182 TOKEN_STRING_INITIALIZER
11183 (struct cmd_vf_vlan_anti_spoof_result,
11185 static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
11186 TOKEN_STRING_INITIALIZER
11187 (struct cmd_vf_vlan_anti_spoof_result,
11188 antispoof, "antispoof");
11189 static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
11190 TOKEN_NUM_INITIALIZER
11191 (struct cmd_vf_vlan_anti_spoof_result,
11192 port_id, RTE_UINT16);
11193 static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
11194 TOKEN_NUM_INITIALIZER
11195 (struct cmd_vf_vlan_anti_spoof_result,
11196 vf_id, RTE_UINT32);
11197 static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11198 TOKEN_STRING_INITIALIZER
11199 (struct cmd_vf_vlan_anti_spoof_result,
11203 cmd_set_vf_vlan_anti_spoof_parsed(
11204 void *parsed_result,
11205 __rte_unused struct cmdline *cl,
11206 __rte_unused void *data)
11208 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
11209 int ret = -ENOTSUP;
11211 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11213 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11216 #ifdef RTE_NET_IXGBE
11217 if (ret == -ENOTSUP)
11218 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11219 res->vf_id, is_on);
11221 #ifdef RTE_NET_I40E
11222 if (ret == -ENOTSUP)
11223 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11224 res->vf_id, is_on);
11226 #ifdef RTE_NET_BNXT
11227 if (ret == -ENOTSUP)
11228 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11229 res->vf_id, is_on);
11236 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11239 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11242 fprintf(stderr, "function not implemented\n");
11245 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11249 static cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11250 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11252 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11254 (void *)&cmd_vf_vlan_anti_spoof_set,
11255 (void *)&cmd_vf_vlan_anti_spoof_vf,
11256 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11257 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11258 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11259 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11260 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11265 /* vf mac anti spoof configuration */
11267 /* Common result structure for vf mac anti spoof */
11268 struct cmd_vf_mac_anti_spoof_result {
11269 cmdline_fixed_string_t set;
11270 cmdline_fixed_string_t vf;
11271 cmdline_fixed_string_t mac;
11272 cmdline_fixed_string_t antispoof;
11275 cmdline_fixed_string_t on_off;
11278 /* Common CLI fields for vf mac anti spoof enable disable */
11279 static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11280 TOKEN_STRING_INITIALIZER
11281 (struct cmd_vf_mac_anti_spoof_result,
11283 static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11284 TOKEN_STRING_INITIALIZER
11285 (struct cmd_vf_mac_anti_spoof_result,
11287 static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11288 TOKEN_STRING_INITIALIZER
11289 (struct cmd_vf_mac_anti_spoof_result,
11291 static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11292 TOKEN_STRING_INITIALIZER
11293 (struct cmd_vf_mac_anti_spoof_result,
11294 antispoof, "antispoof");
11295 static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11296 TOKEN_NUM_INITIALIZER
11297 (struct cmd_vf_mac_anti_spoof_result,
11298 port_id, RTE_UINT16);
11299 static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11300 TOKEN_NUM_INITIALIZER
11301 (struct cmd_vf_mac_anti_spoof_result,
11302 vf_id, RTE_UINT32);
11303 static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11304 TOKEN_STRING_INITIALIZER
11305 (struct cmd_vf_mac_anti_spoof_result,
11309 cmd_set_vf_mac_anti_spoof_parsed(
11310 void *parsed_result,
11311 __rte_unused struct cmdline *cl,
11312 __rte_unused void *data)
11314 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11315 int ret = -ENOTSUP;
11317 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11319 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11322 #ifdef RTE_NET_IXGBE
11323 if (ret == -ENOTSUP)
11324 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11325 res->vf_id, is_on);
11327 #ifdef RTE_NET_I40E
11328 if (ret == -ENOTSUP)
11329 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11330 res->vf_id, is_on);
11332 #ifdef RTE_NET_BNXT
11333 if (ret == -ENOTSUP)
11334 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11335 res->vf_id, is_on);
11342 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11343 res->vf_id, is_on);
11346 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11349 fprintf(stderr, "function not implemented\n");
11352 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11356 static cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11357 .f = cmd_set_vf_mac_anti_spoof_parsed,
11359 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11361 (void *)&cmd_vf_mac_anti_spoof_set,
11362 (void *)&cmd_vf_mac_anti_spoof_vf,
11363 (void *)&cmd_vf_mac_anti_spoof_mac,
11364 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11365 (void *)&cmd_vf_mac_anti_spoof_port_id,
11366 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11367 (void *)&cmd_vf_mac_anti_spoof_on_off,
11372 /* vf vlan strip queue configuration */
11374 /* Common result structure for vf mac anti spoof */
11375 struct cmd_vf_vlan_stripq_result {
11376 cmdline_fixed_string_t set;
11377 cmdline_fixed_string_t vf;
11378 cmdline_fixed_string_t vlan;
11379 cmdline_fixed_string_t stripq;
11382 cmdline_fixed_string_t on_off;
11385 /* Common CLI fields for vf vlan strip enable disable */
11386 static cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11387 TOKEN_STRING_INITIALIZER
11388 (struct cmd_vf_vlan_stripq_result,
11390 static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11391 TOKEN_STRING_INITIALIZER
11392 (struct cmd_vf_vlan_stripq_result,
11394 static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11395 TOKEN_STRING_INITIALIZER
11396 (struct cmd_vf_vlan_stripq_result,
11398 static cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11399 TOKEN_STRING_INITIALIZER
11400 (struct cmd_vf_vlan_stripq_result,
11402 static cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11403 TOKEN_NUM_INITIALIZER
11404 (struct cmd_vf_vlan_stripq_result,
11405 port_id, RTE_UINT16);
11406 static cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11407 TOKEN_NUM_INITIALIZER
11408 (struct cmd_vf_vlan_stripq_result,
11409 vf_id, RTE_UINT16);
11410 static cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11411 TOKEN_STRING_INITIALIZER
11412 (struct cmd_vf_vlan_stripq_result,
11416 cmd_set_vf_vlan_stripq_parsed(
11417 void *parsed_result,
11418 __rte_unused struct cmdline *cl,
11419 __rte_unused void *data)
11421 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11422 int ret = -ENOTSUP;
11424 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11426 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11429 #ifdef RTE_NET_IXGBE
11430 if (ret == -ENOTSUP)
11431 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11432 res->vf_id, is_on);
11434 #ifdef RTE_NET_I40E
11435 if (ret == -ENOTSUP)
11436 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11437 res->vf_id, is_on);
11439 #ifdef RTE_NET_BNXT
11440 if (ret == -ENOTSUP)
11441 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11442 res->vf_id, is_on);
11449 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11450 res->vf_id, is_on);
11453 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11456 fprintf(stderr, "function not implemented\n");
11459 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11463 static cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11464 .f = cmd_set_vf_vlan_stripq_parsed,
11466 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11468 (void *)&cmd_vf_vlan_stripq_set,
11469 (void *)&cmd_vf_vlan_stripq_vf,
11470 (void *)&cmd_vf_vlan_stripq_vlan,
11471 (void *)&cmd_vf_vlan_stripq_stripq,
11472 (void *)&cmd_vf_vlan_stripq_port_id,
11473 (void *)&cmd_vf_vlan_stripq_vf_id,
11474 (void *)&cmd_vf_vlan_stripq_on_off,
11479 /* vf vlan insert configuration */
11481 /* Common result structure for vf vlan insert */
11482 struct cmd_vf_vlan_insert_result {
11483 cmdline_fixed_string_t set;
11484 cmdline_fixed_string_t vf;
11485 cmdline_fixed_string_t vlan;
11486 cmdline_fixed_string_t insert;
11492 /* Common CLI fields for vf vlan insert enable disable */
11493 static cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11494 TOKEN_STRING_INITIALIZER
11495 (struct cmd_vf_vlan_insert_result,
11497 static cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11498 TOKEN_STRING_INITIALIZER
11499 (struct cmd_vf_vlan_insert_result,
11501 static cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11502 TOKEN_STRING_INITIALIZER
11503 (struct cmd_vf_vlan_insert_result,
11505 static cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11506 TOKEN_STRING_INITIALIZER
11507 (struct cmd_vf_vlan_insert_result,
11509 static cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11510 TOKEN_NUM_INITIALIZER
11511 (struct cmd_vf_vlan_insert_result,
11512 port_id, RTE_UINT16);
11513 static cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11514 TOKEN_NUM_INITIALIZER
11515 (struct cmd_vf_vlan_insert_result,
11516 vf_id, RTE_UINT16);
11517 static cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11518 TOKEN_NUM_INITIALIZER
11519 (struct cmd_vf_vlan_insert_result,
11520 vlan_id, RTE_UINT16);
11523 cmd_set_vf_vlan_insert_parsed(
11524 void *parsed_result,
11525 __rte_unused struct cmdline *cl,
11526 __rte_unused void *data)
11528 struct cmd_vf_vlan_insert_result *res = parsed_result;
11529 int ret = -ENOTSUP;
11531 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11534 #ifdef RTE_NET_IXGBE
11535 if (ret == -ENOTSUP)
11536 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11539 #ifdef RTE_NET_I40E
11540 if (ret == -ENOTSUP)
11541 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11544 #ifdef RTE_NET_BNXT
11545 if (ret == -ENOTSUP)
11546 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11554 fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
11555 res->vf_id, res->vlan_id);
11558 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11561 fprintf(stderr, "function not implemented\n");
11564 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11568 static cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11569 .f = cmd_set_vf_vlan_insert_parsed,
11571 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11573 (void *)&cmd_vf_vlan_insert_set,
11574 (void *)&cmd_vf_vlan_insert_vf,
11575 (void *)&cmd_vf_vlan_insert_vlan,
11576 (void *)&cmd_vf_vlan_insert_insert,
11577 (void *)&cmd_vf_vlan_insert_port_id,
11578 (void *)&cmd_vf_vlan_insert_vf_id,
11579 (void *)&cmd_vf_vlan_insert_vlan_id,
11584 /* tx loopback configuration */
11586 /* Common result structure for tx loopback */
11587 struct cmd_tx_loopback_result {
11588 cmdline_fixed_string_t set;
11589 cmdline_fixed_string_t tx;
11590 cmdline_fixed_string_t loopback;
11592 cmdline_fixed_string_t on_off;
11595 /* Common CLI fields for tx loopback enable disable */
11596 static cmdline_parse_token_string_t cmd_tx_loopback_set =
11597 TOKEN_STRING_INITIALIZER
11598 (struct cmd_tx_loopback_result,
11600 static cmdline_parse_token_string_t cmd_tx_loopback_tx =
11601 TOKEN_STRING_INITIALIZER
11602 (struct cmd_tx_loopback_result,
11604 static cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11605 TOKEN_STRING_INITIALIZER
11606 (struct cmd_tx_loopback_result,
11607 loopback, "loopback");
11608 static cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11609 TOKEN_NUM_INITIALIZER
11610 (struct cmd_tx_loopback_result,
11611 port_id, RTE_UINT16);
11612 static cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11613 TOKEN_STRING_INITIALIZER
11614 (struct cmd_tx_loopback_result,
11618 cmd_set_tx_loopback_parsed(
11619 void *parsed_result,
11620 __rte_unused struct cmdline *cl,
11621 __rte_unused void *data)
11623 struct cmd_tx_loopback_result *res = parsed_result;
11624 int ret = -ENOTSUP;
11626 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11628 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11631 #ifdef RTE_NET_IXGBE
11632 if (ret == -ENOTSUP)
11633 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11635 #ifdef RTE_NET_I40E
11636 if (ret == -ENOTSUP)
11637 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11639 #ifdef RTE_NET_BNXT
11640 if (ret == -ENOTSUP)
11641 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11643 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11644 if (ret == -ENOTSUP)
11645 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11652 fprintf(stderr, "invalid is_on %d\n", is_on);
11655 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11658 fprintf(stderr, "function not implemented\n");
11661 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11665 static cmdline_parse_inst_t cmd_set_tx_loopback = {
11666 .f = cmd_set_tx_loopback_parsed,
11668 .help_str = "set tx loopback <port_id> on|off",
11670 (void *)&cmd_tx_loopback_set,
11671 (void *)&cmd_tx_loopback_tx,
11672 (void *)&cmd_tx_loopback_loopback,
11673 (void *)&cmd_tx_loopback_port_id,
11674 (void *)&cmd_tx_loopback_on_off,
11679 /* all queues drop enable configuration */
11681 /* Common result structure for all queues drop enable */
11682 struct cmd_all_queues_drop_en_result {
11683 cmdline_fixed_string_t set;
11684 cmdline_fixed_string_t all;
11685 cmdline_fixed_string_t queues;
11686 cmdline_fixed_string_t drop;
11688 cmdline_fixed_string_t on_off;
11691 /* Common CLI fields for tx loopback enable disable */
11692 static cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11693 TOKEN_STRING_INITIALIZER
11694 (struct cmd_all_queues_drop_en_result,
11696 static cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11697 TOKEN_STRING_INITIALIZER
11698 (struct cmd_all_queues_drop_en_result,
11700 static cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11701 TOKEN_STRING_INITIALIZER
11702 (struct cmd_all_queues_drop_en_result,
11704 static cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11705 TOKEN_STRING_INITIALIZER
11706 (struct cmd_all_queues_drop_en_result,
11708 static cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11709 TOKEN_NUM_INITIALIZER
11710 (struct cmd_all_queues_drop_en_result,
11711 port_id, RTE_UINT16);
11712 static cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11713 TOKEN_STRING_INITIALIZER
11714 (struct cmd_all_queues_drop_en_result,
11718 cmd_set_all_queues_drop_en_parsed(
11719 void *parsed_result,
11720 __rte_unused struct cmdline *cl,
11721 __rte_unused void *data)
11723 struct cmd_all_queues_drop_en_result *res = parsed_result;
11724 int ret = -ENOTSUP;
11725 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11727 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11730 #ifdef RTE_NET_IXGBE
11731 if (ret == -ENOTSUP)
11732 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11734 #ifdef RTE_NET_BNXT
11735 if (ret == -ENOTSUP)
11736 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11742 fprintf(stderr, "invalid is_on %d\n", is_on);
11745 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11748 fprintf(stderr, "function not implemented\n");
11751 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11755 static cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11756 .f = cmd_set_all_queues_drop_en_parsed,
11758 .help_str = "set all queues drop <port_id> on|off",
11760 (void *)&cmd_all_queues_drop_en_set,
11761 (void *)&cmd_all_queues_drop_en_all,
11762 (void *)&cmd_all_queues_drop_en_queues,
11763 (void *)&cmd_all_queues_drop_en_drop,
11764 (void *)&cmd_all_queues_drop_en_port_id,
11765 (void *)&cmd_all_queues_drop_en_on_off,
11770 /* vf split drop enable configuration */
11772 /* Common result structure for vf split drop enable */
11773 struct cmd_vf_split_drop_en_result {
11774 cmdline_fixed_string_t set;
11775 cmdline_fixed_string_t vf;
11776 cmdline_fixed_string_t split;
11777 cmdline_fixed_string_t drop;
11780 cmdline_fixed_string_t on_off;
11783 /* Common CLI fields for vf split drop enable disable */
11784 static cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11785 TOKEN_STRING_INITIALIZER
11786 (struct cmd_vf_split_drop_en_result,
11788 static cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11789 TOKEN_STRING_INITIALIZER
11790 (struct cmd_vf_split_drop_en_result,
11792 static cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11793 TOKEN_STRING_INITIALIZER
11794 (struct cmd_vf_split_drop_en_result,
11796 static cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11797 TOKEN_STRING_INITIALIZER
11798 (struct cmd_vf_split_drop_en_result,
11800 static cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11801 TOKEN_NUM_INITIALIZER
11802 (struct cmd_vf_split_drop_en_result,
11803 port_id, RTE_UINT16);
11804 static cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11805 TOKEN_NUM_INITIALIZER
11806 (struct cmd_vf_split_drop_en_result,
11807 vf_id, RTE_UINT16);
11808 static cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11809 TOKEN_STRING_INITIALIZER
11810 (struct cmd_vf_split_drop_en_result,
11814 cmd_set_vf_split_drop_en_parsed(
11815 void *parsed_result,
11816 __rte_unused struct cmdline *cl,
11817 __rte_unused void *data)
11819 struct cmd_vf_split_drop_en_result *res = parsed_result;
11820 int ret = -ENOTSUP;
11821 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11823 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11826 #ifdef RTE_NET_IXGBE
11827 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11834 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11835 res->vf_id, is_on);
11838 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11841 fprintf(stderr, "not supported on port %d\n", res->port_id);
11844 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11848 static cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11849 .f = cmd_set_vf_split_drop_en_parsed,
11851 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11853 (void *)&cmd_vf_split_drop_en_set,
11854 (void *)&cmd_vf_split_drop_en_vf,
11855 (void *)&cmd_vf_split_drop_en_split,
11856 (void *)&cmd_vf_split_drop_en_drop,
11857 (void *)&cmd_vf_split_drop_en_port_id,
11858 (void *)&cmd_vf_split_drop_en_vf_id,
11859 (void *)&cmd_vf_split_drop_en_on_off,
11864 /* vf mac address configuration */
11866 /* Common result structure for vf mac address */
11867 struct cmd_set_vf_mac_addr_result {
11868 cmdline_fixed_string_t set;
11869 cmdline_fixed_string_t vf;
11870 cmdline_fixed_string_t mac;
11871 cmdline_fixed_string_t addr;
11874 struct rte_ether_addr mac_addr;
11878 /* Common CLI fields for vf split drop enable disable */
11879 static cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11880 TOKEN_STRING_INITIALIZER
11881 (struct cmd_set_vf_mac_addr_result,
11883 static cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11884 TOKEN_STRING_INITIALIZER
11885 (struct cmd_set_vf_mac_addr_result,
11887 static cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11888 TOKEN_STRING_INITIALIZER
11889 (struct cmd_set_vf_mac_addr_result,
11891 static cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11892 TOKEN_STRING_INITIALIZER
11893 (struct cmd_set_vf_mac_addr_result,
11895 static cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11896 TOKEN_NUM_INITIALIZER
11897 (struct cmd_set_vf_mac_addr_result,
11898 port_id, RTE_UINT16);
11899 static cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11900 TOKEN_NUM_INITIALIZER
11901 (struct cmd_set_vf_mac_addr_result,
11902 vf_id, RTE_UINT16);
11903 static cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11904 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11908 cmd_set_vf_mac_addr_parsed(
11909 void *parsed_result,
11910 __rte_unused struct cmdline *cl,
11911 __rte_unused void *data)
11913 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11914 int ret = -ENOTSUP;
11916 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11919 #ifdef RTE_NET_IXGBE
11920 if (ret == -ENOTSUP)
11921 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11924 #ifdef RTE_NET_I40E
11925 if (ret == -ENOTSUP)
11926 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11929 #ifdef RTE_NET_BNXT
11930 if (ret == -ENOTSUP)
11931 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11939 fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
11942 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11945 fprintf(stderr, "function not implemented\n");
11948 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11952 static cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11953 .f = cmd_set_vf_mac_addr_parsed,
11955 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11957 (void *)&cmd_set_vf_mac_addr_set,
11958 (void *)&cmd_set_vf_mac_addr_vf,
11959 (void *)&cmd_set_vf_mac_addr_mac,
11960 (void *)&cmd_set_vf_mac_addr_addr,
11961 (void *)&cmd_set_vf_mac_addr_port_id,
11962 (void *)&cmd_set_vf_mac_addr_vf_id,
11963 (void *)&cmd_set_vf_mac_addr_mac_addr,
11968 /* MACsec configuration */
11970 /* Common result structure for MACsec offload enable */
11971 struct cmd_macsec_offload_on_result {
11972 cmdline_fixed_string_t set;
11973 cmdline_fixed_string_t macsec;
11974 cmdline_fixed_string_t offload;
11976 cmdline_fixed_string_t on;
11977 cmdline_fixed_string_t encrypt;
11978 cmdline_fixed_string_t en_on_off;
11979 cmdline_fixed_string_t replay_protect;
11980 cmdline_fixed_string_t rp_on_off;
11983 /* Common CLI fields for MACsec offload disable */
11984 static cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11985 TOKEN_STRING_INITIALIZER
11986 (struct cmd_macsec_offload_on_result,
11988 static cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11989 TOKEN_STRING_INITIALIZER
11990 (struct cmd_macsec_offload_on_result,
11992 static cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11993 TOKEN_STRING_INITIALIZER
11994 (struct cmd_macsec_offload_on_result,
11995 offload, "offload");
11996 static cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11997 TOKEN_NUM_INITIALIZER
11998 (struct cmd_macsec_offload_on_result,
11999 port_id, RTE_UINT16);
12000 static cmdline_parse_token_string_t cmd_macsec_offload_on_on =
12001 TOKEN_STRING_INITIALIZER
12002 (struct cmd_macsec_offload_on_result,
12004 static cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
12005 TOKEN_STRING_INITIALIZER
12006 (struct cmd_macsec_offload_on_result,
12007 encrypt, "encrypt");
12008 static cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
12009 TOKEN_STRING_INITIALIZER
12010 (struct cmd_macsec_offload_on_result,
12011 en_on_off, "on#off");
12012 static cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
12013 TOKEN_STRING_INITIALIZER
12014 (struct cmd_macsec_offload_on_result,
12015 replay_protect, "replay-protect");
12016 static cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
12017 TOKEN_STRING_INITIALIZER
12018 (struct cmd_macsec_offload_on_result,
12019 rp_on_off, "on#off");
12022 cmd_set_macsec_offload_on_parsed(
12023 void *parsed_result,
12024 __rte_unused struct cmdline *cl,
12025 __rte_unused void *data)
12027 struct cmd_macsec_offload_on_result *res = parsed_result;
12028 int ret = -ENOTSUP;
12029 portid_t port_id = res->port_id;
12030 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
12031 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
12032 struct rte_eth_dev_info dev_info;
12034 if (port_id_is_invalid(port_id, ENABLED_WARN))
12036 if (!port_is_stopped(port_id)) {
12037 fprintf(stderr, "Please stop port %d first\n", port_id);
12041 ret = eth_dev_info_get_print_err(port_id, &dev_info);
12045 if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) {
12046 #ifdef RTE_NET_IXGBE
12047 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
12055 ports[port_id].dev_conf.txmode.offloads |=
12056 RTE_ETH_TX_OFFLOAD_MACSEC_INSERT;
12057 cmd_reconfig_device_queue(port_id, 1, 1);
12060 fprintf(stderr, "invalid port_id %d\n", port_id);
12063 fprintf(stderr, "not supported on port %d\n", port_id);
12066 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12070 static cmdline_parse_inst_t cmd_set_macsec_offload_on = {
12071 .f = cmd_set_macsec_offload_on_parsed,
12073 .help_str = "set macsec offload <port_id> on "
12074 "encrypt on|off replay-protect on|off",
12076 (void *)&cmd_macsec_offload_on_set,
12077 (void *)&cmd_macsec_offload_on_macsec,
12078 (void *)&cmd_macsec_offload_on_offload,
12079 (void *)&cmd_macsec_offload_on_port_id,
12080 (void *)&cmd_macsec_offload_on_on,
12081 (void *)&cmd_macsec_offload_on_encrypt,
12082 (void *)&cmd_macsec_offload_on_en_on_off,
12083 (void *)&cmd_macsec_offload_on_replay_protect,
12084 (void *)&cmd_macsec_offload_on_rp_on_off,
12089 /* Common result structure for MACsec offload disable */
12090 struct cmd_macsec_offload_off_result {
12091 cmdline_fixed_string_t set;
12092 cmdline_fixed_string_t macsec;
12093 cmdline_fixed_string_t offload;
12095 cmdline_fixed_string_t off;
12098 /* Common CLI fields for MACsec offload disable */
12099 static cmdline_parse_token_string_t cmd_macsec_offload_off_set =
12100 TOKEN_STRING_INITIALIZER
12101 (struct cmd_macsec_offload_off_result,
12103 static cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
12104 TOKEN_STRING_INITIALIZER
12105 (struct cmd_macsec_offload_off_result,
12107 static cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
12108 TOKEN_STRING_INITIALIZER
12109 (struct cmd_macsec_offload_off_result,
12110 offload, "offload");
12111 static cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
12112 TOKEN_NUM_INITIALIZER
12113 (struct cmd_macsec_offload_off_result,
12114 port_id, RTE_UINT16);
12115 static cmdline_parse_token_string_t cmd_macsec_offload_off_off =
12116 TOKEN_STRING_INITIALIZER
12117 (struct cmd_macsec_offload_off_result,
12121 cmd_set_macsec_offload_off_parsed(
12122 void *parsed_result,
12123 __rte_unused struct cmdline *cl,
12124 __rte_unused void *data)
12126 struct cmd_macsec_offload_off_result *res = parsed_result;
12127 int ret = -ENOTSUP;
12128 struct rte_eth_dev_info dev_info;
12129 portid_t port_id = res->port_id;
12131 if (port_id_is_invalid(port_id, ENABLED_WARN))
12133 if (!port_is_stopped(port_id)) {
12134 fprintf(stderr, "Please stop port %d first\n", port_id);
12138 ret = eth_dev_info_get_print_err(port_id, &dev_info);
12142 if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) {
12143 #ifdef RTE_NET_IXGBE
12144 ret = rte_pmd_ixgbe_macsec_disable(port_id);
12149 ports[port_id].dev_conf.txmode.offloads &=
12150 ~RTE_ETH_TX_OFFLOAD_MACSEC_INSERT;
12151 cmd_reconfig_device_queue(port_id, 1, 1);
12154 fprintf(stderr, "invalid port_id %d\n", port_id);
12157 fprintf(stderr, "not supported on port %d\n", port_id);
12160 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12164 static cmdline_parse_inst_t cmd_set_macsec_offload_off = {
12165 .f = cmd_set_macsec_offload_off_parsed,
12167 .help_str = "set macsec offload <port_id> off",
12169 (void *)&cmd_macsec_offload_off_set,
12170 (void *)&cmd_macsec_offload_off_macsec,
12171 (void *)&cmd_macsec_offload_off_offload,
12172 (void *)&cmd_macsec_offload_off_port_id,
12173 (void *)&cmd_macsec_offload_off_off,
12178 /* Common result structure for MACsec secure connection configure */
12179 struct cmd_macsec_sc_result {
12180 cmdline_fixed_string_t set;
12181 cmdline_fixed_string_t macsec;
12182 cmdline_fixed_string_t sc;
12183 cmdline_fixed_string_t tx_rx;
12185 struct rte_ether_addr mac;
12189 /* Common CLI fields for MACsec secure connection configure */
12190 static cmdline_parse_token_string_t cmd_macsec_sc_set =
12191 TOKEN_STRING_INITIALIZER
12192 (struct cmd_macsec_sc_result,
12194 static cmdline_parse_token_string_t cmd_macsec_sc_macsec =
12195 TOKEN_STRING_INITIALIZER
12196 (struct cmd_macsec_sc_result,
12198 static cmdline_parse_token_string_t cmd_macsec_sc_sc =
12199 TOKEN_STRING_INITIALIZER
12200 (struct cmd_macsec_sc_result,
12202 static cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
12203 TOKEN_STRING_INITIALIZER
12204 (struct cmd_macsec_sc_result,
12206 static cmdline_parse_token_num_t cmd_macsec_sc_port_id =
12207 TOKEN_NUM_INITIALIZER
12208 (struct cmd_macsec_sc_result,
12209 port_id, RTE_UINT16);
12210 static cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
12211 TOKEN_ETHERADDR_INITIALIZER
12212 (struct cmd_macsec_sc_result,
12214 static cmdline_parse_token_num_t cmd_macsec_sc_pi =
12215 TOKEN_NUM_INITIALIZER
12216 (struct cmd_macsec_sc_result,
12220 cmd_set_macsec_sc_parsed(
12221 void *parsed_result,
12222 __rte_unused struct cmdline *cl,
12223 __rte_unused void *data)
12225 struct cmd_macsec_sc_result *res = parsed_result;
12226 int ret = -ENOTSUP;
12227 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12229 #ifdef RTE_NET_IXGBE
12231 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12232 res->mac.addr_bytes) :
12233 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12234 res->mac.addr_bytes, res->pi);
12236 RTE_SET_USED(is_tx);
12242 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12245 fprintf(stderr, "not supported on port %d\n", res->port_id);
12248 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12252 static cmdline_parse_inst_t cmd_set_macsec_sc = {
12253 .f = cmd_set_macsec_sc_parsed,
12255 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12257 (void *)&cmd_macsec_sc_set,
12258 (void *)&cmd_macsec_sc_macsec,
12259 (void *)&cmd_macsec_sc_sc,
12260 (void *)&cmd_macsec_sc_tx_rx,
12261 (void *)&cmd_macsec_sc_port_id,
12262 (void *)&cmd_macsec_sc_mac,
12263 (void *)&cmd_macsec_sc_pi,
12268 /* Common result structure for MACsec secure connection configure */
12269 struct cmd_macsec_sa_result {
12270 cmdline_fixed_string_t set;
12271 cmdline_fixed_string_t macsec;
12272 cmdline_fixed_string_t sa;
12273 cmdline_fixed_string_t tx_rx;
12278 cmdline_fixed_string_t key;
12281 /* Common CLI fields for MACsec secure connection configure */
12282 static cmdline_parse_token_string_t cmd_macsec_sa_set =
12283 TOKEN_STRING_INITIALIZER
12284 (struct cmd_macsec_sa_result,
12286 static cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12287 TOKEN_STRING_INITIALIZER
12288 (struct cmd_macsec_sa_result,
12290 static cmdline_parse_token_string_t cmd_macsec_sa_sa =
12291 TOKEN_STRING_INITIALIZER
12292 (struct cmd_macsec_sa_result,
12294 static cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12295 TOKEN_STRING_INITIALIZER
12296 (struct cmd_macsec_sa_result,
12298 static cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12299 TOKEN_NUM_INITIALIZER
12300 (struct cmd_macsec_sa_result,
12301 port_id, RTE_UINT16);
12302 static cmdline_parse_token_num_t cmd_macsec_sa_idx =
12303 TOKEN_NUM_INITIALIZER
12304 (struct cmd_macsec_sa_result,
12306 static cmdline_parse_token_num_t cmd_macsec_sa_an =
12307 TOKEN_NUM_INITIALIZER
12308 (struct cmd_macsec_sa_result,
12310 static cmdline_parse_token_num_t cmd_macsec_sa_pn =
12311 TOKEN_NUM_INITIALIZER
12312 (struct cmd_macsec_sa_result,
12314 static cmdline_parse_token_string_t cmd_macsec_sa_key =
12315 TOKEN_STRING_INITIALIZER
12316 (struct cmd_macsec_sa_result,
12320 cmd_set_macsec_sa_parsed(
12321 void *parsed_result,
12322 __rte_unused struct cmdline *cl,
12323 __rte_unused void *data)
12325 struct cmd_macsec_sa_result *res = parsed_result;
12326 int ret = -ENOTSUP;
12327 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12328 uint8_t key[16] = { 0 };
12334 key_len = strlen(res->key) / 2;
12338 for (i = 0; i < key_len; i++) {
12339 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12342 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12345 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12348 #ifdef RTE_NET_IXGBE
12350 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12351 res->idx, res->an, res->pn, key) :
12352 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12353 res->idx, res->an, res->pn, key);
12355 RTE_SET_USED(is_tx);
12362 fprintf(stderr, "invalid idx %d or an %d\n", res->idx, res->an);
12365 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12368 fprintf(stderr, "not supported on port %d\n", res->port_id);
12371 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12375 static cmdline_parse_inst_t cmd_set_macsec_sa = {
12376 .f = cmd_set_macsec_sa_parsed,
12378 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12380 (void *)&cmd_macsec_sa_set,
12381 (void *)&cmd_macsec_sa_macsec,
12382 (void *)&cmd_macsec_sa_sa,
12383 (void *)&cmd_macsec_sa_tx_rx,
12384 (void *)&cmd_macsec_sa_port_id,
12385 (void *)&cmd_macsec_sa_idx,
12386 (void *)&cmd_macsec_sa_an,
12387 (void *)&cmd_macsec_sa_pn,
12388 (void *)&cmd_macsec_sa_key,
12393 /* VF unicast promiscuous mode configuration */
12395 /* Common result structure for VF unicast promiscuous mode */
12396 struct cmd_vf_promisc_result {
12397 cmdline_fixed_string_t set;
12398 cmdline_fixed_string_t vf;
12399 cmdline_fixed_string_t promisc;
12402 cmdline_fixed_string_t on_off;
12405 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12406 static cmdline_parse_token_string_t cmd_vf_promisc_set =
12407 TOKEN_STRING_INITIALIZER
12408 (struct cmd_vf_promisc_result,
12410 static cmdline_parse_token_string_t cmd_vf_promisc_vf =
12411 TOKEN_STRING_INITIALIZER
12412 (struct cmd_vf_promisc_result,
12414 static cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12415 TOKEN_STRING_INITIALIZER
12416 (struct cmd_vf_promisc_result,
12417 promisc, "promisc");
12418 static cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12419 TOKEN_NUM_INITIALIZER
12420 (struct cmd_vf_promisc_result,
12421 port_id, RTE_UINT16);
12422 static cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12423 TOKEN_NUM_INITIALIZER
12424 (struct cmd_vf_promisc_result,
12425 vf_id, RTE_UINT32);
12426 static cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12427 TOKEN_STRING_INITIALIZER
12428 (struct cmd_vf_promisc_result,
12432 cmd_set_vf_promisc_parsed(
12433 void *parsed_result,
12434 __rte_unused struct cmdline *cl,
12435 __rte_unused void *data)
12437 struct cmd_vf_promisc_result *res = parsed_result;
12438 int ret = -ENOTSUP;
12440 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12442 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12445 #ifdef RTE_NET_I40E
12446 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12447 res->vf_id, is_on);
12454 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12457 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12460 fprintf(stderr, "function not implemented\n");
12463 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12467 static cmdline_parse_inst_t cmd_set_vf_promisc = {
12468 .f = cmd_set_vf_promisc_parsed,
12470 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12471 "Set unicast promiscuous mode for a VF from the PF",
12473 (void *)&cmd_vf_promisc_set,
12474 (void *)&cmd_vf_promisc_vf,
12475 (void *)&cmd_vf_promisc_promisc,
12476 (void *)&cmd_vf_promisc_port_id,
12477 (void *)&cmd_vf_promisc_vf_id,
12478 (void *)&cmd_vf_promisc_on_off,
12483 /* VF multicast promiscuous mode configuration */
12485 /* Common result structure for VF multicast promiscuous mode */
12486 struct cmd_vf_allmulti_result {
12487 cmdline_fixed_string_t set;
12488 cmdline_fixed_string_t vf;
12489 cmdline_fixed_string_t allmulti;
12492 cmdline_fixed_string_t on_off;
12495 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12496 static cmdline_parse_token_string_t cmd_vf_allmulti_set =
12497 TOKEN_STRING_INITIALIZER
12498 (struct cmd_vf_allmulti_result,
12500 static cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12501 TOKEN_STRING_INITIALIZER
12502 (struct cmd_vf_allmulti_result,
12504 static cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12505 TOKEN_STRING_INITIALIZER
12506 (struct cmd_vf_allmulti_result,
12507 allmulti, "allmulti");
12508 static cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12509 TOKEN_NUM_INITIALIZER
12510 (struct cmd_vf_allmulti_result,
12511 port_id, RTE_UINT16);
12512 static cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12513 TOKEN_NUM_INITIALIZER
12514 (struct cmd_vf_allmulti_result,
12515 vf_id, RTE_UINT32);
12516 static cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12517 TOKEN_STRING_INITIALIZER
12518 (struct cmd_vf_allmulti_result,
12522 cmd_set_vf_allmulti_parsed(
12523 void *parsed_result,
12524 __rte_unused struct cmdline *cl,
12525 __rte_unused void *data)
12527 struct cmd_vf_allmulti_result *res = parsed_result;
12528 int ret = -ENOTSUP;
12530 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12532 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12535 #ifdef RTE_NET_I40E
12536 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12537 res->vf_id, is_on);
12544 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12547 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12550 fprintf(stderr, "function not implemented\n");
12553 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12557 static cmdline_parse_inst_t cmd_set_vf_allmulti = {
12558 .f = cmd_set_vf_allmulti_parsed,
12560 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12561 "Set multicast promiscuous mode for a VF from the PF",
12563 (void *)&cmd_vf_allmulti_set,
12564 (void *)&cmd_vf_allmulti_vf,
12565 (void *)&cmd_vf_allmulti_allmulti,
12566 (void *)&cmd_vf_allmulti_port_id,
12567 (void *)&cmd_vf_allmulti_vf_id,
12568 (void *)&cmd_vf_allmulti_on_off,
12573 /* vf broadcast mode configuration */
12575 /* Common result structure for vf broadcast */
12576 struct cmd_set_vf_broadcast_result {
12577 cmdline_fixed_string_t set;
12578 cmdline_fixed_string_t vf;
12579 cmdline_fixed_string_t broadcast;
12582 cmdline_fixed_string_t on_off;
12585 /* Common CLI fields for vf broadcast enable disable */
12586 static cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12587 TOKEN_STRING_INITIALIZER
12588 (struct cmd_set_vf_broadcast_result,
12590 static cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12591 TOKEN_STRING_INITIALIZER
12592 (struct cmd_set_vf_broadcast_result,
12594 static cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12595 TOKEN_STRING_INITIALIZER
12596 (struct cmd_set_vf_broadcast_result,
12597 broadcast, "broadcast");
12598 static cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12599 TOKEN_NUM_INITIALIZER
12600 (struct cmd_set_vf_broadcast_result,
12601 port_id, RTE_UINT16);
12602 static cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12603 TOKEN_NUM_INITIALIZER
12604 (struct cmd_set_vf_broadcast_result,
12605 vf_id, RTE_UINT16);
12606 static cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12607 TOKEN_STRING_INITIALIZER
12608 (struct cmd_set_vf_broadcast_result,
12612 cmd_set_vf_broadcast_parsed(
12613 void *parsed_result,
12614 __rte_unused struct cmdline *cl,
12615 __rte_unused void *data)
12617 struct cmd_set_vf_broadcast_result *res = parsed_result;
12618 int ret = -ENOTSUP;
12620 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12622 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12625 #ifdef RTE_NET_I40E
12626 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12627 res->vf_id, is_on);
12634 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12635 res->vf_id, is_on);
12638 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12641 fprintf(stderr, "function not implemented\n");
12644 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12648 static cmdline_parse_inst_t cmd_set_vf_broadcast = {
12649 .f = cmd_set_vf_broadcast_parsed,
12651 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12653 (void *)&cmd_set_vf_broadcast_set,
12654 (void *)&cmd_set_vf_broadcast_vf,
12655 (void *)&cmd_set_vf_broadcast_broadcast,
12656 (void *)&cmd_set_vf_broadcast_port_id,
12657 (void *)&cmd_set_vf_broadcast_vf_id,
12658 (void *)&cmd_set_vf_broadcast_on_off,
12663 /* vf vlan tag configuration */
12665 /* Common result structure for vf vlan tag */
12666 struct cmd_set_vf_vlan_tag_result {
12667 cmdline_fixed_string_t set;
12668 cmdline_fixed_string_t vf;
12669 cmdline_fixed_string_t vlan;
12670 cmdline_fixed_string_t tag;
12673 cmdline_fixed_string_t on_off;
12676 /* Common CLI fields for vf vlan tag enable disable */
12677 static cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12678 TOKEN_STRING_INITIALIZER
12679 (struct cmd_set_vf_vlan_tag_result,
12681 static cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12682 TOKEN_STRING_INITIALIZER
12683 (struct cmd_set_vf_vlan_tag_result,
12685 static cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12686 TOKEN_STRING_INITIALIZER
12687 (struct cmd_set_vf_vlan_tag_result,
12689 static cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12690 TOKEN_STRING_INITIALIZER
12691 (struct cmd_set_vf_vlan_tag_result,
12693 static cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12694 TOKEN_NUM_INITIALIZER
12695 (struct cmd_set_vf_vlan_tag_result,
12696 port_id, RTE_UINT16);
12697 static cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12698 TOKEN_NUM_INITIALIZER
12699 (struct cmd_set_vf_vlan_tag_result,
12700 vf_id, RTE_UINT16);
12701 static cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12702 TOKEN_STRING_INITIALIZER
12703 (struct cmd_set_vf_vlan_tag_result,
12707 cmd_set_vf_vlan_tag_parsed(
12708 void *parsed_result,
12709 __rte_unused struct cmdline *cl,
12710 __rte_unused void *data)
12712 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12713 int ret = -ENOTSUP;
12715 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12717 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12720 #ifdef RTE_NET_I40E
12721 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12722 res->vf_id, is_on);
12729 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12730 res->vf_id, is_on);
12733 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12736 fprintf(stderr, "function not implemented\n");
12739 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12743 static cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12744 .f = cmd_set_vf_vlan_tag_parsed,
12746 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12748 (void *)&cmd_set_vf_vlan_tag_set,
12749 (void *)&cmd_set_vf_vlan_tag_vf,
12750 (void *)&cmd_set_vf_vlan_tag_vlan,
12751 (void *)&cmd_set_vf_vlan_tag_tag,
12752 (void *)&cmd_set_vf_vlan_tag_port_id,
12753 (void *)&cmd_set_vf_vlan_tag_vf_id,
12754 (void *)&cmd_set_vf_vlan_tag_on_off,
12759 /* Common definition of VF and TC TX bandwidth configuration */
12760 struct cmd_vf_tc_bw_result {
12761 cmdline_fixed_string_t set;
12762 cmdline_fixed_string_t vf;
12763 cmdline_fixed_string_t tc;
12764 cmdline_fixed_string_t tx;
12765 cmdline_fixed_string_t min_bw;
12766 cmdline_fixed_string_t max_bw;
12767 cmdline_fixed_string_t strict_link_prio;
12772 cmdline_fixed_string_t bw_list;
12776 static cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12777 TOKEN_STRING_INITIALIZER
12778 (struct cmd_vf_tc_bw_result,
12780 static cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12781 TOKEN_STRING_INITIALIZER
12782 (struct cmd_vf_tc_bw_result,
12784 static cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12785 TOKEN_STRING_INITIALIZER
12786 (struct cmd_vf_tc_bw_result,
12788 static cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12789 TOKEN_STRING_INITIALIZER
12790 (struct cmd_vf_tc_bw_result,
12792 static cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12793 TOKEN_STRING_INITIALIZER
12794 (struct cmd_vf_tc_bw_result,
12795 strict_link_prio, "strict-link-priority");
12796 static cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12797 TOKEN_STRING_INITIALIZER
12798 (struct cmd_vf_tc_bw_result,
12799 min_bw, "min-bandwidth");
12800 static cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12801 TOKEN_STRING_INITIALIZER
12802 (struct cmd_vf_tc_bw_result,
12803 max_bw, "max-bandwidth");
12804 static cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12805 TOKEN_NUM_INITIALIZER
12806 (struct cmd_vf_tc_bw_result,
12807 port_id, RTE_UINT16);
12808 static cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12809 TOKEN_NUM_INITIALIZER
12810 (struct cmd_vf_tc_bw_result,
12811 vf_id, RTE_UINT16);
12812 static cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12813 TOKEN_NUM_INITIALIZER
12814 (struct cmd_vf_tc_bw_result,
12816 static cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12817 TOKEN_NUM_INITIALIZER
12818 (struct cmd_vf_tc_bw_result,
12820 static cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12821 TOKEN_STRING_INITIALIZER
12822 (struct cmd_vf_tc_bw_result,
12824 static cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12825 TOKEN_NUM_INITIALIZER
12826 (struct cmd_vf_tc_bw_result,
12827 tc_map, RTE_UINT8);
12829 /* VF max bandwidth setting */
12831 cmd_vf_max_bw_parsed(
12832 void *parsed_result,
12833 __rte_unused struct cmdline *cl,
12834 __rte_unused void *data)
12836 struct cmd_vf_tc_bw_result *res = parsed_result;
12837 int ret = -ENOTSUP;
12839 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12842 #ifdef RTE_NET_I40E
12843 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12844 res->vf_id, res->bw);
12851 fprintf(stderr, "invalid vf_id %d or bandwidth %d\n",
12852 res->vf_id, res->bw);
12855 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12858 fprintf(stderr, "function not implemented\n");
12861 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12865 static cmdline_parse_inst_t cmd_vf_max_bw = {
12866 .f = cmd_vf_max_bw_parsed,
12868 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12870 (void *)&cmd_vf_tc_bw_set,
12871 (void *)&cmd_vf_tc_bw_vf,
12872 (void *)&cmd_vf_tc_bw_tx,
12873 (void *)&cmd_vf_tc_bw_max_bw,
12874 (void *)&cmd_vf_tc_bw_port_id,
12875 (void *)&cmd_vf_tc_bw_vf_id,
12876 (void *)&cmd_vf_tc_bw_bw,
12882 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12887 const char *p, *p0 = str;
12894 p = strchr(p0, '(');
12897 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12901 p0 = strchr(p, ')');
12904 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12908 if (size >= sizeof(s)) {
12910 "The string size exceeds the internal buffer size\n");
12913 snprintf(s, sizeof(s), "%.*s", size, p);
12914 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12916 fprintf(stderr, "Failed to get the bandwidth list.\n");
12920 for (i = 0; i < ret; i++)
12921 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12926 /* TC min bandwidth setting */
12928 cmd_vf_tc_min_bw_parsed(
12929 void *parsed_result,
12930 __rte_unused struct cmdline *cl,
12931 __rte_unused void *data)
12933 struct cmd_vf_tc_bw_result *res = parsed_result;
12936 int ret = -ENOTSUP;
12938 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12941 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12945 #ifdef RTE_NET_I40E
12946 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12954 fprintf(stderr, "invalid vf_id %d or bandwidth\n", res->vf_id);
12957 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12960 fprintf(stderr, "function not implemented\n");
12963 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12967 static cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12968 .f = cmd_vf_tc_min_bw_parsed,
12970 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12971 " <bw1, bw2, ...>",
12973 (void *)&cmd_vf_tc_bw_set,
12974 (void *)&cmd_vf_tc_bw_vf,
12975 (void *)&cmd_vf_tc_bw_tc,
12976 (void *)&cmd_vf_tc_bw_tx,
12977 (void *)&cmd_vf_tc_bw_min_bw,
12978 (void *)&cmd_vf_tc_bw_port_id,
12979 (void *)&cmd_vf_tc_bw_vf_id,
12980 (void *)&cmd_vf_tc_bw_bw_list,
12986 cmd_tc_min_bw_parsed(
12987 void *parsed_result,
12988 __rte_unused struct cmdline *cl,
12989 __rte_unused void *data)
12991 struct cmd_vf_tc_bw_result *res = parsed_result;
12992 struct rte_port *port;
12995 int ret = -ENOTSUP;
12997 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13000 port = &ports[res->port_id];
13001 /** Check if the port is not started **/
13002 if (port->port_status != RTE_PORT_STOPPED) {
13003 fprintf(stderr, "Please stop port %d first\n", res->port_id);
13007 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13011 #ifdef RTE_NET_IXGBE
13012 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
13019 fprintf(stderr, "invalid bandwidth\n");
13022 fprintf(stderr, "invalid port_id %d\n", res->port_id);
13025 fprintf(stderr, "function not implemented\n");
13028 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
13032 static cmdline_parse_inst_t cmd_tc_min_bw = {
13033 .f = cmd_tc_min_bw_parsed,
13035 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
13037 (void *)&cmd_vf_tc_bw_set,
13038 (void *)&cmd_vf_tc_bw_tc,
13039 (void *)&cmd_vf_tc_bw_tx,
13040 (void *)&cmd_vf_tc_bw_min_bw,
13041 (void *)&cmd_vf_tc_bw_port_id,
13042 (void *)&cmd_vf_tc_bw_bw_list,
13047 /* TC max bandwidth setting */
13049 cmd_vf_tc_max_bw_parsed(
13050 void *parsed_result,
13051 __rte_unused struct cmdline *cl,
13052 __rte_unused void *data)
13054 struct cmd_vf_tc_bw_result *res = parsed_result;
13055 int ret = -ENOTSUP;
13057 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13060 #ifdef RTE_NET_I40E
13061 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
13062 res->tc_no, res->bw);
13070 "invalid vf_id %d, tc_no %d or bandwidth %d\n",
13071 res->vf_id, res->tc_no, res->bw);
13074 fprintf(stderr, "invalid port_id %d\n", res->port_id);
13077 fprintf(stderr, "function not implemented\n");
13080 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
13084 static cmdline_parse_inst_t cmd_vf_tc_max_bw = {
13085 .f = cmd_vf_tc_max_bw_parsed,
13087 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
13090 (void *)&cmd_vf_tc_bw_set,
13091 (void *)&cmd_vf_tc_bw_vf,
13092 (void *)&cmd_vf_tc_bw_tc,
13093 (void *)&cmd_vf_tc_bw_tx,
13094 (void *)&cmd_vf_tc_bw_max_bw,
13095 (void *)&cmd_vf_tc_bw_port_id,
13096 (void *)&cmd_vf_tc_bw_vf_id,
13097 (void *)&cmd_vf_tc_bw_tc_no,
13098 (void *)&cmd_vf_tc_bw_bw,
13103 /** Set VXLAN encapsulation details */
13104 struct cmd_set_vxlan_result {
13105 cmdline_fixed_string_t set;
13106 cmdline_fixed_string_t vxlan;
13107 cmdline_fixed_string_t pos_token;
13108 cmdline_fixed_string_t ip_version;
13109 uint32_t vlan_present:1;
13113 cmdline_ipaddr_t ip_src;
13114 cmdline_ipaddr_t ip_dst;
13118 struct rte_ether_addr eth_src;
13119 struct rte_ether_addr eth_dst;
13122 static cmdline_parse_token_string_t cmd_set_vxlan_set =
13123 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
13124 static cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
13125 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
13126 static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
13127 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
13129 static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
13130 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
13131 "vxlan-with-vlan");
13132 static cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
13133 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13135 static cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
13136 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
13138 static cmdline_parse_token_string_t cmd_set_vxlan_vni =
13139 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13141 static cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
13142 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
13143 static cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
13144 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13146 static cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
13147 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
13148 static cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
13149 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13151 static cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
13152 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
13153 static cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
13154 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13156 static cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
13157 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
13158 static cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
13159 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13161 static cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
13162 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
13163 static cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
13164 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13166 static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
13167 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
13168 static cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
13169 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13171 static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
13172 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
13173 static cmdline_parse_token_string_t cmd_set_vxlan_vlan =
13174 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13176 static cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
13177 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
13178 static cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
13179 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13181 static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
13182 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
13183 static cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
13184 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13186 static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
13187 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
13189 static void cmd_set_vxlan_parsed(void *parsed_result,
13190 __rte_unused struct cmdline *cl,
13191 __rte_unused void *data)
13193 struct cmd_set_vxlan_result *res = parsed_result;
13198 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
13201 vxlan_encap_conf.select_tos_ttl = 0;
13202 if (strcmp(res->vxlan, "vxlan") == 0)
13203 vxlan_encap_conf.select_vlan = 0;
13204 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
13205 vxlan_encap_conf.select_vlan = 1;
13206 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
13207 vxlan_encap_conf.select_vlan = 0;
13208 vxlan_encap_conf.select_tos_ttl = 1;
13210 if (strcmp(res->ip_version, "ipv4") == 0)
13211 vxlan_encap_conf.select_ipv4 = 1;
13212 else if (strcmp(res->ip_version, "ipv6") == 0)
13213 vxlan_encap_conf.select_ipv4 = 0;
13216 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
13217 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13218 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13219 vxlan_encap_conf.ip_tos = res->tos;
13220 vxlan_encap_conf.ip_ttl = res->ttl;
13221 if (vxlan_encap_conf.select_ipv4) {
13222 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
13223 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
13225 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
13226 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
13228 if (vxlan_encap_conf.select_vlan)
13229 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13230 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
13231 RTE_ETHER_ADDR_LEN);
13232 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13233 RTE_ETHER_ADDR_LEN);
13236 static cmdline_parse_inst_t cmd_set_vxlan = {
13237 .f = cmd_set_vxlan_parsed,
13239 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
13240 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
13241 " eth-src <eth-src> eth-dst <eth-dst>",
13243 (void *)&cmd_set_vxlan_set,
13244 (void *)&cmd_set_vxlan_vxlan,
13245 (void *)&cmd_set_vxlan_ip_version,
13246 (void *)&cmd_set_vxlan_ip_version_value,
13247 (void *)&cmd_set_vxlan_vni,
13248 (void *)&cmd_set_vxlan_vni_value,
13249 (void *)&cmd_set_vxlan_udp_src,
13250 (void *)&cmd_set_vxlan_udp_src_value,
13251 (void *)&cmd_set_vxlan_udp_dst,
13252 (void *)&cmd_set_vxlan_udp_dst_value,
13253 (void *)&cmd_set_vxlan_ip_src,
13254 (void *)&cmd_set_vxlan_ip_src_value,
13255 (void *)&cmd_set_vxlan_ip_dst,
13256 (void *)&cmd_set_vxlan_ip_dst_value,
13257 (void *)&cmd_set_vxlan_eth_src,
13258 (void *)&cmd_set_vxlan_eth_src_value,
13259 (void *)&cmd_set_vxlan_eth_dst,
13260 (void *)&cmd_set_vxlan_eth_dst_value,
13265 static cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
13266 .f = cmd_set_vxlan_parsed,
13268 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
13269 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
13270 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13271 " eth-dst <eth-dst>",
13273 (void *)&cmd_set_vxlan_set,
13274 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
13275 (void *)&cmd_set_vxlan_ip_version,
13276 (void *)&cmd_set_vxlan_ip_version_value,
13277 (void *)&cmd_set_vxlan_vni,
13278 (void *)&cmd_set_vxlan_vni_value,
13279 (void *)&cmd_set_vxlan_udp_src,
13280 (void *)&cmd_set_vxlan_udp_src_value,
13281 (void *)&cmd_set_vxlan_udp_dst,
13282 (void *)&cmd_set_vxlan_udp_dst_value,
13283 (void *)&cmd_set_vxlan_ip_tos,
13284 (void *)&cmd_set_vxlan_ip_tos_value,
13285 (void *)&cmd_set_vxlan_ip_ttl,
13286 (void *)&cmd_set_vxlan_ip_ttl_value,
13287 (void *)&cmd_set_vxlan_ip_src,
13288 (void *)&cmd_set_vxlan_ip_src_value,
13289 (void *)&cmd_set_vxlan_ip_dst,
13290 (void *)&cmd_set_vxlan_ip_dst_value,
13291 (void *)&cmd_set_vxlan_eth_src,
13292 (void *)&cmd_set_vxlan_eth_src_value,
13293 (void *)&cmd_set_vxlan_eth_dst,
13294 (void *)&cmd_set_vxlan_eth_dst_value,
13299 static cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
13300 .f = cmd_set_vxlan_parsed,
13302 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
13303 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
13304 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
13307 (void *)&cmd_set_vxlan_set,
13308 (void *)&cmd_set_vxlan_vxlan_with_vlan,
13309 (void *)&cmd_set_vxlan_ip_version,
13310 (void *)&cmd_set_vxlan_ip_version_value,
13311 (void *)&cmd_set_vxlan_vni,
13312 (void *)&cmd_set_vxlan_vni_value,
13313 (void *)&cmd_set_vxlan_udp_src,
13314 (void *)&cmd_set_vxlan_udp_src_value,
13315 (void *)&cmd_set_vxlan_udp_dst,
13316 (void *)&cmd_set_vxlan_udp_dst_value,
13317 (void *)&cmd_set_vxlan_ip_src,
13318 (void *)&cmd_set_vxlan_ip_src_value,
13319 (void *)&cmd_set_vxlan_ip_dst,
13320 (void *)&cmd_set_vxlan_ip_dst_value,
13321 (void *)&cmd_set_vxlan_vlan,
13322 (void *)&cmd_set_vxlan_vlan_value,
13323 (void *)&cmd_set_vxlan_eth_src,
13324 (void *)&cmd_set_vxlan_eth_src_value,
13325 (void *)&cmd_set_vxlan_eth_dst,
13326 (void *)&cmd_set_vxlan_eth_dst_value,
13331 /** Set NVGRE encapsulation details */
13332 struct cmd_set_nvgre_result {
13333 cmdline_fixed_string_t set;
13334 cmdline_fixed_string_t nvgre;
13335 cmdline_fixed_string_t pos_token;
13336 cmdline_fixed_string_t ip_version;
13338 cmdline_ipaddr_t ip_src;
13339 cmdline_ipaddr_t ip_dst;
13341 struct rte_ether_addr eth_src;
13342 struct rte_ether_addr eth_dst;
13345 static cmdline_parse_token_string_t cmd_set_nvgre_set =
13346 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
13347 static cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
13348 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
13349 static cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
13350 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
13351 "nvgre-with-vlan");
13352 static cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
13353 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13355 static cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
13356 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
13358 static cmdline_parse_token_string_t cmd_set_nvgre_tni =
13359 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13361 static cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
13362 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
13363 static cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
13364 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13366 static cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
13367 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
13368 static cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
13369 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13371 static cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
13372 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
13373 static cmdline_parse_token_string_t cmd_set_nvgre_vlan =
13374 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13376 static cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
13377 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
13378 static cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
13379 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13381 static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
13382 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
13383 static cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
13384 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13386 static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
13387 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
13389 static void cmd_set_nvgre_parsed(void *parsed_result,
13390 __rte_unused struct cmdline *cl,
13391 __rte_unused void *data)
13393 struct cmd_set_nvgre_result *res = parsed_result;
13395 uint32_t nvgre_tni;
13398 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
13401 if (strcmp(res->nvgre, "nvgre") == 0)
13402 nvgre_encap_conf.select_vlan = 0;
13403 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
13404 nvgre_encap_conf.select_vlan = 1;
13405 if (strcmp(res->ip_version, "ipv4") == 0)
13406 nvgre_encap_conf.select_ipv4 = 1;
13407 else if (strcmp(res->ip_version, "ipv6") == 0)
13408 nvgre_encap_conf.select_ipv4 = 0;
13411 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
13412 if (nvgre_encap_conf.select_ipv4) {
13413 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
13414 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
13416 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
13417 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
13419 if (nvgre_encap_conf.select_vlan)
13420 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13421 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
13422 RTE_ETHER_ADDR_LEN);
13423 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13424 RTE_ETHER_ADDR_LEN);
13427 static cmdline_parse_inst_t cmd_set_nvgre = {
13428 .f = cmd_set_nvgre_parsed,
13430 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
13431 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13432 " eth-dst <eth-dst>",
13434 (void *)&cmd_set_nvgre_set,
13435 (void *)&cmd_set_nvgre_nvgre,
13436 (void *)&cmd_set_nvgre_ip_version,
13437 (void *)&cmd_set_nvgre_ip_version_value,
13438 (void *)&cmd_set_nvgre_tni,
13439 (void *)&cmd_set_nvgre_tni_value,
13440 (void *)&cmd_set_nvgre_ip_src,
13441 (void *)&cmd_set_nvgre_ip_src_value,
13442 (void *)&cmd_set_nvgre_ip_dst,
13443 (void *)&cmd_set_nvgre_ip_dst_value,
13444 (void *)&cmd_set_nvgre_eth_src,
13445 (void *)&cmd_set_nvgre_eth_src_value,
13446 (void *)&cmd_set_nvgre_eth_dst,
13447 (void *)&cmd_set_nvgre_eth_dst_value,
13452 static cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
13453 .f = cmd_set_nvgre_parsed,
13455 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
13456 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13457 " eth-src <eth-src> eth-dst <eth-dst>",
13459 (void *)&cmd_set_nvgre_set,
13460 (void *)&cmd_set_nvgre_nvgre_with_vlan,
13461 (void *)&cmd_set_nvgre_ip_version,
13462 (void *)&cmd_set_nvgre_ip_version_value,
13463 (void *)&cmd_set_nvgre_tni,
13464 (void *)&cmd_set_nvgre_tni_value,
13465 (void *)&cmd_set_nvgre_ip_src,
13466 (void *)&cmd_set_nvgre_ip_src_value,
13467 (void *)&cmd_set_nvgre_ip_dst,
13468 (void *)&cmd_set_nvgre_ip_dst_value,
13469 (void *)&cmd_set_nvgre_vlan,
13470 (void *)&cmd_set_nvgre_vlan_value,
13471 (void *)&cmd_set_nvgre_eth_src,
13472 (void *)&cmd_set_nvgre_eth_src_value,
13473 (void *)&cmd_set_nvgre_eth_dst,
13474 (void *)&cmd_set_nvgre_eth_dst_value,
13479 /** Set L2 encapsulation details */
13480 struct cmd_set_l2_encap_result {
13481 cmdline_fixed_string_t set;
13482 cmdline_fixed_string_t l2_encap;
13483 cmdline_fixed_string_t pos_token;
13484 cmdline_fixed_string_t ip_version;
13485 uint32_t vlan_present:1;
13487 struct rte_ether_addr eth_src;
13488 struct rte_ether_addr eth_dst;
13491 static cmdline_parse_token_string_t cmd_set_l2_encap_set =
13492 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13493 static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13494 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13495 static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13496 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13497 "l2_encap-with-vlan");
13498 static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13499 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13501 static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13502 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13504 static cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13505 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13507 static cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13508 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13509 static cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13510 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13512 static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13513 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13514 static cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13515 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13517 static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13518 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13520 static void cmd_set_l2_encap_parsed(void *parsed_result,
13521 __rte_unused struct cmdline *cl,
13522 __rte_unused void *data)
13524 struct cmd_set_l2_encap_result *res = parsed_result;
13526 if (strcmp(res->l2_encap, "l2_encap") == 0)
13527 l2_encap_conf.select_vlan = 0;
13528 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13529 l2_encap_conf.select_vlan = 1;
13530 if (strcmp(res->ip_version, "ipv4") == 0)
13531 l2_encap_conf.select_ipv4 = 1;
13532 else if (strcmp(res->ip_version, "ipv6") == 0)
13533 l2_encap_conf.select_ipv4 = 0;
13536 if (l2_encap_conf.select_vlan)
13537 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13538 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13539 RTE_ETHER_ADDR_LEN);
13540 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13541 RTE_ETHER_ADDR_LEN);
13544 static cmdline_parse_inst_t cmd_set_l2_encap = {
13545 .f = cmd_set_l2_encap_parsed,
13547 .help_str = "set l2_encap ip-version ipv4|ipv6"
13548 " eth-src <eth-src> eth-dst <eth-dst>",
13550 (void *)&cmd_set_l2_encap_set,
13551 (void *)&cmd_set_l2_encap_l2_encap,
13552 (void *)&cmd_set_l2_encap_ip_version,
13553 (void *)&cmd_set_l2_encap_ip_version_value,
13554 (void *)&cmd_set_l2_encap_eth_src,
13555 (void *)&cmd_set_l2_encap_eth_src_value,
13556 (void *)&cmd_set_l2_encap_eth_dst,
13557 (void *)&cmd_set_l2_encap_eth_dst_value,
13562 static cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13563 .f = cmd_set_l2_encap_parsed,
13565 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13566 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13568 (void *)&cmd_set_l2_encap_set,
13569 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13570 (void *)&cmd_set_l2_encap_ip_version,
13571 (void *)&cmd_set_l2_encap_ip_version_value,
13572 (void *)&cmd_set_l2_encap_vlan,
13573 (void *)&cmd_set_l2_encap_vlan_value,
13574 (void *)&cmd_set_l2_encap_eth_src,
13575 (void *)&cmd_set_l2_encap_eth_src_value,
13576 (void *)&cmd_set_l2_encap_eth_dst,
13577 (void *)&cmd_set_l2_encap_eth_dst_value,
13582 /** Set L2 decapsulation details */
13583 struct cmd_set_l2_decap_result {
13584 cmdline_fixed_string_t set;
13585 cmdline_fixed_string_t l2_decap;
13586 cmdline_fixed_string_t pos_token;
13587 uint32_t vlan_present:1;
13590 static cmdline_parse_token_string_t cmd_set_l2_decap_set =
13591 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13592 static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13593 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13595 static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13596 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13597 "l2_decap-with-vlan");
13599 static void cmd_set_l2_decap_parsed(void *parsed_result,
13600 __rte_unused struct cmdline *cl,
13601 __rte_unused void *data)
13603 struct cmd_set_l2_decap_result *res = parsed_result;
13605 if (strcmp(res->l2_decap, "l2_decap") == 0)
13606 l2_decap_conf.select_vlan = 0;
13607 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13608 l2_decap_conf.select_vlan = 1;
13611 static cmdline_parse_inst_t cmd_set_l2_decap = {
13612 .f = cmd_set_l2_decap_parsed,
13614 .help_str = "set l2_decap",
13616 (void *)&cmd_set_l2_decap_set,
13617 (void *)&cmd_set_l2_decap_l2_decap,
13622 static cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13623 .f = cmd_set_l2_decap_parsed,
13625 .help_str = "set l2_decap-with-vlan",
13627 (void *)&cmd_set_l2_decap_set,
13628 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13633 /** Set MPLSoGRE encapsulation details */
13634 struct cmd_set_mplsogre_encap_result {
13635 cmdline_fixed_string_t set;
13636 cmdline_fixed_string_t mplsogre;
13637 cmdline_fixed_string_t pos_token;
13638 cmdline_fixed_string_t ip_version;
13639 uint32_t vlan_present:1;
13641 cmdline_ipaddr_t ip_src;
13642 cmdline_ipaddr_t ip_dst;
13644 struct rte_ether_addr eth_src;
13645 struct rte_ether_addr eth_dst;
13648 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13649 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13651 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13652 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13654 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13655 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13656 mplsogre, "mplsogre_encap-with-vlan");
13657 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13658 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13659 pos_token, "ip-version");
13660 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13661 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13662 ip_version, "ipv4#ipv6");
13663 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13664 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13665 pos_token, "label");
13666 static cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13667 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13669 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13670 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13671 pos_token, "ip-src");
13672 static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13673 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13674 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13675 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13676 pos_token, "ip-dst");
13677 static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13678 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13679 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13680 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13681 pos_token, "vlan-tci");
13682 static cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13683 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13685 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13686 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13687 pos_token, "eth-src");
13688 static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13689 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13691 static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13692 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13693 pos_token, "eth-dst");
13694 static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13695 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13698 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13699 __rte_unused struct cmdline *cl,
13700 __rte_unused void *data)
13702 struct cmd_set_mplsogre_encap_result *res = parsed_result;
13704 uint32_t mplsogre_label;
13707 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13710 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13711 mplsogre_encap_conf.select_vlan = 0;
13712 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13713 mplsogre_encap_conf.select_vlan = 1;
13714 if (strcmp(res->ip_version, "ipv4") == 0)
13715 mplsogre_encap_conf.select_ipv4 = 1;
13716 else if (strcmp(res->ip_version, "ipv6") == 0)
13717 mplsogre_encap_conf.select_ipv4 = 0;
13720 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13721 if (mplsogre_encap_conf.select_ipv4) {
13722 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13723 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13725 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13726 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13728 if (mplsogre_encap_conf.select_vlan)
13729 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13730 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13731 RTE_ETHER_ADDR_LEN);
13732 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13733 RTE_ETHER_ADDR_LEN);
13736 static cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13737 .f = cmd_set_mplsogre_encap_parsed,
13739 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13740 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13741 " eth-dst <eth-dst>",
13743 (void *)&cmd_set_mplsogre_encap_set,
13744 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13745 (void *)&cmd_set_mplsogre_encap_ip_version,
13746 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13747 (void *)&cmd_set_mplsogre_encap_label,
13748 (void *)&cmd_set_mplsogre_encap_label_value,
13749 (void *)&cmd_set_mplsogre_encap_ip_src,
13750 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13751 (void *)&cmd_set_mplsogre_encap_ip_dst,
13752 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13753 (void *)&cmd_set_mplsogre_encap_eth_src,
13754 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13755 (void *)&cmd_set_mplsogre_encap_eth_dst,
13756 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13761 static cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13762 .f = cmd_set_mplsogre_encap_parsed,
13764 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13765 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
13766 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13768 (void *)&cmd_set_mplsogre_encap_set,
13769 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13770 (void *)&cmd_set_mplsogre_encap_ip_version,
13771 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13772 (void *)&cmd_set_mplsogre_encap_label,
13773 (void *)&cmd_set_mplsogre_encap_label_value,
13774 (void *)&cmd_set_mplsogre_encap_ip_src,
13775 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13776 (void *)&cmd_set_mplsogre_encap_ip_dst,
13777 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13778 (void *)&cmd_set_mplsogre_encap_vlan,
13779 (void *)&cmd_set_mplsogre_encap_vlan_value,
13780 (void *)&cmd_set_mplsogre_encap_eth_src,
13781 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13782 (void *)&cmd_set_mplsogre_encap_eth_dst,
13783 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13788 /** Set MPLSoGRE decapsulation details */
13789 struct cmd_set_mplsogre_decap_result {
13790 cmdline_fixed_string_t set;
13791 cmdline_fixed_string_t mplsogre;
13792 cmdline_fixed_string_t pos_token;
13793 cmdline_fixed_string_t ip_version;
13794 uint32_t vlan_present:1;
13797 static cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13798 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13800 static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13801 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13803 static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13804 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13805 mplsogre, "mplsogre_decap-with-vlan");
13806 static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13807 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13808 pos_token, "ip-version");
13809 static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13810 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13811 ip_version, "ipv4#ipv6");
13813 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13814 __rte_unused struct cmdline *cl,
13815 __rte_unused void *data)
13817 struct cmd_set_mplsogre_decap_result *res = parsed_result;
13819 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13820 mplsogre_decap_conf.select_vlan = 0;
13821 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13822 mplsogre_decap_conf.select_vlan = 1;
13823 if (strcmp(res->ip_version, "ipv4") == 0)
13824 mplsogre_decap_conf.select_ipv4 = 1;
13825 else if (strcmp(res->ip_version, "ipv6") == 0)
13826 mplsogre_decap_conf.select_ipv4 = 0;
13829 static cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13830 .f = cmd_set_mplsogre_decap_parsed,
13832 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13834 (void *)&cmd_set_mplsogre_decap_set,
13835 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13836 (void *)&cmd_set_mplsogre_decap_ip_version,
13837 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13842 static cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13843 .f = cmd_set_mplsogre_decap_parsed,
13845 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13847 (void *)&cmd_set_mplsogre_decap_set,
13848 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13849 (void *)&cmd_set_mplsogre_decap_ip_version,
13850 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13855 /** Set MPLSoUDP encapsulation details */
13856 struct cmd_set_mplsoudp_encap_result {
13857 cmdline_fixed_string_t set;
13858 cmdline_fixed_string_t mplsoudp;
13859 cmdline_fixed_string_t pos_token;
13860 cmdline_fixed_string_t ip_version;
13861 uint32_t vlan_present:1;
13865 cmdline_ipaddr_t ip_src;
13866 cmdline_ipaddr_t ip_dst;
13868 struct rte_ether_addr eth_src;
13869 struct rte_ether_addr eth_dst;
13872 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13873 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13875 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13876 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13878 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13879 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13880 mplsoudp, "mplsoudp_encap-with-vlan");
13881 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13882 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13883 pos_token, "ip-version");
13884 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13885 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13886 ip_version, "ipv4#ipv6");
13887 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13888 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13889 pos_token, "label");
13890 static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13891 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13893 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13894 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13895 pos_token, "udp-src");
13896 static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13897 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13899 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13900 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13901 pos_token, "udp-dst");
13902 static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13903 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13905 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13906 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13907 pos_token, "ip-src");
13908 static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13909 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13910 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13911 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13912 pos_token, "ip-dst");
13913 static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13914 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13915 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13916 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13917 pos_token, "vlan-tci");
13918 static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13919 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13921 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13922 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13923 pos_token, "eth-src");
13924 static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13925 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13927 static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13928 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13929 pos_token, "eth-dst");
13930 static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13931 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13934 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13935 __rte_unused struct cmdline *cl,
13936 __rte_unused void *data)
13938 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13940 uint32_t mplsoudp_label;
13943 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13946 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13947 mplsoudp_encap_conf.select_vlan = 0;
13948 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13949 mplsoudp_encap_conf.select_vlan = 1;
13950 if (strcmp(res->ip_version, "ipv4") == 0)
13951 mplsoudp_encap_conf.select_ipv4 = 1;
13952 else if (strcmp(res->ip_version, "ipv6") == 0)
13953 mplsoudp_encap_conf.select_ipv4 = 0;
13956 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13957 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13958 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13959 if (mplsoudp_encap_conf.select_ipv4) {
13960 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13961 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13963 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13964 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13966 if (mplsoudp_encap_conf.select_vlan)
13967 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13968 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13969 RTE_ETHER_ADDR_LEN);
13970 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13971 RTE_ETHER_ADDR_LEN);
13974 static cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13975 .f = cmd_set_mplsoudp_encap_parsed,
13977 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13978 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13979 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13981 (void *)&cmd_set_mplsoudp_encap_set,
13982 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13983 (void *)&cmd_set_mplsoudp_encap_ip_version,
13984 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13985 (void *)&cmd_set_mplsoudp_encap_label,
13986 (void *)&cmd_set_mplsoudp_encap_label_value,
13987 (void *)&cmd_set_mplsoudp_encap_udp_src,
13988 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13989 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13990 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13991 (void *)&cmd_set_mplsoudp_encap_ip_src,
13992 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13993 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13994 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13995 (void *)&cmd_set_mplsoudp_encap_eth_src,
13996 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13997 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13998 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
14003 static cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
14004 .f = cmd_set_mplsoudp_encap_parsed,
14006 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
14007 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
14008 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
14009 " eth-src <eth-src> eth-dst <eth-dst>",
14011 (void *)&cmd_set_mplsoudp_encap_set,
14012 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
14013 (void *)&cmd_set_mplsoudp_encap_ip_version,
14014 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
14015 (void *)&cmd_set_mplsoudp_encap_label,
14016 (void *)&cmd_set_mplsoudp_encap_label_value,
14017 (void *)&cmd_set_mplsoudp_encap_udp_src,
14018 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
14019 (void *)&cmd_set_mplsoudp_encap_udp_dst,
14020 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
14021 (void *)&cmd_set_mplsoudp_encap_ip_src,
14022 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
14023 (void *)&cmd_set_mplsoudp_encap_ip_dst,
14024 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
14025 (void *)&cmd_set_mplsoudp_encap_vlan,
14026 (void *)&cmd_set_mplsoudp_encap_vlan_value,
14027 (void *)&cmd_set_mplsoudp_encap_eth_src,
14028 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
14029 (void *)&cmd_set_mplsoudp_encap_eth_dst,
14030 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
14035 /** Set MPLSoUDP decapsulation details */
14036 struct cmd_set_mplsoudp_decap_result {
14037 cmdline_fixed_string_t set;
14038 cmdline_fixed_string_t mplsoudp;
14039 cmdline_fixed_string_t pos_token;
14040 cmdline_fixed_string_t ip_version;
14041 uint32_t vlan_present:1;
14044 static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
14045 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
14047 static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
14048 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
14050 static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
14051 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
14052 mplsoudp, "mplsoudp_decap-with-vlan");
14053 static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
14054 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
14055 pos_token, "ip-version");
14056 static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
14057 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
14058 ip_version, "ipv4#ipv6");
14060 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
14061 __rte_unused struct cmdline *cl,
14062 __rte_unused void *data)
14064 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
14066 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
14067 mplsoudp_decap_conf.select_vlan = 0;
14068 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
14069 mplsoudp_decap_conf.select_vlan = 1;
14070 if (strcmp(res->ip_version, "ipv4") == 0)
14071 mplsoudp_decap_conf.select_ipv4 = 1;
14072 else if (strcmp(res->ip_version, "ipv6") == 0)
14073 mplsoudp_decap_conf.select_ipv4 = 0;
14076 static cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
14077 .f = cmd_set_mplsoudp_decap_parsed,
14079 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
14081 (void *)&cmd_set_mplsoudp_decap_set,
14082 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
14083 (void *)&cmd_set_mplsoudp_decap_ip_version,
14084 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
14089 static cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
14090 .f = cmd_set_mplsoudp_decap_parsed,
14092 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
14094 (void *)&cmd_set_mplsoudp_decap_set,
14095 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
14096 (void *)&cmd_set_mplsoudp_decap_ip_version,
14097 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
14102 /** Set connection tracking object common details */
14103 struct cmd_set_conntrack_common_result {
14104 cmdline_fixed_string_t set;
14105 cmdline_fixed_string_t conntrack;
14106 cmdline_fixed_string_t common;
14107 cmdline_fixed_string_t peer;
14108 cmdline_fixed_string_t is_orig;
14109 cmdline_fixed_string_t enable;
14110 cmdline_fixed_string_t live;
14111 cmdline_fixed_string_t sack;
14112 cmdline_fixed_string_t cack;
14113 cmdline_fixed_string_t last_dir;
14114 cmdline_fixed_string_t liberal;
14115 cmdline_fixed_string_t state;
14116 cmdline_fixed_string_t max_ack_win;
14117 cmdline_fixed_string_t retrans;
14118 cmdline_fixed_string_t last_win;
14119 cmdline_fixed_string_t last_seq;
14120 cmdline_fixed_string_t last_ack;
14121 cmdline_fixed_string_t last_end;
14122 cmdline_fixed_string_t last_index;
14125 uint16_t peer_port;
14126 uint32_t is_original;
14141 static cmdline_parse_token_string_t cmd_set_conntrack_set =
14142 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14144 static cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
14145 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14146 conntrack, "conntrack");
14147 static cmdline_parse_token_string_t cmd_set_conntrack_common_com =
14148 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14150 static cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
14151 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14153 static cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
14154 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14155 peer_port, RTE_UINT16);
14156 static cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
14157 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14158 is_orig, "is_orig");
14159 static cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
14160 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14161 is_original, RTE_UINT32);
14162 static cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
14163 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14165 static cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
14166 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14168 static cmdline_parse_token_string_t cmd_set_conntrack_common_live =
14169 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14171 static cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
14172 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14173 is_live, RTE_UINT32);
14174 static cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
14175 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14177 static cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
14178 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14179 s_ack, RTE_UINT32);
14180 static cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
14181 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14183 static cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
14184 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14185 c_ack, RTE_UINT32);
14186 static cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
14187 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14188 last_dir, "last_dir");
14189 static cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
14190 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14192 static cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
14193 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14194 liberal, "liberal");
14195 static cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
14196 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14198 static cmdline_parse_token_string_t cmd_set_conntrack_common_state =
14199 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14201 static cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
14202 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14204 static cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
14205 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14206 max_ack_win, "max_ack_win");
14207 static cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
14208 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14209 factor, RTE_UINT8);
14210 static cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
14211 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14213 static cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
14214 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14215 re_num, RTE_UINT8);
14216 static cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
14217 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14218 last_win, "last_win");
14219 static cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
14220 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14222 static cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
14223 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14224 last_seq, "last_seq");
14225 static cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
14226 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14228 static cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
14229 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14230 last_ack, "last_ack");
14231 static cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
14232 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14234 static cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
14235 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14236 last_end, "last_end");
14237 static cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
14238 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14240 static cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
14241 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14242 last_index, "last_index");
14243 static cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
14244 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14247 static void cmd_set_conntrack_common_parsed(void *parsed_result,
14248 __rte_unused struct cmdline *cl,
14249 __rte_unused void *data)
14251 struct cmd_set_conntrack_common_result *res = parsed_result;
14253 /* No need to swap to big endian. */
14254 conntrack_context.peer_port = res->peer_port;
14255 conntrack_context.is_original_dir = res->is_original;
14256 conntrack_context.enable = res->en;
14257 conntrack_context.live_connection = res->is_live;
14258 conntrack_context.selective_ack = res->s_ack;
14259 conntrack_context.challenge_ack_passed = res->c_ack;
14260 conntrack_context.last_direction = res->ld;
14261 conntrack_context.liberal_mode = res->lb;
14262 conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
14263 conntrack_context.max_ack_window = res->factor;
14264 conntrack_context.retransmission_limit = res->re_num;
14265 conntrack_context.last_window = res->lw;
14266 conntrack_context.last_index =
14267 (enum rte_flow_conntrack_tcp_last_index)res->li;
14268 conntrack_context.last_seq = res->ls;
14269 conntrack_context.last_ack = res->la;
14270 conntrack_context.last_end = res->le;
14273 static cmdline_parse_inst_t cmd_set_conntrack_common = {
14274 .f = cmd_set_conntrack_common_parsed,
14276 .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
14277 " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
14278 " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
14279 " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
14280 " last_index <flag>",
14282 (void *)&cmd_set_conntrack_set,
14283 (void *)&cmd_set_conntrack_conntrack,
14284 (void *)&cmd_set_conntrack_common_com,
14285 (void *)&cmd_set_conntrack_common_peer,
14286 (void *)&cmd_set_conntrack_common_peer_value,
14287 (void *)&cmd_set_conntrack_common_is_orig,
14288 (void *)&cmd_set_conntrack_common_is_orig_value,
14289 (void *)&cmd_set_conntrack_common_enable,
14290 (void *)&cmd_set_conntrack_common_enable_value,
14291 (void *)&cmd_set_conntrack_common_live,
14292 (void *)&cmd_set_conntrack_common_live_value,
14293 (void *)&cmd_set_conntrack_common_sack,
14294 (void *)&cmd_set_conntrack_common_sack_value,
14295 (void *)&cmd_set_conntrack_common_cack,
14296 (void *)&cmd_set_conntrack_common_cack_value,
14297 (void *)&cmd_set_conntrack_common_last_dir,
14298 (void *)&cmd_set_conntrack_common_last_dir_value,
14299 (void *)&cmd_set_conntrack_common_liberal,
14300 (void *)&cmd_set_conntrack_common_liberal_value,
14301 (void *)&cmd_set_conntrack_common_state,
14302 (void *)&cmd_set_conntrack_common_state_value,
14303 (void *)&cmd_set_conntrack_common_max_ackwin,
14304 (void *)&cmd_set_conntrack_common_max_ackwin_value,
14305 (void *)&cmd_set_conntrack_common_retrans,
14306 (void *)&cmd_set_conntrack_common_retrans_value,
14307 (void *)&cmd_set_conntrack_common_last_win,
14308 (void *)&cmd_set_conntrack_common_last_win_value,
14309 (void *)&cmd_set_conntrack_common_last_seq,
14310 (void *)&cmd_set_conntrack_common_last_seq_value,
14311 (void *)&cmd_set_conntrack_common_last_ack,
14312 (void *)&cmd_set_conntrack_common_last_ack_value,
14313 (void *)&cmd_set_conntrack_common_last_end,
14314 (void *)&cmd_set_conntrack_common_last_end_value,
14315 (void *)&cmd_set_conntrack_common_last_index,
14316 (void *)&cmd_set_conntrack_common_last_index_value,
14321 /** Set connection tracking object both directions' details */
14322 struct cmd_set_conntrack_dir_result {
14323 cmdline_fixed_string_t set;
14324 cmdline_fixed_string_t conntrack;
14325 cmdline_fixed_string_t dir;
14326 cmdline_fixed_string_t scale;
14327 cmdline_fixed_string_t fin;
14328 cmdline_fixed_string_t ack_seen;
14329 cmdline_fixed_string_t unack;
14330 cmdline_fixed_string_t sent_end;
14331 cmdline_fixed_string_t reply_end;
14332 cmdline_fixed_string_t max_win;
14333 cmdline_fixed_string_t max_ack;
14344 static cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
14345 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14347 static cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
14348 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14350 static cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
14351 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14352 factor, RTE_UINT32);
14353 static cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
14354 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14356 static cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
14357 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14359 static cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
14360 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14361 ack_seen, "acked");
14362 static cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
14363 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14365 static cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
14366 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14367 unack, "unack_data");
14368 static cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
14369 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14371 static cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
14372 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14373 sent_end, "sent_end");
14374 static cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
14375 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14377 static cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
14378 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14379 reply_end, "reply_end");
14380 static cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
14381 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14383 static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
14384 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14385 max_win, "max_win");
14386 static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
14387 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14389 static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
14390 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14391 max_ack, "max_ack");
14392 static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
14393 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14396 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
14397 __rte_unused struct cmdline *cl,
14398 __rte_unused void *data)
14400 struct cmd_set_conntrack_dir_result *res = parsed_result;
14401 struct rte_flow_tcp_dir_param *dir = NULL;
14403 if (strcmp(res->dir, "orig") == 0)
14404 dir = &conntrack_context.original_dir;
14405 else if (strcmp(res->dir, "rply") == 0)
14406 dir = &conntrack_context.reply_dir;
14409 dir->scale = res->factor;
14410 dir->close_initiated = res->f;
14411 dir->last_ack_seen = res->as;
14412 dir->data_unacked = res->un;
14413 dir->sent_end = res->se;
14414 dir->reply_end = res->re;
14415 dir->max_ack = res->ma;
14416 dir->max_win = res->mw;
14419 static cmdline_parse_inst_t cmd_set_conntrack_dir = {
14420 .f = cmd_set_conntrack_dir_parsed,
14422 .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
14423 " acked <seen> unack_data <unack> sent_end <sent>"
14424 " reply_end <reply> max_win <win> max_ack <ack>",
14426 (void *)&cmd_set_conntrack_set,
14427 (void *)&cmd_set_conntrack_conntrack,
14428 (void *)&cmd_set_conntrack_dir_dir,
14429 (void *)&cmd_set_conntrack_dir_scale,
14430 (void *)&cmd_set_conntrack_dir_scale_value,
14431 (void *)&cmd_set_conntrack_dir_fin,
14432 (void *)&cmd_set_conntrack_dir_fin_value,
14433 (void *)&cmd_set_conntrack_dir_ack,
14434 (void *)&cmd_set_conntrack_dir_ack_value,
14435 (void *)&cmd_set_conntrack_dir_unack_data,
14436 (void *)&cmd_set_conntrack_dir_unack_data_value,
14437 (void *)&cmd_set_conntrack_dir_sent_end,
14438 (void *)&cmd_set_conntrack_dir_sent_end_value,
14439 (void *)&cmd_set_conntrack_dir_reply_end,
14440 (void *)&cmd_set_conntrack_dir_reply_end_value,
14441 (void *)&cmd_set_conntrack_dir_max_win,
14442 (void *)&cmd_set_conntrack_dir_max_win_value,
14443 (void *)&cmd_set_conntrack_dir_max_ack,
14444 (void *)&cmd_set_conntrack_dir_max_ack_value,
14449 /* Strict link priority scheduling mode setting */
14451 cmd_strict_link_prio_parsed(
14452 void *parsed_result,
14453 __rte_unused struct cmdline *cl,
14454 __rte_unused void *data)
14456 struct cmd_vf_tc_bw_result *res = parsed_result;
14457 int ret = -ENOTSUP;
14459 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14462 #ifdef RTE_NET_I40E
14463 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14470 fprintf(stderr, "invalid tc_bitmap 0x%x\n", res->tc_map);
14473 fprintf(stderr, "invalid port_id %d\n", res->port_id);
14476 fprintf(stderr, "function not implemented\n");
14479 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
14483 static cmdline_parse_inst_t cmd_strict_link_prio = {
14484 .f = cmd_strict_link_prio_parsed,
14486 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14488 (void *)&cmd_vf_tc_bw_set,
14489 (void *)&cmd_vf_tc_bw_tx,
14490 (void *)&cmd_vf_tc_bw_strict_link_prio,
14491 (void *)&cmd_vf_tc_bw_port_id,
14492 (void *)&cmd_vf_tc_bw_tc_map,
14497 /* Load dynamic device personalization*/
14498 struct cmd_ddp_add_result {
14499 cmdline_fixed_string_t ddp;
14500 cmdline_fixed_string_t add;
14505 static cmdline_parse_token_string_t cmd_ddp_add_ddp =
14506 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14507 static cmdline_parse_token_string_t cmd_ddp_add_add =
14508 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14509 static cmdline_parse_token_num_t cmd_ddp_add_port_id =
14510 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
14512 static cmdline_parse_token_string_t cmd_ddp_add_filepath =
14513 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14516 cmd_ddp_add_parsed(
14517 void *parsed_result,
14518 __rte_unused struct cmdline *cl,
14519 __rte_unused void *data)
14521 struct cmd_ddp_add_result *res = parsed_result;
14527 int ret = -ENOTSUP;
14529 if (!all_ports_stopped()) {
14530 fprintf(stderr, "Please stop all ports first\n");
14534 filepath = strdup(res->filepath);
14535 if (filepath == NULL) {
14536 fprintf(stderr, "Failed to allocate memory\n");
14539 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14541 buff = open_file(file_fld[0], &size);
14543 free((void *)filepath);
14547 #ifdef RTE_NET_I40E
14548 if (ret == -ENOTSUP)
14549 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14551 RTE_PMD_I40E_PKG_OP_WR_ADD);
14554 if (ret == -EEXIST)
14555 fprintf(stderr, "Profile has already existed.\n");
14557 fprintf(stderr, "Failed to load profile.\n");
14558 else if (file_num == 2)
14559 save_file(file_fld[1], buff, size);
14562 free((void *)filepath);
14565 static cmdline_parse_inst_t cmd_ddp_add = {
14566 .f = cmd_ddp_add_parsed,
14568 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14570 (void *)&cmd_ddp_add_ddp,
14571 (void *)&cmd_ddp_add_add,
14572 (void *)&cmd_ddp_add_port_id,
14573 (void *)&cmd_ddp_add_filepath,
14578 /* Delete dynamic device personalization*/
14579 struct cmd_ddp_del_result {
14580 cmdline_fixed_string_t ddp;
14581 cmdline_fixed_string_t del;
14586 static cmdline_parse_token_string_t cmd_ddp_del_ddp =
14587 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14588 static cmdline_parse_token_string_t cmd_ddp_del_del =
14589 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14590 static cmdline_parse_token_num_t cmd_ddp_del_port_id =
14591 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
14592 static cmdline_parse_token_string_t cmd_ddp_del_filepath =
14593 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14596 cmd_ddp_del_parsed(
14597 void *parsed_result,
14598 __rte_unused struct cmdline *cl,
14599 __rte_unused void *data)
14601 struct cmd_ddp_del_result *res = parsed_result;
14604 int ret = -ENOTSUP;
14606 if (!all_ports_stopped()) {
14607 fprintf(stderr, "Please stop all ports first\n");
14611 buff = open_file(res->filepath, &size);
14615 #ifdef RTE_NET_I40E
14616 if (ret == -ENOTSUP)
14617 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14619 RTE_PMD_I40E_PKG_OP_WR_DEL);
14622 if (ret == -EACCES)
14623 fprintf(stderr, "Profile does not exist.\n");
14625 fprintf(stderr, "Failed to delete profile.\n");
14630 static cmdline_parse_inst_t cmd_ddp_del = {
14631 .f = cmd_ddp_del_parsed,
14633 .help_str = "ddp del <port_id> <backup_profile_path>",
14635 (void *)&cmd_ddp_del_ddp,
14636 (void *)&cmd_ddp_del_del,
14637 (void *)&cmd_ddp_del_port_id,
14638 (void *)&cmd_ddp_del_filepath,
14643 /* Get dynamic device personalization profile info */
14644 struct cmd_ddp_info_result {
14645 cmdline_fixed_string_t ddp;
14646 cmdline_fixed_string_t get;
14647 cmdline_fixed_string_t info;
14651 static cmdline_parse_token_string_t cmd_ddp_info_ddp =
14652 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14653 static cmdline_parse_token_string_t cmd_ddp_info_get =
14654 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14655 static cmdline_parse_token_string_t cmd_ddp_info_info =
14656 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14657 static cmdline_parse_token_string_t cmd_ddp_info_filepath =
14658 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14661 cmd_ddp_info_parsed(
14662 void *parsed_result,
14663 __rte_unused struct cmdline *cl,
14664 __rte_unused void *data)
14666 struct cmd_ddp_info_result *res = parsed_result;
14669 int ret = -ENOTSUP;
14670 #ifdef RTE_NET_I40E
14673 uint32_t buff_size = 0;
14674 struct rte_pmd_i40e_profile_info info;
14675 uint32_t dev_num = 0;
14676 struct rte_pmd_i40e_ddp_device_id *devs;
14677 uint32_t proto_num = 0;
14678 struct rte_pmd_i40e_proto_info *proto = NULL;
14679 uint32_t pctype_num = 0;
14680 struct rte_pmd_i40e_ptype_info *pctype;
14681 uint32_t ptype_num = 0;
14682 struct rte_pmd_i40e_ptype_info *ptype;
14687 pkg = open_file(res->filepath, &pkg_size);
14691 #ifdef RTE_NET_I40E
14692 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14693 (uint8_t *)&info, sizeof(info),
14694 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14696 printf("Global Track id: 0x%x\n", info.track_id);
14697 printf("Global Version: %d.%d.%d.%d\n",
14698 info.version.major,
14699 info.version.minor,
14700 info.version.update,
14701 info.version.draft);
14702 printf("Global Package name: %s\n\n", info.name);
14705 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14706 (uint8_t *)&info, sizeof(info),
14707 RTE_PMD_I40E_PKG_INFO_HEADER);
14709 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14710 printf("i40e Profile Version: %d.%d.%d.%d\n",
14711 info.version.major,
14712 info.version.minor,
14713 info.version.update,
14714 info.version.draft);
14715 printf("i40e Profile name: %s\n\n", info.name);
14718 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14719 (uint8_t *)&buff_size, sizeof(buff_size),
14720 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14721 if (!ret && buff_size) {
14722 buff = (uint8_t *)malloc(buff_size);
14724 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14726 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14728 printf("Package Notes:\n%s\n\n", buff);
14733 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14734 (uint8_t *)&dev_num, sizeof(dev_num),
14735 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14736 if (!ret && dev_num) {
14737 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14738 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14740 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14741 (uint8_t *)devs, buff_size,
14742 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14744 printf("List of supported devices:\n");
14745 for (i = 0; i < dev_num; i++) {
14746 printf(" %04X:%04X %04X:%04X\n",
14747 devs[i].vendor_dev_id >> 16,
14748 devs[i].vendor_dev_id & 0xFFFF,
14749 devs[i].sub_vendor_dev_id >> 16,
14750 devs[i].sub_vendor_dev_id & 0xFFFF);
14758 /* get information about protocols and packet types */
14759 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14760 (uint8_t *)&proto_num, sizeof(proto_num),
14761 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14762 if (ret || !proto_num)
14763 goto no_print_return;
14765 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14766 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14768 goto no_print_return;
14770 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14772 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14774 printf("List of used protocols:\n");
14775 for (i = 0; i < proto_num; i++)
14776 printf(" %2u: %s\n", proto[i].proto_id,
14780 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14781 (uint8_t *)&pctype_num, sizeof(pctype_num),
14782 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14783 if (ret || !pctype_num)
14784 goto no_print_pctypes;
14786 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14787 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14789 goto no_print_pctypes;
14791 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14793 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14796 goto no_print_pctypes;
14799 printf("List of defined packet classification types:\n");
14800 for (i = 0; i < pctype_num; i++) {
14801 printf(" %2u:", pctype[i].ptype_id);
14802 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14803 proto_id = pctype[i].protocols[j];
14804 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14805 for (n = 0; n < proto_num; n++) {
14806 if (proto[n].proto_id == proto_id) {
14807 printf(" %s", proto[n].name);
14820 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14822 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14823 if (ret || !ptype_num)
14824 goto no_print_return;
14826 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14827 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14829 goto no_print_return;
14831 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14833 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14836 goto no_print_return;
14838 printf("List of defined packet types:\n");
14839 for (i = 0; i < ptype_num; i++) {
14840 printf(" %2u:", ptype[i].ptype_id);
14841 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14842 proto_id = ptype[i].protocols[j];
14843 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14844 for (n = 0; n < proto_num; n++) {
14845 if (proto[n].proto_id == proto_id) {
14846 printf(" %s", proto[n].name);
14861 if (ret == -ENOTSUP)
14862 fprintf(stderr, "Function not supported in PMD\n");
14866 static cmdline_parse_inst_t cmd_ddp_get_info = {
14867 .f = cmd_ddp_info_parsed,
14869 .help_str = "ddp get info <profile_path>",
14871 (void *)&cmd_ddp_info_ddp,
14872 (void *)&cmd_ddp_info_get,
14873 (void *)&cmd_ddp_info_info,
14874 (void *)&cmd_ddp_info_filepath,
14879 /* Get dynamic device personalization profile info list*/
14880 #define PROFILE_INFO_SIZE 48
14881 #define MAX_PROFILE_NUM 16
14883 struct cmd_ddp_get_list_result {
14884 cmdline_fixed_string_t ddp;
14885 cmdline_fixed_string_t get;
14886 cmdline_fixed_string_t list;
14890 static cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14891 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14892 static cmdline_parse_token_string_t cmd_ddp_get_list_get =
14893 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14894 static cmdline_parse_token_string_t cmd_ddp_get_list_list =
14895 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14896 static cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14897 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14901 cmd_ddp_get_list_parsed(
14902 __rte_unused void *parsed_result,
14903 __rte_unused struct cmdline *cl,
14904 __rte_unused void *data)
14906 #ifdef RTE_NET_I40E
14907 struct cmd_ddp_get_list_result *res = parsed_result;
14908 struct rte_pmd_i40e_profile_list *p_list;
14909 struct rte_pmd_i40e_profile_info *p_info;
14914 int ret = -ENOTSUP;
14916 #ifdef RTE_NET_I40E
14917 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14918 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14920 fprintf(stderr, "%s: Failed to malloc buffer\n", __func__);
14924 if (ret == -ENOTSUP)
14925 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14926 (uint8_t *)p_list, size);
14929 p_num = p_list->p_count;
14930 printf("Profile number is: %d\n\n", p_num);
14932 for (i = 0; i < p_num; i++) {
14933 p_info = &p_list->p_info[i];
14934 printf("Profile %d:\n", i);
14935 printf("Track id: 0x%x\n", p_info->track_id);
14936 printf("Version: %d.%d.%d.%d\n",
14937 p_info->version.major,
14938 p_info->version.minor,
14939 p_info->version.update,
14940 p_info->version.draft);
14941 printf("Profile name: %s\n\n", p_info->name);
14949 fprintf(stderr, "Failed to get ddp list\n");
14952 static cmdline_parse_inst_t cmd_ddp_get_list = {
14953 .f = cmd_ddp_get_list_parsed,
14955 .help_str = "ddp get list <port_id>",
14957 (void *)&cmd_ddp_get_list_ddp,
14958 (void *)&cmd_ddp_get_list_get,
14959 (void *)&cmd_ddp_get_list_list,
14960 (void *)&cmd_ddp_get_list_port_id,
14965 /* Configure input set */
14966 struct cmd_cfg_input_set_result {
14967 cmdline_fixed_string_t port;
14968 cmdline_fixed_string_t cfg;
14970 cmdline_fixed_string_t pctype;
14972 cmdline_fixed_string_t inset_type;
14973 cmdline_fixed_string_t opt;
14974 cmdline_fixed_string_t field;
14979 cmd_cfg_input_set_parsed(
14980 __rte_unused void *parsed_result,
14981 __rte_unused struct cmdline *cl,
14982 __rte_unused void *data)
14984 #ifdef RTE_NET_I40E
14985 struct cmd_cfg_input_set_result *res = parsed_result;
14986 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14987 struct rte_pmd_i40e_inset inset;
14989 int ret = -ENOTSUP;
14991 if (!all_ports_stopped()) {
14992 fprintf(stderr, "Please stop all ports first\n");
14996 #ifdef RTE_NET_I40E
14997 if (!strcmp(res->inset_type, "hash_inset"))
14998 inset_type = INSET_HASH;
14999 else if (!strcmp(res->inset_type, "fdir_inset"))
15000 inset_type = INSET_FDIR;
15001 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15002 inset_type = INSET_FDIR_FLX;
15003 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
15004 &inset, inset_type);
15006 fprintf(stderr, "Failed to get input set.\n");
15010 if (!strcmp(res->opt, "get")) {
15011 ret = rte_pmd_i40e_inset_field_get(inset.inset,
15014 printf("Field index %d is enabled.\n", res->field_idx);
15016 printf("Field index %d is disabled.\n", res->field_idx);
15018 } else if (!strcmp(res->opt, "set"))
15019 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
15021 else if (!strcmp(res->opt, "clear"))
15022 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15025 fprintf(stderr, "Failed to configure input set field.\n");
15029 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15030 &inset, inset_type);
15032 fprintf(stderr, "Failed to set input set.\n");
15037 if (ret == -ENOTSUP)
15038 fprintf(stderr, "Function not supported\n");
15041 static cmdline_parse_token_string_t cmd_cfg_input_set_port =
15042 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15044 static cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15045 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15047 static cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15048 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15049 port_id, RTE_UINT16);
15050 static cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15051 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15053 static cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15054 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15055 pctype_id, RTE_UINT8);
15056 static cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15057 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15059 "hash_inset#fdir_inset#fdir_flx_inset");
15060 static cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15061 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15062 opt, "get#set#clear");
15063 static cmdline_parse_token_string_t cmd_cfg_input_set_field =
15064 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15066 static cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15067 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15068 field_idx, RTE_UINT8);
15070 static cmdline_parse_inst_t cmd_cfg_input_set = {
15071 .f = cmd_cfg_input_set_parsed,
15073 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15074 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15076 (void *)&cmd_cfg_input_set_port,
15077 (void *)&cmd_cfg_input_set_cfg,
15078 (void *)&cmd_cfg_input_set_port_id,
15079 (void *)&cmd_cfg_input_set_pctype,
15080 (void *)&cmd_cfg_input_set_pctype_id,
15081 (void *)&cmd_cfg_input_set_inset_type,
15082 (void *)&cmd_cfg_input_set_opt,
15083 (void *)&cmd_cfg_input_set_field,
15084 (void *)&cmd_cfg_input_set_field_idx,
15089 /* Clear input set */
15090 struct cmd_clear_input_set_result {
15091 cmdline_fixed_string_t port;
15092 cmdline_fixed_string_t cfg;
15094 cmdline_fixed_string_t pctype;
15096 cmdline_fixed_string_t inset_type;
15097 cmdline_fixed_string_t clear;
15098 cmdline_fixed_string_t all;
15102 cmd_clear_input_set_parsed(
15103 __rte_unused void *parsed_result,
15104 __rte_unused struct cmdline *cl,
15105 __rte_unused void *data)
15107 #ifdef RTE_NET_I40E
15108 struct cmd_clear_input_set_result *res = parsed_result;
15109 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15110 struct rte_pmd_i40e_inset inset;
15112 int ret = -ENOTSUP;
15114 if (!all_ports_stopped()) {
15115 fprintf(stderr, "Please stop all ports first\n");
15119 #ifdef RTE_NET_I40E
15120 if (!strcmp(res->inset_type, "hash_inset"))
15121 inset_type = INSET_HASH;
15122 else if (!strcmp(res->inset_type, "fdir_inset"))
15123 inset_type = INSET_FDIR;
15124 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15125 inset_type = INSET_FDIR_FLX;
15127 memset(&inset, 0, sizeof(inset));
15129 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15130 &inset, inset_type);
15132 fprintf(stderr, "Failed to clear input set.\n");
15138 if (ret == -ENOTSUP)
15139 fprintf(stderr, "Function not supported\n");
15142 static cmdline_parse_token_string_t cmd_clear_input_set_port =
15143 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15145 static cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15146 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15148 static cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15149 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15150 port_id, RTE_UINT16);
15151 static cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15152 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15154 static cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15155 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15156 pctype_id, RTE_UINT8);
15157 static cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15158 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15160 "hash_inset#fdir_inset#fdir_flx_inset");
15161 static cmdline_parse_token_string_t cmd_clear_input_set_clear =
15162 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15164 static cmdline_parse_token_string_t cmd_clear_input_set_all =
15165 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15168 static cmdline_parse_inst_t cmd_clear_input_set = {
15169 .f = cmd_clear_input_set_parsed,
15171 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15172 "fdir_inset|fdir_flx_inset clear all",
15174 (void *)&cmd_clear_input_set_port,
15175 (void *)&cmd_clear_input_set_cfg,
15176 (void *)&cmd_clear_input_set_port_id,
15177 (void *)&cmd_clear_input_set_pctype,
15178 (void *)&cmd_clear_input_set_pctype_id,
15179 (void *)&cmd_clear_input_set_inset_type,
15180 (void *)&cmd_clear_input_set_clear,
15181 (void *)&cmd_clear_input_set_all,
15186 /* show vf stats */
15188 /* Common result structure for show vf stats */
15189 struct cmd_show_vf_stats_result {
15190 cmdline_fixed_string_t show;
15191 cmdline_fixed_string_t vf;
15192 cmdline_fixed_string_t stats;
15197 /* Common CLI fields show vf stats*/
15198 static cmdline_parse_token_string_t cmd_show_vf_stats_show =
15199 TOKEN_STRING_INITIALIZER
15200 (struct cmd_show_vf_stats_result,
15202 static cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15203 TOKEN_STRING_INITIALIZER
15204 (struct cmd_show_vf_stats_result,
15206 static cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15207 TOKEN_STRING_INITIALIZER
15208 (struct cmd_show_vf_stats_result,
15210 static cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15211 TOKEN_NUM_INITIALIZER
15212 (struct cmd_show_vf_stats_result,
15213 port_id, RTE_UINT16);
15214 static cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15215 TOKEN_NUM_INITIALIZER
15216 (struct cmd_show_vf_stats_result,
15217 vf_id, RTE_UINT16);
15220 cmd_show_vf_stats_parsed(
15221 void *parsed_result,
15222 __rte_unused struct cmdline *cl,
15223 __rte_unused void *data)
15225 struct cmd_show_vf_stats_result *res = parsed_result;
15226 struct rte_eth_stats stats;
15227 int ret = -ENOTSUP;
15228 static const char *nic_stats_border = "########################";
15230 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15233 memset(&stats, 0, sizeof(stats));
15235 #ifdef RTE_NET_I40E
15236 if (ret == -ENOTSUP)
15237 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15241 #ifdef RTE_NET_BNXT
15242 if (ret == -ENOTSUP)
15243 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15252 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15255 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15258 fprintf(stderr, "function not implemented\n");
15261 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15264 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15265 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15267 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15269 stats.ipackets, stats.imissed, stats.ibytes);
15270 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15271 printf(" RX-nombuf: %-10"PRIu64"\n",
15273 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15275 stats.opackets, stats.oerrors, stats.obytes);
15277 printf(" %s############################%s\n",
15278 nic_stats_border, nic_stats_border);
15281 static cmdline_parse_inst_t cmd_show_vf_stats = {
15282 .f = cmd_show_vf_stats_parsed,
15284 .help_str = "show vf stats <port_id> <vf_id>",
15286 (void *)&cmd_show_vf_stats_show,
15287 (void *)&cmd_show_vf_stats_vf,
15288 (void *)&cmd_show_vf_stats_stats,
15289 (void *)&cmd_show_vf_stats_port_id,
15290 (void *)&cmd_show_vf_stats_vf_id,
15295 /* clear vf stats */
15297 /* Common result structure for clear vf stats */
15298 struct cmd_clear_vf_stats_result {
15299 cmdline_fixed_string_t clear;
15300 cmdline_fixed_string_t vf;
15301 cmdline_fixed_string_t stats;
15306 /* Common CLI fields clear vf stats*/
15307 static cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15308 TOKEN_STRING_INITIALIZER
15309 (struct cmd_clear_vf_stats_result,
15311 static cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15312 TOKEN_STRING_INITIALIZER
15313 (struct cmd_clear_vf_stats_result,
15315 static cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15316 TOKEN_STRING_INITIALIZER
15317 (struct cmd_clear_vf_stats_result,
15319 static cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15320 TOKEN_NUM_INITIALIZER
15321 (struct cmd_clear_vf_stats_result,
15322 port_id, RTE_UINT16);
15323 static cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15324 TOKEN_NUM_INITIALIZER
15325 (struct cmd_clear_vf_stats_result,
15326 vf_id, RTE_UINT16);
15329 cmd_clear_vf_stats_parsed(
15330 void *parsed_result,
15331 __rte_unused struct cmdline *cl,
15332 __rte_unused void *data)
15334 struct cmd_clear_vf_stats_result *res = parsed_result;
15335 int ret = -ENOTSUP;
15337 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15340 #ifdef RTE_NET_I40E
15341 if (ret == -ENOTSUP)
15342 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15345 #ifdef RTE_NET_BNXT
15346 if (ret == -ENOTSUP)
15347 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15355 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15358 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15361 fprintf(stderr, "function not implemented\n");
15364 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15368 static cmdline_parse_inst_t cmd_clear_vf_stats = {
15369 .f = cmd_clear_vf_stats_parsed,
15371 .help_str = "clear vf stats <port_id> <vf_id>",
15373 (void *)&cmd_clear_vf_stats_clear,
15374 (void *)&cmd_clear_vf_stats_vf,
15375 (void *)&cmd_clear_vf_stats_stats,
15376 (void *)&cmd_clear_vf_stats_port_id,
15377 (void *)&cmd_clear_vf_stats_vf_id,
15382 /* port config pctype mapping reset */
15384 /* Common result structure for port config pctype mapping reset */
15385 struct cmd_pctype_mapping_reset_result {
15386 cmdline_fixed_string_t port;
15387 cmdline_fixed_string_t config;
15389 cmdline_fixed_string_t pctype;
15390 cmdline_fixed_string_t mapping;
15391 cmdline_fixed_string_t reset;
15394 /* Common CLI fields for port config pctype mapping reset*/
15395 static cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15396 TOKEN_STRING_INITIALIZER
15397 (struct cmd_pctype_mapping_reset_result,
15399 static cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15400 TOKEN_STRING_INITIALIZER
15401 (struct cmd_pctype_mapping_reset_result,
15403 static cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15404 TOKEN_NUM_INITIALIZER
15405 (struct cmd_pctype_mapping_reset_result,
15406 port_id, RTE_UINT16);
15407 static cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15408 TOKEN_STRING_INITIALIZER
15409 (struct cmd_pctype_mapping_reset_result,
15411 static cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15412 TOKEN_STRING_INITIALIZER
15413 (struct cmd_pctype_mapping_reset_result,
15414 mapping, "mapping");
15415 static cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15416 TOKEN_STRING_INITIALIZER
15417 (struct cmd_pctype_mapping_reset_result,
15421 cmd_pctype_mapping_reset_parsed(
15422 void *parsed_result,
15423 __rte_unused struct cmdline *cl,
15424 __rte_unused void *data)
15426 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15427 int ret = -ENOTSUP;
15429 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15432 #ifdef RTE_NET_I40E
15433 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15440 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15443 fprintf(stderr, "function not implemented\n");
15446 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15450 static cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15451 .f = cmd_pctype_mapping_reset_parsed,
15453 .help_str = "port config <port_id> pctype mapping reset",
15455 (void *)&cmd_pctype_mapping_reset_port,
15456 (void *)&cmd_pctype_mapping_reset_config,
15457 (void *)&cmd_pctype_mapping_reset_port_id,
15458 (void *)&cmd_pctype_mapping_reset_pctype,
15459 (void *)&cmd_pctype_mapping_reset_mapping,
15460 (void *)&cmd_pctype_mapping_reset_reset,
15465 /* show port pctype mapping */
15467 /* Common result structure for show port pctype mapping */
15468 struct cmd_pctype_mapping_get_result {
15469 cmdline_fixed_string_t show;
15470 cmdline_fixed_string_t port;
15472 cmdline_fixed_string_t pctype;
15473 cmdline_fixed_string_t mapping;
15476 /* Common CLI fields for pctype mapping get */
15477 static cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15478 TOKEN_STRING_INITIALIZER
15479 (struct cmd_pctype_mapping_get_result,
15481 static cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15482 TOKEN_STRING_INITIALIZER
15483 (struct cmd_pctype_mapping_get_result,
15485 static cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15486 TOKEN_NUM_INITIALIZER
15487 (struct cmd_pctype_mapping_get_result,
15488 port_id, RTE_UINT16);
15489 static cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15490 TOKEN_STRING_INITIALIZER
15491 (struct cmd_pctype_mapping_get_result,
15493 static cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15494 TOKEN_STRING_INITIALIZER
15495 (struct cmd_pctype_mapping_get_result,
15496 mapping, "mapping");
15499 cmd_pctype_mapping_get_parsed(
15500 void *parsed_result,
15501 __rte_unused struct cmdline *cl,
15502 __rte_unused void *data)
15504 struct cmd_pctype_mapping_get_result *res = parsed_result;
15505 int ret = -ENOTSUP;
15506 #ifdef RTE_NET_I40E
15507 struct rte_pmd_i40e_flow_type_mapping
15508 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15509 int i, j, first_pctype;
15512 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15515 #ifdef RTE_NET_I40E
15516 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15523 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15526 fprintf(stderr, "function not implemented\n");
15529 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15533 #ifdef RTE_NET_I40E
15534 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15535 if (mapping[i].pctype != 0ULL) {
15538 printf("pctype: ");
15539 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15540 if (mapping[i].pctype & (1ULL << j)) {
15541 printf(first_pctype ?
15542 "%02d" : ",%02d", j);
15546 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15552 static cmdline_parse_inst_t cmd_pctype_mapping_get = {
15553 .f = cmd_pctype_mapping_get_parsed,
15555 .help_str = "show port <port_id> pctype mapping",
15557 (void *)&cmd_pctype_mapping_get_show,
15558 (void *)&cmd_pctype_mapping_get_port,
15559 (void *)&cmd_pctype_mapping_get_port_id,
15560 (void *)&cmd_pctype_mapping_get_pctype,
15561 (void *)&cmd_pctype_mapping_get_mapping,
15566 /* port config pctype mapping update */
15568 /* Common result structure for port config pctype mapping update */
15569 struct cmd_pctype_mapping_update_result {
15570 cmdline_fixed_string_t port;
15571 cmdline_fixed_string_t config;
15573 cmdline_fixed_string_t pctype;
15574 cmdline_fixed_string_t mapping;
15575 cmdline_fixed_string_t update;
15576 cmdline_fixed_string_t pctype_list;
15577 uint16_t flow_type;
15580 /* Common CLI fields for pctype mapping update*/
15581 static cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15582 TOKEN_STRING_INITIALIZER
15583 (struct cmd_pctype_mapping_update_result,
15585 static cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15586 TOKEN_STRING_INITIALIZER
15587 (struct cmd_pctype_mapping_update_result,
15589 static cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15590 TOKEN_NUM_INITIALIZER
15591 (struct cmd_pctype_mapping_update_result,
15592 port_id, RTE_UINT16);
15593 static cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15594 TOKEN_STRING_INITIALIZER
15595 (struct cmd_pctype_mapping_update_result,
15597 static cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15598 TOKEN_STRING_INITIALIZER
15599 (struct cmd_pctype_mapping_update_result,
15600 mapping, "mapping");
15601 static cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15602 TOKEN_STRING_INITIALIZER
15603 (struct cmd_pctype_mapping_update_result,
15605 static cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15606 TOKEN_STRING_INITIALIZER
15607 (struct cmd_pctype_mapping_update_result,
15608 pctype_list, NULL);
15609 static cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15610 TOKEN_NUM_INITIALIZER
15611 (struct cmd_pctype_mapping_update_result,
15612 flow_type, RTE_UINT16);
15615 cmd_pctype_mapping_update_parsed(
15616 void *parsed_result,
15617 __rte_unused struct cmdline *cl,
15618 __rte_unused void *data)
15620 struct cmd_pctype_mapping_update_result *res = parsed_result;
15621 int ret = -ENOTSUP;
15622 #ifdef RTE_NET_I40E
15623 struct rte_pmd_i40e_flow_type_mapping mapping;
15625 unsigned int nb_item;
15626 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15629 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15632 #ifdef RTE_NET_I40E
15633 nb_item = parse_item_list(res->pctype_list, "pctypes",
15634 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15635 mapping.flow_type = res->flow_type;
15636 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15637 mapping.pctype |= (1ULL << pctype_list[i]);
15638 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15648 fprintf(stderr, "invalid pctype or flow type\n");
15651 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15654 fprintf(stderr, "function not implemented\n");
15657 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15661 static cmdline_parse_inst_t cmd_pctype_mapping_update = {
15662 .f = cmd_pctype_mapping_update_parsed,
15664 .help_str = "port config <port_id> pctype mapping update"
15665 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15667 (void *)&cmd_pctype_mapping_update_port,
15668 (void *)&cmd_pctype_mapping_update_config,
15669 (void *)&cmd_pctype_mapping_update_port_id,
15670 (void *)&cmd_pctype_mapping_update_pctype,
15671 (void *)&cmd_pctype_mapping_update_mapping,
15672 (void *)&cmd_pctype_mapping_update_update,
15673 (void *)&cmd_pctype_mapping_update_pc_type,
15674 (void *)&cmd_pctype_mapping_update_flow_type,
15679 /* ptype mapping get */
15681 /* Common result structure for ptype mapping get */
15682 struct cmd_ptype_mapping_get_result {
15683 cmdline_fixed_string_t ptype;
15684 cmdline_fixed_string_t mapping;
15685 cmdline_fixed_string_t get;
15687 uint8_t valid_only;
15690 /* Common CLI fields for ptype mapping get */
15691 static cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15692 TOKEN_STRING_INITIALIZER
15693 (struct cmd_ptype_mapping_get_result,
15695 static cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15696 TOKEN_STRING_INITIALIZER
15697 (struct cmd_ptype_mapping_get_result,
15698 mapping, "mapping");
15699 static cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15700 TOKEN_STRING_INITIALIZER
15701 (struct cmd_ptype_mapping_get_result,
15703 static cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15704 TOKEN_NUM_INITIALIZER
15705 (struct cmd_ptype_mapping_get_result,
15706 port_id, RTE_UINT16);
15707 static cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15708 TOKEN_NUM_INITIALIZER
15709 (struct cmd_ptype_mapping_get_result,
15710 valid_only, RTE_UINT8);
15713 cmd_ptype_mapping_get_parsed(
15714 void *parsed_result,
15715 __rte_unused struct cmdline *cl,
15716 __rte_unused void *data)
15718 struct cmd_ptype_mapping_get_result *res = parsed_result;
15719 int ret = -ENOTSUP;
15720 #ifdef RTE_NET_I40E
15721 int max_ptype_num = 256;
15722 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15727 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15730 #ifdef RTE_NET_I40E
15731 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15742 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15745 fprintf(stderr, "function not implemented\n");
15748 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15751 #ifdef RTE_NET_I40E
15753 for (i = 0; i < count; i++)
15754 printf("%3d\t0x%08x\n",
15755 mapping[i].hw_ptype, mapping[i].sw_ptype);
15760 static cmdline_parse_inst_t cmd_ptype_mapping_get = {
15761 .f = cmd_ptype_mapping_get_parsed,
15763 .help_str = "ptype mapping get <port_id> <valid_only>",
15765 (void *)&cmd_ptype_mapping_get_ptype,
15766 (void *)&cmd_ptype_mapping_get_mapping,
15767 (void *)&cmd_ptype_mapping_get_get,
15768 (void *)&cmd_ptype_mapping_get_port_id,
15769 (void *)&cmd_ptype_mapping_get_valid_only,
15774 /* ptype mapping replace */
15776 /* Common result structure for ptype mapping replace */
15777 struct cmd_ptype_mapping_replace_result {
15778 cmdline_fixed_string_t ptype;
15779 cmdline_fixed_string_t mapping;
15780 cmdline_fixed_string_t replace;
15787 /* Common CLI fields for ptype mapping replace */
15788 static cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15789 TOKEN_STRING_INITIALIZER
15790 (struct cmd_ptype_mapping_replace_result,
15792 static cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15793 TOKEN_STRING_INITIALIZER
15794 (struct cmd_ptype_mapping_replace_result,
15795 mapping, "mapping");
15796 static cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15797 TOKEN_STRING_INITIALIZER
15798 (struct cmd_ptype_mapping_replace_result,
15799 replace, "replace");
15800 static cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15801 TOKEN_NUM_INITIALIZER
15802 (struct cmd_ptype_mapping_replace_result,
15803 port_id, RTE_UINT16);
15804 static cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15805 TOKEN_NUM_INITIALIZER
15806 (struct cmd_ptype_mapping_replace_result,
15807 target, RTE_UINT32);
15808 static cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15809 TOKEN_NUM_INITIALIZER
15810 (struct cmd_ptype_mapping_replace_result,
15812 static cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15813 TOKEN_NUM_INITIALIZER
15814 (struct cmd_ptype_mapping_replace_result,
15815 pkt_type, RTE_UINT32);
15818 cmd_ptype_mapping_replace_parsed(
15819 void *parsed_result,
15820 __rte_unused struct cmdline *cl,
15821 __rte_unused void *data)
15823 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15824 int ret = -ENOTSUP;
15826 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15829 #ifdef RTE_NET_I40E
15830 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15840 fprintf(stderr, "invalid ptype 0x%8x or 0x%8x\n",
15841 res->target, res->pkt_type);
15844 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15847 fprintf(stderr, "function not implemented\n");
15850 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15854 static cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15855 .f = cmd_ptype_mapping_replace_parsed,
15858 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15860 (void *)&cmd_ptype_mapping_replace_ptype,
15861 (void *)&cmd_ptype_mapping_replace_mapping,
15862 (void *)&cmd_ptype_mapping_replace_replace,
15863 (void *)&cmd_ptype_mapping_replace_port_id,
15864 (void *)&cmd_ptype_mapping_replace_target,
15865 (void *)&cmd_ptype_mapping_replace_mask,
15866 (void *)&cmd_ptype_mapping_replace_pkt_type,
15871 /* ptype mapping reset */
15873 /* Common result structure for ptype mapping reset */
15874 struct cmd_ptype_mapping_reset_result {
15875 cmdline_fixed_string_t ptype;
15876 cmdline_fixed_string_t mapping;
15877 cmdline_fixed_string_t reset;
15881 /* Common CLI fields for ptype mapping reset*/
15882 static cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15883 TOKEN_STRING_INITIALIZER
15884 (struct cmd_ptype_mapping_reset_result,
15886 static cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15887 TOKEN_STRING_INITIALIZER
15888 (struct cmd_ptype_mapping_reset_result,
15889 mapping, "mapping");
15890 static cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15891 TOKEN_STRING_INITIALIZER
15892 (struct cmd_ptype_mapping_reset_result,
15894 static cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15895 TOKEN_NUM_INITIALIZER
15896 (struct cmd_ptype_mapping_reset_result,
15897 port_id, RTE_UINT16);
15900 cmd_ptype_mapping_reset_parsed(
15901 void *parsed_result,
15902 __rte_unused struct cmdline *cl,
15903 __rte_unused void *data)
15905 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15906 int ret = -ENOTSUP;
15908 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15911 #ifdef RTE_NET_I40E
15912 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15919 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15922 fprintf(stderr, "function not implemented\n");
15925 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15929 static cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15930 .f = cmd_ptype_mapping_reset_parsed,
15932 .help_str = "ptype mapping reset <port_id>",
15934 (void *)&cmd_ptype_mapping_reset_ptype,
15935 (void *)&cmd_ptype_mapping_reset_mapping,
15936 (void *)&cmd_ptype_mapping_reset_reset,
15937 (void *)&cmd_ptype_mapping_reset_port_id,
15942 /* ptype mapping update */
15944 /* Common result structure for ptype mapping update */
15945 struct cmd_ptype_mapping_update_result {
15946 cmdline_fixed_string_t ptype;
15947 cmdline_fixed_string_t mapping;
15948 cmdline_fixed_string_t reset;
15954 /* Common CLI fields for ptype mapping update*/
15955 static cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15956 TOKEN_STRING_INITIALIZER
15957 (struct cmd_ptype_mapping_update_result,
15959 static cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15960 TOKEN_STRING_INITIALIZER
15961 (struct cmd_ptype_mapping_update_result,
15962 mapping, "mapping");
15963 static cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15964 TOKEN_STRING_INITIALIZER
15965 (struct cmd_ptype_mapping_update_result,
15967 static cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15968 TOKEN_NUM_INITIALIZER
15969 (struct cmd_ptype_mapping_update_result,
15970 port_id, RTE_UINT16);
15971 static cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15972 TOKEN_NUM_INITIALIZER
15973 (struct cmd_ptype_mapping_update_result,
15974 hw_ptype, RTE_UINT8);
15975 static cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15976 TOKEN_NUM_INITIALIZER
15977 (struct cmd_ptype_mapping_update_result,
15978 sw_ptype, RTE_UINT32);
15981 cmd_ptype_mapping_update_parsed(
15982 void *parsed_result,
15983 __rte_unused struct cmdline *cl,
15984 __rte_unused void *data)
15986 struct cmd_ptype_mapping_update_result *res = parsed_result;
15987 int ret = -ENOTSUP;
15988 #ifdef RTE_NET_I40E
15989 struct rte_pmd_i40e_ptype_mapping mapping;
15991 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15994 #ifdef RTE_NET_I40E
15995 mapping.hw_ptype = res->hw_ptype;
15996 mapping.sw_ptype = res->sw_ptype;
15997 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
16007 fprintf(stderr, "invalid ptype 0x%8x\n", res->sw_ptype);
16010 fprintf(stderr, "invalid port_id %d\n", res->port_id);
16013 fprintf(stderr, "function not implemented\n");
16016 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
16020 static cmdline_parse_inst_t cmd_ptype_mapping_update = {
16021 .f = cmd_ptype_mapping_update_parsed,
16023 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16025 (void *)&cmd_ptype_mapping_update_ptype,
16026 (void *)&cmd_ptype_mapping_update_mapping,
16027 (void *)&cmd_ptype_mapping_update_update,
16028 (void *)&cmd_ptype_mapping_update_port_id,
16029 (void *)&cmd_ptype_mapping_update_hw_ptype,
16030 (void *)&cmd_ptype_mapping_update_sw_ptype,
16035 /* Common result structure for file commands */
16036 struct cmd_cmdfile_result {
16037 cmdline_fixed_string_t load;
16038 cmdline_fixed_string_t filename;
16041 /* Common CLI fields for file commands */
16042 static cmdline_parse_token_string_t cmd_load_cmdfile =
16043 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16044 static cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16045 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16048 cmd_load_from_file_parsed(
16049 void *parsed_result,
16050 __rte_unused struct cmdline *cl,
16051 __rte_unused void *data)
16053 struct cmd_cmdfile_result *res = parsed_result;
16055 cmdline_read_from_file(res->filename);
16058 static cmdline_parse_inst_t cmd_load_from_file = {
16059 .f = cmd_load_from_file_parsed,
16061 .help_str = "load <filename>",
16063 (void *)&cmd_load_cmdfile,
16064 (void *)&cmd_load_cmdfile_filename,
16069 /* Get Rx offloads capabilities */
16070 struct cmd_rx_offload_get_capa_result {
16071 cmdline_fixed_string_t show;
16072 cmdline_fixed_string_t port;
16074 cmdline_fixed_string_t rx_offload;
16075 cmdline_fixed_string_t capabilities;
16078 static cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
16079 TOKEN_STRING_INITIALIZER
16080 (struct cmd_rx_offload_get_capa_result,
16082 static cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
16083 TOKEN_STRING_INITIALIZER
16084 (struct cmd_rx_offload_get_capa_result,
16086 static cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
16087 TOKEN_NUM_INITIALIZER
16088 (struct cmd_rx_offload_get_capa_result,
16089 port_id, RTE_UINT16);
16090 static cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
16091 TOKEN_STRING_INITIALIZER
16092 (struct cmd_rx_offload_get_capa_result,
16093 rx_offload, "rx_offload");
16094 static cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
16095 TOKEN_STRING_INITIALIZER
16096 (struct cmd_rx_offload_get_capa_result,
16097 capabilities, "capabilities");
16100 print_rx_offloads(uint64_t offloads)
16102 uint64_t single_offload;
16110 begin = __builtin_ctzll(offloads);
16111 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16113 single_offload = 1ULL << begin;
16114 for (bit = begin; bit < end; bit++) {
16115 if (offloads & single_offload)
16117 rte_eth_dev_rx_offload_name(single_offload));
16118 single_offload <<= 1;
16123 cmd_rx_offload_get_capa_parsed(
16124 void *parsed_result,
16125 __rte_unused struct cmdline *cl,
16126 __rte_unused void *data)
16128 struct cmd_rx_offload_get_capa_result *res = parsed_result;
16129 struct rte_eth_dev_info dev_info;
16130 portid_t port_id = res->port_id;
16131 uint64_t queue_offloads;
16132 uint64_t port_offloads;
16135 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16139 queue_offloads = dev_info.rx_queue_offload_capa;
16140 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
16142 printf("Rx Offloading Capabilities of port %d :\n", port_id);
16143 printf(" Per Queue :");
16144 print_rx_offloads(queue_offloads);
16147 printf(" Per Port :");
16148 print_rx_offloads(port_offloads);
16152 static cmdline_parse_inst_t cmd_rx_offload_get_capa = {
16153 .f = cmd_rx_offload_get_capa_parsed,
16155 .help_str = "show port <port_id> rx_offload capabilities",
16157 (void *)&cmd_rx_offload_get_capa_show,
16158 (void *)&cmd_rx_offload_get_capa_port,
16159 (void *)&cmd_rx_offload_get_capa_port_id,
16160 (void *)&cmd_rx_offload_get_capa_rx_offload,
16161 (void *)&cmd_rx_offload_get_capa_capabilities,
16166 /* Get Rx offloads configuration */
16167 struct cmd_rx_offload_get_configuration_result {
16168 cmdline_fixed_string_t show;
16169 cmdline_fixed_string_t port;
16171 cmdline_fixed_string_t rx_offload;
16172 cmdline_fixed_string_t configuration;
16175 static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
16176 TOKEN_STRING_INITIALIZER
16177 (struct cmd_rx_offload_get_configuration_result,
16179 static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
16180 TOKEN_STRING_INITIALIZER
16181 (struct cmd_rx_offload_get_configuration_result,
16183 static cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
16184 TOKEN_NUM_INITIALIZER
16185 (struct cmd_rx_offload_get_configuration_result,
16186 port_id, RTE_UINT16);
16187 static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
16188 TOKEN_STRING_INITIALIZER
16189 (struct cmd_rx_offload_get_configuration_result,
16190 rx_offload, "rx_offload");
16191 static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
16192 TOKEN_STRING_INITIALIZER
16193 (struct cmd_rx_offload_get_configuration_result,
16194 configuration, "configuration");
16197 cmd_rx_offload_get_configuration_parsed(
16198 void *parsed_result,
16199 __rte_unused struct cmdline *cl,
16200 __rte_unused void *data)
16202 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
16203 struct rte_eth_dev_info dev_info;
16204 portid_t port_id = res->port_id;
16205 struct rte_port *port = &ports[port_id];
16206 struct rte_eth_conf dev_conf;
16207 uint64_t port_offloads;
16208 uint64_t queue_offloads;
16209 uint16_t nb_rx_queues;
16213 printf("Rx Offloading Configuration of port %d :\n", port_id);
16215 ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
16219 port_offloads = dev_conf.rxmode.offloads;
16221 print_rx_offloads(port_offloads);
16224 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16228 nb_rx_queues = dev_info.nb_rx_queues;
16229 for (q = 0; q < nb_rx_queues; q++) {
16230 queue_offloads = port->rxq[q].conf.offloads;
16231 printf(" Queue[%2d] :", q);
16232 print_rx_offloads(queue_offloads);
16238 static cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
16239 .f = cmd_rx_offload_get_configuration_parsed,
16241 .help_str = "show port <port_id> rx_offload configuration",
16243 (void *)&cmd_rx_offload_get_configuration_show,
16244 (void *)&cmd_rx_offload_get_configuration_port,
16245 (void *)&cmd_rx_offload_get_configuration_port_id,
16246 (void *)&cmd_rx_offload_get_configuration_rx_offload,
16247 (void *)&cmd_rx_offload_get_configuration_configuration,
16252 /* Enable/Disable a per port offloading */
16253 struct cmd_config_per_port_rx_offload_result {
16254 cmdline_fixed_string_t port;
16255 cmdline_fixed_string_t config;
16257 cmdline_fixed_string_t rx_offload;
16258 cmdline_fixed_string_t offload;
16259 cmdline_fixed_string_t on_off;
16262 static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
16263 TOKEN_STRING_INITIALIZER
16264 (struct cmd_config_per_port_rx_offload_result,
16266 static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
16267 TOKEN_STRING_INITIALIZER
16268 (struct cmd_config_per_port_rx_offload_result,
16270 static cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
16271 TOKEN_NUM_INITIALIZER
16272 (struct cmd_config_per_port_rx_offload_result,
16273 port_id, RTE_UINT16);
16274 static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
16275 TOKEN_STRING_INITIALIZER
16276 (struct cmd_config_per_port_rx_offload_result,
16277 rx_offload, "rx_offload");
16278 static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
16279 TOKEN_STRING_INITIALIZER
16280 (struct cmd_config_per_port_rx_offload_result,
16281 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16282 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16283 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16284 "scatter#buffer_split#timestamp#security#"
16285 "keep_crc#rss_hash");
16286 static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
16287 TOKEN_STRING_INITIALIZER
16288 (struct cmd_config_per_port_rx_offload_result,
16292 search_rx_offload(const char *name)
16294 uint64_t single_offload;
16295 const char *single_name;
16299 single_offload = 1;
16300 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16301 single_name = rte_eth_dev_rx_offload_name(single_offload);
16302 if (!strcasecmp(single_name, name)) {
16306 single_offload <<= 1;
16310 return single_offload;
16316 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16317 __rte_unused struct cmdline *cl,
16318 __rte_unused void *data)
16320 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16321 portid_t port_id = res->port_id;
16322 struct rte_eth_dev_info dev_info;
16323 struct rte_port *port = &ports[port_id];
16324 uint64_t single_offload;
16325 uint16_t nb_rx_queues;
16329 if (port->port_status != RTE_PORT_STOPPED) {
16331 "Error: Can't config offload when Port %d is not stopped\n",
16336 single_offload = search_rx_offload(res->offload);
16337 if (single_offload == 0) {
16338 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16342 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16346 nb_rx_queues = dev_info.nb_rx_queues;
16347 if (!strcmp(res->on_off, "on")) {
16348 port->dev_conf.rxmode.offloads |= single_offload;
16349 for (q = 0; q < nb_rx_queues; q++)
16350 port->rxq[q].conf.offloads |= single_offload;
16352 port->dev_conf.rxmode.offloads &= ~single_offload;
16353 for (q = 0; q < nb_rx_queues; q++)
16354 port->rxq[q].conf.offloads &= ~single_offload;
16357 cmd_reconfig_device_queue(port_id, 1, 1);
16360 static cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16361 .f = cmd_config_per_port_rx_offload_parsed,
16363 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16364 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16365 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16366 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16367 "keep_crc|rss_hash on|off",
16369 (void *)&cmd_config_per_port_rx_offload_result_port,
16370 (void *)&cmd_config_per_port_rx_offload_result_config,
16371 (void *)&cmd_config_per_port_rx_offload_result_port_id,
16372 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16373 (void *)&cmd_config_per_port_rx_offload_result_offload,
16374 (void *)&cmd_config_per_port_rx_offload_result_on_off,
16379 /* Enable/Disable a per queue offloading */
16380 struct cmd_config_per_queue_rx_offload_result {
16381 cmdline_fixed_string_t port;
16383 cmdline_fixed_string_t rxq;
16385 cmdline_fixed_string_t rx_offload;
16386 cmdline_fixed_string_t offload;
16387 cmdline_fixed_string_t on_off;
16390 static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16391 TOKEN_STRING_INITIALIZER
16392 (struct cmd_config_per_queue_rx_offload_result,
16394 static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16395 TOKEN_NUM_INITIALIZER
16396 (struct cmd_config_per_queue_rx_offload_result,
16397 port_id, RTE_UINT16);
16398 static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16399 TOKEN_STRING_INITIALIZER
16400 (struct cmd_config_per_queue_rx_offload_result,
16402 static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16403 TOKEN_NUM_INITIALIZER
16404 (struct cmd_config_per_queue_rx_offload_result,
16405 queue_id, RTE_UINT16);
16406 static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16407 TOKEN_STRING_INITIALIZER
16408 (struct cmd_config_per_queue_rx_offload_result,
16409 rx_offload, "rx_offload");
16410 static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16411 TOKEN_STRING_INITIALIZER
16412 (struct cmd_config_per_queue_rx_offload_result,
16413 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16414 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16415 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16416 "scatter#buffer_split#timestamp#security#keep_crc");
16417 static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16418 TOKEN_STRING_INITIALIZER
16419 (struct cmd_config_per_queue_rx_offload_result,
16423 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16424 __rte_unused struct cmdline *cl,
16425 __rte_unused void *data)
16427 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16428 struct rte_eth_dev_info dev_info;
16429 portid_t port_id = res->port_id;
16430 uint16_t queue_id = res->queue_id;
16431 struct rte_port *port = &ports[port_id];
16432 uint64_t single_offload;
16435 if (port->port_status != RTE_PORT_STOPPED) {
16437 "Error: Can't config offload when Port %d is not stopped\n",
16442 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16446 if (queue_id >= dev_info.nb_rx_queues) {
16448 "Error: input queue_id should be 0 ... %d\n",
16449 dev_info.nb_rx_queues - 1);
16453 single_offload = search_rx_offload(res->offload);
16454 if (single_offload == 0) {
16455 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16459 if (!strcmp(res->on_off, "on"))
16460 port->rxq[queue_id].conf.offloads |= single_offload;
16462 port->rxq[queue_id].conf.offloads &= ~single_offload;
16464 cmd_reconfig_device_queue(port_id, 1, 1);
16467 static cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16468 .f = cmd_config_per_queue_rx_offload_parsed,
16470 .help_str = "port <port_id> rxq <queue_id> rx_offload "
16471 "vlan_strip|ipv4_cksum|"
16472 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16473 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16474 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16477 (void *)&cmd_config_per_queue_rx_offload_result_port,
16478 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
16479 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
16480 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16481 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16482 (void *)&cmd_config_per_queue_rx_offload_result_offload,
16483 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
16488 /* Get Tx offloads capabilities */
16489 struct cmd_tx_offload_get_capa_result {
16490 cmdline_fixed_string_t show;
16491 cmdline_fixed_string_t port;
16493 cmdline_fixed_string_t tx_offload;
16494 cmdline_fixed_string_t capabilities;
16497 static cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16498 TOKEN_STRING_INITIALIZER
16499 (struct cmd_tx_offload_get_capa_result,
16501 static cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16502 TOKEN_STRING_INITIALIZER
16503 (struct cmd_tx_offload_get_capa_result,
16505 static cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16506 TOKEN_NUM_INITIALIZER
16507 (struct cmd_tx_offload_get_capa_result,
16508 port_id, RTE_UINT16);
16509 static cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16510 TOKEN_STRING_INITIALIZER
16511 (struct cmd_tx_offload_get_capa_result,
16512 tx_offload, "tx_offload");
16513 static cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16514 TOKEN_STRING_INITIALIZER
16515 (struct cmd_tx_offload_get_capa_result,
16516 capabilities, "capabilities");
16519 print_tx_offloads(uint64_t offloads)
16521 uint64_t single_offload;
16529 begin = __builtin_ctzll(offloads);
16530 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16532 single_offload = 1ULL << begin;
16533 for (bit = begin; bit < end; bit++) {
16534 if (offloads & single_offload)
16536 rte_eth_dev_tx_offload_name(single_offload));
16537 single_offload <<= 1;
16542 cmd_tx_offload_get_capa_parsed(
16543 void *parsed_result,
16544 __rte_unused struct cmdline *cl,
16545 __rte_unused void *data)
16547 struct cmd_tx_offload_get_capa_result *res = parsed_result;
16548 struct rte_eth_dev_info dev_info;
16549 portid_t port_id = res->port_id;
16550 uint64_t queue_offloads;
16551 uint64_t port_offloads;
16554 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16558 queue_offloads = dev_info.tx_queue_offload_capa;
16559 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16561 printf("Tx Offloading Capabilities of port %d :\n", port_id);
16562 printf(" Per Queue :");
16563 print_tx_offloads(queue_offloads);
16566 printf(" Per Port :");
16567 print_tx_offloads(port_offloads);
16571 static cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16572 .f = cmd_tx_offload_get_capa_parsed,
16574 .help_str = "show port <port_id> tx_offload capabilities",
16576 (void *)&cmd_tx_offload_get_capa_show,
16577 (void *)&cmd_tx_offload_get_capa_port,
16578 (void *)&cmd_tx_offload_get_capa_port_id,
16579 (void *)&cmd_tx_offload_get_capa_tx_offload,
16580 (void *)&cmd_tx_offload_get_capa_capabilities,
16585 /* Get Tx offloads configuration */
16586 struct cmd_tx_offload_get_configuration_result {
16587 cmdline_fixed_string_t show;
16588 cmdline_fixed_string_t port;
16590 cmdline_fixed_string_t tx_offload;
16591 cmdline_fixed_string_t configuration;
16594 static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16595 TOKEN_STRING_INITIALIZER
16596 (struct cmd_tx_offload_get_configuration_result,
16598 static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16599 TOKEN_STRING_INITIALIZER
16600 (struct cmd_tx_offload_get_configuration_result,
16602 static cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16603 TOKEN_NUM_INITIALIZER
16604 (struct cmd_tx_offload_get_configuration_result,
16605 port_id, RTE_UINT16);
16606 static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16607 TOKEN_STRING_INITIALIZER
16608 (struct cmd_tx_offload_get_configuration_result,
16609 tx_offload, "tx_offload");
16610 static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16611 TOKEN_STRING_INITIALIZER
16612 (struct cmd_tx_offload_get_configuration_result,
16613 configuration, "configuration");
16616 cmd_tx_offload_get_configuration_parsed(
16617 void *parsed_result,
16618 __rte_unused struct cmdline *cl,
16619 __rte_unused void *data)
16621 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16622 struct rte_eth_dev_info dev_info;
16623 portid_t port_id = res->port_id;
16624 struct rte_port *port = &ports[port_id];
16625 struct rte_eth_conf dev_conf;
16626 uint64_t port_offloads;
16627 uint64_t queue_offloads;
16628 uint16_t nb_tx_queues;
16632 printf("Tx Offloading Configuration of port %d :\n", port_id);
16634 ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
16638 port_offloads = dev_conf.txmode.offloads;
16640 print_tx_offloads(port_offloads);
16643 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16647 nb_tx_queues = dev_info.nb_tx_queues;
16648 for (q = 0; q < nb_tx_queues; q++) {
16649 queue_offloads = port->txq[q].conf.offloads;
16650 printf(" Queue[%2d] :", q);
16651 print_tx_offloads(queue_offloads);
16657 static cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16658 .f = cmd_tx_offload_get_configuration_parsed,
16660 .help_str = "show port <port_id> tx_offload configuration",
16662 (void *)&cmd_tx_offload_get_configuration_show,
16663 (void *)&cmd_tx_offload_get_configuration_port,
16664 (void *)&cmd_tx_offload_get_configuration_port_id,
16665 (void *)&cmd_tx_offload_get_configuration_tx_offload,
16666 (void *)&cmd_tx_offload_get_configuration_configuration,
16671 /* Enable/Disable a per port offloading */
16672 struct cmd_config_per_port_tx_offload_result {
16673 cmdline_fixed_string_t port;
16674 cmdline_fixed_string_t config;
16676 cmdline_fixed_string_t tx_offload;
16677 cmdline_fixed_string_t offload;
16678 cmdline_fixed_string_t on_off;
16681 static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16682 TOKEN_STRING_INITIALIZER
16683 (struct cmd_config_per_port_tx_offload_result,
16685 static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16686 TOKEN_STRING_INITIALIZER
16687 (struct cmd_config_per_port_tx_offload_result,
16689 static cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16690 TOKEN_NUM_INITIALIZER
16691 (struct cmd_config_per_port_tx_offload_result,
16692 port_id, RTE_UINT16);
16693 static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16694 TOKEN_STRING_INITIALIZER
16695 (struct cmd_config_per_port_tx_offload_result,
16696 tx_offload, "tx_offload");
16697 static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16698 TOKEN_STRING_INITIALIZER
16699 (struct cmd_config_per_port_tx_offload_result,
16700 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16701 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16702 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16703 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16704 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16705 "send_on_timestamp");
16706 static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16707 TOKEN_STRING_INITIALIZER
16708 (struct cmd_config_per_port_tx_offload_result,
16712 search_tx_offload(const char *name)
16714 uint64_t single_offload;
16715 const char *single_name;
16719 single_offload = 1;
16720 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16721 single_name = rte_eth_dev_tx_offload_name(single_offload);
16722 if (single_name == NULL)
16724 if (!strcasecmp(single_name, name)) {
16727 } else if (!strcasecmp(single_name, "UNKNOWN"))
16729 single_offload <<= 1;
16733 return single_offload;
16739 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16740 __rte_unused struct cmdline *cl,
16741 __rte_unused void *data)
16743 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16744 portid_t port_id = res->port_id;
16745 struct rte_eth_dev_info dev_info;
16746 struct rte_port *port = &ports[port_id];
16747 uint64_t single_offload;
16748 uint16_t nb_tx_queues;
16752 if (port->port_status != RTE_PORT_STOPPED) {
16754 "Error: Can't config offload when Port %d is not stopped\n",
16759 single_offload = search_tx_offload(res->offload);
16760 if (single_offload == 0) {
16761 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16765 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16769 nb_tx_queues = dev_info.nb_tx_queues;
16770 if (!strcmp(res->on_off, "on")) {
16771 port->dev_conf.txmode.offloads |= single_offload;
16772 for (q = 0; q < nb_tx_queues; q++)
16773 port->txq[q].conf.offloads |= single_offload;
16775 port->dev_conf.txmode.offloads &= ~single_offload;
16776 for (q = 0; q < nb_tx_queues; q++)
16777 port->txq[q].conf.offloads &= ~single_offload;
16780 cmd_reconfig_device_queue(port_id, 1, 1);
16783 static cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16784 .f = cmd_config_per_port_tx_offload_parsed,
16786 .help_str = "port config <port_id> tx_offload "
16787 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16788 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16789 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16790 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16791 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16792 "send_on_timestamp on|off",
16794 (void *)&cmd_config_per_port_tx_offload_result_port,
16795 (void *)&cmd_config_per_port_tx_offload_result_config,
16796 (void *)&cmd_config_per_port_tx_offload_result_port_id,
16797 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16798 (void *)&cmd_config_per_port_tx_offload_result_offload,
16799 (void *)&cmd_config_per_port_tx_offload_result_on_off,
16804 /* Enable/Disable a per queue offloading */
16805 struct cmd_config_per_queue_tx_offload_result {
16806 cmdline_fixed_string_t port;
16808 cmdline_fixed_string_t txq;
16810 cmdline_fixed_string_t tx_offload;
16811 cmdline_fixed_string_t offload;
16812 cmdline_fixed_string_t on_off;
16815 static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16816 TOKEN_STRING_INITIALIZER
16817 (struct cmd_config_per_queue_tx_offload_result,
16819 static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16820 TOKEN_NUM_INITIALIZER
16821 (struct cmd_config_per_queue_tx_offload_result,
16822 port_id, RTE_UINT16);
16823 static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16824 TOKEN_STRING_INITIALIZER
16825 (struct cmd_config_per_queue_tx_offload_result,
16827 static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16828 TOKEN_NUM_INITIALIZER
16829 (struct cmd_config_per_queue_tx_offload_result,
16830 queue_id, RTE_UINT16);
16831 static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16832 TOKEN_STRING_INITIALIZER
16833 (struct cmd_config_per_queue_tx_offload_result,
16834 tx_offload, "tx_offload");
16835 static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16836 TOKEN_STRING_INITIALIZER
16837 (struct cmd_config_per_queue_tx_offload_result,
16838 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16839 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16840 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16841 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16842 "mt_lockfree#multi_segs#mbuf_fast_free#security");
16843 static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16844 TOKEN_STRING_INITIALIZER
16845 (struct cmd_config_per_queue_tx_offload_result,
16849 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16850 __rte_unused struct cmdline *cl,
16851 __rte_unused void *data)
16853 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16854 struct rte_eth_dev_info dev_info;
16855 portid_t port_id = res->port_id;
16856 uint16_t queue_id = res->queue_id;
16857 struct rte_port *port = &ports[port_id];
16858 uint64_t single_offload;
16861 if (port->port_status != RTE_PORT_STOPPED) {
16863 "Error: Can't config offload when Port %d is not stopped\n",
16868 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16872 if (queue_id >= dev_info.nb_tx_queues) {
16874 "Error: input queue_id should be 0 ... %d\n",
16875 dev_info.nb_tx_queues - 1);
16879 single_offload = search_tx_offload(res->offload);
16880 if (single_offload == 0) {
16881 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16885 if (!strcmp(res->on_off, "on"))
16886 port->txq[queue_id].conf.offloads |= single_offload;
16888 port->txq[queue_id].conf.offloads &= ~single_offload;
16890 cmd_reconfig_device_queue(port_id, 1, 1);
16893 static cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16894 .f = cmd_config_per_queue_tx_offload_parsed,
16896 .help_str = "port <port_id> txq <queue_id> tx_offload "
16897 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16898 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16899 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16900 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16901 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16904 (void *)&cmd_config_per_queue_tx_offload_result_port,
16905 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16906 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16907 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16908 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16909 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16910 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16915 /* *** configure tx_metadata for specific port *** */
16916 struct cmd_config_tx_metadata_specific_result {
16917 cmdline_fixed_string_t port;
16918 cmdline_fixed_string_t keyword;
16920 cmdline_fixed_string_t item;
16925 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16926 __rte_unused struct cmdline *cl,
16927 __rte_unused void *data)
16929 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16931 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16933 ports[res->port_id].tx_metadata = res->value;
16934 /* Add/remove callback to insert valid metadata in every Tx packet. */
16935 if (ports[res->port_id].tx_metadata)
16936 add_tx_md_callback(res->port_id);
16938 remove_tx_md_callback(res->port_id);
16939 rte_flow_dynf_metadata_register();
16942 static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16943 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16945 static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16946 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16947 keyword, "config");
16948 static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16949 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16950 port_id, RTE_UINT16);
16951 static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16952 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16953 item, "tx_metadata");
16954 static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16955 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16956 value, RTE_UINT32);
16958 static cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16959 .f = cmd_config_tx_metadata_specific_parsed,
16961 .help_str = "port config <port_id> tx_metadata <value>",
16963 (void *)&cmd_config_tx_metadata_specific_port,
16964 (void *)&cmd_config_tx_metadata_specific_keyword,
16965 (void *)&cmd_config_tx_metadata_specific_id,
16966 (void *)&cmd_config_tx_metadata_specific_item,
16967 (void *)&cmd_config_tx_metadata_specific_value,
16972 /* *** set dynf *** */
16973 struct cmd_config_tx_dynf_specific_result {
16974 cmdline_fixed_string_t port;
16975 cmdline_fixed_string_t keyword;
16977 cmdline_fixed_string_t item;
16978 cmdline_fixed_string_t name;
16979 cmdline_fixed_string_t value;
16983 cmd_config_dynf_specific_parsed(void *parsed_result,
16984 __rte_unused struct cmdline *cl,
16985 __rte_unused void *data)
16987 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16988 struct rte_mbuf_dynflag desc_flag;
16990 uint64_t old_port_flags;
16992 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16994 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16996 if (strlcpy(desc_flag.name, res->name,
16997 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16998 fprintf(stderr, "Flag name too long\n");
17001 desc_flag.flags = 0;
17002 flag = rte_mbuf_dynflag_register(&desc_flag);
17004 fprintf(stderr, "Can't register flag\n");
17007 strcpy(dynf_names[flag], desc_flag.name);
17009 old_port_flags = ports[res->port_id].mbuf_dynf;
17010 if (!strcmp(res->value, "set")) {
17011 ports[res->port_id].mbuf_dynf |= 1UL << flag;
17012 if (old_port_flags == 0)
17013 add_tx_dynf_callback(res->port_id);
17015 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
17016 if (ports[res->port_id].mbuf_dynf == 0)
17017 remove_tx_dynf_callback(res->port_id);
17021 static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
17022 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17024 static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
17025 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17026 keyword, "config");
17027 static cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
17028 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17029 port_id, RTE_UINT16);
17030 static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
17031 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17033 static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
17034 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17036 static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
17037 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
17038 value, "set#clear");
17040 static cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
17041 .f = cmd_config_dynf_specific_parsed,
17043 .help_str = "port config <port id> dynf <name> set|clear",
17045 (void *)&cmd_config_tx_dynf_specific_port,
17046 (void *)&cmd_config_tx_dynf_specific_keyword,
17047 (void *)&cmd_config_tx_dynf_specific_port_id,
17048 (void *)&cmd_config_tx_dynf_specific_item,
17049 (void *)&cmd_config_tx_dynf_specific_name,
17050 (void *)&cmd_config_tx_dynf_specific_value,
17055 /* *** display tx_metadata per port configuration *** */
17056 struct cmd_show_tx_metadata_result {
17057 cmdline_fixed_string_t cmd_show;
17058 cmdline_fixed_string_t cmd_port;
17059 cmdline_fixed_string_t cmd_keyword;
17064 cmd_show_tx_metadata_parsed(void *parsed_result,
17065 __rte_unused struct cmdline *cl,
17066 __rte_unused void *data)
17068 struct cmd_show_tx_metadata_result *res = parsed_result;
17070 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17071 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17074 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
17075 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
17076 ports[res->cmd_pid].tx_metadata);
17080 static cmdline_parse_token_string_t cmd_show_tx_metadata_show =
17081 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17083 static cmdline_parse_token_string_t cmd_show_tx_metadata_port =
17084 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17086 static cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
17087 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
17088 cmd_pid, RTE_UINT16);
17089 static cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
17090 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
17091 cmd_keyword, "tx_metadata");
17093 static cmdline_parse_inst_t cmd_show_tx_metadata = {
17094 .f = cmd_show_tx_metadata_parsed,
17096 .help_str = "show port <port_id> tx_metadata",
17098 (void *)&cmd_show_tx_metadata_show,
17099 (void *)&cmd_show_tx_metadata_port,
17100 (void *)&cmd_show_tx_metadata_pid,
17101 (void *)&cmd_show_tx_metadata_keyword,
17106 /* *** show fec capability per port configuration *** */
17107 struct cmd_show_fec_capability_result {
17108 cmdline_fixed_string_t cmd_show;
17109 cmdline_fixed_string_t cmd_port;
17110 cmdline_fixed_string_t cmd_fec;
17111 cmdline_fixed_string_t cmd_keyword;
17116 cmd_show_fec_capability_parsed(void *parsed_result,
17117 __rte_unused struct cmdline *cl,
17118 __rte_unused void *data)
17120 struct cmd_show_fec_capability_result *res = parsed_result;
17121 struct rte_eth_fec_capa *speed_fec_capa;
17125 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17126 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
17130 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
17131 if (ret == -ENOTSUP) {
17132 fprintf(stderr, "Function not implemented\n");
17134 } else if (ret < 0) {
17135 fprintf(stderr, "Get FEC capability failed: %d\n", ret);
17139 num = (unsigned int)ret;
17140 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
17141 if (speed_fec_capa == NULL) {
17142 fprintf(stderr, "Failed to alloc FEC capability buffer\n");
17146 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
17148 fprintf(stderr, "Error getting FEC capability: %d\n", ret);
17152 show_fec_capability(num, speed_fec_capa);
17154 free(speed_fec_capa);
17157 static cmdline_parse_token_string_t cmd_show_fec_capability_show =
17158 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17160 static cmdline_parse_token_string_t cmd_show_fec_capability_port =
17161 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17163 static cmdline_parse_token_num_t cmd_show_fec_capability_pid =
17164 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
17165 cmd_pid, RTE_UINT16);
17166 static cmdline_parse_token_string_t cmd_show_fec_capability_fec =
17167 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17169 static cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
17170 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17171 cmd_keyword, "capabilities");
17173 static cmdline_parse_inst_t cmd_show_capability = {
17174 .f = cmd_show_fec_capability_parsed,
17176 .help_str = "show port <port_id> fec capabilities",
17178 (void *)&cmd_show_fec_capability_show,
17179 (void *)&cmd_show_fec_capability_port,
17180 (void *)&cmd_show_fec_capability_pid,
17181 (void *)&cmd_show_fec_capability_fec,
17182 (void *)&cmd_show_fec_capability_keyword,
17187 /* *** show fec mode per port configuration *** */
17188 struct cmd_show_fec_metadata_result {
17189 cmdline_fixed_string_t cmd_show;
17190 cmdline_fixed_string_t cmd_port;
17191 cmdline_fixed_string_t cmd_keyword;
17196 cmd_show_fec_mode_parsed(void *parsed_result,
17197 __rte_unused struct cmdline *cl,
17198 __rte_unused void *data)
17200 #define FEC_NAME_SIZE 16
17201 struct cmd_show_fec_metadata_result *res = parsed_result;
17203 char buf[FEC_NAME_SIZE];
17206 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17207 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
17210 ret = rte_eth_fec_get(res->cmd_pid, &mode);
17211 if (ret == -ENOTSUP) {
17212 fprintf(stderr, "Function not implemented\n");
17214 } else if (ret < 0) {
17215 fprintf(stderr, "Get FEC mode failed\n");
17220 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
17221 strlcpy(buf, "off", sizeof(buf));
17223 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
17224 strlcpy(buf, "auto", sizeof(buf));
17226 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
17227 strlcpy(buf, "baser", sizeof(buf));
17229 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
17230 strlcpy(buf, "rs", sizeof(buf));
17236 printf("%s\n", buf);
17239 static cmdline_parse_token_string_t cmd_show_fec_mode_show =
17240 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17242 static cmdline_parse_token_string_t cmd_show_fec_mode_port =
17243 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17245 static cmdline_parse_token_num_t cmd_show_fec_mode_pid =
17246 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
17247 cmd_pid, RTE_UINT16);
17248 static cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
17249 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17250 cmd_keyword, "fec_mode");
17252 static cmdline_parse_inst_t cmd_show_fec_mode = {
17253 .f = cmd_show_fec_mode_parsed,
17255 .help_str = "show port <port_id> fec_mode",
17257 (void *)&cmd_show_fec_mode_show,
17258 (void *)&cmd_show_fec_mode_port,
17259 (void *)&cmd_show_fec_mode_pid,
17260 (void *)&cmd_show_fec_mode_keyword,
17265 /* *** set fec mode per port configuration *** */
17266 struct cmd_set_port_fec_mode {
17267 cmdline_fixed_string_t set;
17268 cmdline_fixed_string_t port;
17270 cmdline_fixed_string_t fec_mode;
17271 cmdline_fixed_string_t fec_value;
17274 /* Common CLI fields for set fec mode */
17275 static cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
17276 TOKEN_STRING_INITIALIZER
17277 (struct cmd_set_port_fec_mode,
17279 static cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
17280 TOKEN_STRING_INITIALIZER
17281 (struct cmd_set_port_fec_mode,
17283 static cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
17284 TOKEN_NUM_INITIALIZER
17285 (struct cmd_set_port_fec_mode,
17286 port_id, RTE_UINT16);
17287 static cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
17288 TOKEN_STRING_INITIALIZER
17289 (struct cmd_set_port_fec_mode,
17290 fec_mode, "fec_mode");
17291 static cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
17292 TOKEN_STRING_INITIALIZER
17293 (struct cmd_set_port_fec_mode,
17297 cmd_set_port_fec_mode_parsed(
17298 void *parsed_result,
17299 __rte_unused struct cmdline *cl,
17300 __rte_unused void *data)
17302 struct cmd_set_port_fec_mode *res = parsed_result;
17303 uint16_t port_id = res->port_id;
17307 ret = parse_fec_mode(res->fec_value, &fec_capa);
17309 fprintf(stderr, "Unknown fec mode: %s for port %d\n",
17310 res->fec_value, port_id);
17314 ret = rte_eth_fec_set(port_id, fec_capa);
17315 if (ret == -ENOTSUP) {
17316 fprintf(stderr, "Function not implemented\n");
17318 } else if (ret < 0) {
17319 fprintf(stderr, "Set FEC mode failed\n");
17324 static cmdline_parse_inst_t cmd_set_fec_mode = {
17325 .f = cmd_set_port_fec_mode_parsed,
17327 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
17329 (void *)&cmd_set_port_fec_mode_set,
17330 (void *)&cmd_set_port_fec_mode_port,
17331 (void *)&cmd_set_port_fec_mode_port_id,
17332 (void *)&cmd_set_port_fec_mode_str,
17333 (void *)&cmd_set_port_fec_mode_value,
17338 /* *** set available descriptors threshold for an RxQ of a port *** */
17339 struct cmd_set_rxq_avail_thresh_result {
17340 cmdline_fixed_string_t set;
17341 cmdline_fixed_string_t port;
17343 cmdline_fixed_string_t rxq;
17345 cmdline_fixed_string_t avail_thresh;
17346 uint8_t avail_thresh_num;
17349 static void cmd_set_rxq_avail_thresh_parsed(void *parsed_result,
17350 __rte_unused struct cmdline *cl,
17351 __rte_unused void *data)
17353 struct cmd_set_rxq_avail_thresh_result *res = parsed_result;
17356 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
17357 && (strcmp(res->rxq, "rxq") == 0)
17358 && (strcmp(res->avail_thresh, "avail_thresh") == 0))
17359 ret = set_rxq_avail_thresh(res->port_num, res->rxq_num,
17360 res->avail_thresh_num);
17362 printf("rxq_avail_thresh_cmd error: (%s)\n", strerror(-ret));
17366 static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_set =
17367 TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
17369 static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_port =
17370 TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
17372 static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_portnum =
17373 TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
17374 port_num, RTE_UINT16);
17375 static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_rxq =
17376 TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
17378 static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_rxqnum =
17379 TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
17380 rxq_num, RTE_UINT16);
17381 static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_avail_thresh =
17382 TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
17383 avail_thresh, "avail_thresh");
17384 static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_avail_threshnum =
17385 TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
17386 avail_thresh_num, RTE_UINT8);
17388 static cmdline_parse_inst_t cmd_set_rxq_avail_thresh = {
17389 .f = cmd_set_rxq_avail_thresh_parsed,
17392 "set port <port_id> rxq <queue_id> avail_thresh <0..99>: "
17393 "Set available descriptors threshold for Rx queue",
17395 (void *)&cmd_set_rxq_avail_thresh_set,
17396 (void *)&cmd_set_rxq_avail_thresh_port,
17397 (void *)&cmd_set_rxq_avail_thresh_portnum,
17398 (void *)&cmd_set_rxq_avail_thresh_rxq,
17399 (void *)&cmd_set_rxq_avail_thresh_rxqnum,
17400 (void *)&cmd_set_rxq_avail_thresh_avail_thresh,
17401 (void *)&cmd_set_rxq_avail_thresh_avail_threshnum,
17406 /* show port supported ptypes */
17408 /* Common result structure for show port ptypes */
17409 struct cmd_show_port_supported_ptypes_result {
17410 cmdline_fixed_string_t show;
17411 cmdline_fixed_string_t port;
17413 cmdline_fixed_string_t ptypes;
17416 /* Common CLI fields for show port ptypes */
17417 static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
17418 TOKEN_STRING_INITIALIZER
17419 (struct cmd_show_port_supported_ptypes_result,
17421 static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
17422 TOKEN_STRING_INITIALIZER
17423 (struct cmd_show_port_supported_ptypes_result,
17425 static cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
17426 TOKEN_NUM_INITIALIZER
17427 (struct cmd_show_port_supported_ptypes_result,
17428 port_id, RTE_UINT16);
17429 static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
17430 TOKEN_STRING_INITIALIZER
17431 (struct cmd_show_port_supported_ptypes_result,
17435 cmd_show_port_supported_ptypes_parsed(
17436 void *parsed_result,
17437 __rte_unused struct cmdline *cl,
17438 __rte_unused void *data)
17440 #define RSVD_PTYPE_MASK 0xf0000000
17441 #define MAX_PTYPES_PER_LAYER 16
17442 #define LTYPE_NAMESIZE 32
17443 #define PTYPE_NAMESIZE 256
17444 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
17445 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
17446 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
17447 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
17448 uint16_t port_id = res->port_id;
17451 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
17455 while (ptype_mask != RSVD_PTYPE_MASK) {
17457 switch (ptype_mask) {
17458 case RTE_PTYPE_L2_MASK:
17459 strlcpy(ltype, "L2", sizeof(ltype));
17461 case RTE_PTYPE_L3_MASK:
17462 strlcpy(ltype, "L3", sizeof(ltype));
17464 case RTE_PTYPE_L4_MASK:
17465 strlcpy(ltype, "L4", sizeof(ltype));
17467 case RTE_PTYPE_TUNNEL_MASK:
17468 strlcpy(ltype, "Tunnel", sizeof(ltype));
17470 case RTE_PTYPE_INNER_L2_MASK:
17471 strlcpy(ltype, "Inner L2", sizeof(ltype));
17473 case RTE_PTYPE_INNER_L3_MASK:
17474 strlcpy(ltype, "Inner L3", sizeof(ltype));
17476 case RTE_PTYPE_INNER_L4_MASK:
17477 strlcpy(ltype, "Inner L4", sizeof(ltype));
17483 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
17484 ptype_mask, ptypes,
17485 MAX_PTYPES_PER_LAYER);
17488 printf("Supported %s ptypes:\n", ltype);
17490 printf("%s ptypes unsupported\n", ltype);
17492 for (i = 0; i < ret; ++i) {
17493 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
17494 printf("%s\n", buf);
17501 static cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
17502 .f = cmd_show_port_supported_ptypes_parsed,
17504 .help_str = "show port <port_id> ptypes",
17506 (void *)&cmd_show_port_supported_ptypes_show,
17507 (void *)&cmd_show_port_supported_ptypes_port,
17508 (void *)&cmd_show_port_supported_ptypes_port_id,
17509 (void *)&cmd_show_port_supported_ptypes_ptypes,
17514 /* *** display rx/tx descriptor status *** */
17515 struct cmd_show_rx_tx_desc_status_result {
17516 cmdline_fixed_string_t cmd_show;
17517 cmdline_fixed_string_t cmd_port;
17518 cmdline_fixed_string_t cmd_keyword;
17519 cmdline_fixed_string_t cmd_desc;
17520 cmdline_fixed_string_t cmd_status;
17527 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
17528 __rte_unused struct cmdline *cl,
17529 __rte_unused void *data)
17531 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
17534 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17535 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17539 if (!strcmp(res->cmd_keyword, "rxq")) {
17540 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
17544 "Invalid input: queue id = %d, desc id = %d\n",
17545 res->cmd_qid, res->cmd_did);
17548 if (rc == RTE_ETH_RX_DESC_AVAIL)
17549 printf("Desc status = AVAILABLE\n");
17550 else if (rc == RTE_ETH_RX_DESC_DONE)
17551 printf("Desc status = DONE\n");
17553 printf("Desc status = UNAVAILABLE\n");
17554 } else if (!strcmp(res->cmd_keyword, "txq")) {
17555 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17559 "Invalid input: queue id = %d, desc id = %d\n",
17560 res->cmd_qid, res->cmd_did);
17563 if (rc == RTE_ETH_TX_DESC_FULL)
17564 printf("Desc status = FULL\n");
17565 else if (rc == RTE_ETH_TX_DESC_DONE)
17566 printf("Desc status = DONE\n");
17568 printf("Desc status = UNAVAILABLE\n");
17572 static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17573 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17575 static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17576 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17578 static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17579 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17580 cmd_pid, RTE_UINT16);
17581 static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17582 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17583 cmd_keyword, "rxq#txq");
17584 static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17585 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17586 cmd_qid, RTE_UINT16);
17587 static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17588 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17590 static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17591 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17592 cmd_did, RTE_UINT16);
17593 static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17594 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17595 cmd_status, "status");
17596 static cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17597 .f = cmd_show_rx_tx_desc_status_parsed,
17599 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17602 (void *)&cmd_show_rx_tx_desc_status_show,
17603 (void *)&cmd_show_rx_tx_desc_status_port,
17604 (void *)&cmd_show_rx_tx_desc_status_pid,
17605 (void *)&cmd_show_rx_tx_desc_status_keyword,
17606 (void *)&cmd_show_rx_tx_desc_status_qid,
17607 (void *)&cmd_show_rx_tx_desc_status_desc,
17608 (void *)&cmd_show_rx_tx_desc_status_did,
17609 (void *)&cmd_show_rx_tx_desc_status_status,
17614 /* *** display rx queue desc used count *** */
17615 struct cmd_show_rx_queue_desc_used_count_result {
17616 cmdline_fixed_string_t cmd_show;
17617 cmdline_fixed_string_t cmd_port;
17618 cmdline_fixed_string_t cmd_rxq;
17619 cmdline_fixed_string_t cmd_desc;
17620 cmdline_fixed_string_t cmd_used;
17621 cmdline_fixed_string_t cmd_count;
17627 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17628 __rte_unused struct cmdline *cl,
17629 __rte_unused void *data)
17631 struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17634 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17635 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17639 rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17641 fprintf(stderr, "Invalid queueid = %d\n", res->cmd_qid);
17644 printf("Used desc count = %d\n", rc);
17647 static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17648 TOKEN_STRING_INITIALIZER
17649 (struct cmd_show_rx_queue_desc_used_count_result,
17651 static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17652 TOKEN_STRING_INITIALIZER
17653 (struct cmd_show_rx_queue_desc_used_count_result,
17655 static cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17656 TOKEN_NUM_INITIALIZER
17657 (struct cmd_show_rx_queue_desc_used_count_result,
17658 cmd_pid, RTE_UINT16);
17659 static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17660 TOKEN_STRING_INITIALIZER
17661 (struct cmd_show_rx_queue_desc_used_count_result,
17663 static cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17664 TOKEN_NUM_INITIALIZER
17665 (struct cmd_show_rx_queue_desc_used_count_result,
17666 cmd_qid, RTE_UINT16);
17667 static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17668 TOKEN_STRING_INITIALIZER
17669 (struct cmd_show_rx_queue_desc_used_count_result,
17670 cmd_count, "desc");
17671 static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17672 TOKEN_STRING_INITIALIZER
17673 (struct cmd_show_rx_queue_desc_used_count_result,
17674 cmd_count, "used");
17675 static cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17676 TOKEN_STRING_INITIALIZER
17677 (struct cmd_show_rx_queue_desc_used_count_result,
17678 cmd_count, "count");
17679 static cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17680 .f = cmd_show_rx_queue_desc_used_count_parsed,
17682 .help_str = "show port <port_id> rxq <queue_id> desc used count",
17684 (void *)&cmd_show_rx_queue_desc_used_count_show,
17685 (void *)&cmd_show_rx_queue_desc_used_count_port,
17686 (void *)&cmd_show_rx_queue_desc_used_count_pid,
17687 (void *)&cmd_show_rx_queue_desc_used_count_rxq,
17688 (void *)&cmd_show_rx_queue_desc_used_count_qid,
17689 (void *)&cmd_show_rx_queue_desc_used_count_desc,
17690 (void *)&cmd_show_rx_queue_desc_used_count_used,
17691 (void *)&cmd_show_rx_queue_desc_used_count_count,
17696 /* Common result structure for set port ptypes */
17697 struct cmd_set_port_ptypes_result {
17698 cmdline_fixed_string_t set;
17699 cmdline_fixed_string_t port;
17701 cmdline_fixed_string_t ptype_mask;
17705 /* Common CLI fields for set port ptypes */
17706 static cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17707 TOKEN_STRING_INITIALIZER
17708 (struct cmd_set_port_ptypes_result,
17710 static cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17711 TOKEN_STRING_INITIALIZER
17712 (struct cmd_set_port_ptypes_result,
17714 static cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17715 TOKEN_NUM_INITIALIZER
17716 (struct cmd_set_port_ptypes_result,
17717 port_id, RTE_UINT16);
17718 static cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17719 TOKEN_STRING_INITIALIZER
17720 (struct cmd_set_port_ptypes_result,
17721 ptype_mask, "ptype_mask");
17722 static cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17723 TOKEN_NUM_INITIALIZER
17724 (struct cmd_set_port_ptypes_result,
17728 cmd_set_port_ptypes_parsed(
17729 void *parsed_result,
17730 __rte_unused struct cmdline *cl,
17731 __rte_unused void *data)
17733 struct cmd_set_port_ptypes_result *res = parsed_result;
17734 #define PTYPE_NAMESIZE 256
17735 char ptype_name[PTYPE_NAMESIZE];
17736 uint16_t port_id = res->port_id;
17737 uint32_t ptype_mask = res->mask;
17740 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17743 fprintf(stderr, "Port %d doesn't support any ptypes.\n",
17748 uint32_t ptypes[ret];
17750 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17752 fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
17757 printf("Successfully set following ptypes for Port %d\n", port_id);
17758 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17759 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17760 printf("%s\n", ptype_name);
17763 clear_ptypes = false;
17766 static cmdline_parse_inst_t cmd_set_port_ptypes = {
17767 .f = cmd_set_port_ptypes_parsed,
17769 .help_str = "set port <port_id> ptype_mask <mask>",
17771 (void *)&cmd_set_port_ptypes_set,
17772 (void *)&cmd_set_port_ptypes_port,
17773 (void *)&cmd_set_port_ptypes_port_id,
17774 (void *)&cmd_set_port_ptypes_mask_str,
17775 (void *)&cmd_set_port_ptypes_mask_u32,
17780 /* *** display mac addresses added to a port *** */
17781 struct cmd_showport_macs_result {
17782 cmdline_fixed_string_t cmd_show;
17783 cmdline_fixed_string_t cmd_port;
17784 cmdline_fixed_string_t cmd_keyword;
17789 cmd_showport_macs_parsed(void *parsed_result,
17790 __rte_unused struct cmdline *cl,
17791 __rte_unused void *data)
17793 struct cmd_showport_macs_result *res = parsed_result;
17795 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17798 if (!strcmp(res->cmd_keyword, "macs"))
17799 show_macs(res->cmd_pid);
17800 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17801 show_mcast_macs(res->cmd_pid);
17804 static cmdline_parse_token_string_t cmd_showport_macs_show =
17805 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17807 static cmdline_parse_token_string_t cmd_showport_macs_port =
17808 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17810 static cmdline_parse_token_num_t cmd_showport_macs_pid =
17811 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17812 cmd_pid, RTE_UINT16);
17813 static cmdline_parse_token_string_t cmd_showport_macs_keyword =
17814 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17815 cmd_keyword, "macs#mcast_macs");
17817 static cmdline_parse_inst_t cmd_showport_macs = {
17818 .f = cmd_showport_macs_parsed,
17820 .help_str = "show port <port_id> macs|mcast_macs",
17822 (void *)&cmd_showport_macs_show,
17823 (void *)&cmd_showport_macs_port,
17824 (void *)&cmd_showport_macs_pid,
17825 (void *)&cmd_showport_macs_keyword,
17830 /* *** show flow transfer proxy port ID for the given port *** */
17831 struct cmd_show_port_flow_transfer_proxy_result {
17832 cmdline_fixed_string_t show;
17833 cmdline_fixed_string_t port;
17835 cmdline_fixed_string_t flow;
17836 cmdline_fixed_string_t transfer;
17837 cmdline_fixed_string_t proxy;
17840 static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_show =
17841 TOKEN_STRING_INITIALIZER
17842 (struct cmd_show_port_flow_transfer_proxy_result,
17844 static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_port =
17845 TOKEN_STRING_INITIALIZER
17846 (struct cmd_show_port_flow_transfer_proxy_result,
17848 static cmdline_parse_token_num_t cmd_show_port_flow_transfer_proxy_port_id =
17849 TOKEN_NUM_INITIALIZER
17850 (struct cmd_show_port_flow_transfer_proxy_result,
17851 port_id, RTE_UINT16);
17852 static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_flow =
17853 TOKEN_STRING_INITIALIZER
17854 (struct cmd_show_port_flow_transfer_proxy_result,
17856 static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_transfer =
17857 TOKEN_STRING_INITIALIZER
17858 (struct cmd_show_port_flow_transfer_proxy_result,
17859 transfer, "transfer");
17860 static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_proxy =
17861 TOKEN_STRING_INITIALIZER
17862 (struct cmd_show_port_flow_transfer_proxy_result,
17866 cmd_show_port_flow_transfer_proxy_parsed(void *parsed_result,
17867 __rte_unused struct cmdline *cl,
17868 __rte_unused void *data)
17870 struct cmd_show_port_flow_transfer_proxy_result *res = parsed_result;
17871 portid_t proxy_port_id;
17876 ret = rte_flow_pick_transfer_proxy(res->port_id, &proxy_port_id, NULL);
17878 fprintf(stderr, "Failed to pick transfer proxy: %s\n",
17879 rte_strerror(-ret));
17883 printf("Transfer proxy port ID: %u\n\n", proxy_port_id);
17886 static cmdline_parse_inst_t cmd_show_port_flow_transfer_proxy = {
17887 .f = cmd_show_port_flow_transfer_proxy_parsed,
17889 .help_str = "show port <port_id> flow transfer proxy",
17891 (void *)&cmd_show_port_flow_transfer_proxy_show,
17892 (void *)&cmd_show_port_flow_transfer_proxy_port,
17893 (void *)&cmd_show_port_flow_transfer_proxy_port_id,
17894 (void *)&cmd_show_port_flow_transfer_proxy_flow,
17895 (void *)&cmd_show_port_flow_transfer_proxy_transfer,
17896 (void *)&cmd_show_port_flow_transfer_proxy_proxy,
17901 /* ******************************************************************************** */
17903 /* list of instructions */
17904 static cmdline_parse_ctx_t builtin_ctx[] = {
17905 (cmdline_parse_inst_t *)&cmd_help_brief,
17906 (cmdline_parse_inst_t *)&cmd_help_long,
17907 (cmdline_parse_inst_t *)&cmd_quit,
17908 (cmdline_parse_inst_t *)&cmd_load_from_file,
17909 (cmdline_parse_inst_t *)&cmd_showport,
17910 (cmdline_parse_inst_t *)&cmd_showqueue,
17911 (cmdline_parse_inst_t *)&cmd_showeeprom,
17912 (cmdline_parse_inst_t *)&cmd_showportall,
17913 (cmdline_parse_inst_t *)&cmd_representor_info,
17914 (cmdline_parse_inst_t *)&cmd_showdevice,
17915 (cmdline_parse_inst_t *)&cmd_showcfg,
17916 (cmdline_parse_inst_t *)&cmd_showfwdall,
17917 (cmdline_parse_inst_t *)&cmd_start,
17918 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17919 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17920 (cmdline_parse_inst_t *)&cmd_set_link_up,
17921 (cmdline_parse_inst_t *)&cmd_set_link_down,
17922 (cmdline_parse_inst_t *)&cmd_reset,
17923 (cmdline_parse_inst_t *)&cmd_set_numbers,
17924 (cmdline_parse_inst_t *)&cmd_set_log,
17925 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
17926 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
17927 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17928 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17929 (cmdline_parse_inst_t *)&cmd_set_txtimes,
17930 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17931 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17932 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17933 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17934 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17935 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17936 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17937 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17938 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17939 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17940 (cmdline_parse_inst_t *)&cmd_set_link_check,
17941 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17942 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17943 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17944 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17945 #ifdef RTE_NET_BOND
17946 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17947 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17948 (cmdline_parse_inst_t *) &cmd_show_bonding_lacp_info,
17949 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17950 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17951 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17952 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17953 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17954 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17955 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17956 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17957 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17959 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17960 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17961 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17962 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17963 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17964 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17965 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17966 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17967 (cmdline_parse_inst_t *)&cmd_csum_set,
17968 (cmdline_parse_inst_t *)&cmd_csum_show,
17969 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17970 (cmdline_parse_inst_t *)&cmd_tso_set,
17971 (cmdline_parse_inst_t *)&cmd_tso_show,
17972 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17973 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17975 (cmdline_parse_inst_t *)&cmd_gro_enable,
17976 (cmdline_parse_inst_t *)&cmd_gro_flush,
17977 (cmdline_parse_inst_t *)&cmd_gro_show,
17980 (cmdline_parse_inst_t *)&cmd_gso_enable,
17981 (cmdline_parse_inst_t *)&cmd_gso_size,
17982 (cmdline_parse_inst_t *)&cmd_gso_show,
17984 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17985 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17986 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17987 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17988 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17989 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17990 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17991 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17992 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17993 (cmdline_parse_inst_t *)&cmd_link_flow_control_show,
17994 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17995 (cmdline_parse_inst_t *)&cmd_queue_priority_flow_control_set,
17996 (cmdline_parse_inst_t *)&cmd_config_dcb,
17997 (cmdline_parse_inst_t *)&cmd_read_reg,
17998 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17999 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
18000 (cmdline_parse_inst_t *)&cmd_write_reg,
18001 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
18002 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
18003 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
18004 (cmdline_parse_inst_t *)&cmd_stop,
18005 (cmdline_parse_inst_t *)&cmd_mac_addr,
18006 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
18007 (cmdline_parse_inst_t *)&cmd_set_qmap,
18008 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
18009 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
18010 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
18011 (cmdline_parse_inst_t *)&cmd_operate_port,
18012 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
18013 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
18014 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
18015 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
18016 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
18017 (cmdline_parse_inst_t *)&cmd_config_speed_all,
18018 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
18019 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
18020 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
18021 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
18022 (cmdline_parse_inst_t *)&cmd_config_mtu,
18023 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
18024 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
18025 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
18026 (cmdline_parse_inst_t *)&cmd_config_rss,
18027 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
18028 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
18029 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
18030 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
18031 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
18032 (cmdline_parse_inst_t *)&cmd_showport_reta,
18033 (cmdline_parse_inst_t *)&cmd_showport_macs,
18034 (cmdline_parse_inst_t *)&cmd_show_port_flow_transfer_proxy,
18035 (cmdline_parse_inst_t *)&cmd_config_burst,
18036 (cmdline_parse_inst_t *)&cmd_config_thresh,
18037 (cmdline_parse_inst_t *)&cmd_config_threshold,
18038 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
18039 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
18040 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
18041 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
18042 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
18043 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
18044 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
18045 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
18046 (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
18047 (cmdline_parse_inst_t *)&cmd_dump,
18048 (cmdline_parse_inst_t *)&cmd_dump_one,
18049 #ifdef RTE_NET_I40E
18050 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
18052 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
18053 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
18054 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
18055 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
18056 (cmdline_parse_inst_t *)&cmd_flow,
18057 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
18058 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
18059 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
18060 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm_rfc4115,
18061 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
18062 (cmdline_parse_inst_t *)&cmd_create_port_meter,
18063 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
18064 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
18065 (cmdline_parse_inst_t *)&cmd_del_port_meter,
18066 (cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
18067 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
18068 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
18069 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
18070 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
18071 (cmdline_parse_inst_t *)&cmd_mcast_addr,
18072 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
18073 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
18074 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
18075 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
18076 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
18077 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
18078 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
18079 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
18080 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
18081 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
18082 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
18083 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
18084 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
18085 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
18086 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
18087 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
18088 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
18089 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
18090 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
18091 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
18092 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
18093 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
18094 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
18095 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
18096 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
18097 (cmdline_parse_inst_t *)&cmd_set_vxlan,
18098 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
18099 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
18100 (cmdline_parse_inst_t *)&cmd_set_nvgre,
18101 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
18102 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
18103 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
18104 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
18105 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
18106 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
18107 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
18108 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
18109 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
18110 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
18111 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
18112 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
18113 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
18114 (cmdline_parse_inst_t *)&cmd_set_conntrack_common,
18115 (cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
18116 (cmdline_parse_inst_t *)&cmd_ddp_add,
18117 (cmdline_parse_inst_t *)&cmd_ddp_del,
18118 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
18119 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
18120 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
18121 (cmdline_parse_inst_t *)&cmd_clear_input_set,
18122 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
18123 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
18124 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
18125 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
18126 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
18127 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
18128 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
18129 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
18131 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
18132 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
18133 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
18134 (cmdline_parse_inst_t *)&cmd_queue_region,
18135 (cmdline_parse_inst_t *)&cmd_region_flowtype,
18136 (cmdline_parse_inst_t *)&cmd_user_priority_region,
18137 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
18138 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
18139 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
18140 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
18141 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
18142 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
18143 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
18144 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
18145 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
18146 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
18147 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
18148 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
18149 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
18150 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
18151 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
18152 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
18153 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
18154 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
18155 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
18156 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
18157 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
18158 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
18159 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
18160 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
18161 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
18162 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
18163 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
18164 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
18165 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
18166 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
18167 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
18168 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
18169 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
18170 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
18172 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
18173 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
18175 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
18176 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
18177 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
18178 (cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
18179 (cmdline_parse_inst_t *)&cmd_set_raw,
18180 (cmdline_parse_inst_t *)&cmd_show_set_raw,
18181 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
18182 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
18183 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
18184 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
18185 (cmdline_parse_inst_t *)&cmd_set_rxq_avail_thresh,
18186 (cmdline_parse_inst_t *)&cmd_show_capability,
18187 (cmdline_parse_inst_t *)&cmd_set_flex_is_pattern,
18188 (cmdline_parse_inst_t *)&cmd_set_flex_spec_pattern,
18193 testpmd_add_driver_commands(struct testpmd_driver_commands *c)
18195 TAILQ_INSERT_TAIL(&driver_commands_head, c, next);
18201 struct testpmd_driver_commands *c;
18202 unsigned int count;
18205 /* initialize non-constant commands */
18206 cmd_set_fwd_mode_init();
18207 cmd_set_fwd_retry_mode_init();
18210 for (i = 0; builtin_ctx[i] != NULL; i++)
18212 TAILQ_FOREACH(c, &driver_commands_head, next) {
18213 for (i = 0; c->commands[i].ctx != NULL; i++)
18217 /* cmdline expects a NULL terminated array */
18218 main_ctx = calloc(count + 1, sizeof(main_ctx[0]));
18219 if (main_ctx == NULL)
18223 for (i = 0; builtin_ctx[i] != NULL; i++, count++)
18224 main_ctx[count] = builtin_ctx[i];
18225 TAILQ_FOREACH(c, &driver_commands_head, next) {
18226 for (i = 0; c->commands[i].ctx != NULL; i++, count++)
18227 main_ctx[count] = c->commands[i].ctx;
18233 /* read cmdline commands from file */
18235 cmdline_read_from_file(const char *filename)
18237 struct cmdline *cl;
18239 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
18242 "Failed to create file based cmdline context: %s\n",
18247 cmdline_interact(cl);
18252 printf("Read CLI commands from %s\n", filename);
18255 /* prompt function, called from main on MAIN lcore */
18261 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
18262 if (testpmd_cl == NULL)
18265 ret = atexit(prompt_exit);
18267 fprintf(stderr, "Cannot set exit function for cmdline\n");
18269 cmdline_interact(testpmd_cl);
18271 cmdline_stdin_exit(testpmd_cl);
18277 if (testpmd_cl != NULL) {
18278 cmdline_quit(testpmd_cl);
18279 cmdline_stdin_exit(testpmd_cl);
18284 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
18286 if (id == (portid_t)RTE_PORT_ALL) {
18289 RTE_ETH_FOREACH_DEV(pid) {
18290 /* check if need_reconfig has been set to 1 */
18291 if (ports[pid].need_reconfig == 0)
18292 ports[pid].need_reconfig = dev;
18293 /* check if need_reconfig_queues has been set to 1 */
18294 if (ports[pid].need_reconfig_queues == 0)
18295 ports[pid].need_reconfig_queues = queue;
18297 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
18298 /* check if need_reconfig has been set to 1 */
18299 if (ports[id].need_reconfig == 0)
18300 ports[id].need_reconfig = dev;
18301 /* check if need_reconfig_queues has been set to 1 */
18302 if (ports[id].need_reconfig_queues == 0)
18303 ports[id].need_reconfig_queues = queue;