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;
73 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
75 /* *** Help command with introduction. *** */
76 struct cmd_help_brief_result {
77 cmdline_fixed_string_t help;
80 static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
82 __rte_unused void *data)
87 "Help is available for the following sections:\n\n"
88 " help control : Start and stop forwarding.\n"
89 " help display : Displaying port, stats and config "
91 " help config : Configuration information.\n"
92 " help ports : Configuring ports.\n"
93 " help registers : Reading and setting port registers.\n"
94 " help filters : Filters configuration help.\n"
95 " help traffic_management : Traffic Management commands.\n"
96 " help devices : Device related cmds.\n"
97 " help all : All of the above sections.\n\n"
102 cmdline_parse_token_string_t cmd_help_brief_help =
103 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
105 cmdline_parse_inst_t cmd_help_brief = {
106 .f = cmd_help_brief_parsed,
108 .help_str = "help: Show help",
110 (void *)&cmd_help_brief_help,
115 /* *** Help command with help sections. *** */
116 struct cmd_help_long_result {
117 cmdline_fixed_string_t help;
118 cmdline_fixed_string_t section;
121 static void cmd_help_long_parsed(void *parsed_result,
123 __rte_unused void *data)
126 struct cmd_help_long_result *res = parsed_result;
128 if (!strcmp(res->section, "all"))
131 if (show_all || !strcmp(res->section, "control")) {
136 "Control forwarding:\n"
137 "-------------------\n\n"
140 " Start packet forwarding with current configuration.\n\n"
143 " Start packet forwarding with current config"
144 " after sending one burst of packets.\n\n"
147 " Stop packet forwarding, and display accumulated"
151 " Quit to prompt.\n\n"
155 if (show_all || !strcmp(res->section, "display")) {
163 "show port (info|stats|summary|xstats|fdir|dcb_tc) (port_id|all)\n"
164 " Display information for port_id, or all.\n\n"
166 "show port info (port_id) representor\n"
167 " Show supported representors for a specific port\n\n"
169 "show port port_id (module_eeprom|eeprom)\n"
170 " Display the module EEPROM or EEPROM information for port_id.\n\n"
172 "show port X rss reta (size) (mask0,mask1,...)\n"
173 " Display the rss redirection table entry indicated"
174 " by masks on port X. size is used to indicate the"
175 " hardware supported reta size\n\n"
177 "show port (port_id) rss-hash [key]\n"
178 " Display the RSS hash functions and RSS hash key of port\n\n"
180 "clear port (info|stats|xstats|fdir) (port_id|all)\n"
181 " Clear information for port_id, or all.\n\n"
183 "show (rxq|txq) info (port_id) (queue_id)\n"
184 " Display information for configured RX/TX queue.\n\n"
186 "show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n"
187 " Display the given configuration.\n\n"
189 "read rxd (port_id) (queue_id) (rxd_id)\n"
190 " Display an RX descriptor of a port RX queue.\n\n"
192 "read txd (port_id) (queue_id) (txd_id)\n"
193 " Display a TX descriptor of a port TX queue.\n\n"
195 "ddp get list (port_id)\n"
196 " Get ddp profile info list\n\n"
198 "ddp get info (profile_path)\n"
199 " Get ddp profile information.\n\n"
201 "show vf stats (port_id) (vf_id)\n"
202 " Display a VF's statistics.\n\n"
204 "clear vf stats (port_id) (vf_id)\n"
205 " Reset a VF's statistics.\n\n"
207 "show port (port_id) pctype mapping\n"
208 " Get flow ptype to pctype mapping on a port\n\n"
210 "show port meter stats (port_id) (meter_id) (clear)\n"
211 " Get meter stats on a port\n\n"
213 "show fwd stats all\n"
214 " Display statistics for all fwd engines.\n\n"
216 "clear fwd stats all\n"
217 " Clear statistics for all fwd engines.\n\n"
219 "show port (port_id) rx_offload capabilities\n"
220 " List all per queue and per port Rx offloading"
221 " capabilities of a port\n\n"
223 "show port (port_id) rx_offload configuration\n"
224 " List port level and all queue level"
225 " Rx offloading configuration\n\n"
227 "show port (port_id) tx_offload capabilities\n"
228 " List all per queue and per port"
229 " Tx offloading capabilities of a port\n\n"
231 "show port (port_id) tx_offload configuration\n"
232 " List port level and all queue level"
233 " Tx offloading configuration\n\n"
235 "show port (port_id) tx_metadata\n"
236 " Show Tx metadata value set"
237 " for a specific port\n\n"
239 "show port (port_id) ptypes\n"
240 " Show port supported ptypes"
241 " for a specific port\n\n"
243 "show device info (<identifier>|all)"
244 " Show general information about devices probed.\n\n"
246 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
247 " Show status of rx|tx descriptor.\n\n"
249 "show port (port_id) rxq (queue_id) desc used count\n"
250 " Show current number of filled receive"
251 " packet descriptors.\n\n"
253 "show port (port_id) macs|mcast_macs"
254 " Display list of mac addresses added to port.\n\n"
256 "show port (port_id) flow transfer proxy\n"
257 " Display proxy port to manage transfer flows\n\n"
259 "show port (port_id) fec capabilities"
260 " Show fec capabilities of a port.\n\n"
262 "show port (port_id) fec_mode"
263 " Show fec mode of a port.\n\n"
265 "show port (port_id) flow_ctrl"
266 " Show flow control info of a port.\n\n"
270 if (show_all || !strcmp(res->section, "config")) {
276 "Configuration changes only become active when"
277 " forwarding is started/restarted.\n\n"
280 " Reset forwarding to the default configuration.\n\n"
282 "set verbose (level)\n"
283 " Set the debug verbosity level X.\n\n"
285 "set log global|(type) (level)\n"
286 " Set the log level.\n\n"
289 " Set number of ports.\n\n"
292 " Set number of cores.\n\n"
294 "set coremask (mask)\n"
295 " Set the forwarding cores hexadecimal mask.\n\n"
297 "set portmask (mask)\n"
298 " Set the forwarding ports hexadecimal mask.\n\n"
301 " Set number of packets per burst.\n\n"
303 "set burst tx delay (microseconds) retry (num)\n"
304 " Set the transmit delay time and number of retries,"
305 " effective when retry is enabled.\n\n"
307 "set rxoffs (x[,y]*)\n"
308 " Set the offset of each packet segment on"
309 " receiving if split feature is engaged."
310 " Affects only the queues configured with split"
313 "set rxpkts (x[,y]*)\n"
314 " Set the length of each segment to scatter"
315 " packets on receiving if split feature is engaged."
316 " Affects only the queues configured with split"
319 "set txpkts (x[,y]*)\n"
320 " Set the length of each segment of TXONLY"
321 " and optionally CSUM packets.\n\n"
323 "set txsplit (off|on|rand)\n"
324 " Set the split policy for the TX packets."
325 " Right now only applicable for CSUM and TXONLY"
328 "set txtimes (x, y)\n"
329 " Set the scheduling on timestamps"
330 " timings for the TXONLY mode\n\n"
332 "set corelist (x[,y]*)\n"
333 " Set the list of forwarding cores.\n\n"
335 "set portlist (x[,y]*)\n"
336 " Set the list of forwarding ports.\n\n"
338 "set port setup on (iterator|event)\n"
339 " Select how attached port is retrieved for setup.\n\n"
341 "set tx loopback (port_id) (on|off)\n"
342 " Enable or disable tx loopback.\n\n"
344 "set all queues drop (port_id) (on|off)\n"
345 " Set drop enable bit for all queues.\n\n"
347 "set vf split drop (port_id) (vf_id) (on|off)\n"
348 " Set split drop enable bit for a VF from the PF.\n\n"
350 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
351 " Set MAC antispoof for a VF from the PF.\n\n"
353 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
354 " Enable MACsec offload.\n\n"
356 "set macsec offload (port_id) off\n"
357 " Disable MACsec offload.\n\n"
359 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
360 " Configure MACsec secure connection (SC).\n\n"
362 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
363 " Configure MACsec secure association (SA).\n\n"
365 "set vf broadcast (port_id) (vf_id) (on|off)\n"
366 " Set VF broadcast for a VF from the PF.\n\n"
368 "vlan set stripq (on|off) (port_id,queue_id)\n"
369 " Set the VLAN strip for a queue on a port.\n\n"
371 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
372 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
374 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
375 " Set VLAN insert for a VF from the PF.\n\n"
377 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
378 " Set VLAN antispoof for a VF from the PF.\n\n"
380 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
381 " Set VLAN tag for a VF from the PF.\n\n"
383 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
384 " Set a VF's max bandwidth(Mbps).\n\n"
386 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
387 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
389 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
390 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
392 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
393 " Set some TCs' strict link priority mode on a physical port.\n\n"
395 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
396 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
398 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
399 " Set the VLAN strip or filter or qinq strip or extend\n\n"
401 "vlan set (inner|outer) tpid (value) (port_id)\n"
402 " Set the VLAN TPID for Packet Filtering on"
405 "rx_vlan add (vlan_id|all) (port_id)\n"
406 " Add a vlan_id, or all identifiers, to the set"
407 " of VLAN identifiers filtered by port_id.\n\n"
409 "rx_vlan rm (vlan_id|all) (port_id)\n"
410 " Remove a vlan_id, or all identifiers, from the set"
411 " of VLAN identifiers filtered by port_id.\n\n"
413 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
414 " Add a vlan_id, to the set of VLAN identifiers"
415 "filtered for VF(s) from port_id.\n\n"
417 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
418 " Remove a vlan_id, to the set of VLAN identifiers"
419 "filtered for VF(s) from port_id.\n\n"
421 "rx_vxlan_port add (udp_port) (port_id)\n"
422 " Add an UDP port for VXLAN packet filter on a port\n\n"
424 "rx_vxlan_port rm (udp_port) (port_id)\n"
425 " Remove an UDP port for VXLAN packet filter on a port\n\n"
427 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
428 " Set hardware insertion of VLAN IDs (single or double VLAN "
429 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
431 "tx_vlan set pvid port_id vlan_id (on|off)\n"
432 " Set port based TX VLAN insertion.\n\n"
434 "tx_vlan reset (port_id)\n"
435 " Disable hardware insertion of a VLAN header in"
436 " packets sent on a port.\n\n"
438 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
439 " Select hardware or software calculation of the"
440 " checksum when transmitting a packet using the"
441 " csum forward engine.\n"
442 " ip|udp|tcp|sctp always concern the inner layer.\n"
443 " outer-ip concerns the outer IP layer in"
444 " outer-udp concerns the outer UDP layer in"
445 " case the packet is recognized as a tunnel packet by"
446 " the forward engine (vxlan, gre and ipip are supported)\n"
447 " Please check the NIC datasheet for HW limits.\n\n"
449 "csum parse-tunnel (on|off) (tx_port_id)\n"
450 " If disabled, treat tunnel packets as non-tunneled"
451 " packets (treat inner headers as payload). The port\n"
452 " argument is the port used for TX in csum forward"
455 "csum show (port_id)\n"
456 " Display tx checksum offload configuration\n\n"
458 "tso set (segsize) (portid)\n"
459 " Enable TCP Segmentation Offload in csum forward"
461 " Please check the NIC datasheet for HW limits.\n\n"
464 " Display the status of TCP Segmentation Offload.\n\n"
467 "set port (port_id) gro on|off\n"
468 " Enable or disable Generic Receive Offload in"
469 " csum forwarding engine.\n\n"
471 "show port (port_id) gro\n"
472 " Display GRO configuration.\n\n"
474 "set gro flush (cycles)\n"
475 " Set the cycle to flush GROed packets from"
476 " reassembly tables.\n\n"
480 "set port (port_id) gso (on|off)"
481 " Enable or disable Generic Segmentation Offload in"
482 " csum forwarding engine.\n\n"
484 "set gso segsz (length)\n"
485 " Set max packet length for output GSO segments,"
486 " including packet header and payload.\n\n"
488 "show port (port_id) gso\n"
489 " Show GSO configuration.\n\n"
493 " Set packet forwarding mode.\n\n"
495 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
496 " Add a MAC address on port_id.\n\n"
498 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
499 " Remove a MAC address from port_id.\n\n"
501 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
502 " Set the default MAC address for port_id.\n\n"
504 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
505 " Add a MAC address for a VF on the port.\n\n"
507 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
508 " Set the MAC address for a VF from the PF.\n\n"
510 "set eth-peer (port_id) (peer_addr)\n"
511 " set the peer address for certain port.\n\n"
513 "set port (port_id) uta (mac_address|all) (on|off)\n"
514 " Add/Remove a or all unicast hash filter(s)"
517 "set promisc (port_id|all) (on|off)\n"
518 " Set the promiscuous mode on port_id, or all.\n\n"
520 "set allmulti (port_id|all) (on|off)\n"
521 " Set the allmulti mode on port_id, or all.\n\n"
523 "set vf promisc (port_id) (vf_id) (on|off)\n"
524 " Set unicast promiscuous mode for a VF from the PF.\n\n"
526 "set vf allmulti (port_id) (vf_id) (on|off)\n"
527 " Set multicast promiscuous mode for a VF from the PF.\n\n"
529 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
530 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
531 " (on|off) autoneg (on|off) (port_id)\n"
532 "set flow_ctrl rx (on|off) (portid)\n"
533 "set flow_ctrl tx (on|off) (portid)\n"
534 "set flow_ctrl high_water (high_water) (portid)\n"
535 "set flow_ctrl low_water (low_water) (portid)\n"
536 "set flow_ctrl pause_time (pause_time) (portid)\n"
537 "set flow_ctrl send_xon (send_xon) (portid)\n"
538 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
539 "set flow_ctrl autoneg (on|off) (port_id)\n"
540 " Set the link flow control parameter on a port.\n\n"
542 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
543 " (low_water) (pause_time) (priority) (port_id)\n"
544 " Set the priority flow control parameter on a"
547 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
548 " Set statistics mapping (qmapping 0..15) for RX/TX"
550 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
551 " on port 0 to mapping 5.\n\n"
553 "set xstats-hide-zero on|off\n"
554 " Set the option to hide the zero values"
555 " for xstats display.\n"
557 "set record-core-cycles on|off\n"
558 " Set the option to enable measurement of CPU cycles.\n"
560 "set record-burst-stats on|off\n"
561 " Set the option to enable display of RX and TX bursts.\n"
563 "set port (port_id) vf (vf_id) rx|tx on|off\n"
564 " Enable/Disable a VF receive/transmit from a port\n\n"
566 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
568 " AUPE:accepts untagged VLAN;"
569 "ROPE:accept unicast hash\n\n"
570 " BAM:accepts broadcast packets;"
571 "MPE:accepts all multicast packets\n\n"
572 " Enable/Disable a VF receive mode of a port\n\n"
574 "set port (port_id) queue (queue_id) rate (rate_num)\n"
575 " Set rate limit for a queue of a port\n\n"
577 "set port (port_id) vf (vf_id) rate (rate_num) "
578 "queue_mask (queue_mask_value)\n"
579 " Set rate limit for queues in VF of a port\n\n"
581 "set flush_rx (on|off)\n"
582 " Flush (default) or don't flush RX streams before"
583 " forwarding. Mainly used with PCAP drivers.\n\n"
585 "set bypass mode (normal|bypass|isolate) (port_id)\n"
586 " Set the bypass mode for the lowest port on bypass enabled"
589 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
590 "mode (normal|bypass|isolate) (port_id)\n"
591 " Set the event required to initiate specified bypass mode for"
592 " the lowest port on a bypass enabled NIC where:\n"
593 " timeout = enable bypass after watchdog timeout.\n"
594 " os_on = enable bypass when OS/board is powered on.\n"
595 " os_off = enable bypass when OS/board is powered off.\n"
596 " power_on = enable bypass when power supply is turned on.\n"
597 " power_off = enable bypass when power supply is turned off."
600 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
601 " Set the bypass watchdog timeout to 'n' seconds"
602 " where 0 = instant.\n\n"
604 "show bypass config (port_id)\n"
605 " Show the bypass configuration for a bypass enabled NIC"
606 " using the lowest port on the NIC.\n\n"
609 "create bonded device (mode) (socket)\n"
610 " Create a new bonded device with specific bonding mode and socket.\n\n"
612 "add bonding slave (slave_id) (port_id)\n"
613 " Add a slave device to a bonded device.\n\n"
615 "remove bonding slave (slave_id) (port_id)\n"
616 " Remove a slave device from a bonded device.\n\n"
618 "set bonding mode (value) (port_id)\n"
619 " Set the bonding mode on a bonded device.\n\n"
621 "set bonding primary (slave_id) (port_id)\n"
622 " Set the primary slave for a bonded device.\n\n"
624 "show bonding config (port_id)\n"
625 " Show the bonding config for port_id.\n\n"
627 "show bonding lacp info (port_id)\n"
628 " Show the bonding lacp information for port_id.\n\n"
630 "set bonding mac_addr (port_id) (address)\n"
631 " Set the MAC address of a bonded device.\n\n"
633 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
634 " Set Aggregation mode for IEEE802.3AD (mode 4)"
636 "set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
637 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
639 "set bonding mon_period (port_id) (value)\n"
640 " Set the bonding link status monitoring polling period in ms.\n\n"
642 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
643 " Enable/disable dedicated queues for LACP control traffic.\n\n"
646 "set link-up port (port_id)\n"
647 " Set link up for a port.\n\n"
649 "set link-down port (port_id)\n"
650 " Set link down for a port.\n\n"
652 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
653 " Load a profile package on a port\n\n"
655 "ddp del (port_id) (backup_profile_path)\n"
656 " Delete a profile package from a port\n\n"
658 "ptype mapping get (port_id) (valid_only)\n"
659 " Get ptype mapping on a port\n\n"
661 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
662 " Replace target with the pkt_type in ptype mapping\n\n"
664 "ptype mapping reset (port_id)\n"
665 " Reset ptype mapping on a port\n\n"
667 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
668 " Update a ptype mapping item on a port\n\n"
670 "set port (port_id) ptype_mask (ptype_mask)\n"
671 " set packet types classification for a specific port\n\n"
673 "set port (port_id) queue-region region_id (value) "
674 "queue_start_index (value) queue_num (value)\n"
675 " Set a queue region on a port\n\n"
677 "set port (port_id) queue-region region_id (value) "
679 " Set a flowtype region index on a port\n\n"
681 "set port (port_id) queue-region UP (value) region_id (value)\n"
682 " Set the mapping of User Priority to "
683 "queue region on a port\n\n"
685 "set port (port_id) queue-region flush (on|off)\n"
686 " flush all queue region related configuration\n\n"
688 "show port meter cap (port_id)\n"
689 " Show port meter capability information\n\n"
691 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
692 " meter profile add - srtcm rfc 2697\n\n"
694 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
695 " meter profile add - trtcm rfc 2698\n\n"
697 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
698 " meter profile add - trtcm rfc 4115\n\n"
700 "del port meter profile (port_id) (profile_id)\n"
701 " meter profile delete\n\n"
703 "create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
704 "(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
705 "(dscp_tbl_entry63)]\n"
708 "enable port meter (port_id) (mtr_id)\n"
711 "disable port meter (port_id) (mtr_id)\n"
714 "del port meter (port_id) (mtr_id)\n"
717 "add port meter policy (port_id) (policy_id) g_actions (actions)\n"
718 "y_actions (actions) r_actions (actions)\n"
719 " meter policy add\n\n"
721 "del port meter policy (port_id) (policy_id)\n"
722 " meter policy delete\n\n"
724 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
725 " meter update meter profile\n\n"
727 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
728 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
729 " update meter dscp table entries\n\n"
731 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
732 "(action0) [(action1) (action2)]\n"
733 " meter update policer action\n\n"
735 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
736 " meter update stats\n\n"
738 "show port (port_id) queue-region\n"
739 " show all queue region related configuration info\n\n"
741 "set port (port_id) fec_mode auto|off|rs|baser\n"
742 " set fec mode for a specific port\n\n"
744 , list_pkt_forwarding_modes()
748 if (show_all || !strcmp(res->section, "ports")) {
754 "----------------\n\n"
756 "port start (port_id|all)\n"
757 " Start all ports or port_id.\n\n"
759 "port stop (port_id|all)\n"
760 " Stop all ports or port_id.\n\n"
762 "port close (port_id|all)\n"
763 " Close all ports or port_id.\n\n"
765 "port reset (port_id|all)\n"
766 " Reset all ports or port_id.\n\n"
768 "port attach (ident)\n"
769 " Attach physical or virtual dev by pci address or virtual device name\n\n"
771 "port detach (port_id)\n"
772 " Detach physical or virtual dev by port_id\n\n"
774 "port config (port_id|all)"
775 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
776 " duplex (half|full|auto)\n"
777 " Set speed and duplex for all ports or port_id\n\n"
779 "port config (port_id|all) loopback (mode)\n"
780 " Set loopback mode for all ports or port_id\n\n"
782 "port config all (rxq|txq|rxd|txd) (value)\n"
783 " Set number for rxq/txq/rxd/txd.\n\n"
785 "port config all max-pkt-len (value)\n"
786 " Set the max packet length.\n\n"
788 "port config all max-lro-pkt-size (value)\n"
789 " Set the max LRO aggregated packet size.\n\n"
791 "port config all drop-en (on|off)\n"
792 " Enable or disable packet drop on all RX queues of all ports when no "
793 "receive buffers available.\n\n"
795 "port config all rss (all|default|ip|tcp|udp|sctp|"
796 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|none|level-default|"
797 "level-outer|level-inner|<flowtype_id>)\n"
798 " Set the RSS mode.\n\n"
800 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
801 " Set the RSS redirection table.\n\n"
803 "port config (port_id) dcb vt (on|off) (traffic_class)"
805 " Set the DCB mode.\n\n"
807 "port config all burst (value)\n"
808 " Set the number of packets per burst.\n\n"
810 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
812 " Set the ring prefetch/host/writeback threshold"
813 " for tx/rx queue.\n\n"
815 "port config all (txfreet|txrst|rxfreet) (value)\n"
816 " Set free threshold for rx/tx, or set"
817 " tx rs bit threshold.\n\n"
818 "port config mtu X value\n"
819 " Set the MTU of port X to a given value\n\n"
821 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
822 " Set a rx/tx queue's ring size configuration, the new"
823 " value will take effect after command that (re-)start the port"
824 " or command that setup the specific queue\n\n"
826 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
827 " Start/stop a rx/tx queue of port X. Only take effect"
828 " when port X is started\n\n"
830 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
831 " Switch on/off a deferred start of port X rx/tx queue. Only"
832 " take effect when port X is stopped.\n\n"
834 "port (port_id) (rxq|txq) (queue_id) setup\n"
835 " Setup a rx/tx queue of port X.\n\n"
837 "port config (port_id) pctype mapping reset\n"
838 " Reset flow type to pctype mapping on a port\n\n"
840 "port config (port_id) pctype mapping update"
841 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
842 " Update a flow type to pctype mapping item on a port\n\n"
844 "port config (port_id) pctype (pctype_id) hash_inset|"
845 "fdir_inset|fdir_flx_inset get|set|clear field\n"
847 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
849 "port config (port_id) pctype (pctype_id) hash_inset|"
850 "fdir_inset|fdir_flx_inset clear all"
851 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
853 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
854 " Add/remove UDP tunnel port for tunneling offload\n\n"
856 "port config <port_id> rx_offload vlan_strip|"
857 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
858 "outer_ipv4_cksum|macsec_strip|header_split|"
859 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
860 "buffer_split|timestamp|security|keep_crc on|off\n"
861 " Enable or disable a per port Rx offloading"
862 " on all Rx queues of a port\n\n"
864 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
865 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
866 "outer_ipv4_cksum|macsec_strip|header_split|"
867 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
868 "buffer_split|timestamp|security|keep_crc on|off\n"
869 " Enable or disable a per queue Rx offloading"
870 " only on a specific Rx queue\n\n"
872 "port config (port_id) tx_offload vlan_insert|"
873 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
874 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
875 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
876 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
878 " Enable or disable a per port Tx offloading"
879 " on all Tx queues of a port\n\n"
881 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
882 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
883 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
884 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
885 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
887 " Enable or disable a per queue Tx offloading"
888 " only on a specific Tx queue\n\n"
890 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
891 " Load an eBPF program as a callback"
892 " for particular RX/TX queue\n\n"
894 "bpf-unload rx|tx (port) (queue)\n"
895 " Unload previously loaded eBPF program"
896 " for particular RX/TX queue\n\n"
898 "port config (port_id) tx_metadata (value)\n"
899 " Set Tx metadata value per port. Testpmd will add this value"
900 " to any Tx packet sent from this port\n\n"
902 "port config (port_id) dynf (name) set|clear\n"
903 " Register a dynf and Set/clear this flag on Tx. "
904 "Testpmd will set this value to any Tx packet "
905 "sent from this port\n\n"
907 "port cleanup (port_id) txq (queue_id) (free_cnt)\n"
908 " Cleanup txq mbufs for a specific Tx queue\n\n"
912 if (show_all || !strcmp(res->section, "registers")) {
920 "read reg (port_id) (address)\n"
921 " Display value of a port register.\n\n"
923 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
924 " Display a port register bit field.\n\n"
926 "read regbit (port_id) (address) (bit_x)\n"
927 " Display a single port register bit.\n\n"
929 "write reg (port_id) (address) (value)\n"
930 " Set value of a port register.\n\n"
932 "write regfield (port_id) (address) (bit_x) (bit_y)"
934 " Set bit field of a port register.\n\n"
936 "write regbit (port_id) (address) (bit_x) (value)\n"
937 " Set single bit value of a port register.\n\n"
940 if (show_all || !strcmp(res->section, "filters")) {
949 "flow_director_filter (port_id) mode raw (add|del|update)"
950 " flow (flow_id) (drop|fwd) queue (queue_id)"
951 " fd_id (fd_id_value) packet (packet file name)\n"
952 " Add/Del a raw type flow director filter.\n\n"
955 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
956 " src_mask (ipv4_src) (ipv6_src) (src_port)"
957 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
958 " Set flow director IP mask.\n\n"
960 "flow_director_mask (port_id) mode MAC-VLAN"
961 " vlan (vlan_value)\n"
962 " Set flow director MAC-VLAN mask.\n\n"
964 "flow_director_mask (port_id) mode Tunnel"
965 " vlan (vlan_value) mac (mac_value)"
966 " tunnel-type (tunnel_type_value)"
967 " tunnel-id (tunnel_id_value)\n"
968 " Set flow director Tunnel mask.\n\n"
970 "flow_director_flex_payload (port_id)"
971 " (raw|l2|l3|l4) (config)\n"
972 " Configure flex payload selection.\n\n"
974 "flow validate {port_id}"
975 " [group {group_id}] [priority {level}]"
976 " [ingress] [egress]"
977 " pattern {item} [/ {item} [...]] / end"
978 " actions {action} [/ {action} [...]] / end\n"
979 " Check whether a flow rule can be created.\n\n"
981 "flow create {port_id}"
982 " [group {group_id}] [priority {level}]"
983 " [ingress] [egress]"
984 " pattern {item} [/ {item} [...]] / end"
985 " actions {action} [/ {action} [...]] / end\n"
986 " Create a flow rule.\n\n"
988 "flow destroy {port_id} rule {rule_id} [...]\n"
989 " Destroy specific flow rules.\n\n"
991 "flow flush {port_id}\n"
992 " Destroy all flow rules.\n\n"
994 "flow query {port_id} {rule_id} {action}\n"
995 " Query an existing flow rule.\n\n"
997 "flow list {port_id} [group {group_id}] [...]\n"
998 " List existing flow rules sorted by priority,"
999 " filtered by group identifiers.\n\n"
1001 "flow isolate {port_id} {boolean}\n"
1002 " Restrict ingress traffic to the defined"
1005 "flow aged {port_id} [destroy]\n"
1006 " List and destroy aged flows"
1009 "flow indirect_action {port_id} create"
1010 " [action_id {indirect_action_id}]"
1011 " [ingress] [egress]"
1012 " action {action} / end\n"
1013 " Create indirect action.\n\n"
1015 "flow indirect_action {port_id} update"
1016 " {indirect_action_id} action {action} / end\n"
1017 " Update indirect action.\n\n"
1019 "flow indirect_action {port_id} destroy"
1020 " action_id {indirect_action_id} [...]\n"
1021 " Destroy specific indirect actions.\n\n"
1023 "flow indirect_action {port_id} query"
1024 " {indirect_action_id}\n"
1025 " Query an existing indirect action.\n\n"
1027 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1028 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1029 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1030 " Configure the VXLAN encapsulation for flows.\n\n"
1032 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1033 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1034 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1035 " eth-dst (eth-dst)\n"
1036 " Configure the VXLAN encapsulation for flows.\n\n"
1038 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1039 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1040 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1041 " eth-dst (eth-dst)\n"
1042 " Configure the VXLAN encapsulation for flows.\n\n"
1044 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1045 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1047 " Configure the NVGRE encapsulation for flows.\n\n"
1049 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1050 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1051 " eth-src (eth-src) eth-dst (eth-dst)\n"
1052 " Configure the NVGRE encapsulation for flows.\n\n"
1054 "set raw_encap {flow items}\n"
1055 " Configure the encapsulation with raw data.\n\n"
1057 "set raw_decap {flow items}\n"
1058 " Configure the decapsulation with raw data.\n\n"
1063 if (show_all || !strcmp(res->section, "traffic_management")) {
1067 "Traffic Management:\n"
1069 "show port tm cap (port_id)\n"
1070 " Display the port TM capability.\n\n"
1072 "show port tm level cap (port_id) (level_id)\n"
1073 " Display the port TM hierarchical level capability.\n\n"
1075 "show port tm node cap (port_id) (node_id)\n"
1076 " Display the port TM node capability.\n\n"
1078 "show port tm node type (port_id) (node_id)\n"
1079 " Display the port TM node type.\n\n"
1081 "show port tm node stats (port_id) (node_id) (clear)\n"
1082 " Display the port TM node stats.\n\n"
1084 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1085 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1086 " (packet_length_adjust) (packet_mode)\n"
1087 " Add port tm node private shaper profile.\n\n"
1089 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1090 " Delete port tm node private shaper profile.\n\n"
1092 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1093 " (shaper_profile_id)\n"
1094 " Add/update port tm node shared shaper.\n\n"
1096 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1097 " Delete port tm node shared shaper.\n\n"
1099 "set port tm node shaper profile (port_id) (node_id)"
1100 " (shaper_profile_id)\n"
1101 " Set port tm node shaper profile.\n\n"
1103 "add port tm node wred profile (port_id) (wred_profile_id)"
1104 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1105 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1106 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1107 " Add port tm node wred profile.\n\n"
1109 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1110 " Delete port tm node wred profile.\n\n"
1112 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1113 " (priority) (weight) (level_id) (shaper_profile_id)"
1114 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1115 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1116 " Add port tm nonleaf node.\n\n"
1118 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1119 " (priority) (weight) (level_id) (shaper_profile_id)"
1120 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1121 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1122 " Add port tm nonleaf node with pkt mode enabled.\n\n"
1124 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1125 " (priority) (weight) (level_id) (shaper_profile_id)"
1126 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1127 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1128 " Add port tm leaf node.\n\n"
1130 "del port tm node (port_id) (node_id)\n"
1131 " Delete port tm node.\n\n"
1133 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1134 " (priority) (weight)\n"
1135 " Set port tm node parent.\n\n"
1137 "suspend port tm node (port_id) (node_id)"
1138 " Suspend tm node.\n\n"
1140 "resume port tm node (port_id) (node_id)"
1141 " Resume tm node.\n\n"
1143 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1144 " Commit tm hierarchy.\n\n"
1146 "set port tm mark ip_ecn (port) (green) (yellow)"
1148 " Enables/Disables the traffic management marking"
1149 " for IP ECN (Explicit Congestion Notification)"
1150 " packets on a given port\n\n"
1152 "set port tm mark ip_dscp (port) (green) (yellow)"
1154 " Enables/Disables the traffic management marking"
1155 " on the port for IP dscp packets\n\n"
1157 "set port tm mark vlan_dei (port) (green) (yellow)"
1159 " Enables/Disables the traffic management marking"
1160 " on the port for VLAN packets with DEI enabled\n\n"
1164 if (show_all || !strcmp(res->section, "devices")) {
1168 "Device Operations:\n"
1170 "device detach (identifier)\n"
1171 " Detach device by identifier.\n\n"
1177 cmdline_parse_token_string_t cmd_help_long_help =
1178 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1180 cmdline_parse_token_string_t cmd_help_long_section =
1181 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1182 "all#control#display#config#"
1183 "ports#registers#filters#traffic_management#devices");
1185 cmdline_parse_inst_t cmd_help_long = {
1186 .f = cmd_help_long_parsed,
1188 .help_str = "help all|control|display|config|ports|register|"
1189 "filters|traffic_management|devices: "
1192 (void *)&cmd_help_long_help,
1193 (void *)&cmd_help_long_section,
1199 /* *** start/stop/close all ports *** */
1200 struct cmd_operate_port_result {
1201 cmdline_fixed_string_t keyword;
1202 cmdline_fixed_string_t name;
1203 cmdline_fixed_string_t value;
1206 static void cmd_operate_port_parsed(void *parsed_result,
1207 __rte_unused struct cmdline *cl,
1208 __rte_unused void *data)
1210 struct cmd_operate_port_result *res = parsed_result;
1212 if (!strcmp(res->name, "start"))
1213 start_port(RTE_PORT_ALL);
1214 else if (!strcmp(res->name, "stop"))
1215 stop_port(RTE_PORT_ALL);
1216 else if (!strcmp(res->name, "close"))
1217 close_port(RTE_PORT_ALL);
1218 else if (!strcmp(res->name, "reset"))
1219 reset_port(RTE_PORT_ALL);
1221 fprintf(stderr, "Unknown parameter\n");
1224 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1225 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1227 cmdline_parse_token_string_t cmd_operate_port_all_port =
1228 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1229 "start#stop#close#reset");
1230 cmdline_parse_token_string_t cmd_operate_port_all_all =
1231 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1233 cmdline_parse_inst_t cmd_operate_port = {
1234 .f = cmd_operate_port_parsed,
1236 .help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports",
1238 (void *)&cmd_operate_port_all_cmd,
1239 (void *)&cmd_operate_port_all_port,
1240 (void *)&cmd_operate_port_all_all,
1245 /* *** start/stop/close specific port *** */
1246 struct cmd_operate_specific_port_result {
1247 cmdline_fixed_string_t keyword;
1248 cmdline_fixed_string_t name;
1252 static void cmd_operate_specific_port_parsed(void *parsed_result,
1253 __rte_unused struct cmdline *cl,
1254 __rte_unused void *data)
1256 struct cmd_operate_specific_port_result *res = parsed_result;
1258 if (!strcmp(res->name, "start"))
1259 start_port(res->value);
1260 else if (!strcmp(res->name, "stop"))
1261 stop_port(res->value);
1262 else if (!strcmp(res->name, "close"))
1263 close_port(res->value);
1264 else if (!strcmp(res->name, "reset"))
1265 reset_port(res->value);
1267 fprintf(stderr, "Unknown parameter\n");
1270 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1271 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1273 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1274 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1275 name, "start#stop#close#reset");
1276 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1277 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1280 cmdline_parse_inst_t cmd_operate_specific_port = {
1281 .f = cmd_operate_specific_port_parsed,
1283 .help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id",
1285 (void *)&cmd_operate_specific_port_cmd,
1286 (void *)&cmd_operate_specific_port_port,
1287 (void *)&cmd_operate_specific_port_id,
1292 /* *** enable port setup (after attach) via iterator or event *** */
1293 struct cmd_set_port_setup_on_result {
1294 cmdline_fixed_string_t set;
1295 cmdline_fixed_string_t port;
1296 cmdline_fixed_string_t setup;
1297 cmdline_fixed_string_t on;
1298 cmdline_fixed_string_t mode;
1301 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1302 __rte_unused struct cmdline *cl,
1303 __rte_unused void *data)
1305 struct cmd_set_port_setup_on_result *res = parsed_result;
1307 if (strcmp(res->mode, "event") == 0)
1308 setup_on_probe_event = true;
1309 else if (strcmp(res->mode, "iterator") == 0)
1310 setup_on_probe_event = false;
1312 fprintf(stderr, "Unknown mode\n");
1315 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1316 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1318 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1319 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1321 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1322 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1324 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1325 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1327 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1328 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1329 mode, "iterator#event");
1331 cmdline_parse_inst_t cmd_set_port_setup_on = {
1332 .f = cmd_set_port_setup_on_parsed,
1334 .help_str = "set port setup on iterator|event",
1336 (void *)&cmd_set_port_setup_on_set,
1337 (void *)&cmd_set_port_setup_on_port,
1338 (void *)&cmd_set_port_setup_on_setup,
1339 (void *)&cmd_set_port_setup_on_on,
1340 (void *)&cmd_set_port_setup_on_mode,
1345 /* *** attach a specified port *** */
1346 struct cmd_operate_attach_port_result {
1347 cmdline_fixed_string_t port;
1348 cmdline_fixed_string_t keyword;
1349 cmdline_multi_string_t identifier;
1352 static void cmd_operate_attach_port_parsed(void *parsed_result,
1353 __rte_unused struct cmdline *cl,
1354 __rte_unused void *data)
1356 struct cmd_operate_attach_port_result *res = parsed_result;
1358 if (!strcmp(res->keyword, "attach"))
1359 attach_port(res->identifier);
1361 fprintf(stderr, "Unknown parameter\n");
1364 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1365 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1367 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1368 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1370 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1371 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1372 identifier, TOKEN_STRING_MULTI);
1374 cmdline_parse_inst_t cmd_operate_attach_port = {
1375 .f = cmd_operate_attach_port_parsed,
1377 .help_str = "port attach <identifier>: "
1378 "(identifier: pci address or virtual dev name)",
1380 (void *)&cmd_operate_attach_port_port,
1381 (void *)&cmd_operate_attach_port_keyword,
1382 (void *)&cmd_operate_attach_port_identifier,
1387 /* *** detach a specified port *** */
1388 struct cmd_operate_detach_port_result {
1389 cmdline_fixed_string_t port;
1390 cmdline_fixed_string_t keyword;
1394 static void cmd_operate_detach_port_parsed(void *parsed_result,
1395 __rte_unused struct cmdline *cl,
1396 __rte_unused void *data)
1398 struct cmd_operate_detach_port_result *res = parsed_result;
1400 if (!strcmp(res->keyword, "detach")) {
1401 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1402 detach_port_device(res->port_id);
1404 fprintf(stderr, "Unknown parameter\n");
1408 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1409 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1411 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1412 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1414 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1415 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1416 port_id, RTE_UINT16);
1418 cmdline_parse_inst_t cmd_operate_detach_port = {
1419 .f = cmd_operate_detach_port_parsed,
1421 .help_str = "port detach <port_id>",
1423 (void *)&cmd_operate_detach_port_port,
1424 (void *)&cmd_operate_detach_port_keyword,
1425 (void *)&cmd_operate_detach_port_port_id,
1430 /* *** detach device by identifier *** */
1431 struct cmd_operate_detach_device_result {
1432 cmdline_fixed_string_t device;
1433 cmdline_fixed_string_t keyword;
1434 cmdline_fixed_string_t identifier;
1437 static void cmd_operate_detach_device_parsed(void *parsed_result,
1438 __rte_unused struct cmdline *cl,
1439 __rte_unused void *data)
1441 struct cmd_operate_detach_device_result *res = parsed_result;
1443 if (!strcmp(res->keyword, "detach"))
1444 detach_devargs(res->identifier);
1446 fprintf(stderr, "Unknown parameter\n");
1449 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1450 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1452 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1453 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1455 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1456 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1459 cmdline_parse_inst_t cmd_operate_detach_device = {
1460 .f = cmd_operate_detach_device_parsed,
1462 .help_str = "device detach <identifier>:"
1463 "(identifier: pci address or virtual dev name)",
1465 (void *)&cmd_operate_detach_device_device,
1466 (void *)&cmd_operate_detach_device_keyword,
1467 (void *)&cmd_operate_detach_device_identifier,
1471 /* *** configure speed for all ports *** */
1472 struct cmd_config_speed_all {
1473 cmdline_fixed_string_t port;
1474 cmdline_fixed_string_t keyword;
1475 cmdline_fixed_string_t all;
1476 cmdline_fixed_string_t item1;
1477 cmdline_fixed_string_t item2;
1478 cmdline_fixed_string_t value1;
1479 cmdline_fixed_string_t value2;
1483 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1488 if (!strcmp(duplexstr, "half")) {
1489 duplex = RTE_ETH_LINK_HALF_DUPLEX;
1490 } else if (!strcmp(duplexstr, "full")) {
1491 duplex = RTE_ETH_LINK_FULL_DUPLEX;
1492 } else if (!strcmp(duplexstr, "auto")) {
1493 duplex = RTE_ETH_LINK_FULL_DUPLEX;
1495 fprintf(stderr, "Unknown duplex parameter\n");
1499 if (!strcmp(speedstr, "10")) {
1500 *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1501 RTE_ETH_LINK_SPEED_10M_HD : RTE_ETH_LINK_SPEED_10M;
1502 } else if (!strcmp(speedstr, "100")) {
1503 *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1504 RTE_ETH_LINK_SPEED_100M_HD : RTE_ETH_LINK_SPEED_100M;
1506 if (duplex != RTE_ETH_LINK_FULL_DUPLEX) {
1507 fprintf(stderr, "Invalid speed/duplex parameters\n");
1510 if (!strcmp(speedstr, "1000")) {
1511 *speed = RTE_ETH_LINK_SPEED_1G;
1512 } else if (!strcmp(speedstr, "10000")) {
1513 *speed = RTE_ETH_LINK_SPEED_10G;
1514 } else if (!strcmp(speedstr, "25000")) {
1515 *speed = RTE_ETH_LINK_SPEED_25G;
1516 } else if (!strcmp(speedstr, "40000")) {
1517 *speed = RTE_ETH_LINK_SPEED_40G;
1518 } else if (!strcmp(speedstr, "50000")) {
1519 *speed = RTE_ETH_LINK_SPEED_50G;
1520 } else if (!strcmp(speedstr, "100000")) {
1521 *speed = RTE_ETH_LINK_SPEED_100G;
1522 } else if (!strcmp(speedstr, "200000")) {
1523 *speed = RTE_ETH_LINK_SPEED_200G;
1524 } else if (!strcmp(speedstr, "auto")) {
1525 *speed = RTE_ETH_LINK_SPEED_AUTONEG;
1527 fprintf(stderr, "Unknown speed parameter\n");
1532 if (*speed != RTE_ETH_LINK_SPEED_AUTONEG)
1533 *speed |= RTE_ETH_LINK_SPEED_FIXED;
1539 cmd_config_speed_all_parsed(void *parsed_result,
1540 __rte_unused struct cmdline *cl,
1541 __rte_unused void *data)
1543 struct cmd_config_speed_all *res = parsed_result;
1544 uint32_t link_speed;
1547 if (!all_ports_stopped()) {
1548 fprintf(stderr, "Please stop all ports first\n");
1552 if (parse_and_check_speed_duplex(res->value1, res->value2,
1556 RTE_ETH_FOREACH_DEV(pid) {
1557 ports[pid].dev_conf.link_speeds = link_speed;
1560 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1563 cmdline_parse_token_string_t cmd_config_speed_all_port =
1564 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1565 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1566 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1568 cmdline_parse_token_string_t cmd_config_speed_all_all =
1569 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1570 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1571 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1572 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1573 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1574 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1575 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1576 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1577 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1578 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1581 cmdline_parse_inst_t cmd_config_speed_all = {
1582 .f = cmd_config_speed_all_parsed,
1584 .help_str = "port config all speed "
1585 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1588 (void *)&cmd_config_speed_all_port,
1589 (void *)&cmd_config_speed_all_keyword,
1590 (void *)&cmd_config_speed_all_all,
1591 (void *)&cmd_config_speed_all_item1,
1592 (void *)&cmd_config_speed_all_value1,
1593 (void *)&cmd_config_speed_all_item2,
1594 (void *)&cmd_config_speed_all_value2,
1599 /* *** configure speed for specific port *** */
1600 struct cmd_config_speed_specific {
1601 cmdline_fixed_string_t port;
1602 cmdline_fixed_string_t keyword;
1604 cmdline_fixed_string_t item1;
1605 cmdline_fixed_string_t item2;
1606 cmdline_fixed_string_t value1;
1607 cmdline_fixed_string_t value2;
1611 cmd_config_speed_specific_parsed(void *parsed_result,
1612 __rte_unused struct cmdline *cl,
1613 __rte_unused void *data)
1615 struct cmd_config_speed_specific *res = parsed_result;
1616 uint32_t link_speed;
1618 if (port_id_is_invalid(res->id, ENABLED_WARN))
1621 if (!port_is_stopped(res->id)) {
1622 fprintf(stderr, "Please stop port %d first\n", res->id);
1626 if (parse_and_check_speed_duplex(res->value1, res->value2,
1630 ports[res->id].dev_conf.link_speeds = link_speed;
1632 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1636 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1637 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1639 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1640 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1642 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1643 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1644 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1645 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1647 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1648 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1649 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1650 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1651 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1653 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1654 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1657 cmdline_parse_inst_t cmd_config_speed_specific = {
1658 .f = cmd_config_speed_specific_parsed,
1660 .help_str = "port config <port_id> speed "
1661 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1664 (void *)&cmd_config_speed_specific_port,
1665 (void *)&cmd_config_speed_specific_keyword,
1666 (void *)&cmd_config_speed_specific_id,
1667 (void *)&cmd_config_speed_specific_item1,
1668 (void *)&cmd_config_speed_specific_value1,
1669 (void *)&cmd_config_speed_specific_item2,
1670 (void *)&cmd_config_speed_specific_value2,
1675 /* *** configure loopback for all ports *** */
1676 struct cmd_config_loopback_all {
1677 cmdline_fixed_string_t port;
1678 cmdline_fixed_string_t keyword;
1679 cmdline_fixed_string_t all;
1680 cmdline_fixed_string_t item;
1685 cmd_config_loopback_all_parsed(void *parsed_result,
1686 __rte_unused struct cmdline *cl,
1687 __rte_unused void *data)
1689 struct cmd_config_loopback_all *res = parsed_result;
1692 if (!all_ports_stopped()) {
1693 fprintf(stderr, "Please stop all ports first\n");
1697 RTE_ETH_FOREACH_DEV(pid) {
1698 ports[pid].dev_conf.lpbk_mode = res->mode;
1701 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1704 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1705 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1706 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1707 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1709 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1710 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1711 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1712 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1714 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1715 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1717 cmdline_parse_inst_t cmd_config_loopback_all = {
1718 .f = cmd_config_loopback_all_parsed,
1720 .help_str = "port config all loopback <mode>",
1722 (void *)&cmd_config_loopback_all_port,
1723 (void *)&cmd_config_loopback_all_keyword,
1724 (void *)&cmd_config_loopback_all_all,
1725 (void *)&cmd_config_loopback_all_item,
1726 (void *)&cmd_config_loopback_all_mode,
1731 /* *** configure loopback for specific port *** */
1732 struct cmd_config_loopback_specific {
1733 cmdline_fixed_string_t port;
1734 cmdline_fixed_string_t keyword;
1736 cmdline_fixed_string_t item;
1741 cmd_config_loopback_specific_parsed(void *parsed_result,
1742 __rte_unused struct cmdline *cl,
1743 __rte_unused void *data)
1745 struct cmd_config_loopback_specific *res = parsed_result;
1747 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1750 if (!port_is_stopped(res->port_id)) {
1751 fprintf(stderr, "Please stop port %u first\n", res->port_id);
1755 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1757 cmd_reconfig_device_queue(res->port_id, 1, 1);
1761 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1762 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1764 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1765 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1767 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1768 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1770 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1771 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1773 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1774 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1777 cmdline_parse_inst_t cmd_config_loopback_specific = {
1778 .f = cmd_config_loopback_specific_parsed,
1780 .help_str = "port config <port_id> loopback <mode>",
1782 (void *)&cmd_config_loopback_specific_port,
1783 (void *)&cmd_config_loopback_specific_keyword,
1784 (void *)&cmd_config_loopback_specific_id,
1785 (void *)&cmd_config_loopback_specific_item,
1786 (void *)&cmd_config_loopback_specific_mode,
1791 /* *** configure txq/rxq, txd/rxd *** */
1792 struct cmd_config_rx_tx {
1793 cmdline_fixed_string_t port;
1794 cmdline_fixed_string_t keyword;
1795 cmdline_fixed_string_t all;
1796 cmdline_fixed_string_t name;
1801 cmd_config_rx_tx_parsed(void *parsed_result,
1802 __rte_unused struct cmdline *cl,
1803 __rte_unused void *data)
1805 struct cmd_config_rx_tx *res = parsed_result;
1807 if (!all_ports_stopped()) {
1808 fprintf(stderr, "Please stop all ports first\n");
1811 if (!strcmp(res->name, "rxq")) {
1812 if (!res->value && !nb_txq) {
1813 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1816 if (check_nb_rxq(res->value) != 0)
1818 nb_rxq = res->value;
1820 else if (!strcmp(res->name, "txq")) {
1821 if (!res->value && !nb_rxq) {
1822 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1825 if (check_nb_txq(res->value) != 0)
1827 nb_txq = res->value;
1829 else if (!strcmp(res->name, "rxd")) {
1830 if (check_nb_rxd(res->value) != 0)
1832 nb_rxd = res->value;
1833 } else if (!strcmp(res->name, "txd")) {
1834 if (check_nb_txd(res->value) != 0)
1837 nb_txd = res->value;
1839 fprintf(stderr, "Unknown parameter\n");
1847 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1850 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1851 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1852 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1853 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1854 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1855 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1856 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1857 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1859 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1860 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
1862 cmdline_parse_inst_t cmd_config_rx_tx = {
1863 .f = cmd_config_rx_tx_parsed,
1865 .help_str = "port config all rxq|txq|rxd|txd <value>",
1867 (void *)&cmd_config_rx_tx_port,
1868 (void *)&cmd_config_rx_tx_keyword,
1869 (void *)&cmd_config_rx_tx_all,
1870 (void *)&cmd_config_rx_tx_name,
1871 (void *)&cmd_config_rx_tx_value,
1876 /* *** config max packet length *** */
1877 struct cmd_config_max_pkt_len_result {
1878 cmdline_fixed_string_t port;
1879 cmdline_fixed_string_t keyword;
1880 cmdline_fixed_string_t all;
1881 cmdline_fixed_string_t name;
1886 cmd_config_max_pkt_len_parsed(void *parsed_result,
1887 __rte_unused struct cmdline *cl,
1888 __rte_unused void *data)
1890 struct cmd_config_max_pkt_len_result *res = parsed_result;
1894 if (strcmp(res->name, "max-pkt-len") != 0) {
1895 printf("Unknown parameter\n");
1899 if (!all_ports_stopped()) {
1900 fprintf(stderr, "Please stop all ports first\n");
1904 RTE_ETH_FOREACH_DEV(port_id) {
1905 struct rte_port *port = &ports[port_id];
1907 if (res->value < RTE_ETHER_MIN_LEN) {
1909 "max-pkt-len can not be less than %d\n",
1914 ret = eth_dev_info_get_print_err(port_id, &port->dev_info);
1917 "rte_eth_dev_info_get() failed for port %u\n",
1922 update_mtu_from_frame_size(port_id, res->value);
1927 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1930 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1931 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1933 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1934 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1936 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1937 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1939 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1940 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1942 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1943 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1946 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1947 .f = cmd_config_max_pkt_len_parsed,
1949 .help_str = "port config all max-pkt-len <value>",
1951 (void *)&cmd_config_max_pkt_len_port,
1952 (void *)&cmd_config_max_pkt_len_keyword,
1953 (void *)&cmd_config_max_pkt_len_all,
1954 (void *)&cmd_config_max_pkt_len_name,
1955 (void *)&cmd_config_max_pkt_len_value,
1960 /* *** config max LRO aggregated packet size *** */
1961 struct cmd_config_max_lro_pkt_size_result {
1962 cmdline_fixed_string_t port;
1963 cmdline_fixed_string_t keyword;
1964 cmdline_fixed_string_t all;
1965 cmdline_fixed_string_t name;
1970 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1971 __rte_unused struct cmdline *cl,
1972 __rte_unused void *data)
1974 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1977 if (!all_ports_stopped()) {
1978 fprintf(stderr, "Please stop all ports first\n");
1982 RTE_ETH_FOREACH_DEV(pid) {
1983 struct rte_port *port = &ports[pid];
1985 if (!strcmp(res->name, "max-lro-pkt-size")) {
1987 port->dev_conf.rxmode.max_lro_pkt_size)
1990 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
1992 fprintf(stderr, "Unknown parameter\n");
1999 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2002 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2003 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2005 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2006 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2008 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2009 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2011 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2012 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2013 name, "max-lro-pkt-size");
2014 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2015 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2018 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2019 .f = cmd_config_max_lro_pkt_size_parsed,
2021 .help_str = "port config all max-lro-pkt-size <value>",
2023 (void *)&cmd_config_max_lro_pkt_size_port,
2024 (void *)&cmd_config_max_lro_pkt_size_keyword,
2025 (void *)&cmd_config_max_lro_pkt_size_all,
2026 (void *)&cmd_config_max_lro_pkt_size_name,
2027 (void *)&cmd_config_max_lro_pkt_size_value,
2032 /* *** configure port MTU *** */
2033 struct cmd_config_mtu_result {
2034 cmdline_fixed_string_t port;
2035 cmdline_fixed_string_t keyword;
2036 cmdline_fixed_string_t mtu;
2042 cmd_config_mtu_parsed(void *parsed_result,
2043 __rte_unused struct cmdline *cl,
2044 __rte_unused void *data)
2046 struct cmd_config_mtu_result *res = parsed_result;
2048 if (res->value < RTE_ETHER_MIN_LEN) {
2049 fprintf(stderr, "mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2052 port_mtu_set(res->port_id, res->value);
2055 cmdline_parse_token_string_t cmd_config_mtu_port =
2056 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2058 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2059 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2061 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2062 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2064 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2065 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2067 cmdline_parse_token_num_t cmd_config_mtu_value =
2068 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2071 cmdline_parse_inst_t cmd_config_mtu = {
2072 .f = cmd_config_mtu_parsed,
2074 .help_str = "port config mtu <port_id> <value>",
2076 (void *)&cmd_config_mtu_port,
2077 (void *)&cmd_config_mtu_keyword,
2078 (void *)&cmd_config_mtu_mtu,
2079 (void *)&cmd_config_mtu_port_id,
2080 (void *)&cmd_config_mtu_value,
2085 /* *** configure rx mode *** */
2086 struct cmd_config_rx_mode_flag {
2087 cmdline_fixed_string_t port;
2088 cmdline_fixed_string_t keyword;
2089 cmdline_fixed_string_t all;
2090 cmdline_fixed_string_t name;
2091 cmdline_fixed_string_t value;
2095 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2096 __rte_unused struct cmdline *cl,
2097 __rte_unused void *data)
2099 struct cmd_config_rx_mode_flag *res = parsed_result;
2101 if (!all_ports_stopped()) {
2102 fprintf(stderr, "Please stop all ports first\n");
2106 if (!strcmp(res->name, "drop-en")) {
2107 if (!strcmp(res->value, "on"))
2109 else if (!strcmp(res->value, "off"))
2112 fprintf(stderr, "Unknown parameter\n");
2116 fprintf(stderr, "Unknown parameter\n");
2122 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2125 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2126 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2127 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2128 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2130 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2131 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2132 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2133 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2135 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2136 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2139 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2140 .f = cmd_config_rx_mode_flag_parsed,
2142 .help_str = "port config all drop-en on|off",
2144 (void *)&cmd_config_rx_mode_flag_port,
2145 (void *)&cmd_config_rx_mode_flag_keyword,
2146 (void *)&cmd_config_rx_mode_flag_all,
2147 (void *)&cmd_config_rx_mode_flag_name,
2148 (void *)&cmd_config_rx_mode_flag_value,
2153 /* *** configure rss *** */
2154 struct cmd_config_rss {
2155 cmdline_fixed_string_t port;
2156 cmdline_fixed_string_t keyword;
2157 cmdline_fixed_string_t all;
2158 cmdline_fixed_string_t name;
2159 cmdline_fixed_string_t value;
2163 cmd_config_rss_parsed(void *parsed_result,
2164 __rte_unused struct cmdline *cl,
2165 __rte_unused void *data)
2167 struct cmd_config_rss *res = parsed_result;
2168 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2169 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2170 int use_default = 0;
2171 int all_updated = 1;
2176 if (!strcmp(res->value, "all"))
2177 rss_conf.rss_hf = RTE_ETH_RSS_ETH | RTE_ETH_RSS_VLAN | RTE_ETH_RSS_IP |
2178 RTE_ETH_RSS_TCP | RTE_ETH_RSS_UDP | RTE_ETH_RSS_SCTP |
2179 RTE_ETH_RSS_L2_PAYLOAD | RTE_ETH_RSS_L2TPV3 | RTE_ETH_RSS_ESP |
2180 RTE_ETH_RSS_AH | RTE_ETH_RSS_PFCP | RTE_ETH_RSS_GTPU |
2182 else if (!strcmp(res->value, "eth"))
2183 rss_conf.rss_hf = RTE_ETH_RSS_ETH;
2184 else if (!strcmp(res->value, "vlan"))
2185 rss_conf.rss_hf = RTE_ETH_RSS_VLAN;
2186 else if (!strcmp(res->value, "ip"))
2187 rss_conf.rss_hf = RTE_ETH_RSS_IP;
2188 else if (!strcmp(res->value, "udp"))
2189 rss_conf.rss_hf = RTE_ETH_RSS_UDP;
2190 else if (!strcmp(res->value, "tcp"))
2191 rss_conf.rss_hf = RTE_ETH_RSS_TCP;
2192 else if (!strcmp(res->value, "sctp"))
2193 rss_conf.rss_hf = RTE_ETH_RSS_SCTP;
2194 else if (!strcmp(res->value, "ether"))
2195 rss_conf.rss_hf = RTE_ETH_RSS_L2_PAYLOAD;
2196 else if (!strcmp(res->value, "port"))
2197 rss_conf.rss_hf = RTE_ETH_RSS_PORT;
2198 else if (!strcmp(res->value, "vxlan"))
2199 rss_conf.rss_hf = RTE_ETH_RSS_VXLAN;
2200 else if (!strcmp(res->value, "geneve"))
2201 rss_conf.rss_hf = RTE_ETH_RSS_GENEVE;
2202 else if (!strcmp(res->value, "nvgre"))
2203 rss_conf.rss_hf = RTE_ETH_RSS_NVGRE;
2204 else if (!strcmp(res->value, "l3-pre32"))
2205 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2206 else if (!strcmp(res->value, "l3-pre40"))
2207 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2208 else if (!strcmp(res->value, "l3-pre48"))
2209 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2210 else if (!strcmp(res->value, "l3-pre56"))
2211 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2212 else if (!strcmp(res->value, "l3-pre64"))
2213 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2214 else if (!strcmp(res->value, "l3-pre96"))
2215 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2216 else if (!strcmp(res->value, "l3-src-only"))
2217 rss_conf.rss_hf = RTE_ETH_RSS_L3_SRC_ONLY;
2218 else if (!strcmp(res->value, "l3-dst-only"))
2219 rss_conf.rss_hf = RTE_ETH_RSS_L3_DST_ONLY;
2220 else if (!strcmp(res->value, "l4-src-only"))
2221 rss_conf.rss_hf = RTE_ETH_RSS_L4_SRC_ONLY;
2222 else if (!strcmp(res->value, "l4-dst-only"))
2223 rss_conf.rss_hf = RTE_ETH_RSS_L4_DST_ONLY;
2224 else if (!strcmp(res->value, "l2-src-only"))
2225 rss_conf.rss_hf = RTE_ETH_RSS_L2_SRC_ONLY;
2226 else if (!strcmp(res->value, "l2-dst-only"))
2227 rss_conf.rss_hf = RTE_ETH_RSS_L2_DST_ONLY;
2228 else if (!strcmp(res->value, "l2tpv3"))
2229 rss_conf.rss_hf = RTE_ETH_RSS_L2TPV3;
2230 else if (!strcmp(res->value, "esp"))
2231 rss_conf.rss_hf = RTE_ETH_RSS_ESP;
2232 else if (!strcmp(res->value, "ah"))
2233 rss_conf.rss_hf = RTE_ETH_RSS_AH;
2234 else if (!strcmp(res->value, "pfcp"))
2235 rss_conf.rss_hf = RTE_ETH_RSS_PFCP;
2236 else if (!strcmp(res->value, "pppoe"))
2237 rss_conf.rss_hf = RTE_ETH_RSS_PPPOE;
2238 else if (!strcmp(res->value, "gtpu"))
2239 rss_conf.rss_hf = RTE_ETH_RSS_GTPU;
2240 else if (!strcmp(res->value, "ecpri"))
2241 rss_conf.rss_hf = RTE_ETH_RSS_ECPRI;
2242 else if (!strcmp(res->value, "mpls"))
2243 rss_conf.rss_hf = RTE_ETH_RSS_MPLS;
2244 else if (!strcmp(res->value, "ipv4-chksum"))
2245 rss_conf.rss_hf = RTE_ETH_RSS_IPV4_CHKSUM;
2246 else if (!strcmp(res->value, "none"))
2247 rss_conf.rss_hf = 0;
2248 else if (!strcmp(res->value, "level-default")) {
2249 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2250 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_PMD_DEFAULT);
2251 } else if (!strcmp(res->value, "level-outer")) {
2252 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2253 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_OUTERMOST);
2254 } else if (!strcmp(res->value, "level-inner")) {
2255 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2256 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_INNERMOST);
2257 } else if (!strcmp(res->value, "default"))
2259 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2260 atoi(res->value) < 64)
2261 rss_conf.rss_hf = 1ULL << atoi(res->value);
2263 fprintf(stderr, "Unknown parameter\n");
2266 rss_conf.rss_key = NULL;
2267 /* Update global configuration for RSS types. */
2268 RTE_ETH_FOREACH_DEV(i) {
2269 struct rte_eth_rss_conf local_rss_conf;
2271 ret = eth_dev_info_get_print_err(i, &dev_info);
2276 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2278 local_rss_conf = rss_conf;
2279 local_rss_conf.rss_hf = rss_conf.rss_hf &
2280 dev_info.flow_type_rss_offloads;
2281 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2282 printf("Port %u modified RSS hash function based on hardware support,"
2283 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2284 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2286 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2290 "Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n",
2291 i, -diag, strerror(-diag));
2294 if (all_updated && !use_default) {
2295 rss_hf = rss_conf.rss_hf;
2296 printf("rss_hf %#"PRIx64"\n", rss_hf);
2300 cmdline_parse_token_string_t cmd_config_rss_port =
2301 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2302 cmdline_parse_token_string_t cmd_config_rss_keyword =
2303 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2304 cmdline_parse_token_string_t cmd_config_rss_all =
2305 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2306 cmdline_parse_token_string_t cmd_config_rss_name =
2307 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2308 cmdline_parse_token_string_t cmd_config_rss_value =
2309 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2311 cmdline_parse_inst_t cmd_config_rss = {
2312 .f = cmd_config_rss_parsed,
2314 .help_str = "port config all rss "
2315 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2316 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none|level-default|"
2317 "level-outer|level-inner|ipv4-chksum|<flowtype_id>",
2319 (void *)&cmd_config_rss_port,
2320 (void *)&cmd_config_rss_keyword,
2321 (void *)&cmd_config_rss_all,
2322 (void *)&cmd_config_rss_name,
2323 (void *)&cmd_config_rss_value,
2328 /* *** configure rss hash key *** */
2329 struct cmd_config_rss_hash_key {
2330 cmdline_fixed_string_t port;
2331 cmdline_fixed_string_t config;
2333 cmdline_fixed_string_t rss_hash_key;
2334 cmdline_fixed_string_t rss_type;
2335 cmdline_fixed_string_t key;
2339 hexa_digit_to_value(char hexa_digit)
2341 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2342 return (uint8_t) (hexa_digit - '0');
2343 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2344 return (uint8_t) ((hexa_digit - 'a') + 10);
2345 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2346 return (uint8_t) ((hexa_digit - 'A') + 10);
2347 /* Invalid hexa digit */
2352 parse_and_check_key_hexa_digit(char *key, int idx)
2356 hexa_v = hexa_digit_to_value(key[idx]);
2359 "invalid key: character %c at position %d is not a valid hexa digit\n",
2365 cmd_config_rss_hash_key_parsed(void *parsed_result,
2366 __rte_unused struct cmdline *cl,
2367 __rte_unused void *data)
2369 struct cmd_config_rss_hash_key *res = parsed_result;
2370 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2374 struct rte_eth_dev_info dev_info;
2375 uint8_t hash_key_size;
2379 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2383 if (dev_info.hash_key_size > 0 &&
2384 dev_info.hash_key_size <= sizeof(hash_key))
2385 hash_key_size = dev_info.hash_key_size;
2388 "dev_info did not provide a valid hash key size\n");
2391 /* Check the length of the RSS hash key */
2392 key_len = strlen(res->key);
2393 if (key_len != (hash_key_size * 2)) {
2395 "key length: %d invalid - key must be a string of %d hexa-decimal numbers\n",
2396 (int)key_len, hash_key_size * 2);
2399 /* Translate RSS hash key into binary representation */
2400 for (i = 0; i < hash_key_size; i++) {
2401 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2404 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2407 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2409 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2413 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2414 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2415 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2416 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2418 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2419 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2421 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2422 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2423 rss_hash_key, "rss-hash-key");
2424 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2425 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2426 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2427 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2428 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2429 "ipv6-tcp-ex#ipv6-udp-ex#"
2430 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2431 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2432 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls");
2433 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2434 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2436 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2437 .f = cmd_config_rss_hash_key_parsed,
2439 .help_str = "port config <port_id> rss-hash-key "
2440 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2441 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2442 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2443 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2444 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2445 "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls "
2446 "<string of hex digits (variable length, NIC dependent)>",
2448 (void *)&cmd_config_rss_hash_key_port,
2449 (void *)&cmd_config_rss_hash_key_config,
2450 (void *)&cmd_config_rss_hash_key_port_id,
2451 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2452 (void *)&cmd_config_rss_hash_key_rss_type,
2453 (void *)&cmd_config_rss_hash_key_value,
2458 /* *** cleanup txq mbufs *** */
2459 struct cmd_cleanup_txq_mbufs_result {
2460 cmdline_fixed_string_t port;
2461 cmdline_fixed_string_t keyword;
2462 cmdline_fixed_string_t name;
2469 cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2470 __rte_unused struct cmdline *cl,
2471 __rte_unused void *data)
2473 struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2474 uint16_t port_id = res->port_id;
2475 uint16_t queue_id = res->queue_id;
2476 uint32_t free_cnt = res->free_cnt;
2477 struct rte_eth_txq_info qinfo;
2480 if (test_done == 0) {
2481 fprintf(stderr, "Please stop forwarding first\n");
2485 if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2486 fprintf(stderr, "Failed to get port %u Tx queue %u info\n",
2491 if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2492 fprintf(stderr, "Tx queue %u not started\n", queue_id);
2496 ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2499 "Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n",
2500 port_id, queue_id, strerror(-ret), ret);
2504 printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2505 port_id, queue_id, ret);
2508 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2509 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2511 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2512 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2514 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2515 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2517 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2518 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2520 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2521 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2523 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2524 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2527 cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2528 .f = cmd_cleanup_txq_mbufs_parsed,
2530 .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2532 (void *)&cmd_cleanup_txq_mbufs_port,
2533 (void *)&cmd_cleanup_txq_mbufs_cleanup,
2534 (void *)&cmd_cleanup_txq_mbufs_port_id,
2535 (void *)&cmd_cleanup_txq_mbufs_txq,
2536 (void *)&cmd_cleanup_txq_mbufs_queue_id,
2537 (void *)&cmd_cleanup_txq_mbufs_free_cnt,
2542 /* *** configure port rxq/txq ring size *** */
2543 struct cmd_config_rxtx_ring_size {
2544 cmdline_fixed_string_t port;
2545 cmdline_fixed_string_t config;
2547 cmdline_fixed_string_t rxtxq;
2549 cmdline_fixed_string_t rsize;
2554 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2555 __rte_unused struct cmdline *cl,
2556 __rte_unused void *data)
2558 struct cmd_config_rxtx_ring_size *res = parsed_result;
2559 struct rte_port *port;
2562 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2565 if (res->portid == (portid_t)RTE_PORT_ALL) {
2566 fprintf(stderr, "Invalid port id\n");
2570 port = &ports[res->portid];
2572 if (!strcmp(res->rxtxq, "rxq"))
2574 else if (!strcmp(res->rxtxq, "txq"))
2577 fprintf(stderr, "Unknown parameter\n");
2581 if (isrx && rx_queue_id_is_invalid(res->qid))
2583 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2586 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2588 "Invalid rx ring_size, must > rx_free_thresh: %d\n",
2594 port->nb_rx_desc[res->qid] = res->size;
2596 port->nb_tx_desc[res->qid] = res->size;
2598 cmd_reconfig_device_queue(res->portid, 0, 1);
2601 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2602 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2604 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2605 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2607 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2608 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2609 portid, RTE_UINT16);
2610 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2611 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2613 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2614 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2616 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2617 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2618 rsize, "ring_size");
2619 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2620 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2623 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2624 .f = cmd_config_rxtx_ring_size_parsed,
2626 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2628 (void *)&cmd_config_rxtx_ring_size_port,
2629 (void *)&cmd_config_rxtx_ring_size_config,
2630 (void *)&cmd_config_rxtx_ring_size_portid,
2631 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2632 (void *)&cmd_config_rxtx_ring_size_qid,
2633 (void *)&cmd_config_rxtx_ring_size_rsize,
2634 (void *)&cmd_config_rxtx_ring_size_size,
2639 /* *** configure port rxq/txq start/stop *** */
2640 struct cmd_config_rxtx_queue {
2641 cmdline_fixed_string_t port;
2643 cmdline_fixed_string_t rxtxq;
2645 cmdline_fixed_string_t opname;
2649 cmd_config_rxtx_queue_parsed(void *parsed_result,
2650 __rte_unused struct cmdline *cl,
2651 __rte_unused void *data)
2653 struct cmd_config_rxtx_queue *res = parsed_result;
2658 if (test_done == 0) {
2659 fprintf(stderr, "Please stop forwarding first\n");
2663 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2666 if (port_is_started(res->portid) != 1) {
2667 fprintf(stderr, "Please start port %u first\n", res->portid);
2671 if (!strcmp(res->rxtxq, "rxq"))
2673 else if (!strcmp(res->rxtxq, "txq"))
2676 fprintf(stderr, "Unknown parameter\n");
2680 if (isrx && rx_queue_id_is_invalid(res->qid))
2682 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2685 if (!strcmp(res->opname, "start"))
2687 else if (!strcmp(res->opname, "stop"))
2690 fprintf(stderr, "Unknown parameter\n");
2694 if (isstart && isrx)
2695 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2696 else if (!isstart && isrx)
2697 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2698 else if (isstart && !isrx)
2699 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2701 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2703 if (ret == -ENOTSUP)
2704 fprintf(stderr, "Function not supported in PMD\n");
2707 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2708 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2709 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2710 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2711 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2712 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2713 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2714 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2715 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2716 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2719 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2720 .f = cmd_config_rxtx_queue_parsed,
2722 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2724 (void *)&cmd_config_rxtx_queue_port,
2725 (void *)&cmd_config_rxtx_queue_portid,
2726 (void *)&cmd_config_rxtx_queue_rxtxq,
2727 (void *)&cmd_config_rxtx_queue_qid,
2728 (void *)&cmd_config_rxtx_queue_opname,
2733 /* *** configure port rxq/txq deferred start on/off *** */
2734 struct cmd_config_deferred_start_rxtx_queue {
2735 cmdline_fixed_string_t port;
2737 cmdline_fixed_string_t rxtxq;
2739 cmdline_fixed_string_t opname;
2740 cmdline_fixed_string_t state;
2744 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2745 __rte_unused struct cmdline *cl,
2746 __rte_unused void *data)
2748 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2749 struct rte_port *port;
2752 uint8_t needreconfig = 0;
2754 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2757 if (port_is_started(res->port_id) != 0) {
2758 fprintf(stderr, "Please stop port %u first\n", res->port_id);
2762 port = &ports[res->port_id];
2764 isrx = !strcmp(res->rxtxq, "rxq");
2766 if (isrx && rx_queue_id_is_invalid(res->qid))
2768 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2771 ison = !strcmp(res->state, "on");
2773 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2774 port->rx_conf[res->qid].rx_deferred_start = ison;
2776 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2777 port->tx_conf[res->qid].tx_deferred_start = ison;
2782 cmd_reconfig_device_queue(res->port_id, 0, 1);
2785 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2786 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2788 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2789 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2790 port_id, RTE_UINT16);
2791 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2792 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2794 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2795 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2797 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2798 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2799 opname, "deferred_start");
2800 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2801 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2804 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2805 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2807 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2809 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2810 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2811 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2812 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2813 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2814 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2819 /* *** configure port rxq/txq setup *** */
2820 struct cmd_setup_rxtx_queue {
2821 cmdline_fixed_string_t port;
2823 cmdline_fixed_string_t rxtxq;
2825 cmdline_fixed_string_t setup;
2828 /* Common CLI fields for queue setup */
2829 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2830 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2831 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2832 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2833 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2834 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2835 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2836 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2837 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2838 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2841 cmd_setup_rxtx_queue_parsed(
2842 void *parsed_result,
2843 __rte_unused struct cmdline *cl,
2844 __rte_unused void *data)
2846 struct cmd_setup_rxtx_queue *res = parsed_result;
2847 struct rte_port *port;
2848 struct rte_mempool *mp;
2849 unsigned int socket_id;
2853 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2856 if (res->portid == (portid_t)RTE_PORT_ALL) {
2857 fprintf(stderr, "Invalid port id\n");
2861 if (!strcmp(res->rxtxq, "rxq"))
2863 else if (!strcmp(res->rxtxq, "txq"))
2866 fprintf(stderr, "Unknown parameter\n");
2870 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2871 fprintf(stderr, "Invalid rx queue\n");
2873 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2874 fprintf(stderr, "Invalid tx queue\n");
2878 port = &ports[res->portid];
2880 socket_id = rxring_numa[res->portid];
2881 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2882 socket_id = port->socket_id;
2884 mp = mbuf_pool_find(socket_id, 0);
2887 "Failed to setup RX queue: No mempool allocation on the socket %d\n",
2888 rxring_numa[res->portid]);
2891 ret = rx_queue_setup(res->portid,
2893 port->nb_rx_desc[res->qid],
2895 &port->rx_conf[res->qid],
2898 fprintf(stderr, "Failed to setup RX queue\n");
2900 socket_id = txring_numa[res->portid];
2901 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2902 socket_id = port->socket_id;
2904 if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
2906 "Failed to setup TX queue: not enough descriptors\n");
2909 ret = rte_eth_tx_queue_setup(res->portid,
2911 port->nb_tx_desc[res->qid],
2913 &port->tx_conf[res->qid]);
2915 fprintf(stderr, "Failed to setup TX queue\n");
2919 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2920 .f = cmd_setup_rxtx_queue_parsed,
2922 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2924 (void *)&cmd_setup_rxtx_queue_port,
2925 (void *)&cmd_setup_rxtx_queue_portid,
2926 (void *)&cmd_setup_rxtx_queue_rxtxq,
2927 (void *)&cmd_setup_rxtx_queue_qid,
2928 (void *)&cmd_setup_rxtx_queue_setup,
2934 /* *** Configure RSS RETA *** */
2935 struct cmd_config_rss_reta {
2936 cmdline_fixed_string_t port;
2937 cmdline_fixed_string_t keyword;
2939 cmdline_fixed_string_t name;
2940 cmdline_fixed_string_t list_name;
2941 cmdline_fixed_string_t list_of_items;
2945 parse_reta_config(const char *str,
2946 struct rte_eth_rss_reta_entry64 *reta_conf,
2947 uint16_t nb_entries)
2951 uint16_t hash_index, idx, shift;
2954 const char *p, *p0 = str;
2961 unsigned long int_fld[_NUM_FLD];
2962 char *str_fld[_NUM_FLD];
2964 while ((p = strchr(p0,'(')) != NULL) {
2966 if((p0 = strchr(p,')')) == NULL)
2970 if(size >= sizeof(s))
2973 snprintf(s, sizeof(s), "%.*s", size, p);
2974 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2976 for (i = 0; i < _NUM_FLD; i++) {
2978 int_fld[i] = strtoul(str_fld[i], &end, 0);
2979 if (errno != 0 || end == str_fld[i] ||
2984 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2985 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2987 if (hash_index >= nb_entries) {
2988 fprintf(stderr, "Invalid RETA hash index=%d\n",
2993 idx = hash_index / RTE_ETH_RETA_GROUP_SIZE;
2994 shift = hash_index % RTE_ETH_RETA_GROUP_SIZE;
2995 reta_conf[idx].mask |= (1ULL << shift);
2996 reta_conf[idx].reta[shift] = nb_queue;
3003 cmd_set_rss_reta_parsed(void *parsed_result,
3004 __rte_unused struct cmdline *cl,
3005 __rte_unused void *data)
3008 struct rte_eth_dev_info dev_info;
3009 struct rte_eth_rss_reta_entry64 reta_conf[8];
3010 struct cmd_config_rss_reta *res = parsed_result;
3012 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3016 if (dev_info.reta_size == 0) {
3018 "Redirection table size is 0 which is invalid for RSS\n");
3021 printf("The reta size of port %d is %u\n",
3022 res->port_id, dev_info.reta_size);
3023 if (dev_info.reta_size > RTE_ETH_RSS_RETA_SIZE_512) {
3025 "Currently do not support more than %u entries of redirection table\n",
3026 RTE_ETH_RSS_RETA_SIZE_512);
3030 memset(reta_conf, 0, sizeof(reta_conf));
3031 if (!strcmp(res->list_name, "reta")) {
3032 if (parse_reta_config(res->list_of_items, reta_conf,
3033 dev_info.reta_size)) {
3035 "Invalid RSS Redirection Table config entered\n");
3038 ret = rte_eth_dev_rss_reta_update(res->port_id,
3039 reta_conf, dev_info.reta_size);
3042 "Bad redirection table parameter, return code = %d\n",
3047 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3048 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3049 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3050 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3051 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3052 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3053 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3054 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3055 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3056 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3057 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3058 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3060 cmdline_parse_inst_t cmd_config_rss_reta = {
3061 .f = cmd_set_rss_reta_parsed,
3063 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3065 (void *)&cmd_config_rss_reta_port,
3066 (void *)&cmd_config_rss_reta_keyword,
3067 (void *)&cmd_config_rss_reta_port_id,
3068 (void *)&cmd_config_rss_reta_name,
3069 (void *)&cmd_config_rss_reta_list_name,
3070 (void *)&cmd_config_rss_reta_list_of_items,
3075 /* *** SHOW PORT RETA INFO *** */
3076 struct cmd_showport_reta {
3077 cmdline_fixed_string_t show;
3078 cmdline_fixed_string_t port;
3080 cmdline_fixed_string_t rss;
3081 cmdline_fixed_string_t reta;
3083 cmdline_fixed_string_t list_of_items;
3087 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3088 uint16_t nb_entries,
3092 const char *p, *p0 = str;
3097 uint16_t num = (nb_entries + RTE_ETH_RETA_GROUP_SIZE - 1) /
3098 RTE_ETH_RETA_GROUP_SIZE;
3101 p = strchr(p0, '(');
3105 p0 = strchr(p, ')');
3109 if (size >= sizeof(s)) {
3111 "The string size exceeds the internal buffer size\n");
3114 snprintf(s, sizeof(s), "%.*s", size, p);
3115 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3116 if (ret <= 0 || ret != num) {
3118 "The bits of masks do not match the number of reta entries: %u\n",
3122 for (i = 0; i < ret; i++)
3123 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3129 cmd_showport_reta_parsed(void *parsed_result,
3130 __rte_unused struct cmdline *cl,
3131 __rte_unused void *data)
3133 struct cmd_showport_reta *res = parsed_result;
3134 struct rte_eth_rss_reta_entry64 reta_conf[8];
3135 struct rte_eth_dev_info dev_info;
3136 uint16_t max_reta_size;
3139 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3143 max_reta_size = RTE_MIN(dev_info.reta_size, RTE_ETH_RSS_RETA_SIZE_512);
3144 if (res->size == 0 || res->size > max_reta_size) {
3145 fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n",
3146 res->size, max_reta_size);
3150 memset(reta_conf, 0, sizeof(reta_conf));
3151 if (showport_parse_reta_config(reta_conf, res->size,
3152 res->list_of_items) < 0) {
3153 fprintf(stderr, "Invalid string: %s for reta masks\n",
3154 res->list_of_items);
3157 port_rss_reta_info(res->port_id, reta_conf, res->size);
3160 cmdline_parse_token_string_t cmd_showport_reta_show =
3161 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3162 cmdline_parse_token_string_t cmd_showport_reta_port =
3163 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3164 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3165 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3166 cmdline_parse_token_string_t cmd_showport_reta_rss =
3167 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3168 cmdline_parse_token_string_t cmd_showport_reta_reta =
3169 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3170 cmdline_parse_token_num_t cmd_showport_reta_size =
3171 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3172 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3173 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3174 list_of_items, NULL);
3176 cmdline_parse_inst_t cmd_showport_reta = {
3177 .f = cmd_showport_reta_parsed,
3179 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3181 (void *)&cmd_showport_reta_show,
3182 (void *)&cmd_showport_reta_port,
3183 (void *)&cmd_showport_reta_port_id,
3184 (void *)&cmd_showport_reta_rss,
3185 (void *)&cmd_showport_reta_reta,
3186 (void *)&cmd_showport_reta_size,
3187 (void *)&cmd_showport_reta_list_of_items,
3192 /* *** Show RSS hash configuration *** */
3193 struct cmd_showport_rss_hash {
3194 cmdline_fixed_string_t show;
3195 cmdline_fixed_string_t port;
3197 cmdline_fixed_string_t rss_hash;
3198 cmdline_fixed_string_t rss_type;
3199 cmdline_fixed_string_t key; /* optional argument */
3202 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3203 __rte_unused struct cmdline *cl,
3206 struct cmd_showport_rss_hash *res = parsed_result;
3208 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3211 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3212 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3213 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3214 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3215 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3216 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3218 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3219 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3221 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3222 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3224 cmdline_parse_inst_t cmd_showport_rss_hash = {
3225 .f = cmd_showport_rss_hash_parsed,
3227 .help_str = "show port <port_id> rss-hash",
3229 (void *)&cmd_showport_rss_hash_show,
3230 (void *)&cmd_showport_rss_hash_port,
3231 (void *)&cmd_showport_rss_hash_port_id,
3232 (void *)&cmd_showport_rss_hash_rss_hash,
3237 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3238 .f = cmd_showport_rss_hash_parsed,
3240 .help_str = "show port <port_id> rss-hash key",
3242 (void *)&cmd_showport_rss_hash_show,
3243 (void *)&cmd_showport_rss_hash_port,
3244 (void *)&cmd_showport_rss_hash_port_id,
3245 (void *)&cmd_showport_rss_hash_rss_hash,
3246 (void *)&cmd_showport_rss_hash_rss_key,
3251 /* *** Configure DCB *** */
3252 struct cmd_config_dcb {
3253 cmdline_fixed_string_t port;
3254 cmdline_fixed_string_t config;
3256 cmdline_fixed_string_t dcb;
3257 cmdline_fixed_string_t vt;
3258 cmdline_fixed_string_t vt_en;
3260 cmdline_fixed_string_t pfc;
3261 cmdline_fixed_string_t pfc_en;
3265 cmd_config_dcb_parsed(void *parsed_result,
3266 __rte_unused struct cmdline *cl,
3267 __rte_unused void *data)
3269 struct cmd_config_dcb *res = parsed_result;
3270 struct rte_eth_dcb_info dcb_info;
3271 portid_t port_id = res->port_id;
3272 struct rte_port *port;
3276 port = &ports[port_id];
3277 /** Check if the port is not started **/
3278 if (port->port_status != RTE_PORT_STOPPED) {
3279 fprintf(stderr, "Please stop port %d first\n", port_id);
3283 if ((res->num_tcs != RTE_ETH_4_TCS) && (res->num_tcs != RTE_ETH_8_TCS)) {
3285 "The invalid number of traffic class, only 4 or 8 allowed.\n");
3289 if (nb_fwd_lcores < res->num_tcs) {
3291 "nb_cores shouldn't be less than number of TCs.\n");
3295 /* Check whether the port supports the report of DCB info. */
3296 ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3297 if (ret == -ENOTSUP) {
3298 fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n");
3302 if (!strncmp(res->pfc_en, "on", 2))
3307 /* DCB in VT mode */
3308 if (!strncmp(res->vt_en, "on", 2))
3309 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3310 (enum rte_eth_nb_tcs)res->num_tcs,
3313 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3314 (enum rte_eth_nb_tcs)res->num_tcs,
3317 fprintf(stderr, "Cannot initialize network ports.\n");
3323 cmd_reconfig_device_queue(port_id, 1, 1);
3326 cmdline_parse_token_string_t cmd_config_dcb_port =
3327 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3328 cmdline_parse_token_string_t cmd_config_dcb_config =
3329 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3330 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3331 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3332 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3333 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3334 cmdline_parse_token_string_t cmd_config_dcb_vt =
3335 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3336 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3337 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3338 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3339 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3340 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3341 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3342 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3343 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3345 cmdline_parse_inst_t cmd_config_dcb = {
3346 .f = cmd_config_dcb_parsed,
3348 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3350 (void *)&cmd_config_dcb_port,
3351 (void *)&cmd_config_dcb_config,
3352 (void *)&cmd_config_dcb_port_id,
3353 (void *)&cmd_config_dcb_dcb,
3354 (void *)&cmd_config_dcb_vt,
3355 (void *)&cmd_config_dcb_vt_en,
3356 (void *)&cmd_config_dcb_num_tcs,
3357 (void *)&cmd_config_dcb_pfc,
3358 (void *)&cmd_config_dcb_pfc_en,
3363 /* *** configure number of packets per burst *** */
3364 struct cmd_config_burst {
3365 cmdline_fixed_string_t port;
3366 cmdline_fixed_string_t keyword;
3367 cmdline_fixed_string_t all;
3368 cmdline_fixed_string_t name;
3373 cmd_config_burst_parsed(void *parsed_result,
3374 __rte_unused struct cmdline *cl,
3375 __rte_unused void *data)
3377 struct cmd_config_burst *res = parsed_result;
3378 struct rte_eth_dev_info dev_info;
3379 uint16_t rec_nb_pkts;
3382 if (!all_ports_stopped()) {
3383 fprintf(stderr, "Please stop all ports first\n");
3387 if (!strcmp(res->name, "burst")) {
3388 if (res->value == 0) {
3389 /* If user gives a value of zero, query the PMD for
3390 * its recommended Rx burst size. Testpmd uses a single
3391 * size for all ports, so assume all ports are the same
3392 * NIC model and use the values from Port 0.
3394 ret = eth_dev_info_get_print_err(0, &dev_info);
3398 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3400 if (rec_nb_pkts == 0) {
3401 printf("PMD does not recommend a burst size.\n"
3402 "User provided value must be between"
3403 " 1 and %d\n", MAX_PKT_BURST);
3405 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3406 printf("PMD recommended burst size of %d"
3407 " exceeds maximum value of %d\n",
3408 rec_nb_pkts, MAX_PKT_BURST);
3411 printf("Using PMD-provided burst value of %d\n",
3413 nb_pkt_per_burst = rec_nb_pkts;
3414 } else if (res->value > MAX_PKT_BURST) {
3415 fprintf(stderr, "burst must be >= 1 && <= %d\n",
3419 nb_pkt_per_burst = res->value;
3421 fprintf(stderr, "Unknown parameter\n");
3427 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3430 cmdline_parse_token_string_t cmd_config_burst_port =
3431 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3432 cmdline_parse_token_string_t cmd_config_burst_keyword =
3433 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3434 cmdline_parse_token_string_t cmd_config_burst_all =
3435 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3436 cmdline_parse_token_string_t cmd_config_burst_name =
3437 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3438 cmdline_parse_token_num_t cmd_config_burst_value =
3439 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3441 cmdline_parse_inst_t cmd_config_burst = {
3442 .f = cmd_config_burst_parsed,
3444 .help_str = "port config all burst <value>",
3446 (void *)&cmd_config_burst_port,
3447 (void *)&cmd_config_burst_keyword,
3448 (void *)&cmd_config_burst_all,
3449 (void *)&cmd_config_burst_name,
3450 (void *)&cmd_config_burst_value,
3455 /* *** configure rx/tx queues *** */
3456 struct cmd_config_thresh {
3457 cmdline_fixed_string_t port;
3458 cmdline_fixed_string_t keyword;
3459 cmdline_fixed_string_t all;
3460 cmdline_fixed_string_t name;
3465 cmd_config_thresh_parsed(void *parsed_result,
3466 __rte_unused struct cmdline *cl,
3467 __rte_unused void *data)
3469 struct cmd_config_thresh *res = parsed_result;
3471 if (!all_ports_stopped()) {
3472 fprintf(stderr, "Please stop all ports first\n");
3476 if (!strcmp(res->name, "txpt"))
3477 tx_pthresh = res->value;
3478 else if(!strcmp(res->name, "txht"))
3479 tx_hthresh = res->value;
3480 else if(!strcmp(res->name, "txwt"))
3481 tx_wthresh = res->value;
3482 else if(!strcmp(res->name, "rxpt"))
3483 rx_pthresh = res->value;
3484 else if(!strcmp(res->name, "rxht"))
3485 rx_hthresh = res->value;
3486 else if(!strcmp(res->name, "rxwt"))
3487 rx_wthresh = res->value;
3489 fprintf(stderr, "Unknown parameter\n");
3495 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3498 cmdline_parse_token_string_t cmd_config_thresh_port =
3499 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3500 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3501 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3502 cmdline_parse_token_string_t cmd_config_thresh_all =
3503 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3504 cmdline_parse_token_string_t cmd_config_thresh_name =
3505 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3506 "txpt#txht#txwt#rxpt#rxht#rxwt");
3507 cmdline_parse_token_num_t cmd_config_thresh_value =
3508 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3510 cmdline_parse_inst_t cmd_config_thresh = {
3511 .f = cmd_config_thresh_parsed,
3513 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3515 (void *)&cmd_config_thresh_port,
3516 (void *)&cmd_config_thresh_keyword,
3517 (void *)&cmd_config_thresh_all,
3518 (void *)&cmd_config_thresh_name,
3519 (void *)&cmd_config_thresh_value,
3524 /* *** configure free/rs threshold *** */
3525 struct cmd_config_threshold {
3526 cmdline_fixed_string_t port;
3527 cmdline_fixed_string_t keyword;
3528 cmdline_fixed_string_t all;
3529 cmdline_fixed_string_t name;
3534 cmd_config_threshold_parsed(void *parsed_result,
3535 __rte_unused struct cmdline *cl,
3536 __rte_unused void *data)
3538 struct cmd_config_threshold *res = parsed_result;
3540 if (!all_ports_stopped()) {
3541 fprintf(stderr, "Please stop all ports first\n");
3545 if (!strcmp(res->name, "txfreet"))
3546 tx_free_thresh = res->value;
3547 else if (!strcmp(res->name, "txrst"))
3548 tx_rs_thresh = res->value;
3549 else if (!strcmp(res->name, "rxfreet"))
3550 rx_free_thresh = res->value;
3552 fprintf(stderr, "Unknown parameter\n");
3558 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3561 cmdline_parse_token_string_t cmd_config_threshold_port =
3562 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3563 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3564 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3566 cmdline_parse_token_string_t cmd_config_threshold_all =
3567 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3568 cmdline_parse_token_string_t cmd_config_threshold_name =
3569 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3570 "txfreet#txrst#rxfreet");
3571 cmdline_parse_token_num_t cmd_config_threshold_value =
3572 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3574 cmdline_parse_inst_t cmd_config_threshold = {
3575 .f = cmd_config_threshold_parsed,
3577 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3579 (void *)&cmd_config_threshold_port,
3580 (void *)&cmd_config_threshold_keyword,
3581 (void *)&cmd_config_threshold_all,
3582 (void *)&cmd_config_threshold_name,
3583 (void *)&cmd_config_threshold_value,
3589 struct cmd_stop_result {
3590 cmdline_fixed_string_t stop;
3593 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3594 __rte_unused struct cmdline *cl,
3595 __rte_unused void *data)
3597 stop_packet_forwarding();
3600 cmdline_parse_token_string_t cmd_stop_stop =
3601 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3603 cmdline_parse_inst_t cmd_stop = {
3604 .f = cmd_stop_parsed,
3606 .help_str = "stop: Stop packet forwarding",
3608 (void *)&cmd_stop_stop,
3613 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3616 parse_item_list(const char *str, const char *item_name, unsigned int max_items,
3617 unsigned int *parsed_items, int check_unique_values)
3619 unsigned int nb_item;
3627 * First parse all items in the list and store their value.
3632 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3634 if ((c >= '0') && (c <= '9')) {
3635 value = (unsigned int) (value * 10 + (c - '0'));
3640 fprintf(stderr, "character %c is not a decimal digit\n", c);
3644 fprintf(stderr, "No valid value before comma\n");
3647 if (nb_item < max_items) {
3648 parsed_items[nb_item] = value;
3654 if (nb_item >= max_items) {
3655 fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
3656 item_name, nb_item + 1, max_items);
3659 parsed_items[nb_item++] = value;
3660 if (! check_unique_values)
3664 * Then, check that all values in the list are different.
3665 * No optimization here...
3667 for (i = 0; i < nb_item; i++) {
3668 for (j = i + 1; j < nb_item; j++) {
3669 if (parsed_items[j] == parsed_items[i]) {
3671 "duplicated %s %u at index %u and %u\n",
3672 item_name, parsed_items[i], i, j);
3680 struct cmd_set_list_result {
3681 cmdline_fixed_string_t cmd_keyword;
3682 cmdline_fixed_string_t list_name;
3683 cmdline_fixed_string_t list_of_items;
3686 static void cmd_set_list_parsed(void *parsed_result,
3687 __rte_unused struct cmdline *cl,
3688 __rte_unused void *data)
3690 struct cmd_set_list_result *res;
3692 unsigned int lcorelist[RTE_MAX_LCORE];
3693 unsigned int portlist[RTE_MAX_ETHPORTS];
3695 unsigned int nb_item;
3697 if (test_done == 0) {
3698 fprintf(stderr, "Please stop forwarding first\n");
3702 res = parsed_result;
3703 if (!strcmp(res->list_name, "corelist")) {
3704 nb_item = parse_item_list(res->list_of_items, "core",
3706 parsed_items.lcorelist, 1);
3708 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3713 if (!strcmp(res->list_name, "portlist")) {
3714 nb_item = parse_item_list(res->list_of_items, "port",
3716 parsed_items.portlist, 1);
3718 set_fwd_ports_list(parsed_items.portlist, nb_item);
3724 cmdline_parse_token_string_t cmd_set_list_keyword =
3725 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3727 cmdline_parse_token_string_t cmd_set_list_name =
3728 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3729 "corelist#portlist");
3730 cmdline_parse_token_string_t cmd_set_list_of_items =
3731 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3734 cmdline_parse_inst_t cmd_set_fwd_list = {
3735 .f = cmd_set_list_parsed,
3737 .help_str = "set corelist|portlist <list0[,list1]*>",
3739 (void *)&cmd_set_list_keyword,
3740 (void *)&cmd_set_list_name,
3741 (void *)&cmd_set_list_of_items,
3746 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3748 struct cmd_setmask_result {
3749 cmdline_fixed_string_t set;
3750 cmdline_fixed_string_t mask;
3754 static void cmd_set_mask_parsed(void *parsed_result,
3755 __rte_unused struct cmdline *cl,
3756 __rte_unused void *data)
3758 struct cmd_setmask_result *res = parsed_result;
3760 if (test_done == 0) {
3761 fprintf(stderr, "Please stop forwarding first\n");
3764 if (!strcmp(res->mask, "coremask")) {
3765 set_fwd_lcores_mask(res->hexavalue);
3767 } else if (!strcmp(res->mask, "portmask")) {
3768 set_fwd_ports_mask(res->hexavalue);
3773 cmdline_parse_token_string_t cmd_setmask_set =
3774 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3775 cmdline_parse_token_string_t cmd_setmask_mask =
3776 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3777 "coremask#portmask");
3778 cmdline_parse_token_num_t cmd_setmask_value =
3779 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3781 cmdline_parse_inst_t cmd_set_fwd_mask = {
3782 .f = cmd_set_mask_parsed,
3784 .help_str = "set coremask|portmask <hexadecimal value>",
3786 (void *)&cmd_setmask_set,
3787 (void *)&cmd_setmask_mask,
3788 (void *)&cmd_setmask_value,
3794 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3796 struct cmd_set_result {
3797 cmdline_fixed_string_t set;
3798 cmdline_fixed_string_t what;
3802 static void cmd_set_parsed(void *parsed_result,
3803 __rte_unused struct cmdline *cl,
3804 __rte_unused void *data)
3806 struct cmd_set_result *res = parsed_result;
3807 if (!strcmp(res->what, "nbport")) {
3808 set_fwd_ports_number(res->value);
3810 } else if (!strcmp(res->what, "nbcore")) {
3811 set_fwd_lcores_number(res->value);
3813 } else if (!strcmp(res->what, "burst"))
3814 set_nb_pkt_per_burst(res->value);
3815 else if (!strcmp(res->what, "verbose"))
3816 set_verbose_level(res->value);
3819 cmdline_parse_token_string_t cmd_set_set =
3820 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3821 cmdline_parse_token_string_t cmd_set_what =
3822 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3823 "nbport#nbcore#burst#verbose");
3824 cmdline_parse_token_num_t cmd_set_value =
3825 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3827 cmdline_parse_inst_t cmd_set_numbers = {
3828 .f = cmd_set_parsed,
3830 .help_str = "set nbport|nbcore|burst|verbose <value>",
3832 (void *)&cmd_set_set,
3833 (void *)&cmd_set_what,
3834 (void *)&cmd_set_value,
3839 /* *** SET LOG LEVEL CONFIGURATION *** */
3841 struct cmd_set_log_result {
3842 cmdline_fixed_string_t set;
3843 cmdline_fixed_string_t log;
3844 cmdline_fixed_string_t type;
3849 cmd_set_log_parsed(void *parsed_result,
3850 __rte_unused struct cmdline *cl,
3851 __rte_unused void *data)
3853 struct cmd_set_log_result *res;
3856 res = parsed_result;
3857 if (!strcmp(res->type, "global"))
3858 rte_log_set_global_level(res->level);
3860 ret = rte_log_set_level_regexp(res->type, res->level);
3862 fprintf(stderr, "Unable to set log level\n");
3866 cmdline_parse_token_string_t cmd_set_log_set =
3867 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3868 cmdline_parse_token_string_t cmd_set_log_log =
3869 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3870 cmdline_parse_token_string_t cmd_set_log_type =
3871 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3872 cmdline_parse_token_num_t cmd_set_log_level =
3873 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3875 cmdline_parse_inst_t cmd_set_log = {
3876 .f = cmd_set_log_parsed,
3878 .help_str = "set log global|<type> <level>",
3880 (void *)&cmd_set_log_set,
3881 (void *)&cmd_set_log_log,
3882 (void *)&cmd_set_log_type,
3883 (void *)&cmd_set_log_level,
3888 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3890 struct cmd_set_rxoffs_result {
3891 cmdline_fixed_string_t cmd_keyword;
3892 cmdline_fixed_string_t rxoffs;
3893 cmdline_fixed_string_t seg_offsets;
3897 cmd_set_rxoffs_parsed(void *parsed_result,
3898 __rte_unused struct cmdline *cl,
3899 __rte_unused void *data)
3901 struct cmd_set_rxoffs_result *res;
3902 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3903 unsigned int nb_segs;
3905 res = parsed_result;
3906 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3907 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3909 set_rx_pkt_offsets(seg_offsets, nb_segs);
3910 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3913 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3914 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3915 cmd_keyword, "set");
3916 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3917 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3919 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3920 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3923 cmdline_parse_inst_t cmd_set_rxoffs = {
3924 .f = cmd_set_rxoffs_parsed,
3926 .help_str = "set rxoffs <len0[,len1]*>",
3928 (void *)&cmd_set_rxoffs_keyword,
3929 (void *)&cmd_set_rxoffs_name,
3930 (void *)&cmd_set_rxoffs_offsets,
3935 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3937 struct cmd_set_rxpkts_result {
3938 cmdline_fixed_string_t cmd_keyword;
3939 cmdline_fixed_string_t rxpkts;
3940 cmdline_fixed_string_t seg_lengths;
3944 cmd_set_rxpkts_parsed(void *parsed_result,
3945 __rte_unused struct cmdline *cl,
3946 __rte_unused void *data)
3948 struct cmd_set_rxpkts_result *res;
3949 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3950 unsigned int nb_segs;
3952 res = parsed_result;
3953 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3954 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3956 set_rx_pkt_segments(seg_lengths, nb_segs);
3957 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3960 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3961 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3962 cmd_keyword, "set");
3963 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3964 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3966 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3967 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3970 cmdline_parse_inst_t cmd_set_rxpkts = {
3971 .f = cmd_set_rxpkts_parsed,
3973 .help_str = "set rxpkts <len0[,len1]*>",
3975 (void *)&cmd_set_rxpkts_keyword,
3976 (void *)&cmd_set_rxpkts_name,
3977 (void *)&cmd_set_rxpkts_lengths,
3982 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3984 struct cmd_set_txpkts_result {
3985 cmdline_fixed_string_t cmd_keyword;
3986 cmdline_fixed_string_t txpkts;
3987 cmdline_fixed_string_t seg_lengths;
3991 cmd_set_txpkts_parsed(void *parsed_result,
3992 __rte_unused struct cmdline *cl,
3993 __rte_unused void *data)
3995 struct cmd_set_txpkts_result *res;
3996 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3997 unsigned int nb_segs;
3999 res = parsed_result;
4000 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4001 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4003 set_tx_pkt_segments(seg_lengths, nb_segs);
4006 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4007 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4008 cmd_keyword, "set");
4009 cmdline_parse_token_string_t cmd_set_txpkts_name =
4010 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4012 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4013 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4016 cmdline_parse_inst_t cmd_set_txpkts = {
4017 .f = cmd_set_txpkts_parsed,
4019 .help_str = "set txpkts <len0[,len1]*>",
4021 (void *)&cmd_set_txpkts_keyword,
4022 (void *)&cmd_set_txpkts_name,
4023 (void *)&cmd_set_txpkts_lengths,
4028 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4030 struct cmd_set_txsplit_result {
4031 cmdline_fixed_string_t cmd_keyword;
4032 cmdline_fixed_string_t txsplit;
4033 cmdline_fixed_string_t mode;
4037 cmd_set_txsplit_parsed(void *parsed_result,
4038 __rte_unused struct cmdline *cl,
4039 __rte_unused void *data)
4041 struct cmd_set_txsplit_result *res;
4043 res = parsed_result;
4044 set_tx_pkt_split(res->mode);
4047 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4048 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4049 cmd_keyword, "set");
4050 cmdline_parse_token_string_t cmd_set_txsplit_name =
4051 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4052 txsplit, "txsplit");
4053 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4054 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4057 cmdline_parse_inst_t cmd_set_txsplit = {
4058 .f = cmd_set_txsplit_parsed,
4060 .help_str = "set txsplit on|off|rand",
4062 (void *)&cmd_set_txsplit_keyword,
4063 (void *)&cmd_set_txsplit_name,
4064 (void *)&cmd_set_txsplit_mode,
4069 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4071 struct cmd_set_txtimes_result {
4072 cmdline_fixed_string_t cmd_keyword;
4073 cmdline_fixed_string_t txtimes;
4074 cmdline_fixed_string_t tx_times;
4078 cmd_set_txtimes_parsed(void *parsed_result,
4079 __rte_unused struct cmdline *cl,
4080 __rte_unused void *data)
4082 struct cmd_set_txtimes_result *res;
4083 unsigned int tx_times[2] = {0, 0};
4084 unsigned int n_times;
4086 res = parsed_result;
4087 n_times = parse_item_list(res->tx_times, "tx times",
4090 set_tx_pkt_times(tx_times);
4093 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4094 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4095 cmd_keyword, "set");
4096 cmdline_parse_token_string_t cmd_set_txtimes_name =
4097 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4098 txtimes, "txtimes");
4099 cmdline_parse_token_string_t cmd_set_txtimes_value =
4100 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4103 cmdline_parse_inst_t cmd_set_txtimes = {
4104 .f = cmd_set_txtimes_parsed,
4106 .help_str = "set txtimes <inter_burst>,<intra_burst>",
4108 (void *)&cmd_set_txtimes_keyword,
4109 (void *)&cmd_set_txtimes_name,
4110 (void *)&cmd_set_txtimes_value,
4115 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4116 struct cmd_rx_vlan_filter_all_result {
4117 cmdline_fixed_string_t rx_vlan;
4118 cmdline_fixed_string_t what;
4119 cmdline_fixed_string_t all;
4124 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4125 __rte_unused struct cmdline *cl,
4126 __rte_unused void *data)
4128 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4130 if (!strcmp(res->what, "add"))
4131 rx_vlan_all_filter_set(res->port_id, 1);
4133 rx_vlan_all_filter_set(res->port_id, 0);
4136 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4137 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4138 rx_vlan, "rx_vlan");
4139 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4140 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4142 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4143 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4145 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4146 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4147 port_id, RTE_UINT16);
4149 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4150 .f = cmd_rx_vlan_filter_all_parsed,
4152 .help_str = "rx_vlan add|rm all <port_id>: "
4153 "Add/Remove all identifiers to/from the set of VLAN "
4154 "identifiers filtered by a port",
4156 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4157 (void *)&cmd_rx_vlan_filter_all_what,
4158 (void *)&cmd_rx_vlan_filter_all_all,
4159 (void *)&cmd_rx_vlan_filter_all_portid,
4164 /* *** VLAN OFFLOAD SET ON A PORT *** */
4165 struct cmd_vlan_offload_result {
4166 cmdline_fixed_string_t vlan;
4167 cmdline_fixed_string_t set;
4168 cmdline_fixed_string_t vlan_type;
4169 cmdline_fixed_string_t what;
4170 cmdline_fixed_string_t on;
4171 cmdline_fixed_string_t port_id;
4175 cmd_vlan_offload_parsed(void *parsed_result,
4176 __rte_unused struct cmdline *cl,
4177 __rte_unused void *data)
4180 struct cmd_vlan_offload_result *res = parsed_result;
4183 portid_t port_id = 0;
4187 len = strnlen(str, STR_TOKEN_SIZE);
4189 /* Get port_id first */
4197 tmp = strtoul(str, NULL, 0);
4198 /* If port_id greater that what portid_t can represent, return */
4199 if(tmp >= RTE_MAX_ETHPORTS)
4201 port_id = (portid_t)tmp;
4203 if (!strcmp(res->on, "on"))
4208 if (!strcmp(res->what, "strip"))
4209 rx_vlan_strip_set(port_id, on);
4210 else if(!strcmp(res->what, "stripq")){
4211 uint16_t queue_id = 0;
4213 /* No queue_id, return */
4215 fprintf(stderr, "must specify (port,queue_id)\n");
4218 tmp = strtoul(str + i + 1, NULL, 0);
4219 /* If queue_id greater that what 16-bits can represent, return */
4223 queue_id = (uint16_t)tmp;
4224 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4226 else if (!strcmp(res->what, "filter"))
4227 rx_vlan_filter_set(port_id, on);
4228 else if (!strcmp(res->what, "qinq_strip"))
4229 rx_vlan_qinq_strip_set(port_id, on);
4231 vlan_extend_set(port_id, on);
4236 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4237 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4239 cmdline_parse_token_string_t cmd_vlan_offload_set =
4240 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4242 cmdline_parse_token_string_t cmd_vlan_offload_what =
4243 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4244 what, "strip#filter#qinq_strip#extend#stripq");
4245 cmdline_parse_token_string_t cmd_vlan_offload_on =
4246 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4248 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4249 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4252 cmdline_parse_inst_t cmd_vlan_offload = {
4253 .f = cmd_vlan_offload_parsed,
4255 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4256 "<port_id[,queue_id]>: "
4257 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4259 (void *)&cmd_vlan_offload_vlan,
4260 (void *)&cmd_vlan_offload_set,
4261 (void *)&cmd_vlan_offload_what,
4262 (void *)&cmd_vlan_offload_on,
4263 (void *)&cmd_vlan_offload_portid,
4268 /* *** VLAN TPID SET ON A PORT *** */
4269 struct cmd_vlan_tpid_result {
4270 cmdline_fixed_string_t vlan;
4271 cmdline_fixed_string_t set;
4272 cmdline_fixed_string_t vlan_type;
4273 cmdline_fixed_string_t what;
4279 cmd_vlan_tpid_parsed(void *parsed_result,
4280 __rte_unused struct cmdline *cl,
4281 __rte_unused void *data)
4283 struct cmd_vlan_tpid_result *res = parsed_result;
4284 enum rte_vlan_type vlan_type;
4286 if (!strcmp(res->vlan_type, "inner"))
4287 vlan_type = RTE_ETH_VLAN_TYPE_INNER;
4288 else if (!strcmp(res->vlan_type, "outer"))
4289 vlan_type = RTE_ETH_VLAN_TYPE_OUTER;
4291 fprintf(stderr, "Unknown vlan type\n");
4294 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4297 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4298 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4300 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4301 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4303 cmdline_parse_token_string_t cmd_vlan_type =
4304 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4305 vlan_type, "inner#outer");
4306 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4307 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4309 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4310 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4312 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4313 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4314 port_id, RTE_UINT16);
4316 cmdline_parse_inst_t cmd_vlan_tpid = {
4317 .f = cmd_vlan_tpid_parsed,
4319 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4320 "Set the VLAN Ether type",
4322 (void *)&cmd_vlan_tpid_vlan,
4323 (void *)&cmd_vlan_tpid_set,
4324 (void *)&cmd_vlan_type,
4325 (void *)&cmd_vlan_tpid_what,
4326 (void *)&cmd_vlan_tpid_tpid,
4327 (void *)&cmd_vlan_tpid_portid,
4332 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4333 struct cmd_rx_vlan_filter_result {
4334 cmdline_fixed_string_t rx_vlan;
4335 cmdline_fixed_string_t what;
4341 cmd_rx_vlan_filter_parsed(void *parsed_result,
4342 __rte_unused struct cmdline *cl,
4343 __rte_unused void *data)
4345 struct cmd_rx_vlan_filter_result *res = parsed_result;
4347 if (!strcmp(res->what, "add"))
4348 rx_vft_set(res->port_id, res->vlan_id, 1);
4350 rx_vft_set(res->port_id, res->vlan_id, 0);
4353 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4354 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4355 rx_vlan, "rx_vlan");
4356 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4357 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4359 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4360 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4361 vlan_id, RTE_UINT16);
4362 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4363 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4364 port_id, RTE_UINT16);
4366 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4367 .f = cmd_rx_vlan_filter_parsed,
4369 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4370 "Add/Remove a VLAN identifier to/from the set of VLAN "
4371 "identifiers filtered by a port",
4373 (void *)&cmd_rx_vlan_filter_rx_vlan,
4374 (void *)&cmd_rx_vlan_filter_what,
4375 (void *)&cmd_rx_vlan_filter_vlanid,
4376 (void *)&cmd_rx_vlan_filter_portid,
4381 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4382 struct cmd_tx_vlan_set_result {
4383 cmdline_fixed_string_t tx_vlan;
4384 cmdline_fixed_string_t set;
4390 cmd_tx_vlan_set_parsed(void *parsed_result,
4391 __rte_unused struct cmdline *cl,
4392 __rte_unused void *data)
4394 struct cmd_tx_vlan_set_result *res = parsed_result;
4396 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4399 if (!port_is_stopped(res->port_id)) {
4400 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4404 tx_vlan_set(res->port_id, res->vlan_id);
4406 cmd_reconfig_device_queue(res->port_id, 1, 1);
4409 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4410 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4411 tx_vlan, "tx_vlan");
4412 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4413 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4415 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4416 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4417 port_id, RTE_UINT16);
4418 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4419 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4420 vlan_id, RTE_UINT16);
4422 cmdline_parse_inst_t cmd_tx_vlan_set = {
4423 .f = cmd_tx_vlan_set_parsed,
4425 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4426 "Enable hardware insertion of a single VLAN header "
4427 "with a given TAG Identifier in packets sent on a port",
4429 (void *)&cmd_tx_vlan_set_tx_vlan,
4430 (void *)&cmd_tx_vlan_set_set,
4431 (void *)&cmd_tx_vlan_set_portid,
4432 (void *)&cmd_tx_vlan_set_vlanid,
4437 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4438 struct cmd_tx_vlan_set_qinq_result {
4439 cmdline_fixed_string_t tx_vlan;
4440 cmdline_fixed_string_t set;
4443 uint16_t vlan_id_outer;
4447 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4448 __rte_unused struct cmdline *cl,
4449 __rte_unused void *data)
4451 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4453 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4456 if (!port_is_stopped(res->port_id)) {
4457 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4461 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4463 cmd_reconfig_device_queue(res->port_id, 1, 1);
4466 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4467 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4468 tx_vlan, "tx_vlan");
4469 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4470 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4472 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4473 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4474 port_id, RTE_UINT16);
4475 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4476 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4477 vlan_id, RTE_UINT16);
4478 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4479 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4480 vlan_id_outer, RTE_UINT16);
4482 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4483 .f = cmd_tx_vlan_set_qinq_parsed,
4485 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4486 "Enable hardware insertion of double VLAN header "
4487 "with given TAG Identifiers in packets sent on a port",
4489 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4490 (void *)&cmd_tx_vlan_set_qinq_set,
4491 (void *)&cmd_tx_vlan_set_qinq_portid,
4492 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4493 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4498 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4499 struct cmd_tx_vlan_set_pvid_result {
4500 cmdline_fixed_string_t tx_vlan;
4501 cmdline_fixed_string_t set;
4502 cmdline_fixed_string_t pvid;
4505 cmdline_fixed_string_t mode;
4509 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4510 __rte_unused struct cmdline *cl,
4511 __rte_unused void *data)
4513 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4515 if (strcmp(res->mode, "on") == 0)
4516 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4518 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4521 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4522 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4523 tx_vlan, "tx_vlan");
4524 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4525 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4527 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4528 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4530 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4531 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4532 port_id, RTE_UINT16);
4533 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4534 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4535 vlan_id, RTE_UINT16);
4536 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4537 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4540 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4541 .f = cmd_tx_vlan_set_pvid_parsed,
4543 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4545 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4546 (void *)&cmd_tx_vlan_set_pvid_set,
4547 (void *)&cmd_tx_vlan_set_pvid_pvid,
4548 (void *)&cmd_tx_vlan_set_pvid_port_id,
4549 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4550 (void *)&cmd_tx_vlan_set_pvid_mode,
4555 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4556 struct cmd_tx_vlan_reset_result {
4557 cmdline_fixed_string_t tx_vlan;
4558 cmdline_fixed_string_t reset;
4563 cmd_tx_vlan_reset_parsed(void *parsed_result,
4564 __rte_unused struct cmdline *cl,
4565 __rte_unused void *data)
4567 struct cmd_tx_vlan_reset_result *res = parsed_result;
4569 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4572 if (!port_is_stopped(res->port_id)) {
4573 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4577 tx_vlan_reset(res->port_id);
4579 cmd_reconfig_device_queue(res->port_id, 1, 1);
4582 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4583 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4584 tx_vlan, "tx_vlan");
4585 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4586 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4588 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4589 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4590 port_id, RTE_UINT16);
4592 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4593 .f = cmd_tx_vlan_reset_parsed,
4595 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4596 "VLAN header in packets sent on a port",
4598 (void *)&cmd_tx_vlan_reset_tx_vlan,
4599 (void *)&cmd_tx_vlan_reset_reset,
4600 (void *)&cmd_tx_vlan_reset_portid,
4606 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4607 struct cmd_csum_result {
4608 cmdline_fixed_string_t csum;
4609 cmdline_fixed_string_t mode;
4610 cmdline_fixed_string_t proto;
4611 cmdline_fixed_string_t hwsw;
4616 csum_show(int port_id)
4618 struct rte_eth_dev_info dev_info;
4619 uint64_t tx_offloads;
4622 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4623 printf("Parse tunnel is %s\n",
4624 (ports[port_id].parse_tunnel) ? "on" : "off");
4625 printf("IP checksum offload is %s\n",
4626 (tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4627 printf("UDP checksum offload is %s\n",
4628 (tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4629 printf("TCP checksum offload is %s\n",
4630 (tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4631 printf("SCTP checksum offload is %s\n",
4632 (tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4633 printf("Outer-Ip checksum offload is %s\n",
4634 (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4635 printf("Outer-Udp checksum offload is %s\n",
4636 (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4638 /* display warnings if configuration is not supported by the NIC */
4639 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4643 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) &&
4644 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4646 "Warning: hardware IP checksum enabled but not supported by port %d\n",
4649 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) &&
4650 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) == 0) {
4652 "Warning: hardware UDP checksum enabled but not supported by port %d\n",
4655 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) &&
4656 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) == 0) {
4658 "Warning: hardware TCP checksum enabled but not supported by port %d\n",
4661 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) &&
4662 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4664 "Warning: hardware SCTP checksum enabled but not supported by port %d\n",
4667 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4668 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4670 "Warning: hardware outer IP checksum enabled but not supported by port %d\n",
4673 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4674 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)
4677 "Warning: hardware outer UDP checksum enabled but not supported by port %d\n",
4683 cmd_config_queue_tx_offloads(struct rte_port *port)
4687 /* Apply queue tx offloads configuration */
4688 for (k = 0; k < port->dev_info.max_tx_queues; k++)
4689 port->tx_conf[k].offloads =
4690 port->dev_conf.txmode.offloads;
4694 cmd_csum_parsed(void *parsed_result,
4695 __rte_unused struct cmdline *cl,
4696 __rte_unused void *data)
4698 struct cmd_csum_result *res = parsed_result;
4700 uint64_t csum_offloads = 0;
4701 struct rte_eth_dev_info dev_info;
4704 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4705 fprintf(stderr, "invalid port %d\n", res->port_id);
4708 if (!port_is_stopped(res->port_id)) {
4709 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4713 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4717 if (!strcmp(res->mode, "set")) {
4719 if (!strcmp(res->hwsw, "hw"))
4722 if (!strcmp(res->proto, "ip")) {
4723 if (hw == 0 || (dev_info.tx_offload_capa &
4724 RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)) {
4725 csum_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
4728 "IP checksum offload is not supported by port %u\n",
4731 } else if (!strcmp(res->proto, "udp")) {
4732 if (hw == 0 || (dev_info.tx_offload_capa &
4733 RTE_ETH_TX_OFFLOAD_UDP_CKSUM)) {
4734 csum_offloads |= RTE_ETH_TX_OFFLOAD_UDP_CKSUM;
4737 "UDP checksum offload is not supported by port %u\n",
4740 } else if (!strcmp(res->proto, "tcp")) {
4741 if (hw == 0 || (dev_info.tx_offload_capa &
4742 RTE_ETH_TX_OFFLOAD_TCP_CKSUM)) {
4743 csum_offloads |= RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
4746 "TCP checksum offload is not supported by port %u\n",
4749 } else if (!strcmp(res->proto, "sctp")) {
4750 if (hw == 0 || (dev_info.tx_offload_capa &
4751 RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) {
4752 csum_offloads |= RTE_ETH_TX_OFFLOAD_SCTP_CKSUM;
4755 "SCTP checksum offload is not supported by port %u\n",
4758 } else if (!strcmp(res->proto, "outer-ip")) {
4759 if (hw == 0 || (dev_info.tx_offload_capa &
4760 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4762 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4765 "Outer IP checksum offload is not supported by port %u\n",
4768 } else if (!strcmp(res->proto, "outer-udp")) {
4769 if (hw == 0 || (dev_info.tx_offload_capa &
4770 RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4772 RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM;
4775 "Outer UDP checksum offload is not supported by port %u\n",
4781 ports[res->port_id].dev_conf.txmode.offloads |=
4784 ports[res->port_id].dev_conf.txmode.offloads &=
4787 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4789 csum_show(res->port_id);
4791 cmd_reconfig_device_queue(res->port_id, 1, 1);
4794 cmdline_parse_token_string_t cmd_csum_csum =
4795 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4797 cmdline_parse_token_string_t cmd_csum_mode =
4798 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4800 cmdline_parse_token_string_t cmd_csum_proto =
4801 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4802 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4803 cmdline_parse_token_string_t cmd_csum_hwsw =
4804 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4806 cmdline_parse_token_num_t cmd_csum_portid =
4807 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4808 port_id, RTE_UINT16);
4810 cmdline_parse_inst_t cmd_csum_set = {
4811 .f = cmd_csum_parsed,
4813 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4814 "Enable/Disable hardware calculation of L3/L4 checksum when "
4815 "using csum forward engine",
4817 (void *)&cmd_csum_csum,
4818 (void *)&cmd_csum_mode,
4819 (void *)&cmd_csum_proto,
4820 (void *)&cmd_csum_hwsw,
4821 (void *)&cmd_csum_portid,
4826 cmdline_parse_token_string_t cmd_csum_mode_show =
4827 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4830 cmdline_parse_inst_t cmd_csum_show = {
4831 .f = cmd_csum_parsed,
4833 .help_str = "csum show <port_id>: Show checksum offload configuration",
4835 (void *)&cmd_csum_csum,
4836 (void *)&cmd_csum_mode_show,
4837 (void *)&cmd_csum_portid,
4842 /* Enable/disable tunnel parsing */
4843 struct cmd_csum_tunnel_result {
4844 cmdline_fixed_string_t csum;
4845 cmdline_fixed_string_t parse;
4846 cmdline_fixed_string_t onoff;
4851 cmd_csum_tunnel_parsed(void *parsed_result,
4852 __rte_unused struct cmdline *cl,
4853 __rte_unused void *data)
4855 struct cmd_csum_tunnel_result *res = parsed_result;
4857 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4860 if (!strcmp(res->onoff, "on"))
4861 ports[res->port_id].parse_tunnel = 1;
4863 ports[res->port_id].parse_tunnel = 0;
4865 csum_show(res->port_id);
4868 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4869 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4871 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4872 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4873 parse, "parse-tunnel");
4874 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4875 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4877 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4878 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4879 port_id, RTE_UINT16);
4881 cmdline_parse_inst_t cmd_csum_tunnel = {
4882 .f = cmd_csum_tunnel_parsed,
4884 .help_str = "csum parse-tunnel on|off <port_id>: "
4885 "Enable/Disable parsing of tunnels for csum engine",
4887 (void *)&cmd_csum_tunnel_csum,
4888 (void *)&cmd_csum_tunnel_parse,
4889 (void *)&cmd_csum_tunnel_onoff,
4890 (void *)&cmd_csum_tunnel_portid,
4895 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4896 struct cmd_tso_set_result {
4897 cmdline_fixed_string_t tso;
4898 cmdline_fixed_string_t mode;
4904 cmd_tso_set_parsed(void *parsed_result,
4905 __rte_unused struct cmdline *cl,
4906 __rte_unused void *data)
4908 struct cmd_tso_set_result *res = parsed_result;
4909 struct rte_eth_dev_info dev_info;
4912 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4914 if (!port_is_stopped(res->port_id)) {
4915 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4919 if (!strcmp(res->mode, "set"))
4920 ports[res->port_id].tso_segsz = res->tso_segsz;
4922 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4926 if ((ports[res->port_id].tso_segsz != 0) &&
4927 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) {
4928 fprintf(stderr, "Error: TSO is not supported by port %d\n",
4933 if (ports[res->port_id].tso_segsz == 0) {
4934 ports[res->port_id].dev_conf.txmode.offloads &=
4935 ~RTE_ETH_TX_OFFLOAD_TCP_TSO;
4936 printf("TSO for non-tunneled packets is disabled\n");
4938 ports[res->port_id].dev_conf.txmode.offloads |=
4939 RTE_ETH_TX_OFFLOAD_TCP_TSO;
4940 printf("TSO segment size for non-tunneled packets is %d\n",
4941 ports[res->port_id].tso_segsz);
4943 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4945 /* display warnings if configuration is not supported by the NIC */
4946 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4950 if ((ports[res->port_id].tso_segsz != 0) &&
4951 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) {
4953 "Warning: TSO enabled but not supported by port %d\n",
4957 cmd_reconfig_device_queue(res->port_id, 1, 1);
4960 cmdline_parse_token_string_t cmd_tso_set_tso =
4961 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4963 cmdline_parse_token_string_t cmd_tso_set_mode =
4964 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4966 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4967 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4968 tso_segsz, RTE_UINT16);
4969 cmdline_parse_token_num_t cmd_tso_set_portid =
4970 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4971 port_id, RTE_UINT16);
4973 cmdline_parse_inst_t cmd_tso_set = {
4974 .f = cmd_tso_set_parsed,
4976 .help_str = "tso set <tso_segsz> <port_id>: "
4977 "Set TSO segment size of non-tunneled packets for csum engine "
4980 (void *)&cmd_tso_set_tso,
4981 (void *)&cmd_tso_set_mode,
4982 (void *)&cmd_tso_set_tso_segsz,
4983 (void *)&cmd_tso_set_portid,
4988 cmdline_parse_token_string_t cmd_tso_show_mode =
4989 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4993 cmdline_parse_inst_t cmd_tso_show = {
4994 .f = cmd_tso_set_parsed,
4996 .help_str = "tso show <port_id>: "
4997 "Show TSO segment size of non-tunneled packets for csum engine",
4999 (void *)&cmd_tso_set_tso,
5000 (void *)&cmd_tso_show_mode,
5001 (void *)&cmd_tso_set_portid,
5006 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5007 struct cmd_tunnel_tso_set_result {
5008 cmdline_fixed_string_t tso;
5009 cmdline_fixed_string_t mode;
5014 static struct rte_eth_dev_info
5015 check_tunnel_tso_nic_support(portid_t port_id)
5017 struct rte_eth_dev_info dev_info;
5019 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
5022 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO))
5024 "Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n",
5026 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO))
5028 "Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n",
5030 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO))
5032 "Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n",
5034 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO))
5036 "Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n",
5038 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IP_TNL_TSO))
5040 "Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n",
5042 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO))
5044 "Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n",
5050 cmd_tunnel_tso_set_parsed(void *parsed_result,
5051 __rte_unused struct cmdline *cl,
5052 __rte_unused void *data)
5054 struct cmd_tunnel_tso_set_result *res = parsed_result;
5055 struct rte_eth_dev_info dev_info;
5057 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5059 if (!port_is_stopped(res->port_id)) {
5060 fprintf(stderr, "Please stop port %d first\n", res->port_id);
5064 if (!strcmp(res->mode, "set"))
5065 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5067 dev_info = check_tunnel_tso_nic_support(res->port_id);
5068 if (ports[res->port_id].tunnel_tso_segsz == 0) {
5069 ports[res->port_id].dev_conf.txmode.offloads &=
5070 ~(RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5071 RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5072 RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5073 RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5074 RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5075 RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO);
5076 printf("TSO for tunneled packets is disabled\n");
5078 uint64_t tso_offloads = (RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5079 RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5080 RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5081 RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5082 RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5083 RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO);
5085 ports[res->port_id].dev_conf.txmode.offloads |=
5086 (tso_offloads & dev_info.tx_offload_capa);
5087 printf("TSO segment size for tunneled packets is %d\n",
5088 ports[res->port_id].tunnel_tso_segsz);
5090 /* Below conditions are needed to make it work:
5091 * (1) tunnel TSO is supported by the NIC;
5092 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5094 * (3) for tunneled pkts with outer L3 of IPv4,
5095 * "csum set outer-ip" must be set to hw, because after tso,
5096 * total_len of outer IP header is changed, and the checksum
5097 * of outer IP header calculated by sw should be wrong; that
5098 * is not necessary for IPv6 tunneled pkts because there's no
5099 * checksum in IP header anymore.
5102 if (!ports[res->port_id].parse_tunnel)
5104 "Warning: csum parse_tunnel must be set so that tunneled packets are recognized\n");
5105 if (!(ports[res->port_id].dev_conf.txmode.offloads &
5106 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5108 "Warning: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n");
5111 cmd_config_queue_tx_offloads(&ports[res->port_id]);
5112 cmd_reconfig_device_queue(res->port_id, 1, 1);
5115 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5116 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5118 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5119 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5121 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5122 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5123 tso_segsz, RTE_UINT16);
5124 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5125 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5126 port_id, RTE_UINT16);
5128 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5129 .f = cmd_tunnel_tso_set_parsed,
5131 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5132 "Set TSO segment size of tunneled packets for csum engine "
5135 (void *)&cmd_tunnel_tso_set_tso,
5136 (void *)&cmd_tunnel_tso_set_mode,
5137 (void *)&cmd_tunnel_tso_set_tso_segsz,
5138 (void *)&cmd_tunnel_tso_set_portid,
5143 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5144 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5148 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5149 .f = cmd_tunnel_tso_set_parsed,
5151 .help_str = "tunnel_tso show <port_id> "
5152 "Show TSO segment size of tunneled packets for csum engine",
5154 (void *)&cmd_tunnel_tso_set_tso,
5155 (void *)&cmd_tunnel_tso_show_mode,
5156 (void *)&cmd_tunnel_tso_set_portid,
5162 /* *** SET GRO FOR A PORT *** */
5163 struct cmd_gro_enable_result {
5164 cmdline_fixed_string_t cmd_set;
5165 cmdline_fixed_string_t cmd_port;
5166 cmdline_fixed_string_t cmd_keyword;
5167 cmdline_fixed_string_t cmd_onoff;
5172 cmd_gro_enable_parsed(void *parsed_result,
5173 __rte_unused struct cmdline *cl,
5174 __rte_unused void *data)
5176 struct cmd_gro_enable_result *res;
5178 res = parsed_result;
5179 if (!strcmp(res->cmd_keyword, "gro"))
5180 setup_gro(res->cmd_onoff, res->cmd_pid);
5183 cmdline_parse_token_string_t cmd_gro_enable_set =
5184 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5186 cmdline_parse_token_string_t cmd_gro_enable_port =
5187 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5188 cmd_keyword, "port");
5189 cmdline_parse_token_num_t cmd_gro_enable_pid =
5190 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5191 cmd_pid, RTE_UINT16);
5192 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5193 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5194 cmd_keyword, "gro");
5195 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5196 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5197 cmd_onoff, "on#off");
5199 cmdline_parse_inst_t cmd_gro_enable = {
5200 .f = cmd_gro_enable_parsed,
5202 .help_str = "set port <port_id> gro on|off",
5204 (void *)&cmd_gro_enable_set,
5205 (void *)&cmd_gro_enable_port,
5206 (void *)&cmd_gro_enable_pid,
5207 (void *)&cmd_gro_enable_keyword,
5208 (void *)&cmd_gro_enable_onoff,
5213 /* *** DISPLAY GRO CONFIGURATION *** */
5214 struct cmd_gro_show_result {
5215 cmdline_fixed_string_t cmd_show;
5216 cmdline_fixed_string_t cmd_port;
5217 cmdline_fixed_string_t cmd_keyword;
5222 cmd_gro_show_parsed(void *parsed_result,
5223 __rte_unused struct cmdline *cl,
5224 __rte_unused void *data)
5226 struct cmd_gro_show_result *res;
5228 res = parsed_result;
5229 if (!strcmp(res->cmd_keyword, "gro"))
5230 show_gro(res->cmd_pid);
5233 cmdline_parse_token_string_t cmd_gro_show_show =
5234 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5236 cmdline_parse_token_string_t cmd_gro_show_port =
5237 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5239 cmdline_parse_token_num_t cmd_gro_show_pid =
5240 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5241 cmd_pid, RTE_UINT16);
5242 cmdline_parse_token_string_t cmd_gro_show_keyword =
5243 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5244 cmd_keyword, "gro");
5246 cmdline_parse_inst_t cmd_gro_show = {
5247 .f = cmd_gro_show_parsed,
5249 .help_str = "show port <port_id> gro",
5251 (void *)&cmd_gro_show_show,
5252 (void *)&cmd_gro_show_port,
5253 (void *)&cmd_gro_show_pid,
5254 (void *)&cmd_gro_show_keyword,
5259 /* *** SET FLUSH CYCLES FOR GRO *** */
5260 struct cmd_gro_flush_result {
5261 cmdline_fixed_string_t cmd_set;
5262 cmdline_fixed_string_t cmd_keyword;
5263 cmdline_fixed_string_t cmd_flush;
5268 cmd_gro_flush_parsed(void *parsed_result,
5269 __rte_unused struct cmdline *cl,
5270 __rte_unused void *data)
5272 struct cmd_gro_flush_result *res;
5274 res = parsed_result;
5275 if ((!strcmp(res->cmd_keyword, "gro")) &&
5276 (!strcmp(res->cmd_flush, "flush")))
5277 setup_gro_flush_cycles(res->cmd_cycles);
5280 cmdline_parse_token_string_t cmd_gro_flush_set =
5281 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5283 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5284 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5285 cmd_keyword, "gro");
5286 cmdline_parse_token_string_t cmd_gro_flush_flush =
5287 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5288 cmd_flush, "flush");
5289 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5290 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5291 cmd_cycles, RTE_UINT8);
5293 cmdline_parse_inst_t cmd_gro_flush = {
5294 .f = cmd_gro_flush_parsed,
5296 .help_str = "set gro flush <cycles>",
5298 (void *)&cmd_gro_flush_set,
5299 (void *)&cmd_gro_flush_keyword,
5300 (void *)&cmd_gro_flush_flush,
5301 (void *)&cmd_gro_flush_cycles,
5305 #endif /* RTE_LIB_GRO */
5308 /* *** ENABLE/DISABLE GSO *** */
5309 struct cmd_gso_enable_result {
5310 cmdline_fixed_string_t cmd_set;
5311 cmdline_fixed_string_t cmd_port;
5312 cmdline_fixed_string_t cmd_keyword;
5313 cmdline_fixed_string_t cmd_mode;
5318 cmd_gso_enable_parsed(void *parsed_result,
5319 __rte_unused struct cmdline *cl,
5320 __rte_unused void *data)
5322 struct cmd_gso_enable_result *res;
5324 res = parsed_result;
5325 if (!strcmp(res->cmd_keyword, "gso"))
5326 setup_gso(res->cmd_mode, res->cmd_pid);
5329 cmdline_parse_token_string_t cmd_gso_enable_set =
5330 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5332 cmdline_parse_token_string_t cmd_gso_enable_port =
5333 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5335 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5336 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5337 cmd_keyword, "gso");
5338 cmdline_parse_token_string_t cmd_gso_enable_mode =
5339 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5340 cmd_mode, "on#off");
5341 cmdline_parse_token_num_t cmd_gso_enable_pid =
5342 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5343 cmd_pid, RTE_UINT16);
5345 cmdline_parse_inst_t cmd_gso_enable = {
5346 .f = cmd_gso_enable_parsed,
5348 .help_str = "set port <port_id> gso on|off",
5350 (void *)&cmd_gso_enable_set,
5351 (void *)&cmd_gso_enable_port,
5352 (void *)&cmd_gso_enable_pid,
5353 (void *)&cmd_gso_enable_keyword,
5354 (void *)&cmd_gso_enable_mode,
5359 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5360 struct cmd_gso_size_result {
5361 cmdline_fixed_string_t cmd_set;
5362 cmdline_fixed_string_t cmd_keyword;
5363 cmdline_fixed_string_t cmd_segsz;
5368 cmd_gso_size_parsed(void *parsed_result,
5369 __rte_unused struct cmdline *cl,
5370 __rte_unused void *data)
5372 struct cmd_gso_size_result *res = parsed_result;
5374 if (test_done == 0) {
5376 "Before setting GSO segsz, please first stop forwarding\n");
5380 if (!strcmp(res->cmd_keyword, "gso") &&
5381 !strcmp(res->cmd_segsz, "segsz")) {
5382 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5384 "gso_size should be larger than %zu. Please input a legal value\n",
5385 RTE_GSO_SEG_SIZE_MIN);
5387 gso_max_segment_size = res->cmd_size;
5391 cmdline_parse_token_string_t cmd_gso_size_set =
5392 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5394 cmdline_parse_token_string_t cmd_gso_size_keyword =
5395 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5396 cmd_keyword, "gso");
5397 cmdline_parse_token_string_t cmd_gso_size_segsz =
5398 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5399 cmd_segsz, "segsz");
5400 cmdline_parse_token_num_t cmd_gso_size_size =
5401 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5402 cmd_size, RTE_UINT16);
5404 cmdline_parse_inst_t cmd_gso_size = {
5405 .f = cmd_gso_size_parsed,
5407 .help_str = "set gso segsz <length>",
5409 (void *)&cmd_gso_size_set,
5410 (void *)&cmd_gso_size_keyword,
5411 (void *)&cmd_gso_size_segsz,
5412 (void *)&cmd_gso_size_size,
5417 /* *** SHOW GSO CONFIGURATION *** */
5418 struct cmd_gso_show_result {
5419 cmdline_fixed_string_t cmd_show;
5420 cmdline_fixed_string_t cmd_port;
5421 cmdline_fixed_string_t cmd_keyword;
5426 cmd_gso_show_parsed(void *parsed_result,
5427 __rte_unused struct cmdline *cl,
5428 __rte_unused void *data)
5430 struct cmd_gso_show_result *res = parsed_result;
5432 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5433 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
5436 if (!strcmp(res->cmd_keyword, "gso")) {
5437 if (gso_ports[res->cmd_pid].enable) {
5438 printf("Max GSO'd packet size: %uB\n"
5439 "Supported GSO types: TCP/IPv4, "
5440 "UDP/IPv4, VxLAN with inner "
5441 "TCP/IPv4 packet, GRE with inner "
5442 "TCP/IPv4 packet\n",
5443 gso_max_segment_size);
5445 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5449 cmdline_parse_token_string_t cmd_gso_show_show =
5450 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5452 cmdline_parse_token_string_t cmd_gso_show_port =
5453 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5455 cmdline_parse_token_string_t cmd_gso_show_keyword =
5456 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5457 cmd_keyword, "gso");
5458 cmdline_parse_token_num_t cmd_gso_show_pid =
5459 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5460 cmd_pid, RTE_UINT16);
5462 cmdline_parse_inst_t cmd_gso_show = {
5463 .f = cmd_gso_show_parsed,
5465 .help_str = "show port <port_id> gso",
5467 (void *)&cmd_gso_show_show,
5468 (void *)&cmd_gso_show_port,
5469 (void *)&cmd_gso_show_pid,
5470 (void *)&cmd_gso_show_keyword,
5474 #endif /* RTE_LIB_GSO */
5476 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5477 struct cmd_set_flush_rx {
5478 cmdline_fixed_string_t set;
5479 cmdline_fixed_string_t flush_rx;
5480 cmdline_fixed_string_t mode;
5484 cmd_set_flush_rx_parsed(void *parsed_result,
5485 __rte_unused struct cmdline *cl,
5486 __rte_unused void *data)
5488 struct cmd_set_flush_rx *res = parsed_result;
5490 if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) {
5491 printf("multi-process doesn't support to flush Rx queues.\n");
5495 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5498 cmdline_parse_token_string_t cmd_setflushrx_set =
5499 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5501 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5502 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5503 flush_rx, "flush_rx");
5504 cmdline_parse_token_string_t cmd_setflushrx_mode =
5505 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5509 cmdline_parse_inst_t cmd_set_flush_rx = {
5510 .f = cmd_set_flush_rx_parsed,
5511 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5514 (void *)&cmd_setflushrx_set,
5515 (void *)&cmd_setflushrx_flush_rx,
5516 (void *)&cmd_setflushrx_mode,
5521 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5522 struct cmd_set_link_check {
5523 cmdline_fixed_string_t set;
5524 cmdline_fixed_string_t link_check;
5525 cmdline_fixed_string_t mode;
5529 cmd_set_link_check_parsed(void *parsed_result,
5530 __rte_unused struct cmdline *cl,
5531 __rte_unused void *data)
5533 struct cmd_set_link_check *res = parsed_result;
5534 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5537 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5538 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5540 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5541 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5542 link_check, "link_check");
5543 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5544 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5548 cmdline_parse_inst_t cmd_set_link_check = {
5549 .f = cmd_set_link_check_parsed,
5550 .help_str = "set link_check on|off: Enable/Disable link status check "
5551 "when starting/stopping a port",
5554 (void *)&cmd_setlinkcheck_set,
5555 (void *)&cmd_setlinkcheck_link_check,
5556 (void *)&cmd_setlinkcheck_mode,
5561 /* *** SET NIC BYPASS MODE *** */
5562 struct cmd_set_bypass_mode_result {
5563 cmdline_fixed_string_t set;
5564 cmdline_fixed_string_t bypass;
5565 cmdline_fixed_string_t mode;
5566 cmdline_fixed_string_t value;
5571 cmd_set_bypass_mode_parsed(void *parsed_result,
5572 __rte_unused struct cmdline *cl,
5573 __rte_unused void *data)
5575 struct cmd_set_bypass_mode_result *res = parsed_result;
5576 portid_t port_id = res->port_id;
5577 int32_t rc = -EINVAL;
5579 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5580 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5582 if (!strcmp(res->value, "bypass"))
5583 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5584 else if (!strcmp(res->value, "isolate"))
5585 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5587 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5589 /* Set the bypass mode for the relevant port. */
5590 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5593 fprintf(stderr, "\t Failed to set bypass mode for port = %d.\n",
5597 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5598 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5600 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5601 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5603 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5604 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5606 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5607 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5608 value, "normal#bypass#isolate");
5609 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5610 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5611 port_id, RTE_UINT16);
5613 cmdline_parse_inst_t cmd_set_bypass_mode = {
5614 .f = cmd_set_bypass_mode_parsed,
5615 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5616 "Set the NIC bypass mode for port_id",
5619 (void *)&cmd_setbypass_mode_set,
5620 (void *)&cmd_setbypass_mode_bypass,
5621 (void *)&cmd_setbypass_mode_mode,
5622 (void *)&cmd_setbypass_mode_value,
5623 (void *)&cmd_setbypass_mode_port,
5628 /* *** SET NIC BYPASS EVENT *** */
5629 struct cmd_set_bypass_event_result {
5630 cmdline_fixed_string_t set;
5631 cmdline_fixed_string_t bypass;
5632 cmdline_fixed_string_t event;
5633 cmdline_fixed_string_t event_value;
5634 cmdline_fixed_string_t mode;
5635 cmdline_fixed_string_t mode_value;
5640 cmd_set_bypass_event_parsed(void *parsed_result,
5641 __rte_unused struct cmdline *cl,
5642 __rte_unused void *data)
5644 int32_t rc = -EINVAL;
5645 struct cmd_set_bypass_event_result *res = parsed_result;
5646 portid_t port_id = res->port_id;
5648 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5649 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5650 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5652 if (!strcmp(res->event_value, "timeout"))
5653 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5654 else if (!strcmp(res->event_value, "os_on"))
5655 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5656 else if (!strcmp(res->event_value, "os_off"))
5657 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5658 else if (!strcmp(res->event_value, "power_on"))
5659 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5660 else if (!strcmp(res->event_value, "power_off"))
5661 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5663 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5665 if (!strcmp(res->mode_value, "bypass"))
5666 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5667 else if (!strcmp(res->mode_value, "isolate"))
5668 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5670 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5672 /* Set the watchdog timeout. */
5673 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5676 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5677 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5682 "Failed to set timeout value %u for port %d, errto code: %d.\n",
5683 bypass_timeout, port_id, rc);
5687 /* Set the bypass event to transition to bypass mode. */
5688 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5693 fprintf(stderr, "\t Failed to set bypass event for port = %d.\n",
5697 cmdline_parse_token_string_t cmd_setbypass_event_set =
5698 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5700 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5701 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5703 cmdline_parse_token_string_t cmd_setbypass_event_event =
5704 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5706 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5707 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5708 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5709 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5710 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5712 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5713 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5714 mode_value, "normal#bypass#isolate");
5715 cmdline_parse_token_num_t cmd_setbypass_event_port =
5716 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5717 port_id, RTE_UINT16);
5719 cmdline_parse_inst_t cmd_set_bypass_event = {
5720 .f = cmd_set_bypass_event_parsed,
5721 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5722 "power_off mode normal|bypass|isolate <port_id>: "
5723 "Set the NIC bypass event mode for port_id",
5726 (void *)&cmd_setbypass_event_set,
5727 (void *)&cmd_setbypass_event_bypass,
5728 (void *)&cmd_setbypass_event_event,
5729 (void *)&cmd_setbypass_event_event_value,
5730 (void *)&cmd_setbypass_event_mode,
5731 (void *)&cmd_setbypass_event_mode_value,
5732 (void *)&cmd_setbypass_event_port,
5738 /* *** SET NIC BYPASS TIMEOUT *** */
5739 struct cmd_set_bypass_timeout_result {
5740 cmdline_fixed_string_t set;
5741 cmdline_fixed_string_t bypass;
5742 cmdline_fixed_string_t timeout;
5743 cmdline_fixed_string_t value;
5747 cmd_set_bypass_timeout_parsed(void *parsed_result,
5748 __rte_unused struct cmdline *cl,
5749 __rte_unused void *data)
5751 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5753 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5754 if (!strcmp(res->value, "1.5"))
5755 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5756 else if (!strcmp(res->value, "2"))
5757 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5758 else if (!strcmp(res->value, "3"))
5759 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5760 else if (!strcmp(res->value, "4"))
5761 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5762 else if (!strcmp(res->value, "8"))
5763 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5764 else if (!strcmp(res->value, "16"))
5765 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5766 else if (!strcmp(res->value, "32"))
5767 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5769 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5773 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5774 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5776 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5777 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5779 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5780 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5781 timeout, "timeout");
5782 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5783 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5784 value, "0#1.5#2#3#4#8#16#32");
5786 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5787 .f = cmd_set_bypass_timeout_parsed,
5788 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5789 "Set the NIC bypass watchdog timeout in seconds",
5792 (void *)&cmd_setbypass_timeout_set,
5793 (void *)&cmd_setbypass_timeout_bypass,
5794 (void *)&cmd_setbypass_timeout_timeout,
5795 (void *)&cmd_setbypass_timeout_value,
5800 /* *** SHOW NIC BYPASS MODE *** */
5801 struct cmd_show_bypass_config_result {
5802 cmdline_fixed_string_t show;
5803 cmdline_fixed_string_t bypass;
5804 cmdline_fixed_string_t config;
5809 cmd_show_bypass_config_parsed(void *parsed_result,
5810 __rte_unused struct cmdline *cl,
5811 __rte_unused void *data)
5813 struct cmd_show_bypass_config_result *res = parsed_result;
5814 portid_t port_id = res->port_id;
5816 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5817 uint32_t event_mode;
5818 uint32_t bypass_mode;
5819 uint32_t timeout = bypass_timeout;
5822 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5823 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5824 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5825 {"UNKNOWN", "normal", "bypass", "isolate"};
5826 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5834 /* Display the bypass mode.*/
5835 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5836 fprintf(stderr, "\tFailed to get bypass mode for port = %d\n",
5841 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5842 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5844 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5847 /* Display the bypass timeout.*/
5848 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5849 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5851 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5853 /* Display the bypass events and associated modes. */
5854 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5856 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5858 "\tFailed to get bypass mode for event = %s\n",
5861 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5862 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5864 printf("\tbypass event: %-16s = %s\n", events[i],
5871 "\tFailed to get bypass configuration for port = %d\n",
5875 cmdline_parse_token_string_t cmd_showbypass_config_show =
5876 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5878 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5879 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5881 cmdline_parse_token_string_t cmd_showbypass_config_config =
5882 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5884 cmdline_parse_token_num_t cmd_showbypass_config_port =
5885 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5886 port_id, RTE_UINT16);
5888 cmdline_parse_inst_t cmd_show_bypass_config = {
5889 .f = cmd_show_bypass_config_parsed,
5890 .help_str = "show bypass config <port_id>: "
5891 "Show the NIC bypass config for port_id",
5894 (void *)&cmd_showbypass_config_show,
5895 (void *)&cmd_showbypass_config_bypass,
5896 (void *)&cmd_showbypass_config_config,
5897 (void *)&cmd_showbypass_config_port,
5903 /* *** SET BONDING MODE *** */
5904 struct cmd_set_bonding_mode_result {
5905 cmdline_fixed_string_t set;
5906 cmdline_fixed_string_t bonding;
5907 cmdline_fixed_string_t mode;
5912 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5913 __rte_unused struct cmdline *cl,
5914 __rte_unused void *data)
5916 struct cmd_set_bonding_mode_result *res = parsed_result;
5917 portid_t port_id = res->port_id;
5918 struct rte_port *port = &ports[port_id];
5921 * Bonding mode changed means resources of device changed, like whether
5922 * started rte timer or not. Device should be restarted when resources
5923 * of device changed.
5925 if (port->port_status != RTE_PORT_STOPPED) {
5927 "\t Error: Can't set bonding mode when port %d is not stopped\n",
5932 /* Set the bonding mode for the relevant port. */
5933 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5934 fprintf(stderr, "\t Failed to set bonding mode for port = %d.\n",
5938 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5939 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5941 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5942 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5943 bonding, "bonding");
5944 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5945 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5947 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5948 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5950 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5951 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5952 port_id, RTE_UINT16);
5954 cmdline_parse_inst_t cmd_set_bonding_mode = {
5955 .f = cmd_set_bonding_mode_parsed,
5956 .help_str = "set bonding mode <mode_value> <port_id>: "
5957 "Set the bonding mode for port_id",
5960 (void *) &cmd_setbonding_mode_set,
5961 (void *) &cmd_setbonding_mode_bonding,
5962 (void *) &cmd_setbonding_mode_mode,
5963 (void *) &cmd_setbonding_mode_value,
5964 (void *) &cmd_setbonding_mode_port,
5969 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5970 struct cmd_set_bonding_lacp_dedicated_queues_result {
5971 cmdline_fixed_string_t set;
5972 cmdline_fixed_string_t bonding;
5973 cmdline_fixed_string_t lacp;
5974 cmdline_fixed_string_t dedicated_queues;
5976 cmdline_fixed_string_t mode;
5979 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5980 __rte_unused struct cmdline *cl,
5981 __rte_unused void *data)
5983 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5984 portid_t port_id = res->port_id;
5985 struct rte_port *port;
5987 port = &ports[port_id];
5989 /** Check if the port is not started **/
5990 if (port->port_status != RTE_PORT_STOPPED) {
5991 fprintf(stderr, "Please stop port %d first\n", port_id);
5995 if (!strcmp(res->mode, "enable")) {
5996 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5997 printf("Dedicate queues for LACP control packets"
6000 printf("Enabling dedicate queues for LACP control "
6001 "packets on port %d failed\n", port_id);
6002 } else if (!strcmp(res->mode, "disable")) {
6003 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
6004 printf("Dedicated queues for LACP control packets "
6007 printf("Disabling dedicated queues for LACP control "
6008 "traffic on port %d failed\n", port_id);
6012 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
6013 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6015 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
6016 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6017 bonding, "bonding");
6018 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
6019 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6021 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
6022 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6023 dedicated_queues, "dedicated_queues");
6024 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
6025 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6026 port_id, RTE_UINT16);
6027 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
6028 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6029 mode, "enable#disable");
6031 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
6032 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
6033 .help_str = "set bonding lacp dedicated_queues <port_id> "
6035 "Enable/disable dedicated queues for LACP control traffic for port_id",
6038 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
6039 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
6040 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
6041 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
6042 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
6043 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
6048 /* *** SET BALANCE XMIT POLICY *** */
6049 struct cmd_set_bonding_balance_xmit_policy_result {
6050 cmdline_fixed_string_t set;
6051 cmdline_fixed_string_t bonding;
6052 cmdline_fixed_string_t balance_xmit_policy;
6054 cmdline_fixed_string_t policy;
6057 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
6058 __rte_unused struct cmdline *cl,
6059 __rte_unused void *data)
6061 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6062 portid_t port_id = res->port_id;
6065 if (!strcmp(res->policy, "l2")) {
6066 policy = BALANCE_XMIT_POLICY_LAYER2;
6067 } else if (!strcmp(res->policy, "l23")) {
6068 policy = BALANCE_XMIT_POLICY_LAYER23;
6069 } else if (!strcmp(res->policy, "l34")) {
6070 policy = BALANCE_XMIT_POLICY_LAYER34;
6072 fprintf(stderr, "\t Invalid xmit policy selection");
6076 /* Set the bonding mode for the relevant port. */
6077 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6079 "\t Failed to set bonding balance xmit policy for port = %d.\n",
6084 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6085 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6087 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6088 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6089 bonding, "bonding");
6090 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6091 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6092 balance_xmit_policy, "balance_xmit_policy");
6093 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6094 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6095 port_id, RTE_UINT16);
6096 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6097 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6098 policy, "l2#l23#l34");
6100 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6101 .f = cmd_set_bonding_balance_xmit_policy_parsed,
6102 .help_str = "set bonding balance_xmit_policy <port_id> "
6104 "Set the bonding balance_xmit_policy for port_id",
6107 (void *)&cmd_setbonding_balance_xmit_policy_set,
6108 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
6109 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6110 (void *)&cmd_setbonding_balance_xmit_policy_port,
6111 (void *)&cmd_setbonding_balance_xmit_policy_policy,
6116 /* *** SHOW IEEE802.3 BONDING INFORMATION *** */
6117 struct cmd_show_bonding_lacp_info_result {
6118 cmdline_fixed_string_t show;
6119 cmdline_fixed_string_t bonding;
6120 cmdline_fixed_string_t lacp;
6121 cmdline_fixed_string_t info;
6125 static void port_param_show(struct port_params *params)
6127 char buf[RTE_ETHER_ADDR_FMT_SIZE];
6129 printf("\t\tsystem priority: %u\n", params->system_priority);
6130 rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, ¶ms->system);
6131 printf("\t\tsystem mac address: %s\n", buf);
6132 printf("\t\tport key: %u\n", params->key);
6133 printf("\t\tport priority: %u\n", params->port_priority);
6134 printf("\t\tport number: %u\n", params->port_number);
6137 static void lacp_slave_info_show(struct rte_eth_bond_8023ad_slave_info *info)
6139 char a_state[256] = { 0 };
6140 char p_state[256] = { 0 };
6145 static const char * const state[] = {
6155 static const char * const selection[] = {
6161 for (i = 0; i < RTE_DIM(state); i++) {
6162 if ((info->actor_state >> i) & 1)
6163 a_len += snprintf(&a_state[a_len],
6164 RTE_DIM(a_state) - a_len, "%s ",
6167 if ((info->partner_state >> i) & 1)
6168 p_len += snprintf(&p_state[p_len],
6169 RTE_DIM(p_state) - p_len, "%s ",
6172 printf("\tAggregator port id: %u\n", info->agg_port_id);
6173 printf("\tselection: %s\n", selection[info->selected]);
6174 printf("\tActor detail info:\n");
6175 port_param_show(&info->actor);
6176 printf("\t\tport state: %s\n", a_state);
6177 printf("\tPartner detail info:\n");
6178 port_param_show(&info->partner);
6179 printf("\t\tport state: %s\n", p_state);
6183 static void lacp_conf_show(struct rte_eth_bond_8023ad_conf *conf)
6185 printf("\tfast period: %u ms\n", conf->fast_periodic_ms);
6186 printf("\tslow period: %u ms\n", conf->slow_periodic_ms);
6187 printf("\tshort timeout: %u ms\n", conf->short_timeout_ms);
6188 printf("\tlong timeout: %u ms\n", conf->long_timeout_ms);
6189 printf("\taggregate wait timeout: %u ms\n",
6190 conf->aggregate_wait_timeout_ms);
6191 printf("\ttx period: %u ms\n", conf->tx_period_ms);
6192 printf("\trx marker period: %u ms\n", conf->rx_marker_period_ms);
6193 printf("\tupdate timeout: %u ms\n", conf->update_timeout_ms);
6194 switch (conf->agg_selection) {
6196 printf("\taggregation mode: bandwidth\n");
6199 printf("\taggregation mode: stable\n");
6202 printf("\taggregation mode: count\n");
6205 printf("\taggregation mode: invalid\n");
6212 static void cmd_show_bonding_lacp_info_parsed(void *parsed_result,
6213 __rte_unused struct cmdline *cl,
6214 __rte_unused void *data)
6216 struct cmd_show_bonding_lacp_info_result *res = parsed_result;
6217 struct rte_eth_bond_8023ad_slave_info slave_info;
6218 struct rte_eth_bond_8023ad_conf port_conf;
6219 portid_t slaves[RTE_MAX_ETHPORTS];
6220 portid_t port_id = res->port_id;
6221 int num_active_slaves;
6226 bonding_mode = rte_eth_bond_mode_get(port_id);
6227 if (bonding_mode != BONDING_MODE_8023AD) {
6228 fprintf(stderr, "\tBonding mode is not mode 4\n");
6232 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6234 if (num_active_slaves < 0) {
6235 fprintf(stderr, "\tFailed to get active slave list for port = %u\n",
6239 if (num_active_slaves == 0)
6240 fprintf(stderr, "\tIEEE802.3 port %u has no active slave\n",
6243 printf("\tIEEE802.3 port: %u\n", port_id);
6244 ret = rte_eth_bond_8023ad_conf_get(port_id, &port_conf);
6246 fprintf(stderr, "\tGet bonded device %u info failed\n",
6250 lacp_conf_show(&port_conf);
6252 for (i = 0; i < num_active_slaves; i++) {
6253 ret = rte_eth_bond_8023ad_slave_info(port_id, slaves[i],
6256 fprintf(stderr, "\tGet slave device %u info failed\n",
6260 printf("\tSlave Port: %u\n", slaves[i]);
6261 lacp_slave_info_show(&slave_info);
6265 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_show =
6266 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6268 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_bonding =
6269 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6270 bonding, "bonding");
6271 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_lacp =
6272 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6274 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_info =
6275 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6277 cmdline_parse_token_num_t cmd_show_bonding_lacp_info_port_id =
6278 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6279 port_id, RTE_UINT16);
6281 cmdline_parse_inst_t cmd_show_bonding_lacp_info = {
6282 .f = cmd_show_bonding_lacp_info_parsed,
6283 .help_str = "show bonding lacp info <port_id> : "
6284 "Show bonding IEEE802.3 information for port_id",
6287 (void *)&cmd_show_bonding_lacp_info_show,
6288 (void *)&cmd_show_bonding_lacp_info_bonding,
6289 (void *)&cmd_show_bonding_lacp_info_lacp,
6290 (void *)&cmd_show_bonding_lacp_info_info,
6291 (void *)&cmd_show_bonding_lacp_info_port_id,
6296 /* *** SHOW NIC BONDING CONFIGURATION *** */
6297 struct cmd_show_bonding_config_result {
6298 cmdline_fixed_string_t show;
6299 cmdline_fixed_string_t bonding;
6300 cmdline_fixed_string_t config;
6304 static void cmd_show_bonding_config_parsed(void *parsed_result,
6305 __rte_unused struct cmdline *cl,
6306 __rte_unused void *data)
6308 struct cmd_show_bonding_config_result *res = parsed_result;
6309 int bonding_mode, agg_mode;
6310 portid_t slaves[RTE_MAX_ETHPORTS];
6311 int num_slaves, num_active_slaves;
6314 portid_t port_id = res->port_id;
6316 /* Display the bonding mode.*/
6317 bonding_mode = rte_eth_bond_mode_get(port_id);
6318 if (bonding_mode < 0) {
6319 fprintf(stderr, "\tFailed to get bonding mode for port = %d\n",
6323 printf("\tBonding mode: %d\n", bonding_mode);
6325 if (bonding_mode == BONDING_MODE_BALANCE ||
6326 bonding_mode == BONDING_MODE_8023AD) {
6327 int balance_xmit_policy;
6329 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6330 if (balance_xmit_policy < 0) {
6332 "\tFailed to get balance xmit policy for port = %d\n",
6336 printf("\tBalance Xmit Policy: ");
6338 switch (balance_xmit_policy) {
6339 case BALANCE_XMIT_POLICY_LAYER2:
6340 printf("BALANCE_XMIT_POLICY_LAYER2");
6342 case BALANCE_XMIT_POLICY_LAYER23:
6343 printf("BALANCE_XMIT_POLICY_LAYER23");
6345 case BALANCE_XMIT_POLICY_LAYER34:
6346 printf("BALANCE_XMIT_POLICY_LAYER34");
6353 if (bonding_mode == BONDING_MODE_8023AD) {
6354 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6355 printf("\tIEEE802.3AD Aggregator Mode: ");
6358 printf("bandwidth");
6370 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6372 if (num_slaves < 0) {
6373 fprintf(stderr, "\tFailed to get slave list for port = %d\n",
6377 if (num_slaves > 0) {
6378 printf("\tSlaves (%d): [", num_slaves);
6379 for (i = 0; i < num_slaves - 1; i++)
6380 printf("%d ", slaves[i]);
6382 printf("%d]\n", slaves[num_slaves - 1]);
6384 printf("\tSlaves: []\n");
6388 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6391 if (num_active_slaves < 0) {
6393 "\tFailed to get active slave list for port = %d\n",
6397 if (num_active_slaves > 0) {
6398 printf("\tActive Slaves (%d): [", num_active_slaves);
6399 for (i = 0; i < num_active_slaves - 1; i++)
6400 printf("%d ", slaves[i]);
6402 printf("%d]\n", slaves[num_active_slaves - 1]);
6405 printf("\tActive Slaves: []\n");
6409 primary_id = rte_eth_bond_primary_get(port_id);
6410 if (primary_id < 0) {
6411 fprintf(stderr, "\tFailed to get primary slave for port = %d\n",
6415 printf("\tPrimary: [%d]\n", primary_id);
6419 cmdline_parse_token_string_t cmd_showbonding_config_show =
6420 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6422 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6423 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6424 bonding, "bonding");
6425 cmdline_parse_token_string_t cmd_showbonding_config_config =
6426 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6428 cmdline_parse_token_num_t cmd_showbonding_config_port =
6429 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6430 port_id, RTE_UINT16);
6432 cmdline_parse_inst_t cmd_show_bonding_config = {
6433 .f = cmd_show_bonding_config_parsed,
6434 .help_str = "show bonding config <port_id>: "
6435 "Show the bonding config for port_id",
6438 (void *)&cmd_showbonding_config_show,
6439 (void *)&cmd_showbonding_config_bonding,
6440 (void *)&cmd_showbonding_config_config,
6441 (void *)&cmd_showbonding_config_port,
6446 /* *** SET BONDING PRIMARY *** */
6447 struct cmd_set_bonding_primary_result {
6448 cmdline_fixed_string_t set;
6449 cmdline_fixed_string_t bonding;
6450 cmdline_fixed_string_t primary;
6455 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6456 __rte_unused struct cmdline *cl,
6457 __rte_unused void *data)
6459 struct cmd_set_bonding_primary_result *res = parsed_result;
6460 portid_t master_port_id = res->port_id;
6461 portid_t slave_port_id = res->slave_id;
6463 /* Set the primary slave for a bonded device. */
6464 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6465 fprintf(stderr, "\t Failed to set primary slave for port = %d.\n",
6472 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6473 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6475 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6476 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6477 bonding, "bonding");
6478 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6479 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6480 primary, "primary");
6481 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6482 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6483 slave_id, RTE_UINT16);
6484 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6485 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6486 port_id, RTE_UINT16);
6488 cmdline_parse_inst_t cmd_set_bonding_primary = {
6489 .f = cmd_set_bonding_primary_parsed,
6490 .help_str = "set bonding primary <slave_id> <port_id>: "
6491 "Set the primary slave for port_id",
6494 (void *)&cmd_setbonding_primary_set,
6495 (void *)&cmd_setbonding_primary_bonding,
6496 (void *)&cmd_setbonding_primary_primary,
6497 (void *)&cmd_setbonding_primary_slave,
6498 (void *)&cmd_setbonding_primary_port,
6503 /* *** ADD SLAVE *** */
6504 struct cmd_add_bonding_slave_result {
6505 cmdline_fixed_string_t add;
6506 cmdline_fixed_string_t bonding;
6507 cmdline_fixed_string_t slave;
6512 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6513 __rte_unused struct cmdline *cl,
6514 __rte_unused void *data)
6516 struct cmd_add_bonding_slave_result *res = parsed_result;
6517 portid_t master_port_id = res->port_id;
6518 portid_t slave_port_id = res->slave_id;
6520 /* add the slave for a bonded device. */
6521 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6523 "\t Failed to add slave %d to master port = %d.\n",
6524 slave_port_id, master_port_id);
6528 set_port_slave_flag(slave_port_id);
6531 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6532 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6534 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6535 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6536 bonding, "bonding");
6537 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6538 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6540 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6541 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6542 slave_id, RTE_UINT16);
6543 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6544 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6545 port_id, RTE_UINT16);
6547 cmdline_parse_inst_t cmd_add_bonding_slave = {
6548 .f = cmd_add_bonding_slave_parsed,
6549 .help_str = "add bonding slave <slave_id> <port_id>: "
6550 "Add a slave device to a bonded device",
6553 (void *)&cmd_addbonding_slave_add,
6554 (void *)&cmd_addbonding_slave_bonding,
6555 (void *)&cmd_addbonding_slave_slave,
6556 (void *)&cmd_addbonding_slave_slaveid,
6557 (void *)&cmd_addbonding_slave_port,
6562 /* *** REMOVE SLAVE *** */
6563 struct cmd_remove_bonding_slave_result {
6564 cmdline_fixed_string_t remove;
6565 cmdline_fixed_string_t bonding;
6566 cmdline_fixed_string_t slave;
6571 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6572 __rte_unused struct cmdline *cl,
6573 __rte_unused void *data)
6575 struct cmd_remove_bonding_slave_result *res = parsed_result;
6576 portid_t master_port_id = res->port_id;
6577 portid_t slave_port_id = res->slave_id;
6579 /* remove the slave from a bonded device. */
6580 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6582 "\t Failed to remove slave %d from master port = %d.\n",
6583 slave_port_id, master_port_id);
6587 clear_port_slave_flag(slave_port_id);
6590 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6591 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6593 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6594 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6595 bonding, "bonding");
6596 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6597 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6599 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6600 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6601 slave_id, RTE_UINT16);
6602 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6603 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6604 port_id, RTE_UINT16);
6606 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6607 .f = cmd_remove_bonding_slave_parsed,
6608 .help_str = "remove bonding slave <slave_id> <port_id>: "
6609 "Remove a slave device from a bonded device",
6612 (void *)&cmd_removebonding_slave_remove,
6613 (void *)&cmd_removebonding_slave_bonding,
6614 (void *)&cmd_removebonding_slave_slave,
6615 (void *)&cmd_removebonding_slave_slaveid,
6616 (void *)&cmd_removebonding_slave_port,
6621 /* *** CREATE BONDED DEVICE *** */
6622 struct cmd_create_bonded_device_result {
6623 cmdline_fixed_string_t create;
6624 cmdline_fixed_string_t bonded;
6625 cmdline_fixed_string_t device;
6630 static int bond_dev_num = 0;
6632 static void cmd_create_bonded_device_parsed(void *parsed_result,
6633 __rte_unused struct cmdline *cl,
6634 __rte_unused void *data)
6636 struct cmd_create_bonded_device_result *res = parsed_result;
6637 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6641 if (test_done == 0) {
6642 fprintf(stderr, "Please stop forwarding first\n");
6646 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6649 /* Create a new bonded device. */
6650 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6652 fprintf(stderr, "\t Failed to create bonded device.\n");
6655 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6658 /* Update number of ports */
6659 nb_ports = rte_eth_dev_count_avail();
6660 reconfig(port_id, res->socket);
6661 ret = rte_eth_promiscuous_enable(port_id);
6664 "Failed to enable promiscuous mode for port %u: %s - ignore\n",
6665 port_id, rte_strerror(-ret));
6667 ports[port_id].need_setup = 0;
6668 ports[port_id].port_status = RTE_PORT_STOPPED;
6673 cmdline_parse_token_string_t cmd_createbonded_device_create =
6674 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6676 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6677 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6679 cmdline_parse_token_string_t cmd_createbonded_device_device =
6680 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6682 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6683 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6685 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6686 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6689 cmdline_parse_inst_t cmd_create_bonded_device = {
6690 .f = cmd_create_bonded_device_parsed,
6691 .help_str = "create bonded device <mode> <socket>: "
6692 "Create a new bonded device with specific bonding mode and socket",
6695 (void *)&cmd_createbonded_device_create,
6696 (void *)&cmd_createbonded_device_bonded,
6697 (void *)&cmd_createbonded_device_device,
6698 (void *)&cmd_createbonded_device_mode,
6699 (void *)&cmd_createbonded_device_socket,
6704 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6705 struct cmd_set_bond_mac_addr_result {
6706 cmdline_fixed_string_t set;
6707 cmdline_fixed_string_t bonding;
6708 cmdline_fixed_string_t mac_addr;
6710 struct rte_ether_addr address;
6713 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6714 __rte_unused struct cmdline *cl,
6715 __rte_unused void *data)
6717 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6720 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6723 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6725 /* check the return value and print it if is < 0 */
6727 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6731 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6732 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6733 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6734 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6736 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6737 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6739 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6740 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6741 port_num, RTE_UINT16);
6742 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6743 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6745 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6746 .f = cmd_set_bond_mac_addr_parsed,
6748 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6750 (void *)&cmd_set_bond_mac_addr_set,
6751 (void *)&cmd_set_bond_mac_addr_bonding,
6752 (void *)&cmd_set_bond_mac_addr_mac,
6753 (void *)&cmd_set_bond_mac_addr_portnum,
6754 (void *)&cmd_set_bond_mac_addr_addr,
6760 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6761 struct cmd_set_bond_mon_period_result {
6762 cmdline_fixed_string_t set;
6763 cmdline_fixed_string_t bonding;
6764 cmdline_fixed_string_t mon_period;
6769 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6770 __rte_unused struct cmdline *cl,
6771 __rte_unused void *data)
6773 struct cmd_set_bond_mon_period_result *res = parsed_result;
6776 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6778 /* check the return value and print it if is < 0 */
6780 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6784 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6785 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6787 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6788 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6789 bonding, "bonding");
6790 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6791 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6792 mon_period, "mon_period");
6793 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6794 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6795 port_num, RTE_UINT16);
6796 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6797 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6798 period_ms, RTE_UINT32);
6800 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6801 .f = cmd_set_bond_mon_period_parsed,
6803 .help_str = "set bonding mon_period <port_id> <period_ms>",
6805 (void *)&cmd_set_bond_mon_period_set,
6806 (void *)&cmd_set_bond_mon_period_bonding,
6807 (void *)&cmd_set_bond_mon_period_mon_period,
6808 (void *)&cmd_set_bond_mon_period_portnum,
6809 (void *)&cmd_set_bond_mon_period_period_ms,
6816 struct cmd_set_bonding_agg_mode_policy_result {
6817 cmdline_fixed_string_t set;
6818 cmdline_fixed_string_t bonding;
6819 cmdline_fixed_string_t agg_mode;
6821 cmdline_fixed_string_t policy;
6826 cmd_set_bonding_agg_mode(void *parsed_result,
6827 __rte_unused struct cmdline *cl,
6828 __rte_unused void *data)
6830 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6831 uint8_t policy = AGG_BANDWIDTH;
6833 if (!strcmp(res->policy, "bandwidth"))
6834 policy = AGG_BANDWIDTH;
6835 else if (!strcmp(res->policy, "stable"))
6836 policy = AGG_STABLE;
6837 else if (!strcmp(res->policy, "count"))
6840 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6844 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6845 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6847 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6848 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6849 bonding, "bonding");
6851 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6852 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6853 agg_mode, "agg_mode");
6855 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6856 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6857 port_num, RTE_UINT16);
6859 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6860 TOKEN_STRING_INITIALIZER(
6861 struct cmd_set_bonding_balance_xmit_policy_result,
6862 policy, "stable#bandwidth#count");
6864 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6865 .f = cmd_set_bonding_agg_mode,
6867 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6869 (void *)&cmd_set_bonding_agg_mode_set,
6870 (void *)&cmd_set_bonding_agg_mode_bonding,
6871 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6872 (void *)&cmd_set_bonding_agg_mode_portnum,
6873 (void *)&cmd_set_bonding_agg_mode_policy_string,
6879 #endif /* RTE_NET_BOND */
6881 /* *** SET FORWARDING MODE *** */
6882 struct cmd_set_fwd_mode_result {
6883 cmdline_fixed_string_t set;
6884 cmdline_fixed_string_t fwd;
6885 cmdline_fixed_string_t mode;
6888 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6889 __rte_unused struct cmdline *cl,
6890 __rte_unused void *data)
6892 struct cmd_set_fwd_mode_result *res = parsed_result;
6895 set_pkt_forwarding_mode(res->mode);
6898 cmdline_parse_token_string_t cmd_setfwd_set =
6899 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6900 cmdline_parse_token_string_t cmd_setfwd_fwd =
6901 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6902 cmdline_parse_token_string_t cmd_setfwd_mode =
6903 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6904 "" /* defined at init */);
6906 cmdline_parse_inst_t cmd_set_fwd_mode = {
6907 .f = cmd_set_fwd_mode_parsed,
6909 .help_str = NULL, /* defined at init */
6911 (void *)&cmd_setfwd_set,
6912 (void *)&cmd_setfwd_fwd,
6913 (void *)&cmd_setfwd_mode,
6918 static void cmd_set_fwd_mode_init(void)
6921 static char token[128];
6922 static char help[256];
6923 cmdline_parse_token_string_t *token_struct;
6925 modes = list_pkt_forwarding_modes();
6926 snprintf(help, sizeof(help), "set fwd %s: "
6927 "Set packet forwarding mode", modes);
6928 cmd_set_fwd_mode.help_str = help;
6930 /* string token separator is # */
6931 for (c = token; *modes != '\0'; modes++)
6936 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6937 token_struct->string_data.str = token;
6940 /* *** SET RETRY FORWARDING MODE *** */
6941 struct cmd_set_fwd_retry_mode_result {
6942 cmdline_fixed_string_t set;
6943 cmdline_fixed_string_t fwd;
6944 cmdline_fixed_string_t mode;
6945 cmdline_fixed_string_t retry;
6948 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6949 __rte_unused struct cmdline *cl,
6950 __rte_unused void *data)
6952 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6955 set_pkt_forwarding_mode(res->mode);
6958 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6959 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6961 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6962 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6964 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6965 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6967 "" /* defined at init */);
6968 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6969 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6972 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6973 .f = cmd_set_fwd_retry_mode_parsed,
6975 .help_str = NULL, /* defined at init */
6977 (void *)&cmd_setfwd_retry_set,
6978 (void *)&cmd_setfwd_retry_fwd,
6979 (void *)&cmd_setfwd_retry_mode,
6980 (void *)&cmd_setfwd_retry_retry,
6985 static void cmd_set_fwd_retry_mode_init(void)
6988 static char token[128];
6989 static char help[256];
6990 cmdline_parse_token_string_t *token_struct;
6992 modes = list_pkt_forwarding_retry_modes();
6993 snprintf(help, sizeof(help), "set fwd %s retry: "
6994 "Set packet forwarding mode with retry", modes);
6995 cmd_set_fwd_retry_mode.help_str = help;
6997 /* string token separator is # */
6998 for (c = token; *modes != '\0'; modes++)
7003 token_struct = (cmdline_parse_token_string_t *)
7004 cmd_set_fwd_retry_mode.tokens[2];
7005 token_struct->string_data.str = token;
7008 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
7009 struct cmd_set_burst_tx_retry_result {
7010 cmdline_fixed_string_t set;
7011 cmdline_fixed_string_t burst;
7012 cmdline_fixed_string_t tx;
7013 cmdline_fixed_string_t delay;
7015 cmdline_fixed_string_t retry;
7019 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
7020 __rte_unused struct cmdline *cl,
7021 __rte_unused void *data)
7023 struct cmd_set_burst_tx_retry_result *res = parsed_result;
7025 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
7026 && !strcmp(res->tx, "tx")) {
7027 if (!strcmp(res->delay, "delay"))
7028 burst_tx_delay_time = res->time;
7029 if (!strcmp(res->retry, "retry"))
7030 burst_tx_retry_num = res->retry_num;
7035 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
7036 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
7037 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
7038 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
7040 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
7041 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
7042 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
7043 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
7044 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
7045 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
7047 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
7048 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
7049 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
7050 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
7053 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
7054 .f = cmd_set_burst_tx_retry_parsed,
7055 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
7057 (void *)&cmd_set_burst_tx_retry_set,
7058 (void *)&cmd_set_burst_tx_retry_burst,
7059 (void *)&cmd_set_burst_tx_retry_tx,
7060 (void *)&cmd_set_burst_tx_retry_delay,
7061 (void *)&cmd_set_burst_tx_retry_time,
7062 (void *)&cmd_set_burst_tx_retry_retry,
7063 (void *)&cmd_set_burst_tx_retry_retry_num,
7068 /* *** SET PROMISC MODE *** */
7069 struct cmd_set_promisc_mode_result {
7070 cmdline_fixed_string_t set;
7071 cmdline_fixed_string_t promisc;
7072 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
7073 uint16_t port_num; /* valid if "allports" argument == 0 */
7074 cmdline_fixed_string_t mode;
7077 static void cmd_set_promisc_mode_parsed(void *parsed_result,
7078 __rte_unused struct cmdline *cl,
7081 struct cmd_set_promisc_mode_result *res = parsed_result;
7085 if (!strcmp(res->mode, "on"))
7092 RTE_ETH_FOREACH_DEV(i)
7093 eth_set_promisc_mode(i, enable);
7095 eth_set_promisc_mode(res->port_num, enable);
7099 cmdline_parse_token_string_t cmd_setpromisc_set =
7100 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
7101 cmdline_parse_token_string_t cmd_setpromisc_promisc =
7102 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
7104 cmdline_parse_token_string_t cmd_setpromisc_portall =
7105 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
7107 cmdline_parse_token_num_t cmd_setpromisc_portnum =
7108 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
7110 cmdline_parse_token_string_t cmd_setpromisc_mode =
7111 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
7114 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
7115 .f = cmd_set_promisc_mode_parsed,
7117 .help_str = "set promisc all on|off: Set promisc mode for all ports",
7119 (void *)&cmd_setpromisc_set,
7120 (void *)&cmd_setpromisc_promisc,
7121 (void *)&cmd_setpromisc_portall,
7122 (void *)&cmd_setpromisc_mode,
7127 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
7128 .f = cmd_set_promisc_mode_parsed,
7130 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
7132 (void *)&cmd_setpromisc_set,
7133 (void *)&cmd_setpromisc_promisc,
7134 (void *)&cmd_setpromisc_portnum,
7135 (void *)&cmd_setpromisc_mode,
7140 /* *** SET ALLMULTI MODE *** */
7141 struct cmd_set_allmulti_mode_result {
7142 cmdline_fixed_string_t set;
7143 cmdline_fixed_string_t allmulti;
7144 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
7145 uint16_t port_num; /* valid if "allports" argument == 0 */
7146 cmdline_fixed_string_t mode;
7149 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
7150 __rte_unused struct cmdline *cl,
7153 struct cmd_set_allmulti_mode_result *res = parsed_result;
7157 if (!strcmp(res->mode, "on"))
7164 RTE_ETH_FOREACH_DEV(i) {
7165 eth_set_allmulticast_mode(i, enable);
7169 eth_set_allmulticast_mode(res->port_num, enable);
7173 cmdline_parse_token_string_t cmd_setallmulti_set =
7174 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
7175 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
7176 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
7178 cmdline_parse_token_string_t cmd_setallmulti_portall =
7179 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
7181 cmdline_parse_token_num_t cmd_setallmulti_portnum =
7182 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
7184 cmdline_parse_token_string_t cmd_setallmulti_mode =
7185 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
7188 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
7189 .f = cmd_set_allmulti_mode_parsed,
7191 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
7193 (void *)&cmd_setallmulti_set,
7194 (void *)&cmd_setallmulti_allmulti,
7195 (void *)&cmd_setallmulti_portall,
7196 (void *)&cmd_setallmulti_mode,
7201 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
7202 .f = cmd_set_allmulti_mode_parsed,
7204 .help_str = "set allmulti <port_id> on|off: "
7205 "Set allmulti mode on port_id",
7207 (void *)&cmd_setallmulti_set,
7208 (void *)&cmd_setallmulti_allmulti,
7209 (void *)&cmd_setallmulti_portnum,
7210 (void *)&cmd_setallmulti_mode,
7215 /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
7216 struct cmd_link_flow_ctrl_show {
7217 cmdline_fixed_string_t show;
7218 cmdline_fixed_string_t port;
7220 cmdline_fixed_string_t flow_ctrl;
7223 cmdline_parse_token_string_t cmd_lfc_show_show =
7224 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7226 cmdline_parse_token_string_t cmd_lfc_show_port =
7227 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7229 cmdline_parse_token_num_t cmd_lfc_show_portid =
7230 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
7231 port_id, RTE_UINT16);
7232 cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
7233 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7234 flow_ctrl, "flow_ctrl");
7237 cmd_link_flow_ctrl_show_parsed(void *parsed_result,
7238 __rte_unused struct cmdline *cl,
7239 __rte_unused void *data)
7241 struct cmd_link_flow_ctrl_show *res = parsed_result;
7242 static const char *info_border = "*********************";
7243 struct rte_eth_fc_conf fc_conf;
7244 bool rx_fc_en = false;
7245 bool tx_fc_en = false;
7248 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7251 "Failed to get current flow ctrl information: err = %d\n",
7256 if (fc_conf.mode == RTE_ETH_FC_RX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
7258 if (fc_conf.mode == RTE_ETH_FC_TX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
7261 printf("\n%s Flow control infos for port %-2d %s\n",
7262 info_border, res->port_id, info_border);
7263 printf("FC mode:\n");
7264 printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
7265 printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
7266 printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
7267 printf("Pause time: 0x%x\n", fc_conf.pause_time);
7268 printf("High waterline: 0x%x\n", fc_conf.high_water);
7269 printf("Low waterline: 0x%x\n", fc_conf.low_water);
7270 printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
7271 printf("Forward MAC control frames: %s\n",
7272 fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
7273 printf("\n%s************** End ***********%s\n",
7274 info_border, info_border);
7277 cmdline_parse_inst_t cmd_link_flow_control_show = {
7278 .f = cmd_link_flow_ctrl_show_parsed,
7280 .help_str = "show port <port_id> flow_ctrl",
7282 (void *)&cmd_lfc_show_show,
7283 (void *)&cmd_lfc_show_port,
7284 (void *)&cmd_lfc_show_portid,
7285 (void *)&cmd_lfc_show_flow_ctrl,
7290 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
7291 struct cmd_link_flow_ctrl_set_result {
7292 cmdline_fixed_string_t set;
7293 cmdline_fixed_string_t flow_ctrl;
7294 cmdline_fixed_string_t rx;
7295 cmdline_fixed_string_t rx_lfc_mode;
7296 cmdline_fixed_string_t tx;
7297 cmdline_fixed_string_t tx_lfc_mode;
7298 cmdline_fixed_string_t mac_ctrl_frame_fwd;
7299 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
7300 cmdline_fixed_string_t autoneg_str;
7301 cmdline_fixed_string_t autoneg;
7302 cmdline_fixed_string_t hw_str;
7303 uint32_t high_water;
7304 cmdline_fixed_string_t lw_str;
7306 cmdline_fixed_string_t pt_str;
7307 uint16_t pause_time;
7308 cmdline_fixed_string_t xon_str;
7313 cmdline_parse_token_string_t cmd_lfc_set_set =
7314 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7316 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
7317 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7318 flow_ctrl, "flow_ctrl");
7319 cmdline_parse_token_string_t cmd_lfc_set_rx =
7320 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7322 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
7323 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7324 rx_lfc_mode, "on#off");
7325 cmdline_parse_token_string_t cmd_lfc_set_tx =
7326 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7328 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7329 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7330 tx_lfc_mode, "on#off");
7331 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7332 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7333 hw_str, "high_water");
7334 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7335 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7336 high_water, RTE_UINT32);
7337 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7338 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7339 lw_str, "low_water");
7340 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7341 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7342 low_water, RTE_UINT32);
7343 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7344 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7345 pt_str, "pause_time");
7346 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7347 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7348 pause_time, RTE_UINT16);
7349 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7350 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7351 xon_str, "send_xon");
7352 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7353 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7354 send_xon, RTE_UINT16);
7355 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7356 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7357 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7358 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7359 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7360 mac_ctrl_frame_fwd_mode, "on#off");
7361 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7362 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7363 autoneg_str, "autoneg");
7364 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7365 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7367 cmdline_parse_token_num_t cmd_lfc_set_portid =
7368 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7369 port_id, RTE_UINT16);
7371 /* forward declaration */
7373 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7376 cmdline_parse_inst_t cmd_link_flow_control_set = {
7377 .f = cmd_link_flow_ctrl_set_parsed,
7379 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7380 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7381 "autoneg on|off <port_id>: Configure the Ethernet flow control",
7383 (void *)&cmd_lfc_set_set,
7384 (void *)&cmd_lfc_set_flow_ctrl,
7385 (void *)&cmd_lfc_set_rx,
7386 (void *)&cmd_lfc_set_rx_mode,
7387 (void *)&cmd_lfc_set_tx,
7388 (void *)&cmd_lfc_set_tx_mode,
7389 (void *)&cmd_lfc_set_high_water,
7390 (void *)&cmd_lfc_set_low_water,
7391 (void *)&cmd_lfc_set_pause_time,
7392 (void *)&cmd_lfc_set_send_xon,
7393 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7394 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7395 (void *)&cmd_lfc_set_autoneg_str,
7396 (void *)&cmd_lfc_set_autoneg,
7397 (void *)&cmd_lfc_set_portid,
7402 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7403 .f = cmd_link_flow_ctrl_set_parsed,
7404 .data = (void *)&cmd_link_flow_control_set_rx,
7405 .help_str = "set flow_ctrl rx on|off <port_id>: "
7406 "Change rx flow control parameter",
7408 (void *)&cmd_lfc_set_set,
7409 (void *)&cmd_lfc_set_flow_ctrl,
7410 (void *)&cmd_lfc_set_rx,
7411 (void *)&cmd_lfc_set_rx_mode,
7412 (void *)&cmd_lfc_set_portid,
7417 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7418 .f = cmd_link_flow_ctrl_set_parsed,
7419 .data = (void *)&cmd_link_flow_control_set_tx,
7420 .help_str = "set flow_ctrl tx on|off <port_id>: "
7421 "Change tx flow control parameter",
7423 (void *)&cmd_lfc_set_set,
7424 (void *)&cmd_lfc_set_flow_ctrl,
7425 (void *)&cmd_lfc_set_tx,
7426 (void *)&cmd_lfc_set_tx_mode,
7427 (void *)&cmd_lfc_set_portid,
7432 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7433 .f = cmd_link_flow_ctrl_set_parsed,
7434 .data = (void *)&cmd_link_flow_control_set_hw,
7435 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7436 "Change high water flow control parameter",
7438 (void *)&cmd_lfc_set_set,
7439 (void *)&cmd_lfc_set_flow_ctrl,
7440 (void *)&cmd_lfc_set_high_water_str,
7441 (void *)&cmd_lfc_set_high_water,
7442 (void *)&cmd_lfc_set_portid,
7447 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7448 .f = cmd_link_flow_ctrl_set_parsed,
7449 .data = (void *)&cmd_link_flow_control_set_lw,
7450 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7451 "Change low water flow control parameter",
7453 (void *)&cmd_lfc_set_set,
7454 (void *)&cmd_lfc_set_flow_ctrl,
7455 (void *)&cmd_lfc_set_low_water_str,
7456 (void *)&cmd_lfc_set_low_water,
7457 (void *)&cmd_lfc_set_portid,
7462 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7463 .f = cmd_link_flow_ctrl_set_parsed,
7464 .data = (void *)&cmd_link_flow_control_set_pt,
7465 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7466 "Change pause time flow control parameter",
7468 (void *)&cmd_lfc_set_set,
7469 (void *)&cmd_lfc_set_flow_ctrl,
7470 (void *)&cmd_lfc_set_pause_time_str,
7471 (void *)&cmd_lfc_set_pause_time,
7472 (void *)&cmd_lfc_set_portid,
7477 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7478 .f = cmd_link_flow_ctrl_set_parsed,
7479 .data = (void *)&cmd_link_flow_control_set_xon,
7480 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7481 "Change send_xon flow control parameter",
7483 (void *)&cmd_lfc_set_set,
7484 (void *)&cmd_lfc_set_flow_ctrl,
7485 (void *)&cmd_lfc_set_send_xon_str,
7486 (void *)&cmd_lfc_set_send_xon,
7487 (void *)&cmd_lfc_set_portid,
7492 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7493 .f = cmd_link_flow_ctrl_set_parsed,
7494 .data = (void *)&cmd_link_flow_control_set_macfwd,
7495 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7496 "Change mac ctrl fwd flow control parameter",
7498 (void *)&cmd_lfc_set_set,
7499 (void *)&cmd_lfc_set_flow_ctrl,
7500 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7501 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7502 (void *)&cmd_lfc_set_portid,
7507 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7508 .f = cmd_link_flow_ctrl_set_parsed,
7509 .data = (void *)&cmd_link_flow_control_set_autoneg,
7510 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7511 "Change autoneg flow control parameter",
7513 (void *)&cmd_lfc_set_set,
7514 (void *)&cmd_lfc_set_flow_ctrl,
7515 (void *)&cmd_lfc_set_autoneg_str,
7516 (void *)&cmd_lfc_set_autoneg,
7517 (void *)&cmd_lfc_set_portid,
7523 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7524 __rte_unused struct cmdline *cl,
7527 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7528 cmdline_parse_inst_t *cmd = data;
7529 struct rte_eth_fc_conf fc_conf;
7535 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7536 * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7537 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7538 * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7540 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7541 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7544 /* Partial command line, retrieve current configuration */
7546 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7549 "cannot get current flow ctrl parameters, return code = %d\n",
7554 if ((fc_conf.mode == RTE_ETH_FC_RX_PAUSE) ||
7555 (fc_conf.mode == RTE_ETH_FC_FULL))
7557 if ((fc_conf.mode == RTE_ETH_FC_TX_PAUSE) ||
7558 (fc_conf.mode == RTE_ETH_FC_FULL))
7562 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7563 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7565 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7566 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7568 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7570 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7571 fc_conf.high_water = res->high_water;
7573 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7574 fc_conf.low_water = res->low_water;
7576 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7577 fc_conf.pause_time = res->pause_time;
7579 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7580 fc_conf.send_xon = res->send_xon;
7582 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7583 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7584 fc_conf.mac_ctrl_frame_fwd = 1;
7586 fc_conf.mac_ctrl_frame_fwd = 0;
7589 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7590 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7592 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7595 "bad flow control parameter, return code = %d\n",
7599 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7600 struct cmd_priority_flow_ctrl_set_result {
7601 cmdline_fixed_string_t set;
7602 cmdline_fixed_string_t pfc_ctrl;
7603 cmdline_fixed_string_t rx;
7604 cmdline_fixed_string_t rx_pfc_mode;
7605 cmdline_fixed_string_t tx;
7606 cmdline_fixed_string_t tx_pfc_mode;
7607 uint32_t high_water;
7609 uint16_t pause_time;
7615 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7616 __rte_unused struct cmdline *cl,
7617 __rte_unused void *data)
7619 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7620 struct rte_eth_pfc_conf pfc_conf;
7621 int rx_fc_enable, tx_fc_enable;
7625 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7626 * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7627 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7628 * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7630 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7631 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7634 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7635 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7636 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7637 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7638 pfc_conf.fc.high_water = res->high_water;
7639 pfc_conf.fc.low_water = res->low_water;
7640 pfc_conf.fc.pause_time = res->pause_time;
7641 pfc_conf.priority = res->priority;
7643 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7646 "bad priority flow control parameter, return code = %d\n",
7650 cmdline_parse_token_string_t cmd_pfc_set_set =
7651 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7653 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7654 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7655 pfc_ctrl, "pfc_ctrl");
7656 cmdline_parse_token_string_t cmd_pfc_set_rx =
7657 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7659 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7660 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7661 rx_pfc_mode, "on#off");
7662 cmdline_parse_token_string_t cmd_pfc_set_tx =
7663 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7665 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7666 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7667 tx_pfc_mode, "on#off");
7668 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7669 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7670 high_water, RTE_UINT32);
7671 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7672 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7673 low_water, RTE_UINT32);
7674 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7675 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7676 pause_time, RTE_UINT16);
7677 cmdline_parse_token_num_t cmd_pfc_set_priority =
7678 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7679 priority, RTE_UINT8);
7680 cmdline_parse_token_num_t cmd_pfc_set_portid =
7681 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7682 port_id, RTE_UINT16);
7684 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7685 .f = cmd_priority_flow_ctrl_set_parsed,
7687 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7688 "<pause_time> <priority> <port_id>: "
7689 "Configure the Ethernet priority flow control",
7691 (void *)&cmd_pfc_set_set,
7692 (void *)&cmd_pfc_set_flow_ctrl,
7693 (void *)&cmd_pfc_set_rx,
7694 (void *)&cmd_pfc_set_rx_mode,
7695 (void *)&cmd_pfc_set_tx,
7696 (void *)&cmd_pfc_set_tx_mode,
7697 (void *)&cmd_pfc_set_high_water,
7698 (void *)&cmd_pfc_set_low_water,
7699 (void *)&cmd_pfc_set_pause_time,
7700 (void *)&cmd_pfc_set_priority,
7701 (void *)&cmd_pfc_set_portid,
7706 /* *** RESET CONFIGURATION *** */
7707 struct cmd_reset_result {
7708 cmdline_fixed_string_t reset;
7709 cmdline_fixed_string_t def;
7712 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7714 __rte_unused void *data)
7716 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7717 set_def_fwd_config();
7720 cmdline_parse_token_string_t cmd_reset_set =
7721 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7722 cmdline_parse_token_string_t cmd_reset_def =
7723 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7726 cmdline_parse_inst_t cmd_reset = {
7727 .f = cmd_reset_parsed,
7729 .help_str = "set default: Reset default forwarding configuration",
7731 (void *)&cmd_reset_set,
7732 (void *)&cmd_reset_def,
7737 /* *** START FORWARDING *** */
7738 struct cmd_start_result {
7739 cmdline_fixed_string_t start;
7742 cmdline_parse_token_string_t cmd_start_start =
7743 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7745 static void cmd_start_parsed(__rte_unused void *parsed_result,
7746 __rte_unused struct cmdline *cl,
7747 __rte_unused void *data)
7749 start_packet_forwarding(0);
7752 cmdline_parse_inst_t cmd_start = {
7753 .f = cmd_start_parsed,
7755 .help_str = "start: Start packet forwarding",
7757 (void *)&cmd_start_start,
7762 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7763 struct cmd_start_tx_first_result {
7764 cmdline_fixed_string_t start;
7765 cmdline_fixed_string_t tx_first;
7769 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7770 __rte_unused struct cmdline *cl,
7771 __rte_unused void *data)
7773 start_packet_forwarding(1);
7776 cmdline_parse_token_string_t cmd_start_tx_first_start =
7777 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7779 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7780 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7781 tx_first, "tx_first");
7783 cmdline_parse_inst_t cmd_start_tx_first = {
7784 .f = cmd_start_tx_first_parsed,
7786 .help_str = "start tx_first: Start packet forwarding, "
7787 "after sending 1 burst of packets",
7789 (void *)&cmd_start_tx_first_start,
7790 (void *)&cmd_start_tx_first_tx_first,
7795 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7796 struct cmd_start_tx_first_n_result {
7797 cmdline_fixed_string_t start;
7798 cmdline_fixed_string_t tx_first;
7803 cmd_start_tx_first_n_parsed(void *parsed_result,
7804 __rte_unused struct cmdline *cl,
7805 __rte_unused void *data)
7807 struct cmd_start_tx_first_n_result *res = parsed_result;
7809 start_packet_forwarding(res->tx_num);
7812 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7813 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7815 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7816 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7817 tx_first, "tx_first");
7818 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7819 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7820 tx_num, RTE_UINT32);
7822 cmdline_parse_inst_t cmd_start_tx_first_n = {
7823 .f = cmd_start_tx_first_n_parsed,
7825 .help_str = "start tx_first <num>: "
7826 "packet forwarding, after sending <num> bursts of packets",
7828 (void *)&cmd_start_tx_first_n_start,
7829 (void *)&cmd_start_tx_first_n_tx_first,
7830 (void *)&cmd_start_tx_first_n_tx_num,
7835 /* *** SET LINK UP *** */
7836 struct cmd_set_link_up_result {
7837 cmdline_fixed_string_t set;
7838 cmdline_fixed_string_t link_up;
7839 cmdline_fixed_string_t port;
7843 cmdline_parse_token_string_t cmd_set_link_up_set =
7844 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7845 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7846 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7848 cmdline_parse_token_string_t cmd_set_link_up_port =
7849 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7850 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7851 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7854 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7855 __rte_unused struct cmdline *cl,
7856 __rte_unused void *data)
7858 struct cmd_set_link_up_result *res = parsed_result;
7859 dev_set_link_up(res->port_id);
7862 cmdline_parse_inst_t cmd_set_link_up = {
7863 .f = cmd_set_link_up_parsed,
7865 .help_str = "set link-up port <port id>",
7867 (void *)&cmd_set_link_up_set,
7868 (void *)&cmd_set_link_up_link_up,
7869 (void *)&cmd_set_link_up_port,
7870 (void *)&cmd_set_link_up_port_id,
7875 /* *** SET LINK DOWN *** */
7876 struct cmd_set_link_down_result {
7877 cmdline_fixed_string_t set;
7878 cmdline_fixed_string_t link_down;
7879 cmdline_fixed_string_t port;
7883 cmdline_parse_token_string_t cmd_set_link_down_set =
7884 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7885 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7886 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7888 cmdline_parse_token_string_t cmd_set_link_down_port =
7889 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7890 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7891 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7894 static void cmd_set_link_down_parsed(
7895 __rte_unused void *parsed_result,
7896 __rte_unused struct cmdline *cl,
7897 __rte_unused void *data)
7899 struct cmd_set_link_down_result *res = parsed_result;
7900 dev_set_link_down(res->port_id);
7903 cmdline_parse_inst_t cmd_set_link_down = {
7904 .f = cmd_set_link_down_parsed,
7906 .help_str = "set link-down port <port id>",
7908 (void *)&cmd_set_link_down_set,
7909 (void *)&cmd_set_link_down_link_down,
7910 (void *)&cmd_set_link_down_port,
7911 (void *)&cmd_set_link_down_port_id,
7916 /* *** SHOW CFG *** */
7917 struct cmd_showcfg_result {
7918 cmdline_fixed_string_t show;
7919 cmdline_fixed_string_t cfg;
7920 cmdline_fixed_string_t what;
7923 static void cmd_showcfg_parsed(void *parsed_result,
7924 __rte_unused struct cmdline *cl,
7925 __rte_unused void *data)
7927 struct cmd_showcfg_result *res = parsed_result;
7928 if (!strcmp(res->what, "rxtx"))
7929 rxtx_config_display();
7930 else if (!strcmp(res->what, "cores"))
7931 fwd_lcores_config_display();
7932 else if (!strcmp(res->what, "fwd"))
7933 pkt_fwd_config_display(&cur_fwd_config);
7934 else if (!strcmp(res->what, "rxoffs"))
7935 show_rx_pkt_offsets();
7936 else if (!strcmp(res->what, "rxpkts"))
7937 show_rx_pkt_segments();
7938 else if (!strcmp(res->what, "txpkts"))
7939 show_tx_pkt_segments();
7940 else if (!strcmp(res->what, "txtimes"))
7941 show_tx_pkt_times();
7944 cmdline_parse_token_string_t cmd_showcfg_show =
7945 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7946 cmdline_parse_token_string_t cmd_showcfg_port =
7947 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7948 cmdline_parse_token_string_t cmd_showcfg_what =
7949 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7950 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7952 cmdline_parse_inst_t cmd_showcfg = {
7953 .f = cmd_showcfg_parsed,
7955 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7957 (void *)&cmd_showcfg_show,
7958 (void *)&cmd_showcfg_port,
7959 (void *)&cmd_showcfg_what,
7964 /* *** SHOW ALL PORT INFO *** */
7965 struct cmd_showportall_result {
7966 cmdline_fixed_string_t show;
7967 cmdline_fixed_string_t port;
7968 cmdline_fixed_string_t what;
7969 cmdline_fixed_string_t all;
7972 static void cmd_showportall_parsed(void *parsed_result,
7973 __rte_unused struct cmdline *cl,
7974 __rte_unused void *data)
7978 struct cmd_showportall_result *res = parsed_result;
7979 if (!strcmp(res->show, "clear")) {
7980 if (!strcmp(res->what, "stats"))
7981 RTE_ETH_FOREACH_DEV(i)
7983 else if (!strcmp(res->what, "xstats"))
7984 RTE_ETH_FOREACH_DEV(i)
7985 nic_xstats_clear(i);
7986 } else if (!strcmp(res->what, "info"))
7987 RTE_ETH_FOREACH_DEV(i)
7988 port_infos_display(i);
7989 else if (!strcmp(res->what, "summary")) {
7990 port_summary_header_display();
7991 RTE_ETH_FOREACH_DEV(i)
7992 port_summary_display(i);
7994 else if (!strcmp(res->what, "stats"))
7995 RTE_ETH_FOREACH_DEV(i)
7996 nic_stats_display(i);
7997 else if (!strcmp(res->what, "xstats"))
7998 RTE_ETH_FOREACH_DEV(i)
7999 nic_xstats_display(i);
8000 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
8001 else if (!strcmp(res->what, "fdir"))
8002 RTE_ETH_FOREACH_DEV(i)
8005 else if (!strcmp(res->what, "dcb_tc"))
8006 RTE_ETH_FOREACH_DEV(i)
8007 port_dcb_info_display(i);
8010 cmdline_parse_token_string_t cmd_showportall_show =
8011 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
8013 cmdline_parse_token_string_t cmd_showportall_port =
8014 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
8015 cmdline_parse_token_string_t cmd_showportall_what =
8016 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
8017 "info#summary#stats#xstats#fdir#dcb_tc");
8018 cmdline_parse_token_string_t cmd_showportall_all =
8019 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
8020 cmdline_parse_inst_t cmd_showportall = {
8021 .f = cmd_showportall_parsed,
8023 .help_str = "show|clear port "
8024 "info|summary|stats|xstats|fdir|dcb_tc all",
8026 (void *)&cmd_showportall_show,
8027 (void *)&cmd_showportall_port,
8028 (void *)&cmd_showportall_what,
8029 (void *)&cmd_showportall_all,
8034 /* *** SHOW PORT INFO *** */
8035 struct cmd_showport_result {
8036 cmdline_fixed_string_t show;
8037 cmdline_fixed_string_t port;
8038 cmdline_fixed_string_t what;
8042 static void cmd_showport_parsed(void *parsed_result,
8043 __rte_unused struct cmdline *cl,
8044 __rte_unused void *data)
8046 struct cmd_showport_result *res = parsed_result;
8047 if (!strcmp(res->show, "clear")) {
8048 if (!strcmp(res->what, "stats"))
8049 nic_stats_clear(res->portnum);
8050 else if (!strcmp(res->what, "xstats"))
8051 nic_xstats_clear(res->portnum);
8052 } else if (!strcmp(res->what, "info"))
8053 port_infos_display(res->portnum);
8054 else if (!strcmp(res->what, "summary")) {
8055 port_summary_header_display();
8056 port_summary_display(res->portnum);
8058 else if (!strcmp(res->what, "stats"))
8059 nic_stats_display(res->portnum);
8060 else if (!strcmp(res->what, "xstats"))
8061 nic_xstats_display(res->portnum);
8062 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
8063 else if (!strcmp(res->what, "fdir"))
8064 fdir_get_infos(res->portnum);
8066 else if (!strcmp(res->what, "dcb_tc"))
8067 port_dcb_info_display(res->portnum);
8070 cmdline_parse_token_string_t cmd_showport_show =
8071 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
8073 cmdline_parse_token_string_t cmd_showport_port =
8074 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
8075 cmdline_parse_token_string_t cmd_showport_what =
8076 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
8077 "info#summary#stats#xstats#fdir#dcb_tc");
8078 cmdline_parse_token_num_t cmd_showport_portnum =
8079 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
8081 cmdline_parse_inst_t cmd_showport = {
8082 .f = cmd_showport_parsed,
8084 .help_str = "show|clear port "
8085 "info|summary|stats|xstats|fdir|dcb_tc "
8088 (void *)&cmd_showport_show,
8089 (void *)&cmd_showport_port,
8090 (void *)&cmd_showport_what,
8091 (void *)&cmd_showport_portnum,
8096 /* *** show port representors information *** */
8097 struct cmd_representor_info_result {
8098 cmdline_fixed_string_t cmd_show;
8099 cmdline_fixed_string_t cmd_port;
8100 cmdline_fixed_string_t cmd_info;
8101 cmdline_fixed_string_t cmd_keyword;
8106 cmd_representor_info_parsed(void *parsed_result,
8107 __rte_unused struct cmdline *cl,
8108 __rte_unused void *data)
8110 struct cmd_representor_info_result *res = parsed_result;
8111 struct rte_eth_representor_info *info;
8112 struct rte_eth_representor_range *range;
8113 uint32_t range_diff;
8118 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
8119 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
8123 ret = rte_eth_representor_info_get(res->cmd_pid, NULL);
8126 "Failed to get the number of representor info ranges for port %hu: %s\n",
8127 res->cmd_pid, rte_strerror(-ret));
8132 info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0]));
8135 "Failed to allocate memory for representor info for port %hu\n",
8139 info->nb_ranges_alloc = num;
8141 ret = rte_eth_representor_info_get(res->cmd_pid, info);
8144 "Failed to get the representor info for port %hu: %s\n",
8145 res->cmd_pid, rte_strerror(-ret));
8150 printf("Port controller: %hu\n", info->controller);
8151 printf("Port PF: %hu\n", info->pf);
8153 printf("Ranges: %u\n", info->nb_ranges);
8154 for (i = 0; i < info->nb_ranges; i++) {
8155 range = &info->ranges[i];
8156 range_diff = range->id_end - range->id_base;
8158 printf("%u. ", i + 1);
8159 printf("'%s' ", range->name);
8161 printf("[%u-%u]: ", range->id_base, range->id_end);
8163 printf("[%u]: ", range->id_base);
8165 printf("Controller %d, PF %d", range->controller, range->pf);
8167 switch (range->type) {
8168 case RTE_ETH_REPRESENTOR_NONE:
8171 case RTE_ETH_REPRESENTOR_VF:
8173 printf(", VF %d..%d\n", range->vf,
8174 range->vf + range_diff);
8176 printf(", VF %d\n", range->vf);
8178 case RTE_ETH_REPRESENTOR_SF:
8179 printf(", SF %d\n", range->sf);
8181 case RTE_ETH_REPRESENTOR_PF:
8183 printf("..%d\n", range->pf + range_diff);
8188 printf(", UNKNOWN TYPE %d\n", range->type);
8196 cmdline_parse_token_string_t cmd_representor_info_show =
8197 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8199 cmdline_parse_token_string_t cmd_representor_info_port =
8200 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8202 cmdline_parse_token_string_t cmd_representor_info_info =
8203 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8205 cmdline_parse_token_num_t cmd_representor_info_pid =
8206 TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result,
8207 cmd_pid, RTE_UINT16);
8208 cmdline_parse_token_string_t cmd_representor_info_keyword =
8209 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8210 cmd_keyword, "representor");
8212 cmdline_parse_inst_t cmd_representor_info = {
8213 .f = cmd_representor_info_parsed,
8215 .help_str = "show port info <port_id> representor",
8217 (void *)&cmd_representor_info_show,
8218 (void *)&cmd_representor_info_port,
8219 (void *)&cmd_representor_info_info,
8220 (void *)&cmd_representor_info_pid,
8221 (void *)&cmd_representor_info_keyword,
8227 /* *** SHOW DEVICE INFO *** */
8228 struct cmd_showdevice_result {
8229 cmdline_fixed_string_t show;
8230 cmdline_fixed_string_t device;
8231 cmdline_fixed_string_t what;
8232 cmdline_fixed_string_t identifier;
8235 static void cmd_showdevice_parsed(void *parsed_result,
8236 __rte_unused struct cmdline *cl,
8237 __rte_unused void *data)
8239 struct cmd_showdevice_result *res = parsed_result;
8240 if (!strcmp(res->what, "info")) {
8241 if (!strcmp(res->identifier, "all"))
8242 device_infos_display(NULL);
8244 device_infos_display(res->identifier);
8248 cmdline_parse_token_string_t cmd_showdevice_show =
8249 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
8251 cmdline_parse_token_string_t cmd_showdevice_device =
8252 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
8253 cmdline_parse_token_string_t cmd_showdevice_what =
8254 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
8256 cmdline_parse_token_string_t cmd_showdevice_identifier =
8257 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
8260 cmdline_parse_inst_t cmd_showdevice = {
8261 .f = cmd_showdevice_parsed,
8263 .help_str = "show device info <identifier>|all",
8265 (void *)&cmd_showdevice_show,
8266 (void *)&cmd_showdevice_device,
8267 (void *)&cmd_showdevice_what,
8268 (void *)&cmd_showdevice_identifier,
8273 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
8274 struct cmd_showeeprom_result {
8275 cmdline_fixed_string_t show;
8276 cmdline_fixed_string_t port;
8278 cmdline_fixed_string_t type;
8281 static void cmd_showeeprom_parsed(void *parsed_result,
8282 __rte_unused struct cmdline *cl,
8283 __rte_unused void *data)
8285 struct cmd_showeeprom_result *res = parsed_result;
8287 if (!strcmp(res->type, "eeprom"))
8288 port_eeprom_display(res->portnum);
8289 else if (!strcmp(res->type, "module_eeprom"))
8290 port_module_eeprom_display(res->portnum);
8292 fprintf(stderr, "Unknown argument\n");
8295 cmdline_parse_token_string_t cmd_showeeprom_show =
8296 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
8297 cmdline_parse_token_string_t cmd_showeeprom_port =
8298 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
8299 cmdline_parse_token_num_t cmd_showeeprom_portnum =
8300 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
8302 cmdline_parse_token_string_t cmd_showeeprom_type =
8303 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
8305 cmdline_parse_inst_t cmd_showeeprom = {
8306 .f = cmd_showeeprom_parsed,
8308 .help_str = "show port <port_id> module_eeprom|eeprom",
8310 (void *)&cmd_showeeprom_show,
8311 (void *)&cmd_showeeprom_port,
8312 (void *)&cmd_showeeprom_portnum,
8313 (void *)&cmd_showeeprom_type,
8318 /* *** SHOW QUEUE INFO *** */
8319 struct cmd_showqueue_result {
8320 cmdline_fixed_string_t show;
8321 cmdline_fixed_string_t type;
8322 cmdline_fixed_string_t what;
8328 cmd_showqueue_parsed(void *parsed_result,
8329 __rte_unused struct cmdline *cl,
8330 __rte_unused void *data)
8332 struct cmd_showqueue_result *res = parsed_result;
8334 if (!strcmp(res->type, "rxq"))
8335 rx_queue_infos_display(res->portnum, res->queuenum);
8336 else if (!strcmp(res->type, "txq"))
8337 tx_queue_infos_display(res->portnum, res->queuenum);
8340 cmdline_parse_token_string_t cmd_showqueue_show =
8341 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
8342 cmdline_parse_token_string_t cmd_showqueue_type =
8343 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
8344 cmdline_parse_token_string_t cmd_showqueue_what =
8345 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
8346 cmdline_parse_token_num_t cmd_showqueue_portnum =
8347 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
8349 cmdline_parse_token_num_t cmd_showqueue_queuenum =
8350 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
8353 cmdline_parse_inst_t cmd_showqueue = {
8354 .f = cmd_showqueue_parsed,
8356 .help_str = "show rxq|txq info <port_id> <queue_id>",
8358 (void *)&cmd_showqueue_show,
8359 (void *)&cmd_showqueue_type,
8360 (void *)&cmd_showqueue_what,
8361 (void *)&cmd_showqueue_portnum,
8362 (void *)&cmd_showqueue_queuenum,
8367 /* show/clear fwd engine statistics */
8369 cmdline_fixed_string_t action;
8370 cmdline_fixed_string_t fwd;
8371 cmdline_fixed_string_t stats;
8372 cmdline_fixed_string_t all;
8375 cmdline_parse_token_string_t cmd_fwd_action =
8376 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
8377 cmdline_parse_token_string_t cmd_fwd_fwd =
8378 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
8379 cmdline_parse_token_string_t cmd_fwd_stats =
8380 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
8381 cmdline_parse_token_string_t cmd_fwd_all =
8382 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
8385 cmd_showfwdall_parsed(void *parsed_result,
8386 __rte_unused struct cmdline *cl,
8387 __rte_unused void *data)
8389 struct fwd_result *res = parsed_result;
8391 if (!strcmp(res->action, "show"))
8392 fwd_stats_display();
8397 static cmdline_parse_inst_t cmd_showfwdall = {
8398 .f = cmd_showfwdall_parsed,
8400 .help_str = "show|clear fwd stats all",
8402 (void *)&cmd_fwd_action,
8403 (void *)&cmd_fwd_fwd,
8404 (void *)&cmd_fwd_stats,
8405 (void *)&cmd_fwd_all,
8410 /* *** READ PORT REGISTER *** */
8411 struct cmd_read_reg_result {
8412 cmdline_fixed_string_t read;
8413 cmdline_fixed_string_t reg;
8419 cmd_read_reg_parsed(void *parsed_result,
8420 __rte_unused struct cmdline *cl,
8421 __rte_unused void *data)
8423 struct cmd_read_reg_result *res = parsed_result;
8424 port_reg_display(res->port_id, res->reg_off);
8427 cmdline_parse_token_string_t cmd_read_reg_read =
8428 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
8429 cmdline_parse_token_string_t cmd_read_reg_reg =
8430 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
8431 cmdline_parse_token_num_t cmd_read_reg_port_id =
8432 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
8433 cmdline_parse_token_num_t cmd_read_reg_reg_off =
8434 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
8436 cmdline_parse_inst_t cmd_read_reg = {
8437 .f = cmd_read_reg_parsed,
8439 .help_str = "read reg <port_id> <reg_off>",
8441 (void *)&cmd_read_reg_read,
8442 (void *)&cmd_read_reg_reg,
8443 (void *)&cmd_read_reg_port_id,
8444 (void *)&cmd_read_reg_reg_off,
8449 /* *** READ PORT REGISTER BIT FIELD *** */
8450 struct cmd_read_reg_bit_field_result {
8451 cmdline_fixed_string_t read;
8452 cmdline_fixed_string_t regfield;
8460 cmd_read_reg_bit_field_parsed(void *parsed_result,
8461 __rte_unused struct cmdline *cl,
8462 __rte_unused void *data)
8464 struct cmd_read_reg_bit_field_result *res = parsed_result;
8465 port_reg_bit_field_display(res->port_id, res->reg_off,
8466 res->bit1_pos, res->bit2_pos);
8469 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8470 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8472 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8473 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8474 regfield, "regfield");
8475 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8476 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8478 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8479 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8481 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8482 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8484 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8485 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8488 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8489 .f = cmd_read_reg_bit_field_parsed,
8491 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8492 "Read register bit field between bit_x and bit_y included",
8494 (void *)&cmd_read_reg_bit_field_read,
8495 (void *)&cmd_read_reg_bit_field_regfield,
8496 (void *)&cmd_read_reg_bit_field_port_id,
8497 (void *)&cmd_read_reg_bit_field_reg_off,
8498 (void *)&cmd_read_reg_bit_field_bit1_pos,
8499 (void *)&cmd_read_reg_bit_field_bit2_pos,
8504 /* *** READ PORT REGISTER BIT *** */
8505 struct cmd_read_reg_bit_result {
8506 cmdline_fixed_string_t read;
8507 cmdline_fixed_string_t regbit;
8514 cmd_read_reg_bit_parsed(void *parsed_result,
8515 __rte_unused struct cmdline *cl,
8516 __rte_unused void *data)
8518 struct cmd_read_reg_bit_result *res = parsed_result;
8519 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8522 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8523 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8524 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8525 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8527 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8528 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
8530 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8531 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
8533 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8534 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
8537 cmdline_parse_inst_t cmd_read_reg_bit = {
8538 .f = cmd_read_reg_bit_parsed,
8540 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8542 (void *)&cmd_read_reg_bit_read,
8543 (void *)&cmd_read_reg_bit_regbit,
8544 (void *)&cmd_read_reg_bit_port_id,
8545 (void *)&cmd_read_reg_bit_reg_off,
8546 (void *)&cmd_read_reg_bit_bit_pos,
8551 /* *** WRITE PORT REGISTER *** */
8552 struct cmd_write_reg_result {
8553 cmdline_fixed_string_t write;
8554 cmdline_fixed_string_t reg;
8561 cmd_write_reg_parsed(void *parsed_result,
8562 __rte_unused struct cmdline *cl,
8563 __rte_unused void *data)
8565 struct cmd_write_reg_result *res = parsed_result;
8566 port_reg_set(res->port_id, res->reg_off, res->value);
8569 cmdline_parse_token_string_t cmd_write_reg_write =
8570 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8571 cmdline_parse_token_string_t cmd_write_reg_reg =
8572 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8573 cmdline_parse_token_num_t cmd_write_reg_port_id =
8574 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8575 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8576 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8577 cmdline_parse_token_num_t cmd_write_reg_value =
8578 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8580 cmdline_parse_inst_t cmd_write_reg = {
8581 .f = cmd_write_reg_parsed,
8583 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8585 (void *)&cmd_write_reg_write,
8586 (void *)&cmd_write_reg_reg,
8587 (void *)&cmd_write_reg_port_id,
8588 (void *)&cmd_write_reg_reg_off,
8589 (void *)&cmd_write_reg_value,
8594 /* *** WRITE PORT REGISTER BIT FIELD *** */
8595 struct cmd_write_reg_bit_field_result {
8596 cmdline_fixed_string_t write;
8597 cmdline_fixed_string_t regfield;
8606 cmd_write_reg_bit_field_parsed(void *parsed_result,
8607 __rte_unused struct cmdline *cl,
8608 __rte_unused void *data)
8610 struct cmd_write_reg_bit_field_result *res = parsed_result;
8611 port_reg_bit_field_set(res->port_id, res->reg_off,
8612 res->bit1_pos, res->bit2_pos, res->value);
8615 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8616 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8618 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8619 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8620 regfield, "regfield");
8621 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8622 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8624 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8625 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8627 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8628 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8630 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8631 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8633 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8634 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8637 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8638 .f = cmd_write_reg_bit_field_parsed,
8640 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8642 "Set register bit field between bit_x and bit_y included",
8644 (void *)&cmd_write_reg_bit_field_write,
8645 (void *)&cmd_write_reg_bit_field_regfield,
8646 (void *)&cmd_write_reg_bit_field_port_id,
8647 (void *)&cmd_write_reg_bit_field_reg_off,
8648 (void *)&cmd_write_reg_bit_field_bit1_pos,
8649 (void *)&cmd_write_reg_bit_field_bit2_pos,
8650 (void *)&cmd_write_reg_bit_field_value,
8655 /* *** WRITE PORT REGISTER BIT *** */
8656 struct cmd_write_reg_bit_result {
8657 cmdline_fixed_string_t write;
8658 cmdline_fixed_string_t regbit;
8666 cmd_write_reg_bit_parsed(void *parsed_result,
8667 __rte_unused struct cmdline *cl,
8668 __rte_unused void *data)
8670 struct cmd_write_reg_bit_result *res = parsed_result;
8671 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8674 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8675 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8677 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8678 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8680 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8681 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8683 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8684 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8686 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8687 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8689 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8690 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8693 cmdline_parse_inst_t cmd_write_reg_bit = {
8694 .f = cmd_write_reg_bit_parsed,
8696 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8699 (void *)&cmd_write_reg_bit_write,
8700 (void *)&cmd_write_reg_bit_regbit,
8701 (void *)&cmd_write_reg_bit_port_id,
8702 (void *)&cmd_write_reg_bit_reg_off,
8703 (void *)&cmd_write_reg_bit_bit_pos,
8704 (void *)&cmd_write_reg_bit_value,
8709 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8710 struct cmd_read_rxd_txd_result {
8711 cmdline_fixed_string_t read;
8712 cmdline_fixed_string_t rxd_txd;
8719 cmd_read_rxd_txd_parsed(void *parsed_result,
8720 __rte_unused struct cmdline *cl,
8721 __rte_unused void *data)
8723 struct cmd_read_rxd_txd_result *res = parsed_result;
8725 if (!strcmp(res->rxd_txd, "rxd"))
8726 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8727 else if (!strcmp(res->rxd_txd, "txd"))
8728 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8731 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8732 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8733 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8734 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8736 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8737 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8739 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8740 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8742 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8743 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8746 cmdline_parse_inst_t cmd_read_rxd_txd = {
8747 .f = cmd_read_rxd_txd_parsed,
8749 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8751 (void *)&cmd_read_rxd_txd_read,
8752 (void *)&cmd_read_rxd_txd_rxd_txd,
8753 (void *)&cmd_read_rxd_txd_port_id,
8754 (void *)&cmd_read_rxd_txd_queue_id,
8755 (void *)&cmd_read_rxd_txd_desc_id,
8761 struct cmd_quit_result {
8762 cmdline_fixed_string_t quit;
8765 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8767 __rte_unused void *data)
8772 cmdline_parse_token_string_t cmd_quit_quit =
8773 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8775 cmdline_parse_inst_t cmd_quit = {
8776 .f = cmd_quit_parsed,
8778 .help_str = "quit: Exit application",
8780 (void *)&cmd_quit_quit,
8785 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8786 struct cmd_mac_addr_result {
8787 cmdline_fixed_string_t mac_addr_cmd;
8788 cmdline_fixed_string_t what;
8790 struct rte_ether_addr address;
8793 static void cmd_mac_addr_parsed(void *parsed_result,
8794 __rte_unused struct cmdline *cl,
8795 __rte_unused void *data)
8797 struct cmd_mac_addr_result *res = parsed_result;
8800 if (strcmp(res->what, "add") == 0)
8801 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8802 else if (strcmp(res->what, "set") == 0)
8803 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8806 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8808 /* check the return value and print it if is < 0 */
8810 fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
8814 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8815 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8817 cmdline_parse_token_string_t cmd_mac_addr_what =
8818 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8820 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8821 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8823 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8824 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8826 cmdline_parse_inst_t cmd_mac_addr = {
8827 .f = cmd_mac_addr_parsed,
8829 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8830 "Add/Remove/Set MAC address on port_id",
8832 (void *)&cmd_mac_addr_cmd,
8833 (void *)&cmd_mac_addr_what,
8834 (void *)&cmd_mac_addr_portnum,
8835 (void *)&cmd_mac_addr_addr,
8840 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8841 struct cmd_eth_peer_result {
8842 cmdline_fixed_string_t set;
8843 cmdline_fixed_string_t eth_peer;
8845 cmdline_fixed_string_t peer_addr;
8848 static void cmd_set_eth_peer_parsed(void *parsed_result,
8849 __rte_unused struct cmdline *cl,
8850 __rte_unused void *data)
8852 struct cmd_eth_peer_result *res = parsed_result;
8854 if (test_done == 0) {
8855 fprintf(stderr, "Please stop forwarding first\n");
8858 if (!strcmp(res->eth_peer, "eth-peer")) {
8859 set_fwd_eth_peer(res->port_id, res->peer_addr);
8863 cmdline_parse_token_string_t cmd_eth_peer_set =
8864 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8865 cmdline_parse_token_string_t cmd_eth_peer =
8866 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8867 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8868 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8870 cmdline_parse_token_string_t cmd_eth_peer_addr =
8871 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8873 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8874 .f = cmd_set_eth_peer_parsed,
8876 .help_str = "set eth-peer <port_id> <peer_mac>",
8878 (void *)&cmd_eth_peer_set,
8879 (void *)&cmd_eth_peer,
8880 (void *)&cmd_eth_peer_port_id,
8881 (void *)&cmd_eth_peer_addr,
8886 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8887 struct cmd_set_qmap_result {
8888 cmdline_fixed_string_t set;
8889 cmdline_fixed_string_t qmap;
8890 cmdline_fixed_string_t what;
8897 cmd_set_qmap_parsed(void *parsed_result,
8898 __rte_unused struct cmdline *cl,
8899 __rte_unused void *data)
8901 struct cmd_set_qmap_result *res = parsed_result;
8902 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8904 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8907 cmdline_parse_token_string_t cmd_setqmap_set =
8908 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8910 cmdline_parse_token_string_t cmd_setqmap_qmap =
8911 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8913 cmdline_parse_token_string_t cmd_setqmap_what =
8914 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8916 cmdline_parse_token_num_t cmd_setqmap_portid =
8917 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8918 port_id, RTE_UINT16);
8919 cmdline_parse_token_num_t cmd_setqmap_queueid =
8920 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8921 queue_id, RTE_UINT16);
8922 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8923 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8924 map_value, RTE_UINT8);
8926 cmdline_parse_inst_t cmd_set_qmap = {
8927 .f = cmd_set_qmap_parsed,
8929 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8930 "Set statistics mapping value on tx|rx queue_id of port_id",
8932 (void *)&cmd_setqmap_set,
8933 (void *)&cmd_setqmap_qmap,
8934 (void *)&cmd_setqmap_what,
8935 (void *)&cmd_setqmap_portid,
8936 (void *)&cmd_setqmap_queueid,
8937 (void *)&cmd_setqmap_mapvalue,
8942 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8943 struct cmd_set_xstats_hide_zero_result {
8944 cmdline_fixed_string_t keyword;
8945 cmdline_fixed_string_t name;
8946 cmdline_fixed_string_t on_off;
8950 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8951 __rte_unused struct cmdline *cl,
8952 __rte_unused void *data)
8954 struct cmd_set_xstats_hide_zero_result *res;
8955 uint16_t on_off = 0;
8957 res = parsed_result;
8958 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8959 set_xstats_hide_zero(on_off);
8962 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8963 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8965 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8966 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8967 name, "xstats-hide-zero");
8968 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8969 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8972 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8973 .f = cmd_set_xstats_hide_zero_parsed,
8975 .help_str = "set xstats-hide-zero on|off",
8977 (void *)&cmd_set_xstats_hide_zero_keyword,
8978 (void *)&cmd_set_xstats_hide_zero_name,
8979 (void *)&cmd_set_xstats_hide_zero_on_off,
8984 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8985 struct cmd_set_record_core_cycles_result {
8986 cmdline_fixed_string_t keyword;
8987 cmdline_fixed_string_t name;
8988 cmdline_fixed_string_t on_off;
8992 cmd_set_record_core_cycles_parsed(void *parsed_result,
8993 __rte_unused struct cmdline *cl,
8994 __rte_unused void *data)
8996 struct cmd_set_record_core_cycles_result *res;
8997 uint16_t on_off = 0;
8999 res = parsed_result;
9000 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9001 set_record_core_cycles(on_off);
9004 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
9005 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9007 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
9008 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9009 name, "record-core-cycles");
9010 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
9011 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9014 cmdline_parse_inst_t cmd_set_record_core_cycles = {
9015 .f = cmd_set_record_core_cycles_parsed,
9017 .help_str = "set record-core-cycles on|off",
9019 (void *)&cmd_set_record_core_cycles_keyword,
9020 (void *)&cmd_set_record_core_cycles_name,
9021 (void *)&cmd_set_record_core_cycles_on_off,
9026 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
9027 struct cmd_set_record_burst_stats_result {
9028 cmdline_fixed_string_t keyword;
9029 cmdline_fixed_string_t name;
9030 cmdline_fixed_string_t on_off;
9034 cmd_set_record_burst_stats_parsed(void *parsed_result,
9035 __rte_unused struct cmdline *cl,
9036 __rte_unused void *data)
9038 struct cmd_set_record_burst_stats_result *res;
9039 uint16_t on_off = 0;
9041 res = parsed_result;
9042 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9043 set_record_burst_stats(on_off);
9046 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
9047 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9049 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
9050 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9051 name, "record-burst-stats");
9052 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
9053 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9056 cmdline_parse_inst_t cmd_set_record_burst_stats = {
9057 .f = cmd_set_record_burst_stats_parsed,
9059 .help_str = "set record-burst-stats on|off",
9061 (void *)&cmd_set_record_burst_stats_keyword,
9062 (void *)&cmd_set_record_burst_stats_name,
9063 (void *)&cmd_set_record_burst_stats_on_off,
9068 /* *** CONFIGURE UNICAST HASH TABLE *** */
9069 struct cmd_set_uc_hash_table {
9070 cmdline_fixed_string_t set;
9071 cmdline_fixed_string_t port;
9073 cmdline_fixed_string_t what;
9074 struct rte_ether_addr address;
9075 cmdline_fixed_string_t mode;
9079 cmd_set_uc_hash_parsed(void *parsed_result,
9080 __rte_unused struct cmdline *cl,
9081 __rte_unused void *data)
9084 struct cmd_set_uc_hash_table *res = parsed_result;
9086 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9088 if (strcmp(res->what, "uta") == 0)
9089 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
9090 &res->address,(uint8_t)is_on);
9093 "bad unicast hash table parameter, return code = %d\n",
9098 cmdline_parse_token_string_t cmd_set_uc_hash_set =
9099 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9101 cmdline_parse_token_string_t cmd_set_uc_hash_port =
9102 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9104 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
9105 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
9106 port_id, RTE_UINT16);
9107 cmdline_parse_token_string_t cmd_set_uc_hash_what =
9108 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9110 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
9111 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
9113 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
9114 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9117 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
9118 .f = cmd_set_uc_hash_parsed,
9120 .help_str = "set port <port_id> uta <mac_addr> on|off)",
9122 (void *)&cmd_set_uc_hash_set,
9123 (void *)&cmd_set_uc_hash_port,
9124 (void *)&cmd_set_uc_hash_portid,
9125 (void *)&cmd_set_uc_hash_what,
9126 (void *)&cmd_set_uc_hash_mac,
9127 (void *)&cmd_set_uc_hash_mode,
9132 struct cmd_set_uc_all_hash_table {
9133 cmdline_fixed_string_t set;
9134 cmdline_fixed_string_t port;
9136 cmdline_fixed_string_t what;
9137 cmdline_fixed_string_t value;
9138 cmdline_fixed_string_t mode;
9142 cmd_set_uc_all_hash_parsed(void *parsed_result,
9143 __rte_unused struct cmdline *cl,
9144 __rte_unused void *data)
9147 struct cmd_set_uc_all_hash_table *res = parsed_result;
9149 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9151 if ((strcmp(res->what, "uta") == 0) &&
9152 (strcmp(res->value, "all") == 0))
9153 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
9156 "bad unicast hash table parameter, return code = %d\n",
9160 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
9161 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9163 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
9164 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9166 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
9167 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
9168 port_id, RTE_UINT16);
9169 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
9170 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9172 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
9173 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9175 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
9176 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9179 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
9180 .f = cmd_set_uc_all_hash_parsed,
9182 .help_str = "set port <port_id> uta all on|off",
9184 (void *)&cmd_set_uc_all_hash_set,
9185 (void *)&cmd_set_uc_all_hash_port,
9186 (void *)&cmd_set_uc_all_hash_portid,
9187 (void *)&cmd_set_uc_all_hash_what,
9188 (void *)&cmd_set_uc_all_hash_value,
9189 (void *)&cmd_set_uc_all_hash_mode,
9194 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
9195 struct cmd_set_vf_traffic {
9196 cmdline_fixed_string_t set;
9197 cmdline_fixed_string_t port;
9199 cmdline_fixed_string_t vf;
9201 cmdline_fixed_string_t what;
9202 cmdline_fixed_string_t mode;
9206 cmd_set_vf_traffic_parsed(void *parsed_result,
9207 __rte_unused struct cmdline *cl,
9208 __rte_unused void *data)
9210 struct cmd_set_vf_traffic *res = parsed_result;
9211 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
9212 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9214 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
9217 cmdline_parse_token_string_t cmd_setvf_traffic_set =
9218 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9220 cmdline_parse_token_string_t cmd_setvf_traffic_port =
9221 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9223 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
9224 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9225 port_id, RTE_UINT16);
9226 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
9227 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9229 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
9230 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9232 cmdline_parse_token_string_t cmd_setvf_traffic_what =
9233 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9235 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
9236 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9239 cmdline_parse_inst_t cmd_set_vf_traffic = {
9240 .f = cmd_set_vf_traffic_parsed,
9242 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
9244 (void *)&cmd_setvf_traffic_set,
9245 (void *)&cmd_setvf_traffic_port,
9246 (void *)&cmd_setvf_traffic_portid,
9247 (void *)&cmd_setvf_traffic_vf,
9248 (void *)&cmd_setvf_traffic_vfid,
9249 (void *)&cmd_setvf_traffic_what,
9250 (void *)&cmd_setvf_traffic_mode,
9255 /* *** CONFIGURE VF RECEIVE MODE *** */
9256 struct cmd_set_vf_rxmode {
9257 cmdline_fixed_string_t set;
9258 cmdline_fixed_string_t port;
9260 cmdline_fixed_string_t vf;
9262 cmdline_fixed_string_t what;
9263 cmdline_fixed_string_t mode;
9264 cmdline_fixed_string_t on;
9268 cmd_set_vf_rxmode_parsed(void *parsed_result,
9269 __rte_unused struct cmdline *cl,
9270 __rte_unused void *data)
9273 uint16_t vf_rxmode = 0;
9274 struct cmd_set_vf_rxmode *res = parsed_result;
9276 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
9277 if (!strcmp(res->what,"rxmode")) {
9278 if (!strcmp(res->mode, "AUPE"))
9279 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_UNTAG;
9280 else if (!strcmp(res->mode, "ROPE"))
9281 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_HASH_UC;
9282 else if (!strcmp(res->mode, "BAM"))
9283 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_BROADCAST;
9284 else if (!strncmp(res->mode, "MPE",3))
9285 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_MULTICAST;
9288 RTE_SET_USED(is_on);
9290 #ifdef RTE_NET_IXGBE
9291 if (ret == -ENOTSUP)
9292 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
9293 vf_rxmode, (uint8_t)is_on);
9296 if (ret == -ENOTSUP)
9297 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
9298 vf_rxmode, (uint8_t)is_on);
9302 "bad VF receive mode parameter, return code = %d\n",
9306 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
9307 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9309 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
9310 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9312 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
9313 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9314 port_id, RTE_UINT16);
9315 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
9316 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9318 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
9319 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9321 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
9322 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9324 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
9325 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9326 mode, "AUPE#ROPE#BAM#MPE");
9327 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
9328 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9331 cmdline_parse_inst_t cmd_set_vf_rxmode = {
9332 .f = cmd_set_vf_rxmode_parsed,
9334 .help_str = "set port <port_id> vf <vf_id> rxmode "
9335 "AUPE|ROPE|BAM|MPE on|off",
9337 (void *)&cmd_set_vf_rxmode_set,
9338 (void *)&cmd_set_vf_rxmode_port,
9339 (void *)&cmd_set_vf_rxmode_portid,
9340 (void *)&cmd_set_vf_rxmode_vf,
9341 (void *)&cmd_set_vf_rxmode_vfid,
9342 (void *)&cmd_set_vf_rxmode_what,
9343 (void *)&cmd_set_vf_rxmode_mode,
9344 (void *)&cmd_set_vf_rxmode_on,
9349 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
9350 struct cmd_vf_mac_addr_result {
9351 cmdline_fixed_string_t mac_addr_cmd;
9352 cmdline_fixed_string_t what;
9353 cmdline_fixed_string_t port;
9355 cmdline_fixed_string_t vf;
9357 struct rte_ether_addr address;
9360 static void cmd_vf_mac_addr_parsed(void *parsed_result,
9361 __rte_unused struct cmdline *cl,
9362 __rte_unused void *data)
9364 struct cmd_vf_mac_addr_result *res = parsed_result;
9367 if (strcmp(res->what, "add") != 0)
9371 if (ret == -ENOTSUP)
9372 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
9376 if (ret == -ENOTSUP)
9377 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
9382 fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
9386 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
9387 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9388 mac_addr_cmd,"mac_addr");
9389 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
9390 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9392 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
9393 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9395 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
9396 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9397 port_num, RTE_UINT16);
9398 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
9399 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9401 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
9402 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9404 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
9405 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
9408 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
9409 .f = cmd_vf_mac_addr_parsed,
9411 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
9412 "Add MAC address filtering for a VF on port_id",
9414 (void *)&cmd_vf_mac_addr_cmd,
9415 (void *)&cmd_vf_mac_addr_what,
9416 (void *)&cmd_vf_mac_addr_port,
9417 (void *)&cmd_vf_mac_addr_portnum,
9418 (void *)&cmd_vf_mac_addr_vf,
9419 (void *)&cmd_vf_mac_addr_vfnum,
9420 (void *)&cmd_vf_mac_addr_addr,
9425 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
9426 struct cmd_vf_rx_vlan_filter {
9427 cmdline_fixed_string_t rx_vlan;
9428 cmdline_fixed_string_t what;
9430 cmdline_fixed_string_t port;
9432 cmdline_fixed_string_t vf;
9437 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
9438 __rte_unused struct cmdline *cl,
9439 __rte_unused void *data)
9441 struct cmd_vf_rx_vlan_filter *res = parsed_result;
9444 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9446 #ifdef RTE_NET_IXGBE
9447 if (ret == -ENOTSUP)
9448 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9449 res->vlan_id, res->vf_mask, is_add);
9452 if (ret == -ENOTSUP)
9453 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9454 res->vlan_id, res->vf_mask, is_add);
9457 if (ret == -ENOTSUP)
9458 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9459 res->vlan_id, res->vf_mask, is_add);
9466 fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
9467 res->vlan_id, res->vf_mask);
9470 fprintf(stderr, "invalid port_id %d\n", res->port_id);
9473 fprintf(stderr, "function not implemented or supported\n");
9476 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9480 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9481 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9482 rx_vlan, "rx_vlan");
9483 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9484 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9486 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9487 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9488 vlan_id, RTE_UINT16);
9489 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9490 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9492 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9493 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9494 port_id, RTE_UINT16);
9495 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9496 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9498 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9499 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9500 vf_mask, RTE_UINT64);
9502 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9503 .f = cmd_vf_rx_vlan_filter_parsed,
9505 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9506 "(vf_mask = hexadecimal VF mask)",
9508 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9509 (void *)&cmd_vf_rx_vlan_filter_what,
9510 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9511 (void *)&cmd_vf_rx_vlan_filter_port,
9512 (void *)&cmd_vf_rx_vlan_filter_portid,
9513 (void *)&cmd_vf_rx_vlan_filter_vf,
9514 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9519 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9520 struct cmd_queue_rate_limit_result {
9521 cmdline_fixed_string_t set;
9522 cmdline_fixed_string_t port;
9524 cmdline_fixed_string_t queue;
9526 cmdline_fixed_string_t rate;
9530 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9531 __rte_unused struct cmdline *cl,
9532 __rte_unused void *data)
9534 struct cmd_queue_rate_limit_result *res = parsed_result;
9537 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9538 && (strcmp(res->queue, "queue") == 0)
9539 && (strcmp(res->rate, "rate") == 0))
9540 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9543 fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
9548 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9549 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9551 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9552 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9554 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9555 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9556 port_num, RTE_UINT16);
9557 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9558 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9560 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9561 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9562 queue_num, RTE_UINT8);
9563 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9564 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9566 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9567 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9568 rate_num, RTE_UINT16);
9570 cmdline_parse_inst_t cmd_queue_rate_limit = {
9571 .f = cmd_queue_rate_limit_parsed,
9573 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9574 "Set rate limit for a queue on port_id",
9576 (void *)&cmd_queue_rate_limit_set,
9577 (void *)&cmd_queue_rate_limit_port,
9578 (void *)&cmd_queue_rate_limit_portnum,
9579 (void *)&cmd_queue_rate_limit_queue,
9580 (void *)&cmd_queue_rate_limit_queuenum,
9581 (void *)&cmd_queue_rate_limit_rate,
9582 (void *)&cmd_queue_rate_limit_ratenum,
9587 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9588 struct cmd_vf_rate_limit_result {
9589 cmdline_fixed_string_t set;
9590 cmdline_fixed_string_t port;
9592 cmdline_fixed_string_t vf;
9594 cmdline_fixed_string_t rate;
9596 cmdline_fixed_string_t q_msk;
9600 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9601 __rte_unused struct cmdline *cl,
9602 __rte_unused void *data)
9604 struct cmd_vf_rate_limit_result *res = parsed_result;
9607 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9608 && (strcmp(res->vf, "vf") == 0)
9609 && (strcmp(res->rate, "rate") == 0)
9610 && (strcmp(res->q_msk, "queue_mask") == 0))
9611 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9612 res->rate_num, res->q_msk_val);
9614 fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
9619 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9620 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9622 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9623 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9625 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9626 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9627 port_num, RTE_UINT16);
9628 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9629 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9631 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9632 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9634 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9635 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9637 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9638 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9639 rate_num, RTE_UINT16);
9640 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9641 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9642 q_msk, "queue_mask");
9643 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9644 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9645 q_msk_val, RTE_UINT64);
9647 cmdline_parse_inst_t cmd_vf_rate_limit = {
9648 .f = cmd_vf_rate_limit_parsed,
9650 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9651 "queue_mask <queue_mask_value>: "
9652 "Set rate limit for queues of VF on port_id",
9654 (void *)&cmd_vf_rate_limit_set,
9655 (void *)&cmd_vf_rate_limit_port,
9656 (void *)&cmd_vf_rate_limit_portnum,
9657 (void *)&cmd_vf_rate_limit_vf,
9658 (void *)&cmd_vf_rate_limit_vfnum,
9659 (void *)&cmd_vf_rate_limit_rate,
9660 (void *)&cmd_vf_rate_limit_ratenum,
9661 (void *)&cmd_vf_rate_limit_q_msk,
9662 (void *)&cmd_vf_rate_limit_q_msk_val,
9667 /* *** CONFIGURE TUNNEL UDP PORT *** */
9668 struct cmd_tunnel_udp_config {
9669 cmdline_fixed_string_t rx_vxlan_port;
9670 cmdline_fixed_string_t what;
9676 cmd_tunnel_udp_config_parsed(void *parsed_result,
9677 __rte_unused struct cmdline *cl,
9678 __rte_unused void *data)
9680 struct cmd_tunnel_udp_config *res = parsed_result;
9681 struct rte_eth_udp_tunnel tunnel_udp;
9684 tunnel_udp.udp_port = res->udp_port;
9685 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9687 if (!strcmp(res->what, "add"))
9688 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9691 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9695 fprintf(stderr, "udp tunneling add error: (%s)\n",
9699 cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9700 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9701 rx_vxlan_port, "rx_vxlan_port");
9702 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9703 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9705 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9706 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9707 udp_port, RTE_UINT16);
9708 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9709 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9710 port_id, RTE_UINT16);
9712 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9713 .f = cmd_tunnel_udp_config_parsed,
9715 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9716 "Add/Remove a tunneling UDP port filter",
9718 (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9719 (void *)&cmd_tunnel_udp_config_what,
9720 (void *)&cmd_tunnel_udp_config_udp_port,
9721 (void *)&cmd_tunnel_udp_config_port_id,
9726 struct cmd_config_tunnel_udp_port {
9727 cmdline_fixed_string_t port;
9728 cmdline_fixed_string_t config;
9730 cmdline_fixed_string_t udp_tunnel_port;
9731 cmdline_fixed_string_t action;
9732 cmdline_fixed_string_t tunnel_type;
9737 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9738 __rte_unused struct cmdline *cl,
9739 __rte_unused void *data)
9741 struct cmd_config_tunnel_udp_port *res = parsed_result;
9742 struct rte_eth_udp_tunnel tunnel_udp;
9745 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9748 tunnel_udp.udp_port = res->udp_port;
9750 if (!strcmp(res->tunnel_type, "vxlan")) {
9751 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9752 } else if (!strcmp(res->tunnel_type, "geneve")) {
9753 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_GENEVE;
9754 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9755 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN_GPE;
9756 } else if (!strcmp(res->tunnel_type, "ecpri")) {
9757 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_ECPRI;
9759 fprintf(stderr, "Invalid tunnel type\n");
9763 if (!strcmp(res->action, "add"))
9764 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9767 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9771 fprintf(stderr, "udp tunneling port add error: (%s)\n",
9775 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9776 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9778 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9779 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9781 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9782 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9784 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9785 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9788 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9789 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9791 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9792 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9793 "vxlan#geneve#vxlan-gpe#ecpri");
9794 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9795 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9798 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9799 .f = cmd_cfg_tunnel_udp_port_parsed,
9801 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9802 "geneve|vxlan-gpe|ecpri <udp_port>",
9804 (void *)&cmd_config_tunnel_udp_port_port,
9805 (void *)&cmd_config_tunnel_udp_port_config,
9806 (void *)&cmd_config_tunnel_udp_port_port_id,
9807 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9808 (void *)&cmd_config_tunnel_udp_port_action,
9809 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9810 (void *)&cmd_config_tunnel_udp_port_value,
9815 /* ******************************************************************************** */
9817 struct cmd_dump_result {
9818 cmdline_fixed_string_t dump;
9822 dump_struct_sizes(void)
9824 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9825 DUMP_SIZE(struct rte_mbuf);
9826 DUMP_SIZE(struct rte_mempool);
9827 DUMP_SIZE(struct rte_ring);
9832 /* Dump the socket memory statistics on console */
9834 dump_socket_mem(FILE *f)
9836 struct rte_malloc_socket_stats socket_stats;
9841 unsigned int n_alloc = 0;
9842 unsigned int n_free = 0;
9843 static size_t last_allocs;
9844 static size_t last_total;
9847 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9848 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9849 !socket_stats.heap_totalsz_bytes)
9851 total += socket_stats.heap_totalsz_bytes;
9852 alloc += socket_stats.heap_allocsz_bytes;
9853 free += socket_stats.heap_freesz_bytes;
9854 n_alloc += socket_stats.alloc_count;
9855 n_free += socket_stats.free_count;
9857 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9859 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9860 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9861 (double)socket_stats.heap_allocsz_bytes * 100 /
9862 (double)socket_stats.heap_totalsz_bytes,
9863 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9864 socket_stats.alloc_count,
9865 socket_stats.free_count);
9868 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9869 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9870 total ? ((double)alloc * 100 / (double)total) : 0,
9871 (double)free / (1024 * 1024),
9874 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9875 ((double)total - (double)last_total) / (1024 * 1024),
9876 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9877 last_allocs = alloc;
9881 static void cmd_dump_parsed(void *parsed_result,
9882 __rte_unused struct cmdline *cl,
9883 __rte_unused void *data)
9885 struct cmd_dump_result *res = parsed_result;
9887 if (!strcmp(res->dump, "dump_physmem"))
9888 rte_dump_physmem_layout(stdout);
9889 else if (!strcmp(res->dump, "dump_socket_mem"))
9890 dump_socket_mem(stdout);
9891 else if (!strcmp(res->dump, "dump_memzone"))
9892 rte_memzone_dump(stdout);
9893 else if (!strcmp(res->dump, "dump_struct_sizes"))
9894 dump_struct_sizes();
9895 else if (!strcmp(res->dump, "dump_ring"))
9896 rte_ring_list_dump(stdout);
9897 else if (!strcmp(res->dump, "dump_mempool"))
9898 rte_mempool_list_dump(stdout);
9899 else if (!strcmp(res->dump, "dump_devargs"))
9900 rte_devargs_dump(stdout);
9901 else if (!strcmp(res->dump, "dump_log_types"))
9902 rte_log_dump(stdout);
9905 cmdline_parse_token_string_t cmd_dump_dump =
9906 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9910 "dump_struct_sizes#"
9916 cmdline_parse_inst_t cmd_dump = {
9917 .f = cmd_dump_parsed, /* function to call */
9918 .data = NULL, /* 2nd arg of func */
9919 .help_str = "Dump status",
9920 .tokens = { /* token list, NULL terminated */
9921 (void *)&cmd_dump_dump,
9926 /* ******************************************************************************** */
9928 struct cmd_dump_one_result {
9929 cmdline_fixed_string_t dump;
9930 cmdline_fixed_string_t name;
9933 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9934 __rte_unused void *data)
9936 struct cmd_dump_one_result *res = parsed_result;
9938 if (!strcmp(res->dump, "dump_ring")) {
9940 r = rte_ring_lookup(res->name);
9942 cmdline_printf(cl, "Cannot find ring\n");
9945 rte_ring_dump(stdout, r);
9946 } else if (!strcmp(res->dump, "dump_mempool")) {
9947 struct rte_mempool *mp;
9948 mp = rte_mempool_lookup(res->name);
9950 cmdline_printf(cl, "Cannot find mempool\n");
9953 rte_mempool_dump(stdout, mp);
9957 cmdline_parse_token_string_t cmd_dump_one_dump =
9958 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9959 "dump_ring#dump_mempool");
9961 cmdline_parse_token_string_t cmd_dump_one_name =
9962 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9964 cmdline_parse_inst_t cmd_dump_one = {
9965 .f = cmd_dump_one_parsed, /* function to call */
9966 .data = NULL, /* 2nd arg of func */
9967 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9968 .tokens = { /* token list, NULL terminated */
9969 (void *)&cmd_dump_one_dump,
9970 (void *)&cmd_dump_one_name,
9975 /* *** queue region set *** */
9976 struct cmd_queue_region_result {
9977 cmdline_fixed_string_t set;
9978 cmdline_fixed_string_t port;
9980 cmdline_fixed_string_t cmd;
9981 cmdline_fixed_string_t region;
9983 cmdline_fixed_string_t queue_start_index;
9985 cmdline_fixed_string_t queue_num;
9986 uint8_t queue_num_value;
9990 cmd_queue_region_parsed(void *parsed_result,
9991 __rte_unused struct cmdline *cl,
9992 __rte_unused void *data)
9994 struct cmd_queue_region_result *res = parsed_result;
9997 struct rte_pmd_i40e_queue_region_conf region_conf;
9998 enum rte_pmd_i40e_queue_region_op op_type;
10001 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10004 #ifdef RTE_NET_I40E
10005 memset(®ion_conf, 0, sizeof(region_conf));
10006 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
10007 region_conf.region_id = res->region_id;
10008 region_conf.queue_num = res->queue_num_value;
10009 region_conf.queue_start_index = res->queue_id;
10011 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10012 op_type, ®ion_conf);
10019 fprintf(stderr, "function not implemented or supported\n");
10022 fprintf(stderr, "queue region config error: (%s)\n",
10027 cmdline_parse_token_string_t cmd_queue_region_set =
10028 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10030 cmdline_parse_token_string_t cmd_queue_region_port =
10031 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
10032 cmdline_parse_token_num_t cmd_queue_region_port_id =
10033 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10034 port_id, RTE_UINT16);
10035 cmdline_parse_token_string_t cmd_queue_region_cmd =
10036 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10037 cmd, "queue-region");
10038 cmdline_parse_token_string_t cmd_queue_region_id =
10039 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10040 region, "region_id");
10041 cmdline_parse_token_num_t cmd_queue_region_index =
10042 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10043 region_id, RTE_UINT8);
10044 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
10045 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10046 queue_start_index, "queue_start_index");
10047 cmdline_parse_token_num_t cmd_queue_region_queue_id =
10048 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10049 queue_id, RTE_UINT8);
10050 cmdline_parse_token_string_t cmd_queue_region_queue_num =
10051 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10052 queue_num, "queue_num");
10053 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
10054 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10055 queue_num_value, RTE_UINT8);
10057 cmdline_parse_inst_t cmd_queue_region = {
10058 .f = cmd_queue_region_parsed,
10060 .help_str = "set port <port_id> queue-region region_id <value> "
10061 "queue_start_index <value> queue_num <value>: Set a queue region",
10063 (void *)&cmd_queue_region_set,
10064 (void *)&cmd_queue_region_port,
10065 (void *)&cmd_queue_region_port_id,
10066 (void *)&cmd_queue_region_cmd,
10067 (void *)&cmd_queue_region_id,
10068 (void *)&cmd_queue_region_index,
10069 (void *)&cmd_queue_region_queue_start_index,
10070 (void *)&cmd_queue_region_queue_id,
10071 (void *)&cmd_queue_region_queue_num,
10072 (void *)&cmd_queue_region_queue_num_value,
10077 /* *** queue region and flowtype set *** */
10078 struct cmd_region_flowtype_result {
10079 cmdline_fixed_string_t set;
10080 cmdline_fixed_string_t port;
10082 cmdline_fixed_string_t cmd;
10083 cmdline_fixed_string_t region;
10085 cmdline_fixed_string_t flowtype;
10086 uint8_t flowtype_id;
10090 cmd_region_flowtype_parsed(void *parsed_result,
10091 __rte_unused struct cmdline *cl,
10092 __rte_unused void *data)
10094 struct cmd_region_flowtype_result *res = parsed_result;
10095 int ret = -ENOTSUP;
10096 #ifdef RTE_NET_I40E
10097 struct rte_pmd_i40e_queue_region_conf region_conf;
10098 enum rte_pmd_i40e_queue_region_op op_type;
10101 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10104 #ifdef RTE_NET_I40E
10105 memset(®ion_conf, 0, sizeof(region_conf));
10107 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10108 region_conf.region_id = res->region_id;
10109 region_conf.hw_flowtype = res->flowtype_id;
10111 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10112 op_type, ®ion_conf);
10119 fprintf(stderr, "function not implemented or supported\n");
10122 fprintf(stderr, "region flowtype config error: (%s)\n",
10127 cmdline_parse_token_string_t cmd_region_flowtype_set =
10128 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10130 cmdline_parse_token_string_t cmd_region_flowtype_port =
10131 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10133 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10134 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10135 port_id, RTE_UINT16);
10136 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10137 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10138 cmd, "queue-region");
10139 cmdline_parse_token_string_t cmd_region_flowtype_index =
10140 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10141 region, "region_id");
10142 cmdline_parse_token_num_t cmd_region_flowtype_id =
10143 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10144 region_id, RTE_UINT8);
10145 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10146 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10147 flowtype, "flowtype");
10148 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10149 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10150 flowtype_id, RTE_UINT8);
10151 cmdline_parse_inst_t cmd_region_flowtype = {
10152 .f = cmd_region_flowtype_parsed,
10154 .help_str = "set port <port_id> queue-region region_id <value> "
10155 "flowtype <value>: Set a flowtype region index",
10157 (void *)&cmd_region_flowtype_set,
10158 (void *)&cmd_region_flowtype_port,
10159 (void *)&cmd_region_flowtype_port_index,
10160 (void *)&cmd_region_flowtype_cmd,
10161 (void *)&cmd_region_flowtype_index,
10162 (void *)&cmd_region_flowtype_id,
10163 (void *)&cmd_region_flowtype_flow_index,
10164 (void *)&cmd_region_flowtype_flow_id,
10169 /* *** User Priority (UP) to queue region (region_id) set *** */
10170 struct cmd_user_priority_region_result {
10171 cmdline_fixed_string_t set;
10172 cmdline_fixed_string_t port;
10174 cmdline_fixed_string_t cmd;
10175 cmdline_fixed_string_t user_priority;
10176 uint8_t user_priority_id;
10177 cmdline_fixed_string_t region;
10182 cmd_user_priority_region_parsed(void *parsed_result,
10183 __rte_unused struct cmdline *cl,
10184 __rte_unused void *data)
10186 struct cmd_user_priority_region_result *res = parsed_result;
10187 int ret = -ENOTSUP;
10188 #ifdef RTE_NET_I40E
10189 struct rte_pmd_i40e_queue_region_conf region_conf;
10190 enum rte_pmd_i40e_queue_region_op op_type;
10193 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10196 #ifdef RTE_NET_I40E
10197 memset(®ion_conf, 0, sizeof(region_conf));
10198 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10199 region_conf.user_priority = res->user_priority_id;
10200 region_conf.region_id = res->region_id;
10202 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10203 op_type, ®ion_conf);
10210 fprintf(stderr, "function not implemented or supported\n");
10213 fprintf(stderr, "user_priority region config error: (%s)\n",
10218 cmdline_parse_token_string_t cmd_user_priority_region_set =
10219 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10221 cmdline_parse_token_string_t cmd_user_priority_region_port =
10222 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10224 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10225 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10226 port_id, RTE_UINT16);
10227 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10228 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10229 cmd, "queue-region");
10230 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10231 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10232 user_priority, "UP");
10233 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10234 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10235 user_priority_id, RTE_UINT8);
10236 cmdline_parse_token_string_t cmd_user_priority_region_region =
10237 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10238 region, "region_id");
10239 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10240 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10241 region_id, RTE_UINT8);
10243 cmdline_parse_inst_t cmd_user_priority_region = {
10244 .f = cmd_user_priority_region_parsed,
10246 .help_str = "set port <port_id> queue-region UP <value> "
10247 "region_id <value>: Set the mapping of User Priority (UP) "
10248 "to queue region (region_id) ",
10250 (void *)&cmd_user_priority_region_set,
10251 (void *)&cmd_user_priority_region_port,
10252 (void *)&cmd_user_priority_region_port_index,
10253 (void *)&cmd_user_priority_region_cmd,
10254 (void *)&cmd_user_priority_region_UP,
10255 (void *)&cmd_user_priority_region_UP_id,
10256 (void *)&cmd_user_priority_region_region,
10257 (void *)&cmd_user_priority_region_region_id,
10262 /* *** flush all queue region related configuration *** */
10263 struct cmd_flush_queue_region_result {
10264 cmdline_fixed_string_t set;
10265 cmdline_fixed_string_t port;
10267 cmdline_fixed_string_t cmd;
10268 cmdline_fixed_string_t flush;
10269 cmdline_fixed_string_t what;
10273 cmd_flush_queue_region_parsed(void *parsed_result,
10274 __rte_unused struct cmdline *cl,
10275 __rte_unused void *data)
10277 struct cmd_flush_queue_region_result *res = parsed_result;
10278 int ret = -ENOTSUP;
10279 #ifdef RTE_NET_I40E
10280 struct rte_pmd_i40e_queue_region_conf region_conf;
10281 enum rte_pmd_i40e_queue_region_op op_type;
10284 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10287 #ifdef RTE_NET_I40E
10288 memset(®ion_conf, 0, sizeof(region_conf));
10290 if (strcmp(res->what, "on") == 0)
10291 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10293 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10295 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10296 op_type, ®ion_conf);
10303 fprintf(stderr, "function not implemented or supported\n");
10306 fprintf(stderr, "queue region config flush error: (%s)\n",
10311 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10312 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10314 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10315 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10317 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10318 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10319 port_id, RTE_UINT16);
10320 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10321 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10322 cmd, "queue-region");
10323 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10324 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10326 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10327 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10330 cmdline_parse_inst_t cmd_flush_queue_region = {
10331 .f = cmd_flush_queue_region_parsed,
10333 .help_str = "set port <port_id> queue-region flush on|off"
10334 ": flush all queue region related configuration",
10336 (void *)&cmd_flush_queue_region_set,
10337 (void *)&cmd_flush_queue_region_port,
10338 (void *)&cmd_flush_queue_region_port_index,
10339 (void *)&cmd_flush_queue_region_cmd,
10340 (void *)&cmd_flush_queue_region_flush,
10341 (void *)&cmd_flush_queue_region_what,
10346 /* *** get all queue region related configuration info *** */
10347 struct cmd_show_queue_region_info {
10348 cmdline_fixed_string_t show;
10349 cmdline_fixed_string_t port;
10351 cmdline_fixed_string_t cmd;
10355 cmd_show_queue_region_info_parsed(void *parsed_result,
10356 __rte_unused struct cmdline *cl,
10357 __rte_unused void *data)
10359 struct cmd_show_queue_region_info *res = parsed_result;
10360 int ret = -ENOTSUP;
10361 #ifdef RTE_NET_I40E
10362 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10363 enum rte_pmd_i40e_queue_region_op op_type;
10366 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10369 #ifdef RTE_NET_I40E
10370 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10372 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10374 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10375 op_type, &rte_pmd_regions);
10377 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10384 fprintf(stderr, "function not implemented or supported\n");
10387 fprintf(stderr, "queue region config info show error: (%s)\n",
10392 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10393 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10395 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10396 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10398 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10399 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10400 port_id, RTE_UINT16);
10401 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10402 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10403 cmd, "queue-region");
10405 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10406 .f = cmd_show_queue_region_info_parsed,
10408 .help_str = "show port <port_id> queue-region"
10409 ": show all queue region related configuration info",
10411 (void *)&cmd_show_queue_region_info_get,
10412 (void *)&cmd_show_queue_region_info_port,
10413 (void *)&cmd_show_queue_region_info_port_index,
10414 (void *)&cmd_show_queue_region_info_cmd,
10419 /* *** Filters Control *** */
10421 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10423 if ((ip_addr).family == AF_INET) \
10424 (ip) = (ip_addr).addr.ipv4.s_addr; \
10426 fprintf(stderr, "invalid parameter.\n"); \
10431 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10433 if ((ip_addr).family == AF_INET6) \
10434 rte_memcpy(&(ip), \
10435 &((ip_addr).addr.ipv6), \
10436 sizeof(struct in6_addr)); \
10438 fprintf(stderr, "invalid parameter.\n"); \
10443 #ifdef RTE_NET_I40E
10446 str2flowtype(char *string)
10449 static const struct {
10452 } flowtype_str[] = {
10453 {"raw", RTE_ETH_FLOW_RAW},
10454 {"ipv4", RTE_ETH_FLOW_IPV4},
10455 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10456 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10457 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10458 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10459 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10460 {"ipv6", RTE_ETH_FLOW_IPV6},
10461 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10462 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10463 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10464 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10465 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10466 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10467 {"ipv6-ex", RTE_ETH_FLOW_IPV6_EX},
10468 {"ipv6-tcp-ex", RTE_ETH_FLOW_IPV6_TCP_EX},
10469 {"ipv6-udp-ex", RTE_ETH_FLOW_IPV6_UDP_EX},
10470 {"gtpu", RTE_ETH_FLOW_GTPU},
10473 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10474 if (!strcmp(flowtype_str[i].str, string))
10475 return flowtype_str[i].type;
10478 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10479 return (uint16_t)atoi(string);
10481 return RTE_ETH_FLOW_UNKNOWN;
10484 /* *** deal with flow director filter *** */
10485 struct cmd_flow_director_result {
10486 cmdline_fixed_string_t flow_director_filter;
10488 cmdline_fixed_string_t mode;
10489 cmdline_fixed_string_t mode_value;
10490 cmdline_fixed_string_t ops;
10491 cmdline_fixed_string_t flow;
10492 cmdline_fixed_string_t flow_type;
10493 cmdline_fixed_string_t drop;
10494 cmdline_fixed_string_t queue;
10496 cmdline_fixed_string_t fd_id;
10497 uint32_t fd_id_value;
10498 cmdline_fixed_string_t packet;
10503 cmd_flow_director_filter_parsed(void *parsed_result,
10504 __rte_unused struct cmdline *cl,
10505 __rte_unused void *data)
10507 struct cmd_flow_director_result *res = parsed_result;
10509 struct rte_pmd_i40e_flow_type_mapping
10510 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10511 struct rte_pmd_i40e_pkt_template_conf conf;
10512 uint16_t flow_type = str2flowtype(res->flow_type);
10513 uint16_t i, port = res->port_id;
10516 memset(&conf, 0, sizeof(conf));
10518 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10519 fprintf(stderr, "Invalid flow type specified.\n");
10522 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10526 if (mapping[flow_type].pctype == 0ULL) {
10527 fprintf(stderr, "Invalid flow type specified.\n");
10530 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10531 if (mapping[flow_type].pctype & (1ULL << i)) {
10532 conf.input.pctype = i;
10537 conf.input.packet = open_file(res->filepath,
10538 &conf.input.length);
10539 if (!conf.input.packet)
10541 if (!strcmp(res->drop, "drop"))
10542 conf.action.behavior =
10543 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10545 conf.action.behavior =
10546 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10547 conf.action.report_status =
10548 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10549 conf.action.rx_queue = res->queue_id;
10550 conf.soft_id = res->fd_id_value;
10551 add = strcmp(res->ops, "del") ? 1 : 0;
10552 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10556 fprintf(stderr, "flow director config error: (%s)\n",
10558 close_file(conf.input.packet);
10561 cmdline_parse_token_string_t cmd_flow_director_filter =
10562 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10563 flow_director_filter, "flow_director_filter");
10564 cmdline_parse_token_num_t cmd_flow_director_port_id =
10565 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10566 port_id, RTE_UINT16);
10567 cmdline_parse_token_string_t cmd_flow_director_ops =
10568 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10569 ops, "add#del#update");
10570 cmdline_parse_token_string_t cmd_flow_director_flow =
10571 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10573 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10574 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10576 cmdline_parse_token_string_t cmd_flow_director_drop =
10577 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10579 cmdline_parse_token_string_t cmd_flow_director_queue =
10580 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10582 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10583 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10584 queue_id, RTE_UINT16);
10585 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10586 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10588 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10589 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10590 fd_id_value, RTE_UINT32);
10592 cmdline_parse_token_string_t cmd_flow_director_mode =
10593 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10595 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10596 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10597 mode_value, "raw");
10598 cmdline_parse_token_string_t cmd_flow_director_packet =
10599 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10601 cmdline_parse_token_string_t cmd_flow_director_filepath =
10602 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10605 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10606 .f = cmd_flow_director_filter_parsed,
10608 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10609 "director entry on NIC",
10611 (void *)&cmd_flow_director_filter,
10612 (void *)&cmd_flow_director_port_id,
10613 (void *)&cmd_flow_director_mode,
10614 (void *)&cmd_flow_director_mode_raw,
10615 (void *)&cmd_flow_director_ops,
10616 (void *)&cmd_flow_director_flow,
10617 (void *)&cmd_flow_director_flow_type,
10618 (void *)&cmd_flow_director_drop,
10619 (void *)&cmd_flow_director_queue,
10620 (void *)&cmd_flow_director_queue_id,
10621 (void *)&cmd_flow_director_fd_id,
10622 (void *)&cmd_flow_director_fd_id_value,
10623 (void *)&cmd_flow_director_packet,
10624 (void *)&cmd_flow_director_filepath,
10629 #endif /* RTE_NET_I40E */
10631 /* *** deal with flow director mask *** */
10632 struct cmd_flow_director_mask_result {
10633 cmdline_fixed_string_t flow_director_mask;
10635 cmdline_fixed_string_t mode;
10636 cmdline_fixed_string_t mode_value;
10637 cmdline_fixed_string_t vlan;
10638 uint16_t vlan_mask;
10639 cmdline_fixed_string_t src_mask;
10640 cmdline_ipaddr_t ipv4_src;
10641 cmdline_ipaddr_t ipv6_src;
10643 cmdline_fixed_string_t dst_mask;
10644 cmdline_ipaddr_t ipv4_dst;
10645 cmdline_ipaddr_t ipv6_dst;
10647 cmdline_fixed_string_t mac;
10648 uint8_t mac_addr_byte_mask;
10649 cmdline_fixed_string_t tunnel_id;
10650 uint32_t tunnel_id_mask;
10651 cmdline_fixed_string_t tunnel_type;
10652 uint8_t tunnel_type_mask;
10656 cmd_flow_director_mask_parsed(void *parsed_result,
10657 __rte_unused struct cmdline *cl,
10658 __rte_unused void *data)
10660 struct cmd_flow_director_mask_result *res = parsed_result;
10661 struct rte_eth_fdir_masks *mask;
10662 struct rte_port *port;
10664 port = &ports[res->port_id];
10665 /** Check if the port is not started **/
10666 if (port->port_status != RTE_PORT_STOPPED) {
10667 fprintf(stderr, "Please stop port %d first\n", res->port_id);
10671 mask = &port->dev_conf.fdir_conf.mask;
10673 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10674 if (strcmp(res->mode_value, "MAC-VLAN")) {
10675 fprintf(stderr, "Please set mode to MAC-VLAN.\n");
10679 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10680 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10681 if (strcmp(res->mode_value, "Tunnel")) {
10682 fprintf(stderr, "Please set mode to Tunnel.\n");
10686 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10687 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10688 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10689 mask->tunnel_type_mask = res->tunnel_type_mask;
10691 if (strcmp(res->mode_value, "IP")) {
10692 fprintf(stderr, "Please set mode to IP.\n");
10696 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10697 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10698 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10699 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10700 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10701 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10702 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10705 cmd_reconfig_device_queue(res->port_id, 1, 1);
10708 cmdline_parse_token_string_t cmd_flow_director_mask =
10709 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10710 flow_director_mask, "flow_director_mask");
10711 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10712 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10713 port_id, RTE_UINT16);
10714 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10715 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10717 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10718 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10719 vlan_mask, RTE_UINT16);
10720 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10721 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10722 src_mask, "src_mask");
10723 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10724 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10726 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10727 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10729 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10730 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10731 port_src, RTE_UINT16);
10732 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10733 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10734 dst_mask, "dst_mask");
10735 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10736 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10738 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10739 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10741 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10742 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10743 port_dst, RTE_UINT16);
10745 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10746 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10748 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10749 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10751 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10752 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10753 mode_value, "MAC-VLAN");
10754 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10755 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10756 mode_value, "Tunnel");
10757 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10758 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10760 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10761 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10762 mac_addr_byte_mask, RTE_UINT8);
10763 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10764 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10765 tunnel_type, "tunnel-type");
10766 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10767 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10768 tunnel_type_mask, RTE_UINT8);
10769 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10770 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10771 tunnel_id, "tunnel-id");
10772 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10773 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10774 tunnel_id_mask, RTE_UINT32);
10776 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10777 .f = cmd_flow_director_mask_parsed,
10779 .help_str = "flow_director_mask ... : "
10780 "Set IP mode flow director's mask on NIC",
10782 (void *)&cmd_flow_director_mask,
10783 (void *)&cmd_flow_director_mask_port_id,
10784 (void *)&cmd_flow_director_mask_mode,
10785 (void *)&cmd_flow_director_mask_mode_ip,
10786 (void *)&cmd_flow_director_mask_vlan,
10787 (void *)&cmd_flow_director_mask_vlan_value,
10788 (void *)&cmd_flow_director_mask_src,
10789 (void *)&cmd_flow_director_mask_ipv4_src,
10790 (void *)&cmd_flow_director_mask_ipv6_src,
10791 (void *)&cmd_flow_director_mask_port_src,
10792 (void *)&cmd_flow_director_mask_dst,
10793 (void *)&cmd_flow_director_mask_ipv4_dst,
10794 (void *)&cmd_flow_director_mask_ipv6_dst,
10795 (void *)&cmd_flow_director_mask_port_dst,
10800 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10801 .f = cmd_flow_director_mask_parsed,
10803 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10804 "flow director's mask on NIC",
10806 (void *)&cmd_flow_director_mask,
10807 (void *)&cmd_flow_director_mask_port_id,
10808 (void *)&cmd_flow_director_mask_mode,
10809 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10810 (void *)&cmd_flow_director_mask_vlan,
10811 (void *)&cmd_flow_director_mask_vlan_value,
10816 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10817 .f = cmd_flow_director_mask_parsed,
10819 .help_str = "flow_director_mask ... : Set tunnel mode "
10820 "flow director's mask on NIC",
10822 (void *)&cmd_flow_director_mask,
10823 (void *)&cmd_flow_director_mask_port_id,
10824 (void *)&cmd_flow_director_mask_mode,
10825 (void *)&cmd_flow_director_mask_mode_tunnel,
10826 (void *)&cmd_flow_director_mask_vlan,
10827 (void *)&cmd_flow_director_mask_vlan_value,
10828 (void *)&cmd_flow_director_mask_mac,
10829 (void *)&cmd_flow_director_mask_mac_value,
10830 (void *)&cmd_flow_director_mask_tunnel_type,
10831 (void *)&cmd_flow_director_mask_tunnel_type_value,
10832 (void *)&cmd_flow_director_mask_tunnel_id,
10833 (void *)&cmd_flow_director_mask_tunnel_id_value,
10838 /* *** deal with flow director flexible payload configuration *** */
10839 struct cmd_flow_director_flexpayload_result {
10840 cmdline_fixed_string_t flow_director_flexpayload;
10842 cmdline_fixed_string_t payload_layer;
10843 cmdline_fixed_string_t payload_cfg;
10847 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10850 const char *p, *p0 = q_arg;
10852 unsigned long int_fld;
10853 char *str_fld[max_num];
10858 p = strchr(p0, '(');
10862 p0 = strchr(p, ')');
10867 if (size >= sizeof(s))
10870 snprintf(s, sizeof(s), "%.*s", size, p);
10871 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10872 if (ret < 0 || ret > max_num)
10874 for (i = 0; i < ret; i++) {
10876 int_fld = strtoul(str_fld[i], &end, 0);
10877 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10879 offsets[i] = (uint16_t)int_fld;
10885 cmd_flow_director_flxpld_parsed(void *parsed_result,
10886 __rte_unused struct cmdline *cl,
10887 __rte_unused void *data)
10889 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10890 struct rte_eth_flex_payload_cfg flex_cfg;
10891 struct rte_port *port;
10894 port = &ports[res->port_id];
10895 /** Check if the port is not started **/
10896 if (port->port_status != RTE_PORT_STOPPED) {
10897 fprintf(stderr, "Please stop port %d first\n", res->port_id);
10901 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10903 if (!strcmp(res->payload_layer, "raw"))
10904 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10905 else if (!strcmp(res->payload_layer, "l2"))
10906 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10907 else if (!strcmp(res->payload_layer, "l3"))
10908 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10909 else if (!strcmp(res->payload_layer, "l4"))
10910 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10912 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10913 RTE_ETH_FDIR_MAX_FLEXLEN);
10915 fprintf(stderr, "error: Cannot parse flex payload input.\n");
10919 fdir_set_flex_payload(res->port_id, &flex_cfg);
10920 cmd_reconfig_device_queue(res->port_id, 1, 1);
10923 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10924 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10925 flow_director_flexpayload,
10926 "flow_director_flex_payload");
10927 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10928 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10929 port_id, RTE_UINT16);
10930 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10931 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10932 payload_layer, "raw#l2#l3#l4");
10933 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10934 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10935 payload_cfg, NULL);
10937 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10938 .f = cmd_flow_director_flxpld_parsed,
10940 .help_str = "flow_director_flexpayload ... : "
10941 "Set flow director's flex payload on NIC",
10943 (void *)&cmd_flow_director_flexpayload,
10944 (void *)&cmd_flow_director_flexpayload_port_id,
10945 (void *)&cmd_flow_director_flexpayload_payload_layer,
10946 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10951 /* Generic flow interface command. */
10952 extern cmdline_parse_inst_t cmd_flow;
10954 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10955 struct cmd_mcast_addr_result {
10956 cmdline_fixed_string_t mcast_addr_cmd;
10957 cmdline_fixed_string_t what;
10959 struct rte_ether_addr mc_addr;
10962 static void cmd_mcast_addr_parsed(void *parsed_result,
10963 __rte_unused struct cmdline *cl,
10964 __rte_unused void *data)
10966 struct cmd_mcast_addr_result *res = parsed_result;
10968 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
10970 "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
10971 RTE_ETHER_ADDR_BYTES(&res->mc_addr));
10974 if (strcmp(res->what, "add") == 0)
10975 mcast_addr_add(res->port_num, &res->mc_addr);
10977 mcast_addr_remove(res->port_num, &res->mc_addr);
10980 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10981 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10982 mcast_addr_cmd, "mcast_addr");
10983 cmdline_parse_token_string_t cmd_mcast_addr_what =
10984 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10986 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10987 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
10989 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10990 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10992 cmdline_parse_inst_t cmd_mcast_addr = {
10993 .f = cmd_mcast_addr_parsed,
10995 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10996 "Add/Remove multicast MAC address on port_id",
10998 (void *)&cmd_mcast_addr_cmd,
10999 (void *)&cmd_mcast_addr_what,
11000 (void *)&cmd_mcast_addr_portnum,
11001 (void *)&cmd_mcast_addr_addr,
11006 /* vf vlan anti spoof configuration */
11008 /* Common result structure for vf vlan anti spoof */
11009 struct cmd_vf_vlan_anti_spoof_result {
11010 cmdline_fixed_string_t set;
11011 cmdline_fixed_string_t vf;
11012 cmdline_fixed_string_t vlan;
11013 cmdline_fixed_string_t antispoof;
11016 cmdline_fixed_string_t on_off;
11019 /* Common CLI fields for vf vlan anti spoof enable disable */
11020 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
11021 TOKEN_STRING_INITIALIZER
11022 (struct cmd_vf_vlan_anti_spoof_result,
11024 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
11025 TOKEN_STRING_INITIALIZER
11026 (struct cmd_vf_vlan_anti_spoof_result,
11028 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
11029 TOKEN_STRING_INITIALIZER
11030 (struct cmd_vf_vlan_anti_spoof_result,
11032 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
11033 TOKEN_STRING_INITIALIZER
11034 (struct cmd_vf_vlan_anti_spoof_result,
11035 antispoof, "antispoof");
11036 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
11037 TOKEN_NUM_INITIALIZER
11038 (struct cmd_vf_vlan_anti_spoof_result,
11039 port_id, RTE_UINT16);
11040 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
11041 TOKEN_NUM_INITIALIZER
11042 (struct cmd_vf_vlan_anti_spoof_result,
11043 vf_id, RTE_UINT32);
11044 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11045 TOKEN_STRING_INITIALIZER
11046 (struct cmd_vf_vlan_anti_spoof_result,
11050 cmd_set_vf_vlan_anti_spoof_parsed(
11051 void *parsed_result,
11052 __rte_unused struct cmdline *cl,
11053 __rte_unused void *data)
11055 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
11056 int ret = -ENOTSUP;
11058 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11060 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11063 #ifdef RTE_NET_IXGBE
11064 if (ret == -ENOTSUP)
11065 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11066 res->vf_id, is_on);
11068 #ifdef RTE_NET_I40E
11069 if (ret == -ENOTSUP)
11070 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11071 res->vf_id, is_on);
11073 #ifdef RTE_NET_BNXT
11074 if (ret == -ENOTSUP)
11075 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11076 res->vf_id, is_on);
11083 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11086 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11089 fprintf(stderr, "function not implemented\n");
11092 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11096 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11097 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11099 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11101 (void *)&cmd_vf_vlan_anti_spoof_set,
11102 (void *)&cmd_vf_vlan_anti_spoof_vf,
11103 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11104 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11105 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11106 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11107 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11112 /* vf mac anti spoof configuration */
11114 /* Common result structure for vf mac anti spoof */
11115 struct cmd_vf_mac_anti_spoof_result {
11116 cmdline_fixed_string_t set;
11117 cmdline_fixed_string_t vf;
11118 cmdline_fixed_string_t mac;
11119 cmdline_fixed_string_t antispoof;
11122 cmdline_fixed_string_t on_off;
11125 /* Common CLI fields for vf mac anti spoof enable disable */
11126 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11127 TOKEN_STRING_INITIALIZER
11128 (struct cmd_vf_mac_anti_spoof_result,
11130 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11131 TOKEN_STRING_INITIALIZER
11132 (struct cmd_vf_mac_anti_spoof_result,
11134 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11135 TOKEN_STRING_INITIALIZER
11136 (struct cmd_vf_mac_anti_spoof_result,
11138 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11139 TOKEN_STRING_INITIALIZER
11140 (struct cmd_vf_mac_anti_spoof_result,
11141 antispoof, "antispoof");
11142 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11143 TOKEN_NUM_INITIALIZER
11144 (struct cmd_vf_mac_anti_spoof_result,
11145 port_id, RTE_UINT16);
11146 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11147 TOKEN_NUM_INITIALIZER
11148 (struct cmd_vf_mac_anti_spoof_result,
11149 vf_id, RTE_UINT32);
11150 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11151 TOKEN_STRING_INITIALIZER
11152 (struct cmd_vf_mac_anti_spoof_result,
11156 cmd_set_vf_mac_anti_spoof_parsed(
11157 void *parsed_result,
11158 __rte_unused struct cmdline *cl,
11159 __rte_unused void *data)
11161 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11162 int ret = -ENOTSUP;
11164 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11166 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11169 #ifdef RTE_NET_IXGBE
11170 if (ret == -ENOTSUP)
11171 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11172 res->vf_id, is_on);
11174 #ifdef RTE_NET_I40E
11175 if (ret == -ENOTSUP)
11176 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11177 res->vf_id, is_on);
11179 #ifdef RTE_NET_BNXT
11180 if (ret == -ENOTSUP)
11181 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11182 res->vf_id, is_on);
11189 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11190 res->vf_id, is_on);
11193 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11196 fprintf(stderr, "function not implemented\n");
11199 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11203 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11204 .f = cmd_set_vf_mac_anti_spoof_parsed,
11206 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11208 (void *)&cmd_vf_mac_anti_spoof_set,
11209 (void *)&cmd_vf_mac_anti_spoof_vf,
11210 (void *)&cmd_vf_mac_anti_spoof_mac,
11211 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11212 (void *)&cmd_vf_mac_anti_spoof_port_id,
11213 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11214 (void *)&cmd_vf_mac_anti_spoof_on_off,
11219 /* vf vlan strip queue configuration */
11221 /* Common result structure for vf mac anti spoof */
11222 struct cmd_vf_vlan_stripq_result {
11223 cmdline_fixed_string_t set;
11224 cmdline_fixed_string_t vf;
11225 cmdline_fixed_string_t vlan;
11226 cmdline_fixed_string_t stripq;
11229 cmdline_fixed_string_t on_off;
11232 /* Common CLI fields for vf vlan strip enable disable */
11233 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11234 TOKEN_STRING_INITIALIZER
11235 (struct cmd_vf_vlan_stripq_result,
11237 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11238 TOKEN_STRING_INITIALIZER
11239 (struct cmd_vf_vlan_stripq_result,
11241 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11242 TOKEN_STRING_INITIALIZER
11243 (struct cmd_vf_vlan_stripq_result,
11245 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11246 TOKEN_STRING_INITIALIZER
11247 (struct cmd_vf_vlan_stripq_result,
11249 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11250 TOKEN_NUM_INITIALIZER
11251 (struct cmd_vf_vlan_stripq_result,
11252 port_id, RTE_UINT16);
11253 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11254 TOKEN_NUM_INITIALIZER
11255 (struct cmd_vf_vlan_stripq_result,
11256 vf_id, RTE_UINT16);
11257 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11258 TOKEN_STRING_INITIALIZER
11259 (struct cmd_vf_vlan_stripq_result,
11263 cmd_set_vf_vlan_stripq_parsed(
11264 void *parsed_result,
11265 __rte_unused struct cmdline *cl,
11266 __rte_unused void *data)
11268 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11269 int ret = -ENOTSUP;
11271 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11273 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11276 #ifdef RTE_NET_IXGBE
11277 if (ret == -ENOTSUP)
11278 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11279 res->vf_id, is_on);
11281 #ifdef RTE_NET_I40E
11282 if (ret == -ENOTSUP)
11283 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11284 res->vf_id, is_on);
11286 #ifdef RTE_NET_BNXT
11287 if (ret == -ENOTSUP)
11288 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11289 res->vf_id, is_on);
11296 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11297 res->vf_id, is_on);
11300 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11303 fprintf(stderr, "function not implemented\n");
11306 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11310 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11311 .f = cmd_set_vf_vlan_stripq_parsed,
11313 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11315 (void *)&cmd_vf_vlan_stripq_set,
11316 (void *)&cmd_vf_vlan_stripq_vf,
11317 (void *)&cmd_vf_vlan_stripq_vlan,
11318 (void *)&cmd_vf_vlan_stripq_stripq,
11319 (void *)&cmd_vf_vlan_stripq_port_id,
11320 (void *)&cmd_vf_vlan_stripq_vf_id,
11321 (void *)&cmd_vf_vlan_stripq_on_off,
11326 /* vf vlan insert configuration */
11328 /* Common result structure for vf vlan insert */
11329 struct cmd_vf_vlan_insert_result {
11330 cmdline_fixed_string_t set;
11331 cmdline_fixed_string_t vf;
11332 cmdline_fixed_string_t vlan;
11333 cmdline_fixed_string_t insert;
11339 /* Common CLI fields for vf vlan insert enable disable */
11340 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11341 TOKEN_STRING_INITIALIZER
11342 (struct cmd_vf_vlan_insert_result,
11344 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11345 TOKEN_STRING_INITIALIZER
11346 (struct cmd_vf_vlan_insert_result,
11348 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11349 TOKEN_STRING_INITIALIZER
11350 (struct cmd_vf_vlan_insert_result,
11352 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11353 TOKEN_STRING_INITIALIZER
11354 (struct cmd_vf_vlan_insert_result,
11356 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11357 TOKEN_NUM_INITIALIZER
11358 (struct cmd_vf_vlan_insert_result,
11359 port_id, RTE_UINT16);
11360 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11361 TOKEN_NUM_INITIALIZER
11362 (struct cmd_vf_vlan_insert_result,
11363 vf_id, RTE_UINT16);
11364 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11365 TOKEN_NUM_INITIALIZER
11366 (struct cmd_vf_vlan_insert_result,
11367 vlan_id, RTE_UINT16);
11370 cmd_set_vf_vlan_insert_parsed(
11371 void *parsed_result,
11372 __rte_unused struct cmdline *cl,
11373 __rte_unused void *data)
11375 struct cmd_vf_vlan_insert_result *res = parsed_result;
11376 int ret = -ENOTSUP;
11378 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11381 #ifdef RTE_NET_IXGBE
11382 if (ret == -ENOTSUP)
11383 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11386 #ifdef RTE_NET_I40E
11387 if (ret == -ENOTSUP)
11388 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11391 #ifdef RTE_NET_BNXT
11392 if (ret == -ENOTSUP)
11393 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11401 fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
11402 res->vf_id, res->vlan_id);
11405 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11408 fprintf(stderr, "function not implemented\n");
11411 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11415 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11416 .f = cmd_set_vf_vlan_insert_parsed,
11418 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11420 (void *)&cmd_vf_vlan_insert_set,
11421 (void *)&cmd_vf_vlan_insert_vf,
11422 (void *)&cmd_vf_vlan_insert_vlan,
11423 (void *)&cmd_vf_vlan_insert_insert,
11424 (void *)&cmd_vf_vlan_insert_port_id,
11425 (void *)&cmd_vf_vlan_insert_vf_id,
11426 (void *)&cmd_vf_vlan_insert_vlan_id,
11431 /* tx loopback configuration */
11433 /* Common result structure for tx loopback */
11434 struct cmd_tx_loopback_result {
11435 cmdline_fixed_string_t set;
11436 cmdline_fixed_string_t tx;
11437 cmdline_fixed_string_t loopback;
11439 cmdline_fixed_string_t on_off;
11442 /* Common CLI fields for tx loopback enable disable */
11443 cmdline_parse_token_string_t cmd_tx_loopback_set =
11444 TOKEN_STRING_INITIALIZER
11445 (struct cmd_tx_loopback_result,
11447 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11448 TOKEN_STRING_INITIALIZER
11449 (struct cmd_tx_loopback_result,
11451 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11452 TOKEN_STRING_INITIALIZER
11453 (struct cmd_tx_loopback_result,
11454 loopback, "loopback");
11455 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11456 TOKEN_NUM_INITIALIZER
11457 (struct cmd_tx_loopback_result,
11458 port_id, RTE_UINT16);
11459 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11460 TOKEN_STRING_INITIALIZER
11461 (struct cmd_tx_loopback_result,
11465 cmd_set_tx_loopback_parsed(
11466 void *parsed_result,
11467 __rte_unused struct cmdline *cl,
11468 __rte_unused void *data)
11470 struct cmd_tx_loopback_result *res = parsed_result;
11471 int ret = -ENOTSUP;
11473 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11475 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11478 #ifdef RTE_NET_IXGBE
11479 if (ret == -ENOTSUP)
11480 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11482 #ifdef RTE_NET_I40E
11483 if (ret == -ENOTSUP)
11484 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11486 #ifdef RTE_NET_BNXT
11487 if (ret == -ENOTSUP)
11488 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11490 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11491 if (ret == -ENOTSUP)
11492 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11499 fprintf(stderr, "invalid is_on %d\n", is_on);
11502 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11505 fprintf(stderr, "function not implemented\n");
11508 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11512 cmdline_parse_inst_t cmd_set_tx_loopback = {
11513 .f = cmd_set_tx_loopback_parsed,
11515 .help_str = "set tx loopback <port_id> on|off",
11517 (void *)&cmd_tx_loopback_set,
11518 (void *)&cmd_tx_loopback_tx,
11519 (void *)&cmd_tx_loopback_loopback,
11520 (void *)&cmd_tx_loopback_port_id,
11521 (void *)&cmd_tx_loopback_on_off,
11526 /* all queues drop enable configuration */
11528 /* Common result structure for all queues drop enable */
11529 struct cmd_all_queues_drop_en_result {
11530 cmdline_fixed_string_t set;
11531 cmdline_fixed_string_t all;
11532 cmdline_fixed_string_t queues;
11533 cmdline_fixed_string_t drop;
11535 cmdline_fixed_string_t on_off;
11538 /* Common CLI fields for tx loopback enable disable */
11539 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11540 TOKEN_STRING_INITIALIZER
11541 (struct cmd_all_queues_drop_en_result,
11543 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11544 TOKEN_STRING_INITIALIZER
11545 (struct cmd_all_queues_drop_en_result,
11547 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11548 TOKEN_STRING_INITIALIZER
11549 (struct cmd_all_queues_drop_en_result,
11551 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11552 TOKEN_STRING_INITIALIZER
11553 (struct cmd_all_queues_drop_en_result,
11555 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11556 TOKEN_NUM_INITIALIZER
11557 (struct cmd_all_queues_drop_en_result,
11558 port_id, RTE_UINT16);
11559 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11560 TOKEN_STRING_INITIALIZER
11561 (struct cmd_all_queues_drop_en_result,
11565 cmd_set_all_queues_drop_en_parsed(
11566 void *parsed_result,
11567 __rte_unused struct cmdline *cl,
11568 __rte_unused void *data)
11570 struct cmd_all_queues_drop_en_result *res = parsed_result;
11571 int ret = -ENOTSUP;
11572 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11574 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11577 #ifdef RTE_NET_IXGBE
11578 if (ret == -ENOTSUP)
11579 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11581 #ifdef RTE_NET_BNXT
11582 if (ret == -ENOTSUP)
11583 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11589 fprintf(stderr, "invalid is_on %d\n", is_on);
11592 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11595 fprintf(stderr, "function not implemented\n");
11598 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11602 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11603 .f = cmd_set_all_queues_drop_en_parsed,
11605 .help_str = "set all queues drop <port_id> on|off",
11607 (void *)&cmd_all_queues_drop_en_set,
11608 (void *)&cmd_all_queues_drop_en_all,
11609 (void *)&cmd_all_queues_drop_en_queues,
11610 (void *)&cmd_all_queues_drop_en_drop,
11611 (void *)&cmd_all_queues_drop_en_port_id,
11612 (void *)&cmd_all_queues_drop_en_on_off,
11617 /* vf split drop enable configuration */
11619 /* Common result structure for vf split drop enable */
11620 struct cmd_vf_split_drop_en_result {
11621 cmdline_fixed_string_t set;
11622 cmdline_fixed_string_t vf;
11623 cmdline_fixed_string_t split;
11624 cmdline_fixed_string_t drop;
11627 cmdline_fixed_string_t on_off;
11630 /* Common CLI fields for vf split drop enable disable */
11631 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11632 TOKEN_STRING_INITIALIZER
11633 (struct cmd_vf_split_drop_en_result,
11635 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11636 TOKEN_STRING_INITIALIZER
11637 (struct cmd_vf_split_drop_en_result,
11639 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11640 TOKEN_STRING_INITIALIZER
11641 (struct cmd_vf_split_drop_en_result,
11643 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11644 TOKEN_STRING_INITIALIZER
11645 (struct cmd_vf_split_drop_en_result,
11647 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11648 TOKEN_NUM_INITIALIZER
11649 (struct cmd_vf_split_drop_en_result,
11650 port_id, RTE_UINT16);
11651 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11652 TOKEN_NUM_INITIALIZER
11653 (struct cmd_vf_split_drop_en_result,
11654 vf_id, RTE_UINT16);
11655 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11656 TOKEN_STRING_INITIALIZER
11657 (struct cmd_vf_split_drop_en_result,
11661 cmd_set_vf_split_drop_en_parsed(
11662 void *parsed_result,
11663 __rte_unused struct cmdline *cl,
11664 __rte_unused void *data)
11666 struct cmd_vf_split_drop_en_result *res = parsed_result;
11667 int ret = -ENOTSUP;
11668 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11670 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11673 #ifdef RTE_NET_IXGBE
11674 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11681 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11682 res->vf_id, is_on);
11685 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11688 fprintf(stderr, "not supported on port %d\n", res->port_id);
11691 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11695 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11696 .f = cmd_set_vf_split_drop_en_parsed,
11698 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11700 (void *)&cmd_vf_split_drop_en_set,
11701 (void *)&cmd_vf_split_drop_en_vf,
11702 (void *)&cmd_vf_split_drop_en_split,
11703 (void *)&cmd_vf_split_drop_en_drop,
11704 (void *)&cmd_vf_split_drop_en_port_id,
11705 (void *)&cmd_vf_split_drop_en_vf_id,
11706 (void *)&cmd_vf_split_drop_en_on_off,
11711 /* vf mac address configuration */
11713 /* Common result structure for vf mac address */
11714 struct cmd_set_vf_mac_addr_result {
11715 cmdline_fixed_string_t set;
11716 cmdline_fixed_string_t vf;
11717 cmdline_fixed_string_t mac;
11718 cmdline_fixed_string_t addr;
11721 struct rte_ether_addr mac_addr;
11725 /* Common CLI fields for vf split drop enable disable */
11726 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11727 TOKEN_STRING_INITIALIZER
11728 (struct cmd_set_vf_mac_addr_result,
11730 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11731 TOKEN_STRING_INITIALIZER
11732 (struct cmd_set_vf_mac_addr_result,
11734 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11735 TOKEN_STRING_INITIALIZER
11736 (struct cmd_set_vf_mac_addr_result,
11738 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11739 TOKEN_STRING_INITIALIZER
11740 (struct cmd_set_vf_mac_addr_result,
11742 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11743 TOKEN_NUM_INITIALIZER
11744 (struct cmd_set_vf_mac_addr_result,
11745 port_id, RTE_UINT16);
11746 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11747 TOKEN_NUM_INITIALIZER
11748 (struct cmd_set_vf_mac_addr_result,
11749 vf_id, RTE_UINT16);
11750 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11751 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11755 cmd_set_vf_mac_addr_parsed(
11756 void *parsed_result,
11757 __rte_unused struct cmdline *cl,
11758 __rte_unused void *data)
11760 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11761 int ret = -ENOTSUP;
11763 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11766 #ifdef RTE_NET_IXGBE
11767 if (ret == -ENOTSUP)
11768 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11771 #ifdef RTE_NET_I40E
11772 if (ret == -ENOTSUP)
11773 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11776 #ifdef RTE_NET_BNXT
11777 if (ret == -ENOTSUP)
11778 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11786 fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
11789 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11792 fprintf(stderr, "function not implemented\n");
11795 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11799 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11800 .f = cmd_set_vf_mac_addr_parsed,
11802 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11804 (void *)&cmd_set_vf_mac_addr_set,
11805 (void *)&cmd_set_vf_mac_addr_vf,
11806 (void *)&cmd_set_vf_mac_addr_mac,
11807 (void *)&cmd_set_vf_mac_addr_addr,
11808 (void *)&cmd_set_vf_mac_addr_port_id,
11809 (void *)&cmd_set_vf_mac_addr_vf_id,
11810 (void *)&cmd_set_vf_mac_addr_mac_addr,
11815 /* MACsec configuration */
11817 /* Common result structure for MACsec offload enable */
11818 struct cmd_macsec_offload_on_result {
11819 cmdline_fixed_string_t set;
11820 cmdline_fixed_string_t macsec;
11821 cmdline_fixed_string_t offload;
11823 cmdline_fixed_string_t on;
11824 cmdline_fixed_string_t encrypt;
11825 cmdline_fixed_string_t en_on_off;
11826 cmdline_fixed_string_t replay_protect;
11827 cmdline_fixed_string_t rp_on_off;
11830 /* Common CLI fields for MACsec offload disable */
11831 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11832 TOKEN_STRING_INITIALIZER
11833 (struct cmd_macsec_offload_on_result,
11835 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11836 TOKEN_STRING_INITIALIZER
11837 (struct cmd_macsec_offload_on_result,
11839 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11840 TOKEN_STRING_INITIALIZER
11841 (struct cmd_macsec_offload_on_result,
11842 offload, "offload");
11843 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11844 TOKEN_NUM_INITIALIZER
11845 (struct cmd_macsec_offload_on_result,
11846 port_id, RTE_UINT16);
11847 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11848 TOKEN_STRING_INITIALIZER
11849 (struct cmd_macsec_offload_on_result,
11851 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11852 TOKEN_STRING_INITIALIZER
11853 (struct cmd_macsec_offload_on_result,
11854 encrypt, "encrypt");
11855 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11856 TOKEN_STRING_INITIALIZER
11857 (struct cmd_macsec_offload_on_result,
11858 en_on_off, "on#off");
11859 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11860 TOKEN_STRING_INITIALIZER
11861 (struct cmd_macsec_offload_on_result,
11862 replay_protect, "replay-protect");
11863 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11864 TOKEN_STRING_INITIALIZER
11865 (struct cmd_macsec_offload_on_result,
11866 rp_on_off, "on#off");
11869 cmd_set_macsec_offload_on_parsed(
11870 void *parsed_result,
11871 __rte_unused struct cmdline *cl,
11872 __rte_unused void *data)
11874 struct cmd_macsec_offload_on_result *res = parsed_result;
11875 int ret = -ENOTSUP;
11876 portid_t port_id = res->port_id;
11877 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11878 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11879 struct rte_eth_dev_info dev_info;
11881 if (port_id_is_invalid(port_id, ENABLED_WARN))
11883 if (!port_is_stopped(port_id)) {
11884 fprintf(stderr, "Please stop port %d first\n", port_id);
11888 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11892 if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) {
11893 #ifdef RTE_NET_IXGBE
11894 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11902 ports[port_id].dev_conf.txmode.offloads |=
11903 RTE_ETH_TX_OFFLOAD_MACSEC_INSERT;
11904 cmd_reconfig_device_queue(port_id, 1, 1);
11907 fprintf(stderr, "invalid port_id %d\n", port_id);
11910 fprintf(stderr, "not supported on port %d\n", port_id);
11913 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11917 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11918 .f = cmd_set_macsec_offload_on_parsed,
11920 .help_str = "set macsec offload <port_id> on "
11921 "encrypt on|off replay-protect on|off",
11923 (void *)&cmd_macsec_offload_on_set,
11924 (void *)&cmd_macsec_offload_on_macsec,
11925 (void *)&cmd_macsec_offload_on_offload,
11926 (void *)&cmd_macsec_offload_on_port_id,
11927 (void *)&cmd_macsec_offload_on_on,
11928 (void *)&cmd_macsec_offload_on_encrypt,
11929 (void *)&cmd_macsec_offload_on_en_on_off,
11930 (void *)&cmd_macsec_offload_on_replay_protect,
11931 (void *)&cmd_macsec_offload_on_rp_on_off,
11936 /* Common result structure for MACsec offload disable */
11937 struct cmd_macsec_offload_off_result {
11938 cmdline_fixed_string_t set;
11939 cmdline_fixed_string_t macsec;
11940 cmdline_fixed_string_t offload;
11942 cmdline_fixed_string_t off;
11945 /* Common CLI fields for MACsec offload disable */
11946 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11947 TOKEN_STRING_INITIALIZER
11948 (struct cmd_macsec_offload_off_result,
11950 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11951 TOKEN_STRING_INITIALIZER
11952 (struct cmd_macsec_offload_off_result,
11954 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11955 TOKEN_STRING_INITIALIZER
11956 (struct cmd_macsec_offload_off_result,
11957 offload, "offload");
11958 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11959 TOKEN_NUM_INITIALIZER
11960 (struct cmd_macsec_offload_off_result,
11961 port_id, RTE_UINT16);
11962 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11963 TOKEN_STRING_INITIALIZER
11964 (struct cmd_macsec_offload_off_result,
11968 cmd_set_macsec_offload_off_parsed(
11969 void *parsed_result,
11970 __rte_unused struct cmdline *cl,
11971 __rte_unused void *data)
11973 struct cmd_macsec_offload_off_result *res = parsed_result;
11974 int ret = -ENOTSUP;
11975 struct rte_eth_dev_info dev_info;
11976 portid_t port_id = res->port_id;
11978 if (port_id_is_invalid(port_id, ENABLED_WARN))
11980 if (!port_is_stopped(port_id)) {
11981 fprintf(stderr, "Please stop port %d first\n", port_id);
11985 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11989 if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) {
11990 #ifdef RTE_NET_IXGBE
11991 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11996 ports[port_id].dev_conf.txmode.offloads &=
11997 ~RTE_ETH_TX_OFFLOAD_MACSEC_INSERT;
11998 cmd_reconfig_device_queue(port_id, 1, 1);
12001 fprintf(stderr, "invalid port_id %d\n", port_id);
12004 fprintf(stderr, "not supported on port %d\n", port_id);
12007 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12011 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
12012 .f = cmd_set_macsec_offload_off_parsed,
12014 .help_str = "set macsec offload <port_id> off",
12016 (void *)&cmd_macsec_offload_off_set,
12017 (void *)&cmd_macsec_offload_off_macsec,
12018 (void *)&cmd_macsec_offload_off_offload,
12019 (void *)&cmd_macsec_offload_off_port_id,
12020 (void *)&cmd_macsec_offload_off_off,
12025 /* Common result structure for MACsec secure connection configure */
12026 struct cmd_macsec_sc_result {
12027 cmdline_fixed_string_t set;
12028 cmdline_fixed_string_t macsec;
12029 cmdline_fixed_string_t sc;
12030 cmdline_fixed_string_t tx_rx;
12032 struct rte_ether_addr mac;
12036 /* Common CLI fields for MACsec secure connection configure */
12037 cmdline_parse_token_string_t cmd_macsec_sc_set =
12038 TOKEN_STRING_INITIALIZER
12039 (struct cmd_macsec_sc_result,
12041 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
12042 TOKEN_STRING_INITIALIZER
12043 (struct cmd_macsec_sc_result,
12045 cmdline_parse_token_string_t cmd_macsec_sc_sc =
12046 TOKEN_STRING_INITIALIZER
12047 (struct cmd_macsec_sc_result,
12049 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
12050 TOKEN_STRING_INITIALIZER
12051 (struct cmd_macsec_sc_result,
12053 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
12054 TOKEN_NUM_INITIALIZER
12055 (struct cmd_macsec_sc_result,
12056 port_id, RTE_UINT16);
12057 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
12058 TOKEN_ETHERADDR_INITIALIZER
12059 (struct cmd_macsec_sc_result,
12061 cmdline_parse_token_num_t cmd_macsec_sc_pi =
12062 TOKEN_NUM_INITIALIZER
12063 (struct cmd_macsec_sc_result,
12067 cmd_set_macsec_sc_parsed(
12068 void *parsed_result,
12069 __rte_unused struct cmdline *cl,
12070 __rte_unused void *data)
12072 struct cmd_macsec_sc_result *res = parsed_result;
12073 int ret = -ENOTSUP;
12074 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12076 #ifdef RTE_NET_IXGBE
12078 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12079 res->mac.addr_bytes) :
12080 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12081 res->mac.addr_bytes, res->pi);
12083 RTE_SET_USED(is_tx);
12089 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12092 fprintf(stderr, "not supported on port %d\n", res->port_id);
12095 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12099 cmdline_parse_inst_t cmd_set_macsec_sc = {
12100 .f = cmd_set_macsec_sc_parsed,
12102 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12104 (void *)&cmd_macsec_sc_set,
12105 (void *)&cmd_macsec_sc_macsec,
12106 (void *)&cmd_macsec_sc_sc,
12107 (void *)&cmd_macsec_sc_tx_rx,
12108 (void *)&cmd_macsec_sc_port_id,
12109 (void *)&cmd_macsec_sc_mac,
12110 (void *)&cmd_macsec_sc_pi,
12115 /* Common result structure for MACsec secure connection configure */
12116 struct cmd_macsec_sa_result {
12117 cmdline_fixed_string_t set;
12118 cmdline_fixed_string_t macsec;
12119 cmdline_fixed_string_t sa;
12120 cmdline_fixed_string_t tx_rx;
12125 cmdline_fixed_string_t key;
12128 /* Common CLI fields for MACsec secure connection configure */
12129 cmdline_parse_token_string_t cmd_macsec_sa_set =
12130 TOKEN_STRING_INITIALIZER
12131 (struct cmd_macsec_sa_result,
12133 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12134 TOKEN_STRING_INITIALIZER
12135 (struct cmd_macsec_sa_result,
12137 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12138 TOKEN_STRING_INITIALIZER
12139 (struct cmd_macsec_sa_result,
12141 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12142 TOKEN_STRING_INITIALIZER
12143 (struct cmd_macsec_sa_result,
12145 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12146 TOKEN_NUM_INITIALIZER
12147 (struct cmd_macsec_sa_result,
12148 port_id, RTE_UINT16);
12149 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12150 TOKEN_NUM_INITIALIZER
12151 (struct cmd_macsec_sa_result,
12153 cmdline_parse_token_num_t cmd_macsec_sa_an =
12154 TOKEN_NUM_INITIALIZER
12155 (struct cmd_macsec_sa_result,
12157 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12158 TOKEN_NUM_INITIALIZER
12159 (struct cmd_macsec_sa_result,
12161 cmdline_parse_token_string_t cmd_macsec_sa_key =
12162 TOKEN_STRING_INITIALIZER
12163 (struct cmd_macsec_sa_result,
12167 cmd_set_macsec_sa_parsed(
12168 void *parsed_result,
12169 __rte_unused struct cmdline *cl,
12170 __rte_unused void *data)
12172 struct cmd_macsec_sa_result *res = parsed_result;
12173 int ret = -ENOTSUP;
12174 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12175 uint8_t key[16] = { 0 };
12181 key_len = strlen(res->key) / 2;
12185 for (i = 0; i < key_len; i++) {
12186 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12189 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12192 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12195 #ifdef RTE_NET_IXGBE
12197 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12198 res->idx, res->an, res->pn, key) :
12199 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12200 res->idx, res->an, res->pn, key);
12202 RTE_SET_USED(is_tx);
12209 fprintf(stderr, "invalid idx %d or an %d\n", res->idx, res->an);
12212 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12215 fprintf(stderr, "not supported on port %d\n", res->port_id);
12218 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12222 cmdline_parse_inst_t cmd_set_macsec_sa = {
12223 .f = cmd_set_macsec_sa_parsed,
12225 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12227 (void *)&cmd_macsec_sa_set,
12228 (void *)&cmd_macsec_sa_macsec,
12229 (void *)&cmd_macsec_sa_sa,
12230 (void *)&cmd_macsec_sa_tx_rx,
12231 (void *)&cmd_macsec_sa_port_id,
12232 (void *)&cmd_macsec_sa_idx,
12233 (void *)&cmd_macsec_sa_an,
12234 (void *)&cmd_macsec_sa_pn,
12235 (void *)&cmd_macsec_sa_key,
12240 /* VF unicast promiscuous mode configuration */
12242 /* Common result structure for VF unicast promiscuous mode */
12243 struct cmd_vf_promisc_result {
12244 cmdline_fixed_string_t set;
12245 cmdline_fixed_string_t vf;
12246 cmdline_fixed_string_t promisc;
12249 cmdline_fixed_string_t on_off;
12252 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12253 cmdline_parse_token_string_t cmd_vf_promisc_set =
12254 TOKEN_STRING_INITIALIZER
12255 (struct cmd_vf_promisc_result,
12257 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12258 TOKEN_STRING_INITIALIZER
12259 (struct cmd_vf_promisc_result,
12261 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12262 TOKEN_STRING_INITIALIZER
12263 (struct cmd_vf_promisc_result,
12264 promisc, "promisc");
12265 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12266 TOKEN_NUM_INITIALIZER
12267 (struct cmd_vf_promisc_result,
12268 port_id, RTE_UINT16);
12269 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12270 TOKEN_NUM_INITIALIZER
12271 (struct cmd_vf_promisc_result,
12272 vf_id, RTE_UINT32);
12273 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12274 TOKEN_STRING_INITIALIZER
12275 (struct cmd_vf_promisc_result,
12279 cmd_set_vf_promisc_parsed(
12280 void *parsed_result,
12281 __rte_unused struct cmdline *cl,
12282 __rte_unused void *data)
12284 struct cmd_vf_promisc_result *res = parsed_result;
12285 int ret = -ENOTSUP;
12287 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12289 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12292 #ifdef RTE_NET_I40E
12293 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12294 res->vf_id, is_on);
12301 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12304 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12307 fprintf(stderr, "function not implemented\n");
12310 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12314 cmdline_parse_inst_t cmd_set_vf_promisc = {
12315 .f = cmd_set_vf_promisc_parsed,
12317 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12318 "Set unicast promiscuous mode for a VF from the PF",
12320 (void *)&cmd_vf_promisc_set,
12321 (void *)&cmd_vf_promisc_vf,
12322 (void *)&cmd_vf_promisc_promisc,
12323 (void *)&cmd_vf_promisc_port_id,
12324 (void *)&cmd_vf_promisc_vf_id,
12325 (void *)&cmd_vf_promisc_on_off,
12330 /* VF multicast promiscuous mode configuration */
12332 /* Common result structure for VF multicast promiscuous mode */
12333 struct cmd_vf_allmulti_result {
12334 cmdline_fixed_string_t set;
12335 cmdline_fixed_string_t vf;
12336 cmdline_fixed_string_t allmulti;
12339 cmdline_fixed_string_t on_off;
12342 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12343 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12344 TOKEN_STRING_INITIALIZER
12345 (struct cmd_vf_allmulti_result,
12347 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12348 TOKEN_STRING_INITIALIZER
12349 (struct cmd_vf_allmulti_result,
12351 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12352 TOKEN_STRING_INITIALIZER
12353 (struct cmd_vf_allmulti_result,
12354 allmulti, "allmulti");
12355 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12356 TOKEN_NUM_INITIALIZER
12357 (struct cmd_vf_allmulti_result,
12358 port_id, RTE_UINT16);
12359 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12360 TOKEN_NUM_INITIALIZER
12361 (struct cmd_vf_allmulti_result,
12362 vf_id, RTE_UINT32);
12363 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12364 TOKEN_STRING_INITIALIZER
12365 (struct cmd_vf_allmulti_result,
12369 cmd_set_vf_allmulti_parsed(
12370 void *parsed_result,
12371 __rte_unused struct cmdline *cl,
12372 __rte_unused void *data)
12374 struct cmd_vf_allmulti_result *res = parsed_result;
12375 int ret = -ENOTSUP;
12377 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12379 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12382 #ifdef RTE_NET_I40E
12383 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12384 res->vf_id, is_on);
12391 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12394 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12397 fprintf(stderr, "function not implemented\n");
12400 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12404 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12405 .f = cmd_set_vf_allmulti_parsed,
12407 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12408 "Set multicast promiscuous mode for a VF from the PF",
12410 (void *)&cmd_vf_allmulti_set,
12411 (void *)&cmd_vf_allmulti_vf,
12412 (void *)&cmd_vf_allmulti_allmulti,
12413 (void *)&cmd_vf_allmulti_port_id,
12414 (void *)&cmd_vf_allmulti_vf_id,
12415 (void *)&cmd_vf_allmulti_on_off,
12420 /* vf broadcast mode configuration */
12422 /* Common result structure for vf broadcast */
12423 struct cmd_set_vf_broadcast_result {
12424 cmdline_fixed_string_t set;
12425 cmdline_fixed_string_t vf;
12426 cmdline_fixed_string_t broadcast;
12429 cmdline_fixed_string_t on_off;
12432 /* Common CLI fields for vf broadcast enable disable */
12433 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12434 TOKEN_STRING_INITIALIZER
12435 (struct cmd_set_vf_broadcast_result,
12437 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12438 TOKEN_STRING_INITIALIZER
12439 (struct cmd_set_vf_broadcast_result,
12441 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12442 TOKEN_STRING_INITIALIZER
12443 (struct cmd_set_vf_broadcast_result,
12444 broadcast, "broadcast");
12445 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12446 TOKEN_NUM_INITIALIZER
12447 (struct cmd_set_vf_broadcast_result,
12448 port_id, RTE_UINT16);
12449 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12450 TOKEN_NUM_INITIALIZER
12451 (struct cmd_set_vf_broadcast_result,
12452 vf_id, RTE_UINT16);
12453 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12454 TOKEN_STRING_INITIALIZER
12455 (struct cmd_set_vf_broadcast_result,
12459 cmd_set_vf_broadcast_parsed(
12460 void *parsed_result,
12461 __rte_unused struct cmdline *cl,
12462 __rte_unused void *data)
12464 struct cmd_set_vf_broadcast_result *res = parsed_result;
12465 int ret = -ENOTSUP;
12467 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12469 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12472 #ifdef RTE_NET_I40E
12473 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12474 res->vf_id, is_on);
12481 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12482 res->vf_id, is_on);
12485 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12488 fprintf(stderr, "function not implemented\n");
12491 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12495 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12496 .f = cmd_set_vf_broadcast_parsed,
12498 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12500 (void *)&cmd_set_vf_broadcast_set,
12501 (void *)&cmd_set_vf_broadcast_vf,
12502 (void *)&cmd_set_vf_broadcast_broadcast,
12503 (void *)&cmd_set_vf_broadcast_port_id,
12504 (void *)&cmd_set_vf_broadcast_vf_id,
12505 (void *)&cmd_set_vf_broadcast_on_off,
12510 /* vf vlan tag configuration */
12512 /* Common result structure for vf vlan tag */
12513 struct cmd_set_vf_vlan_tag_result {
12514 cmdline_fixed_string_t set;
12515 cmdline_fixed_string_t vf;
12516 cmdline_fixed_string_t vlan;
12517 cmdline_fixed_string_t tag;
12520 cmdline_fixed_string_t on_off;
12523 /* Common CLI fields for vf vlan tag enable disable */
12524 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12525 TOKEN_STRING_INITIALIZER
12526 (struct cmd_set_vf_vlan_tag_result,
12528 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12529 TOKEN_STRING_INITIALIZER
12530 (struct cmd_set_vf_vlan_tag_result,
12532 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12533 TOKEN_STRING_INITIALIZER
12534 (struct cmd_set_vf_vlan_tag_result,
12536 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12537 TOKEN_STRING_INITIALIZER
12538 (struct cmd_set_vf_vlan_tag_result,
12540 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12541 TOKEN_NUM_INITIALIZER
12542 (struct cmd_set_vf_vlan_tag_result,
12543 port_id, RTE_UINT16);
12544 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12545 TOKEN_NUM_INITIALIZER
12546 (struct cmd_set_vf_vlan_tag_result,
12547 vf_id, RTE_UINT16);
12548 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12549 TOKEN_STRING_INITIALIZER
12550 (struct cmd_set_vf_vlan_tag_result,
12554 cmd_set_vf_vlan_tag_parsed(
12555 void *parsed_result,
12556 __rte_unused struct cmdline *cl,
12557 __rte_unused void *data)
12559 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12560 int ret = -ENOTSUP;
12562 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12564 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12567 #ifdef RTE_NET_I40E
12568 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12569 res->vf_id, is_on);
12576 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12577 res->vf_id, is_on);
12580 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12583 fprintf(stderr, "function not implemented\n");
12586 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12590 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12591 .f = cmd_set_vf_vlan_tag_parsed,
12593 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12595 (void *)&cmd_set_vf_vlan_tag_set,
12596 (void *)&cmd_set_vf_vlan_tag_vf,
12597 (void *)&cmd_set_vf_vlan_tag_vlan,
12598 (void *)&cmd_set_vf_vlan_tag_tag,
12599 (void *)&cmd_set_vf_vlan_tag_port_id,
12600 (void *)&cmd_set_vf_vlan_tag_vf_id,
12601 (void *)&cmd_set_vf_vlan_tag_on_off,
12606 /* Common definition of VF and TC TX bandwidth configuration */
12607 struct cmd_vf_tc_bw_result {
12608 cmdline_fixed_string_t set;
12609 cmdline_fixed_string_t vf;
12610 cmdline_fixed_string_t tc;
12611 cmdline_fixed_string_t tx;
12612 cmdline_fixed_string_t min_bw;
12613 cmdline_fixed_string_t max_bw;
12614 cmdline_fixed_string_t strict_link_prio;
12619 cmdline_fixed_string_t bw_list;
12623 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12624 TOKEN_STRING_INITIALIZER
12625 (struct cmd_vf_tc_bw_result,
12627 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12628 TOKEN_STRING_INITIALIZER
12629 (struct cmd_vf_tc_bw_result,
12631 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12632 TOKEN_STRING_INITIALIZER
12633 (struct cmd_vf_tc_bw_result,
12635 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12636 TOKEN_STRING_INITIALIZER
12637 (struct cmd_vf_tc_bw_result,
12639 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12640 TOKEN_STRING_INITIALIZER
12641 (struct cmd_vf_tc_bw_result,
12642 strict_link_prio, "strict-link-priority");
12643 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12644 TOKEN_STRING_INITIALIZER
12645 (struct cmd_vf_tc_bw_result,
12646 min_bw, "min-bandwidth");
12647 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12648 TOKEN_STRING_INITIALIZER
12649 (struct cmd_vf_tc_bw_result,
12650 max_bw, "max-bandwidth");
12651 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12652 TOKEN_NUM_INITIALIZER
12653 (struct cmd_vf_tc_bw_result,
12654 port_id, RTE_UINT16);
12655 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12656 TOKEN_NUM_INITIALIZER
12657 (struct cmd_vf_tc_bw_result,
12658 vf_id, RTE_UINT16);
12659 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12660 TOKEN_NUM_INITIALIZER
12661 (struct cmd_vf_tc_bw_result,
12663 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12664 TOKEN_NUM_INITIALIZER
12665 (struct cmd_vf_tc_bw_result,
12667 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12668 TOKEN_STRING_INITIALIZER
12669 (struct cmd_vf_tc_bw_result,
12671 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12672 TOKEN_NUM_INITIALIZER
12673 (struct cmd_vf_tc_bw_result,
12674 tc_map, RTE_UINT8);
12676 /* VF max bandwidth setting */
12678 cmd_vf_max_bw_parsed(
12679 void *parsed_result,
12680 __rte_unused struct cmdline *cl,
12681 __rte_unused void *data)
12683 struct cmd_vf_tc_bw_result *res = parsed_result;
12684 int ret = -ENOTSUP;
12686 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12689 #ifdef RTE_NET_I40E
12690 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12691 res->vf_id, res->bw);
12698 fprintf(stderr, "invalid vf_id %d or bandwidth %d\n",
12699 res->vf_id, res->bw);
12702 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12705 fprintf(stderr, "function not implemented\n");
12708 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12712 cmdline_parse_inst_t cmd_vf_max_bw = {
12713 .f = cmd_vf_max_bw_parsed,
12715 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12717 (void *)&cmd_vf_tc_bw_set,
12718 (void *)&cmd_vf_tc_bw_vf,
12719 (void *)&cmd_vf_tc_bw_tx,
12720 (void *)&cmd_vf_tc_bw_max_bw,
12721 (void *)&cmd_vf_tc_bw_port_id,
12722 (void *)&cmd_vf_tc_bw_vf_id,
12723 (void *)&cmd_vf_tc_bw_bw,
12729 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12734 const char *p, *p0 = str;
12741 p = strchr(p0, '(');
12744 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12748 p0 = strchr(p, ')');
12751 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12755 if (size >= sizeof(s)) {
12757 "The string size exceeds the internal buffer size\n");
12760 snprintf(s, sizeof(s), "%.*s", size, p);
12761 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12763 fprintf(stderr, "Failed to get the bandwidth list.\n");
12767 for (i = 0; i < ret; i++)
12768 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12773 /* TC min bandwidth setting */
12775 cmd_vf_tc_min_bw_parsed(
12776 void *parsed_result,
12777 __rte_unused struct cmdline *cl,
12778 __rte_unused void *data)
12780 struct cmd_vf_tc_bw_result *res = parsed_result;
12783 int ret = -ENOTSUP;
12785 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12788 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12792 #ifdef RTE_NET_I40E
12793 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12801 fprintf(stderr, "invalid vf_id %d or bandwidth\n", res->vf_id);
12804 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12807 fprintf(stderr, "function not implemented\n");
12810 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12814 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12815 .f = cmd_vf_tc_min_bw_parsed,
12817 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12818 " <bw1, bw2, ...>",
12820 (void *)&cmd_vf_tc_bw_set,
12821 (void *)&cmd_vf_tc_bw_vf,
12822 (void *)&cmd_vf_tc_bw_tc,
12823 (void *)&cmd_vf_tc_bw_tx,
12824 (void *)&cmd_vf_tc_bw_min_bw,
12825 (void *)&cmd_vf_tc_bw_port_id,
12826 (void *)&cmd_vf_tc_bw_vf_id,
12827 (void *)&cmd_vf_tc_bw_bw_list,
12833 cmd_tc_min_bw_parsed(
12834 void *parsed_result,
12835 __rte_unused struct cmdline *cl,
12836 __rte_unused void *data)
12838 struct cmd_vf_tc_bw_result *res = parsed_result;
12839 struct rte_port *port;
12842 int ret = -ENOTSUP;
12844 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12847 port = &ports[res->port_id];
12848 /** Check if the port is not started **/
12849 if (port->port_status != RTE_PORT_STOPPED) {
12850 fprintf(stderr, "Please stop port %d first\n", res->port_id);
12854 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12858 #ifdef RTE_NET_IXGBE
12859 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12866 fprintf(stderr, "invalid bandwidth\n");
12869 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12872 fprintf(stderr, "function not implemented\n");
12875 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12879 cmdline_parse_inst_t cmd_tc_min_bw = {
12880 .f = cmd_tc_min_bw_parsed,
12882 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12884 (void *)&cmd_vf_tc_bw_set,
12885 (void *)&cmd_vf_tc_bw_tc,
12886 (void *)&cmd_vf_tc_bw_tx,
12887 (void *)&cmd_vf_tc_bw_min_bw,
12888 (void *)&cmd_vf_tc_bw_port_id,
12889 (void *)&cmd_vf_tc_bw_bw_list,
12894 /* TC max bandwidth setting */
12896 cmd_vf_tc_max_bw_parsed(
12897 void *parsed_result,
12898 __rte_unused struct cmdline *cl,
12899 __rte_unused void *data)
12901 struct cmd_vf_tc_bw_result *res = parsed_result;
12902 int ret = -ENOTSUP;
12904 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12907 #ifdef RTE_NET_I40E
12908 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12909 res->tc_no, res->bw);
12917 "invalid vf_id %d, tc_no %d or bandwidth %d\n",
12918 res->vf_id, res->tc_no, res->bw);
12921 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12924 fprintf(stderr, "function not implemented\n");
12927 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12931 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12932 .f = cmd_vf_tc_max_bw_parsed,
12934 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12937 (void *)&cmd_vf_tc_bw_set,
12938 (void *)&cmd_vf_tc_bw_vf,
12939 (void *)&cmd_vf_tc_bw_tc,
12940 (void *)&cmd_vf_tc_bw_tx,
12941 (void *)&cmd_vf_tc_bw_max_bw,
12942 (void *)&cmd_vf_tc_bw_port_id,
12943 (void *)&cmd_vf_tc_bw_vf_id,
12944 (void *)&cmd_vf_tc_bw_tc_no,
12945 (void *)&cmd_vf_tc_bw_bw,
12950 /** Set VXLAN encapsulation details */
12951 struct cmd_set_vxlan_result {
12952 cmdline_fixed_string_t set;
12953 cmdline_fixed_string_t vxlan;
12954 cmdline_fixed_string_t pos_token;
12955 cmdline_fixed_string_t ip_version;
12956 uint32_t vlan_present:1;
12960 cmdline_ipaddr_t ip_src;
12961 cmdline_ipaddr_t ip_dst;
12965 struct rte_ether_addr eth_src;
12966 struct rte_ether_addr eth_dst;
12969 cmdline_parse_token_string_t cmd_set_vxlan_set =
12970 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
12971 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
12972 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
12973 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
12974 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12976 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
12977 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12978 "vxlan-with-vlan");
12979 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
12980 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12982 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
12983 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
12985 cmdline_parse_token_string_t cmd_set_vxlan_vni =
12986 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12988 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
12989 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
12990 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
12991 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12993 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
12994 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
12995 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
12996 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12998 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
12999 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
13000 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
13001 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13003 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
13004 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
13005 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
13006 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13008 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
13009 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
13010 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
13011 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13013 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
13014 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
13015 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
13016 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13018 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
13019 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
13020 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
13021 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13023 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
13024 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
13025 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
13026 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13028 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
13029 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
13030 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
13031 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13033 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
13034 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
13036 static void cmd_set_vxlan_parsed(void *parsed_result,
13037 __rte_unused struct cmdline *cl,
13038 __rte_unused void *data)
13040 struct cmd_set_vxlan_result *res = parsed_result;
13045 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
13048 vxlan_encap_conf.select_tos_ttl = 0;
13049 if (strcmp(res->vxlan, "vxlan") == 0)
13050 vxlan_encap_conf.select_vlan = 0;
13051 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
13052 vxlan_encap_conf.select_vlan = 1;
13053 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
13054 vxlan_encap_conf.select_vlan = 0;
13055 vxlan_encap_conf.select_tos_ttl = 1;
13057 if (strcmp(res->ip_version, "ipv4") == 0)
13058 vxlan_encap_conf.select_ipv4 = 1;
13059 else if (strcmp(res->ip_version, "ipv6") == 0)
13060 vxlan_encap_conf.select_ipv4 = 0;
13063 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
13064 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13065 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13066 vxlan_encap_conf.ip_tos = res->tos;
13067 vxlan_encap_conf.ip_ttl = res->ttl;
13068 if (vxlan_encap_conf.select_ipv4) {
13069 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
13070 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
13072 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
13073 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
13075 if (vxlan_encap_conf.select_vlan)
13076 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13077 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
13078 RTE_ETHER_ADDR_LEN);
13079 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13080 RTE_ETHER_ADDR_LEN);
13083 cmdline_parse_inst_t cmd_set_vxlan = {
13084 .f = cmd_set_vxlan_parsed,
13086 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
13087 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
13088 " eth-src <eth-src> eth-dst <eth-dst>",
13090 (void *)&cmd_set_vxlan_set,
13091 (void *)&cmd_set_vxlan_vxlan,
13092 (void *)&cmd_set_vxlan_ip_version,
13093 (void *)&cmd_set_vxlan_ip_version_value,
13094 (void *)&cmd_set_vxlan_vni,
13095 (void *)&cmd_set_vxlan_vni_value,
13096 (void *)&cmd_set_vxlan_udp_src,
13097 (void *)&cmd_set_vxlan_udp_src_value,
13098 (void *)&cmd_set_vxlan_udp_dst,
13099 (void *)&cmd_set_vxlan_udp_dst_value,
13100 (void *)&cmd_set_vxlan_ip_src,
13101 (void *)&cmd_set_vxlan_ip_src_value,
13102 (void *)&cmd_set_vxlan_ip_dst,
13103 (void *)&cmd_set_vxlan_ip_dst_value,
13104 (void *)&cmd_set_vxlan_eth_src,
13105 (void *)&cmd_set_vxlan_eth_src_value,
13106 (void *)&cmd_set_vxlan_eth_dst,
13107 (void *)&cmd_set_vxlan_eth_dst_value,
13112 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
13113 .f = cmd_set_vxlan_parsed,
13115 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
13116 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
13117 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13118 " eth-dst <eth-dst>",
13120 (void *)&cmd_set_vxlan_set,
13121 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
13122 (void *)&cmd_set_vxlan_ip_version,
13123 (void *)&cmd_set_vxlan_ip_version_value,
13124 (void *)&cmd_set_vxlan_vni,
13125 (void *)&cmd_set_vxlan_vni_value,
13126 (void *)&cmd_set_vxlan_udp_src,
13127 (void *)&cmd_set_vxlan_udp_src_value,
13128 (void *)&cmd_set_vxlan_udp_dst,
13129 (void *)&cmd_set_vxlan_udp_dst_value,
13130 (void *)&cmd_set_vxlan_ip_tos,
13131 (void *)&cmd_set_vxlan_ip_tos_value,
13132 (void *)&cmd_set_vxlan_ip_ttl,
13133 (void *)&cmd_set_vxlan_ip_ttl_value,
13134 (void *)&cmd_set_vxlan_ip_src,
13135 (void *)&cmd_set_vxlan_ip_src_value,
13136 (void *)&cmd_set_vxlan_ip_dst,
13137 (void *)&cmd_set_vxlan_ip_dst_value,
13138 (void *)&cmd_set_vxlan_eth_src,
13139 (void *)&cmd_set_vxlan_eth_src_value,
13140 (void *)&cmd_set_vxlan_eth_dst,
13141 (void *)&cmd_set_vxlan_eth_dst_value,
13146 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
13147 .f = cmd_set_vxlan_parsed,
13149 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
13150 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
13151 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
13154 (void *)&cmd_set_vxlan_set,
13155 (void *)&cmd_set_vxlan_vxlan_with_vlan,
13156 (void *)&cmd_set_vxlan_ip_version,
13157 (void *)&cmd_set_vxlan_ip_version_value,
13158 (void *)&cmd_set_vxlan_vni,
13159 (void *)&cmd_set_vxlan_vni_value,
13160 (void *)&cmd_set_vxlan_udp_src,
13161 (void *)&cmd_set_vxlan_udp_src_value,
13162 (void *)&cmd_set_vxlan_udp_dst,
13163 (void *)&cmd_set_vxlan_udp_dst_value,
13164 (void *)&cmd_set_vxlan_ip_src,
13165 (void *)&cmd_set_vxlan_ip_src_value,
13166 (void *)&cmd_set_vxlan_ip_dst,
13167 (void *)&cmd_set_vxlan_ip_dst_value,
13168 (void *)&cmd_set_vxlan_vlan,
13169 (void *)&cmd_set_vxlan_vlan_value,
13170 (void *)&cmd_set_vxlan_eth_src,
13171 (void *)&cmd_set_vxlan_eth_src_value,
13172 (void *)&cmd_set_vxlan_eth_dst,
13173 (void *)&cmd_set_vxlan_eth_dst_value,
13178 /** Set NVGRE encapsulation details */
13179 struct cmd_set_nvgre_result {
13180 cmdline_fixed_string_t set;
13181 cmdline_fixed_string_t nvgre;
13182 cmdline_fixed_string_t pos_token;
13183 cmdline_fixed_string_t ip_version;
13185 cmdline_ipaddr_t ip_src;
13186 cmdline_ipaddr_t ip_dst;
13188 struct rte_ether_addr eth_src;
13189 struct rte_ether_addr eth_dst;
13192 cmdline_parse_token_string_t cmd_set_nvgre_set =
13193 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
13194 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
13195 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
13196 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
13197 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
13198 "nvgre-with-vlan");
13199 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
13200 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13202 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
13203 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
13205 cmdline_parse_token_string_t cmd_set_nvgre_tni =
13206 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13208 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
13209 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
13210 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
13211 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13213 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
13214 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
13215 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
13216 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13218 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
13219 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
13220 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
13221 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13223 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
13224 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
13225 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
13226 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13228 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
13229 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
13230 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
13231 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13233 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
13234 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
13236 static void cmd_set_nvgre_parsed(void *parsed_result,
13237 __rte_unused struct cmdline *cl,
13238 __rte_unused void *data)
13240 struct cmd_set_nvgre_result *res = parsed_result;
13242 uint32_t nvgre_tni;
13245 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
13248 if (strcmp(res->nvgre, "nvgre") == 0)
13249 nvgre_encap_conf.select_vlan = 0;
13250 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
13251 nvgre_encap_conf.select_vlan = 1;
13252 if (strcmp(res->ip_version, "ipv4") == 0)
13253 nvgre_encap_conf.select_ipv4 = 1;
13254 else if (strcmp(res->ip_version, "ipv6") == 0)
13255 nvgre_encap_conf.select_ipv4 = 0;
13258 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
13259 if (nvgre_encap_conf.select_ipv4) {
13260 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
13261 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
13263 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
13264 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
13266 if (nvgre_encap_conf.select_vlan)
13267 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13268 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
13269 RTE_ETHER_ADDR_LEN);
13270 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13271 RTE_ETHER_ADDR_LEN);
13274 cmdline_parse_inst_t cmd_set_nvgre = {
13275 .f = cmd_set_nvgre_parsed,
13277 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
13278 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13279 " eth-dst <eth-dst>",
13281 (void *)&cmd_set_nvgre_set,
13282 (void *)&cmd_set_nvgre_nvgre,
13283 (void *)&cmd_set_nvgre_ip_version,
13284 (void *)&cmd_set_nvgre_ip_version_value,
13285 (void *)&cmd_set_nvgre_tni,
13286 (void *)&cmd_set_nvgre_tni_value,
13287 (void *)&cmd_set_nvgre_ip_src,
13288 (void *)&cmd_set_nvgre_ip_src_value,
13289 (void *)&cmd_set_nvgre_ip_dst,
13290 (void *)&cmd_set_nvgre_ip_dst_value,
13291 (void *)&cmd_set_nvgre_eth_src,
13292 (void *)&cmd_set_nvgre_eth_src_value,
13293 (void *)&cmd_set_nvgre_eth_dst,
13294 (void *)&cmd_set_nvgre_eth_dst_value,
13299 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
13300 .f = cmd_set_nvgre_parsed,
13302 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
13303 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13304 " eth-src <eth-src> eth-dst <eth-dst>",
13306 (void *)&cmd_set_nvgre_set,
13307 (void *)&cmd_set_nvgre_nvgre_with_vlan,
13308 (void *)&cmd_set_nvgre_ip_version,
13309 (void *)&cmd_set_nvgre_ip_version_value,
13310 (void *)&cmd_set_nvgre_tni,
13311 (void *)&cmd_set_nvgre_tni_value,
13312 (void *)&cmd_set_nvgre_ip_src,
13313 (void *)&cmd_set_nvgre_ip_src_value,
13314 (void *)&cmd_set_nvgre_ip_dst,
13315 (void *)&cmd_set_nvgre_ip_dst_value,
13316 (void *)&cmd_set_nvgre_vlan,
13317 (void *)&cmd_set_nvgre_vlan_value,
13318 (void *)&cmd_set_nvgre_eth_src,
13319 (void *)&cmd_set_nvgre_eth_src_value,
13320 (void *)&cmd_set_nvgre_eth_dst,
13321 (void *)&cmd_set_nvgre_eth_dst_value,
13326 /** Set L2 encapsulation details */
13327 struct cmd_set_l2_encap_result {
13328 cmdline_fixed_string_t set;
13329 cmdline_fixed_string_t l2_encap;
13330 cmdline_fixed_string_t pos_token;
13331 cmdline_fixed_string_t ip_version;
13332 uint32_t vlan_present:1;
13334 struct rte_ether_addr eth_src;
13335 struct rte_ether_addr eth_dst;
13338 cmdline_parse_token_string_t cmd_set_l2_encap_set =
13339 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13340 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13341 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13342 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13343 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13344 "l2_encap-with-vlan");
13345 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13346 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13348 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13349 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13351 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13352 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13354 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13355 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13356 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13357 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13359 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13360 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13361 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13362 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13364 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13365 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13367 static void cmd_set_l2_encap_parsed(void *parsed_result,
13368 __rte_unused struct cmdline *cl,
13369 __rte_unused void *data)
13371 struct cmd_set_l2_encap_result *res = parsed_result;
13373 if (strcmp(res->l2_encap, "l2_encap") == 0)
13374 l2_encap_conf.select_vlan = 0;
13375 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13376 l2_encap_conf.select_vlan = 1;
13377 if (strcmp(res->ip_version, "ipv4") == 0)
13378 l2_encap_conf.select_ipv4 = 1;
13379 else if (strcmp(res->ip_version, "ipv6") == 0)
13380 l2_encap_conf.select_ipv4 = 0;
13383 if (l2_encap_conf.select_vlan)
13384 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13385 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13386 RTE_ETHER_ADDR_LEN);
13387 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13388 RTE_ETHER_ADDR_LEN);
13391 cmdline_parse_inst_t cmd_set_l2_encap = {
13392 .f = cmd_set_l2_encap_parsed,
13394 .help_str = "set l2_encap ip-version ipv4|ipv6"
13395 " eth-src <eth-src> eth-dst <eth-dst>",
13397 (void *)&cmd_set_l2_encap_set,
13398 (void *)&cmd_set_l2_encap_l2_encap,
13399 (void *)&cmd_set_l2_encap_ip_version,
13400 (void *)&cmd_set_l2_encap_ip_version_value,
13401 (void *)&cmd_set_l2_encap_eth_src,
13402 (void *)&cmd_set_l2_encap_eth_src_value,
13403 (void *)&cmd_set_l2_encap_eth_dst,
13404 (void *)&cmd_set_l2_encap_eth_dst_value,
13409 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13410 .f = cmd_set_l2_encap_parsed,
13412 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13413 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13415 (void *)&cmd_set_l2_encap_set,
13416 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13417 (void *)&cmd_set_l2_encap_ip_version,
13418 (void *)&cmd_set_l2_encap_ip_version_value,
13419 (void *)&cmd_set_l2_encap_vlan,
13420 (void *)&cmd_set_l2_encap_vlan_value,
13421 (void *)&cmd_set_l2_encap_eth_src,
13422 (void *)&cmd_set_l2_encap_eth_src_value,
13423 (void *)&cmd_set_l2_encap_eth_dst,
13424 (void *)&cmd_set_l2_encap_eth_dst_value,
13429 /** Set L2 decapsulation details */
13430 struct cmd_set_l2_decap_result {
13431 cmdline_fixed_string_t set;
13432 cmdline_fixed_string_t l2_decap;
13433 cmdline_fixed_string_t pos_token;
13434 uint32_t vlan_present:1;
13437 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13438 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13439 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13440 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13442 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13443 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13444 "l2_decap-with-vlan");
13446 static void cmd_set_l2_decap_parsed(void *parsed_result,
13447 __rte_unused struct cmdline *cl,
13448 __rte_unused void *data)
13450 struct cmd_set_l2_decap_result *res = parsed_result;
13452 if (strcmp(res->l2_decap, "l2_decap") == 0)
13453 l2_decap_conf.select_vlan = 0;
13454 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13455 l2_decap_conf.select_vlan = 1;
13458 cmdline_parse_inst_t cmd_set_l2_decap = {
13459 .f = cmd_set_l2_decap_parsed,
13461 .help_str = "set l2_decap",
13463 (void *)&cmd_set_l2_decap_set,
13464 (void *)&cmd_set_l2_decap_l2_decap,
13469 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13470 .f = cmd_set_l2_decap_parsed,
13472 .help_str = "set l2_decap-with-vlan",
13474 (void *)&cmd_set_l2_decap_set,
13475 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13480 /** Set MPLSoGRE encapsulation details */
13481 struct cmd_set_mplsogre_encap_result {
13482 cmdline_fixed_string_t set;
13483 cmdline_fixed_string_t mplsogre;
13484 cmdline_fixed_string_t pos_token;
13485 cmdline_fixed_string_t ip_version;
13486 uint32_t vlan_present:1;
13488 cmdline_ipaddr_t ip_src;
13489 cmdline_ipaddr_t ip_dst;
13491 struct rte_ether_addr eth_src;
13492 struct rte_ether_addr eth_dst;
13495 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13496 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13498 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13499 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13501 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13502 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13503 mplsogre, "mplsogre_encap-with-vlan");
13504 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13505 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13506 pos_token, "ip-version");
13507 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13508 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13509 ip_version, "ipv4#ipv6");
13510 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13511 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13512 pos_token, "label");
13513 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13514 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13516 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13517 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13518 pos_token, "ip-src");
13519 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13520 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13521 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13522 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13523 pos_token, "ip-dst");
13524 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13525 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13526 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13527 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13528 pos_token, "vlan-tci");
13529 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13530 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13532 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13533 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13534 pos_token, "eth-src");
13535 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13536 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13538 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13539 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13540 pos_token, "eth-dst");
13541 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13542 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13545 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13546 __rte_unused struct cmdline *cl,
13547 __rte_unused void *data)
13549 struct cmd_set_mplsogre_encap_result *res = parsed_result;
13551 uint32_t mplsogre_label;
13554 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13557 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13558 mplsogre_encap_conf.select_vlan = 0;
13559 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13560 mplsogre_encap_conf.select_vlan = 1;
13561 if (strcmp(res->ip_version, "ipv4") == 0)
13562 mplsogre_encap_conf.select_ipv4 = 1;
13563 else if (strcmp(res->ip_version, "ipv6") == 0)
13564 mplsogre_encap_conf.select_ipv4 = 0;
13567 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13568 if (mplsogre_encap_conf.select_ipv4) {
13569 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13570 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13572 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13573 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13575 if (mplsogre_encap_conf.select_vlan)
13576 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13577 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13578 RTE_ETHER_ADDR_LEN);
13579 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13580 RTE_ETHER_ADDR_LEN);
13583 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13584 .f = cmd_set_mplsogre_encap_parsed,
13586 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13587 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13588 " eth-dst <eth-dst>",
13590 (void *)&cmd_set_mplsogre_encap_set,
13591 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13592 (void *)&cmd_set_mplsogre_encap_ip_version,
13593 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13594 (void *)&cmd_set_mplsogre_encap_label,
13595 (void *)&cmd_set_mplsogre_encap_label_value,
13596 (void *)&cmd_set_mplsogre_encap_ip_src,
13597 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13598 (void *)&cmd_set_mplsogre_encap_ip_dst,
13599 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13600 (void *)&cmd_set_mplsogre_encap_eth_src,
13601 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13602 (void *)&cmd_set_mplsogre_encap_eth_dst,
13603 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13608 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13609 .f = cmd_set_mplsogre_encap_parsed,
13611 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13612 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
13613 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13615 (void *)&cmd_set_mplsogre_encap_set,
13616 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13617 (void *)&cmd_set_mplsogre_encap_ip_version,
13618 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13619 (void *)&cmd_set_mplsogre_encap_label,
13620 (void *)&cmd_set_mplsogre_encap_label_value,
13621 (void *)&cmd_set_mplsogre_encap_ip_src,
13622 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13623 (void *)&cmd_set_mplsogre_encap_ip_dst,
13624 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13625 (void *)&cmd_set_mplsogre_encap_vlan,
13626 (void *)&cmd_set_mplsogre_encap_vlan_value,
13627 (void *)&cmd_set_mplsogre_encap_eth_src,
13628 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13629 (void *)&cmd_set_mplsogre_encap_eth_dst,
13630 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13635 /** Set MPLSoGRE decapsulation details */
13636 struct cmd_set_mplsogre_decap_result {
13637 cmdline_fixed_string_t set;
13638 cmdline_fixed_string_t mplsogre;
13639 cmdline_fixed_string_t pos_token;
13640 cmdline_fixed_string_t ip_version;
13641 uint32_t vlan_present:1;
13644 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13645 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13647 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13648 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13650 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13651 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13652 mplsogre, "mplsogre_decap-with-vlan");
13653 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13654 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13655 pos_token, "ip-version");
13656 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13657 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13658 ip_version, "ipv4#ipv6");
13660 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13661 __rte_unused struct cmdline *cl,
13662 __rte_unused void *data)
13664 struct cmd_set_mplsogre_decap_result *res = parsed_result;
13666 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13667 mplsogre_decap_conf.select_vlan = 0;
13668 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13669 mplsogre_decap_conf.select_vlan = 1;
13670 if (strcmp(res->ip_version, "ipv4") == 0)
13671 mplsogre_decap_conf.select_ipv4 = 1;
13672 else if (strcmp(res->ip_version, "ipv6") == 0)
13673 mplsogre_decap_conf.select_ipv4 = 0;
13676 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13677 .f = cmd_set_mplsogre_decap_parsed,
13679 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13681 (void *)&cmd_set_mplsogre_decap_set,
13682 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13683 (void *)&cmd_set_mplsogre_decap_ip_version,
13684 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13689 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13690 .f = cmd_set_mplsogre_decap_parsed,
13692 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13694 (void *)&cmd_set_mplsogre_decap_set,
13695 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13696 (void *)&cmd_set_mplsogre_decap_ip_version,
13697 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13702 /** Set MPLSoUDP encapsulation details */
13703 struct cmd_set_mplsoudp_encap_result {
13704 cmdline_fixed_string_t set;
13705 cmdline_fixed_string_t mplsoudp;
13706 cmdline_fixed_string_t pos_token;
13707 cmdline_fixed_string_t ip_version;
13708 uint32_t vlan_present:1;
13712 cmdline_ipaddr_t ip_src;
13713 cmdline_ipaddr_t ip_dst;
13715 struct rte_ether_addr eth_src;
13716 struct rte_ether_addr eth_dst;
13719 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13720 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13722 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13723 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13725 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13726 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13727 mplsoudp, "mplsoudp_encap-with-vlan");
13728 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13729 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13730 pos_token, "ip-version");
13731 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13732 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13733 ip_version, "ipv4#ipv6");
13734 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13735 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13736 pos_token, "label");
13737 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13738 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13740 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13741 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13742 pos_token, "udp-src");
13743 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13744 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13746 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13747 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13748 pos_token, "udp-dst");
13749 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13750 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13752 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13753 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13754 pos_token, "ip-src");
13755 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13756 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13757 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13758 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13759 pos_token, "ip-dst");
13760 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13761 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13762 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13763 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13764 pos_token, "vlan-tci");
13765 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13766 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13768 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13769 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13770 pos_token, "eth-src");
13771 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13772 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13774 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13775 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13776 pos_token, "eth-dst");
13777 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13778 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13781 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13782 __rte_unused struct cmdline *cl,
13783 __rte_unused void *data)
13785 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13787 uint32_t mplsoudp_label;
13790 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13793 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13794 mplsoudp_encap_conf.select_vlan = 0;
13795 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13796 mplsoudp_encap_conf.select_vlan = 1;
13797 if (strcmp(res->ip_version, "ipv4") == 0)
13798 mplsoudp_encap_conf.select_ipv4 = 1;
13799 else if (strcmp(res->ip_version, "ipv6") == 0)
13800 mplsoudp_encap_conf.select_ipv4 = 0;
13803 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13804 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13805 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13806 if (mplsoudp_encap_conf.select_ipv4) {
13807 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13808 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13810 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13811 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13813 if (mplsoudp_encap_conf.select_vlan)
13814 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13815 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13816 RTE_ETHER_ADDR_LEN);
13817 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13818 RTE_ETHER_ADDR_LEN);
13821 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13822 .f = cmd_set_mplsoudp_encap_parsed,
13824 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13825 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13826 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13828 (void *)&cmd_set_mplsoudp_encap_set,
13829 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13830 (void *)&cmd_set_mplsoudp_encap_ip_version,
13831 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13832 (void *)&cmd_set_mplsoudp_encap_label,
13833 (void *)&cmd_set_mplsoudp_encap_label_value,
13834 (void *)&cmd_set_mplsoudp_encap_udp_src,
13835 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13836 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13837 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13838 (void *)&cmd_set_mplsoudp_encap_ip_src,
13839 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13840 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13841 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13842 (void *)&cmd_set_mplsoudp_encap_eth_src,
13843 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13844 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13845 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13850 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13851 .f = cmd_set_mplsoudp_encap_parsed,
13853 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13854 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
13855 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13856 " eth-src <eth-src> eth-dst <eth-dst>",
13858 (void *)&cmd_set_mplsoudp_encap_set,
13859 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13860 (void *)&cmd_set_mplsoudp_encap_ip_version,
13861 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13862 (void *)&cmd_set_mplsoudp_encap_label,
13863 (void *)&cmd_set_mplsoudp_encap_label_value,
13864 (void *)&cmd_set_mplsoudp_encap_udp_src,
13865 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13866 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13867 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13868 (void *)&cmd_set_mplsoudp_encap_ip_src,
13869 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13870 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13871 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13872 (void *)&cmd_set_mplsoudp_encap_vlan,
13873 (void *)&cmd_set_mplsoudp_encap_vlan_value,
13874 (void *)&cmd_set_mplsoudp_encap_eth_src,
13875 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13876 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13877 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13882 /** Set MPLSoUDP decapsulation details */
13883 struct cmd_set_mplsoudp_decap_result {
13884 cmdline_fixed_string_t set;
13885 cmdline_fixed_string_t mplsoudp;
13886 cmdline_fixed_string_t pos_token;
13887 cmdline_fixed_string_t ip_version;
13888 uint32_t vlan_present:1;
13891 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
13892 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
13894 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
13895 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
13897 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
13898 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13899 mplsoudp, "mplsoudp_decap-with-vlan");
13900 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
13901 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13902 pos_token, "ip-version");
13903 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
13904 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13905 ip_version, "ipv4#ipv6");
13907 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
13908 __rte_unused struct cmdline *cl,
13909 __rte_unused void *data)
13911 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
13913 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
13914 mplsoudp_decap_conf.select_vlan = 0;
13915 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
13916 mplsoudp_decap_conf.select_vlan = 1;
13917 if (strcmp(res->ip_version, "ipv4") == 0)
13918 mplsoudp_decap_conf.select_ipv4 = 1;
13919 else if (strcmp(res->ip_version, "ipv6") == 0)
13920 mplsoudp_decap_conf.select_ipv4 = 0;
13923 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
13924 .f = cmd_set_mplsoudp_decap_parsed,
13926 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
13928 (void *)&cmd_set_mplsoudp_decap_set,
13929 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
13930 (void *)&cmd_set_mplsoudp_decap_ip_version,
13931 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13936 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
13937 .f = cmd_set_mplsoudp_decap_parsed,
13939 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
13941 (void *)&cmd_set_mplsoudp_decap_set,
13942 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
13943 (void *)&cmd_set_mplsoudp_decap_ip_version,
13944 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13949 /** Set connection tracking object common details */
13950 struct cmd_set_conntrack_common_result {
13951 cmdline_fixed_string_t set;
13952 cmdline_fixed_string_t conntrack;
13953 cmdline_fixed_string_t common;
13954 cmdline_fixed_string_t peer;
13955 cmdline_fixed_string_t is_orig;
13956 cmdline_fixed_string_t enable;
13957 cmdline_fixed_string_t live;
13958 cmdline_fixed_string_t sack;
13959 cmdline_fixed_string_t cack;
13960 cmdline_fixed_string_t last_dir;
13961 cmdline_fixed_string_t liberal;
13962 cmdline_fixed_string_t state;
13963 cmdline_fixed_string_t max_ack_win;
13964 cmdline_fixed_string_t retrans;
13965 cmdline_fixed_string_t last_win;
13966 cmdline_fixed_string_t last_seq;
13967 cmdline_fixed_string_t last_ack;
13968 cmdline_fixed_string_t last_end;
13969 cmdline_fixed_string_t last_index;
13972 uint16_t peer_port;
13973 uint32_t is_original;
13988 cmdline_parse_token_string_t cmd_set_conntrack_set =
13989 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13991 cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
13992 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13993 conntrack, "conntrack");
13994 cmdline_parse_token_string_t cmd_set_conntrack_common_com =
13995 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13997 cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
13998 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14000 cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
14001 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14002 peer_port, RTE_UINT16);
14003 cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
14004 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14005 is_orig, "is_orig");
14006 cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
14007 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14008 is_original, RTE_UINT32);
14009 cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
14010 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14012 cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
14013 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14015 cmdline_parse_token_string_t cmd_set_conntrack_common_live =
14016 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14018 cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
14019 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14020 is_live, RTE_UINT32);
14021 cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
14022 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14024 cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
14025 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14026 s_ack, RTE_UINT32);
14027 cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
14028 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14030 cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
14031 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14032 c_ack, RTE_UINT32);
14033 cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
14034 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14035 last_dir, "last_dir");
14036 cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
14037 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14039 cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
14040 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14041 liberal, "liberal");
14042 cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
14043 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14045 cmdline_parse_token_string_t cmd_set_conntrack_common_state =
14046 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14048 cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
14049 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14051 cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
14052 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14053 max_ack_win, "max_ack_win");
14054 cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
14055 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14056 factor, RTE_UINT8);
14057 cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
14058 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14060 cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
14061 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14062 re_num, RTE_UINT8);
14063 cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
14064 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14065 last_win, "last_win");
14066 cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
14067 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14069 cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
14070 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14071 last_seq, "last_seq");
14072 cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
14073 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14075 cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
14076 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14077 last_ack, "last_ack");
14078 cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
14079 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14081 cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
14082 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14083 last_end, "last_end");
14084 cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
14085 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14087 cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
14088 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14089 last_index, "last_index");
14090 cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
14091 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14094 static void cmd_set_conntrack_common_parsed(void *parsed_result,
14095 __rte_unused struct cmdline *cl,
14096 __rte_unused void *data)
14098 struct cmd_set_conntrack_common_result *res = parsed_result;
14100 /* No need to swap to big endian. */
14101 conntrack_context.peer_port = res->peer_port;
14102 conntrack_context.is_original_dir = res->is_original;
14103 conntrack_context.enable = res->en;
14104 conntrack_context.live_connection = res->is_live;
14105 conntrack_context.selective_ack = res->s_ack;
14106 conntrack_context.challenge_ack_passed = res->c_ack;
14107 conntrack_context.last_direction = res->ld;
14108 conntrack_context.liberal_mode = res->lb;
14109 conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
14110 conntrack_context.max_ack_window = res->factor;
14111 conntrack_context.retransmission_limit = res->re_num;
14112 conntrack_context.last_window = res->lw;
14113 conntrack_context.last_index =
14114 (enum rte_flow_conntrack_tcp_last_index)res->li;
14115 conntrack_context.last_seq = res->ls;
14116 conntrack_context.last_ack = res->la;
14117 conntrack_context.last_end = res->le;
14120 cmdline_parse_inst_t cmd_set_conntrack_common = {
14121 .f = cmd_set_conntrack_common_parsed,
14123 .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
14124 " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
14125 " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
14126 " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
14127 " last_index <flag>",
14129 (void *)&cmd_set_conntrack_set,
14130 (void *)&cmd_set_conntrack_conntrack,
14131 (void *)&cmd_set_conntrack_common_com,
14132 (void *)&cmd_set_conntrack_common_peer,
14133 (void *)&cmd_set_conntrack_common_peer_value,
14134 (void *)&cmd_set_conntrack_common_is_orig,
14135 (void *)&cmd_set_conntrack_common_is_orig_value,
14136 (void *)&cmd_set_conntrack_common_enable,
14137 (void *)&cmd_set_conntrack_common_enable_value,
14138 (void *)&cmd_set_conntrack_common_live,
14139 (void *)&cmd_set_conntrack_common_live_value,
14140 (void *)&cmd_set_conntrack_common_sack,
14141 (void *)&cmd_set_conntrack_common_sack_value,
14142 (void *)&cmd_set_conntrack_common_cack,
14143 (void *)&cmd_set_conntrack_common_cack_value,
14144 (void *)&cmd_set_conntrack_common_last_dir,
14145 (void *)&cmd_set_conntrack_common_last_dir_value,
14146 (void *)&cmd_set_conntrack_common_liberal,
14147 (void *)&cmd_set_conntrack_common_liberal_value,
14148 (void *)&cmd_set_conntrack_common_state,
14149 (void *)&cmd_set_conntrack_common_state_value,
14150 (void *)&cmd_set_conntrack_common_max_ackwin,
14151 (void *)&cmd_set_conntrack_common_max_ackwin_value,
14152 (void *)&cmd_set_conntrack_common_retrans,
14153 (void *)&cmd_set_conntrack_common_retrans_value,
14154 (void *)&cmd_set_conntrack_common_last_win,
14155 (void *)&cmd_set_conntrack_common_last_win_value,
14156 (void *)&cmd_set_conntrack_common_last_seq,
14157 (void *)&cmd_set_conntrack_common_last_seq_value,
14158 (void *)&cmd_set_conntrack_common_last_ack,
14159 (void *)&cmd_set_conntrack_common_last_ack_value,
14160 (void *)&cmd_set_conntrack_common_last_end,
14161 (void *)&cmd_set_conntrack_common_last_end_value,
14162 (void *)&cmd_set_conntrack_common_last_index,
14163 (void *)&cmd_set_conntrack_common_last_index_value,
14168 /** Set connection tracking object both directions' details */
14169 struct cmd_set_conntrack_dir_result {
14170 cmdline_fixed_string_t set;
14171 cmdline_fixed_string_t conntrack;
14172 cmdline_fixed_string_t dir;
14173 cmdline_fixed_string_t scale;
14174 cmdline_fixed_string_t fin;
14175 cmdline_fixed_string_t ack_seen;
14176 cmdline_fixed_string_t unack;
14177 cmdline_fixed_string_t sent_end;
14178 cmdline_fixed_string_t reply_end;
14179 cmdline_fixed_string_t max_win;
14180 cmdline_fixed_string_t max_ack;
14191 cmdline_parse_token_string_t cmd_set_conntrack_dir_set =
14192 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14194 cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack =
14195 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14196 conntrack, "conntrack");
14197 cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
14198 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14200 cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
14201 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14203 cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
14204 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14205 factor, RTE_UINT32);
14206 cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
14207 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14209 cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
14210 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14212 cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
14213 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14214 ack_seen, "acked");
14215 cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
14216 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14218 cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
14219 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14220 unack, "unack_data");
14221 cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
14222 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14224 cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
14225 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14226 sent_end, "sent_end");
14227 cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
14228 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14230 cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
14231 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14232 reply_end, "reply_end");
14233 cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
14234 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14236 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
14237 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14238 max_win, "max_win");
14239 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
14240 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14242 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
14243 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14244 max_ack, "max_ack");
14245 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
14246 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14249 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
14250 __rte_unused struct cmdline *cl,
14251 __rte_unused void *data)
14253 struct cmd_set_conntrack_dir_result *res = parsed_result;
14254 struct rte_flow_tcp_dir_param *dir = NULL;
14256 if (strcmp(res->dir, "orig") == 0)
14257 dir = &conntrack_context.original_dir;
14258 else if (strcmp(res->dir, "rply") == 0)
14259 dir = &conntrack_context.reply_dir;
14262 dir->scale = res->factor;
14263 dir->close_initiated = res->f;
14264 dir->last_ack_seen = res->as;
14265 dir->data_unacked = res->un;
14266 dir->sent_end = res->se;
14267 dir->reply_end = res->re;
14268 dir->max_ack = res->ma;
14269 dir->max_win = res->mw;
14272 cmdline_parse_inst_t cmd_set_conntrack_dir = {
14273 .f = cmd_set_conntrack_dir_parsed,
14275 .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
14276 " acked <seen> unack_data <unack> sent_end <sent>"
14277 " reply_end <reply> max_win <win> max_ack <ack>",
14279 (void *)&cmd_set_conntrack_set,
14280 (void *)&cmd_set_conntrack_conntrack,
14281 (void *)&cmd_set_conntrack_dir_dir,
14282 (void *)&cmd_set_conntrack_dir_scale,
14283 (void *)&cmd_set_conntrack_dir_scale_value,
14284 (void *)&cmd_set_conntrack_dir_fin,
14285 (void *)&cmd_set_conntrack_dir_fin_value,
14286 (void *)&cmd_set_conntrack_dir_ack,
14287 (void *)&cmd_set_conntrack_dir_ack_value,
14288 (void *)&cmd_set_conntrack_dir_unack_data,
14289 (void *)&cmd_set_conntrack_dir_unack_data_value,
14290 (void *)&cmd_set_conntrack_dir_sent_end,
14291 (void *)&cmd_set_conntrack_dir_sent_end_value,
14292 (void *)&cmd_set_conntrack_dir_reply_end,
14293 (void *)&cmd_set_conntrack_dir_reply_end_value,
14294 (void *)&cmd_set_conntrack_dir_max_win,
14295 (void *)&cmd_set_conntrack_dir_max_win_value,
14296 (void *)&cmd_set_conntrack_dir_max_ack,
14297 (void *)&cmd_set_conntrack_dir_max_ack_value,
14302 /* Strict link priority scheduling mode setting */
14304 cmd_strict_link_prio_parsed(
14305 void *parsed_result,
14306 __rte_unused struct cmdline *cl,
14307 __rte_unused void *data)
14309 struct cmd_vf_tc_bw_result *res = parsed_result;
14310 int ret = -ENOTSUP;
14312 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14315 #ifdef RTE_NET_I40E
14316 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14323 fprintf(stderr, "invalid tc_bitmap 0x%x\n", res->tc_map);
14326 fprintf(stderr, "invalid port_id %d\n", res->port_id);
14329 fprintf(stderr, "function not implemented\n");
14332 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
14336 cmdline_parse_inst_t cmd_strict_link_prio = {
14337 .f = cmd_strict_link_prio_parsed,
14339 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14341 (void *)&cmd_vf_tc_bw_set,
14342 (void *)&cmd_vf_tc_bw_tx,
14343 (void *)&cmd_vf_tc_bw_strict_link_prio,
14344 (void *)&cmd_vf_tc_bw_port_id,
14345 (void *)&cmd_vf_tc_bw_tc_map,
14350 /* Load dynamic device personalization*/
14351 struct cmd_ddp_add_result {
14352 cmdline_fixed_string_t ddp;
14353 cmdline_fixed_string_t add;
14358 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14359 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14360 cmdline_parse_token_string_t cmd_ddp_add_add =
14361 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14362 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14363 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
14365 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14366 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14369 cmd_ddp_add_parsed(
14370 void *parsed_result,
14371 __rte_unused struct cmdline *cl,
14372 __rte_unused void *data)
14374 struct cmd_ddp_add_result *res = parsed_result;
14380 int ret = -ENOTSUP;
14382 if (!all_ports_stopped()) {
14383 fprintf(stderr, "Please stop all ports first\n");
14387 filepath = strdup(res->filepath);
14388 if (filepath == NULL) {
14389 fprintf(stderr, "Failed to allocate memory\n");
14392 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14394 buff = open_file(file_fld[0], &size);
14396 free((void *)filepath);
14400 #ifdef RTE_NET_I40E
14401 if (ret == -ENOTSUP)
14402 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14404 RTE_PMD_I40E_PKG_OP_WR_ADD);
14407 if (ret == -EEXIST)
14408 fprintf(stderr, "Profile has already existed.\n");
14410 fprintf(stderr, "Failed to load profile.\n");
14411 else if (file_num == 2)
14412 save_file(file_fld[1], buff, size);
14415 free((void *)filepath);
14418 cmdline_parse_inst_t cmd_ddp_add = {
14419 .f = cmd_ddp_add_parsed,
14421 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14423 (void *)&cmd_ddp_add_ddp,
14424 (void *)&cmd_ddp_add_add,
14425 (void *)&cmd_ddp_add_port_id,
14426 (void *)&cmd_ddp_add_filepath,
14431 /* Delete dynamic device personalization*/
14432 struct cmd_ddp_del_result {
14433 cmdline_fixed_string_t ddp;
14434 cmdline_fixed_string_t del;
14439 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14440 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14441 cmdline_parse_token_string_t cmd_ddp_del_del =
14442 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14443 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14444 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
14445 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14446 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14449 cmd_ddp_del_parsed(
14450 void *parsed_result,
14451 __rte_unused struct cmdline *cl,
14452 __rte_unused void *data)
14454 struct cmd_ddp_del_result *res = parsed_result;
14457 int ret = -ENOTSUP;
14459 if (!all_ports_stopped()) {
14460 fprintf(stderr, "Please stop all ports first\n");
14464 buff = open_file(res->filepath, &size);
14468 #ifdef RTE_NET_I40E
14469 if (ret == -ENOTSUP)
14470 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14472 RTE_PMD_I40E_PKG_OP_WR_DEL);
14475 if (ret == -EACCES)
14476 fprintf(stderr, "Profile does not exist.\n");
14478 fprintf(stderr, "Failed to delete profile.\n");
14483 cmdline_parse_inst_t cmd_ddp_del = {
14484 .f = cmd_ddp_del_parsed,
14486 .help_str = "ddp del <port_id> <backup_profile_path>",
14488 (void *)&cmd_ddp_del_ddp,
14489 (void *)&cmd_ddp_del_del,
14490 (void *)&cmd_ddp_del_port_id,
14491 (void *)&cmd_ddp_del_filepath,
14496 /* Get dynamic device personalization profile info */
14497 struct cmd_ddp_info_result {
14498 cmdline_fixed_string_t ddp;
14499 cmdline_fixed_string_t get;
14500 cmdline_fixed_string_t info;
14504 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14505 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14506 cmdline_parse_token_string_t cmd_ddp_info_get =
14507 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14508 cmdline_parse_token_string_t cmd_ddp_info_info =
14509 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14510 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14511 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14514 cmd_ddp_info_parsed(
14515 void *parsed_result,
14516 __rte_unused struct cmdline *cl,
14517 __rte_unused void *data)
14519 struct cmd_ddp_info_result *res = parsed_result;
14522 int ret = -ENOTSUP;
14523 #ifdef RTE_NET_I40E
14526 uint32_t buff_size = 0;
14527 struct rte_pmd_i40e_profile_info info;
14528 uint32_t dev_num = 0;
14529 struct rte_pmd_i40e_ddp_device_id *devs;
14530 uint32_t proto_num = 0;
14531 struct rte_pmd_i40e_proto_info *proto = NULL;
14532 uint32_t pctype_num = 0;
14533 struct rte_pmd_i40e_ptype_info *pctype;
14534 uint32_t ptype_num = 0;
14535 struct rte_pmd_i40e_ptype_info *ptype;
14540 pkg = open_file(res->filepath, &pkg_size);
14544 #ifdef RTE_NET_I40E
14545 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14546 (uint8_t *)&info, sizeof(info),
14547 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14549 printf("Global Track id: 0x%x\n", info.track_id);
14550 printf("Global Version: %d.%d.%d.%d\n",
14551 info.version.major,
14552 info.version.minor,
14553 info.version.update,
14554 info.version.draft);
14555 printf("Global Package name: %s\n\n", info.name);
14558 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14559 (uint8_t *)&info, sizeof(info),
14560 RTE_PMD_I40E_PKG_INFO_HEADER);
14562 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14563 printf("i40e Profile Version: %d.%d.%d.%d\n",
14564 info.version.major,
14565 info.version.minor,
14566 info.version.update,
14567 info.version.draft);
14568 printf("i40e Profile name: %s\n\n", info.name);
14571 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14572 (uint8_t *)&buff_size, sizeof(buff_size),
14573 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14574 if (!ret && buff_size) {
14575 buff = (uint8_t *)malloc(buff_size);
14577 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14579 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14581 printf("Package Notes:\n%s\n\n", buff);
14586 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14587 (uint8_t *)&dev_num, sizeof(dev_num),
14588 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14589 if (!ret && dev_num) {
14590 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14591 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14593 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14594 (uint8_t *)devs, buff_size,
14595 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14597 printf("List of supported devices:\n");
14598 for (i = 0; i < dev_num; i++) {
14599 printf(" %04X:%04X %04X:%04X\n",
14600 devs[i].vendor_dev_id >> 16,
14601 devs[i].vendor_dev_id & 0xFFFF,
14602 devs[i].sub_vendor_dev_id >> 16,
14603 devs[i].sub_vendor_dev_id & 0xFFFF);
14611 /* get information about protocols and packet types */
14612 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14613 (uint8_t *)&proto_num, sizeof(proto_num),
14614 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14615 if (ret || !proto_num)
14616 goto no_print_return;
14618 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14619 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14621 goto no_print_return;
14623 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14625 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14627 printf("List of used protocols:\n");
14628 for (i = 0; i < proto_num; i++)
14629 printf(" %2u: %s\n", proto[i].proto_id,
14633 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14634 (uint8_t *)&pctype_num, sizeof(pctype_num),
14635 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14636 if (ret || !pctype_num)
14637 goto no_print_pctypes;
14639 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14640 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14642 goto no_print_pctypes;
14644 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14646 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14649 goto no_print_pctypes;
14652 printf("List of defined packet classification types:\n");
14653 for (i = 0; i < pctype_num; i++) {
14654 printf(" %2u:", pctype[i].ptype_id);
14655 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14656 proto_id = pctype[i].protocols[j];
14657 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14658 for (n = 0; n < proto_num; n++) {
14659 if (proto[n].proto_id == proto_id) {
14660 printf(" %s", proto[n].name);
14673 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14675 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14676 if (ret || !ptype_num)
14677 goto no_print_return;
14679 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14680 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14682 goto no_print_return;
14684 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14686 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14689 goto no_print_return;
14691 printf("List of defined packet types:\n");
14692 for (i = 0; i < ptype_num; i++) {
14693 printf(" %2u:", ptype[i].ptype_id);
14694 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14695 proto_id = ptype[i].protocols[j];
14696 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14697 for (n = 0; n < proto_num; n++) {
14698 if (proto[n].proto_id == proto_id) {
14699 printf(" %s", proto[n].name);
14715 if (ret == -ENOTSUP)
14716 fprintf(stderr, "Function not supported in PMD\n");
14720 cmdline_parse_inst_t cmd_ddp_get_info = {
14721 .f = cmd_ddp_info_parsed,
14723 .help_str = "ddp get info <profile_path>",
14725 (void *)&cmd_ddp_info_ddp,
14726 (void *)&cmd_ddp_info_get,
14727 (void *)&cmd_ddp_info_info,
14728 (void *)&cmd_ddp_info_filepath,
14733 /* Get dynamic device personalization profile info list*/
14734 #define PROFILE_INFO_SIZE 48
14735 #define MAX_PROFILE_NUM 16
14737 struct cmd_ddp_get_list_result {
14738 cmdline_fixed_string_t ddp;
14739 cmdline_fixed_string_t get;
14740 cmdline_fixed_string_t list;
14744 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14745 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14746 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14747 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14748 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14749 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14750 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14751 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14755 cmd_ddp_get_list_parsed(
14756 __rte_unused void *parsed_result,
14757 __rte_unused struct cmdline *cl,
14758 __rte_unused void *data)
14760 #ifdef RTE_NET_I40E
14761 struct cmd_ddp_get_list_result *res = parsed_result;
14762 struct rte_pmd_i40e_profile_list *p_list;
14763 struct rte_pmd_i40e_profile_info *p_info;
14768 int ret = -ENOTSUP;
14770 #ifdef RTE_NET_I40E
14771 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14772 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14774 fprintf(stderr, "%s: Failed to malloc buffer\n", __func__);
14778 if (ret == -ENOTSUP)
14779 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14780 (uint8_t *)p_list, size);
14783 p_num = p_list->p_count;
14784 printf("Profile number is: %d\n\n", p_num);
14786 for (i = 0; i < p_num; i++) {
14787 p_info = &p_list->p_info[i];
14788 printf("Profile %d:\n", i);
14789 printf("Track id: 0x%x\n", p_info->track_id);
14790 printf("Version: %d.%d.%d.%d\n",
14791 p_info->version.major,
14792 p_info->version.minor,
14793 p_info->version.update,
14794 p_info->version.draft);
14795 printf("Profile name: %s\n\n", p_info->name);
14803 fprintf(stderr, "Failed to get ddp list\n");
14806 cmdline_parse_inst_t cmd_ddp_get_list = {
14807 .f = cmd_ddp_get_list_parsed,
14809 .help_str = "ddp get list <port_id>",
14811 (void *)&cmd_ddp_get_list_ddp,
14812 (void *)&cmd_ddp_get_list_get,
14813 (void *)&cmd_ddp_get_list_list,
14814 (void *)&cmd_ddp_get_list_port_id,
14819 /* Configure input set */
14820 struct cmd_cfg_input_set_result {
14821 cmdline_fixed_string_t port;
14822 cmdline_fixed_string_t cfg;
14824 cmdline_fixed_string_t pctype;
14826 cmdline_fixed_string_t inset_type;
14827 cmdline_fixed_string_t opt;
14828 cmdline_fixed_string_t field;
14833 cmd_cfg_input_set_parsed(
14834 __rte_unused void *parsed_result,
14835 __rte_unused struct cmdline *cl,
14836 __rte_unused void *data)
14838 #ifdef RTE_NET_I40E
14839 struct cmd_cfg_input_set_result *res = parsed_result;
14840 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14841 struct rte_pmd_i40e_inset inset;
14843 int ret = -ENOTSUP;
14845 if (!all_ports_stopped()) {
14846 fprintf(stderr, "Please stop all ports first\n");
14850 #ifdef RTE_NET_I40E
14851 if (!strcmp(res->inset_type, "hash_inset"))
14852 inset_type = INSET_HASH;
14853 else if (!strcmp(res->inset_type, "fdir_inset"))
14854 inset_type = INSET_FDIR;
14855 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14856 inset_type = INSET_FDIR_FLX;
14857 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14858 &inset, inset_type);
14860 fprintf(stderr, "Failed to get input set.\n");
14864 if (!strcmp(res->opt, "get")) {
14865 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14868 printf("Field index %d is enabled.\n", res->field_idx);
14870 printf("Field index %d is disabled.\n", res->field_idx);
14872 } else if (!strcmp(res->opt, "set"))
14873 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14875 else if (!strcmp(res->opt, "clear"))
14876 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14879 fprintf(stderr, "Failed to configure input set field.\n");
14883 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14884 &inset, inset_type);
14886 fprintf(stderr, "Failed to set input set.\n");
14891 if (ret == -ENOTSUP)
14892 fprintf(stderr, "Function not supported\n");
14895 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14896 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14898 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14899 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14901 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14902 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14903 port_id, RTE_UINT16);
14904 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14905 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14907 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14908 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14909 pctype_id, RTE_UINT8);
14910 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14911 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14913 "hash_inset#fdir_inset#fdir_flx_inset");
14914 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14915 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14916 opt, "get#set#clear");
14917 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14918 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14920 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14921 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14922 field_idx, RTE_UINT8);
14924 cmdline_parse_inst_t cmd_cfg_input_set = {
14925 .f = cmd_cfg_input_set_parsed,
14927 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14928 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
14930 (void *)&cmd_cfg_input_set_port,
14931 (void *)&cmd_cfg_input_set_cfg,
14932 (void *)&cmd_cfg_input_set_port_id,
14933 (void *)&cmd_cfg_input_set_pctype,
14934 (void *)&cmd_cfg_input_set_pctype_id,
14935 (void *)&cmd_cfg_input_set_inset_type,
14936 (void *)&cmd_cfg_input_set_opt,
14937 (void *)&cmd_cfg_input_set_field,
14938 (void *)&cmd_cfg_input_set_field_idx,
14943 /* Clear input set */
14944 struct cmd_clear_input_set_result {
14945 cmdline_fixed_string_t port;
14946 cmdline_fixed_string_t cfg;
14948 cmdline_fixed_string_t pctype;
14950 cmdline_fixed_string_t inset_type;
14951 cmdline_fixed_string_t clear;
14952 cmdline_fixed_string_t all;
14956 cmd_clear_input_set_parsed(
14957 __rte_unused void *parsed_result,
14958 __rte_unused struct cmdline *cl,
14959 __rte_unused void *data)
14961 #ifdef RTE_NET_I40E
14962 struct cmd_clear_input_set_result *res = parsed_result;
14963 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14964 struct rte_pmd_i40e_inset inset;
14966 int ret = -ENOTSUP;
14968 if (!all_ports_stopped()) {
14969 fprintf(stderr, "Please stop all ports first\n");
14973 #ifdef RTE_NET_I40E
14974 if (!strcmp(res->inset_type, "hash_inset"))
14975 inset_type = INSET_HASH;
14976 else if (!strcmp(res->inset_type, "fdir_inset"))
14977 inset_type = INSET_FDIR;
14978 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14979 inset_type = INSET_FDIR_FLX;
14981 memset(&inset, 0, sizeof(inset));
14983 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14984 &inset, inset_type);
14986 fprintf(stderr, "Failed to clear input set.\n");
14992 if (ret == -ENOTSUP)
14993 fprintf(stderr, "Function not supported\n");
14996 cmdline_parse_token_string_t cmd_clear_input_set_port =
14997 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14999 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15000 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15002 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15003 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15004 port_id, RTE_UINT16);
15005 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15006 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15008 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15009 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15010 pctype_id, RTE_UINT8);
15011 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15012 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15014 "hash_inset#fdir_inset#fdir_flx_inset");
15015 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15016 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15018 cmdline_parse_token_string_t cmd_clear_input_set_all =
15019 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15022 cmdline_parse_inst_t cmd_clear_input_set = {
15023 .f = cmd_clear_input_set_parsed,
15025 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15026 "fdir_inset|fdir_flx_inset clear all",
15028 (void *)&cmd_clear_input_set_port,
15029 (void *)&cmd_clear_input_set_cfg,
15030 (void *)&cmd_clear_input_set_port_id,
15031 (void *)&cmd_clear_input_set_pctype,
15032 (void *)&cmd_clear_input_set_pctype_id,
15033 (void *)&cmd_clear_input_set_inset_type,
15034 (void *)&cmd_clear_input_set_clear,
15035 (void *)&cmd_clear_input_set_all,
15040 /* show vf stats */
15042 /* Common result structure for show vf stats */
15043 struct cmd_show_vf_stats_result {
15044 cmdline_fixed_string_t show;
15045 cmdline_fixed_string_t vf;
15046 cmdline_fixed_string_t stats;
15051 /* Common CLI fields show vf stats*/
15052 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15053 TOKEN_STRING_INITIALIZER
15054 (struct cmd_show_vf_stats_result,
15056 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15057 TOKEN_STRING_INITIALIZER
15058 (struct cmd_show_vf_stats_result,
15060 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15061 TOKEN_STRING_INITIALIZER
15062 (struct cmd_show_vf_stats_result,
15064 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15065 TOKEN_NUM_INITIALIZER
15066 (struct cmd_show_vf_stats_result,
15067 port_id, RTE_UINT16);
15068 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15069 TOKEN_NUM_INITIALIZER
15070 (struct cmd_show_vf_stats_result,
15071 vf_id, RTE_UINT16);
15074 cmd_show_vf_stats_parsed(
15075 void *parsed_result,
15076 __rte_unused struct cmdline *cl,
15077 __rte_unused void *data)
15079 struct cmd_show_vf_stats_result *res = parsed_result;
15080 struct rte_eth_stats stats;
15081 int ret = -ENOTSUP;
15082 static const char *nic_stats_border = "########################";
15084 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15087 memset(&stats, 0, sizeof(stats));
15089 #ifdef RTE_NET_I40E
15090 if (ret == -ENOTSUP)
15091 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15095 #ifdef RTE_NET_BNXT
15096 if (ret == -ENOTSUP)
15097 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15106 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15109 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15112 fprintf(stderr, "function not implemented\n");
15115 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15118 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15119 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15121 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15123 stats.ipackets, stats.imissed, stats.ibytes);
15124 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15125 printf(" RX-nombuf: %-10"PRIu64"\n",
15127 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15129 stats.opackets, stats.oerrors, stats.obytes);
15131 printf(" %s############################%s\n",
15132 nic_stats_border, nic_stats_border);
15135 cmdline_parse_inst_t cmd_show_vf_stats = {
15136 .f = cmd_show_vf_stats_parsed,
15138 .help_str = "show vf stats <port_id> <vf_id>",
15140 (void *)&cmd_show_vf_stats_show,
15141 (void *)&cmd_show_vf_stats_vf,
15142 (void *)&cmd_show_vf_stats_stats,
15143 (void *)&cmd_show_vf_stats_port_id,
15144 (void *)&cmd_show_vf_stats_vf_id,
15149 /* clear vf stats */
15151 /* Common result structure for clear vf stats */
15152 struct cmd_clear_vf_stats_result {
15153 cmdline_fixed_string_t clear;
15154 cmdline_fixed_string_t vf;
15155 cmdline_fixed_string_t stats;
15160 /* Common CLI fields clear vf stats*/
15161 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15162 TOKEN_STRING_INITIALIZER
15163 (struct cmd_clear_vf_stats_result,
15165 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15166 TOKEN_STRING_INITIALIZER
15167 (struct cmd_clear_vf_stats_result,
15169 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15170 TOKEN_STRING_INITIALIZER
15171 (struct cmd_clear_vf_stats_result,
15173 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15174 TOKEN_NUM_INITIALIZER
15175 (struct cmd_clear_vf_stats_result,
15176 port_id, RTE_UINT16);
15177 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15178 TOKEN_NUM_INITIALIZER
15179 (struct cmd_clear_vf_stats_result,
15180 vf_id, RTE_UINT16);
15183 cmd_clear_vf_stats_parsed(
15184 void *parsed_result,
15185 __rte_unused struct cmdline *cl,
15186 __rte_unused void *data)
15188 struct cmd_clear_vf_stats_result *res = parsed_result;
15189 int ret = -ENOTSUP;
15191 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15194 #ifdef RTE_NET_I40E
15195 if (ret == -ENOTSUP)
15196 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15199 #ifdef RTE_NET_BNXT
15200 if (ret == -ENOTSUP)
15201 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15209 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15212 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15215 fprintf(stderr, "function not implemented\n");
15218 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15222 cmdline_parse_inst_t cmd_clear_vf_stats = {
15223 .f = cmd_clear_vf_stats_parsed,
15225 .help_str = "clear vf stats <port_id> <vf_id>",
15227 (void *)&cmd_clear_vf_stats_clear,
15228 (void *)&cmd_clear_vf_stats_vf,
15229 (void *)&cmd_clear_vf_stats_stats,
15230 (void *)&cmd_clear_vf_stats_port_id,
15231 (void *)&cmd_clear_vf_stats_vf_id,
15236 /* port config pctype mapping reset */
15238 /* Common result structure for port config pctype mapping reset */
15239 struct cmd_pctype_mapping_reset_result {
15240 cmdline_fixed_string_t port;
15241 cmdline_fixed_string_t config;
15243 cmdline_fixed_string_t pctype;
15244 cmdline_fixed_string_t mapping;
15245 cmdline_fixed_string_t reset;
15248 /* Common CLI fields for port config pctype mapping reset*/
15249 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15250 TOKEN_STRING_INITIALIZER
15251 (struct cmd_pctype_mapping_reset_result,
15253 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15254 TOKEN_STRING_INITIALIZER
15255 (struct cmd_pctype_mapping_reset_result,
15257 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15258 TOKEN_NUM_INITIALIZER
15259 (struct cmd_pctype_mapping_reset_result,
15260 port_id, RTE_UINT16);
15261 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15262 TOKEN_STRING_INITIALIZER
15263 (struct cmd_pctype_mapping_reset_result,
15265 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15266 TOKEN_STRING_INITIALIZER
15267 (struct cmd_pctype_mapping_reset_result,
15268 mapping, "mapping");
15269 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15270 TOKEN_STRING_INITIALIZER
15271 (struct cmd_pctype_mapping_reset_result,
15275 cmd_pctype_mapping_reset_parsed(
15276 void *parsed_result,
15277 __rte_unused struct cmdline *cl,
15278 __rte_unused void *data)
15280 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15281 int ret = -ENOTSUP;
15283 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15286 #ifdef RTE_NET_I40E
15287 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15294 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15297 fprintf(stderr, "function not implemented\n");
15300 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15304 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15305 .f = cmd_pctype_mapping_reset_parsed,
15307 .help_str = "port config <port_id> pctype mapping reset",
15309 (void *)&cmd_pctype_mapping_reset_port,
15310 (void *)&cmd_pctype_mapping_reset_config,
15311 (void *)&cmd_pctype_mapping_reset_port_id,
15312 (void *)&cmd_pctype_mapping_reset_pctype,
15313 (void *)&cmd_pctype_mapping_reset_mapping,
15314 (void *)&cmd_pctype_mapping_reset_reset,
15319 /* show port pctype mapping */
15321 /* Common result structure for show port pctype mapping */
15322 struct cmd_pctype_mapping_get_result {
15323 cmdline_fixed_string_t show;
15324 cmdline_fixed_string_t port;
15326 cmdline_fixed_string_t pctype;
15327 cmdline_fixed_string_t mapping;
15330 /* Common CLI fields for pctype mapping get */
15331 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15332 TOKEN_STRING_INITIALIZER
15333 (struct cmd_pctype_mapping_get_result,
15335 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15336 TOKEN_STRING_INITIALIZER
15337 (struct cmd_pctype_mapping_get_result,
15339 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15340 TOKEN_NUM_INITIALIZER
15341 (struct cmd_pctype_mapping_get_result,
15342 port_id, RTE_UINT16);
15343 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15344 TOKEN_STRING_INITIALIZER
15345 (struct cmd_pctype_mapping_get_result,
15347 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15348 TOKEN_STRING_INITIALIZER
15349 (struct cmd_pctype_mapping_get_result,
15350 mapping, "mapping");
15353 cmd_pctype_mapping_get_parsed(
15354 void *parsed_result,
15355 __rte_unused struct cmdline *cl,
15356 __rte_unused void *data)
15358 struct cmd_pctype_mapping_get_result *res = parsed_result;
15359 int ret = -ENOTSUP;
15360 #ifdef RTE_NET_I40E
15361 struct rte_pmd_i40e_flow_type_mapping
15362 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15363 int i, j, first_pctype;
15366 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15369 #ifdef RTE_NET_I40E
15370 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15377 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15380 fprintf(stderr, "function not implemented\n");
15383 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15387 #ifdef RTE_NET_I40E
15388 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15389 if (mapping[i].pctype != 0ULL) {
15392 printf("pctype: ");
15393 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15394 if (mapping[i].pctype & (1ULL << j)) {
15395 printf(first_pctype ?
15396 "%02d" : ",%02d", j);
15400 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15406 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15407 .f = cmd_pctype_mapping_get_parsed,
15409 .help_str = "show port <port_id> pctype mapping",
15411 (void *)&cmd_pctype_mapping_get_show,
15412 (void *)&cmd_pctype_mapping_get_port,
15413 (void *)&cmd_pctype_mapping_get_port_id,
15414 (void *)&cmd_pctype_mapping_get_pctype,
15415 (void *)&cmd_pctype_mapping_get_mapping,
15420 /* port config pctype mapping update */
15422 /* Common result structure for port config pctype mapping update */
15423 struct cmd_pctype_mapping_update_result {
15424 cmdline_fixed_string_t port;
15425 cmdline_fixed_string_t config;
15427 cmdline_fixed_string_t pctype;
15428 cmdline_fixed_string_t mapping;
15429 cmdline_fixed_string_t update;
15430 cmdline_fixed_string_t pctype_list;
15431 uint16_t flow_type;
15434 /* Common CLI fields for pctype mapping update*/
15435 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15436 TOKEN_STRING_INITIALIZER
15437 (struct cmd_pctype_mapping_update_result,
15439 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15440 TOKEN_STRING_INITIALIZER
15441 (struct cmd_pctype_mapping_update_result,
15443 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15444 TOKEN_NUM_INITIALIZER
15445 (struct cmd_pctype_mapping_update_result,
15446 port_id, RTE_UINT16);
15447 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15448 TOKEN_STRING_INITIALIZER
15449 (struct cmd_pctype_mapping_update_result,
15451 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15452 TOKEN_STRING_INITIALIZER
15453 (struct cmd_pctype_mapping_update_result,
15454 mapping, "mapping");
15455 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15456 TOKEN_STRING_INITIALIZER
15457 (struct cmd_pctype_mapping_update_result,
15459 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15460 TOKEN_STRING_INITIALIZER
15461 (struct cmd_pctype_mapping_update_result,
15462 pctype_list, NULL);
15463 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15464 TOKEN_NUM_INITIALIZER
15465 (struct cmd_pctype_mapping_update_result,
15466 flow_type, RTE_UINT16);
15469 cmd_pctype_mapping_update_parsed(
15470 void *parsed_result,
15471 __rte_unused struct cmdline *cl,
15472 __rte_unused void *data)
15474 struct cmd_pctype_mapping_update_result *res = parsed_result;
15475 int ret = -ENOTSUP;
15476 #ifdef RTE_NET_I40E
15477 struct rte_pmd_i40e_flow_type_mapping mapping;
15479 unsigned int nb_item;
15480 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15483 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15486 #ifdef RTE_NET_I40E
15487 nb_item = parse_item_list(res->pctype_list, "pctypes",
15488 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15489 mapping.flow_type = res->flow_type;
15490 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15491 mapping.pctype |= (1ULL << pctype_list[i]);
15492 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15502 fprintf(stderr, "invalid pctype or flow type\n");
15505 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15508 fprintf(stderr, "function not implemented\n");
15511 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15515 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15516 .f = cmd_pctype_mapping_update_parsed,
15518 .help_str = "port config <port_id> pctype mapping update"
15519 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15521 (void *)&cmd_pctype_mapping_update_port,
15522 (void *)&cmd_pctype_mapping_update_config,
15523 (void *)&cmd_pctype_mapping_update_port_id,
15524 (void *)&cmd_pctype_mapping_update_pctype,
15525 (void *)&cmd_pctype_mapping_update_mapping,
15526 (void *)&cmd_pctype_mapping_update_update,
15527 (void *)&cmd_pctype_mapping_update_pc_type,
15528 (void *)&cmd_pctype_mapping_update_flow_type,
15533 /* ptype mapping get */
15535 /* Common result structure for ptype mapping get */
15536 struct cmd_ptype_mapping_get_result {
15537 cmdline_fixed_string_t ptype;
15538 cmdline_fixed_string_t mapping;
15539 cmdline_fixed_string_t get;
15541 uint8_t valid_only;
15544 /* Common CLI fields for ptype mapping get */
15545 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15546 TOKEN_STRING_INITIALIZER
15547 (struct cmd_ptype_mapping_get_result,
15549 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15550 TOKEN_STRING_INITIALIZER
15551 (struct cmd_ptype_mapping_get_result,
15552 mapping, "mapping");
15553 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15554 TOKEN_STRING_INITIALIZER
15555 (struct cmd_ptype_mapping_get_result,
15557 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15558 TOKEN_NUM_INITIALIZER
15559 (struct cmd_ptype_mapping_get_result,
15560 port_id, RTE_UINT16);
15561 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15562 TOKEN_NUM_INITIALIZER
15563 (struct cmd_ptype_mapping_get_result,
15564 valid_only, RTE_UINT8);
15567 cmd_ptype_mapping_get_parsed(
15568 void *parsed_result,
15569 __rte_unused struct cmdline *cl,
15570 __rte_unused void *data)
15572 struct cmd_ptype_mapping_get_result *res = parsed_result;
15573 int ret = -ENOTSUP;
15574 #ifdef RTE_NET_I40E
15575 int max_ptype_num = 256;
15576 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15581 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15584 #ifdef RTE_NET_I40E
15585 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15596 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15599 fprintf(stderr, "function not implemented\n");
15602 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15605 #ifdef RTE_NET_I40E
15607 for (i = 0; i < count; i++)
15608 printf("%3d\t0x%08x\n",
15609 mapping[i].hw_ptype, mapping[i].sw_ptype);
15614 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15615 .f = cmd_ptype_mapping_get_parsed,
15617 .help_str = "ptype mapping get <port_id> <valid_only>",
15619 (void *)&cmd_ptype_mapping_get_ptype,
15620 (void *)&cmd_ptype_mapping_get_mapping,
15621 (void *)&cmd_ptype_mapping_get_get,
15622 (void *)&cmd_ptype_mapping_get_port_id,
15623 (void *)&cmd_ptype_mapping_get_valid_only,
15628 /* ptype mapping replace */
15630 /* Common result structure for ptype mapping replace */
15631 struct cmd_ptype_mapping_replace_result {
15632 cmdline_fixed_string_t ptype;
15633 cmdline_fixed_string_t mapping;
15634 cmdline_fixed_string_t replace;
15641 /* Common CLI fields for ptype mapping replace */
15642 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15643 TOKEN_STRING_INITIALIZER
15644 (struct cmd_ptype_mapping_replace_result,
15646 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15647 TOKEN_STRING_INITIALIZER
15648 (struct cmd_ptype_mapping_replace_result,
15649 mapping, "mapping");
15650 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15651 TOKEN_STRING_INITIALIZER
15652 (struct cmd_ptype_mapping_replace_result,
15653 replace, "replace");
15654 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15655 TOKEN_NUM_INITIALIZER
15656 (struct cmd_ptype_mapping_replace_result,
15657 port_id, RTE_UINT16);
15658 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15659 TOKEN_NUM_INITIALIZER
15660 (struct cmd_ptype_mapping_replace_result,
15661 target, RTE_UINT32);
15662 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15663 TOKEN_NUM_INITIALIZER
15664 (struct cmd_ptype_mapping_replace_result,
15666 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15667 TOKEN_NUM_INITIALIZER
15668 (struct cmd_ptype_mapping_replace_result,
15669 pkt_type, RTE_UINT32);
15672 cmd_ptype_mapping_replace_parsed(
15673 void *parsed_result,
15674 __rte_unused struct cmdline *cl,
15675 __rte_unused void *data)
15677 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15678 int ret = -ENOTSUP;
15680 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15683 #ifdef RTE_NET_I40E
15684 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15694 fprintf(stderr, "invalid ptype 0x%8x or 0x%8x\n",
15695 res->target, res->pkt_type);
15698 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15701 fprintf(stderr, "function not implemented\n");
15704 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15708 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15709 .f = cmd_ptype_mapping_replace_parsed,
15712 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15714 (void *)&cmd_ptype_mapping_replace_ptype,
15715 (void *)&cmd_ptype_mapping_replace_mapping,
15716 (void *)&cmd_ptype_mapping_replace_replace,
15717 (void *)&cmd_ptype_mapping_replace_port_id,
15718 (void *)&cmd_ptype_mapping_replace_target,
15719 (void *)&cmd_ptype_mapping_replace_mask,
15720 (void *)&cmd_ptype_mapping_replace_pkt_type,
15725 /* ptype mapping reset */
15727 /* Common result structure for ptype mapping reset */
15728 struct cmd_ptype_mapping_reset_result {
15729 cmdline_fixed_string_t ptype;
15730 cmdline_fixed_string_t mapping;
15731 cmdline_fixed_string_t reset;
15735 /* Common CLI fields for ptype mapping reset*/
15736 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15737 TOKEN_STRING_INITIALIZER
15738 (struct cmd_ptype_mapping_reset_result,
15740 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15741 TOKEN_STRING_INITIALIZER
15742 (struct cmd_ptype_mapping_reset_result,
15743 mapping, "mapping");
15744 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15745 TOKEN_STRING_INITIALIZER
15746 (struct cmd_ptype_mapping_reset_result,
15748 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15749 TOKEN_NUM_INITIALIZER
15750 (struct cmd_ptype_mapping_reset_result,
15751 port_id, RTE_UINT16);
15754 cmd_ptype_mapping_reset_parsed(
15755 void *parsed_result,
15756 __rte_unused struct cmdline *cl,
15757 __rte_unused void *data)
15759 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15760 int ret = -ENOTSUP;
15762 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15765 #ifdef RTE_NET_I40E
15766 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15773 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15776 fprintf(stderr, "function not implemented\n");
15779 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15783 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15784 .f = cmd_ptype_mapping_reset_parsed,
15786 .help_str = "ptype mapping reset <port_id>",
15788 (void *)&cmd_ptype_mapping_reset_ptype,
15789 (void *)&cmd_ptype_mapping_reset_mapping,
15790 (void *)&cmd_ptype_mapping_reset_reset,
15791 (void *)&cmd_ptype_mapping_reset_port_id,
15796 /* ptype mapping update */
15798 /* Common result structure for ptype mapping update */
15799 struct cmd_ptype_mapping_update_result {
15800 cmdline_fixed_string_t ptype;
15801 cmdline_fixed_string_t mapping;
15802 cmdline_fixed_string_t reset;
15808 /* Common CLI fields for ptype mapping update*/
15809 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15810 TOKEN_STRING_INITIALIZER
15811 (struct cmd_ptype_mapping_update_result,
15813 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15814 TOKEN_STRING_INITIALIZER
15815 (struct cmd_ptype_mapping_update_result,
15816 mapping, "mapping");
15817 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15818 TOKEN_STRING_INITIALIZER
15819 (struct cmd_ptype_mapping_update_result,
15821 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15822 TOKEN_NUM_INITIALIZER
15823 (struct cmd_ptype_mapping_update_result,
15824 port_id, RTE_UINT16);
15825 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15826 TOKEN_NUM_INITIALIZER
15827 (struct cmd_ptype_mapping_update_result,
15828 hw_ptype, RTE_UINT8);
15829 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15830 TOKEN_NUM_INITIALIZER
15831 (struct cmd_ptype_mapping_update_result,
15832 sw_ptype, RTE_UINT32);
15835 cmd_ptype_mapping_update_parsed(
15836 void *parsed_result,
15837 __rte_unused struct cmdline *cl,
15838 __rte_unused void *data)
15840 struct cmd_ptype_mapping_update_result *res = parsed_result;
15841 int ret = -ENOTSUP;
15842 #ifdef RTE_NET_I40E
15843 struct rte_pmd_i40e_ptype_mapping mapping;
15845 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15848 #ifdef RTE_NET_I40E
15849 mapping.hw_ptype = res->hw_ptype;
15850 mapping.sw_ptype = res->sw_ptype;
15851 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15861 fprintf(stderr, "invalid ptype 0x%8x\n", res->sw_ptype);
15864 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15867 fprintf(stderr, "function not implemented\n");
15870 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15874 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15875 .f = cmd_ptype_mapping_update_parsed,
15877 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15879 (void *)&cmd_ptype_mapping_update_ptype,
15880 (void *)&cmd_ptype_mapping_update_mapping,
15881 (void *)&cmd_ptype_mapping_update_update,
15882 (void *)&cmd_ptype_mapping_update_port_id,
15883 (void *)&cmd_ptype_mapping_update_hw_ptype,
15884 (void *)&cmd_ptype_mapping_update_sw_ptype,
15889 /* Common result structure for file commands */
15890 struct cmd_cmdfile_result {
15891 cmdline_fixed_string_t load;
15892 cmdline_fixed_string_t filename;
15895 /* Common CLI fields for file commands */
15896 cmdline_parse_token_string_t cmd_load_cmdfile =
15897 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15898 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15899 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15902 cmd_load_from_file_parsed(
15903 void *parsed_result,
15904 __rte_unused struct cmdline *cl,
15905 __rte_unused void *data)
15907 struct cmd_cmdfile_result *res = parsed_result;
15909 cmdline_read_from_file(res->filename);
15912 cmdline_parse_inst_t cmd_load_from_file = {
15913 .f = cmd_load_from_file_parsed,
15915 .help_str = "load <filename>",
15917 (void *)&cmd_load_cmdfile,
15918 (void *)&cmd_load_cmdfile_filename,
15923 /* Get Rx offloads capabilities */
15924 struct cmd_rx_offload_get_capa_result {
15925 cmdline_fixed_string_t show;
15926 cmdline_fixed_string_t port;
15928 cmdline_fixed_string_t rx_offload;
15929 cmdline_fixed_string_t capabilities;
15932 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
15933 TOKEN_STRING_INITIALIZER
15934 (struct cmd_rx_offload_get_capa_result,
15936 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
15937 TOKEN_STRING_INITIALIZER
15938 (struct cmd_rx_offload_get_capa_result,
15940 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
15941 TOKEN_NUM_INITIALIZER
15942 (struct cmd_rx_offload_get_capa_result,
15943 port_id, RTE_UINT16);
15944 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
15945 TOKEN_STRING_INITIALIZER
15946 (struct cmd_rx_offload_get_capa_result,
15947 rx_offload, "rx_offload");
15948 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
15949 TOKEN_STRING_INITIALIZER
15950 (struct cmd_rx_offload_get_capa_result,
15951 capabilities, "capabilities");
15954 print_rx_offloads(uint64_t offloads)
15956 uint64_t single_offload;
15964 begin = __builtin_ctzll(offloads);
15965 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15967 single_offload = 1ULL << begin;
15968 for (bit = begin; bit < end; bit++) {
15969 if (offloads & single_offload)
15971 rte_eth_dev_rx_offload_name(single_offload));
15972 single_offload <<= 1;
15977 cmd_rx_offload_get_capa_parsed(
15978 void *parsed_result,
15979 __rte_unused struct cmdline *cl,
15980 __rte_unused void *data)
15982 struct cmd_rx_offload_get_capa_result *res = parsed_result;
15983 struct rte_eth_dev_info dev_info;
15984 portid_t port_id = res->port_id;
15985 uint64_t queue_offloads;
15986 uint64_t port_offloads;
15989 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15993 queue_offloads = dev_info.rx_queue_offload_capa;
15994 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
15996 printf("Rx Offloading Capabilities of port %d :\n", port_id);
15997 printf(" Per Queue :");
15998 print_rx_offloads(queue_offloads);
16001 printf(" Per Port :");
16002 print_rx_offloads(port_offloads);
16006 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
16007 .f = cmd_rx_offload_get_capa_parsed,
16009 .help_str = "show port <port_id> rx_offload capabilities",
16011 (void *)&cmd_rx_offload_get_capa_show,
16012 (void *)&cmd_rx_offload_get_capa_port,
16013 (void *)&cmd_rx_offload_get_capa_port_id,
16014 (void *)&cmd_rx_offload_get_capa_rx_offload,
16015 (void *)&cmd_rx_offload_get_capa_capabilities,
16020 /* Get Rx offloads configuration */
16021 struct cmd_rx_offload_get_configuration_result {
16022 cmdline_fixed_string_t show;
16023 cmdline_fixed_string_t port;
16025 cmdline_fixed_string_t rx_offload;
16026 cmdline_fixed_string_t configuration;
16029 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
16030 TOKEN_STRING_INITIALIZER
16031 (struct cmd_rx_offload_get_configuration_result,
16033 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
16034 TOKEN_STRING_INITIALIZER
16035 (struct cmd_rx_offload_get_configuration_result,
16037 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
16038 TOKEN_NUM_INITIALIZER
16039 (struct cmd_rx_offload_get_configuration_result,
16040 port_id, RTE_UINT16);
16041 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
16042 TOKEN_STRING_INITIALIZER
16043 (struct cmd_rx_offload_get_configuration_result,
16044 rx_offload, "rx_offload");
16045 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
16046 TOKEN_STRING_INITIALIZER
16047 (struct cmd_rx_offload_get_configuration_result,
16048 configuration, "configuration");
16051 cmd_rx_offload_get_configuration_parsed(
16052 void *parsed_result,
16053 __rte_unused struct cmdline *cl,
16054 __rte_unused void *data)
16056 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
16057 struct rte_eth_dev_info dev_info;
16058 portid_t port_id = res->port_id;
16059 struct rte_port *port = &ports[port_id];
16060 struct rte_eth_conf dev_conf;
16061 uint64_t port_offloads;
16062 uint64_t queue_offloads;
16063 uint16_t nb_rx_queues;
16067 printf("Rx Offloading Configuration of port %d :\n", port_id);
16069 ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
16073 port_offloads = dev_conf.rxmode.offloads;
16075 print_rx_offloads(port_offloads);
16078 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16082 nb_rx_queues = dev_info.nb_rx_queues;
16083 for (q = 0; q < nb_rx_queues; q++) {
16084 queue_offloads = port->rx_conf[q].offloads;
16085 printf(" Queue[%2d] :", q);
16086 print_rx_offloads(queue_offloads);
16092 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
16093 .f = cmd_rx_offload_get_configuration_parsed,
16095 .help_str = "show port <port_id> rx_offload configuration",
16097 (void *)&cmd_rx_offload_get_configuration_show,
16098 (void *)&cmd_rx_offload_get_configuration_port,
16099 (void *)&cmd_rx_offload_get_configuration_port_id,
16100 (void *)&cmd_rx_offload_get_configuration_rx_offload,
16101 (void *)&cmd_rx_offload_get_configuration_configuration,
16106 /* Enable/Disable a per port offloading */
16107 struct cmd_config_per_port_rx_offload_result {
16108 cmdline_fixed_string_t port;
16109 cmdline_fixed_string_t config;
16111 cmdline_fixed_string_t rx_offload;
16112 cmdline_fixed_string_t offload;
16113 cmdline_fixed_string_t on_off;
16116 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
16117 TOKEN_STRING_INITIALIZER
16118 (struct cmd_config_per_port_rx_offload_result,
16120 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
16121 TOKEN_STRING_INITIALIZER
16122 (struct cmd_config_per_port_rx_offload_result,
16124 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
16125 TOKEN_NUM_INITIALIZER
16126 (struct cmd_config_per_port_rx_offload_result,
16127 port_id, RTE_UINT16);
16128 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
16129 TOKEN_STRING_INITIALIZER
16130 (struct cmd_config_per_port_rx_offload_result,
16131 rx_offload, "rx_offload");
16132 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
16133 TOKEN_STRING_INITIALIZER
16134 (struct cmd_config_per_port_rx_offload_result,
16135 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16136 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16137 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16138 "scatter#buffer_split#timestamp#security#"
16139 "keep_crc#rss_hash");
16140 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
16141 TOKEN_STRING_INITIALIZER
16142 (struct cmd_config_per_port_rx_offload_result,
16146 search_rx_offload(const char *name)
16148 uint64_t single_offload;
16149 const char *single_name;
16153 single_offload = 1;
16154 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16155 single_name = rte_eth_dev_rx_offload_name(single_offload);
16156 if (!strcasecmp(single_name, name)) {
16160 single_offload <<= 1;
16164 return single_offload;
16170 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16171 __rte_unused struct cmdline *cl,
16172 __rte_unused void *data)
16174 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16175 portid_t port_id = res->port_id;
16176 struct rte_eth_dev_info dev_info;
16177 struct rte_port *port = &ports[port_id];
16178 uint64_t single_offload;
16179 uint16_t nb_rx_queues;
16183 if (port->port_status != RTE_PORT_STOPPED) {
16185 "Error: Can't config offload when Port %d is not stopped\n",
16190 single_offload = search_rx_offload(res->offload);
16191 if (single_offload == 0) {
16192 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16196 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16200 nb_rx_queues = dev_info.nb_rx_queues;
16201 if (!strcmp(res->on_off, "on")) {
16202 port->dev_conf.rxmode.offloads |= single_offload;
16203 for (q = 0; q < nb_rx_queues; q++)
16204 port->rx_conf[q].offloads |= single_offload;
16206 port->dev_conf.rxmode.offloads &= ~single_offload;
16207 for (q = 0; q < nb_rx_queues; q++)
16208 port->rx_conf[q].offloads &= ~single_offload;
16211 cmd_reconfig_device_queue(port_id, 1, 1);
16214 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16215 .f = cmd_config_per_port_rx_offload_parsed,
16217 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16218 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16219 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16220 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16221 "keep_crc|rss_hash on|off",
16223 (void *)&cmd_config_per_port_rx_offload_result_port,
16224 (void *)&cmd_config_per_port_rx_offload_result_config,
16225 (void *)&cmd_config_per_port_rx_offload_result_port_id,
16226 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16227 (void *)&cmd_config_per_port_rx_offload_result_offload,
16228 (void *)&cmd_config_per_port_rx_offload_result_on_off,
16233 /* Enable/Disable a per queue offloading */
16234 struct cmd_config_per_queue_rx_offload_result {
16235 cmdline_fixed_string_t port;
16237 cmdline_fixed_string_t rxq;
16239 cmdline_fixed_string_t rx_offload;
16240 cmdline_fixed_string_t offload;
16241 cmdline_fixed_string_t on_off;
16244 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16245 TOKEN_STRING_INITIALIZER
16246 (struct cmd_config_per_queue_rx_offload_result,
16248 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16249 TOKEN_NUM_INITIALIZER
16250 (struct cmd_config_per_queue_rx_offload_result,
16251 port_id, RTE_UINT16);
16252 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16253 TOKEN_STRING_INITIALIZER
16254 (struct cmd_config_per_queue_rx_offload_result,
16256 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16257 TOKEN_NUM_INITIALIZER
16258 (struct cmd_config_per_queue_rx_offload_result,
16259 queue_id, RTE_UINT16);
16260 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16261 TOKEN_STRING_INITIALIZER
16262 (struct cmd_config_per_queue_rx_offload_result,
16263 rx_offload, "rx_offload");
16264 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16265 TOKEN_STRING_INITIALIZER
16266 (struct cmd_config_per_queue_rx_offload_result,
16267 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16268 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16269 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16270 "scatter#buffer_split#timestamp#security#keep_crc");
16271 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16272 TOKEN_STRING_INITIALIZER
16273 (struct cmd_config_per_queue_rx_offload_result,
16277 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16278 __rte_unused struct cmdline *cl,
16279 __rte_unused void *data)
16281 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16282 struct rte_eth_dev_info dev_info;
16283 portid_t port_id = res->port_id;
16284 uint16_t queue_id = res->queue_id;
16285 struct rte_port *port = &ports[port_id];
16286 uint64_t single_offload;
16289 if (port->port_status != RTE_PORT_STOPPED) {
16291 "Error: Can't config offload when Port %d is not stopped\n",
16296 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16300 if (queue_id >= dev_info.nb_rx_queues) {
16302 "Error: input queue_id should be 0 ... %d\n",
16303 dev_info.nb_rx_queues - 1);
16307 single_offload = search_rx_offload(res->offload);
16308 if (single_offload == 0) {
16309 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16313 if (!strcmp(res->on_off, "on"))
16314 port->rx_conf[queue_id].offloads |= single_offload;
16316 port->rx_conf[queue_id].offloads &= ~single_offload;
16318 cmd_reconfig_device_queue(port_id, 1, 1);
16321 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16322 .f = cmd_config_per_queue_rx_offload_parsed,
16324 .help_str = "port <port_id> rxq <queue_id> rx_offload "
16325 "vlan_strip|ipv4_cksum|"
16326 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16327 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16328 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16331 (void *)&cmd_config_per_queue_rx_offload_result_port,
16332 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
16333 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
16334 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16335 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16336 (void *)&cmd_config_per_queue_rx_offload_result_offload,
16337 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
16342 /* Get Tx offloads capabilities */
16343 struct cmd_tx_offload_get_capa_result {
16344 cmdline_fixed_string_t show;
16345 cmdline_fixed_string_t port;
16347 cmdline_fixed_string_t tx_offload;
16348 cmdline_fixed_string_t capabilities;
16351 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16352 TOKEN_STRING_INITIALIZER
16353 (struct cmd_tx_offload_get_capa_result,
16355 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16356 TOKEN_STRING_INITIALIZER
16357 (struct cmd_tx_offload_get_capa_result,
16359 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16360 TOKEN_NUM_INITIALIZER
16361 (struct cmd_tx_offload_get_capa_result,
16362 port_id, RTE_UINT16);
16363 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16364 TOKEN_STRING_INITIALIZER
16365 (struct cmd_tx_offload_get_capa_result,
16366 tx_offload, "tx_offload");
16367 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16368 TOKEN_STRING_INITIALIZER
16369 (struct cmd_tx_offload_get_capa_result,
16370 capabilities, "capabilities");
16373 print_tx_offloads(uint64_t offloads)
16375 uint64_t single_offload;
16383 begin = __builtin_ctzll(offloads);
16384 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16386 single_offload = 1ULL << begin;
16387 for (bit = begin; bit < end; bit++) {
16388 if (offloads & single_offload)
16390 rte_eth_dev_tx_offload_name(single_offload));
16391 single_offload <<= 1;
16396 cmd_tx_offload_get_capa_parsed(
16397 void *parsed_result,
16398 __rte_unused struct cmdline *cl,
16399 __rte_unused void *data)
16401 struct cmd_tx_offload_get_capa_result *res = parsed_result;
16402 struct rte_eth_dev_info dev_info;
16403 portid_t port_id = res->port_id;
16404 uint64_t queue_offloads;
16405 uint64_t port_offloads;
16408 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16412 queue_offloads = dev_info.tx_queue_offload_capa;
16413 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16415 printf("Tx Offloading Capabilities of port %d :\n", port_id);
16416 printf(" Per Queue :");
16417 print_tx_offloads(queue_offloads);
16420 printf(" Per Port :");
16421 print_tx_offloads(port_offloads);
16425 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16426 .f = cmd_tx_offload_get_capa_parsed,
16428 .help_str = "show port <port_id> tx_offload capabilities",
16430 (void *)&cmd_tx_offload_get_capa_show,
16431 (void *)&cmd_tx_offload_get_capa_port,
16432 (void *)&cmd_tx_offload_get_capa_port_id,
16433 (void *)&cmd_tx_offload_get_capa_tx_offload,
16434 (void *)&cmd_tx_offload_get_capa_capabilities,
16439 /* Get Tx offloads configuration */
16440 struct cmd_tx_offload_get_configuration_result {
16441 cmdline_fixed_string_t show;
16442 cmdline_fixed_string_t port;
16444 cmdline_fixed_string_t tx_offload;
16445 cmdline_fixed_string_t configuration;
16448 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16449 TOKEN_STRING_INITIALIZER
16450 (struct cmd_tx_offload_get_configuration_result,
16452 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16453 TOKEN_STRING_INITIALIZER
16454 (struct cmd_tx_offload_get_configuration_result,
16456 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16457 TOKEN_NUM_INITIALIZER
16458 (struct cmd_tx_offload_get_configuration_result,
16459 port_id, RTE_UINT16);
16460 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16461 TOKEN_STRING_INITIALIZER
16462 (struct cmd_tx_offload_get_configuration_result,
16463 tx_offload, "tx_offload");
16464 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16465 TOKEN_STRING_INITIALIZER
16466 (struct cmd_tx_offload_get_configuration_result,
16467 configuration, "configuration");
16470 cmd_tx_offload_get_configuration_parsed(
16471 void *parsed_result,
16472 __rte_unused struct cmdline *cl,
16473 __rte_unused void *data)
16475 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16476 struct rte_eth_dev_info dev_info;
16477 portid_t port_id = res->port_id;
16478 struct rte_port *port = &ports[port_id];
16479 struct rte_eth_conf dev_conf;
16480 uint64_t port_offloads;
16481 uint64_t queue_offloads;
16482 uint16_t nb_tx_queues;
16486 printf("Tx Offloading Configuration of port %d :\n", port_id);
16488 ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
16492 port_offloads = dev_conf.txmode.offloads;
16494 print_tx_offloads(port_offloads);
16497 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16501 nb_tx_queues = dev_info.nb_tx_queues;
16502 for (q = 0; q < nb_tx_queues; q++) {
16503 queue_offloads = port->tx_conf[q].offloads;
16504 printf(" Queue[%2d] :", q);
16505 print_tx_offloads(queue_offloads);
16511 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16512 .f = cmd_tx_offload_get_configuration_parsed,
16514 .help_str = "show port <port_id> tx_offload configuration",
16516 (void *)&cmd_tx_offload_get_configuration_show,
16517 (void *)&cmd_tx_offload_get_configuration_port,
16518 (void *)&cmd_tx_offload_get_configuration_port_id,
16519 (void *)&cmd_tx_offload_get_configuration_tx_offload,
16520 (void *)&cmd_tx_offload_get_configuration_configuration,
16525 /* Enable/Disable a per port offloading */
16526 struct cmd_config_per_port_tx_offload_result {
16527 cmdline_fixed_string_t port;
16528 cmdline_fixed_string_t config;
16530 cmdline_fixed_string_t tx_offload;
16531 cmdline_fixed_string_t offload;
16532 cmdline_fixed_string_t on_off;
16535 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16536 TOKEN_STRING_INITIALIZER
16537 (struct cmd_config_per_port_tx_offload_result,
16539 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16540 TOKEN_STRING_INITIALIZER
16541 (struct cmd_config_per_port_tx_offload_result,
16543 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16544 TOKEN_NUM_INITIALIZER
16545 (struct cmd_config_per_port_tx_offload_result,
16546 port_id, RTE_UINT16);
16547 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16548 TOKEN_STRING_INITIALIZER
16549 (struct cmd_config_per_port_tx_offload_result,
16550 tx_offload, "tx_offload");
16551 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16552 TOKEN_STRING_INITIALIZER
16553 (struct cmd_config_per_port_tx_offload_result,
16554 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16555 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16556 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16557 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16558 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16559 "send_on_timestamp");
16560 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16561 TOKEN_STRING_INITIALIZER
16562 (struct cmd_config_per_port_tx_offload_result,
16566 search_tx_offload(const char *name)
16568 uint64_t single_offload;
16569 const char *single_name;
16573 single_offload = 1;
16574 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16575 single_name = rte_eth_dev_tx_offload_name(single_offload);
16576 if (single_name == NULL)
16578 if (!strcasecmp(single_name, name)) {
16581 } else if (!strcasecmp(single_name, "UNKNOWN"))
16583 single_offload <<= 1;
16587 return single_offload;
16593 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16594 __rte_unused struct cmdline *cl,
16595 __rte_unused void *data)
16597 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16598 portid_t port_id = res->port_id;
16599 struct rte_eth_dev_info dev_info;
16600 struct rte_port *port = &ports[port_id];
16601 uint64_t single_offload;
16602 uint16_t nb_tx_queues;
16606 if (port->port_status != RTE_PORT_STOPPED) {
16608 "Error: Can't config offload when Port %d is not stopped\n",
16613 single_offload = search_tx_offload(res->offload);
16614 if (single_offload == 0) {
16615 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16619 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16623 nb_tx_queues = dev_info.nb_tx_queues;
16624 if (!strcmp(res->on_off, "on")) {
16625 port->dev_conf.txmode.offloads |= single_offload;
16626 for (q = 0; q < nb_tx_queues; q++)
16627 port->tx_conf[q].offloads |= single_offload;
16629 port->dev_conf.txmode.offloads &= ~single_offload;
16630 for (q = 0; q < nb_tx_queues; q++)
16631 port->tx_conf[q].offloads &= ~single_offload;
16634 cmd_reconfig_device_queue(port_id, 1, 1);
16637 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16638 .f = cmd_config_per_port_tx_offload_parsed,
16640 .help_str = "port config <port_id> tx_offload "
16641 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16642 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16643 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16644 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16645 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16646 "send_on_timestamp on|off",
16648 (void *)&cmd_config_per_port_tx_offload_result_port,
16649 (void *)&cmd_config_per_port_tx_offload_result_config,
16650 (void *)&cmd_config_per_port_tx_offload_result_port_id,
16651 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16652 (void *)&cmd_config_per_port_tx_offload_result_offload,
16653 (void *)&cmd_config_per_port_tx_offload_result_on_off,
16658 /* Enable/Disable a per queue offloading */
16659 struct cmd_config_per_queue_tx_offload_result {
16660 cmdline_fixed_string_t port;
16662 cmdline_fixed_string_t txq;
16664 cmdline_fixed_string_t tx_offload;
16665 cmdline_fixed_string_t offload;
16666 cmdline_fixed_string_t on_off;
16669 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16670 TOKEN_STRING_INITIALIZER
16671 (struct cmd_config_per_queue_tx_offload_result,
16673 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16674 TOKEN_NUM_INITIALIZER
16675 (struct cmd_config_per_queue_tx_offload_result,
16676 port_id, RTE_UINT16);
16677 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16678 TOKEN_STRING_INITIALIZER
16679 (struct cmd_config_per_queue_tx_offload_result,
16681 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16682 TOKEN_NUM_INITIALIZER
16683 (struct cmd_config_per_queue_tx_offload_result,
16684 queue_id, RTE_UINT16);
16685 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16686 TOKEN_STRING_INITIALIZER
16687 (struct cmd_config_per_queue_tx_offload_result,
16688 tx_offload, "tx_offload");
16689 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16690 TOKEN_STRING_INITIALIZER
16691 (struct cmd_config_per_queue_tx_offload_result,
16692 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16693 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16694 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16695 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16696 "mt_lockfree#multi_segs#mbuf_fast_free#security");
16697 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16698 TOKEN_STRING_INITIALIZER
16699 (struct cmd_config_per_queue_tx_offload_result,
16703 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16704 __rte_unused struct cmdline *cl,
16705 __rte_unused void *data)
16707 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16708 struct rte_eth_dev_info dev_info;
16709 portid_t port_id = res->port_id;
16710 uint16_t queue_id = res->queue_id;
16711 struct rte_port *port = &ports[port_id];
16712 uint64_t single_offload;
16715 if (port->port_status != RTE_PORT_STOPPED) {
16717 "Error: Can't config offload when Port %d is not stopped\n",
16722 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16726 if (queue_id >= dev_info.nb_tx_queues) {
16728 "Error: input queue_id should be 0 ... %d\n",
16729 dev_info.nb_tx_queues - 1);
16733 single_offload = search_tx_offload(res->offload);
16734 if (single_offload == 0) {
16735 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16739 if (!strcmp(res->on_off, "on"))
16740 port->tx_conf[queue_id].offloads |= single_offload;
16742 port->tx_conf[queue_id].offloads &= ~single_offload;
16744 cmd_reconfig_device_queue(port_id, 1, 1);
16747 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16748 .f = cmd_config_per_queue_tx_offload_parsed,
16750 .help_str = "port <port_id> txq <queue_id> tx_offload "
16751 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16752 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16753 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16754 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16755 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16758 (void *)&cmd_config_per_queue_tx_offload_result_port,
16759 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16760 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16761 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16762 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16763 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16764 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16769 /* *** configure tx_metadata for specific port *** */
16770 struct cmd_config_tx_metadata_specific_result {
16771 cmdline_fixed_string_t port;
16772 cmdline_fixed_string_t keyword;
16774 cmdline_fixed_string_t item;
16779 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16780 __rte_unused struct cmdline *cl,
16781 __rte_unused void *data)
16783 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16785 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16787 ports[res->port_id].tx_metadata = res->value;
16788 /* Add/remove callback to insert valid metadata in every Tx packet. */
16789 if (ports[res->port_id].tx_metadata)
16790 add_tx_md_callback(res->port_id);
16792 remove_tx_md_callback(res->port_id);
16793 rte_flow_dynf_metadata_register();
16796 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16797 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16799 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16800 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16801 keyword, "config");
16802 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16803 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16804 port_id, RTE_UINT16);
16805 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16806 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16807 item, "tx_metadata");
16808 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16809 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16810 value, RTE_UINT32);
16812 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16813 .f = cmd_config_tx_metadata_specific_parsed,
16815 .help_str = "port config <port_id> tx_metadata <value>",
16817 (void *)&cmd_config_tx_metadata_specific_port,
16818 (void *)&cmd_config_tx_metadata_specific_keyword,
16819 (void *)&cmd_config_tx_metadata_specific_id,
16820 (void *)&cmd_config_tx_metadata_specific_item,
16821 (void *)&cmd_config_tx_metadata_specific_value,
16826 /* *** set dynf *** */
16827 struct cmd_config_tx_dynf_specific_result {
16828 cmdline_fixed_string_t port;
16829 cmdline_fixed_string_t keyword;
16831 cmdline_fixed_string_t item;
16832 cmdline_fixed_string_t name;
16833 cmdline_fixed_string_t value;
16837 cmd_config_dynf_specific_parsed(void *parsed_result,
16838 __rte_unused struct cmdline *cl,
16839 __rte_unused void *data)
16841 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16842 struct rte_mbuf_dynflag desc_flag;
16844 uint64_t old_port_flags;
16846 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16848 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16850 if (strlcpy(desc_flag.name, res->name,
16851 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16852 fprintf(stderr, "Flag name too long\n");
16855 desc_flag.flags = 0;
16856 flag = rte_mbuf_dynflag_register(&desc_flag);
16858 fprintf(stderr, "Can't register flag\n");
16861 strcpy(dynf_names[flag], desc_flag.name);
16863 old_port_flags = ports[res->port_id].mbuf_dynf;
16864 if (!strcmp(res->value, "set")) {
16865 ports[res->port_id].mbuf_dynf |= 1UL << flag;
16866 if (old_port_flags == 0)
16867 add_tx_dynf_callback(res->port_id);
16869 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16870 if (ports[res->port_id].mbuf_dynf == 0)
16871 remove_tx_dynf_callback(res->port_id);
16875 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16876 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16878 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16879 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16880 keyword, "config");
16881 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
16882 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16883 port_id, RTE_UINT16);
16884 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
16885 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16887 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
16888 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16890 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
16891 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16892 value, "set#clear");
16894 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
16895 .f = cmd_config_dynf_specific_parsed,
16897 .help_str = "port config <port id> dynf <name> set|clear",
16899 (void *)&cmd_config_tx_dynf_specific_port,
16900 (void *)&cmd_config_tx_dynf_specific_keyword,
16901 (void *)&cmd_config_tx_dynf_specific_port_id,
16902 (void *)&cmd_config_tx_dynf_specific_item,
16903 (void *)&cmd_config_tx_dynf_specific_name,
16904 (void *)&cmd_config_tx_dynf_specific_value,
16909 /* *** display tx_metadata per port configuration *** */
16910 struct cmd_show_tx_metadata_result {
16911 cmdline_fixed_string_t cmd_show;
16912 cmdline_fixed_string_t cmd_port;
16913 cmdline_fixed_string_t cmd_keyword;
16918 cmd_show_tx_metadata_parsed(void *parsed_result,
16919 __rte_unused struct cmdline *cl,
16920 __rte_unused void *data)
16922 struct cmd_show_tx_metadata_result *res = parsed_result;
16924 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16925 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
16928 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
16929 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
16930 ports[res->cmd_pid].tx_metadata);
16934 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
16935 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16937 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
16938 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16940 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
16941 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
16942 cmd_pid, RTE_UINT16);
16943 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
16944 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16945 cmd_keyword, "tx_metadata");
16947 cmdline_parse_inst_t cmd_show_tx_metadata = {
16948 .f = cmd_show_tx_metadata_parsed,
16950 .help_str = "show port <port_id> tx_metadata",
16952 (void *)&cmd_show_tx_metadata_show,
16953 (void *)&cmd_show_tx_metadata_port,
16954 (void *)&cmd_show_tx_metadata_pid,
16955 (void *)&cmd_show_tx_metadata_keyword,
16960 /* *** show fec capability per port configuration *** */
16961 struct cmd_show_fec_capability_result {
16962 cmdline_fixed_string_t cmd_show;
16963 cmdline_fixed_string_t cmd_port;
16964 cmdline_fixed_string_t cmd_fec;
16965 cmdline_fixed_string_t cmd_keyword;
16970 cmd_show_fec_capability_parsed(void *parsed_result,
16971 __rte_unused struct cmdline *cl,
16972 __rte_unused void *data)
16974 struct cmd_show_fec_capability_result *res = parsed_result;
16975 struct rte_eth_fec_capa *speed_fec_capa;
16979 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16980 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
16984 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
16985 if (ret == -ENOTSUP) {
16986 fprintf(stderr, "Function not implemented\n");
16988 } else if (ret < 0) {
16989 fprintf(stderr, "Get FEC capability failed: %d\n", ret);
16993 num = (unsigned int)ret;
16994 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
16995 if (speed_fec_capa == NULL) {
16996 fprintf(stderr, "Failed to alloc FEC capability buffer\n");
17000 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
17002 fprintf(stderr, "Error getting FEC capability: %d\n", ret);
17006 show_fec_capability(num, speed_fec_capa);
17008 free(speed_fec_capa);
17011 cmdline_parse_token_string_t cmd_show_fec_capability_show =
17012 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17014 cmdline_parse_token_string_t cmd_show_fec_capability_port =
17015 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17017 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
17018 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
17019 cmd_pid, RTE_UINT16);
17020 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
17021 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17023 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
17024 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17025 cmd_keyword, "capabilities");
17027 cmdline_parse_inst_t cmd_show_capability = {
17028 .f = cmd_show_fec_capability_parsed,
17030 .help_str = "show port <port_id> fec capabilities",
17032 (void *)&cmd_show_fec_capability_show,
17033 (void *)&cmd_show_fec_capability_port,
17034 (void *)&cmd_show_fec_capability_pid,
17035 (void *)&cmd_show_fec_capability_fec,
17036 (void *)&cmd_show_fec_capability_keyword,
17041 /* *** show fec mode per port configuration *** */
17042 struct cmd_show_fec_metadata_result {
17043 cmdline_fixed_string_t cmd_show;
17044 cmdline_fixed_string_t cmd_port;
17045 cmdline_fixed_string_t cmd_keyword;
17050 cmd_show_fec_mode_parsed(void *parsed_result,
17051 __rte_unused struct cmdline *cl,
17052 __rte_unused void *data)
17054 #define FEC_NAME_SIZE 16
17055 struct cmd_show_fec_metadata_result *res = parsed_result;
17057 char buf[FEC_NAME_SIZE];
17060 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17061 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
17064 ret = rte_eth_fec_get(res->cmd_pid, &mode);
17065 if (ret == -ENOTSUP) {
17066 fprintf(stderr, "Function not implemented\n");
17068 } else if (ret < 0) {
17069 fprintf(stderr, "Get FEC mode failed\n");
17074 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
17075 strlcpy(buf, "off", sizeof(buf));
17077 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
17078 strlcpy(buf, "auto", sizeof(buf));
17080 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
17081 strlcpy(buf, "baser", sizeof(buf));
17083 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
17084 strlcpy(buf, "rs", sizeof(buf));
17090 printf("%s\n", buf);
17093 cmdline_parse_token_string_t cmd_show_fec_mode_show =
17094 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17096 cmdline_parse_token_string_t cmd_show_fec_mode_port =
17097 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17099 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
17100 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
17101 cmd_pid, RTE_UINT16);
17102 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
17103 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17104 cmd_keyword, "fec_mode");
17106 cmdline_parse_inst_t cmd_show_fec_mode = {
17107 .f = cmd_show_fec_mode_parsed,
17109 .help_str = "show port <port_id> fec_mode",
17111 (void *)&cmd_show_fec_mode_show,
17112 (void *)&cmd_show_fec_mode_port,
17113 (void *)&cmd_show_fec_mode_pid,
17114 (void *)&cmd_show_fec_mode_keyword,
17119 /* *** set fec mode per port configuration *** */
17120 struct cmd_set_port_fec_mode {
17121 cmdline_fixed_string_t set;
17122 cmdline_fixed_string_t port;
17124 cmdline_fixed_string_t fec_mode;
17125 cmdline_fixed_string_t fec_value;
17128 /* Common CLI fields for set fec mode */
17129 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
17130 TOKEN_STRING_INITIALIZER
17131 (struct cmd_set_port_fec_mode,
17133 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
17134 TOKEN_STRING_INITIALIZER
17135 (struct cmd_set_port_fec_mode,
17137 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
17138 TOKEN_NUM_INITIALIZER
17139 (struct cmd_set_port_fec_mode,
17140 port_id, RTE_UINT16);
17141 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
17142 TOKEN_STRING_INITIALIZER
17143 (struct cmd_set_port_fec_mode,
17144 fec_mode, "fec_mode");
17145 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
17146 TOKEN_STRING_INITIALIZER
17147 (struct cmd_set_port_fec_mode,
17151 cmd_set_port_fec_mode_parsed(
17152 void *parsed_result,
17153 __rte_unused struct cmdline *cl,
17154 __rte_unused void *data)
17156 struct cmd_set_port_fec_mode *res = parsed_result;
17157 uint16_t port_id = res->port_id;
17161 ret = parse_fec_mode(res->fec_value, &fec_capa);
17163 fprintf(stderr, "Unknown fec mode: %s for port %d\n",
17164 res->fec_value, port_id);
17168 ret = rte_eth_fec_set(port_id, fec_capa);
17169 if (ret == -ENOTSUP) {
17170 fprintf(stderr, "Function not implemented\n");
17172 } else if (ret < 0) {
17173 fprintf(stderr, "Set FEC mode failed\n");
17178 cmdline_parse_inst_t cmd_set_fec_mode = {
17179 .f = cmd_set_port_fec_mode_parsed,
17181 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
17183 (void *)&cmd_set_port_fec_mode_set,
17184 (void *)&cmd_set_port_fec_mode_port,
17185 (void *)&cmd_set_port_fec_mode_port_id,
17186 (void *)&cmd_set_port_fec_mode_str,
17187 (void *)&cmd_set_port_fec_mode_value,
17192 /* show port supported ptypes */
17194 /* Common result structure for show port ptypes */
17195 struct cmd_show_port_supported_ptypes_result {
17196 cmdline_fixed_string_t show;
17197 cmdline_fixed_string_t port;
17199 cmdline_fixed_string_t ptypes;
17202 /* Common CLI fields for show port ptypes */
17203 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
17204 TOKEN_STRING_INITIALIZER
17205 (struct cmd_show_port_supported_ptypes_result,
17207 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
17208 TOKEN_STRING_INITIALIZER
17209 (struct cmd_show_port_supported_ptypes_result,
17211 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
17212 TOKEN_NUM_INITIALIZER
17213 (struct cmd_show_port_supported_ptypes_result,
17214 port_id, RTE_UINT16);
17215 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
17216 TOKEN_STRING_INITIALIZER
17217 (struct cmd_show_port_supported_ptypes_result,
17221 cmd_show_port_supported_ptypes_parsed(
17222 void *parsed_result,
17223 __rte_unused struct cmdline *cl,
17224 __rte_unused void *data)
17226 #define RSVD_PTYPE_MASK 0xf0000000
17227 #define MAX_PTYPES_PER_LAYER 16
17228 #define LTYPE_NAMESIZE 32
17229 #define PTYPE_NAMESIZE 256
17230 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
17231 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
17232 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
17233 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
17234 uint16_t port_id = res->port_id;
17237 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
17241 while (ptype_mask != RSVD_PTYPE_MASK) {
17243 switch (ptype_mask) {
17244 case RTE_PTYPE_L2_MASK:
17245 strlcpy(ltype, "L2", sizeof(ltype));
17247 case RTE_PTYPE_L3_MASK:
17248 strlcpy(ltype, "L3", sizeof(ltype));
17250 case RTE_PTYPE_L4_MASK:
17251 strlcpy(ltype, "L4", sizeof(ltype));
17253 case RTE_PTYPE_TUNNEL_MASK:
17254 strlcpy(ltype, "Tunnel", sizeof(ltype));
17256 case RTE_PTYPE_INNER_L2_MASK:
17257 strlcpy(ltype, "Inner L2", sizeof(ltype));
17259 case RTE_PTYPE_INNER_L3_MASK:
17260 strlcpy(ltype, "Inner L3", sizeof(ltype));
17262 case RTE_PTYPE_INNER_L4_MASK:
17263 strlcpy(ltype, "Inner L4", sizeof(ltype));
17269 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
17270 ptype_mask, ptypes,
17271 MAX_PTYPES_PER_LAYER);
17274 printf("Supported %s ptypes:\n", ltype);
17276 printf("%s ptypes unsupported\n", ltype);
17278 for (i = 0; i < ret; ++i) {
17279 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
17280 printf("%s\n", buf);
17287 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
17288 .f = cmd_show_port_supported_ptypes_parsed,
17290 .help_str = "show port <port_id> ptypes",
17292 (void *)&cmd_show_port_supported_ptypes_show,
17293 (void *)&cmd_show_port_supported_ptypes_port,
17294 (void *)&cmd_show_port_supported_ptypes_port_id,
17295 (void *)&cmd_show_port_supported_ptypes_ptypes,
17300 /* *** display rx/tx descriptor status *** */
17301 struct cmd_show_rx_tx_desc_status_result {
17302 cmdline_fixed_string_t cmd_show;
17303 cmdline_fixed_string_t cmd_port;
17304 cmdline_fixed_string_t cmd_keyword;
17305 cmdline_fixed_string_t cmd_desc;
17306 cmdline_fixed_string_t cmd_status;
17313 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
17314 __rte_unused struct cmdline *cl,
17315 __rte_unused void *data)
17317 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
17320 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17321 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17325 if (!strcmp(res->cmd_keyword, "rxq")) {
17326 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
17330 "Invalid input: queue id = %d, desc id = %d\n",
17331 res->cmd_qid, res->cmd_did);
17334 if (rc == RTE_ETH_RX_DESC_AVAIL)
17335 printf("Desc status = AVAILABLE\n");
17336 else if (rc == RTE_ETH_RX_DESC_DONE)
17337 printf("Desc status = DONE\n");
17339 printf("Desc status = UNAVAILABLE\n");
17340 } else if (!strcmp(res->cmd_keyword, "txq")) {
17341 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17345 "Invalid input: queue id = %d, desc id = %d\n",
17346 res->cmd_qid, res->cmd_did);
17349 if (rc == RTE_ETH_TX_DESC_FULL)
17350 printf("Desc status = FULL\n");
17351 else if (rc == RTE_ETH_TX_DESC_DONE)
17352 printf("Desc status = DONE\n");
17354 printf("Desc status = UNAVAILABLE\n");
17358 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17359 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17361 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17362 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17364 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17365 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17366 cmd_pid, RTE_UINT16);
17367 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17368 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17369 cmd_keyword, "rxq#txq");
17370 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17371 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17372 cmd_qid, RTE_UINT16);
17373 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17374 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17376 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17377 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17378 cmd_did, RTE_UINT16);
17379 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17380 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17381 cmd_status, "status");
17382 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17383 .f = cmd_show_rx_tx_desc_status_parsed,
17385 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17388 (void *)&cmd_show_rx_tx_desc_status_show,
17389 (void *)&cmd_show_rx_tx_desc_status_port,
17390 (void *)&cmd_show_rx_tx_desc_status_pid,
17391 (void *)&cmd_show_rx_tx_desc_status_keyword,
17392 (void *)&cmd_show_rx_tx_desc_status_qid,
17393 (void *)&cmd_show_rx_tx_desc_status_desc,
17394 (void *)&cmd_show_rx_tx_desc_status_did,
17395 (void *)&cmd_show_rx_tx_desc_status_status,
17400 /* *** display rx queue desc used count *** */
17401 struct cmd_show_rx_queue_desc_used_count_result {
17402 cmdline_fixed_string_t cmd_show;
17403 cmdline_fixed_string_t cmd_port;
17404 cmdline_fixed_string_t cmd_rxq;
17405 cmdline_fixed_string_t cmd_desc;
17406 cmdline_fixed_string_t cmd_used;
17407 cmdline_fixed_string_t cmd_count;
17413 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17414 __rte_unused struct cmdline *cl,
17415 __rte_unused void *data)
17417 struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17420 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17421 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17425 rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17427 fprintf(stderr, "Invalid queueid = %d\n", res->cmd_qid);
17430 printf("Used desc count = %d\n", rc);
17433 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17434 TOKEN_STRING_INITIALIZER
17435 (struct cmd_show_rx_queue_desc_used_count_result,
17437 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17438 TOKEN_STRING_INITIALIZER
17439 (struct cmd_show_rx_queue_desc_used_count_result,
17441 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17442 TOKEN_NUM_INITIALIZER
17443 (struct cmd_show_rx_queue_desc_used_count_result,
17444 cmd_pid, RTE_UINT16);
17445 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17446 TOKEN_STRING_INITIALIZER
17447 (struct cmd_show_rx_queue_desc_used_count_result,
17449 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17450 TOKEN_NUM_INITIALIZER
17451 (struct cmd_show_rx_queue_desc_used_count_result,
17452 cmd_qid, RTE_UINT16);
17453 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17454 TOKEN_STRING_INITIALIZER
17455 (struct cmd_show_rx_queue_desc_used_count_result,
17456 cmd_count, "desc");
17457 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17458 TOKEN_STRING_INITIALIZER
17459 (struct cmd_show_rx_queue_desc_used_count_result,
17460 cmd_count, "used");
17461 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17462 TOKEN_STRING_INITIALIZER
17463 (struct cmd_show_rx_queue_desc_used_count_result,
17464 cmd_count, "count");
17465 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17466 .f = cmd_show_rx_queue_desc_used_count_parsed,
17468 .help_str = "show port <port_id> rxq <queue_id> desc used count",
17470 (void *)&cmd_show_rx_queue_desc_used_count_show,
17471 (void *)&cmd_show_rx_queue_desc_used_count_port,
17472 (void *)&cmd_show_rx_queue_desc_used_count_pid,
17473 (void *)&cmd_show_rx_queue_desc_used_count_rxq,
17474 (void *)&cmd_show_rx_queue_desc_used_count_qid,
17475 (void *)&cmd_show_rx_queue_desc_used_count_desc,
17476 (void *)&cmd_show_rx_queue_desc_used_count_used,
17477 (void *)&cmd_show_rx_queue_desc_used_count_count,
17482 /* Common result structure for set port ptypes */
17483 struct cmd_set_port_ptypes_result {
17484 cmdline_fixed_string_t set;
17485 cmdline_fixed_string_t port;
17487 cmdline_fixed_string_t ptype_mask;
17491 /* Common CLI fields for set port ptypes */
17492 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17493 TOKEN_STRING_INITIALIZER
17494 (struct cmd_set_port_ptypes_result,
17496 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17497 TOKEN_STRING_INITIALIZER
17498 (struct cmd_set_port_ptypes_result,
17500 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17501 TOKEN_NUM_INITIALIZER
17502 (struct cmd_set_port_ptypes_result,
17503 port_id, RTE_UINT16);
17504 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17505 TOKEN_STRING_INITIALIZER
17506 (struct cmd_set_port_ptypes_result,
17507 ptype_mask, "ptype_mask");
17508 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17509 TOKEN_NUM_INITIALIZER
17510 (struct cmd_set_port_ptypes_result,
17514 cmd_set_port_ptypes_parsed(
17515 void *parsed_result,
17516 __rte_unused struct cmdline *cl,
17517 __rte_unused void *data)
17519 struct cmd_set_port_ptypes_result *res = parsed_result;
17520 #define PTYPE_NAMESIZE 256
17521 char ptype_name[PTYPE_NAMESIZE];
17522 uint16_t port_id = res->port_id;
17523 uint32_t ptype_mask = res->mask;
17526 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17529 fprintf(stderr, "Port %d doesn't support any ptypes.\n",
17534 uint32_t ptypes[ret];
17536 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17538 fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
17543 printf("Successfully set following ptypes for Port %d\n", port_id);
17544 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17545 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17546 printf("%s\n", ptype_name);
17549 clear_ptypes = false;
17552 cmdline_parse_inst_t cmd_set_port_ptypes = {
17553 .f = cmd_set_port_ptypes_parsed,
17555 .help_str = "set port <port_id> ptype_mask <mask>",
17557 (void *)&cmd_set_port_ptypes_set,
17558 (void *)&cmd_set_port_ptypes_port,
17559 (void *)&cmd_set_port_ptypes_port_id,
17560 (void *)&cmd_set_port_ptypes_mask_str,
17561 (void *)&cmd_set_port_ptypes_mask_u32,
17566 /* *** display mac addresses added to a port *** */
17567 struct cmd_showport_macs_result {
17568 cmdline_fixed_string_t cmd_show;
17569 cmdline_fixed_string_t cmd_port;
17570 cmdline_fixed_string_t cmd_keyword;
17575 cmd_showport_macs_parsed(void *parsed_result,
17576 __rte_unused struct cmdline *cl,
17577 __rte_unused void *data)
17579 struct cmd_showport_macs_result *res = parsed_result;
17581 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17584 if (!strcmp(res->cmd_keyword, "macs"))
17585 show_macs(res->cmd_pid);
17586 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17587 show_mcast_macs(res->cmd_pid);
17590 cmdline_parse_token_string_t cmd_showport_macs_show =
17591 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17593 cmdline_parse_token_string_t cmd_showport_macs_port =
17594 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17596 cmdline_parse_token_num_t cmd_showport_macs_pid =
17597 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17598 cmd_pid, RTE_UINT16);
17599 cmdline_parse_token_string_t cmd_showport_macs_keyword =
17600 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17601 cmd_keyword, "macs#mcast_macs");
17603 cmdline_parse_inst_t cmd_showport_macs = {
17604 .f = cmd_showport_macs_parsed,
17606 .help_str = "show port <port_id> macs|mcast_macs",
17608 (void *)&cmd_showport_macs_show,
17609 (void *)&cmd_showport_macs_port,
17610 (void *)&cmd_showport_macs_pid,
17611 (void *)&cmd_showport_macs_keyword,
17616 /* *** show flow transfer proxy port ID for the given port *** */
17617 struct cmd_show_port_flow_transfer_proxy_result {
17618 cmdline_fixed_string_t show;
17619 cmdline_fixed_string_t port;
17621 cmdline_fixed_string_t flow;
17622 cmdline_fixed_string_t transfer;
17623 cmdline_fixed_string_t proxy;
17626 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_show =
17627 TOKEN_STRING_INITIALIZER
17628 (struct cmd_show_port_flow_transfer_proxy_result,
17630 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_port =
17631 TOKEN_STRING_INITIALIZER
17632 (struct cmd_show_port_flow_transfer_proxy_result,
17634 cmdline_parse_token_num_t cmd_show_port_flow_transfer_proxy_port_id =
17635 TOKEN_NUM_INITIALIZER
17636 (struct cmd_show_port_flow_transfer_proxy_result,
17637 port_id, RTE_UINT16);
17638 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_flow =
17639 TOKEN_STRING_INITIALIZER
17640 (struct cmd_show_port_flow_transfer_proxy_result,
17642 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_transfer =
17643 TOKEN_STRING_INITIALIZER
17644 (struct cmd_show_port_flow_transfer_proxy_result,
17645 transfer, "transfer");
17646 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_proxy =
17647 TOKEN_STRING_INITIALIZER
17648 (struct cmd_show_port_flow_transfer_proxy_result,
17652 cmd_show_port_flow_transfer_proxy_parsed(void *parsed_result,
17653 __rte_unused struct cmdline *cl,
17654 __rte_unused void *data)
17656 struct cmd_show_port_flow_transfer_proxy_result *res = parsed_result;
17657 portid_t proxy_port_id;
17662 ret = rte_flow_pick_transfer_proxy(res->port_id, &proxy_port_id, NULL);
17664 fprintf(stderr, "Failed to pick transfer proxy: %s\n",
17665 rte_strerror(-ret));
17669 printf("Transfer proxy port ID: %u\n\n", proxy_port_id);
17672 cmdline_parse_inst_t cmd_show_port_flow_transfer_proxy = {
17673 .f = cmd_show_port_flow_transfer_proxy_parsed,
17675 .help_str = "show port <port_id> flow transfer proxy",
17677 (void *)&cmd_show_port_flow_transfer_proxy_show,
17678 (void *)&cmd_show_port_flow_transfer_proxy_port,
17679 (void *)&cmd_show_port_flow_transfer_proxy_port_id,
17680 (void *)&cmd_show_port_flow_transfer_proxy_flow,
17681 (void *)&cmd_show_port_flow_transfer_proxy_transfer,
17682 (void *)&cmd_show_port_flow_transfer_proxy_proxy,
17687 /* ******************************************************************************** */
17689 /* list of instructions */
17690 cmdline_parse_ctx_t main_ctx[] = {
17691 (cmdline_parse_inst_t *)&cmd_help_brief,
17692 (cmdline_parse_inst_t *)&cmd_help_long,
17693 (cmdline_parse_inst_t *)&cmd_quit,
17694 (cmdline_parse_inst_t *)&cmd_load_from_file,
17695 (cmdline_parse_inst_t *)&cmd_showport,
17696 (cmdline_parse_inst_t *)&cmd_showqueue,
17697 (cmdline_parse_inst_t *)&cmd_showeeprom,
17698 (cmdline_parse_inst_t *)&cmd_showportall,
17699 (cmdline_parse_inst_t *)&cmd_representor_info,
17700 (cmdline_parse_inst_t *)&cmd_showdevice,
17701 (cmdline_parse_inst_t *)&cmd_showcfg,
17702 (cmdline_parse_inst_t *)&cmd_showfwdall,
17703 (cmdline_parse_inst_t *)&cmd_start,
17704 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17705 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17706 (cmdline_parse_inst_t *)&cmd_set_link_up,
17707 (cmdline_parse_inst_t *)&cmd_set_link_down,
17708 (cmdline_parse_inst_t *)&cmd_reset,
17709 (cmdline_parse_inst_t *)&cmd_set_numbers,
17710 (cmdline_parse_inst_t *)&cmd_set_log,
17711 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
17712 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
17713 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17714 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17715 (cmdline_parse_inst_t *)&cmd_set_txtimes,
17716 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17717 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17718 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17719 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17720 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17721 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17722 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17723 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17724 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17725 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17726 (cmdline_parse_inst_t *)&cmd_set_link_check,
17727 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17728 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17729 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17730 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17731 #ifdef RTE_NET_BOND
17732 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17733 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17734 (cmdline_parse_inst_t *) &cmd_show_bonding_lacp_info,
17735 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17736 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17737 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17738 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17739 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17740 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17741 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17742 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17743 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17745 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17746 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17747 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17748 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17749 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17750 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17751 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17752 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17753 (cmdline_parse_inst_t *)&cmd_csum_set,
17754 (cmdline_parse_inst_t *)&cmd_csum_show,
17755 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17756 (cmdline_parse_inst_t *)&cmd_tso_set,
17757 (cmdline_parse_inst_t *)&cmd_tso_show,
17758 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17759 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17761 (cmdline_parse_inst_t *)&cmd_gro_enable,
17762 (cmdline_parse_inst_t *)&cmd_gro_flush,
17763 (cmdline_parse_inst_t *)&cmd_gro_show,
17766 (cmdline_parse_inst_t *)&cmd_gso_enable,
17767 (cmdline_parse_inst_t *)&cmd_gso_size,
17768 (cmdline_parse_inst_t *)&cmd_gso_show,
17770 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17771 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17772 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17773 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17774 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17775 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17776 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17777 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17778 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17779 (cmdline_parse_inst_t *)&cmd_link_flow_control_show,
17780 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17781 (cmdline_parse_inst_t *)&cmd_config_dcb,
17782 (cmdline_parse_inst_t *)&cmd_read_reg,
17783 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17784 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17785 (cmdline_parse_inst_t *)&cmd_write_reg,
17786 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17787 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17788 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17789 (cmdline_parse_inst_t *)&cmd_stop,
17790 (cmdline_parse_inst_t *)&cmd_mac_addr,
17791 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17792 (cmdline_parse_inst_t *)&cmd_set_qmap,
17793 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17794 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17795 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17796 (cmdline_parse_inst_t *)&cmd_operate_port,
17797 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17798 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17799 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17800 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
17801 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17802 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17803 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17804 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17805 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17806 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17807 (cmdline_parse_inst_t *)&cmd_config_mtu,
17808 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17809 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17810 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17811 (cmdline_parse_inst_t *)&cmd_config_rss,
17812 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17813 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17814 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17815 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17816 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17817 (cmdline_parse_inst_t *)&cmd_showport_reta,
17818 (cmdline_parse_inst_t *)&cmd_showport_macs,
17819 (cmdline_parse_inst_t *)&cmd_show_port_flow_transfer_proxy,
17820 (cmdline_parse_inst_t *)&cmd_config_burst,
17821 (cmdline_parse_inst_t *)&cmd_config_thresh,
17822 (cmdline_parse_inst_t *)&cmd_config_threshold,
17823 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17824 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17825 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17826 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17827 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17828 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17829 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17830 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17831 (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
17832 (cmdline_parse_inst_t *)&cmd_dump,
17833 (cmdline_parse_inst_t *)&cmd_dump_one,
17834 #ifdef RTE_NET_I40E
17835 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17837 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17838 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17839 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17840 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17841 (cmdline_parse_inst_t *)&cmd_flow,
17842 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17843 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17844 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17845 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17846 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17847 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17848 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17849 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17850 (cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
17851 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17852 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17853 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17854 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17855 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17856 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17857 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17858 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17859 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17860 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17861 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17862 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17863 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17864 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17865 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17866 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17867 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17868 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17869 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17870 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17871 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17872 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17873 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17874 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17875 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17876 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17877 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17878 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17879 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
17880 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
17881 (cmdline_parse_inst_t *)&cmd_set_vxlan,
17882 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
17883 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17884 (cmdline_parse_inst_t *)&cmd_set_nvgre,
17885 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17886 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
17887 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
17888 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
17889 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
17890 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
17891 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
17892 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
17893 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
17894 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
17895 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
17896 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
17897 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
17898 (cmdline_parse_inst_t *)&cmd_set_conntrack_common,
17899 (cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
17900 (cmdline_parse_inst_t *)&cmd_ddp_add,
17901 (cmdline_parse_inst_t *)&cmd_ddp_del,
17902 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
17903 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
17904 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
17905 (cmdline_parse_inst_t *)&cmd_clear_input_set,
17906 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
17907 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17908 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
17909 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
17910 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17911 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17912 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17913 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17915 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17916 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17917 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17918 (cmdline_parse_inst_t *)&cmd_queue_region,
17919 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17920 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17921 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17922 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17923 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17924 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17925 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17926 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17927 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17928 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17929 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17930 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17931 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17932 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17933 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17934 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17935 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17936 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
17937 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17938 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17939 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17940 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17941 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17942 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17943 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
17944 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
17945 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
17946 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17947 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17948 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17949 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17950 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17951 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17952 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17953 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17954 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17956 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17957 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17959 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
17960 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
17961 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
17962 (cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
17963 (cmdline_parse_inst_t *)&cmd_set_raw,
17964 (cmdline_parse_inst_t *)&cmd_show_set_raw,
17965 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
17966 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
17967 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
17968 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
17969 (cmdline_parse_inst_t *)&cmd_show_capability,
17970 (cmdline_parse_inst_t *)&cmd_set_flex_is_pattern,
17971 (cmdline_parse_inst_t *)&cmd_set_flex_spec_pattern,
17975 /* read cmdline commands from file */
17977 cmdline_read_from_file(const char *filename)
17979 struct cmdline *cl;
17981 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17984 "Failed to create file based cmdline context: %s\n",
17989 cmdline_interact(cl);
17994 printf("Read CLI commands from %s\n", filename);
17997 /* prompt function, called from main on MAIN lcore */
18002 /* initialize non-constant commands */
18003 cmd_set_fwd_mode_init();
18004 cmd_set_fwd_retry_mode_init();
18006 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
18007 if (testpmd_cl == NULL)
18010 ret = atexit(prompt_exit);
18012 fprintf(stderr, "Cannot set exit function for cmdline\n");
18014 cmdline_interact(testpmd_cl);
18016 cmdline_stdin_exit(testpmd_cl);
18022 if (testpmd_cl != NULL) {
18023 cmdline_quit(testpmd_cl);
18024 cmdline_stdin_exit(testpmd_cl);
18029 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
18031 if (id == (portid_t)RTE_PORT_ALL) {
18034 RTE_ETH_FOREACH_DEV(pid) {
18035 /* check if need_reconfig has been set to 1 */
18036 if (ports[pid].need_reconfig == 0)
18037 ports[pid].need_reconfig = dev;
18038 /* check if need_reconfig_queues has been set to 1 */
18039 if (ports[pid].need_reconfig_queues == 0)
18040 ports[pid].need_reconfig_queues = queue;
18042 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
18043 /* check if need_reconfig has been set to 1 */
18044 if (ports[id].need_reconfig == 0)
18045 ports[id].need_reconfig = dev;
18046 /* check if need_reconfig_queues has been set to 1 */
18047 if (ports[id].need_reconfig_queues == 0)
18048 ports[id].need_reconfig_queues = queue;