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;
5919 /* Set the bonding mode for the relevant port. */
5920 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5921 fprintf(stderr, "\t Failed to set bonding mode for port = %d.\n",
5925 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5926 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5928 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5929 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5930 bonding, "bonding");
5931 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5932 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5934 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5935 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5937 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5938 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5939 port_id, RTE_UINT16);
5941 cmdline_parse_inst_t cmd_set_bonding_mode = {
5942 .f = cmd_set_bonding_mode_parsed,
5943 .help_str = "set bonding mode <mode_value> <port_id>: "
5944 "Set the bonding mode for port_id",
5947 (void *) &cmd_setbonding_mode_set,
5948 (void *) &cmd_setbonding_mode_bonding,
5949 (void *) &cmd_setbonding_mode_mode,
5950 (void *) &cmd_setbonding_mode_value,
5951 (void *) &cmd_setbonding_mode_port,
5956 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5957 struct cmd_set_bonding_lacp_dedicated_queues_result {
5958 cmdline_fixed_string_t set;
5959 cmdline_fixed_string_t bonding;
5960 cmdline_fixed_string_t lacp;
5961 cmdline_fixed_string_t dedicated_queues;
5963 cmdline_fixed_string_t mode;
5966 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5967 __rte_unused struct cmdline *cl,
5968 __rte_unused void *data)
5970 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5971 portid_t port_id = res->port_id;
5972 struct rte_port *port;
5974 port = &ports[port_id];
5976 /** Check if the port is not started **/
5977 if (port->port_status != RTE_PORT_STOPPED) {
5978 fprintf(stderr, "Please stop port %d first\n", port_id);
5982 if (!strcmp(res->mode, "enable")) {
5983 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5984 printf("Dedicate queues for LACP control packets"
5987 printf("Enabling dedicate queues for LACP control "
5988 "packets on port %d failed\n", port_id);
5989 } else if (!strcmp(res->mode, "disable")) {
5990 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5991 printf("Dedicated queues for LACP control packets "
5994 printf("Disabling dedicated queues for LACP control "
5995 "traffic on port %d failed\n", port_id);
5999 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
6000 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6002 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
6003 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6004 bonding, "bonding");
6005 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
6006 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6008 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
6009 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6010 dedicated_queues, "dedicated_queues");
6011 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
6012 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6013 port_id, RTE_UINT16);
6014 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
6015 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6016 mode, "enable#disable");
6018 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
6019 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
6020 .help_str = "set bonding lacp dedicated_queues <port_id> "
6022 "Enable/disable dedicated queues for LACP control traffic for port_id",
6025 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
6026 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
6027 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
6028 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
6029 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
6030 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
6035 /* *** SET BALANCE XMIT POLICY *** */
6036 struct cmd_set_bonding_balance_xmit_policy_result {
6037 cmdline_fixed_string_t set;
6038 cmdline_fixed_string_t bonding;
6039 cmdline_fixed_string_t balance_xmit_policy;
6041 cmdline_fixed_string_t policy;
6044 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
6045 __rte_unused struct cmdline *cl,
6046 __rte_unused void *data)
6048 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6049 portid_t port_id = res->port_id;
6052 if (!strcmp(res->policy, "l2")) {
6053 policy = BALANCE_XMIT_POLICY_LAYER2;
6054 } else if (!strcmp(res->policy, "l23")) {
6055 policy = BALANCE_XMIT_POLICY_LAYER23;
6056 } else if (!strcmp(res->policy, "l34")) {
6057 policy = BALANCE_XMIT_POLICY_LAYER34;
6059 fprintf(stderr, "\t Invalid xmit policy selection");
6063 /* Set the bonding mode for the relevant port. */
6064 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6066 "\t Failed to set bonding balance xmit policy for port = %d.\n",
6071 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6072 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6074 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6075 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6076 bonding, "bonding");
6077 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6078 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6079 balance_xmit_policy, "balance_xmit_policy");
6080 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6081 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6082 port_id, RTE_UINT16);
6083 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6084 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6085 policy, "l2#l23#l34");
6087 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6088 .f = cmd_set_bonding_balance_xmit_policy_parsed,
6089 .help_str = "set bonding balance_xmit_policy <port_id> "
6091 "Set the bonding balance_xmit_policy for port_id",
6094 (void *)&cmd_setbonding_balance_xmit_policy_set,
6095 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
6096 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6097 (void *)&cmd_setbonding_balance_xmit_policy_port,
6098 (void *)&cmd_setbonding_balance_xmit_policy_policy,
6103 /* *** SHOW IEEE802.3 BONDING INFORMATION *** */
6104 struct cmd_show_bonding_lacp_info_result {
6105 cmdline_fixed_string_t show;
6106 cmdline_fixed_string_t bonding;
6107 cmdline_fixed_string_t lacp;
6108 cmdline_fixed_string_t info;
6112 static void port_param_show(struct port_params *params)
6114 char buf[RTE_ETHER_ADDR_FMT_SIZE];
6116 printf("\t\tsystem priority: %u\n", params->system_priority);
6117 rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, ¶ms->system);
6118 printf("\t\tsystem mac address: %s\n", buf);
6119 printf("\t\tport key: %u\n", params->key);
6120 printf("\t\tport priority: %u\n", params->port_priority);
6121 printf("\t\tport number: %u\n", params->port_number);
6124 static void lacp_slave_info_show(struct rte_eth_bond_8023ad_slave_info *info)
6126 char a_state[256] = { 0 };
6127 char p_state[256] = { 0 };
6132 static const char * const state[] = {
6142 static const char * const selection[] = {
6148 for (i = 0; i < RTE_DIM(state); i++) {
6149 if ((info->actor_state >> i) & 1)
6150 a_len += snprintf(&a_state[a_len],
6151 RTE_DIM(a_state) - a_len, "%s ",
6154 if ((info->partner_state >> i) & 1)
6155 p_len += snprintf(&p_state[p_len],
6156 RTE_DIM(p_state) - p_len, "%s ",
6159 printf("\tAggregator port id: %u\n", info->agg_port_id);
6160 printf("\tselection: %s\n", selection[info->selected]);
6161 printf("\tActor detail info:\n");
6162 port_param_show(&info->actor);
6163 printf("\t\tport state: %s\n", a_state);
6164 printf("\tPartner detail info:\n");
6165 port_param_show(&info->partner);
6166 printf("\t\tport state: %s\n", p_state);
6170 static void lacp_conf_show(struct rte_eth_bond_8023ad_conf *conf)
6172 printf("\tfast period: %u ms\n", conf->fast_periodic_ms);
6173 printf("\tslow period: %u ms\n", conf->slow_periodic_ms);
6174 printf("\tshort timeout: %u ms\n", conf->short_timeout_ms);
6175 printf("\tlong timeout: %u ms\n", conf->long_timeout_ms);
6176 printf("\taggregate wait timeout: %u ms\n",
6177 conf->aggregate_wait_timeout_ms);
6178 printf("\ttx period: %u ms\n", conf->tx_period_ms);
6179 printf("\trx marker period: %u ms\n", conf->rx_marker_period_ms);
6180 printf("\tupdate timeout: %u ms\n", conf->update_timeout_ms);
6181 switch (conf->agg_selection) {
6183 printf("\taggregation mode: bandwidth\n");
6186 printf("\taggregation mode: stable\n");
6189 printf("\taggregation mode: count\n");
6192 printf("\taggregation mode: invalid\n");
6199 static void cmd_show_bonding_lacp_info_parsed(void *parsed_result,
6200 __rte_unused struct cmdline *cl,
6201 __rte_unused void *data)
6203 struct cmd_show_bonding_lacp_info_result *res = parsed_result;
6204 struct rte_eth_bond_8023ad_slave_info slave_info;
6205 struct rte_eth_bond_8023ad_conf port_conf;
6206 portid_t slaves[RTE_MAX_ETHPORTS];
6207 portid_t port_id = res->port_id;
6208 int num_active_slaves;
6213 bonding_mode = rte_eth_bond_mode_get(port_id);
6214 if (bonding_mode != BONDING_MODE_8023AD) {
6215 fprintf(stderr, "\tBonding mode is not mode 4\n");
6219 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6221 if (num_active_slaves < 0) {
6222 fprintf(stderr, "\tFailed to get active slave list for port = %u\n",
6226 if (num_active_slaves == 0)
6227 fprintf(stderr, "\tIEEE802.3 port %u has no active slave\n",
6230 printf("\tIEEE802.3 port: %u\n", port_id);
6231 ret = rte_eth_bond_8023ad_conf_get(port_id, &port_conf);
6233 fprintf(stderr, "\tGet bonded device %u info failed\n",
6237 lacp_conf_show(&port_conf);
6239 for (i = 0; i < num_active_slaves; i++) {
6240 ret = rte_eth_bond_8023ad_slave_info(port_id, slaves[i],
6243 fprintf(stderr, "\tGet slave device %u info failed\n",
6247 printf("\tSlave Port: %u\n", slaves[i]);
6248 lacp_slave_info_show(&slave_info);
6252 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_show =
6253 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6255 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_bonding =
6256 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6257 bonding, "bonding");
6258 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_lacp =
6259 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6261 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_info =
6262 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6264 cmdline_parse_token_num_t cmd_show_bonding_lacp_info_port_id =
6265 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6266 port_id, RTE_UINT16);
6268 cmdline_parse_inst_t cmd_show_bonding_lacp_info = {
6269 .f = cmd_show_bonding_lacp_info_parsed,
6270 .help_str = "show bonding lacp info <port_id> : "
6271 "Show bonding IEEE802.3 information for port_id",
6274 (void *)&cmd_show_bonding_lacp_info_show,
6275 (void *)&cmd_show_bonding_lacp_info_bonding,
6276 (void *)&cmd_show_bonding_lacp_info_lacp,
6277 (void *)&cmd_show_bonding_lacp_info_info,
6278 (void *)&cmd_show_bonding_lacp_info_port_id,
6283 /* *** SHOW NIC BONDING CONFIGURATION *** */
6284 struct cmd_show_bonding_config_result {
6285 cmdline_fixed_string_t show;
6286 cmdline_fixed_string_t bonding;
6287 cmdline_fixed_string_t config;
6291 static void cmd_show_bonding_config_parsed(void *parsed_result,
6292 __rte_unused struct cmdline *cl,
6293 __rte_unused void *data)
6295 struct cmd_show_bonding_config_result *res = parsed_result;
6296 int bonding_mode, agg_mode;
6297 portid_t slaves[RTE_MAX_ETHPORTS];
6298 int num_slaves, num_active_slaves;
6301 portid_t port_id = res->port_id;
6303 /* Display the bonding mode.*/
6304 bonding_mode = rte_eth_bond_mode_get(port_id);
6305 if (bonding_mode < 0) {
6306 fprintf(stderr, "\tFailed to get bonding mode for port = %d\n",
6310 printf("\tBonding mode: %d\n", bonding_mode);
6312 if (bonding_mode == BONDING_MODE_BALANCE ||
6313 bonding_mode == BONDING_MODE_8023AD) {
6314 int balance_xmit_policy;
6316 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6317 if (balance_xmit_policy < 0) {
6319 "\tFailed to get balance xmit policy for port = %d\n",
6323 printf("\tBalance Xmit Policy: ");
6325 switch (balance_xmit_policy) {
6326 case BALANCE_XMIT_POLICY_LAYER2:
6327 printf("BALANCE_XMIT_POLICY_LAYER2");
6329 case BALANCE_XMIT_POLICY_LAYER23:
6330 printf("BALANCE_XMIT_POLICY_LAYER23");
6332 case BALANCE_XMIT_POLICY_LAYER34:
6333 printf("BALANCE_XMIT_POLICY_LAYER34");
6340 if (bonding_mode == BONDING_MODE_8023AD) {
6341 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6342 printf("\tIEEE802.3AD Aggregator Mode: ");
6345 printf("bandwidth");
6357 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6359 if (num_slaves < 0) {
6360 fprintf(stderr, "\tFailed to get slave list for port = %d\n",
6364 if (num_slaves > 0) {
6365 printf("\tSlaves (%d): [", num_slaves);
6366 for (i = 0; i < num_slaves - 1; i++)
6367 printf("%d ", slaves[i]);
6369 printf("%d]\n", slaves[num_slaves - 1]);
6371 printf("\tSlaves: []\n");
6375 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6378 if (num_active_slaves < 0) {
6380 "\tFailed to get active slave list for port = %d\n",
6384 if (num_active_slaves > 0) {
6385 printf("\tActive Slaves (%d): [", num_active_slaves);
6386 for (i = 0; i < num_active_slaves - 1; i++)
6387 printf("%d ", slaves[i]);
6389 printf("%d]\n", slaves[num_active_slaves - 1]);
6392 printf("\tActive Slaves: []\n");
6396 primary_id = rte_eth_bond_primary_get(port_id);
6397 if (primary_id < 0) {
6398 fprintf(stderr, "\tFailed to get primary slave for port = %d\n",
6402 printf("\tPrimary: [%d]\n", primary_id);
6406 cmdline_parse_token_string_t cmd_showbonding_config_show =
6407 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6409 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6410 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6411 bonding, "bonding");
6412 cmdline_parse_token_string_t cmd_showbonding_config_config =
6413 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6415 cmdline_parse_token_num_t cmd_showbonding_config_port =
6416 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6417 port_id, RTE_UINT16);
6419 cmdline_parse_inst_t cmd_show_bonding_config = {
6420 .f = cmd_show_bonding_config_parsed,
6421 .help_str = "show bonding config <port_id>: "
6422 "Show the bonding config for port_id",
6425 (void *)&cmd_showbonding_config_show,
6426 (void *)&cmd_showbonding_config_bonding,
6427 (void *)&cmd_showbonding_config_config,
6428 (void *)&cmd_showbonding_config_port,
6433 /* *** SET BONDING PRIMARY *** */
6434 struct cmd_set_bonding_primary_result {
6435 cmdline_fixed_string_t set;
6436 cmdline_fixed_string_t bonding;
6437 cmdline_fixed_string_t primary;
6442 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6443 __rte_unused struct cmdline *cl,
6444 __rte_unused void *data)
6446 struct cmd_set_bonding_primary_result *res = parsed_result;
6447 portid_t master_port_id = res->port_id;
6448 portid_t slave_port_id = res->slave_id;
6450 /* Set the primary slave for a bonded device. */
6451 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6452 fprintf(stderr, "\t Failed to set primary slave for port = %d.\n",
6459 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6460 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6462 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6463 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6464 bonding, "bonding");
6465 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6466 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6467 primary, "primary");
6468 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6469 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6470 slave_id, RTE_UINT16);
6471 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6472 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6473 port_id, RTE_UINT16);
6475 cmdline_parse_inst_t cmd_set_bonding_primary = {
6476 .f = cmd_set_bonding_primary_parsed,
6477 .help_str = "set bonding primary <slave_id> <port_id>: "
6478 "Set the primary slave for port_id",
6481 (void *)&cmd_setbonding_primary_set,
6482 (void *)&cmd_setbonding_primary_bonding,
6483 (void *)&cmd_setbonding_primary_primary,
6484 (void *)&cmd_setbonding_primary_slave,
6485 (void *)&cmd_setbonding_primary_port,
6490 /* *** ADD SLAVE *** */
6491 struct cmd_add_bonding_slave_result {
6492 cmdline_fixed_string_t add;
6493 cmdline_fixed_string_t bonding;
6494 cmdline_fixed_string_t slave;
6499 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6500 __rte_unused struct cmdline *cl,
6501 __rte_unused void *data)
6503 struct cmd_add_bonding_slave_result *res = parsed_result;
6504 portid_t master_port_id = res->port_id;
6505 portid_t slave_port_id = res->slave_id;
6507 /* add the slave for a bonded device. */
6508 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6510 "\t Failed to add slave %d to master port = %d.\n",
6511 slave_port_id, master_port_id);
6515 set_port_slave_flag(slave_port_id);
6518 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6519 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6521 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6522 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6523 bonding, "bonding");
6524 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6525 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6527 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6528 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6529 slave_id, RTE_UINT16);
6530 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6531 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6532 port_id, RTE_UINT16);
6534 cmdline_parse_inst_t cmd_add_bonding_slave = {
6535 .f = cmd_add_bonding_slave_parsed,
6536 .help_str = "add bonding slave <slave_id> <port_id>: "
6537 "Add a slave device to a bonded device",
6540 (void *)&cmd_addbonding_slave_add,
6541 (void *)&cmd_addbonding_slave_bonding,
6542 (void *)&cmd_addbonding_slave_slave,
6543 (void *)&cmd_addbonding_slave_slaveid,
6544 (void *)&cmd_addbonding_slave_port,
6549 /* *** REMOVE SLAVE *** */
6550 struct cmd_remove_bonding_slave_result {
6551 cmdline_fixed_string_t remove;
6552 cmdline_fixed_string_t bonding;
6553 cmdline_fixed_string_t slave;
6558 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6559 __rte_unused struct cmdline *cl,
6560 __rte_unused void *data)
6562 struct cmd_remove_bonding_slave_result *res = parsed_result;
6563 portid_t master_port_id = res->port_id;
6564 portid_t slave_port_id = res->slave_id;
6566 /* remove the slave from a bonded device. */
6567 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6569 "\t Failed to remove slave %d from master port = %d.\n",
6570 slave_port_id, master_port_id);
6574 clear_port_slave_flag(slave_port_id);
6577 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6578 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6580 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6581 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6582 bonding, "bonding");
6583 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6584 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6586 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6587 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6588 slave_id, RTE_UINT16);
6589 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6590 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6591 port_id, RTE_UINT16);
6593 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6594 .f = cmd_remove_bonding_slave_parsed,
6595 .help_str = "remove bonding slave <slave_id> <port_id>: "
6596 "Remove a slave device from a bonded device",
6599 (void *)&cmd_removebonding_slave_remove,
6600 (void *)&cmd_removebonding_slave_bonding,
6601 (void *)&cmd_removebonding_slave_slave,
6602 (void *)&cmd_removebonding_slave_slaveid,
6603 (void *)&cmd_removebonding_slave_port,
6608 /* *** CREATE BONDED DEVICE *** */
6609 struct cmd_create_bonded_device_result {
6610 cmdline_fixed_string_t create;
6611 cmdline_fixed_string_t bonded;
6612 cmdline_fixed_string_t device;
6617 static int bond_dev_num = 0;
6619 static void cmd_create_bonded_device_parsed(void *parsed_result,
6620 __rte_unused struct cmdline *cl,
6621 __rte_unused void *data)
6623 struct cmd_create_bonded_device_result *res = parsed_result;
6624 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6628 if (test_done == 0) {
6629 fprintf(stderr, "Please stop forwarding first\n");
6633 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6636 /* Create a new bonded device. */
6637 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6639 fprintf(stderr, "\t Failed to create bonded device.\n");
6642 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6645 /* Update number of ports */
6646 nb_ports = rte_eth_dev_count_avail();
6647 reconfig(port_id, res->socket);
6648 ret = rte_eth_promiscuous_enable(port_id);
6651 "Failed to enable promiscuous mode for port %u: %s - ignore\n",
6652 port_id, rte_strerror(-ret));
6654 ports[port_id].need_setup = 0;
6655 ports[port_id].port_status = RTE_PORT_STOPPED;
6660 cmdline_parse_token_string_t cmd_createbonded_device_create =
6661 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6663 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6664 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6666 cmdline_parse_token_string_t cmd_createbonded_device_device =
6667 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6669 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6670 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6672 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6673 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6676 cmdline_parse_inst_t cmd_create_bonded_device = {
6677 .f = cmd_create_bonded_device_parsed,
6678 .help_str = "create bonded device <mode> <socket>: "
6679 "Create a new bonded device with specific bonding mode and socket",
6682 (void *)&cmd_createbonded_device_create,
6683 (void *)&cmd_createbonded_device_bonded,
6684 (void *)&cmd_createbonded_device_device,
6685 (void *)&cmd_createbonded_device_mode,
6686 (void *)&cmd_createbonded_device_socket,
6691 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6692 struct cmd_set_bond_mac_addr_result {
6693 cmdline_fixed_string_t set;
6694 cmdline_fixed_string_t bonding;
6695 cmdline_fixed_string_t mac_addr;
6697 struct rte_ether_addr address;
6700 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6701 __rte_unused struct cmdline *cl,
6702 __rte_unused void *data)
6704 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6707 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6710 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6712 /* check the return value and print it if is < 0 */
6714 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6718 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6719 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6720 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6721 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6723 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6724 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6726 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6727 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6728 port_num, RTE_UINT16);
6729 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6730 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6732 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6733 .f = cmd_set_bond_mac_addr_parsed,
6735 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6737 (void *)&cmd_set_bond_mac_addr_set,
6738 (void *)&cmd_set_bond_mac_addr_bonding,
6739 (void *)&cmd_set_bond_mac_addr_mac,
6740 (void *)&cmd_set_bond_mac_addr_portnum,
6741 (void *)&cmd_set_bond_mac_addr_addr,
6747 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6748 struct cmd_set_bond_mon_period_result {
6749 cmdline_fixed_string_t set;
6750 cmdline_fixed_string_t bonding;
6751 cmdline_fixed_string_t mon_period;
6756 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6757 __rte_unused struct cmdline *cl,
6758 __rte_unused void *data)
6760 struct cmd_set_bond_mon_period_result *res = parsed_result;
6763 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6765 /* check the return value and print it if is < 0 */
6767 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6771 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6772 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6774 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6775 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6776 bonding, "bonding");
6777 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6778 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6779 mon_period, "mon_period");
6780 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6781 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6782 port_num, RTE_UINT16);
6783 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6784 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6785 period_ms, RTE_UINT32);
6787 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6788 .f = cmd_set_bond_mon_period_parsed,
6790 .help_str = "set bonding mon_period <port_id> <period_ms>",
6792 (void *)&cmd_set_bond_mon_period_set,
6793 (void *)&cmd_set_bond_mon_period_bonding,
6794 (void *)&cmd_set_bond_mon_period_mon_period,
6795 (void *)&cmd_set_bond_mon_period_portnum,
6796 (void *)&cmd_set_bond_mon_period_period_ms,
6803 struct cmd_set_bonding_agg_mode_policy_result {
6804 cmdline_fixed_string_t set;
6805 cmdline_fixed_string_t bonding;
6806 cmdline_fixed_string_t agg_mode;
6808 cmdline_fixed_string_t policy;
6813 cmd_set_bonding_agg_mode(void *parsed_result,
6814 __rte_unused struct cmdline *cl,
6815 __rte_unused void *data)
6817 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6818 uint8_t policy = AGG_BANDWIDTH;
6820 if (!strcmp(res->policy, "bandwidth"))
6821 policy = AGG_BANDWIDTH;
6822 else if (!strcmp(res->policy, "stable"))
6823 policy = AGG_STABLE;
6824 else if (!strcmp(res->policy, "count"))
6827 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6831 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6832 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6834 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6835 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6836 bonding, "bonding");
6838 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6839 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6840 agg_mode, "agg_mode");
6842 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6843 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6844 port_num, RTE_UINT16);
6846 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6847 TOKEN_STRING_INITIALIZER(
6848 struct cmd_set_bonding_balance_xmit_policy_result,
6849 policy, "stable#bandwidth#count");
6851 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6852 .f = cmd_set_bonding_agg_mode,
6854 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6856 (void *)&cmd_set_bonding_agg_mode_set,
6857 (void *)&cmd_set_bonding_agg_mode_bonding,
6858 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6859 (void *)&cmd_set_bonding_agg_mode_portnum,
6860 (void *)&cmd_set_bonding_agg_mode_policy_string,
6866 #endif /* RTE_NET_BOND */
6868 /* *** SET FORWARDING MODE *** */
6869 struct cmd_set_fwd_mode_result {
6870 cmdline_fixed_string_t set;
6871 cmdline_fixed_string_t fwd;
6872 cmdline_fixed_string_t mode;
6875 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6876 __rte_unused struct cmdline *cl,
6877 __rte_unused void *data)
6879 struct cmd_set_fwd_mode_result *res = parsed_result;
6882 set_pkt_forwarding_mode(res->mode);
6885 cmdline_parse_token_string_t cmd_setfwd_set =
6886 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6887 cmdline_parse_token_string_t cmd_setfwd_fwd =
6888 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6889 cmdline_parse_token_string_t cmd_setfwd_mode =
6890 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6891 "" /* defined at init */);
6893 cmdline_parse_inst_t cmd_set_fwd_mode = {
6894 .f = cmd_set_fwd_mode_parsed,
6896 .help_str = NULL, /* defined at init */
6898 (void *)&cmd_setfwd_set,
6899 (void *)&cmd_setfwd_fwd,
6900 (void *)&cmd_setfwd_mode,
6905 static void cmd_set_fwd_mode_init(void)
6908 static char token[128];
6909 static char help[256];
6910 cmdline_parse_token_string_t *token_struct;
6912 modes = list_pkt_forwarding_modes();
6913 snprintf(help, sizeof(help), "set fwd %s: "
6914 "Set packet forwarding mode", modes);
6915 cmd_set_fwd_mode.help_str = help;
6917 /* string token separator is # */
6918 for (c = token; *modes != '\0'; modes++)
6923 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6924 token_struct->string_data.str = token;
6927 /* *** SET RETRY FORWARDING MODE *** */
6928 struct cmd_set_fwd_retry_mode_result {
6929 cmdline_fixed_string_t set;
6930 cmdline_fixed_string_t fwd;
6931 cmdline_fixed_string_t mode;
6932 cmdline_fixed_string_t retry;
6935 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6936 __rte_unused struct cmdline *cl,
6937 __rte_unused void *data)
6939 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6942 set_pkt_forwarding_mode(res->mode);
6945 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6946 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6948 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6949 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6951 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6952 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6954 "" /* defined at init */);
6955 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6956 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6959 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6960 .f = cmd_set_fwd_retry_mode_parsed,
6962 .help_str = NULL, /* defined at init */
6964 (void *)&cmd_setfwd_retry_set,
6965 (void *)&cmd_setfwd_retry_fwd,
6966 (void *)&cmd_setfwd_retry_mode,
6967 (void *)&cmd_setfwd_retry_retry,
6972 static void cmd_set_fwd_retry_mode_init(void)
6975 static char token[128];
6976 static char help[256];
6977 cmdline_parse_token_string_t *token_struct;
6979 modes = list_pkt_forwarding_retry_modes();
6980 snprintf(help, sizeof(help), "set fwd %s retry: "
6981 "Set packet forwarding mode with retry", modes);
6982 cmd_set_fwd_retry_mode.help_str = help;
6984 /* string token separator is # */
6985 for (c = token; *modes != '\0'; modes++)
6990 token_struct = (cmdline_parse_token_string_t *)
6991 cmd_set_fwd_retry_mode.tokens[2];
6992 token_struct->string_data.str = token;
6995 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6996 struct cmd_set_burst_tx_retry_result {
6997 cmdline_fixed_string_t set;
6998 cmdline_fixed_string_t burst;
6999 cmdline_fixed_string_t tx;
7000 cmdline_fixed_string_t delay;
7002 cmdline_fixed_string_t retry;
7006 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
7007 __rte_unused struct cmdline *cl,
7008 __rte_unused void *data)
7010 struct cmd_set_burst_tx_retry_result *res = parsed_result;
7012 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
7013 && !strcmp(res->tx, "tx")) {
7014 if (!strcmp(res->delay, "delay"))
7015 burst_tx_delay_time = res->time;
7016 if (!strcmp(res->retry, "retry"))
7017 burst_tx_retry_num = res->retry_num;
7022 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
7023 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
7024 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
7025 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
7027 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
7028 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
7029 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
7030 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
7031 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
7032 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
7034 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
7035 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
7036 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
7037 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
7040 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
7041 .f = cmd_set_burst_tx_retry_parsed,
7042 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
7044 (void *)&cmd_set_burst_tx_retry_set,
7045 (void *)&cmd_set_burst_tx_retry_burst,
7046 (void *)&cmd_set_burst_tx_retry_tx,
7047 (void *)&cmd_set_burst_tx_retry_delay,
7048 (void *)&cmd_set_burst_tx_retry_time,
7049 (void *)&cmd_set_burst_tx_retry_retry,
7050 (void *)&cmd_set_burst_tx_retry_retry_num,
7055 /* *** SET PROMISC MODE *** */
7056 struct cmd_set_promisc_mode_result {
7057 cmdline_fixed_string_t set;
7058 cmdline_fixed_string_t promisc;
7059 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
7060 uint16_t port_num; /* valid if "allports" argument == 0 */
7061 cmdline_fixed_string_t mode;
7064 static void cmd_set_promisc_mode_parsed(void *parsed_result,
7065 __rte_unused struct cmdline *cl,
7068 struct cmd_set_promisc_mode_result *res = parsed_result;
7072 if (!strcmp(res->mode, "on"))
7079 RTE_ETH_FOREACH_DEV(i)
7080 eth_set_promisc_mode(i, enable);
7082 eth_set_promisc_mode(res->port_num, enable);
7086 cmdline_parse_token_string_t cmd_setpromisc_set =
7087 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
7088 cmdline_parse_token_string_t cmd_setpromisc_promisc =
7089 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
7091 cmdline_parse_token_string_t cmd_setpromisc_portall =
7092 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
7094 cmdline_parse_token_num_t cmd_setpromisc_portnum =
7095 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
7097 cmdline_parse_token_string_t cmd_setpromisc_mode =
7098 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
7101 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
7102 .f = cmd_set_promisc_mode_parsed,
7104 .help_str = "set promisc all on|off: Set promisc mode for all ports",
7106 (void *)&cmd_setpromisc_set,
7107 (void *)&cmd_setpromisc_promisc,
7108 (void *)&cmd_setpromisc_portall,
7109 (void *)&cmd_setpromisc_mode,
7114 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
7115 .f = cmd_set_promisc_mode_parsed,
7117 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
7119 (void *)&cmd_setpromisc_set,
7120 (void *)&cmd_setpromisc_promisc,
7121 (void *)&cmd_setpromisc_portnum,
7122 (void *)&cmd_setpromisc_mode,
7127 /* *** SET ALLMULTI MODE *** */
7128 struct cmd_set_allmulti_mode_result {
7129 cmdline_fixed_string_t set;
7130 cmdline_fixed_string_t allmulti;
7131 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
7132 uint16_t port_num; /* valid if "allports" argument == 0 */
7133 cmdline_fixed_string_t mode;
7136 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
7137 __rte_unused struct cmdline *cl,
7140 struct cmd_set_allmulti_mode_result *res = parsed_result;
7144 if (!strcmp(res->mode, "on"))
7151 RTE_ETH_FOREACH_DEV(i) {
7152 eth_set_allmulticast_mode(i, enable);
7156 eth_set_allmulticast_mode(res->port_num, enable);
7160 cmdline_parse_token_string_t cmd_setallmulti_set =
7161 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
7162 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
7163 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
7165 cmdline_parse_token_string_t cmd_setallmulti_portall =
7166 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
7168 cmdline_parse_token_num_t cmd_setallmulti_portnum =
7169 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
7171 cmdline_parse_token_string_t cmd_setallmulti_mode =
7172 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
7175 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
7176 .f = cmd_set_allmulti_mode_parsed,
7178 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
7180 (void *)&cmd_setallmulti_set,
7181 (void *)&cmd_setallmulti_allmulti,
7182 (void *)&cmd_setallmulti_portall,
7183 (void *)&cmd_setallmulti_mode,
7188 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
7189 .f = cmd_set_allmulti_mode_parsed,
7191 .help_str = "set allmulti <port_id> on|off: "
7192 "Set allmulti mode on port_id",
7194 (void *)&cmd_setallmulti_set,
7195 (void *)&cmd_setallmulti_allmulti,
7196 (void *)&cmd_setallmulti_portnum,
7197 (void *)&cmd_setallmulti_mode,
7202 /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
7203 struct cmd_link_flow_ctrl_show {
7204 cmdline_fixed_string_t show;
7205 cmdline_fixed_string_t port;
7207 cmdline_fixed_string_t flow_ctrl;
7210 cmdline_parse_token_string_t cmd_lfc_show_show =
7211 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7213 cmdline_parse_token_string_t cmd_lfc_show_port =
7214 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7216 cmdline_parse_token_num_t cmd_lfc_show_portid =
7217 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
7218 port_id, RTE_UINT16);
7219 cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
7220 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7221 flow_ctrl, "flow_ctrl");
7224 cmd_link_flow_ctrl_show_parsed(void *parsed_result,
7225 __rte_unused struct cmdline *cl,
7226 __rte_unused void *data)
7228 struct cmd_link_flow_ctrl_show *res = parsed_result;
7229 static const char *info_border = "*********************";
7230 struct rte_eth_fc_conf fc_conf;
7231 bool rx_fc_en = false;
7232 bool tx_fc_en = false;
7235 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7238 "Failed to get current flow ctrl information: err = %d\n",
7243 if (fc_conf.mode == RTE_ETH_FC_RX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
7245 if (fc_conf.mode == RTE_ETH_FC_TX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
7248 printf("\n%s Flow control infos for port %-2d %s\n",
7249 info_border, res->port_id, info_border);
7250 printf("FC mode:\n");
7251 printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
7252 printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
7253 printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
7254 printf("Pause time: 0x%x\n", fc_conf.pause_time);
7255 printf("High waterline: 0x%x\n", fc_conf.high_water);
7256 printf("Low waterline: 0x%x\n", fc_conf.low_water);
7257 printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
7258 printf("Forward MAC control frames: %s\n",
7259 fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
7260 printf("\n%s************** End ***********%s\n",
7261 info_border, info_border);
7264 cmdline_parse_inst_t cmd_link_flow_control_show = {
7265 .f = cmd_link_flow_ctrl_show_parsed,
7267 .help_str = "show port <port_id> flow_ctrl",
7269 (void *)&cmd_lfc_show_show,
7270 (void *)&cmd_lfc_show_port,
7271 (void *)&cmd_lfc_show_portid,
7272 (void *)&cmd_lfc_show_flow_ctrl,
7277 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
7278 struct cmd_link_flow_ctrl_set_result {
7279 cmdline_fixed_string_t set;
7280 cmdline_fixed_string_t flow_ctrl;
7281 cmdline_fixed_string_t rx;
7282 cmdline_fixed_string_t rx_lfc_mode;
7283 cmdline_fixed_string_t tx;
7284 cmdline_fixed_string_t tx_lfc_mode;
7285 cmdline_fixed_string_t mac_ctrl_frame_fwd;
7286 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
7287 cmdline_fixed_string_t autoneg_str;
7288 cmdline_fixed_string_t autoneg;
7289 cmdline_fixed_string_t hw_str;
7290 uint32_t high_water;
7291 cmdline_fixed_string_t lw_str;
7293 cmdline_fixed_string_t pt_str;
7294 uint16_t pause_time;
7295 cmdline_fixed_string_t xon_str;
7300 cmdline_parse_token_string_t cmd_lfc_set_set =
7301 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7303 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
7304 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7305 flow_ctrl, "flow_ctrl");
7306 cmdline_parse_token_string_t cmd_lfc_set_rx =
7307 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7309 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
7310 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7311 rx_lfc_mode, "on#off");
7312 cmdline_parse_token_string_t cmd_lfc_set_tx =
7313 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7315 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7316 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7317 tx_lfc_mode, "on#off");
7318 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7319 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7320 hw_str, "high_water");
7321 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7322 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7323 high_water, RTE_UINT32);
7324 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7325 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7326 lw_str, "low_water");
7327 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7328 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7329 low_water, RTE_UINT32);
7330 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7331 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7332 pt_str, "pause_time");
7333 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7334 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7335 pause_time, RTE_UINT16);
7336 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7337 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7338 xon_str, "send_xon");
7339 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7340 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7341 send_xon, RTE_UINT16);
7342 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7343 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7344 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7345 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7346 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7347 mac_ctrl_frame_fwd_mode, "on#off");
7348 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7349 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7350 autoneg_str, "autoneg");
7351 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7352 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7354 cmdline_parse_token_num_t cmd_lfc_set_portid =
7355 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7356 port_id, RTE_UINT16);
7358 /* forward declaration */
7360 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7363 cmdline_parse_inst_t cmd_link_flow_control_set = {
7364 .f = cmd_link_flow_ctrl_set_parsed,
7366 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7367 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7368 "autoneg on|off <port_id>: Configure the Ethernet flow control",
7370 (void *)&cmd_lfc_set_set,
7371 (void *)&cmd_lfc_set_flow_ctrl,
7372 (void *)&cmd_lfc_set_rx,
7373 (void *)&cmd_lfc_set_rx_mode,
7374 (void *)&cmd_lfc_set_tx,
7375 (void *)&cmd_lfc_set_tx_mode,
7376 (void *)&cmd_lfc_set_high_water,
7377 (void *)&cmd_lfc_set_low_water,
7378 (void *)&cmd_lfc_set_pause_time,
7379 (void *)&cmd_lfc_set_send_xon,
7380 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7381 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7382 (void *)&cmd_lfc_set_autoneg_str,
7383 (void *)&cmd_lfc_set_autoneg,
7384 (void *)&cmd_lfc_set_portid,
7389 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7390 .f = cmd_link_flow_ctrl_set_parsed,
7391 .data = (void *)&cmd_link_flow_control_set_rx,
7392 .help_str = "set flow_ctrl rx on|off <port_id>: "
7393 "Change rx flow control parameter",
7395 (void *)&cmd_lfc_set_set,
7396 (void *)&cmd_lfc_set_flow_ctrl,
7397 (void *)&cmd_lfc_set_rx,
7398 (void *)&cmd_lfc_set_rx_mode,
7399 (void *)&cmd_lfc_set_portid,
7404 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7405 .f = cmd_link_flow_ctrl_set_parsed,
7406 .data = (void *)&cmd_link_flow_control_set_tx,
7407 .help_str = "set flow_ctrl tx on|off <port_id>: "
7408 "Change tx flow control parameter",
7410 (void *)&cmd_lfc_set_set,
7411 (void *)&cmd_lfc_set_flow_ctrl,
7412 (void *)&cmd_lfc_set_tx,
7413 (void *)&cmd_lfc_set_tx_mode,
7414 (void *)&cmd_lfc_set_portid,
7419 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7420 .f = cmd_link_flow_ctrl_set_parsed,
7421 .data = (void *)&cmd_link_flow_control_set_hw,
7422 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7423 "Change high water flow control parameter",
7425 (void *)&cmd_lfc_set_set,
7426 (void *)&cmd_lfc_set_flow_ctrl,
7427 (void *)&cmd_lfc_set_high_water_str,
7428 (void *)&cmd_lfc_set_high_water,
7429 (void *)&cmd_lfc_set_portid,
7434 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7435 .f = cmd_link_flow_ctrl_set_parsed,
7436 .data = (void *)&cmd_link_flow_control_set_lw,
7437 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7438 "Change low water flow control parameter",
7440 (void *)&cmd_lfc_set_set,
7441 (void *)&cmd_lfc_set_flow_ctrl,
7442 (void *)&cmd_lfc_set_low_water_str,
7443 (void *)&cmd_lfc_set_low_water,
7444 (void *)&cmd_lfc_set_portid,
7449 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7450 .f = cmd_link_flow_ctrl_set_parsed,
7451 .data = (void *)&cmd_link_flow_control_set_pt,
7452 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7453 "Change pause time flow control parameter",
7455 (void *)&cmd_lfc_set_set,
7456 (void *)&cmd_lfc_set_flow_ctrl,
7457 (void *)&cmd_lfc_set_pause_time_str,
7458 (void *)&cmd_lfc_set_pause_time,
7459 (void *)&cmd_lfc_set_portid,
7464 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7465 .f = cmd_link_flow_ctrl_set_parsed,
7466 .data = (void *)&cmd_link_flow_control_set_xon,
7467 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7468 "Change send_xon flow control parameter",
7470 (void *)&cmd_lfc_set_set,
7471 (void *)&cmd_lfc_set_flow_ctrl,
7472 (void *)&cmd_lfc_set_send_xon_str,
7473 (void *)&cmd_lfc_set_send_xon,
7474 (void *)&cmd_lfc_set_portid,
7479 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7480 .f = cmd_link_flow_ctrl_set_parsed,
7481 .data = (void *)&cmd_link_flow_control_set_macfwd,
7482 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7483 "Change mac ctrl fwd flow control parameter",
7485 (void *)&cmd_lfc_set_set,
7486 (void *)&cmd_lfc_set_flow_ctrl,
7487 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7488 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7489 (void *)&cmd_lfc_set_portid,
7494 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7495 .f = cmd_link_flow_ctrl_set_parsed,
7496 .data = (void *)&cmd_link_flow_control_set_autoneg,
7497 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7498 "Change autoneg flow control parameter",
7500 (void *)&cmd_lfc_set_set,
7501 (void *)&cmd_lfc_set_flow_ctrl,
7502 (void *)&cmd_lfc_set_autoneg_str,
7503 (void *)&cmd_lfc_set_autoneg,
7504 (void *)&cmd_lfc_set_portid,
7510 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7511 __rte_unused struct cmdline *cl,
7514 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7515 cmdline_parse_inst_t *cmd = data;
7516 struct rte_eth_fc_conf fc_conf;
7522 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7523 * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7524 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7525 * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7527 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7528 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7531 /* Partial command line, retrieve current configuration */
7533 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7536 "cannot get current flow ctrl parameters, return code = %d\n",
7541 if ((fc_conf.mode == RTE_ETH_FC_RX_PAUSE) ||
7542 (fc_conf.mode == RTE_ETH_FC_FULL))
7544 if ((fc_conf.mode == RTE_ETH_FC_TX_PAUSE) ||
7545 (fc_conf.mode == RTE_ETH_FC_FULL))
7549 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7550 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7552 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7553 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7555 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7557 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7558 fc_conf.high_water = res->high_water;
7560 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7561 fc_conf.low_water = res->low_water;
7563 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7564 fc_conf.pause_time = res->pause_time;
7566 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7567 fc_conf.send_xon = res->send_xon;
7569 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7570 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7571 fc_conf.mac_ctrl_frame_fwd = 1;
7573 fc_conf.mac_ctrl_frame_fwd = 0;
7576 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7577 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7579 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7582 "bad flow control parameter, return code = %d\n",
7586 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7587 struct cmd_priority_flow_ctrl_set_result {
7588 cmdline_fixed_string_t set;
7589 cmdline_fixed_string_t pfc_ctrl;
7590 cmdline_fixed_string_t rx;
7591 cmdline_fixed_string_t rx_pfc_mode;
7592 cmdline_fixed_string_t tx;
7593 cmdline_fixed_string_t tx_pfc_mode;
7594 uint32_t high_water;
7596 uint16_t pause_time;
7602 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7603 __rte_unused struct cmdline *cl,
7604 __rte_unused void *data)
7606 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7607 struct rte_eth_pfc_conf pfc_conf;
7608 int rx_fc_enable, tx_fc_enable;
7612 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7613 * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7614 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7615 * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7617 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7618 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7621 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7622 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7623 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7624 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7625 pfc_conf.fc.high_water = res->high_water;
7626 pfc_conf.fc.low_water = res->low_water;
7627 pfc_conf.fc.pause_time = res->pause_time;
7628 pfc_conf.priority = res->priority;
7630 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7633 "bad priority flow control parameter, return code = %d\n",
7637 cmdline_parse_token_string_t cmd_pfc_set_set =
7638 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7640 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7641 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7642 pfc_ctrl, "pfc_ctrl");
7643 cmdline_parse_token_string_t cmd_pfc_set_rx =
7644 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7646 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7647 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7648 rx_pfc_mode, "on#off");
7649 cmdline_parse_token_string_t cmd_pfc_set_tx =
7650 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7652 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7653 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7654 tx_pfc_mode, "on#off");
7655 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7656 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7657 high_water, RTE_UINT32);
7658 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7659 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7660 low_water, RTE_UINT32);
7661 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7662 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7663 pause_time, RTE_UINT16);
7664 cmdline_parse_token_num_t cmd_pfc_set_priority =
7665 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7666 priority, RTE_UINT8);
7667 cmdline_parse_token_num_t cmd_pfc_set_portid =
7668 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7669 port_id, RTE_UINT16);
7671 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7672 .f = cmd_priority_flow_ctrl_set_parsed,
7674 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7675 "<pause_time> <priority> <port_id>: "
7676 "Configure the Ethernet priority flow control",
7678 (void *)&cmd_pfc_set_set,
7679 (void *)&cmd_pfc_set_flow_ctrl,
7680 (void *)&cmd_pfc_set_rx,
7681 (void *)&cmd_pfc_set_rx_mode,
7682 (void *)&cmd_pfc_set_tx,
7683 (void *)&cmd_pfc_set_tx_mode,
7684 (void *)&cmd_pfc_set_high_water,
7685 (void *)&cmd_pfc_set_low_water,
7686 (void *)&cmd_pfc_set_pause_time,
7687 (void *)&cmd_pfc_set_priority,
7688 (void *)&cmd_pfc_set_portid,
7693 /* *** RESET CONFIGURATION *** */
7694 struct cmd_reset_result {
7695 cmdline_fixed_string_t reset;
7696 cmdline_fixed_string_t def;
7699 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7701 __rte_unused void *data)
7703 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7704 set_def_fwd_config();
7707 cmdline_parse_token_string_t cmd_reset_set =
7708 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7709 cmdline_parse_token_string_t cmd_reset_def =
7710 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7713 cmdline_parse_inst_t cmd_reset = {
7714 .f = cmd_reset_parsed,
7716 .help_str = "set default: Reset default forwarding configuration",
7718 (void *)&cmd_reset_set,
7719 (void *)&cmd_reset_def,
7724 /* *** START FORWARDING *** */
7725 struct cmd_start_result {
7726 cmdline_fixed_string_t start;
7729 cmdline_parse_token_string_t cmd_start_start =
7730 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7732 static void cmd_start_parsed(__rte_unused void *parsed_result,
7733 __rte_unused struct cmdline *cl,
7734 __rte_unused void *data)
7736 start_packet_forwarding(0);
7739 cmdline_parse_inst_t cmd_start = {
7740 .f = cmd_start_parsed,
7742 .help_str = "start: Start packet forwarding",
7744 (void *)&cmd_start_start,
7749 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7750 struct cmd_start_tx_first_result {
7751 cmdline_fixed_string_t start;
7752 cmdline_fixed_string_t tx_first;
7756 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7757 __rte_unused struct cmdline *cl,
7758 __rte_unused void *data)
7760 start_packet_forwarding(1);
7763 cmdline_parse_token_string_t cmd_start_tx_first_start =
7764 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7766 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7767 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7768 tx_first, "tx_first");
7770 cmdline_parse_inst_t cmd_start_tx_first = {
7771 .f = cmd_start_tx_first_parsed,
7773 .help_str = "start tx_first: Start packet forwarding, "
7774 "after sending 1 burst of packets",
7776 (void *)&cmd_start_tx_first_start,
7777 (void *)&cmd_start_tx_first_tx_first,
7782 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7783 struct cmd_start_tx_first_n_result {
7784 cmdline_fixed_string_t start;
7785 cmdline_fixed_string_t tx_first;
7790 cmd_start_tx_first_n_parsed(void *parsed_result,
7791 __rte_unused struct cmdline *cl,
7792 __rte_unused void *data)
7794 struct cmd_start_tx_first_n_result *res = parsed_result;
7796 start_packet_forwarding(res->tx_num);
7799 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7800 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7802 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7803 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7804 tx_first, "tx_first");
7805 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7806 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7807 tx_num, RTE_UINT32);
7809 cmdline_parse_inst_t cmd_start_tx_first_n = {
7810 .f = cmd_start_tx_first_n_parsed,
7812 .help_str = "start tx_first <num>: "
7813 "packet forwarding, after sending <num> bursts of packets",
7815 (void *)&cmd_start_tx_first_n_start,
7816 (void *)&cmd_start_tx_first_n_tx_first,
7817 (void *)&cmd_start_tx_first_n_tx_num,
7822 /* *** SET LINK UP *** */
7823 struct cmd_set_link_up_result {
7824 cmdline_fixed_string_t set;
7825 cmdline_fixed_string_t link_up;
7826 cmdline_fixed_string_t port;
7830 cmdline_parse_token_string_t cmd_set_link_up_set =
7831 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7832 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7833 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7835 cmdline_parse_token_string_t cmd_set_link_up_port =
7836 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7837 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7838 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7841 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7842 __rte_unused struct cmdline *cl,
7843 __rte_unused void *data)
7845 struct cmd_set_link_up_result *res = parsed_result;
7846 dev_set_link_up(res->port_id);
7849 cmdline_parse_inst_t cmd_set_link_up = {
7850 .f = cmd_set_link_up_parsed,
7852 .help_str = "set link-up port <port id>",
7854 (void *)&cmd_set_link_up_set,
7855 (void *)&cmd_set_link_up_link_up,
7856 (void *)&cmd_set_link_up_port,
7857 (void *)&cmd_set_link_up_port_id,
7862 /* *** SET LINK DOWN *** */
7863 struct cmd_set_link_down_result {
7864 cmdline_fixed_string_t set;
7865 cmdline_fixed_string_t link_down;
7866 cmdline_fixed_string_t port;
7870 cmdline_parse_token_string_t cmd_set_link_down_set =
7871 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7872 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7873 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7875 cmdline_parse_token_string_t cmd_set_link_down_port =
7876 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7877 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7878 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7881 static void cmd_set_link_down_parsed(
7882 __rte_unused void *parsed_result,
7883 __rte_unused struct cmdline *cl,
7884 __rte_unused void *data)
7886 struct cmd_set_link_down_result *res = parsed_result;
7887 dev_set_link_down(res->port_id);
7890 cmdline_parse_inst_t cmd_set_link_down = {
7891 .f = cmd_set_link_down_parsed,
7893 .help_str = "set link-down port <port id>",
7895 (void *)&cmd_set_link_down_set,
7896 (void *)&cmd_set_link_down_link_down,
7897 (void *)&cmd_set_link_down_port,
7898 (void *)&cmd_set_link_down_port_id,
7903 /* *** SHOW CFG *** */
7904 struct cmd_showcfg_result {
7905 cmdline_fixed_string_t show;
7906 cmdline_fixed_string_t cfg;
7907 cmdline_fixed_string_t what;
7910 static void cmd_showcfg_parsed(void *parsed_result,
7911 __rte_unused struct cmdline *cl,
7912 __rte_unused void *data)
7914 struct cmd_showcfg_result *res = parsed_result;
7915 if (!strcmp(res->what, "rxtx"))
7916 rxtx_config_display();
7917 else if (!strcmp(res->what, "cores"))
7918 fwd_lcores_config_display();
7919 else if (!strcmp(res->what, "fwd"))
7920 pkt_fwd_config_display(&cur_fwd_config);
7921 else if (!strcmp(res->what, "rxoffs"))
7922 show_rx_pkt_offsets();
7923 else if (!strcmp(res->what, "rxpkts"))
7924 show_rx_pkt_segments();
7925 else if (!strcmp(res->what, "txpkts"))
7926 show_tx_pkt_segments();
7927 else if (!strcmp(res->what, "txtimes"))
7928 show_tx_pkt_times();
7931 cmdline_parse_token_string_t cmd_showcfg_show =
7932 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7933 cmdline_parse_token_string_t cmd_showcfg_port =
7934 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7935 cmdline_parse_token_string_t cmd_showcfg_what =
7936 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7937 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7939 cmdline_parse_inst_t cmd_showcfg = {
7940 .f = cmd_showcfg_parsed,
7942 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7944 (void *)&cmd_showcfg_show,
7945 (void *)&cmd_showcfg_port,
7946 (void *)&cmd_showcfg_what,
7951 /* *** SHOW ALL PORT INFO *** */
7952 struct cmd_showportall_result {
7953 cmdline_fixed_string_t show;
7954 cmdline_fixed_string_t port;
7955 cmdline_fixed_string_t what;
7956 cmdline_fixed_string_t all;
7959 static void cmd_showportall_parsed(void *parsed_result,
7960 __rte_unused struct cmdline *cl,
7961 __rte_unused void *data)
7965 struct cmd_showportall_result *res = parsed_result;
7966 if (!strcmp(res->show, "clear")) {
7967 if (!strcmp(res->what, "stats"))
7968 RTE_ETH_FOREACH_DEV(i)
7970 else if (!strcmp(res->what, "xstats"))
7971 RTE_ETH_FOREACH_DEV(i)
7972 nic_xstats_clear(i);
7973 } else if (!strcmp(res->what, "info"))
7974 RTE_ETH_FOREACH_DEV(i)
7975 port_infos_display(i);
7976 else if (!strcmp(res->what, "summary")) {
7977 port_summary_header_display();
7978 RTE_ETH_FOREACH_DEV(i)
7979 port_summary_display(i);
7981 else if (!strcmp(res->what, "stats"))
7982 RTE_ETH_FOREACH_DEV(i)
7983 nic_stats_display(i);
7984 else if (!strcmp(res->what, "xstats"))
7985 RTE_ETH_FOREACH_DEV(i)
7986 nic_xstats_display(i);
7987 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7988 else if (!strcmp(res->what, "fdir"))
7989 RTE_ETH_FOREACH_DEV(i)
7992 else if (!strcmp(res->what, "dcb_tc"))
7993 RTE_ETH_FOREACH_DEV(i)
7994 port_dcb_info_display(i);
7997 cmdline_parse_token_string_t cmd_showportall_show =
7998 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
8000 cmdline_parse_token_string_t cmd_showportall_port =
8001 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
8002 cmdline_parse_token_string_t cmd_showportall_what =
8003 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
8004 "info#summary#stats#xstats#fdir#dcb_tc");
8005 cmdline_parse_token_string_t cmd_showportall_all =
8006 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
8007 cmdline_parse_inst_t cmd_showportall = {
8008 .f = cmd_showportall_parsed,
8010 .help_str = "show|clear port "
8011 "info|summary|stats|xstats|fdir|dcb_tc all",
8013 (void *)&cmd_showportall_show,
8014 (void *)&cmd_showportall_port,
8015 (void *)&cmd_showportall_what,
8016 (void *)&cmd_showportall_all,
8021 /* *** SHOW PORT INFO *** */
8022 struct cmd_showport_result {
8023 cmdline_fixed_string_t show;
8024 cmdline_fixed_string_t port;
8025 cmdline_fixed_string_t what;
8029 static void cmd_showport_parsed(void *parsed_result,
8030 __rte_unused struct cmdline *cl,
8031 __rte_unused void *data)
8033 struct cmd_showport_result *res = parsed_result;
8034 if (!strcmp(res->show, "clear")) {
8035 if (!strcmp(res->what, "stats"))
8036 nic_stats_clear(res->portnum);
8037 else if (!strcmp(res->what, "xstats"))
8038 nic_xstats_clear(res->portnum);
8039 } else if (!strcmp(res->what, "info"))
8040 port_infos_display(res->portnum);
8041 else if (!strcmp(res->what, "summary")) {
8042 port_summary_header_display();
8043 port_summary_display(res->portnum);
8045 else if (!strcmp(res->what, "stats"))
8046 nic_stats_display(res->portnum);
8047 else if (!strcmp(res->what, "xstats"))
8048 nic_xstats_display(res->portnum);
8049 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
8050 else if (!strcmp(res->what, "fdir"))
8051 fdir_get_infos(res->portnum);
8053 else if (!strcmp(res->what, "dcb_tc"))
8054 port_dcb_info_display(res->portnum);
8057 cmdline_parse_token_string_t cmd_showport_show =
8058 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
8060 cmdline_parse_token_string_t cmd_showport_port =
8061 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
8062 cmdline_parse_token_string_t cmd_showport_what =
8063 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
8064 "info#summary#stats#xstats#fdir#dcb_tc");
8065 cmdline_parse_token_num_t cmd_showport_portnum =
8066 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
8068 cmdline_parse_inst_t cmd_showport = {
8069 .f = cmd_showport_parsed,
8071 .help_str = "show|clear port "
8072 "info|summary|stats|xstats|fdir|dcb_tc "
8075 (void *)&cmd_showport_show,
8076 (void *)&cmd_showport_port,
8077 (void *)&cmd_showport_what,
8078 (void *)&cmd_showport_portnum,
8083 /* *** show port representors information *** */
8084 struct cmd_representor_info_result {
8085 cmdline_fixed_string_t cmd_show;
8086 cmdline_fixed_string_t cmd_port;
8087 cmdline_fixed_string_t cmd_info;
8088 cmdline_fixed_string_t cmd_keyword;
8093 cmd_representor_info_parsed(void *parsed_result,
8094 __rte_unused struct cmdline *cl,
8095 __rte_unused void *data)
8097 struct cmd_representor_info_result *res = parsed_result;
8098 struct rte_eth_representor_info *info;
8099 struct rte_eth_representor_range *range;
8100 uint32_t range_diff;
8105 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
8106 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
8110 ret = rte_eth_representor_info_get(res->cmd_pid, NULL);
8113 "Failed to get the number of representor info ranges for port %hu: %s\n",
8114 res->cmd_pid, rte_strerror(-ret));
8119 info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0]));
8122 "Failed to allocate memory for representor info for port %hu\n",
8126 info->nb_ranges_alloc = num;
8128 ret = rte_eth_representor_info_get(res->cmd_pid, info);
8131 "Failed to get the representor info for port %hu: %s\n",
8132 res->cmd_pid, rte_strerror(-ret));
8137 printf("Port controller: %hu\n", info->controller);
8138 printf("Port PF: %hu\n", info->pf);
8140 printf("Ranges: %u\n", info->nb_ranges);
8141 for (i = 0; i < info->nb_ranges; i++) {
8142 range = &info->ranges[i];
8143 range_diff = range->id_end - range->id_base;
8145 printf("%u. ", i + 1);
8146 printf("'%s' ", range->name);
8148 printf("[%u-%u]: ", range->id_base, range->id_end);
8150 printf("[%u]: ", range->id_base);
8152 printf("Controller %d, PF %d", range->controller, range->pf);
8154 switch (range->type) {
8155 case RTE_ETH_REPRESENTOR_NONE:
8158 case RTE_ETH_REPRESENTOR_VF:
8160 printf(", VF %d..%d\n", range->vf,
8161 range->vf + range_diff);
8163 printf(", VF %d\n", range->vf);
8165 case RTE_ETH_REPRESENTOR_SF:
8166 printf(", SF %d\n", range->sf);
8168 case RTE_ETH_REPRESENTOR_PF:
8170 printf("..%d\n", range->pf + range_diff);
8175 printf(", UNKNOWN TYPE %d\n", range->type);
8183 cmdline_parse_token_string_t cmd_representor_info_show =
8184 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8186 cmdline_parse_token_string_t cmd_representor_info_port =
8187 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8189 cmdline_parse_token_string_t cmd_representor_info_info =
8190 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8192 cmdline_parse_token_num_t cmd_representor_info_pid =
8193 TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result,
8194 cmd_pid, RTE_UINT16);
8195 cmdline_parse_token_string_t cmd_representor_info_keyword =
8196 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8197 cmd_keyword, "representor");
8199 cmdline_parse_inst_t cmd_representor_info = {
8200 .f = cmd_representor_info_parsed,
8202 .help_str = "show port info <port_id> representor",
8204 (void *)&cmd_representor_info_show,
8205 (void *)&cmd_representor_info_port,
8206 (void *)&cmd_representor_info_info,
8207 (void *)&cmd_representor_info_pid,
8208 (void *)&cmd_representor_info_keyword,
8214 /* *** SHOW DEVICE INFO *** */
8215 struct cmd_showdevice_result {
8216 cmdline_fixed_string_t show;
8217 cmdline_fixed_string_t device;
8218 cmdline_fixed_string_t what;
8219 cmdline_fixed_string_t identifier;
8222 static void cmd_showdevice_parsed(void *parsed_result,
8223 __rte_unused struct cmdline *cl,
8224 __rte_unused void *data)
8226 struct cmd_showdevice_result *res = parsed_result;
8227 if (!strcmp(res->what, "info")) {
8228 if (!strcmp(res->identifier, "all"))
8229 device_infos_display(NULL);
8231 device_infos_display(res->identifier);
8235 cmdline_parse_token_string_t cmd_showdevice_show =
8236 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
8238 cmdline_parse_token_string_t cmd_showdevice_device =
8239 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
8240 cmdline_parse_token_string_t cmd_showdevice_what =
8241 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
8243 cmdline_parse_token_string_t cmd_showdevice_identifier =
8244 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
8247 cmdline_parse_inst_t cmd_showdevice = {
8248 .f = cmd_showdevice_parsed,
8250 .help_str = "show device info <identifier>|all",
8252 (void *)&cmd_showdevice_show,
8253 (void *)&cmd_showdevice_device,
8254 (void *)&cmd_showdevice_what,
8255 (void *)&cmd_showdevice_identifier,
8260 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
8261 struct cmd_showeeprom_result {
8262 cmdline_fixed_string_t show;
8263 cmdline_fixed_string_t port;
8265 cmdline_fixed_string_t type;
8268 static void cmd_showeeprom_parsed(void *parsed_result,
8269 __rte_unused struct cmdline *cl,
8270 __rte_unused void *data)
8272 struct cmd_showeeprom_result *res = parsed_result;
8274 if (!strcmp(res->type, "eeprom"))
8275 port_eeprom_display(res->portnum);
8276 else if (!strcmp(res->type, "module_eeprom"))
8277 port_module_eeprom_display(res->portnum);
8279 fprintf(stderr, "Unknown argument\n");
8282 cmdline_parse_token_string_t cmd_showeeprom_show =
8283 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
8284 cmdline_parse_token_string_t cmd_showeeprom_port =
8285 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
8286 cmdline_parse_token_num_t cmd_showeeprom_portnum =
8287 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
8289 cmdline_parse_token_string_t cmd_showeeprom_type =
8290 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
8292 cmdline_parse_inst_t cmd_showeeprom = {
8293 .f = cmd_showeeprom_parsed,
8295 .help_str = "show port <port_id> module_eeprom|eeprom",
8297 (void *)&cmd_showeeprom_show,
8298 (void *)&cmd_showeeprom_port,
8299 (void *)&cmd_showeeprom_portnum,
8300 (void *)&cmd_showeeprom_type,
8305 /* *** SHOW QUEUE INFO *** */
8306 struct cmd_showqueue_result {
8307 cmdline_fixed_string_t show;
8308 cmdline_fixed_string_t type;
8309 cmdline_fixed_string_t what;
8315 cmd_showqueue_parsed(void *parsed_result,
8316 __rte_unused struct cmdline *cl,
8317 __rte_unused void *data)
8319 struct cmd_showqueue_result *res = parsed_result;
8321 if (!strcmp(res->type, "rxq"))
8322 rx_queue_infos_display(res->portnum, res->queuenum);
8323 else if (!strcmp(res->type, "txq"))
8324 tx_queue_infos_display(res->portnum, res->queuenum);
8327 cmdline_parse_token_string_t cmd_showqueue_show =
8328 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
8329 cmdline_parse_token_string_t cmd_showqueue_type =
8330 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
8331 cmdline_parse_token_string_t cmd_showqueue_what =
8332 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
8333 cmdline_parse_token_num_t cmd_showqueue_portnum =
8334 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
8336 cmdline_parse_token_num_t cmd_showqueue_queuenum =
8337 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
8340 cmdline_parse_inst_t cmd_showqueue = {
8341 .f = cmd_showqueue_parsed,
8343 .help_str = "show rxq|txq info <port_id> <queue_id>",
8345 (void *)&cmd_showqueue_show,
8346 (void *)&cmd_showqueue_type,
8347 (void *)&cmd_showqueue_what,
8348 (void *)&cmd_showqueue_portnum,
8349 (void *)&cmd_showqueue_queuenum,
8354 /* show/clear fwd engine statistics */
8356 cmdline_fixed_string_t action;
8357 cmdline_fixed_string_t fwd;
8358 cmdline_fixed_string_t stats;
8359 cmdline_fixed_string_t all;
8362 cmdline_parse_token_string_t cmd_fwd_action =
8363 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
8364 cmdline_parse_token_string_t cmd_fwd_fwd =
8365 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
8366 cmdline_parse_token_string_t cmd_fwd_stats =
8367 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
8368 cmdline_parse_token_string_t cmd_fwd_all =
8369 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
8372 cmd_showfwdall_parsed(void *parsed_result,
8373 __rte_unused struct cmdline *cl,
8374 __rte_unused void *data)
8376 struct fwd_result *res = parsed_result;
8378 if (!strcmp(res->action, "show"))
8379 fwd_stats_display();
8384 static cmdline_parse_inst_t cmd_showfwdall = {
8385 .f = cmd_showfwdall_parsed,
8387 .help_str = "show|clear fwd stats all",
8389 (void *)&cmd_fwd_action,
8390 (void *)&cmd_fwd_fwd,
8391 (void *)&cmd_fwd_stats,
8392 (void *)&cmd_fwd_all,
8397 /* *** READ PORT REGISTER *** */
8398 struct cmd_read_reg_result {
8399 cmdline_fixed_string_t read;
8400 cmdline_fixed_string_t reg;
8406 cmd_read_reg_parsed(void *parsed_result,
8407 __rte_unused struct cmdline *cl,
8408 __rte_unused void *data)
8410 struct cmd_read_reg_result *res = parsed_result;
8411 port_reg_display(res->port_id, res->reg_off);
8414 cmdline_parse_token_string_t cmd_read_reg_read =
8415 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
8416 cmdline_parse_token_string_t cmd_read_reg_reg =
8417 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
8418 cmdline_parse_token_num_t cmd_read_reg_port_id =
8419 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
8420 cmdline_parse_token_num_t cmd_read_reg_reg_off =
8421 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
8423 cmdline_parse_inst_t cmd_read_reg = {
8424 .f = cmd_read_reg_parsed,
8426 .help_str = "read reg <port_id> <reg_off>",
8428 (void *)&cmd_read_reg_read,
8429 (void *)&cmd_read_reg_reg,
8430 (void *)&cmd_read_reg_port_id,
8431 (void *)&cmd_read_reg_reg_off,
8436 /* *** READ PORT REGISTER BIT FIELD *** */
8437 struct cmd_read_reg_bit_field_result {
8438 cmdline_fixed_string_t read;
8439 cmdline_fixed_string_t regfield;
8447 cmd_read_reg_bit_field_parsed(void *parsed_result,
8448 __rte_unused struct cmdline *cl,
8449 __rte_unused void *data)
8451 struct cmd_read_reg_bit_field_result *res = parsed_result;
8452 port_reg_bit_field_display(res->port_id, res->reg_off,
8453 res->bit1_pos, res->bit2_pos);
8456 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8457 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8459 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8460 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8461 regfield, "regfield");
8462 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8463 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8465 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8466 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8468 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8469 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8471 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8472 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8475 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8476 .f = cmd_read_reg_bit_field_parsed,
8478 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8479 "Read register bit field between bit_x and bit_y included",
8481 (void *)&cmd_read_reg_bit_field_read,
8482 (void *)&cmd_read_reg_bit_field_regfield,
8483 (void *)&cmd_read_reg_bit_field_port_id,
8484 (void *)&cmd_read_reg_bit_field_reg_off,
8485 (void *)&cmd_read_reg_bit_field_bit1_pos,
8486 (void *)&cmd_read_reg_bit_field_bit2_pos,
8491 /* *** READ PORT REGISTER BIT *** */
8492 struct cmd_read_reg_bit_result {
8493 cmdline_fixed_string_t read;
8494 cmdline_fixed_string_t regbit;
8501 cmd_read_reg_bit_parsed(void *parsed_result,
8502 __rte_unused struct cmdline *cl,
8503 __rte_unused void *data)
8505 struct cmd_read_reg_bit_result *res = parsed_result;
8506 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8509 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8510 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8511 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8512 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8514 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8515 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
8517 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8518 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
8520 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8521 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
8524 cmdline_parse_inst_t cmd_read_reg_bit = {
8525 .f = cmd_read_reg_bit_parsed,
8527 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8529 (void *)&cmd_read_reg_bit_read,
8530 (void *)&cmd_read_reg_bit_regbit,
8531 (void *)&cmd_read_reg_bit_port_id,
8532 (void *)&cmd_read_reg_bit_reg_off,
8533 (void *)&cmd_read_reg_bit_bit_pos,
8538 /* *** WRITE PORT REGISTER *** */
8539 struct cmd_write_reg_result {
8540 cmdline_fixed_string_t write;
8541 cmdline_fixed_string_t reg;
8548 cmd_write_reg_parsed(void *parsed_result,
8549 __rte_unused struct cmdline *cl,
8550 __rte_unused void *data)
8552 struct cmd_write_reg_result *res = parsed_result;
8553 port_reg_set(res->port_id, res->reg_off, res->value);
8556 cmdline_parse_token_string_t cmd_write_reg_write =
8557 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8558 cmdline_parse_token_string_t cmd_write_reg_reg =
8559 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8560 cmdline_parse_token_num_t cmd_write_reg_port_id =
8561 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8562 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8563 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8564 cmdline_parse_token_num_t cmd_write_reg_value =
8565 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8567 cmdline_parse_inst_t cmd_write_reg = {
8568 .f = cmd_write_reg_parsed,
8570 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8572 (void *)&cmd_write_reg_write,
8573 (void *)&cmd_write_reg_reg,
8574 (void *)&cmd_write_reg_port_id,
8575 (void *)&cmd_write_reg_reg_off,
8576 (void *)&cmd_write_reg_value,
8581 /* *** WRITE PORT REGISTER BIT FIELD *** */
8582 struct cmd_write_reg_bit_field_result {
8583 cmdline_fixed_string_t write;
8584 cmdline_fixed_string_t regfield;
8593 cmd_write_reg_bit_field_parsed(void *parsed_result,
8594 __rte_unused struct cmdline *cl,
8595 __rte_unused void *data)
8597 struct cmd_write_reg_bit_field_result *res = parsed_result;
8598 port_reg_bit_field_set(res->port_id, res->reg_off,
8599 res->bit1_pos, res->bit2_pos, res->value);
8602 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8603 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8605 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8606 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8607 regfield, "regfield");
8608 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8609 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8611 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8612 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8614 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8615 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8617 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8618 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8620 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8621 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8624 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8625 .f = cmd_write_reg_bit_field_parsed,
8627 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8629 "Set register bit field between bit_x and bit_y included",
8631 (void *)&cmd_write_reg_bit_field_write,
8632 (void *)&cmd_write_reg_bit_field_regfield,
8633 (void *)&cmd_write_reg_bit_field_port_id,
8634 (void *)&cmd_write_reg_bit_field_reg_off,
8635 (void *)&cmd_write_reg_bit_field_bit1_pos,
8636 (void *)&cmd_write_reg_bit_field_bit2_pos,
8637 (void *)&cmd_write_reg_bit_field_value,
8642 /* *** WRITE PORT REGISTER BIT *** */
8643 struct cmd_write_reg_bit_result {
8644 cmdline_fixed_string_t write;
8645 cmdline_fixed_string_t regbit;
8653 cmd_write_reg_bit_parsed(void *parsed_result,
8654 __rte_unused struct cmdline *cl,
8655 __rte_unused void *data)
8657 struct cmd_write_reg_bit_result *res = parsed_result;
8658 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8661 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8662 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8664 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8665 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8667 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8668 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8670 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8671 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8673 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8674 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8676 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8677 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8680 cmdline_parse_inst_t cmd_write_reg_bit = {
8681 .f = cmd_write_reg_bit_parsed,
8683 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8686 (void *)&cmd_write_reg_bit_write,
8687 (void *)&cmd_write_reg_bit_regbit,
8688 (void *)&cmd_write_reg_bit_port_id,
8689 (void *)&cmd_write_reg_bit_reg_off,
8690 (void *)&cmd_write_reg_bit_bit_pos,
8691 (void *)&cmd_write_reg_bit_value,
8696 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8697 struct cmd_read_rxd_txd_result {
8698 cmdline_fixed_string_t read;
8699 cmdline_fixed_string_t rxd_txd;
8706 cmd_read_rxd_txd_parsed(void *parsed_result,
8707 __rte_unused struct cmdline *cl,
8708 __rte_unused void *data)
8710 struct cmd_read_rxd_txd_result *res = parsed_result;
8712 if (!strcmp(res->rxd_txd, "rxd"))
8713 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8714 else if (!strcmp(res->rxd_txd, "txd"))
8715 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8718 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8719 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8720 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8721 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8723 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8724 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8726 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8727 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8729 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8730 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8733 cmdline_parse_inst_t cmd_read_rxd_txd = {
8734 .f = cmd_read_rxd_txd_parsed,
8736 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8738 (void *)&cmd_read_rxd_txd_read,
8739 (void *)&cmd_read_rxd_txd_rxd_txd,
8740 (void *)&cmd_read_rxd_txd_port_id,
8741 (void *)&cmd_read_rxd_txd_queue_id,
8742 (void *)&cmd_read_rxd_txd_desc_id,
8748 struct cmd_quit_result {
8749 cmdline_fixed_string_t quit;
8752 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8754 __rte_unused void *data)
8759 cmdline_parse_token_string_t cmd_quit_quit =
8760 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8762 cmdline_parse_inst_t cmd_quit = {
8763 .f = cmd_quit_parsed,
8765 .help_str = "quit: Exit application",
8767 (void *)&cmd_quit_quit,
8772 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8773 struct cmd_mac_addr_result {
8774 cmdline_fixed_string_t mac_addr_cmd;
8775 cmdline_fixed_string_t what;
8777 struct rte_ether_addr address;
8780 static void cmd_mac_addr_parsed(void *parsed_result,
8781 __rte_unused struct cmdline *cl,
8782 __rte_unused void *data)
8784 struct cmd_mac_addr_result *res = parsed_result;
8787 if (strcmp(res->what, "add") == 0)
8788 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8789 else if (strcmp(res->what, "set") == 0)
8790 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8793 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8795 /* check the return value and print it if is < 0 */
8797 fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
8801 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8802 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8804 cmdline_parse_token_string_t cmd_mac_addr_what =
8805 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8807 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8808 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8810 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8811 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8813 cmdline_parse_inst_t cmd_mac_addr = {
8814 .f = cmd_mac_addr_parsed,
8816 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8817 "Add/Remove/Set MAC address on port_id",
8819 (void *)&cmd_mac_addr_cmd,
8820 (void *)&cmd_mac_addr_what,
8821 (void *)&cmd_mac_addr_portnum,
8822 (void *)&cmd_mac_addr_addr,
8827 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8828 struct cmd_eth_peer_result {
8829 cmdline_fixed_string_t set;
8830 cmdline_fixed_string_t eth_peer;
8832 cmdline_fixed_string_t peer_addr;
8835 static void cmd_set_eth_peer_parsed(void *parsed_result,
8836 __rte_unused struct cmdline *cl,
8837 __rte_unused void *data)
8839 struct cmd_eth_peer_result *res = parsed_result;
8841 if (test_done == 0) {
8842 fprintf(stderr, "Please stop forwarding first\n");
8845 if (!strcmp(res->eth_peer, "eth-peer")) {
8846 set_fwd_eth_peer(res->port_id, res->peer_addr);
8850 cmdline_parse_token_string_t cmd_eth_peer_set =
8851 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8852 cmdline_parse_token_string_t cmd_eth_peer =
8853 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8854 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8855 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8857 cmdline_parse_token_string_t cmd_eth_peer_addr =
8858 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8860 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8861 .f = cmd_set_eth_peer_parsed,
8863 .help_str = "set eth-peer <port_id> <peer_mac>",
8865 (void *)&cmd_eth_peer_set,
8866 (void *)&cmd_eth_peer,
8867 (void *)&cmd_eth_peer_port_id,
8868 (void *)&cmd_eth_peer_addr,
8873 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8874 struct cmd_set_qmap_result {
8875 cmdline_fixed_string_t set;
8876 cmdline_fixed_string_t qmap;
8877 cmdline_fixed_string_t what;
8884 cmd_set_qmap_parsed(void *parsed_result,
8885 __rte_unused struct cmdline *cl,
8886 __rte_unused void *data)
8888 struct cmd_set_qmap_result *res = parsed_result;
8889 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8891 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8894 cmdline_parse_token_string_t cmd_setqmap_set =
8895 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8897 cmdline_parse_token_string_t cmd_setqmap_qmap =
8898 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8900 cmdline_parse_token_string_t cmd_setqmap_what =
8901 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8903 cmdline_parse_token_num_t cmd_setqmap_portid =
8904 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8905 port_id, RTE_UINT16);
8906 cmdline_parse_token_num_t cmd_setqmap_queueid =
8907 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8908 queue_id, RTE_UINT16);
8909 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8910 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8911 map_value, RTE_UINT8);
8913 cmdline_parse_inst_t cmd_set_qmap = {
8914 .f = cmd_set_qmap_parsed,
8916 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8917 "Set statistics mapping value on tx|rx queue_id of port_id",
8919 (void *)&cmd_setqmap_set,
8920 (void *)&cmd_setqmap_qmap,
8921 (void *)&cmd_setqmap_what,
8922 (void *)&cmd_setqmap_portid,
8923 (void *)&cmd_setqmap_queueid,
8924 (void *)&cmd_setqmap_mapvalue,
8929 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8930 struct cmd_set_xstats_hide_zero_result {
8931 cmdline_fixed_string_t keyword;
8932 cmdline_fixed_string_t name;
8933 cmdline_fixed_string_t on_off;
8937 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8938 __rte_unused struct cmdline *cl,
8939 __rte_unused void *data)
8941 struct cmd_set_xstats_hide_zero_result *res;
8942 uint16_t on_off = 0;
8944 res = parsed_result;
8945 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8946 set_xstats_hide_zero(on_off);
8949 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8950 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8952 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8953 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8954 name, "xstats-hide-zero");
8955 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8956 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8959 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8960 .f = cmd_set_xstats_hide_zero_parsed,
8962 .help_str = "set xstats-hide-zero on|off",
8964 (void *)&cmd_set_xstats_hide_zero_keyword,
8965 (void *)&cmd_set_xstats_hide_zero_name,
8966 (void *)&cmd_set_xstats_hide_zero_on_off,
8971 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8972 struct cmd_set_record_core_cycles_result {
8973 cmdline_fixed_string_t keyword;
8974 cmdline_fixed_string_t name;
8975 cmdline_fixed_string_t on_off;
8979 cmd_set_record_core_cycles_parsed(void *parsed_result,
8980 __rte_unused struct cmdline *cl,
8981 __rte_unused void *data)
8983 struct cmd_set_record_core_cycles_result *res;
8984 uint16_t on_off = 0;
8986 res = parsed_result;
8987 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8988 set_record_core_cycles(on_off);
8991 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8992 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8994 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8995 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8996 name, "record-core-cycles");
8997 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8998 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
9001 cmdline_parse_inst_t cmd_set_record_core_cycles = {
9002 .f = cmd_set_record_core_cycles_parsed,
9004 .help_str = "set record-core-cycles on|off",
9006 (void *)&cmd_set_record_core_cycles_keyword,
9007 (void *)&cmd_set_record_core_cycles_name,
9008 (void *)&cmd_set_record_core_cycles_on_off,
9013 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
9014 struct cmd_set_record_burst_stats_result {
9015 cmdline_fixed_string_t keyword;
9016 cmdline_fixed_string_t name;
9017 cmdline_fixed_string_t on_off;
9021 cmd_set_record_burst_stats_parsed(void *parsed_result,
9022 __rte_unused struct cmdline *cl,
9023 __rte_unused void *data)
9025 struct cmd_set_record_burst_stats_result *res;
9026 uint16_t on_off = 0;
9028 res = parsed_result;
9029 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9030 set_record_burst_stats(on_off);
9033 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
9034 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9036 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
9037 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9038 name, "record-burst-stats");
9039 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
9040 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9043 cmdline_parse_inst_t cmd_set_record_burst_stats = {
9044 .f = cmd_set_record_burst_stats_parsed,
9046 .help_str = "set record-burst-stats on|off",
9048 (void *)&cmd_set_record_burst_stats_keyword,
9049 (void *)&cmd_set_record_burst_stats_name,
9050 (void *)&cmd_set_record_burst_stats_on_off,
9055 /* *** CONFIGURE UNICAST HASH TABLE *** */
9056 struct cmd_set_uc_hash_table {
9057 cmdline_fixed_string_t set;
9058 cmdline_fixed_string_t port;
9060 cmdline_fixed_string_t what;
9061 struct rte_ether_addr address;
9062 cmdline_fixed_string_t mode;
9066 cmd_set_uc_hash_parsed(void *parsed_result,
9067 __rte_unused struct cmdline *cl,
9068 __rte_unused void *data)
9071 struct cmd_set_uc_hash_table *res = parsed_result;
9073 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9075 if (strcmp(res->what, "uta") == 0)
9076 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
9077 &res->address,(uint8_t)is_on);
9080 "bad unicast hash table parameter, return code = %d\n",
9085 cmdline_parse_token_string_t cmd_set_uc_hash_set =
9086 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9088 cmdline_parse_token_string_t cmd_set_uc_hash_port =
9089 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9091 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
9092 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
9093 port_id, RTE_UINT16);
9094 cmdline_parse_token_string_t cmd_set_uc_hash_what =
9095 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9097 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
9098 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
9100 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
9101 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9104 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
9105 .f = cmd_set_uc_hash_parsed,
9107 .help_str = "set port <port_id> uta <mac_addr> on|off)",
9109 (void *)&cmd_set_uc_hash_set,
9110 (void *)&cmd_set_uc_hash_port,
9111 (void *)&cmd_set_uc_hash_portid,
9112 (void *)&cmd_set_uc_hash_what,
9113 (void *)&cmd_set_uc_hash_mac,
9114 (void *)&cmd_set_uc_hash_mode,
9119 struct cmd_set_uc_all_hash_table {
9120 cmdline_fixed_string_t set;
9121 cmdline_fixed_string_t port;
9123 cmdline_fixed_string_t what;
9124 cmdline_fixed_string_t value;
9125 cmdline_fixed_string_t mode;
9129 cmd_set_uc_all_hash_parsed(void *parsed_result,
9130 __rte_unused struct cmdline *cl,
9131 __rte_unused void *data)
9134 struct cmd_set_uc_all_hash_table *res = parsed_result;
9136 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9138 if ((strcmp(res->what, "uta") == 0) &&
9139 (strcmp(res->value, "all") == 0))
9140 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
9143 "bad unicast hash table parameter, return code = %d\n",
9147 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
9148 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9150 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
9151 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9153 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
9154 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
9155 port_id, RTE_UINT16);
9156 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
9157 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9159 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
9160 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9162 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
9163 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9166 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
9167 .f = cmd_set_uc_all_hash_parsed,
9169 .help_str = "set port <port_id> uta all on|off",
9171 (void *)&cmd_set_uc_all_hash_set,
9172 (void *)&cmd_set_uc_all_hash_port,
9173 (void *)&cmd_set_uc_all_hash_portid,
9174 (void *)&cmd_set_uc_all_hash_what,
9175 (void *)&cmd_set_uc_all_hash_value,
9176 (void *)&cmd_set_uc_all_hash_mode,
9181 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
9182 struct cmd_set_vf_traffic {
9183 cmdline_fixed_string_t set;
9184 cmdline_fixed_string_t port;
9186 cmdline_fixed_string_t vf;
9188 cmdline_fixed_string_t what;
9189 cmdline_fixed_string_t mode;
9193 cmd_set_vf_traffic_parsed(void *parsed_result,
9194 __rte_unused struct cmdline *cl,
9195 __rte_unused void *data)
9197 struct cmd_set_vf_traffic *res = parsed_result;
9198 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
9199 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9201 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
9204 cmdline_parse_token_string_t cmd_setvf_traffic_set =
9205 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9207 cmdline_parse_token_string_t cmd_setvf_traffic_port =
9208 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9210 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
9211 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9212 port_id, RTE_UINT16);
9213 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
9214 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9216 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
9217 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9219 cmdline_parse_token_string_t cmd_setvf_traffic_what =
9220 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9222 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
9223 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9226 cmdline_parse_inst_t cmd_set_vf_traffic = {
9227 .f = cmd_set_vf_traffic_parsed,
9229 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
9231 (void *)&cmd_setvf_traffic_set,
9232 (void *)&cmd_setvf_traffic_port,
9233 (void *)&cmd_setvf_traffic_portid,
9234 (void *)&cmd_setvf_traffic_vf,
9235 (void *)&cmd_setvf_traffic_vfid,
9236 (void *)&cmd_setvf_traffic_what,
9237 (void *)&cmd_setvf_traffic_mode,
9242 /* *** CONFIGURE VF RECEIVE MODE *** */
9243 struct cmd_set_vf_rxmode {
9244 cmdline_fixed_string_t set;
9245 cmdline_fixed_string_t port;
9247 cmdline_fixed_string_t vf;
9249 cmdline_fixed_string_t what;
9250 cmdline_fixed_string_t mode;
9251 cmdline_fixed_string_t on;
9255 cmd_set_vf_rxmode_parsed(void *parsed_result,
9256 __rte_unused struct cmdline *cl,
9257 __rte_unused void *data)
9260 uint16_t vf_rxmode = 0;
9261 struct cmd_set_vf_rxmode *res = parsed_result;
9263 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
9264 if (!strcmp(res->what,"rxmode")) {
9265 if (!strcmp(res->mode, "AUPE"))
9266 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_UNTAG;
9267 else if (!strcmp(res->mode, "ROPE"))
9268 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_HASH_UC;
9269 else if (!strcmp(res->mode, "BAM"))
9270 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_BROADCAST;
9271 else if (!strncmp(res->mode, "MPE",3))
9272 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_MULTICAST;
9275 RTE_SET_USED(is_on);
9277 #ifdef RTE_NET_IXGBE
9278 if (ret == -ENOTSUP)
9279 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
9280 vf_rxmode, (uint8_t)is_on);
9283 if (ret == -ENOTSUP)
9284 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
9285 vf_rxmode, (uint8_t)is_on);
9289 "bad VF receive mode parameter, return code = %d\n",
9293 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
9294 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9296 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
9297 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9299 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
9300 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9301 port_id, RTE_UINT16);
9302 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
9303 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9305 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
9306 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9308 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
9309 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9311 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
9312 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9313 mode, "AUPE#ROPE#BAM#MPE");
9314 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
9315 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9318 cmdline_parse_inst_t cmd_set_vf_rxmode = {
9319 .f = cmd_set_vf_rxmode_parsed,
9321 .help_str = "set port <port_id> vf <vf_id> rxmode "
9322 "AUPE|ROPE|BAM|MPE on|off",
9324 (void *)&cmd_set_vf_rxmode_set,
9325 (void *)&cmd_set_vf_rxmode_port,
9326 (void *)&cmd_set_vf_rxmode_portid,
9327 (void *)&cmd_set_vf_rxmode_vf,
9328 (void *)&cmd_set_vf_rxmode_vfid,
9329 (void *)&cmd_set_vf_rxmode_what,
9330 (void *)&cmd_set_vf_rxmode_mode,
9331 (void *)&cmd_set_vf_rxmode_on,
9336 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
9337 struct cmd_vf_mac_addr_result {
9338 cmdline_fixed_string_t mac_addr_cmd;
9339 cmdline_fixed_string_t what;
9340 cmdline_fixed_string_t port;
9342 cmdline_fixed_string_t vf;
9344 struct rte_ether_addr address;
9347 static void cmd_vf_mac_addr_parsed(void *parsed_result,
9348 __rte_unused struct cmdline *cl,
9349 __rte_unused void *data)
9351 struct cmd_vf_mac_addr_result *res = parsed_result;
9354 if (strcmp(res->what, "add") != 0)
9358 if (ret == -ENOTSUP)
9359 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
9363 if (ret == -ENOTSUP)
9364 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
9369 fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
9373 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
9374 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9375 mac_addr_cmd,"mac_addr");
9376 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
9377 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9379 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
9380 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9382 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
9383 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9384 port_num, RTE_UINT16);
9385 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
9386 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9388 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
9389 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9391 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
9392 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
9395 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
9396 .f = cmd_vf_mac_addr_parsed,
9398 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
9399 "Add MAC address filtering for a VF on port_id",
9401 (void *)&cmd_vf_mac_addr_cmd,
9402 (void *)&cmd_vf_mac_addr_what,
9403 (void *)&cmd_vf_mac_addr_port,
9404 (void *)&cmd_vf_mac_addr_portnum,
9405 (void *)&cmd_vf_mac_addr_vf,
9406 (void *)&cmd_vf_mac_addr_vfnum,
9407 (void *)&cmd_vf_mac_addr_addr,
9412 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
9413 struct cmd_vf_rx_vlan_filter {
9414 cmdline_fixed_string_t rx_vlan;
9415 cmdline_fixed_string_t what;
9417 cmdline_fixed_string_t port;
9419 cmdline_fixed_string_t vf;
9424 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
9425 __rte_unused struct cmdline *cl,
9426 __rte_unused void *data)
9428 struct cmd_vf_rx_vlan_filter *res = parsed_result;
9431 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9433 #ifdef RTE_NET_IXGBE
9434 if (ret == -ENOTSUP)
9435 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9436 res->vlan_id, res->vf_mask, is_add);
9439 if (ret == -ENOTSUP)
9440 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9441 res->vlan_id, res->vf_mask, is_add);
9444 if (ret == -ENOTSUP)
9445 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9446 res->vlan_id, res->vf_mask, is_add);
9453 fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
9454 res->vlan_id, res->vf_mask);
9457 fprintf(stderr, "invalid port_id %d\n", res->port_id);
9460 fprintf(stderr, "function not implemented or supported\n");
9463 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9467 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9468 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9469 rx_vlan, "rx_vlan");
9470 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9471 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9473 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9474 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9475 vlan_id, RTE_UINT16);
9476 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9477 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9479 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9480 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9481 port_id, RTE_UINT16);
9482 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9483 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9485 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9486 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9487 vf_mask, RTE_UINT64);
9489 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9490 .f = cmd_vf_rx_vlan_filter_parsed,
9492 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9493 "(vf_mask = hexadecimal VF mask)",
9495 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9496 (void *)&cmd_vf_rx_vlan_filter_what,
9497 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9498 (void *)&cmd_vf_rx_vlan_filter_port,
9499 (void *)&cmd_vf_rx_vlan_filter_portid,
9500 (void *)&cmd_vf_rx_vlan_filter_vf,
9501 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9506 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9507 struct cmd_queue_rate_limit_result {
9508 cmdline_fixed_string_t set;
9509 cmdline_fixed_string_t port;
9511 cmdline_fixed_string_t queue;
9513 cmdline_fixed_string_t rate;
9517 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9518 __rte_unused struct cmdline *cl,
9519 __rte_unused void *data)
9521 struct cmd_queue_rate_limit_result *res = parsed_result;
9524 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9525 && (strcmp(res->queue, "queue") == 0)
9526 && (strcmp(res->rate, "rate") == 0))
9527 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9530 fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
9535 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9536 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9538 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9539 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9541 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9542 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9543 port_num, RTE_UINT16);
9544 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9545 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9547 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9548 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9549 queue_num, RTE_UINT8);
9550 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9551 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9553 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9554 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9555 rate_num, RTE_UINT16);
9557 cmdline_parse_inst_t cmd_queue_rate_limit = {
9558 .f = cmd_queue_rate_limit_parsed,
9560 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9561 "Set rate limit for a queue on port_id",
9563 (void *)&cmd_queue_rate_limit_set,
9564 (void *)&cmd_queue_rate_limit_port,
9565 (void *)&cmd_queue_rate_limit_portnum,
9566 (void *)&cmd_queue_rate_limit_queue,
9567 (void *)&cmd_queue_rate_limit_queuenum,
9568 (void *)&cmd_queue_rate_limit_rate,
9569 (void *)&cmd_queue_rate_limit_ratenum,
9574 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9575 struct cmd_vf_rate_limit_result {
9576 cmdline_fixed_string_t set;
9577 cmdline_fixed_string_t port;
9579 cmdline_fixed_string_t vf;
9581 cmdline_fixed_string_t rate;
9583 cmdline_fixed_string_t q_msk;
9587 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9588 __rte_unused struct cmdline *cl,
9589 __rte_unused void *data)
9591 struct cmd_vf_rate_limit_result *res = parsed_result;
9594 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9595 && (strcmp(res->vf, "vf") == 0)
9596 && (strcmp(res->rate, "rate") == 0)
9597 && (strcmp(res->q_msk, "queue_mask") == 0))
9598 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9599 res->rate_num, res->q_msk_val);
9601 fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
9606 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9607 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9609 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9610 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9612 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9613 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9614 port_num, RTE_UINT16);
9615 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9616 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9618 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9619 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9621 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9622 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9624 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9625 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9626 rate_num, RTE_UINT16);
9627 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9628 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9629 q_msk, "queue_mask");
9630 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9631 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9632 q_msk_val, RTE_UINT64);
9634 cmdline_parse_inst_t cmd_vf_rate_limit = {
9635 .f = cmd_vf_rate_limit_parsed,
9637 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9638 "queue_mask <queue_mask_value>: "
9639 "Set rate limit for queues of VF on port_id",
9641 (void *)&cmd_vf_rate_limit_set,
9642 (void *)&cmd_vf_rate_limit_port,
9643 (void *)&cmd_vf_rate_limit_portnum,
9644 (void *)&cmd_vf_rate_limit_vf,
9645 (void *)&cmd_vf_rate_limit_vfnum,
9646 (void *)&cmd_vf_rate_limit_rate,
9647 (void *)&cmd_vf_rate_limit_ratenum,
9648 (void *)&cmd_vf_rate_limit_q_msk,
9649 (void *)&cmd_vf_rate_limit_q_msk_val,
9654 /* *** CONFIGURE TUNNEL UDP PORT *** */
9655 struct cmd_tunnel_udp_config {
9656 cmdline_fixed_string_t rx_vxlan_port;
9657 cmdline_fixed_string_t what;
9663 cmd_tunnel_udp_config_parsed(void *parsed_result,
9664 __rte_unused struct cmdline *cl,
9665 __rte_unused void *data)
9667 struct cmd_tunnel_udp_config *res = parsed_result;
9668 struct rte_eth_udp_tunnel tunnel_udp;
9671 tunnel_udp.udp_port = res->udp_port;
9672 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9674 if (!strcmp(res->what, "add"))
9675 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9678 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9682 fprintf(stderr, "udp tunneling add error: (%s)\n",
9686 cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9687 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9688 rx_vxlan_port, "rx_vxlan_port");
9689 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9690 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9692 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9693 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9694 udp_port, RTE_UINT16);
9695 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9696 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9697 port_id, RTE_UINT16);
9699 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9700 .f = cmd_tunnel_udp_config_parsed,
9702 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9703 "Add/Remove a tunneling UDP port filter",
9705 (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9706 (void *)&cmd_tunnel_udp_config_what,
9707 (void *)&cmd_tunnel_udp_config_udp_port,
9708 (void *)&cmd_tunnel_udp_config_port_id,
9713 struct cmd_config_tunnel_udp_port {
9714 cmdline_fixed_string_t port;
9715 cmdline_fixed_string_t config;
9717 cmdline_fixed_string_t udp_tunnel_port;
9718 cmdline_fixed_string_t action;
9719 cmdline_fixed_string_t tunnel_type;
9724 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9725 __rte_unused struct cmdline *cl,
9726 __rte_unused void *data)
9728 struct cmd_config_tunnel_udp_port *res = parsed_result;
9729 struct rte_eth_udp_tunnel tunnel_udp;
9732 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9735 tunnel_udp.udp_port = res->udp_port;
9737 if (!strcmp(res->tunnel_type, "vxlan")) {
9738 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9739 } else if (!strcmp(res->tunnel_type, "geneve")) {
9740 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_GENEVE;
9741 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9742 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN_GPE;
9743 } else if (!strcmp(res->tunnel_type, "ecpri")) {
9744 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_ECPRI;
9746 fprintf(stderr, "Invalid tunnel type\n");
9750 if (!strcmp(res->action, "add"))
9751 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9754 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9758 fprintf(stderr, "udp tunneling port add error: (%s)\n",
9762 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9763 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9765 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9766 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9768 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9769 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9771 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9772 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9775 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9776 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9778 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9779 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9780 "vxlan#geneve#vxlan-gpe#ecpri");
9781 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9782 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9785 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9786 .f = cmd_cfg_tunnel_udp_port_parsed,
9788 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9789 "geneve|vxlan-gpe|ecpri <udp_port>",
9791 (void *)&cmd_config_tunnel_udp_port_port,
9792 (void *)&cmd_config_tunnel_udp_port_config,
9793 (void *)&cmd_config_tunnel_udp_port_port_id,
9794 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9795 (void *)&cmd_config_tunnel_udp_port_action,
9796 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9797 (void *)&cmd_config_tunnel_udp_port_value,
9802 /* ******************************************************************************** */
9804 struct cmd_dump_result {
9805 cmdline_fixed_string_t dump;
9809 dump_struct_sizes(void)
9811 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9812 DUMP_SIZE(struct rte_mbuf);
9813 DUMP_SIZE(struct rte_mempool);
9814 DUMP_SIZE(struct rte_ring);
9819 /* Dump the socket memory statistics on console */
9821 dump_socket_mem(FILE *f)
9823 struct rte_malloc_socket_stats socket_stats;
9828 unsigned int n_alloc = 0;
9829 unsigned int n_free = 0;
9830 static size_t last_allocs;
9831 static size_t last_total;
9834 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9835 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9836 !socket_stats.heap_totalsz_bytes)
9838 total += socket_stats.heap_totalsz_bytes;
9839 alloc += socket_stats.heap_allocsz_bytes;
9840 free += socket_stats.heap_freesz_bytes;
9841 n_alloc += socket_stats.alloc_count;
9842 n_free += socket_stats.free_count;
9844 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9846 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9847 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9848 (double)socket_stats.heap_allocsz_bytes * 100 /
9849 (double)socket_stats.heap_totalsz_bytes,
9850 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9851 socket_stats.alloc_count,
9852 socket_stats.free_count);
9855 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9856 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9857 total ? ((double)alloc * 100 / (double)total) : 0,
9858 (double)free / (1024 * 1024),
9861 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9862 ((double)total - (double)last_total) / (1024 * 1024),
9863 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9864 last_allocs = alloc;
9868 static void cmd_dump_parsed(void *parsed_result,
9869 __rte_unused struct cmdline *cl,
9870 __rte_unused void *data)
9872 struct cmd_dump_result *res = parsed_result;
9874 if (!strcmp(res->dump, "dump_physmem"))
9875 rte_dump_physmem_layout(stdout);
9876 else if (!strcmp(res->dump, "dump_socket_mem"))
9877 dump_socket_mem(stdout);
9878 else if (!strcmp(res->dump, "dump_memzone"))
9879 rte_memzone_dump(stdout);
9880 else if (!strcmp(res->dump, "dump_struct_sizes"))
9881 dump_struct_sizes();
9882 else if (!strcmp(res->dump, "dump_ring"))
9883 rte_ring_list_dump(stdout);
9884 else if (!strcmp(res->dump, "dump_mempool"))
9885 rte_mempool_list_dump(stdout);
9886 else if (!strcmp(res->dump, "dump_devargs"))
9887 rte_devargs_dump(stdout);
9888 else if (!strcmp(res->dump, "dump_log_types"))
9889 rte_log_dump(stdout);
9892 cmdline_parse_token_string_t cmd_dump_dump =
9893 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9897 "dump_struct_sizes#"
9903 cmdline_parse_inst_t cmd_dump = {
9904 .f = cmd_dump_parsed, /* function to call */
9905 .data = NULL, /* 2nd arg of func */
9906 .help_str = "Dump status",
9907 .tokens = { /* token list, NULL terminated */
9908 (void *)&cmd_dump_dump,
9913 /* ******************************************************************************** */
9915 struct cmd_dump_one_result {
9916 cmdline_fixed_string_t dump;
9917 cmdline_fixed_string_t name;
9920 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9921 __rte_unused void *data)
9923 struct cmd_dump_one_result *res = parsed_result;
9925 if (!strcmp(res->dump, "dump_ring")) {
9927 r = rte_ring_lookup(res->name);
9929 cmdline_printf(cl, "Cannot find ring\n");
9932 rte_ring_dump(stdout, r);
9933 } else if (!strcmp(res->dump, "dump_mempool")) {
9934 struct rte_mempool *mp;
9935 mp = rte_mempool_lookup(res->name);
9937 cmdline_printf(cl, "Cannot find mempool\n");
9940 rte_mempool_dump(stdout, mp);
9944 cmdline_parse_token_string_t cmd_dump_one_dump =
9945 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9946 "dump_ring#dump_mempool");
9948 cmdline_parse_token_string_t cmd_dump_one_name =
9949 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9951 cmdline_parse_inst_t cmd_dump_one = {
9952 .f = cmd_dump_one_parsed, /* function to call */
9953 .data = NULL, /* 2nd arg of func */
9954 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9955 .tokens = { /* token list, NULL terminated */
9956 (void *)&cmd_dump_one_dump,
9957 (void *)&cmd_dump_one_name,
9962 /* *** queue region set *** */
9963 struct cmd_queue_region_result {
9964 cmdline_fixed_string_t set;
9965 cmdline_fixed_string_t port;
9967 cmdline_fixed_string_t cmd;
9968 cmdline_fixed_string_t region;
9970 cmdline_fixed_string_t queue_start_index;
9972 cmdline_fixed_string_t queue_num;
9973 uint8_t queue_num_value;
9977 cmd_queue_region_parsed(void *parsed_result,
9978 __rte_unused struct cmdline *cl,
9979 __rte_unused void *data)
9981 struct cmd_queue_region_result *res = parsed_result;
9984 struct rte_pmd_i40e_queue_region_conf region_conf;
9985 enum rte_pmd_i40e_queue_region_op op_type;
9988 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9992 memset(®ion_conf, 0, sizeof(region_conf));
9993 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9994 region_conf.region_id = res->region_id;
9995 region_conf.queue_num = res->queue_num_value;
9996 region_conf.queue_start_index = res->queue_id;
9998 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9999 op_type, ®ion_conf);
10006 fprintf(stderr, "function not implemented or supported\n");
10009 fprintf(stderr, "queue region config error: (%s)\n",
10014 cmdline_parse_token_string_t cmd_queue_region_set =
10015 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10017 cmdline_parse_token_string_t cmd_queue_region_port =
10018 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
10019 cmdline_parse_token_num_t cmd_queue_region_port_id =
10020 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10021 port_id, RTE_UINT16);
10022 cmdline_parse_token_string_t cmd_queue_region_cmd =
10023 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10024 cmd, "queue-region");
10025 cmdline_parse_token_string_t cmd_queue_region_id =
10026 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10027 region, "region_id");
10028 cmdline_parse_token_num_t cmd_queue_region_index =
10029 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10030 region_id, RTE_UINT8);
10031 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
10032 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10033 queue_start_index, "queue_start_index");
10034 cmdline_parse_token_num_t cmd_queue_region_queue_id =
10035 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10036 queue_id, RTE_UINT8);
10037 cmdline_parse_token_string_t cmd_queue_region_queue_num =
10038 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10039 queue_num, "queue_num");
10040 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
10041 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10042 queue_num_value, RTE_UINT8);
10044 cmdline_parse_inst_t cmd_queue_region = {
10045 .f = cmd_queue_region_parsed,
10047 .help_str = "set port <port_id> queue-region region_id <value> "
10048 "queue_start_index <value> queue_num <value>: Set a queue region",
10050 (void *)&cmd_queue_region_set,
10051 (void *)&cmd_queue_region_port,
10052 (void *)&cmd_queue_region_port_id,
10053 (void *)&cmd_queue_region_cmd,
10054 (void *)&cmd_queue_region_id,
10055 (void *)&cmd_queue_region_index,
10056 (void *)&cmd_queue_region_queue_start_index,
10057 (void *)&cmd_queue_region_queue_id,
10058 (void *)&cmd_queue_region_queue_num,
10059 (void *)&cmd_queue_region_queue_num_value,
10064 /* *** queue region and flowtype set *** */
10065 struct cmd_region_flowtype_result {
10066 cmdline_fixed_string_t set;
10067 cmdline_fixed_string_t port;
10069 cmdline_fixed_string_t cmd;
10070 cmdline_fixed_string_t region;
10072 cmdline_fixed_string_t flowtype;
10073 uint8_t flowtype_id;
10077 cmd_region_flowtype_parsed(void *parsed_result,
10078 __rte_unused struct cmdline *cl,
10079 __rte_unused void *data)
10081 struct cmd_region_flowtype_result *res = parsed_result;
10082 int ret = -ENOTSUP;
10083 #ifdef RTE_NET_I40E
10084 struct rte_pmd_i40e_queue_region_conf region_conf;
10085 enum rte_pmd_i40e_queue_region_op op_type;
10088 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10091 #ifdef RTE_NET_I40E
10092 memset(®ion_conf, 0, sizeof(region_conf));
10094 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10095 region_conf.region_id = res->region_id;
10096 region_conf.hw_flowtype = res->flowtype_id;
10098 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10099 op_type, ®ion_conf);
10106 fprintf(stderr, "function not implemented or supported\n");
10109 fprintf(stderr, "region flowtype config error: (%s)\n",
10114 cmdline_parse_token_string_t cmd_region_flowtype_set =
10115 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10117 cmdline_parse_token_string_t cmd_region_flowtype_port =
10118 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10120 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10121 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10122 port_id, RTE_UINT16);
10123 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10124 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10125 cmd, "queue-region");
10126 cmdline_parse_token_string_t cmd_region_flowtype_index =
10127 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10128 region, "region_id");
10129 cmdline_parse_token_num_t cmd_region_flowtype_id =
10130 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10131 region_id, RTE_UINT8);
10132 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10133 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10134 flowtype, "flowtype");
10135 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10136 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10137 flowtype_id, RTE_UINT8);
10138 cmdline_parse_inst_t cmd_region_flowtype = {
10139 .f = cmd_region_flowtype_parsed,
10141 .help_str = "set port <port_id> queue-region region_id <value> "
10142 "flowtype <value>: Set a flowtype region index",
10144 (void *)&cmd_region_flowtype_set,
10145 (void *)&cmd_region_flowtype_port,
10146 (void *)&cmd_region_flowtype_port_index,
10147 (void *)&cmd_region_flowtype_cmd,
10148 (void *)&cmd_region_flowtype_index,
10149 (void *)&cmd_region_flowtype_id,
10150 (void *)&cmd_region_flowtype_flow_index,
10151 (void *)&cmd_region_flowtype_flow_id,
10156 /* *** User Priority (UP) to queue region (region_id) set *** */
10157 struct cmd_user_priority_region_result {
10158 cmdline_fixed_string_t set;
10159 cmdline_fixed_string_t port;
10161 cmdline_fixed_string_t cmd;
10162 cmdline_fixed_string_t user_priority;
10163 uint8_t user_priority_id;
10164 cmdline_fixed_string_t region;
10169 cmd_user_priority_region_parsed(void *parsed_result,
10170 __rte_unused struct cmdline *cl,
10171 __rte_unused void *data)
10173 struct cmd_user_priority_region_result *res = parsed_result;
10174 int ret = -ENOTSUP;
10175 #ifdef RTE_NET_I40E
10176 struct rte_pmd_i40e_queue_region_conf region_conf;
10177 enum rte_pmd_i40e_queue_region_op op_type;
10180 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10183 #ifdef RTE_NET_I40E
10184 memset(®ion_conf, 0, sizeof(region_conf));
10185 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10186 region_conf.user_priority = res->user_priority_id;
10187 region_conf.region_id = res->region_id;
10189 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10190 op_type, ®ion_conf);
10197 fprintf(stderr, "function not implemented or supported\n");
10200 fprintf(stderr, "user_priority region config error: (%s)\n",
10205 cmdline_parse_token_string_t cmd_user_priority_region_set =
10206 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10208 cmdline_parse_token_string_t cmd_user_priority_region_port =
10209 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10211 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10212 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10213 port_id, RTE_UINT16);
10214 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10215 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10216 cmd, "queue-region");
10217 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10218 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10219 user_priority, "UP");
10220 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10221 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10222 user_priority_id, RTE_UINT8);
10223 cmdline_parse_token_string_t cmd_user_priority_region_region =
10224 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10225 region, "region_id");
10226 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10227 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10228 region_id, RTE_UINT8);
10230 cmdline_parse_inst_t cmd_user_priority_region = {
10231 .f = cmd_user_priority_region_parsed,
10233 .help_str = "set port <port_id> queue-region UP <value> "
10234 "region_id <value>: Set the mapping of User Priority (UP) "
10235 "to queue region (region_id) ",
10237 (void *)&cmd_user_priority_region_set,
10238 (void *)&cmd_user_priority_region_port,
10239 (void *)&cmd_user_priority_region_port_index,
10240 (void *)&cmd_user_priority_region_cmd,
10241 (void *)&cmd_user_priority_region_UP,
10242 (void *)&cmd_user_priority_region_UP_id,
10243 (void *)&cmd_user_priority_region_region,
10244 (void *)&cmd_user_priority_region_region_id,
10249 /* *** flush all queue region related configuration *** */
10250 struct cmd_flush_queue_region_result {
10251 cmdline_fixed_string_t set;
10252 cmdline_fixed_string_t port;
10254 cmdline_fixed_string_t cmd;
10255 cmdline_fixed_string_t flush;
10256 cmdline_fixed_string_t what;
10260 cmd_flush_queue_region_parsed(void *parsed_result,
10261 __rte_unused struct cmdline *cl,
10262 __rte_unused void *data)
10264 struct cmd_flush_queue_region_result *res = parsed_result;
10265 int ret = -ENOTSUP;
10266 #ifdef RTE_NET_I40E
10267 struct rte_pmd_i40e_queue_region_conf region_conf;
10268 enum rte_pmd_i40e_queue_region_op op_type;
10271 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10274 #ifdef RTE_NET_I40E
10275 memset(®ion_conf, 0, sizeof(region_conf));
10277 if (strcmp(res->what, "on") == 0)
10278 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10280 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10282 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10283 op_type, ®ion_conf);
10290 fprintf(stderr, "function not implemented or supported\n");
10293 fprintf(stderr, "queue region config flush error: (%s)\n",
10298 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10299 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10301 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10302 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10304 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10305 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10306 port_id, RTE_UINT16);
10307 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10308 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10309 cmd, "queue-region");
10310 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10311 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10313 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10314 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10317 cmdline_parse_inst_t cmd_flush_queue_region = {
10318 .f = cmd_flush_queue_region_parsed,
10320 .help_str = "set port <port_id> queue-region flush on|off"
10321 ": flush all queue region related configuration",
10323 (void *)&cmd_flush_queue_region_set,
10324 (void *)&cmd_flush_queue_region_port,
10325 (void *)&cmd_flush_queue_region_port_index,
10326 (void *)&cmd_flush_queue_region_cmd,
10327 (void *)&cmd_flush_queue_region_flush,
10328 (void *)&cmd_flush_queue_region_what,
10333 /* *** get all queue region related configuration info *** */
10334 struct cmd_show_queue_region_info {
10335 cmdline_fixed_string_t show;
10336 cmdline_fixed_string_t port;
10338 cmdline_fixed_string_t cmd;
10342 cmd_show_queue_region_info_parsed(void *parsed_result,
10343 __rte_unused struct cmdline *cl,
10344 __rte_unused void *data)
10346 struct cmd_show_queue_region_info *res = parsed_result;
10347 int ret = -ENOTSUP;
10348 #ifdef RTE_NET_I40E
10349 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10350 enum rte_pmd_i40e_queue_region_op op_type;
10353 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10356 #ifdef RTE_NET_I40E
10357 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10359 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10361 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10362 op_type, &rte_pmd_regions);
10364 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10371 fprintf(stderr, "function not implemented or supported\n");
10374 fprintf(stderr, "queue region config info show error: (%s)\n",
10379 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10380 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10382 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10383 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10385 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10386 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10387 port_id, RTE_UINT16);
10388 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10389 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10390 cmd, "queue-region");
10392 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10393 .f = cmd_show_queue_region_info_parsed,
10395 .help_str = "show port <port_id> queue-region"
10396 ": show all queue region related configuration info",
10398 (void *)&cmd_show_queue_region_info_get,
10399 (void *)&cmd_show_queue_region_info_port,
10400 (void *)&cmd_show_queue_region_info_port_index,
10401 (void *)&cmd_show_queue_region_info_cmd,
10406 /* *** Filters Control *** */
10408 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10410 if ((ip_addr).family == AF_INET) \
10411 (ip) = (ip_addr).addr.ipv4.s_addr; \
10413 fprintf(stderr, "invalid parameter.\n"); \
10418 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10420 if ((ip_addr).family == AF_INET6) \
10421 rte_memcpy(&(ip), \
10422 &((ip_addr).addr.ipv6), \
10423 sizeof(struct in6_addr)); \
10425 fprintf(stderr, "invalid parameter.\n"); \
10430 #ifdef RTE_NET_I40E
10433 str2flowtype(char *string)
10436 static const struct {
10439 } flowtype_str[] = {
10440 {"raw", RTE_ETH_FLOW_RAW},
10441 {"ipv4", RTE_ETH_FLOW_IPV4},
10442 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10443 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10444 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10445 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10446 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10447 {"ipv6", RTE_ETH_FLOW_IPV6},
10448 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10449 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10450 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10451 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10452 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10453 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10454 {"ipv6-ex", RTE_ETH_FLOW_IPV6_EX},
10455 {"ipv6-tcp-ex", RTE_ETH_FLOW_IPV6_TCP_EX},
10456 {"ipv6-udp-ex", RTE_ETH_FLOW_IPV6_UDP_EX},
10457 {"gtpu", RTE_ETH_FLOW_GTPU},
10460 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10461 if (!strcmp(flowtype_str[i].str, string))
10462 return flowtype_str[i].type;
10465 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10466 return (uint16_t)atoi(string);
10468 return RTE_ETH_FLOW_UNKNOWN;
10471 /* *** deal with flow director filter *** */
10472 struct cmd_flow_director_result {
10473 cmdline_fixed_string_t flow_director_filter;
10475 cmdline_fixed_string_t mode;
10476 cmdline_fixed_string_t mode_value;
10477 cmdline_fixed_string_t ops;
10478 cmdline_fixed_string_t flow;
10479 cmdline_fixed_string_t flow_type;
10480 cmdline_fixed_string_t drop;
10481 cmdline_fixed_string_t queue;
10483 cmdline_fixed_string_t fd_id;
10484 uint32_t fd_id_value;
10485 cmdline_fixed_string_t packet;
10490 cmd_flow_director_filter_parsed(void *parsed_result,
10491 __rte_unused struct cmdline *cl,
10492 __rte_unused void *data)
10494 struct cmd_flow_director_result *res = parsed_result;
10496 struct rte_pmd_i40e_flow_type_mapping
10497 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10498 struct rte_pmd_i40e_pkt_template_conf conf;
10499 uint16_t flow_type = str2flowtype(res->flow_type);
10500 uint16_t i, port = res->port_id;
10503 memset(&conf, 0, sizeof(conf));
10505 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10506 fprintf(stderr, "Invalid flow type specified.\n");
10509 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10513 if (mapping[flow_type].pctype == 0ULL) {
10514 fprintf(stderr, "Invalid flow type specified.\n");
10517 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10518 if (mapping[flow_type].pctype & (1ULL << i)) {
10519 conf.input.pctype = i;
10524 conf.input.packet = open_file(res->filepath,
10525 &conf.input.length);
10526 if (!conf.input.packet)
10528 if (!strcmp(res->drop, "drop"))
10529 conf.action.behavior =
10530 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10532 conf.action.behavior =
10533 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10534 conf.action.report_status =
10535 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10536 conf.action.rx_queue = res->queue_id;
10537 conf.soft_id = res->fd_id_value;
10538 add = strcmp(res->ops, "del") ? 1 : 0;
10539 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10543 fprintf(stderr, "flow director config error: (%s)\n",
10545 close_file(conf.input.packet);
10548 cmdline_parse_token_string_t cmd_flow_director_filter =
10549 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10550 flow_director_filter, "flow_director_filter");
10551 cmdline_parse_token_num_t cmd_flow_director_port_id =
10552 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10553 port_id, RTE_UINT16);
10554 cmdline_parse_token_string_t cmd_flow_director_ops =
10555 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10556 ops, "add#del#update");
10557 cmdline_parse_token_string_t cmd_flow_director_flow =
10558 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10560 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10561 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10563 cmdline_parse_token_string_t cmd_flow_director_drop =
10564 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10566 cmdline_parse_token_string_t cmd_flow_director_queue =
10567 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10569 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10570 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10571 queue_id, RTE_UINT16);
10572 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10573 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10575 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10576 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10577 fd_id_value, RTE_UINT32);
10579 cmdline_parse_token_string_t cmd_flow_director_mode =
10580 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10582 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10583 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10584 mode_value, "raw");
10585 cmdline_parse_token_string_t cmd_flow_director_packet =
10586 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10588 cmdline_parse_token_string_t cmd_flow_director_filepath =
10589 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10592 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10593 .f = cmd_flow_director_filter_parsed,
10595 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10596 "director entry on NIC",
10598 (void *)&cmd_flow_director_filter,
10599 (void *)&cmd_flow_director_port_id,
10600 (void *)&cmd_flow_director_mode,
10601 (void *)&cmd_flow_director_mode_raw,
10602 (void *)&cmd_flow_director_ops,
10603 (void *)&cmd_flow_director_flow,
10604 (void *)&cmd_flow_director_flow_type,
10605 (void *)&cmd_flow_director_drop,
10606 (void *)&cmd_flow_director_queue,
10607 (void *)&cmd_flow_director_queue_id,
10608 (void *)&cmd_flow_director_fd_id,
10609 (void *)&cmd_flow_director_fd_id_value,
10610 (void *)&cmd_flow_director_packet,
10611 (void *)&cmd_flow_director_filepath,
10616 #endif /* RTE_NET_I40E */
10618 /* *** deal with flow director mask *** */
10619 struct cmd_flow_director_mask_result {
10620 cmdline_fixed_string_t flow_director_mask;
10622 cmdline_fixed_string_t mode;
10623 cmdline_fixed_string_t mode_value;
10624 cmdline_fixed_string_t vlan;
10625 uint16_t vlan_mask;
10626 cmdline_fixed_string_t src_mask;
10627 cmdline_ipaddr_t ipv4_src;
10628 cmdline_ipaddr_t ipv6_src;
10630 cmdline_fixed_string_t dst_mask;
10631 cmdline_ipaddr_t ipv4_dst;
10632 cmdline_ipaddr_t ipv6_dst;
10634 cmdline_fixed_string_t mac;
10635 uint8_t mac_addr_byte_mask;
10636 cmdline_fixed_string_t tunnel_id;
10637 uint32_t tunnel_id_mask;
10638 cmdline_fixed_string_t tunnel_type;
10639 uint8_t tunnel_type_mask;
10643 cmd_flow_director_mask_parsed(void *parsed_result,
10644 __rte_unused struct cmdline *cl,
10645 __rte_unused void *data)
10647 struct cmd_flow_director_mask_result *res = parsed_result;
10648 struct rte_eth_fdir_masks *mask;
10649 struct rte_port *port;
10651 port = &ports[res->port_id];
10652 /** Check if the port is not started **/
10653 if (port->port_status != RTE_PORT_STOPPED) {
10654 fprintf(stderr, "Please stop port %d first\n", res->port_id);
10658 mask = &port->dev_conf.fdir_conf.mask;
10660 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10661 if (strcmp(res->mode_value, "MAC-VLAN")) {
10662 fprintf(stderr, "Please set mode to MAC-VLAN.\n");
10666 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10667 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10668 if (strcmp(res->mode_value, "Tunnel")) {
10669 fprintf(stderr, "Please set mode to Tunnel.\n");
10673 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10674 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10675 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10676 mask->tunnel_type_mask = res->tunnel_type_mask;
10678 if (strcmp(res->mode_value, "IP")) {
10679 fprintf(stderr, "Please set mode to IP.\n");
10683 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10684 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10685 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10686 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10687 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10688 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10689 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10692 cmd_reconfig_device_queue(res->port_id, 1, 1);
10695 cmdline_parse_token_string_t cmd_flow_director_mask =
10696 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10697 flow_director_mask, "flow_director_mask");
10698 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10699 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10700 port_id, RTE_UINT16);
10701 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10702 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10704 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10705 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10706 vlan_mask, RTE_UINT16);
10707 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10708 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10709 src_mask, "src_mask");
10710 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10711 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10713 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10714 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10716 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10717 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10718 port_src, RTE_UINT16);
10719 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10720 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10721 dst_mask, "dst_mask");
10722 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10723 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10725 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10726 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10728 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10729 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10730 port_dst, RTE_UINT16);
10732 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10733 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10735 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10736 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10738 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10739 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10740 mode_value, "MAC-VLAN");
10741 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10742 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10743 mode_value, "Tunnel");
10744 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10745 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10747 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10748 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10749 mac_addr_byte_mask, RTE_UINT8);
10750 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10751 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10752 tunnel_type, "tunnel-type");
10753 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10754 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10755 tunnel_type_mask, RTE_UINT8);
10756 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10757 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10758 tunnel_id, "tunnel-id");
10759 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10760 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10761 tunnel_id_mask, RTE_UINT32);
10763 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10764 .f = cmd_flow_director_mask_parsed,
10766 .help_str = "flow_director_mask ... : "
10767 "Set IP mode flow director's mask on NIC",
10769 (void *)&cmd_flow_director_mask,
10770 (void *)&cmd_flow_director_mask_port_id,
10771 (void *)&cmd_flow_director_mask_mode,
10772 (void *)&cmd_flow_director_mask_mode_ip,
10773 (void *)&cmd_flow_director_mask_vlan,
10774 (void *)&cmd_flow_director_mask_vlan_value,
10775 (void *)&cmd_flow_director_mask_src,
10776 (void *)&cmd_flow_director_mask_ipv4_src,
10777 (void *)&cmd_flow_director_mask_ipv6_src,
10778 (void *)&cmd_flow_director_mask_port_src,
10779 (void *)&cmd_flow_director_mask_dst,
10780 (void *)&cmd_flow_director_mask_ipv4_dst,
10781 (void *)&cmd_flow_director_mask_ipv6_dst,
10782 (void *)&cmd_flow_director_mask_port_dst,
10787 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10788 .f = cmd_flow_director_mask_parsed,
10790 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10791 "flow director's mask on NIC",
10793 (void *)&cmd_flow_director_mask,
10794 (void *)&cmd_flow_director_mask_port_id,
10795 (void *)&cmd_flow_director_mask_mode,
10796 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10797 (void *)&cmd_flow_director_mask_vlan,
10798 (void *)&cmd_flow_director_mask_vlan_value,
10803 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10804 .f = cmd_flow_director_mask_parsed,
10806 .help_str = "flow_director_mask ... : Set tunnel mode "
10807 "flow director's mask on NIC",
10809 (void *)&cmd_flow_director_mask,
10810 (void *)&cmd_flow_director_mask_port_id,
10811 (void *)&cmd_flow_director_mask_mode,
10812 (void *)&cmd_flow_director_mask_mode_tunnel,
10813 (void *)&cmd_flow_director_mask_vlan,
10814 (void *)&cmd_flow_director_mask_vlan_value,
10815 (void *)&cmd_flow_director_mask_mac,
10816 (void *)&cmd_flow_director_mask_mac_value,
10817 (void *)&cmd_flow_director_mask_tunnel_type,
10818 (void *)&cmd_flow_director_mask_tunnel_type_value,
10819 (void *)&cmd_flow_director_mask_tunnel_id,
10820 (void *)&cmd_flow_director_mask_tunnel_id_value,
10825 /* *** deal with flow director flexible payload configuration *** */
10826 struct cmd_flow_director_flexpayload_result {
10827 cmdline_fixed_string_t flow_director_flexpayload;
10829 cmdline_fixed_string_t payload_layer;
10830 cmdline_fixed_string_t payload_cfg;
10834 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10837 const char *p, *p0 = q_arg;
10839 unsigned long int_fld;
10840 char *str_fld[max_num];
10845 p = strchr(p0, '(');
10849 p0 = strchr(p, ')');
10854 if (size >= sizeof(s))
10857 snprintf(s, sizeof(s), "%.*s", size, p);
10858 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10859 if (ret < 0 || ret > max_num)
10861 for (i = 0; i < ret; i++) {
10863 int_fld = strtoul(str_fld[i], &end, 0);
10864 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10866 offsets[i] = (uint16_t)int_fld;
10872 cmd_flow_director_flxpld_parsed(void *parsed_result,
10873 __rte_unused struct cmdline *cl,
10874 __rte_unused void *data)
10876 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10877 struct rte_eth_flex_payload_cfg flex_cfg;
10878 struct rte_port *port;
10881 port = &ports[res->port_id];
10882 /** Check if the port is not started **/
10883 if (port->port_status != RTE_PORT_STOPPED) {
10884 fprintf(stderr, "Please stop port %d first\n", res->port_id);
10888 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10890 if (!strcmp(res->payload_layer, "raw"))
10891 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10892 else if (!strcmp(res->payload_layer, "l2"))
10893 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10894 else if (!strcmp(res->payload_layer, "l3"))
10895 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10896 else if (!strcmp(res->payload_layer, "l4"))
10897 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10899 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10900 RTE_ETH_FDIR_MAX_FLEXLEN);
10902 fprintf(stderr, "error: Cannot parse flex payload input.\n");
10906 fdir_set_flex_payload(res->port_id, &flex_cfg);
10907 cmd_reconfig_device_queue(res->port_id, 1, 1);
10910 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10911 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10912 flow_director_flexpayload,
10913 "flow_director_flex_payload");
10914 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10915 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10916 port_id, RTE_UINT16);
10917 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10918 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10919 payload_layer, "raw#l2#l3#l4");
10920 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10921 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10922 payload_cfg, NULL);
10924 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10925 .f = cmd_flow_director_flxpld_parsed,
10927 .help_str = "flow_director_flexpayload ... : "
10928 "Set flow director's flex payload on NIC",
10930 (void *)&cmd_flow_director_flexpayload,
10931 (void *)&cmd_flow_director_flexpayload_port_id,
10932 (void *)&cmd_flow_director_flexpayload_payload_layer,
10933 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10938 /* Generic flow interface command. */
10939 extern cmdline_parse_inst_t cmd_flow;
10941 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10942 struct cmd_mcast_addr_result {
10943 cmdline_fixed_string_t mcast_addr_cmd;
10944 cmdline_fixed_string_t what;
10946 struct rte_ether_addr mc_addr;
10949 static void cmd_mcast_addr_parsed(void *parsed_result,
10950 __rte_unused struct cmdline *cl,
10951 __rte_unused void *data)
10953 struct cmd_mcast_addr_result *res = parsed_result;
10955 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
10957 "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
10958 RTE_ETHER_ADDR_BYTES(&res->mc_addr));
10961 if (strcmp(res->what, "add") == 0)
10962 mcast_addr_add(res->port_num, &res->mc_addr);
10964 mcast_addr_remove(res->port_num, &res->mc_addr);
10967 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10968 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10969 mcast_addr_cmd, "mcast_addr");
10970 cmdline_parse_token_string_t cmd_mcast_addr_what =
10971 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10973 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10974 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
10976 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10977 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10979 cmdline_parse_inst_t cmd_mcast_addr = {
10980 .f = cmd_mcast_addr_parsed,
10982 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10983 "Add/Remove multicast MAC address on port_id",
10985 (void *)&cmd_mcast_addr_cmd,
10986 (void *)&cmd_mcast_addr_what,
10987 (void *)&cmd_mcast_addr_portnum,
10988 (void *)&cmd_mcast_addr_addr,
10993 /* vf vlan anti spoof configuration */
10995 /* Common result structure for vf vlan anti spoof */
10996 struct cmd_vf_vlan_anti_spoof_result {
10997 cmdline_fixed_string_t set;
10998 cmdline_fixed_string_t vf;
10999 cmdline_fixed_string_t vlan;
11000 cmdline_fixed_string_t antispoof;
11003 cmdline_fixed_string_t on_off;
11006 /* Common CLI fields for vf vlan anti spoof enable disable */
11007 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
11008 TOKEN_STRING_INITIALIZER
11009 (struct cmd_vf_vlan_anti_spoof_result,
11011 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
11012 TOKEN_STRING_INITIALIZER
11013 (struct cmd_vf_vlan_anti_spoof_result,
11015 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
11016 TOKEN_STRING_INITIALIZER
11017 (struct cmd_vf_vlan_anti_spoof_result,
11019 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
11020 TOKEN_STRING_INITIALIZER
11021 (struct cmd_vf_vlan_anti_spoof_result,
11022 antispoof, "antispoof");
11023 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
11024 TOKEN_NUM_INITIALIZER
11025 (struct cmd_vf_vlan_anti_spoof_result,
11026 port_id, RTE_UINT16);
11027 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
11028 TOKEN_NUM_INITIALIZER
11029 (struct cmd_vf_vlan_anti_spoof_result,
11030 vf_id, RTE_UINT32);
11031 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11032 TOKEN_STRING_INITIALIZER
11033 (struct cmd_vf_vlan_anti_spoof_result,
11037 cmd_set_vf_vlan_anti_spoof_parsed(
11038 void *parsed_result,
11039 __rte_unused struct cmdline *cl,
11040 __rte_unused void *data)
11042 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
11043 int ret = -ENOTSUP;
11045 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11047 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11050 #ifdef RTE_NET_IXGBE
11051 if (ret == -ENOTSUP)
11052 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11053 res->vf_id, is_on);
11055 #ifdef RTE_NET_I40E
11056 if (ret == -ENOTSUP)
11057 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11058 res->vf_id, is_on);
11060 #ifdef RTE_NET_BNXT
11061 if (ret == -ENOTSUP)
11062 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11063 res->vf_id, is_on);
11070 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11073 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11076 fprintf(stderr, "function not implemented\n");
11079 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11083 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11084 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11086 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11088 (void *)&cmd_vf_vlan_anti_spoof_set,
11089 (void *)&cmd_vf_vlan_anti_spoof_vf,
11090 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11091 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11092 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11093 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11094 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11099 /* vf mac anti spoof configuration */
11101 /* Common result structure for vf mac anti spoof */
11102 struct cmd_vf_mac_anti_spoof_result {
11103 cmdline_fixed_string_t set;
11104 cmdline_fixed_string_t vf;
11105 cmdline_fixed_string_t mac;
11106 cmdline_fixed_string_t antispoof;
11109 cmdline_fixed_string_t on_off;
11112 /* Common CLI fields for vf mac anti spoof enable disable */
11113 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11114 TOKEN_STRING_INITIALIZER
11115 (struct cmd_vf_mac_anti_spoof_result,
11117 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11118 TOKEN_STRING_INITIALIZER
11119 (struct cmd_vf_mac_anti_spoof_result,
11121 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11122 TOKEN_STRING_INITIALIZER
11123 (struct cmd_vf_mac_anti_spoof_result,
11125 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11126 TOKEN_STRING_INITIALIZER
11127 (struct cmd_vf_mac_anti_spoof_result,
11128 antispoof, "antispoof");
11129 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11130 TOKEN_NUM_INITIALIZER
11131 (struct cmd_vf_mac_anti_spoof_result,
11132 port_id, RTE_UINT16);
11133 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11134 TOKEN_NUM_INITIALIZER
11135 (struct cmd_vf_mac_anti_spoof_result,
11136 vf_id, RTE_UINT32);
11137 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11138 TOKEN_STRING_INITIALIZER
11139 (struct cmd_vf_mac_anti_spoof_result,
11143 cmd_set_vf_mac_anti_spoof_parsed(
11144 void *parsed_result,
11145 __rte_unused struct cmdline *cl,
11146 __rte_unused void *data)
11148 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11149 int ret = -ENOTSUP;
11151 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11153 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11156 #ifdef RTE_NET_IXGBE
11157 if (ret == -ENOTSUP)
11158 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11159 res->vf_id, is_on);
11161 #ifdef RTE_NET_I40E
11162 if (ret == -ENOTSUP)
11163 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11164 res->vf_id, is_on);
11166 #ifdef RTE_NET_BNXT
11167 if (ret == -ENOTSUP)
11168 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11169 res->vf_id, is_on);
11176 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11177 res->vf_id, is_on);
11180 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11183 fprintf(stderr, "function not implemented\n");
11186 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11190 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11191 .f = cmd_set_vf_mac_anti_spoof_parsed,
11193 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11195 (void *)&cmd_vf_mac_anti_spoof_set,
11196 (void *)&cmd_vf_mac_anti_spoof_vf,
11197 (void *)&cmd_vf_mac_anti_spoof_mac,
11198 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11199 (void *)&cmd_vf_mac_anti_spoof_port_id,
11200 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11201 (void *)&cmd_vf_mac_anti_spoof_on_off,
11206 /* vf vlan strip queue configuration */
11208 /* Common result structure for vf mac anti spoof */
11209 struct cmd_vf_vlan_stripq_result {
11210 cmdline_fixed_string_t set;
11211 cmdline_fixed_string_t vf;
11212 cmdline_fixed_string_t vlan;
11213 cmdline_fixed_string_t stripq;
11216 cmdline_fixed_string_t on_off;
11219 /* Common CLI fields for vf vlan strip enable disable */
11220 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11221 TOKEN_STRING_INITIALIZER
11222 (struct cmd_vf_vlan_stripq_result,
11224 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11225 TOKEN_STRING_INITIALIZER
11226 (struct cmd_vf_vlan_stripq_result,
11228 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11229 TOKEN_STRING_INITIALIZER
11230 (struct cmd_vf_vlan_stripq_result,
11232 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11233 TOKEN_STRING_INITIALIZER
11234 (struct cmd_vf_vlan_stripq_result,
11236 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11237 TOKEN_NUM_INITIALIZER
11238 (struct cmd_vf_vlan_stripq_result,
11239 port_id, RTE_UINT16);
11240 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11241 TOKEN_NUM_INITIALIZER
11242 (struct cmd_vf_vlan_stripq_result,
11243 vf_id, RTE_UINT16);
11244 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11245 TOKEN_STRING_INITIALIZER
11246 (struct cmd_vf_vlan_stripq_result,
11250 cmd_set_vf_vlan_stripq_parsed(
11251 void *parsed_result,
11252 __rte_unused struct cmdline *cl,
11253 __rte_unused void *data)
11255 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11256 int ret = -ENOTSUP;
11258 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11260 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11263 #ifdef RTE_NET_IXGBE
11264 if (ret == -ENOTSUP)
11265 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11266 res->vf_id, is_on);
11268 #ifdef RTE_NET_I40E
11269 if (ret == -ENOTSUP)
11270 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11271 res->vf_id, is_on);
11273 #ifdef RTE_NET_BNXT
11274 if (ret == -ENOTSUP)
11275 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11276 res->vf_id, is_on);
11283 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11284 res->vf_id, is_on);
11287 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11290 fprintf(stderr, "function not implemented\n");
11293 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11297 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11298 .f = cmd_set_vf_vlan_stripq_parsed,
11300 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11302 (void *)&cmd_vf_vlan_stripq_set,
11303 (void *)&cmd_vf_vlan_stripq_vf,
11304 (void *)&cmd_vf_vlan_stripq_vlan,
11305 (void *)&cmd_vf_vlan_stripq_stripq,
11306 (void *)&cmd_vf_vlan_stripq_port_id,
11307 (void *)&cmd_vf_vlan_stripq_vf_id,
11308 (void *)&cmd_vf_vlan_stripq_on_off,
11313 /* vf vlan insert configuration */
11315 /* Common result structure for vf vlan insert */
11316 struct cmd_vf_vlan_insert_result {
11317 cmdline_fixed_string_t set;
11318 cmdline_fixed_string_t vf;
11319 cmdline_fixed_string_t vlan;
11320 cmdline_fixed_string_t insert;
11326 /* Common CLI fields for vf vlan insert enable disable */
11327 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11328 TOKEN_STRING_INITIALIZER
11329 (struct cmd_vf_vlan_insert_result,
11331 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11332 TOKEN_STRING_INITIALIZER
11333 (struct cmd_vf_vlan_insert_result,
11335 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11336 TOKEN_STRING_INITIALIZER
11337 (struct cmd_vf_vlan_insert_result,
11339 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11340 TOKEN_STRING_INITIALIZER
11341 (struct cmd_vf_vlan_insert_result,
11343 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11344 TOKEN_NUM_INITIALIZER
11345 (struct cmd_vf_vlan_insert_result,
11346 port_id, RTE_UINT16);
11347 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11348 TOKEN_NUM_INITIALIZER
11349 (struct cmd_vf_vlan_insert_result,
11350 vf_id, RTE_UINT16);
11351 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11352 TOKEN_NUM_INITIALIZER
11353 (struct cmd_vf_vlan_insert_result,
11354 vlan_id, RTE_UINT16);
11357 cmd_set_vf_vlan_insert_parsed(
11358 void *parsed_result,
11359 __rte_unused struct cmdline *cl,
11360 __rte_unused void *data)
11362 struct cmd_vf_vlan_insert_result *res = parsed_result;
11363 int ret = -ENOTSUP;
11365 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11368 #ifdef RTE_NET_IXGBE
11369 if (ret == -ENOTSUP)
11370 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11373 #ifdef RTE_NET_I40E
11374 if (ret == -ENOTSUP)
11375 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11378 #ifdef RTE_NET_BNXT
11379 if (ret == -ENOTSUP)
11380 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11388 fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
11389 res->vf_id, res->vlan_id);
11392 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11395 fprintf(stderr, "function not implemented\n");
11398 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11402 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11403 .f = cmd_set_vf_vlan_insert_parsed,
11405 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11407 (void *)&cmd_vf_vlan_insert_set,
11408 (void *)&cmd_vf_vlan_insert_vf,
11409 (void *)&cmd_vf_vlan_insert_vlan,
11410 (void *)&cmd_vf_vlan_insert_insert,
11411 (void *)&cmd_vf_vlan_insert_port_id,
11412 (void *)&cmd_vf_vlan_insert_vf_id,
11413 (void *)&cmd_vf_vlan_insert_vlan_id,
11418 /* tx loopback configuration */
11420 /* Common result structure for tx loopback */
11421 struct cmd_tx_loopback_result {
11422 cmdline_fixed_string_t set;
11423 cmdline_fixed_string_t tx;
11424 cmdline_fixed_string_t loopback;
11426 cmdline_fixed_string_t on_off;
11429 /* Common CLI fields for tx loopback enable disable */
11430 cmdline_parse_token_string_t cmd_tx_loopback_set =
11431 TOKEN_STRING_INITIALIZER
11432 (struct cmd_tx_loopback_result,
11434 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11435 TOKEN_STRING_INITIALIZER
11436 (struct cmd_tx_loopback_result,
11438 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11439 TOKEN_STRING_INITIALIZER
11440 (struct cmd_tx_loopback_result,
11441 loopback, "loopback");
11442 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11443 TOKEN_NUM_INITIALIZER
11444 (struct cmd_tx_loopback_result,
11445 port_id, RTE_UINT16);
11446 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11447 TOKEN_STRING_INITIALIZER
11448 (struct cmd_tx_loopback_result,
11452 cmd_set_tx_loopback_parsed(
11453 void *parsed_result,
11454 __rte_unused struct cmdline *cl,
11455 __rte_unused void *data)
11457 struct cmd_tx_loopback_result *res = parsed_result;
11458 int ret = -ENOTSUP;
11460 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11462 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11465 #ifdef RTE_NET_IXGBE
11466 if (ret == -ENOTSUP)
11467 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11469 #ifdef RTE_NET_I40E
11470 if (ret == -ENOTSUP)
11471 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11473 #ifdef RTE_NET_BNXT
11474 if (ret == -ENOTSUP)
11475 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11477 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11478 if (ret == -ENOTSUP)
11479 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11486 fprintf(stderr, "invalid is_on %d\n", is_on);
11489 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11492 fprintf(stderr, "function not implemented\n");
11495 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11499 cmdline_parse_inst_t cmd_set_tx_loopback = {
11500 .f = cmd_set_tx_loopback_parsed,
11502 .help_str = "set tx loopback <port_id> on|off",
11504 (void *)&cmd_tx_loopback_set,
11505 (void *)&cmd_tx_loopback_tx,
11506 (void *)&cmd_tx_loopback_loopback,
11507 (void *)&cmd_tx_loopback_port_id,
11508 (void *)&cmd_tx_loopback_on_off,
11513 /* all queues drop enable configuration */
11515 /* Common result structure for all queues drop enable */
11516 struct cmd_all_queues_drop_en_result {
11517 cmdline_fixed_string_t set;
11518 cmdline_fixed_string_t all;
11519 cmdline_fixed_string_t queues;
11520 cmdline_fixed_string_t drop;
11522 cmdline_fixed_string_t on_off;
11525 /* Common CLI fields for tx loopback enable disable */
11526 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11527 TOKEN_STRING_INITIALIZER
11528 (struct cmd_all_queues_drop_en_result,
11530 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11531 TOKEN_STRING_INITIALIZER
11532 (struct cmd_all_queues_drop_en_result,
11534 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11535 TOKEN_STRING_INITIALIZER
11536 (struct cmd_all_queues_drop_en_result,
11538 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11539 TOKEN_STRING_INITIALIZER
11540 (struct cmd_all_queues_drop_en_result,
11542 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11543 TOKEN_NUM_INITIALIZER
11544 (struct cmd_all_queues_drop_en_result,
11545 port_id, RTE_UINT16);
11546 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11547 TOKEN_STRING_INITIALIZER
11548 (struct cmd_all_queues_drop_en_result,
11552 cmd_set_all_queues_drop_en_parsed(
11553 void *parsed_result,
11554 __rte_unused struct cmdline *cl,
11555 __rte_unused void *data)
11557 struct cmd_all_queues_drop_en_result *res = parsed_result;
11558 int ret = -ENOTSUP;
11559 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11561 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11564 #ifdef RTE_NET_IXGBE
11565 if (ret == -ENOTSUP)
11566 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11568 #ifdef RTE_NET_BNXT
11569 if (ret == -ENOTSUP)
11570 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11576 fprintf(stderr, "invalid is_on %d\n", is_on);
11579 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11582 fprintf(stderr, "function not implemented\n");
11585 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11589 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11590 .f = cmd_set_all_queues_drop_en_parsed,
11592 .help_str = "set all queues drop <port_id> on|off",
11594 (void *)&cmd_all_queues_drop_en_set,
11595 (void *)&cmd_all_queues_drop_en_all,
11596 (void *)&cmd_all_queues_drop_en_queues,
11597 (void *)&cmd_all_queues_drop_en_drop,
11598 (void *)&cmd_all_queues_drop_en_port_id,
11599 (void *)&cmd_all_queues_drop_en_on_off,
11604 /* vf split drop enable configuration */
11606 /* Common result structure for vf split drop enable */
11607 struct cmd_vf_split_drop_en_result {
11608 cmdline_fixed_string_t set;
11609 cmdline_fixed_string_t vf;
11610 cmdline_fixed_string_t split;
11611 cmdline_fixed_string_t drop;
11614 cmdline_fixed_string_t on_off;
11617 /* Common CLI fields for vf split drop enable disable */
11618 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11619 TOKEN_STRING_INITIALIZER
11620 (struct cmd_vf_split_drop_en_result,
11622 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11623 TOKEN_STRING_INITIALIZER
11624 (struct cmd_vf_split_drop_en_result,
11626 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11627 TOKEN_STRING_INITIALIZER
11628 (struct cmd_vf_split_drop_en_result,
11630 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11631 TOKEN_STRING_INITIALIZER
11632 (struct cmd_vf_split_drop_en_result,
11634 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11635 TOKEN_NUM_INITIALIZER
11636 (struct cmd_vf_split_drop_en_result,
11637 port_id, RTE_UINT16);
11638 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11639 TOKEN_NUM_INITIALIZER
11640 (struct cmd_vf_split_drop_en_result,
11641 vf_id, RTE_UINT16);
11642 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11643 TOKEN_STRING_INITIALIZER
11644 (struct cmd_vf_split_drop_en_result,
11648 cmd_set_vf_split_drop_en_parsed(
11649 void *parsed_result,
11650 __rte_unused struct cmdline *cl,
11651 __rte_unused void *data)
11653 struct cmd_vf_split_drop_en_result *res = parsed_result;
11654 int ret = -ENOTSUP;
11655 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11657 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11660 #ifdef RTE_NET_IXGBE
11661 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11668 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11669 res->vf_id, is_on);
11672 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11675 fprintf(stderr, "not supported on port %d\n", res->port_id);
11678 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11682 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11683 .f = cmd_set_vf_split_drop_en_parsed,
11685 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11687 (void *)&cmd_vf_split_drop_en_set,
11688 (void *)&cmd_vf_split_drop_en_vf,
11689 (void *)&cmd_vf_split_drop_en_split,
11690 (void *)&cmd_vf_split_drop_en_drop,
11691 (void *)&cmd_vf_split_drop_en_port_id,
11692 (void *)&cmd_vf_split_drop_en_vf_id,
11693 (void *)&cmd_vf_split_drop_en_on_off,
11698 /* vf mac address configuration */
11700 /* Common result structure for vf mac address */
11701 struct cmd_set_vf_mac_addr_result {
11702 cmdline_fixed_string_t set;
11703 cmdline_fixed_string_t vf;
11704 cmdline_fixed_string_t mac;
11705 cmdline_fixed_string_t addr;
11708 struct rte_ether_addr mac_addr;
11712 /* Common CLI fields for vf split drop enable disable */
11713 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11714 TOKEN_STRING_INITIALIZER
11715 (struct cmd_set_vf_mac_addr_result,
11717 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11718 TOKEN_STRING_INITIALIZER
11719 (struct cmd_set_vf_mac_addr_result,
11721 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11722 TOKEN_STRING_INITIALIZER
11723 (struct cmd_set_vf_mac_addr_result,
11725 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11726 TOKEN_STRING_INITIALIZER
11727 (struct cmd_set_vf_mac_addr_result,
11729 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11730 TOKEN_NUM_INITIALIZER
11731 (struct cmd_set_vf_mac_addr_result,
11732 port_id, RTE_UINT16);
11733 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11734 TOKEN_NUM_INITIALIZER
11735 (struct cmd_set_vf_mac_addr_result,
11736 vf_id, RTE_UINT16);
11737 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11738 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11742 cmd_set_vf_mac_addr_parsed(
11743 void *parsed_result,
11744 __rte_unused struct cmdline *cl,
11745 __rte_unused void *data)
11747 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11748 int ret = -ENOTSUP;
11750 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11753 #ifdef RTE_NET_IXGBE
11754 if (ret == -ENOTSUP)
11755 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11758 #ifdef RTE_NET_I40E
11759 if (ret == -ENOTSUP)
11760 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11763 #ifdef RTE_NET_BNXT
11764 if (ret == -ENOTSUP)
11765 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11773 fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
11776 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11779 fprintf(stderr, "function not implemented\n");
11782 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11786 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11787 .f = cmd_set_vf_mac_addr_parsed,
11789 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11791 (void *)&cmd_set_vf_mac_addr_set,
11792 (void *)&cmd_set_vf_mac_addr_vf,
11793 (void *)&cmd_set_vf_mac_addr_mac,
11794 (void *)&cmd_set_vf_mac_addr_addr,
11795 (void *)&cmd_set_vf_mac_addr_port_id,
11796 (void *)&cmd_set_vf_mac_addr_vf_id,
11797 (void *)&cmd_set_vf_mac_addr_mac_addr,
11802 /* MACsec configuration */
11804 /* Common result structure for MACsec offload enable */
11805 struct cmd_macsec_offload_on_result {
11806 cmdline_fixed_string_t set;
11807 cmdline_fixed_string_t macsec;
11808 cmdline_fixed_string_t offload;
11810 cmdline_fixed_string_t on;
11811 cmdline_fixed_string_t encrypt;
11812 cmdline_fixed_string_t en_on_off;
11813 cmdline_fixed_string_t replay_protect;
11814 cmdline_fixed_string_t rp_on_off;
11817 /* Common CLI fields for MACsec offload disable */
11818 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11819 TOKEN_STRING_INITIALIZER
11820 (struct cmd_macsec_offload_on_result,
11822 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11823 TOKEN_STRING_INITIALIZER
11824 (struct cmd_macsec_offload_on_result,
11826 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11827 TOKEN_STRING_INITIALIZER
11828 (struct cmd_macsec_offload_on_result,
11829 offload, "offload");
11830 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11831 TOKEN_NUM_INITIALIZER
11832 (struct cmd_macsec_offload_on_result,
11833 port_id, RTE_UINT16);
11834 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11835 TOKEN_STRING_INITIALIZER
11836 (struct cmd_macsec_offload_on_result,
11838 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11839 TOKEN_STRING_INITIALIZER
11840 (struct cmd_macsec_offload_on_result,
11841 encrypt, "encrypt");
11842 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11843 TOKEN_STRING_INITIALIZER
11844 (struct cmd_macsec_offload_on_result,
11845 en_on_off, "on#off");
11846 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11847 TOKEN_STRING_INITIALIZER
11848 (struct cmd_macsec_offload_on_result,
11849 replay_protect, "replay-protect");
11850 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11851 TOKEN_STRING_INITIALIZER
11852 (struct cmd_macsec_offload_on_result,
11853 rp_on_off, "on#off");
11856 cmd_set_macsec_offload_on_parsed(
11857 void *parsed_result,
11858 __rte_unused struct cmdline *cl,
11859 __rte_unused void *data)
11861 struct cmd_macsec_offload_on_result *res = parsed_result;
11862 int ret = -ENOTSUP;
11863 portid_t port_id = res->port_id;
11864 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11865 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11866 struct rte_eth_dev_info dev_info;
11868 if (port_id_is_invalid(port_id, ENABLED_WARN))
11870 if (!port_is_stopped(port_id)) {
11871 fprintf(stderr, "Please stop port %d first\n", port_id);
11875 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11879 if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) {
11880 #ifdef RTE_NET_IXGBE
11881 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11889 ports[port_id].dev_conf.txmode.offloads |=
11890 RTE_ETH_TX_OFFLOAD_MACSEC_INSERT;
11891 cmd_reconfig_device_queue(port_id, 1, 1);
11894 fprintf(stderr, "invalid port_id %d\n", port_id);
11897 fprintf(stderr, "not supported on port %d\n", port_id);
11900 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11904 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11905 .f = cmd_set_macsec_offload_on_parsed,
11907 .help_str = "set macsec offload <port_id> on "
11908 "encrypt on|off replay-protect on|off",
11910 (void *)&cmd_macsec_offload_on_set,
11911 (void *)&cmd_macsec_offload_on_macsec,
11912 (void *)&cmd_macsec_offload_on_offload,
11913 (void *)&cmd_macsec_offload_on_port_id,
11914 (void *)&cmd_macsec_offload_on_on,
11915 (void *)&cmd_macsec_offload_on_encrypt,
11916 (void *)&cmd_macsec_offload_on_en_on_off,
11917 (void *)&cmd_macsec_offload_on_replay_protect,
11918 (void *)&cmd_macsec_offload_on_rp_on_off,
11923 /* Common result structure for MACsec offload disable */
11924 struct cmd_macsec_offload_off_result {
11925 cmdline_fixed_string_t set;
11926 cmdline_fixed_string_t macsec;
11927 cmdline_fixed_string_t offload;
11929 cmdline_fixed_string_t off;
11932 /* Common CLI fields for MACsec offload disable */
11933 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11934 TOKEN_STRING_INITIALIZER
11935 (struct cmd_macsec_offload_off_result,
11937 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11938 TOKEN_STRING_INITIALIZER
11939 (struct cmd_macsec_offload_off_result,
11941 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11942 TOKEN_STRING_INITIALIZER
11943 (struct cmd_macsec_offload_off_result,
11944 offload, "offload");
11945 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11946 TOKEN_NUM_INITIALIZER
11947 (struct cmd_macsec_offload_off_result,
11948 port_id, RTE_UINT16);
11949 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11950 TOKEN_STRING_INITIALIZER
11951 (struct cmd_macsec_offload_off_result,
11955 cmd_set_macsec_offload_off_parsed(
11956 void *parsed_result,
11957 __rte_unused struct cmdline *cl,
11958 __rte_unused void *data)
11960 struct cmd_macsec_offload_off_result *res = parsed_result;
11961 int ret = -ENOTSUP;
11962 struct rte_eth_dev_info dev_info;
11963 portid_t port_id = res->port_id;
11965 if (port_id_is_invalid(port_id, ENABLED_WARN))
11967 if (!port_is_stopped(port_id)) {
11968 fprintf(stderr, "Please stop port %d first\n", port_id);
11972 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11976 if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) {
11977 #ifdef RTE_NET_IXGBE
11978 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11983 ports[port_id].dev_conf.txmode.offloads &=
11984 ~RTE_ETH_TX_OFFLOAD_MACSEC_INSERT;
11985 cmd_reconfig_device_queue(port_id, 1, 1);
11988 fprintf(stderr, "invalid port_id %d\n", port_id);
11991 fprintf(stderr, "not supported on port %d\n", port_id);
11994 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11998 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11999 .f = cmd_set_macsec_offload_off_parsed,
12001 .help_str = "set macsec offload <port_id> off",
12003 (void *)&cmd_macsec_offload_off_set,
12004 (void *)&cmd_macsec_offload_off_macsec,
12005 (void *)&cmd_macsec_offload_off_offload,
12006 (void *)&cmd_macsec_offload_off_port_id,
12007 (void *)&cmd_macsec_offload_off_off,
12012 /* Common result structure for MACsec secure connection configure */
12013 struct cmd_macsec_sc_result {
12014 cmdline_fixed_string_t set;
12015 cmdline_fixed_string_t macsec;
12016 cmdline_fixed_string_t sc;
12017 cmdline_fixed_string_t tx_rx;
12019 struct rte_ether_addr mac;
12023 /* Common CLI fields for MACsec secure connection configure */
12024 cmdline_parse_token_string_t cmd_macsec_sc_set =
12025 TOKEN_STRING_INITIALIZER
12026 (struct cmd_macsec_sc_result,
12028 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
12029 TOKEN_STRING_INITIALIZER
12030 (struct cmd_macsec_sc_result,
12032 cmdline_parse_token_string_t cmd_macsec_sc_sc =
12033 TOKEN_STRING_INITIALIZER
12034 (struct cmd_macsec_sc_result,
12036 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
12037 TOKEN_STRING_INITIALIZER
12038 (struct cmd_macsec_sc_result,
12040 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
12041 TOKEN_NUM_INITIALIZER
12042 (struct cmd_macsec_sc_result,
12043 port_id, RTE_UINT16);
12044 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
12045 TOKEN_ETHERADDR_INITIALIZER
12046 (struct cmd_macsec_sc_result,
12048 cmdline_parse_token_num_t cmd_macsec_sc_pi =
12049 TOKEN_NUM_INITIALIZER
12050 (struct cmd_macsec_sc_result,
12054 cmd_set_macsec_sc_parsed(
12055 void *parsed_result,
12056 __rte_unused struct cmdline *cl,
12057 __rte_unused void *data)
12059 struct cmd_macsec_sc_result *res = parsed_result;
12060 int ret = -ENOTSUP;
12061 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12063 #ifdef RTE_NET_IXGBE
12065 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12066 res->mac.addr_bytes) :
12067 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12068 res->mac.addr_bytes, res->pi);
12070 RTE_SET_USED(is_tx);
12076 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12079 fprintf(stderr, "not supported on port %d\n", res->port_id);
12082 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12086 cmdline_parse_inst_t cmd_set_macsec_sc = {
12087 .f = cmd_set_macsec_sc_parsed,
12089 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12091 (void *)&cmd_macsec_sc_set,
12092 (void *)&cmd_macsec_sc_macsec,
12093 (void *)&cmd_macsec_sc_sc,
12094 (void *)&cmd_macsec_sc_tx_rx,
12095 (void *)&cmd_macsec_sc_port_id,
12096 (void *)&cmd_macsec_sc_mac,
12097 (void *)&cmd_macsec_sc_pi,
12102 /* Common result structure for MACsec secure connection configure */
12103 struct cmd_macsec_sa_result {
12104 cmdline_fixed_string_t set;
12105 cmdline_fixed_string_t macsec;
12106 cmdline_fixed_string_t sa;
12107 cmdline_fixed_string_t tx_rx;
12112 cmdline_fixed_string_t key;
12115 /* Common CLI fields for MACsec secure connection configure */
12116 cmdline_parse_token_string_t cmd_macsec_sa_set =
12117 TOKEN_STRING_INITIALIZER
12118 (struct cmd_macsec_sa_result,
12120 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12121 TOKEN_STRING_INITIALIZER
12122 (struct cmd_macsec_sa_result,
12124 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12125 TOKEN_STRING_INITIALIZER
12126 (struct cmd_macsec_sa_result,
12128 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12129 TOKEN_STRING_INITIALIZER
12130 (struct cmd_macsec_sa_result,
12132 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12133 TOKEN_NUM_INITIALIZER
12134 (struct cmd_macsec_sa_result,
12135 port_id, RTE_UINT16);
12136 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12137 TOKEN_NUM_INITIALIZER
12138 (struct cmd_macsec_sa_result,
12140 cmdline_parse_token_num_t cmd_macsec_sa_an =
12141 TOKEN_NUM_INITIALIZER
12142 (struct cmd_macsec_sa_result,
12144 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12145 TOKEN_NUM_INITIALIZER
12146 (struct cmd_macsec_sa_result,
12148 cmdline_parse_token_string_t cmd_macsec_sa_key =
12149 TOKEN_STRING_INITIALIZER
12150 (struct cmd_macsec_sa_result,
12154 cmd_set_macsec_sa_parsed(
12155 void *parsed_result,
12156 __rte_unused struct cmdline *cl,
12157 __rte_unused void *data)
12159 struct cmd_macsec_sa_result *res = parsed_result;
12160 int ret = -ENOTSUP;
12161 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12162 uint8_t key[16] = { 0 };
12168 key_len = strlen(res->key) / 2;
12172 for (i = 0; i < key_len; i++) {
12173 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12176 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12179 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12182 #ifdef RTE_NET_IXGBE
12184 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12185 res->idx, res->an, res->pn, key) :
12186 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12187 res->idx, res->an, res->pn, key);
12189 RTE_SET_USED(is_tx);
12196 fprintf(stderr, "invalid idx %d or an %d\n", res->idx, res->an);
12199 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12202 fprintf(stderr, "not supported on port %d\n", res->port_id);
12205 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12209 cmdline_parse_inst_t cmd_set_macsec_sa = {
12210 .f = cmd_set_macsec_sa_parsed,
12212 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12214 (void *)&cmd_macsec_sa_set,
12215 (void *)&cmd_macsec_sa_macsec,
12216 (void *)&cmd_macsec_sa_sa,
12217 (void *)&cmd_macsec_sa_tx_rx,
12218 (void *)&cmd_macsec_sa_port_id,
12219 (void *)&cmd_macsec_sa_idx,
12220 (void *)&cmd_macsec_sa_an,
12221 (void *)&cmd_macsec_sa_pn,
12222 (void *)&cmd_macsec_sa_key,
12227 /* VF unicast promiscuous mode configuration */
12229 /* Common result structure for VF unicast promiscuous mode */
12230 struct cmd_vf_promisc_result {
12231 cmdline_fixed_string_t set;
12232 cmdline_fixed_string_t vf;
12233 cmdline_fixed_string_t promisc;
12236 cmdline_fixed_string_t on_off;
12239 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12240 cmdline_parse_token_string_t cmd_vf_promisc_set =
12241 TOKEN_STRING_INITIALIZER
12242 (struct cmd_vf_promisc_result,
12244 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12245 TOKEN_STRING_INITIALIZER
12246 (struct cmd_vf_promisc_result,
12248 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12249 TOKEN_STRING_INITIALIZER
12250 (struct cmd_vf_promisc_result,
12251 promisc, "promisc");
12252 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12253 TOKEN_NUM_INITIALIZER
12254 (struct cmd_vf_promisc_result,
12255 port_id, RTE_UINT16);
12256 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12257 TOKEN_NUM_INITIALIZER
12258 (struct cmd_vf_promisc_result,
12259 vf_id, RTE_UINT32);
12260 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12261 TOKEN_STRING_INITIALIZER
12262 (struct cmd_vf_promisc_result,
12266 cmd_set_vf_promisc_parsed(
12267 void *parsed_result,
12268 __rte_unused struct cmdline *cl,
12269 __rte_unused void *data)
12271 struct cmd_vf_promisc_result *res = parsed_result;
12272 int ret = -ENOTSUP;
12274 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12276 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12279 #ifdef RTE_NET_I40E
12280 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12281 res->vf_id, is_on);
12288 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12291 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12294 fprintf(stderr, "function not implemented\n");
12297 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12301 cmdline_parse_inst_t cmd_set_vf_promisc = {
12302 .f = cmd_set_vf_promisc_parsed,
12304 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12305 "Set unicast promiscuous mode for a VF from the PF",
12307 (void *)&cmd_vf_promisc_set,
12308 (void *)&cmd_vf_promisc_vf,
12309 (void *)&cmd_vf_promisc_promisc,
12310 (void *)&cmd_vf_promisc_port_id,
12311 (void *)&cmd_vf_promisc_vf_id,
12312 (void *)&cmd_vf_promisc_on_off,
12317 /* VF multicast promiscuous mode configuration */
12319 /* Common result structure for VF multicast promiscuous mode */
12320 struct cmd_vf_allmulti_result {
12321 cmdline_fixed_string_t set;
12322 cmdline_fixed_string_t vf;
12323 cmdline_fixed_string_t allmulti;
12326 cmdline_fixed_string_t on_off;
12329 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12330 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12331 TOKEN_STRING_INITIALIZER
12332 (struct cmd_vf_allmulti_result,
12334 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12335 TOKEN_STRING_INITIALIZER
12336 (struct cmd_vf_allmulti_result,
12338 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12339 TOKEN_STRING_INITIALIZER
12340 (struct cmd_vf_allmulti_result,
12341 allmulti, "allmulti");
12342 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12343 TOKEN_NUM_INITIALIZER
12344 (struct cmd_vf_allmulti_result,
12345 port_id, RTE_UINT16);
12346 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12347 TOKEN_NUM_INITIALIZER
12348 (struct cmd_vf_allmulti_result,
12349 vf_id, RTE_UINT32);
12350 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12351 TOKEN_STRING_INITIALIZER
12352 (struct cmd_vf_allmulti_result,
12356 cmd_set_vf_allmulti_parsed(
12357 void *parsed_result,
12358 __rte_unused struct cmdline *cl,
12359 __rte_unused void *data)
12361 struct cmd_vf_allmulti_result *res = parsed_result;
12362 int ret = -ENOTSUP;
12364 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12366 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12369 #ifdef RTE_NET_I40E
12370 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12371 res->vf_id, is_on);
12378 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12381 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12384 fprintf(stderr, "function not implemented\n");
12387 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12391 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12392 .f = cmd_set_vf_allmulti_parsed,
12394 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12395 "Set multicast promiscuous mode for a VF from the PF",
12397 (void *)&cmd_vf_allmulti_set,
12398 (void *)&cmd_vf_allmulti_vf,
12399 (void *)&cmd_vf_allmulti_allmulti,
12400 (void *)&cmd_vf_allmulti_port_id,
12401 (void *)&cmd_vf_allmulti_vf_id,
12402 (void *)&cmd_vf_allmulti_on_off,
12407 /* vf broadcast mode configuration */
12409 /* Common result structure for vf broadcast */
12410 struct cmd_set_vf_broadcast_result {
12411 cmdline_fixed_string_t set;
12412 cmdline_fixed_string_t vf;
12413 cmdline_fixed_string_t broadcast;
12416 cmdline_fixed_string_t on_off;
12419 /* Common CLI fields for vf broadcast enable disable */
12420 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12421 TOKEN_STRING_INITIALIZER
12422 (struct cmd_set_vf_broadcast_result,
12424 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12425 TOKEN_STRING_INITIALIZER
12426 (struct cmd_set_vf_broadcast_result,
12428 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12429 TOKEN_STRING_INITIALIZER
12430 (struct cmd_set_vf_broadcast_result,
12431 broadcast, "broadcast");
12432 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12433 TOKEN_NUM_INITIALIZER
12434 (struct cmd_set_vf_broadcast_result,
12435 port_id, RTE_UINT16);
12436 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12437 TOKEN_NUM_INITIALIZER
12438 (struct cmd_set_vf_broadcast_result,
12439 vf_id, RTE_UINT16);
12440 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12441 TOKEN_STRING_INITIALIZER
12442 (struct cmd_set_vf_broadcast_result,
12446 cmd_set_vf_broadcast_parsed(
12447 void *parsed_result,
12448 __rte_unused struct cmdline *cl,
12449 __rte_unused void *data)
12451 struct cmd_set_vf_broadcast_result *res = parsed_result;
12452 int ret = -ENOTSUP;
12454 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12456 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12459 #ifdef RTE_NET_I40E
12460 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12461 res->vf_id, is_on);
12468 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12469 res->vf_id, is_on);
12472 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12475 fprintf(stderr, "function not implemented\n");
12478 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12482 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12483 .f = cmd_set_vf_broadcast_parsed,
12485 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12487 (void *)&cmd_set_vf_broadcast_set,
12488 (void *)&cmd_set_vf_broadcast_vf,
12489 (void *)&cmd_set_vf_broadcast_broadcast,
12490 (void *)&cmd_set_vf_broadcast_port_id,
12491 (void *)&cmd_set_vf_broadcast_vf_id,
12492 (void *)&cmd_set_vf_broadcast_on_off,
12497 /* vf vlan tag configuration */
12499 /* Common result structure for vf vlan tag */
12500 struct cmd_set_vf_vlan_tag_result {
12501 cmdline_fixed_string_t set;
12502 cmdline_fixed_string_t vf;
12503 cmdline_fixed_string_t vlan;
12504 cmdline_fixed_string_t tag;
12507 cmdline_fixed_string_t on_off;
12510 /* Common CLI fields for vf vlan tag enable disable */
12511 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12512 TOKEN_STRING_INITIALIZER
12513 (struct cmd_set_vf_vlan_tag_result,
12515 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12516 TOKEN_STRING_INITIALIZER
12517 (struct cmd_set_vf_vlan_tag_result,
12519 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12520 TOKEN_STRING_INITIALIZER
12521 (struct cmd_set_vf_vlan_tag_result,
12523 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12524 TOKEN_STRING_INITIALIZER
12525 (struct cmd_set_vf_vlan_tag_result,
12527 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12528 TOKEN_NUM_INITIALIZER
12529 (struct cmd_set_vf_vlan_tag_result,
12530 port_id, RTE_UINT16);
12531 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12532 TOKEN_NUM_INITIALIZER
12533 (struct cmd_set_vf_vlan_tag_result,
12534 vf_id, RTE_UINT16);
12535 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12536 TOKEN_STRING_INITIALIZER
12537 (struct cmd_set_vf_vlan_tag_result,
12541 cmd_set_vf_vlan_tag_parsed(
12542 void *parsed_result,
12543 __rte_unused struct cmdline *cl,
12544 __rte_unused void *data)
12546 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12547 int ret = -ENOTSUP;
12549 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12551 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12554 #ifdef RTE_NET_I40E
12555 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12556 res->vf_id, is_on);
12563 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12564 res->vf_id, is_on);
12567 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12570 fprintf(stderr, "function not implemented\n");
12573 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12577 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12578 .f = cmd_set_vf_vlan_tag_parsed,
12580 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12582 (void *)&cmd_set_vf_vlan_tag_set,
12583 (void *)&cmd_set_vf_vlan_tag_vf,
12584 (void *)&cmd_set_vf_vlan_tag_vlan,
12585 (void *)&cmd_set_vf_vlan_tag_tag,
12586 (void *)&cmd_set_vf_vlan_tag_port_id,
12587 (void *)&cmd_set_vf_vlan_tag_vf_id,
12588 (void *)&cmd_set_vf_vlan_tag_on_off,
12593 /* Common definition of VF and TC TX bandwidth configuration */
12594 struct cmd_vf_tc_bw_result {
12595 cmdline_fixed_string_t set;
12596 cmdline_fixed_string_t vf;
12597 cmdline_fixed_string_t tc;
12598 cmdline_fixed_string_t tx;
12599 cmdline_fixed_string_t min_bw;
12600 cmdline_fixed_string_t max_bw;
12601 cmdline_fixed_string_t strict_link_prio;
12606 cmdline_fixed_string_t bw_list;
12610 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12611 TOKEN_STRING_INITIALIZER
12612 (struct cmd_vf_tc_bw_result,
12614 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12615 TOKEN_STRING_INITIALIZER
12616 (struct cmd_vf_tc_bw_result,
12618 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12619 TOKEN_STRING_INITIALIZER
12620 (struct cmd_vf_tc_bw_result,
12622 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12623 TOKEN_STRING_INITIALIZER
12624 (struct cmd_vf_tc_bw_result,
12626 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12627 TOKEN_STRING_INITIALIZER
12628 (struct cmd_vf_tc_bw_result,
12629 strict_link_prio, "strict-link-priority");
12630 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12631 TOKEN_STRING_INITIALIZER
12632 (struct cmd_vf_tc_bw_result,
12633 min_bw, "min-bandwidth");
12634 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12635 TOKEN_STRING_INITIALIZER
12636 (struct cmd_vf_tc_bw_result,
12637 max_bw, "max-bandwidth");
12638 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12639 TOKEN_NUM_INITIALIZER
12640 (struct cmd_vf_tc_bw_result,
12641 port_id, RTE_UINT16);
12642 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12643 TOKEN_NUM_INITIALIZER
12644 (struct cmd_vf_tc_bw_result,
12645 vf_id, RTE_UINT16);
12646 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12647 TOKEN_NUM_INITIALIZER
12648 (struct cmd_vf_tc_bw_result,
12650 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12651 TOKEN_NUM_INITIALIZER
12652 (struct cmd_vf_tc_bw_result,
12654 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12655 TOKEN_STRING_INITIALIZER
12656 (struct cmd_vf_tc_bw_result,
12658 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12659 TOKEN_NUM_INITIALIZER
12660 (struct cmd_vf_tc_bw_result,
12661 tc_map, RTE_UINT8);
12663 /* VF max bandwidth setting */
12665 cmd_vf_max_bw_parsed(
12666 void *parsed_result,
12667 __rte_unused struct cmdline *cl,
12668 __rte_unused void *data)
12670 struct cmd_vf_tc_bw_result *res = parsed_result;
12671 int ret = -ENOTSUP;
12673 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12676 #ifdef RTE_NET_I40E
12677 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12678 res->vf_id, res->bw);
12685 fprintf(stderr, "invalid vf_id %d or bandwidth %d\n",
12686 res->vf_id, res->bw);
12689 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12692 fprintf(stderr, "function not implemented\n");
12695 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12699 cmdline_parse_inst_t cmd_vf_max_bw = {
12700 .f = cmd_vf_max_bw_parsed,
12702 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12704 (void *)&cmd_vf_tc_bw_set,
12705 (void *)&cmd_vf_tc_bw_vf,
12706 (void *)&cmd_vf_tc_bw_tx,
12707 (void *)&cmd_vf_tc_bw_max_bw,
12708 (void *)&cmd_vf_tc_bw_port_id,
12709 (void *)&cmd_vf_tc_bw_vf_id,
12710 (void *)&cmd_vf_tc_bw_bw,
12716 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12721 const char *p, *p0 = str;
12728 p = strchr(p0, '(');
12731 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12735 p0 = strchr(p, ')');
12738 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12742 if (size >= sizeof(s)) {
12744 "The string size exceeds the internal buffer size\n");
12747 snprintf(s, sizeof(s), "%.*s", size, p);
12748 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12750 fprintf(stderr, "Failed to get the bandwidth list.\n");
12754 for (i = 0; i < ret; i++)
12755 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12760 /* TC min bandwidth setting */
12762 cmd_vf_tc_min_bw_parsed(
12763 void *parsed_result,
12764 __rte_unused struct cmdline *cl,
12765 __rte_unused void *data)
12767 struct cmd_vf_tc_bw_result *res = parsed_result;
12770 int ret = -ENOTSUP;
12772 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12775 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12779 #ifdef RTE_NET_I40E
12780 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12788 fprintf(stderr, "invalid vf_id %d or bandwidth\n", res->vf_id);
12791 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12794 fprintf(stderr, "function not implemented\n");
12797 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12801 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12802 .f = cmd_vf_tc_min_bw_parsed,
12804 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12805 " <bw1, bw2, ...>",
12807 (void *)&cmd_vf_tc_bw_set,
12808 (void *)&cmd_vf_tc_bw_vf,
12809 (void *)&cmd_vf_tc_bw_tc,
12810 (void *)&cmd_vf_tc_bw_tx,
12811 (void *)&cmd_vf_tc_bw_min_bw,
12812 (void *)&cmd_vf_tc_bw_port_id,
12813 (void *)&cmd_vf_tc_bw_vf_id,
12814 (void *)&cmd_vf_tc_bw_bw_list,
12820 cmd_tc_min_bw_parsed(
12821 void *parsed_result,
12822 __rte_unused struct cmdline *cl,
12823 __rte_unused void *data)
12825 struct cmd_vf_tc_bw_result *res = parsed_result;
12826 struct rte_port *port;
12829 int ret = -ENOTSUP;
12831 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12834 port = &ports[res->port_id];
12835 /** Check if the port is not started **/
12836 if (port->port_status != RTE_PORT_STOPPED) {
12837 fprintf(stderr, "Please stop port %d first\n", res->port_id);
12841 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12845 #ifdef RTE_NET_IXGBE
12846 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12853 fprintf(stderr, "invalid bandwidth\n");
12856 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12859 fprintf(stderr, "function not implemented\n");
12862 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12866 cmdline_parse_inst_t cmd_tc_min_bw = {
12867 .f = cmd_tc_min_bw_parsed,
12869 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12871 (void *)&cmd_vf_tc_bw_set,
12872 (void *)&cmd_vf_tc_bw_tc,
12873 (void *)&cmd_vf_tc_bw_tx,
12874 (void *)&cmd_vf_tc_bw_min_bw,
12875 (void *)&cmd_vf_tc_bw_port_id,
12876 (void *)&cmd_vf_tc_bw_bw_list,
12881 /* TC max bandwidth setting */
12883 cmd_vf_tc_max_bw_parsed(
12884 void *parsed_result,
12885 __rte_unused struct cmdline *cl,
12886 __rte_unused void *data)
12888 struct cmd_vf_tc_bw_result *res = parsed_result;
12889 int ret = -ENOTSUP;
12891 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12894 #ifdef RTE_NET_I40E
12895 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12896 res->tc_no, res->bw);
12904 "invalid vf_id %d, tc_no %d or bandwidth %d\n",
12905 res->vf_id, res->tc_no, res->bw);
12908 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12911 fprintf(stderr, "function not implemented\n");
12914 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12918 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12919 .f = cmd_vf_tc_max_bw_parsed,
12921 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12924 (void *)&cmd_vf_tc_bw_set,
12925 (void *)&cmd_vf_tc_bw_vf,
12926 (void *)&cmd_vf_tc_bw_tc,
12927 (void *)&cmd_vf_tc_bw_tx,
12928 (void *)&cmd_vf_tc_bw_max_bw,
12929 (void *)&cmd_vf_tc_bw_port_id,
12930 (void *)&cmd_vf_tc_bw_vf_id,
12931 (void *)&cmd_vf_tc_bw_tc_no,
12932 (void *)&cmd_vf_tc_bw_bw,
12937 /** Set VXLAN encapsulation details */
12938 struct cmd_set_vxlan_result {
12939 cmdline_fixed_string_t set;
12940 cmdline_fixed_string_t vxlan;
12941 cmdline_fixed_string_t pos_token;
12942 cmdline_fixed_string_t ip_version;
12943 uint32_t vlan_present:1;
12947 cmdline_ipaddr_t ip_src;
12948 cmdline_ipaddr_t ip_dst;
12952 struct rte_ether_addr eth_src;
12953 struct rte_ether_addr eth_dst;
12956 cmdline_parse_token_string_t cmd_set_vxlan_set =
12957 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
12958 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
12959 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
12960 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
12961 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12963 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
12964 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12965 "vxlan-with-vlan");
12966 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
12967 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12969 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
12970 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
12972 cmdline_parse_token_string_t cmd_set_vxlan_vni =
12973 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12975 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
12976 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
12977 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
12978 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12980 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
12981 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
12982 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
12983 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12985 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
12986 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
12987 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
12988 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12990 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
12991 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
12992 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
12993 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12995 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
12996 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
12997 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
12998 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13000 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
13001 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
13002 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
13003 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13005 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
13006 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
13007 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
13008 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13010 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
13011 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
13012 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
13013 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13015 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
13016 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
13017 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
13018 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13020 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
13021 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
13023 static void cmd_set_vxlan_parsed(void *parsed_result,
13024 __rte_unused struct cmdline *cl,
13025 __rte_unused void *data)
13027 struct cmd_set_vxlan_result *res = parsed_result;
13032 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
13035 vxlan_encap_conf.select_tos_ttl = 0;
13036 if (strcmp(res->vxlan, "vxlan") == 0)
13037 vxlan_encap_conf.select_vlan = 0;
13038 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
13039 vxlan_encap_conf.select_vlan = 1;
13040 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
13041 vxlan_encap_conf.select_vlan = 0;
13042 vxlan_encap_conf.select_tos_ttl = 1;
13044 if (strcmp(res->ip_version, "ipv4") == 0)
13045 vxlan_encap_conf.select_ipv4 = 1;
13046 else if (strcmp(res->ip_version, "ipv6") == 0)
13047 vxlan_encap_conf.select_ipv4 = 0;
13050 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
13051 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13052 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13053 vxlan_encap_conf.ip_tos = res->tos;
13054 vxlan_encap_conf.ip_ttl = res->ttl;
13055 if (vxlan_encap_conf.select_ipv4) {
13056 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
13057 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
13059 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
13060 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
13062 if (vxlan_encap_conf.select_vlan)
13063 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13064 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
13065 RTE_ETHER_ADDR_LEN);
13066 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13067 RTE_ETHER_ADDR_LEN);
13070 cmdline_parse_inst_t cmd_set_vxlan = {
13071 .f = cmd_set_vxlan_parsed,
13073 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
13074 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
13075 " eth-src <eth-src> eth-dst <eth-dst>",
13077 (void *)&cmd_set_vxlan_set,
13078 (void *)&cmd_set_vxlan_vxlan,
13079 (void *)&cmd_set_vxlan_ip_version,
13080 (void *)&cmd_set_vxlan_ip_version_value,
13081 (void *)&cmd_set_vxlan_vni,
13082 (void *)&cmd_set_vxlan_vni_value,
13083 (void *)&cmd_set_vxlan_udp_src,
13084 (void *)&cmd_set_vxlan_udp_src_value,
13085 (void *)&cmd_set_vxlan_udp_dst,
13086 (void *)&cmd_set_vxlan_udp_dst_value,
13087 (void *)&cmd_set_vxlan_ip_src,
13088 (void *)&cmd_set_vxlan_ip_src_value,
13089 (void *)&cmd_set_vxlan_ip_dst,
13090 (void *)&cmd_set_vxlan_ip_dst_value,
13091 (void *)&cmd_set_vxlan_eth_src,
13092 (void *)&cmd_set_vxlan_eth_src_value,
13093 (void *)&cmd_set_vxlan_eth_dst,
13094 (void *)&cmd_set_vxlan_eth_dst_value,
13099 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
13100 .f = cmd_set_vxlan_parsed,
13102 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
13103 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
13104 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13105 " eth-dst <eth-dst>",
13107 (void *)&cmd_set_vxlan_set,
13108 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
13109 (void *)&cmd_set_vxlan_ip_version,
13110 (void *)&cmd_set_vxlan_ip_version_value,
13111 (void *)&cmd_set_vxlan_vni,
13112 (void *)&cmd_set_vxlan_vni_value,
13113 (void *)&cmd_set_vxlan_udp_src,
13114 (void *)&cmd_set_vxlan_udp_src_value,
13115 (void *)&cmd_set_vxlan_udp_dst,
13116 (void *)&cmd_set_vxlan_udp_dst_value,
13117 (void *)&cmd_set_vxlan_ip_tos,
13118 (void *)&cmd_set_vxlan_ip_tos_value,
13119 (void *)&cmd_set_vxlan_ip_ttl,
13120 (void *)&cmd_set_vxlan_ip_ttl_value,
13121 (void *)&cmd_set_vxlan_ip_src,
13122 (void *)&cmd_set_vxlan_ip_src_value,
13123 (void *)&cmd_set_vxlan_ip_dst,
13124 (void *)&cmd_set_vxlan_ip_dst_value,
13125 (void *)&cmd_set_vxlan_eth_src,
13126 (void *)&cmd_set_vxlan_eth_src_value,
13127 (void *)&cmd_set_vxlan_eth_dst,
13128 (void *)&cmd_set_vxlan_eth_dst_value,
13133 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
13134 .f = cmd_set_vxlan_parsed,
13136 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
13137 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
13138 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
13141 (void *)&cmd_set_vxlan_set,
13142 (void *)&cmd_set_vxlan_vxlan_with_vlan,
13143 (void *)&cmd_set_vxlan_ip_version,
13144 (void *)&cmd_set_vxlan_ip_version_value,
13145 (void *)&cmd_set_vxlan_vni,
13146 (void *)&cmd_set_vxlan_vni_value,
13147 (void *)&cmd_set_vxlan_udp_src,
13148 (void *)&cmd_set_vxlan_udp_src_value,
13149 (void *)&cmd_set_vxlan_udp_dst,
13150 (void *)&cmd_set_vxlan_udp_dst_value,
13151 (void *)&cmd_set_vxlan_ip_src,
13152 (void *)&cmd_set_vxlan_ip_src_value,
13153 (void *)&cmd_set_vxlan_ip_dst,
13154 (void *)&cmd_set_vxlan_ip_dst_value,
13155 (void *)&cmd_set_vxlan_vlan,
13156 (void *)&cmd_set_vxlan_vlan_value,
13157 (void *)&cmd_set_vxlan_eth_src,
13158 (void *)&cmd_set_vxlan_eth_src_value,
13159 (void *)&cmd_set_vxlan_eth_dst,
13160 (void *)&cmd_set_vxlan_eth_dst_value,
13165 /** Set NVGRE encapsulation details */
13166 struct cmd_set_nvgre_result {
13167 cmdline_fixed_string_t set;
13168 cmdline_fixed_string_t nvgre;
13169 cmdline_fixed_string_t pos_token;
13170 cmdline_fixed_string_t ip_version;
13172 cmdline_ipaddr_t ip_src;
13173 cmdline_ipaddr_t ip_dst;
13175 struct rte_ether_addr eth_src;
13176 struct rte_ether_addr eth_dst;
13179 cmdline_parse_token_string_t cmd_set_nvgre_set =
13180 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
13181 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
13182 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
13183 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
13184 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
13185 "nvgre-with-vlan");
13186 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
13187 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13189 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
13190 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
13192 cmdline_parse_token_string_t cmd_set_nvgre_tni =
13193 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13195 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
13196 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
13197 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
13198 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13200 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
13201 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
13202 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
13203 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13205 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
13206 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
13207 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
13208 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13210 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
13211 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
13212 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
13213 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13215 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
13216 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
13217 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
13218 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13220 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
13221 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
13223 static void cmd_set_nvgre_parsed(void *parsed_result,
13224 __rte_unused struct cmdline *cl,
13225 __rte_unused void *data)
13227 struct cmd_set_nvgre_result *res = parsed_result;
13229 uint32_t nvgre_tni;
13232 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
13235 if (strcmp(res->nvgre, "nvgre") == 0)
13236 nvgre_encap_conf.select_vlan = 0;
13237 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
13238 nvgre_encap_conf.select_vlan = 1;
13239 if (strcmp(res->ip_version, "ipv4") == 0)
13240 nvgre_encap_conf.select_ipv4 = 1;
13241 else if (strcmp(res->ip_version, "ipv6") == 0)
13242 nvgre_encap_conf.select_ipv4 = 0;
13245 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
13246 if (nvgre_encap_conf.select_ipv4) {
13247 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
13248 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
13250 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
13251 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
13253 if (nvgre_encap_conf.select_vlan)
13254 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13255 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
13256 RTE_ETHER_ADDR_LEN);
13257 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13258 RTE_ETHER_ADDR_LEN);
13261 cmdline_parse_inst_t cmd_set_nvgre = {
13262 .f = cmd_set_nvgre_parsed,
13264 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
13265 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13266 " eth-dst <eth-dst>",
13268 (void *)&cmd_set_nvgre_set,
13269 (void *)&cmd_set_nvgre_nvgre,
13270 (void *)&cmd_set_nvgre_ip_version,
13271 (void *)&cmd_set_nvgre_ip_version_value,
13272 (void *)&cmd_set_nvgre_tni,
13273 (void *)&cmd_set_nvgre_tni_value,
13274 (void *)&cmd_set_nvgre_ip_src,
13275 (void *)&cmd_set_nvgre_ip_src_value,
13276 (void *)&cmd_set_nvgre_ip_dst,
13277 (void *)&cmd_set_nvgre_ip_dst_value,
13278 (void *)&cmd_set_nvgre_eth_src,
13279 (void *)&cmd_set_nvgre_eth_src_value,
13280 (void *)&cmd_set_nvgre_eth_dst,
13281 (void *)&cmd_set_nvgre_eth_dst_value,
13286 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
13287 .f = cmd_set_nvgre_parsed,
13289 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
13290 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13291 " eth-src <eth-src> eth-dst <eth-dst>",
13293 (void *)&cmd_set_nvgre_set,
13294 (void *)&cmd_set_nvgre_nvgre_with_vlan,
13295 (void *)&cmd_set_nvgre_ip_version,
13296 (void *)&cmd_set_nvgre_ip_version_value,
13297 (void *)&cmd_set_nvgre_tni,
13298 (void *)&cmd_set_nvgre_tni_value,
13299 (void *)&cmd_set_nvgre_ip_src,
13300 (void *)&cmd_set_nvgre_ip_src_value,
13301 (void *)&cmd_set_nvgre_ip_dst,
13302 (void *)&cmd_set_nvgre_ip_dst_value,
13303 (void *)&cmd_set_nvgre_vlan,
13304 (void *)&cmd_set_nvgre_vlan_value,
13305 (void *)&cmd_set_nvgre_eth_src,
13306 (void *)&cmd_set_nvgre_eth_src_value,
13307 (void *)&cmd_set_nvgre_eth_dst,
13308 (void *)&cmd_set_nvgre_eth_dst_value,
13313 /** Set L2 encapsulation details */
13314 struct cmd_set_l2_encap_result {
13315 cmdline_fixed_string_t set;
13316 cmdline_fixed_string_t l2_encap;
13317 cmdline_fixed_string_t pos_token;
13318 cmdline_fixed_string_t ip_version;
13319 uint32_t vlan_present:1;
13321 struct rte_ether_addr eth_src;
13322 struct rte_ether_addr eth_dst;
13325 cmdline_parse_token_string_t cmd_set_l2_encap_set =
13326 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13327 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13328 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13329 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13330 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13331 "l2_encap-with-vlan");
13332 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13333 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13335 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13336 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13338 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13339 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13341 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13342 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13343 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13344 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13346 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13347 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13348 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13349 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13351 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13352 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13354 static void cmd_set_l2_encap_parsed(void *parsed_result,
13355 __rte_unused struct cmdline *cl,
13356 __rte_unused void *data)
13358 struct cmd_set_l2_encap_result *res = parsed_result;
13360 if (strcmp(res->l2_encap, "l2_encap") == 0)
13361 l2_encap_conf.select_vlan = 0;
13362 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13363 l2_encap_conf.select_vlan = 1;
13364 if (strcmp(res->ip_version, "ipv4") == 0)
13365 l2_encap_conf.select_ipv4 = 1;
13366 else if (strcmp(res->ip_version, "ipv6") == 0)
13367 l2_encap_conf.select_ipv4 = 0;
13370 if (l2_encap_conf.select_vlan)
13371 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13372 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13373 RTE_ETHER_ADDR_LEN);
13374 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13375 RTE_ETHER_ADDR_LEN);
13378 cmdline_parse_inst_t cmd_set_l2_encap = {
13379 .f = cmd_set_l2_encap_parsed,
13381 .help_str = "set l2_encap ip-version ipv4|ipv6"
13382 " eth-src <eth-src> eth-dst <eth-dst>",
13384 (void *)&cmd_set_l2_encap_set,
13385 (void *)&cmd_set_l2_encap_l2_encap,
13386 (void *)&cmd_set_l2_encap_ip_version,
13387 (void *)&cmd_set_l2_encap_ip_version_value,
13388 (void *)&cmd_set_l2_encap_eth_src,
13389 (void *)&cmd_set_l2_encap_eth_src_value,
13390 (void *)&cmd_set_l2_encap_eth_dst,
13391 (void *)&cmd_set_l2_encap_eth_dst_value,
13396 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13397 .f = cmd_set_l2_encap_parsed,
13399 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13400 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13402 (void *)&cmd_set_l2_encap_set,
13403 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13404 (void *)&cmd_set_l2_encap_ip_version,
13405 (void *)&cmd_set_l2_encap_ip_version_value,
13406 (void *)&cmd_set_l2_encap_vlan,
13407 (void *)&cmd_set_l2_encap_vlan_value,
13408 (void *)&cmd_set_l2_encap_eth_src,
13409 (void *)&cmd_set_l2_encap_eth_src_value,
13410 (void *)&cmd_set_l2_encap_eth_dst,
13411 (void *)&cmd_set_l2_encap_eth_dst_value,
13416 /** Set L2 decapsulation details */
13417 struct cmd_set_l2_decap_result {
13418 cmdline_fixed_string_t set;
13419 cmdline_fixed_string_t l2_decap;
13420 cmdline_fixed_string_t pos_token;
13421 uint32_t vlan_present:1;
13424 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13425 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13426 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13427 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13429 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13430 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13431 "l2_decap-with-vlan");
13433 static void cmd_set_l2_decap_parsed(void *parsed_result,
13434 __rte_unused struct cmdline *cl,
13435 __rte_unused void *data)
13437 struct cmd_set_l2_decap_result *res = parsed_result;
13439 if (strcmp(res->l2_decap, "l2_decap") == 0)
13440 l2_decap_conf.select_vlan = 0;
13441 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13442 l2_decap_conf.select_vlan = 1;
13445 cmdline_parse_inst_t cmd_set_l2_decap = {
13446 .f = cmd_set_l2_decap_parsed,
13448 .help_str = "set l2_decap",
13450 (void *)&cmd_set_l2_decap_set,
13451 (void *)&cmd_set_l2_decap_l2_decap,
13456 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13457 .f = cmd_set_l2_decap_parsed,
13459 .help_str = "set l2_decap-with-vlan",
13461 (void *)&cmd_set_l2_decap_set,
13462 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13467 /** Set MPLSoGRE encapsulation details */
13468 struct cmd_set_mplsogre_encap_result {
13469 cmdline_fixed_string_t set;
13470 cmdline_fixed_string_t mplsogre;
13471 cmdline_fixed_string_t pos_token;
13472 cmdline_fixed_string_t ip_version;
13473 uint32_t vlan_present:1;
13475 cmdline_ipaddr_t ip_src;
13476 cmdline_ipaddr_t ip_dst;
13478 struct rte_ether_addr eth_src;
13479 struct rte_ether_addr eth_dst;
13482 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13483 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13485 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13486 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13488 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13489 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13490 mplsogre, "mplsogre_encap-with-vlan");
13491 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13492 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13493 pos_token, "ip-version");
13494 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13495 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13496 ip_version, "ipv4#ipv6");
13497 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13498 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13499 pos_token, "label");
13500 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13501 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13503 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13504 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13505 pos_token, "ip-src");
13506 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13507 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13508 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13509 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13510 pos_token, "ip-dst");
13511 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13512 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13513 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13514 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13515 pos_token, "vlan-tci");
13516 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13517 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13519 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13520 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13521 pos_token, "eth-src");
13522 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13523 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13525 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13526 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13527 pos_token, "eth-dst");
13528 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13529 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13532 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13533 __rte_unused struct cmdline *cl,
13534 __rte_unused void *data)
13536 struct cmd_set_mplsogre_encap_result *res = parsed_result;
13538 uint32_t mplsogre_label;
13541 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13544 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13545 mplsogre_encap_conf.select_vlan = 0;
13546 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13547 mplsogre_encap_conf.select_vlan = 1;
13548 if (strcmp(res->ip_version, "ipv4") == 0)
13549 mplsogre_encap_conf.select_ipv4 = 1;
13550 else if (strcmp(res->ip_version, "ipv6") == 0)
13551 mplsogre_encap_conf.select_ipv4 = 0;
13554 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13555 if (mplsogre_encap_conf.select_ipv4) {
13556 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13557 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13559 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13560 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13562 if (mplsogre_encap_conf.select_vlan)
13563 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13564 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13565 RTE_ETHER_ADDR_LEN);
13566 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13567 RTE_ETHER_ADDR_LEN);
13570 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13571 .f = cmd_set_mplsogre_encap_parsed,
13573 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13574 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13575 " eth-dst <eth-dst>",
13577 (void *)&cmd_set_mplsogre_encap_set,
13578 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13579 (void *)&cmd_set_mplsogre_encap_ip_version,
13580 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13581 (void *)&cmd_set_mplsogre_encap_label,
13582 (void *)&cmd_set_mplsogre_encap_label_value,
13583 (void *)&cmd_set_mplsogre_encap_ip_src,
13584 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13585 (void *)&cmd_set_mplsogre_encap_ip_dst,
13586 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13587 (void *)&cmd_set_mplsogre_encap_eth_src,
13588 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13589 (void *)&cmd_set_mplsogre_encap_eth_dst,
13590 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13595 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13596 .f = cmd_set_mplsogre_encap_parsed,
13598 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13599 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
13600 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13602 (void *)&cmd_set_mplsogre_encap_set,
13603 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13604 (void *)&cmd_set_mplsogre_encap_ip_version,
13605 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13606 (void *)&cmd_set_mplsogre_encap_label,
13607 (void *)&cmd_set_mplsogre_encap_label_value,
13608 (void *)&cmd_set_mplsogre_encap_ip_src,
13609 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13610 (void *)&cmd_set_mplsogre_encap_ip_dst,
13611 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13612 (void *)&cmd_set_mplsogre_encap_vlan,
13613 (void *)&cmd_set_mplsogre_encap_vlan_value,
13614 (void *)&cmd_set_mplsogre_encap_eth_src,
13615 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13616 (void *)&cmd_set_mplsogre_encap_eth_dst,
13617 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13622 /** Set MPLSoGRE decapsulation details */
13623 struct cmd_set_mplsogre_decap_result {
13624 cmdline_fixed_string_t set;
13625 cmdline_fixed_string_t mplsogre;
13626 cmdline_fixed_string_t pos_token;
13627 cmdline_fixed_string_t ip_version;
13628 uint32_t vlan_present:1;
13631 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13632 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13634 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13635 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13637 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13638 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13639 mplsogre, "mplsogre_decap-with-vlan");
13640 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13641 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13642 pos_token, "ip-version");
13643 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13644 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13645 ip_version, "ipv4#ipv6");
13647 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13648 __rte_unused struct cmdline *cl,
13649 __rte_unused void *data)
13651 struct cmd_set_mplsogre_decap_result *res = parsed_result;
13653 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13654 mplsogre_decap_conf.select_vlan = 0;
13655 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13656 mplsogre_decap_conf.select_vlan = 1;
13657 if (strcmp(res->ip_version, "ipv4") == 0)
13658 mplsogre_decap_conf.select_ipv4 = 1;
13659 else if (strcmp(res->ip_version, "ipv6") == 0)
13660 mplsogre_decap_conf.select_ipv4 = 0;
13663 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13664 .f = cmd_set_mplsogre_decap_parsed,
13666 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13668 (void *)&cmd_set_mplsogre_decap_set,
13669 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13670 (void *)&cmd_set_mplsogre_decap_ip_version,
13671 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13676 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13677 .f = cmd_set_mplsogre_decap_parsed,
13679 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13681 (void *)&cmd_set_mplsogre_decap_set,
13682 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13683 (void *)&cmd_set_mplsogre_decap_ip_version,
13684 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13689 /** Set MPLSoUDP encapsulation details */
13690 struct cmd_set_mplsoudp_encap_result {
13691 cmdline_fixed_string_t set;
13692 cmdline_fixed_string_t mplsoudp;
13693 cmdline_fixed_string_t pos_token;
13694 cmdline_fixed_string_t ip_version;
13695 uint32_t vlan_present:1;
13699 cmdline_ipaddr_t ip_src;
13700 cmdline_ipaddr_t ip_dst;
13702 struct rte_ether_addr eth_src;
13703 struct rte_ether_addr eth_dst;
13706 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13707 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13709 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13710 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13712 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13713 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13714 mplsoudp, "mplsoudp_encap-with-vlan");
13715 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13716 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13717 pos_token, "ip-version");
13718 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13719 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13720 ip_version, "ipv4#ipv6");
13721 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13722 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13723 pos_token, "label");
13724 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13725 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13727 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13728 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13729 pos_token, "udp-src");
13730 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13731 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13733 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13734 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13735 pos_token, "udp-dst");
13736 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13737 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13739 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13740 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13741 pos_token, "ip-src");
13742 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13743 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13744 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13745 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13746 pos_token, "ip-dst");
13747 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13748 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13749 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13750 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13751 pos_token, "vlan-tci");
13752 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13753 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13755 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13756 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13757 pos_token, "eth-src");
13758 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13759 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13761 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13762 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13763 pos_token, "eth-dst");
13764 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13765 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13768 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13769 __rte_unused struct cmdline *cl,
13770 __rte_unused void *data)
13772 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13774 uint32_t mplsoudp_label;
13777 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13780 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13781 mplsoudp_encap_conf.select_vlan = 0;
13782 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13783 mplsoudp_encap_conf.select_vlan = 1;
13784 if (strcmp(res->ip_version, "ipv4") == 0)
13785 mplsoudp_encap_conf.select_ipv4 = 1;
13786 else if (strcmp(res->ip_version, "ipv6") == 0)
13787 mplsoudp_encap_conf.select_ipv4 = 0;
13790 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13791 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13792 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13793 if (mplsoudp_encap_conf.select_ipv4) {
13794 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13795 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13797 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13798 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13800 if (mplsoudp_encap_conf.select_vlan)
13801 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13802 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13803 RTE_ETHER_ADDR_LEN);
13804 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13805 RTE_ETHER_ADDR_LEN);
13808 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13809 .f = cmd_set_mplsoudp_encap_parsed,
13811 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13812 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13813 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13815 (void *)&cmd_set_mplsoudp_encap_set,
13816 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13817 (void *)&cmd_set_mplsoudp_encap_ip_version,
13818 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13819 (void *)&cmd_set_mplsoudp_encap_label,
13820 (void *)&cmd_set_mplsoudp_encap_label_value,
13821 (void *)&cmd_set_mplsoudp_encap_udp_src,
13822 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13823 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13824 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13825 (void *)&cmd_set_mplsoudp_encap_ip_src,
13826 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13827 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13828 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13829 (void *)&cmd_set_mplsoudp_encap_eth_src,
13830 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13831 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13832 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13837 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13838 .f = cmd_set_mplsoudp_encap_parsed,
13840 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13841 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
13842 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13843 " eth-src <eth-src> eth-dst <eth-dst>",
13845 (void *)&cmd_set_mplsoudp_encap_set,
13846 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13847 (void *)&cmd_set_mplsoudp_encap_ip_version,
13848 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13849 (void *)&cmd_set_mplsoudp_encap_label,
13850 (void *)&cmd_set_mplsoudp_encap_label_value,
13851 (void *)&cmd_set_mplsoudp_encap_udp_src,
13852 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13853 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13854 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13855 (void *)&cmd_set_mplsoudp_encap_ip_src,
13856 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13857 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13858 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13859 (void *)&cmd_set_mplsoudp_encap_vlan,
13860 (void *)&cmd_set_mplsoudp_encap_vlan_value,
13861 (void *)&cmd_set_mplsoudp_encap_eth_src,
13862 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13863 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13864 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13869 /** Set MPLSoUDP decapsulation details */
13870 struct cmd_set_mplsoudp_decap_result {
13871 cmdline_fixed_string_t set;
13872 cmdline_fixed_string_t mplsoudp;
13873 cmdline_fixed_string_t pos_token;
13874 cmdline_fixed_string_t ip_version;
13875 uint32_t vlan_present:1;
13878 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
13879 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
13881 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
13882 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
13884 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
13885 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13886 mplsoudp, "mplsoudp_decap-with-vlan");
13887 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
13888 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13889 pos_token, "ip-version");
13890 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
13891 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13892 ip_version, "ipv4#ipv6");
13894 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
13895 __rte_unused struct cmdline *cl,
13896 __rte_unused void *data)
13898 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
13900 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
13901 mplsoudp_decap_conf.select_vlan = 0;
13902 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
13903 mplsoudp_decap_conf.select_vlan = 1;
13904 if (strcmp(res->ip_version, "ipv4") == 0)
13905 mplsoudp_decap_conf.select_ipv4 = 1;
13906 else if (strcmp(res->ip_version, "ipv6") == 0)
13907 mplsoudp_decap_conf.select_ipv4 = 0;
13910 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
13911 .f = cmd_set_mplsoudp_decap_parsed,
13913 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
13915 (void *)&cmd_set_mplsoudp_decap_set,
13916 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
13917 (void *)&cmd_set_mplsoudp_decap_ip_version,
13918 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13923 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
13924 .f = cmd_set_mplsoudp_decap_parsed,
13926 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
13928 (void *)&cmd_set_mplsoudp_decap_set,
13929 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
13930 (void *)&cmd_set_mplsoudp_decap_ip_version,
13931 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13936 /** Set connection tracking object common details */
13937 struct cmd_set_conntrack_common_result {
13938 cmdline_fixed_string_t set;
13939 cmdline_fixed_string_t conntrack;
13940 cmdline_fixed_string_t common;
13941 cmdline_fixed_string_t peer;
13942 cmdline_fixed_string_t is_orig;
13943 cmdline_fixed_string_t enable;
13944 cmdline_fixed_string_t live;
13945 cmdline_fixed_string_t sack;
13946 cmdline_fixed_string_t cack;
13947 cmdline_fixed_string_t last_dir;
13948 cmdline_fixed_string_t liberal;
13949 cmdline_fixed_string_t state;
13950 cmdline_fixed_string_t max_ack_win;
13951 cmdline_fixed_string_t retrans;
13952 cmdline_fixed_string_t last_win;
13953 cmdline_fixed_string_t last_seq;
13954 cmdline_fixed_string_t last_ack;
13955 cmdline_fixed_string_t last_end;
13956 cmdline_fixed_string_t last_index;
13959 uint16_t peer_port;
13960 uint32_t is_original;
13975 cmdline_parse_token_string_t cmd_set_conntrack_set =
13976 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13978 cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
13979 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13980 conntrack, "conntrack");
13981 cmdline_parse_token_string_t cmd_set_conntrack_common_com =
13982 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13984 cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
13985 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13987 cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
13988 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13989 peer_port, RTE_UINT16);
13990 cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
13991 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13992 is_orig, "is_orig");
13993 cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
13994 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13995 is_original, RTE_UINT32);
13996 cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
13997 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13999 cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
14000 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14002 cmdline_parse_token_string_t cmd_set_conntrack_common_live =
14003 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14005 cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
14006 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14007 is_live, RTE_UINT32);
14008 cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
14009 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14011 cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
14012 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14013 s_ack, RTE_UINT32);
14014 cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
14015 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14017 cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
14018 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14019 c_ack, RTE_UINT32);
14020 cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
14021 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14022 last_dir, "last_dir");
14023 cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
14024 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14026 cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
14027 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14028 liberal, "liberal");
14029 cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
14030 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14032 cmdline_parse_token_string_t cmd_set_conntrack_common_state =
14033 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14035 cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
14036 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14038 cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
14039 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14040 max_ack_win, "max_ack_win");
14041 cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
14042 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14043 factor, RTE_UINT8);
14044 cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
14045 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14047 cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
14048 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14049 re_num, RTE_UINT8);
14050 cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
14051 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14052 last_win, "last_win");
14053 cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
14054 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14056 cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
14057 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14058 last_seq, "last_seq");
14059 cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
14060 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14062 cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
14063 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14064 last_ack, "last_ack");
14065 cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
14066 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14068 cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
14069 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14070 last_end, "last_end");
14071 cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
14072 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14074 cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
14075 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14076 last_index, "last_index");
14077 cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
14078 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14081 static void cmd_set_conntrack_common_parsed(void *parsed_result,
14082 __rte_unused struct cmdline *cl,
14083 __rte_unused void *data)
14085 struct cmd_set_conntrack_common_result *res = parsed_result;
14087 /* No need to swap to big endian. */
14088 conntrack_context.peer_port = res->peer_port;
14089 conntrack_context.is_original_dir = res->is_original;
14090 conntrack_context.enable = res->en;
14091 conntrack_context.live_connection = res->is_live;
14092 conntrack_context.selective_ack = res->s_ack;
14093 conntrack_context.challenge_ack_passed = res->c_ack;
14094 conntrack_context.last_direction = res->ld;
14095 conntrack_context.liberal_mode = res->lb;
14096 conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
14097 conntrack_context.max_ack_window = res->factor;
14098 conntrack_context.retransmission_limit = res->re_num;
14099 conntrack_context.last_window = res->lw;
14100 conntrack_context.last_index =
14101 (enum rte_flow_conntrack_tcp_last_index)res->li;
14102 conntrack_context.last_seq = res->ls;
14103 conntrack_context.last_ack = res->la;
14104 conntrack_context.last_end = res->le;
14107 cmdline_parse_inst_t cmd_set_conntrack_common = {
14108 .f = cmd_set_conntrack_common_parsed,
14110 .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
14111 " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
14112 " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
14113 " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
14114 " last_index <flag>",
14116 (void *)&cmd_set_conntrack_set,
14117 (void *)&cmd_set_conntrack_conntrack,
14118 (void *)&cmd_set_conntrack_common_com,
14119 (void *)&cmd_set_conntrack_common_peer,
14120 (void *)&cmd_set_conntrack_common_peer_value,
14121 (void *)&cmd_set_conntrack_common_is_orig,
14122 (void *)&cmd_set_conntrack_common_is_orig_value,
14123 (void *)&cmd_set_conntrack_common_enable,
14124 (void *)&cmd_set_conntrack_common_enable_value,
14125 (void *)&cmd_set_conntrack_common_live,
14126 (void *)&cmd_set_conntrack_common_live_value,
14127 (void *)&cmd_set_conntrack_common_sack,
14128 (void *)&cmd_set_conntrack_common_sack_value,
14129 (void *)&cmd_set_conntrack_common_cack,
14130 (void *)&cmd_set_conntrack_common_cack_value,
14131 (void *)&cmd_set_conntrack_common_last_dir,
14132 (void *)&cmd_set_conntrack_common_last_dir_value,
14133 (void *)&cmd_set_conntrack_common_liberal,
14134 (void *)&cmd_set_conntrack_common_liberal_value,
14135 (void *)&cmd_set_conntrack_common_state,
14136 (void *)&cmd_set_conntrack_common_state_value,
14137 (void *)&cmd_set_conntrack_common_max_ackwin,
14138 (void *)&cmd_set_conntrack_common_max_ackwin_value,
14139 (void *)&cmd_set_conntrack_common_retrans,
14140 (void *)&cmd_set_conntrack_common_retrans_value,
14141 (void *)&cmd_set_conntrack_common_last_win,
14142 (void *)&cmd_set_conntrack_common_last_win_value,
14143 (void *)&cmd_set_conntrack_common_last_seq,
14144 (void *)&cmd_set_conntrack_common_last_seq_value,
14145 (void *)&cmd_set_conntrack_common_last_ack,
14146 (void *)&cmd_set_conntrack_common_last_ack_value,
14147 (void *)&cmd_set_conntrack_common_last_end,
14148 (void *)&cmd_set_conntrack_common_last_end_value,
14149 (void *)&cmd_set_conntrack_common_last_index,
14150 (void *)&cmd_set_conntrack_common_last_index_value,
14155 /** Set connection tracking object both directions' details */
14156 struct cmd_set_conntrack_dir_result {
14157 cmdline_fixed_string_t set;
14158 cmdline_fixed_string_t conntrack;
14159 cmdline_fixed_string_t dir;
14160 cmdline_fixed_string_t scale;
14161 cmdline_fixed_string_t fin;
14162 cmdline_fixed_string_t ack_seen;
14163 cmdline_fixed_string_t unack;
14164 cmdline_fixed_string_t sent_end;
14165 cmdline_fixed_string_t reply_end;
14166 cmdline_fixed_string_t max_win;
14167 cmdline_fixed_string_t max_ack;
14178 cmdline_parse_token_string_t cmd_set_conntrack_dir_set =
14179 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14181 cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack =
14182 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14183 conntrack, "conntrack");
14184 cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
14185 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14187 cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
14188 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14190 cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
14191 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14192 factor, RTE_UINT32);
14193 cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
14194 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14196 cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
14197 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14199 cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
14200 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14201 ack_seen, "acked");
14202 cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
14203 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14205 cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
14206 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14207 unack, "unack_data");
14208 cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
14209 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14211 cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
14212 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14213 sent_end, "sent_end");
14214 cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
14215 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14217 cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
14218 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14219 reply_end, "reply_end");
14220 cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
14221 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14223 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
14224 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14225 max_win, "max_win");
14226 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
14227 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14229 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
14230 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14231 max_ack, "max_ack");
14232 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
14233 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14236 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
14237 __rte_unused struct cmdline *cl,
14238 __rte_unused void *data)
14240 struct cmd_set_conntrack_dir_result *res = parsed_result;
14241 struct rte_flow_tcp_dir_param *dir = NULL;
14243 if (strcmp(res->dir, "orig") == 0)
14244 dir = &conntrack_context.original_dir;
14245 else if (strcmp(res->dir, "rply") == 0)
14246 dir = &conntrack_context.reply_dir;
14249 dir->scale = res->factor;
14250 dir->close_initiated = res->f;
14251 dir->last_ack_seen = res->as;
14252 dir->data_unacked = res->un;
14253 dir->sent_end = res->se;
14254 dir->reply_end = res->re;
14255 dir->max_ack = res->ma;
14256 dir->max_win = res->mw;
14259 cmdline_parse_inst_t cmd_set_conntrack_dir = {
14260 .f = cmd_set_conntrack_dir_parsed,
14262 .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
14263 " acked <seen> unack_data <unack> sent_end <sent>"
14264 " reply_end <reply> max_win <win> max_ack <ack>",
14266 (void *)&cmd_set_conntrack_set,
14267 (void *)&cmd_set_conntrack_conntrack,
14268 (void *)&cmd_set_conntrack_dir_dir,
14269 (void *)&cmd_set_conntrack_dir_scale,
14270 (void *)&cmd_set_conntrack_dir_scale_value,
14271 (void *)&cmd_set_conntrack_dir_fin,
14272 (void *)&cmd_set_conntrack_dir_fin_value,
14273 (void *)&cmd_set_conntrack_dir_ack,
14274 (void *)&cmd_set_conntrack_dir_ack_value,
14275 (void *)&cmd_set_conntrack_dir_unack_data,
14276 (void *)&cmd_set_conntrack_dir_unack_data_value,
14277 (void *)&cmd_set_conntrack_dir_sent_end,
14278 (void *)&cmd_set_conntrack_dir_sent_end_value,
14279 (void *)&cmd_set_conntrack_dir_reply_end,
14280 (void *)&cmd_set_conntrack_dir_reply_end_value,
14281 (void *)&cmd_set_conntrack_dir_max_win,
14282 (void *)&cmd_set_conntrack_dir_max_win_value,
14283 (void *)&cmd_set_conntrack_dir_max_ack,
14284 (void *)&cmd_set_conntrack_dir_max_ack_value,
14289 /* Strict link priority scheduling mode setting */
14291 cmd_strict_link_prio_parsed(
14292 void *parsed_result,
14293 __rte_unused struct cmdline *cl,
14294 __rte_unused void *data)
14296 struct cmd_vf_tc_bw_result *res = parsed_result;
14297 int ret = -ENOTSUP;
14299 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14302 #ifdef RTE_NET_I40E
14303 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14310 fprintf(stderr, "invalid tc_bitmap 0x%x\n", res->tc_map);
14313 fprintf(stderr, "invalid port_id %d\n", res->port_id);
14316 fprintf(stderr, "function not implemented\n");
14319 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
14323 cmdline_parse_inst_t cmd_strict_link_prio = {
14324 .f = cmd_strict_link_prio_parsed,
14326 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14328 (void *)&cmd_vf_tc_bw_set,
14329 (void *)&cmd_vf_tc_bw_tx,
14330 (void *)&cmd_vf_tc_bw_strict_link_prio,
14331 (void *)&cmd_vf_tc_bw_port_id,
14332 (void *)&cmd_vf_tc_bw_tc_map,
14337 /* Load dynamic device personalization*/
14338 struct cmd_ddp_add_result {
14339 cmdline_fixed_string_t ddp;
14340 cmdline_fixed_string_t add;
14345 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14346 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14347 cmdline_parse_token_string_t cmd_ddp_add_add =
14348 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14349 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14350 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
14352 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14353 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14356 cmd_ddp_add_parsed(
14357 void *parsed_result,
14358 __rte_unused struct cmdline *cl,
14359 __rte_unused void *data)
14361 struct cmd_ddp_add_result *res = parsed_result;
14367 int ret = -ENOTSUP;
14369 if (!all_ports_stopped()) {
14370 fprintf(stderr, "Please stop all ports first\n");
14374 filepath = strdup(res->filepath);
14375 if (filepath == NULL) {
14376 fprintf(stderr, "Failed to allocate memory\n");
14379 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14381 buff = open_file(file_fld[0], &size);
14383 free((void *)filepath);
14387 #ifdef RTE_NET_I40E
14388 if (ret == -ENOTSUP)
14389 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14391 RTE_PMD_I40E_PKG_OP_WR_ADD);
14394 if (ret == -EEXIST)
14395 fprintf(stderr, "Profile has already existed.\n");
14397 fprintf(stderr, "Failed to load profile.\n");
14398 else if (file_num == 2)
14399 save_file(file_fld[1], buff, size);
14402 free((void *)filepath);
14405 cmdline_parse_inst_t cmd_ddp_add = {
14406 .f = cmd_ddp_add_parsed,
14408 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14410 (void *)&cmd_ddp_add_ddp,
14411 (void *)&cmd_ddp_add_add,
14412 (void *)&cmd_ddp_add_port_id,
14413 (void *)&cmd_ddp_add_filepath,
14418 /* Delete dynamic device personalization*/
14419 struct cmd_ddp_del_result {
14420 cmdline_fixed_string_t ddp;
14421 cmdline_fixed_string_t del;
14426 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14427 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14428 cmdline_parse_token_string_t cmd_ddp_del_del =
14429 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14430 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14431 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
14432 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14433 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14436 cmd_ddp_del_parsed(
14437 void *parsed_result,
14438 __rte_unused struct cmdline *cl,
14439 __rte_unused void *data)
14441 struct cmd_ddp_del_result *res = parsed_result;
14444 int ret = -ENOTSUP;
14446 if (!all_ports_stopped()) {
14447 fprintf(stderr, "Please stop all ports first\n");
14451 buff = open_file(res->filepath, &size);
14455 #ifdef RTE_NET_I40E
14456 if (ret == -ENOTSUP)
14457 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14459 RTE_PMD_I40E_PKG_OP_WR_DEL);
14462 if (ret == -EACCES)
14463 fprintf(stderr, "Profile does not exist.\n");
14465 fprintf(stderr, "Failed to delete profile.\n");
14470 cmdline_parse_inst_t cmd_ddp_del = {
14471 .f = cmd_ddp_del_parsed,
14473 .help_str = "ddp del <port_id> <backup_profile_path>",
14475 (void *)&cmd_ddp_del_ddp,
14476 (void *)&cmd_ddp_del_del,
14477 (void *)&cmd_ddp_del_port_id,
14478 (void *)&cmd_ddp_del_filepath,
14483 /* Get dynamic device personalization profile info */
14484 struct cmd_ddp_info_result {
14485 cmdline_fixed_string_t ddp;
14486 cmdline_fixed_string_t get;
14487 cmdline_fixed_string_t info;
14491 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14492 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14493 cmdline_parse_token_string_t cmd_ddp_info_get =
14494 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14495 cmdline_parse_token_string_t cmd_ddp_info_info =
14496 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14497 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14498 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14501 cmd_ddp_info_parsed(
14502 void *parsed_result,
14503 __rte_unused struct cmdline *cl,
14504 __rte_unused void *data)
14506 struct cmd_ddp_info_result *res = parsed_result;
14509 int ret = -ENOTSUP;
14510 #ifdef RTE_NET_I40E
14513 uint32_t buff_size = 0;
14514 struct rte_pmd_i40e_profile_info info;
14515 uint32_t dev_num = 0;
14516 struct rte_pmd_i40e_ddp_device_id *devs;
14517 uint32_t proto_num = 0;
14518 struct rte_pmd_i40e_proto_info *proto = NULL;
14519 uint32_t pctype_num = 0;
14520 struct rte_pmd_i40e_ptype_info *pctype;
14521 uint32_t ptype_num = 0;
14522 struct rte_pmd_i40e_ptype_info *ptype;
14527 pkg = open_file(res->filepath, &pkg_size);
14531 #ifdef RTE_NET_I40E
14532 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14533 (uint8_t *)&info, sizeof(info),
14534 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14536 printf("Global Track id: 0x%x\n", info.track_id);
14537 printf("Global Version: %d.%d.%d.%d\n",
14538 info.version.major,
14539 info.version.minor,
14540 info.version.update,
14541 info.version.draft);
14542 printf("Global Package name: %s\n\n", info.name);
14545 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14546 (uint8_t *)&info, sizeof(info),
14547 RTE_PMD_I40E_PKG_INFO_HEADER);
14549 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14550 printf("i40e Profile Version: %d.%d.%d.%d\n",
14551 info.version.major,
14552 info.version.minor,
14553 info.version.update,
14554 info.version.draft);
14555 printf("i40e Profile name: %s\n\n", info.name);
14558 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14559 (uint8_t *)&buff_size, sizeof(buff_size),
14560 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14561 if (!ret && buff_size) {
14562 buff = (uint8_t *)malloc(buff_size);
14564 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14566 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14568 printf("Package Notes:\n%s\n\n", buff);
14573 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14574 (uint8_t *)&dev_num, sizeof(dev_num),
14575 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14576 if (!ret && dev_num) {
14577 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14578 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14580 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14581 (uint8_t *)devs, buff_size,
14582 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14584 printf("List of supported devices:\n");
14585 for (i = 0; i < dev_num; i++) {
14586 printf(" %04X:%04X %04X:%04X\n",
14587 devs[i].vendor_dev_id >> 16,
14588 devs[i].vendor_dev_id & 0xFFFF,
14589 devs[i].sub_vendor_dev_id >> 16,
14590 devs[i].sub_vendor_dev_id & 0xFFFF);
14598 /* get information about protocols and packet types */
14599 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14600 (uint8_t *)&proto_num, sizeof(proto_num),
14601 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14602 if (ret || !proto_num)
14603 goto no_print_return;
14605 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14606 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14608 goto no_print_return;
14610 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14612 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14614 printf("List of used protocols:\n");
14615 for (i = 0; i < proto_num; i++)
14616 printf(" %2u: %s\n", proto[i].proto_id,
14620 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14621 (uint8_t *)&pctype_num, sizeof(pctype_num),
14622 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14623 if (ret || !pctype_num)
14624 goto no_print_pctypes;
14626 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14627 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14629 goto no_print_pctypes;
14631 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14633 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14636 goto no_print_pctypes;
14639 printf("List of defined packet classification types:\n");
14640 for (i = 0; i < pctype_num; i++) {
14641 printf(" %2u:", pctype[i].ptype_id);
14642 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14643 proto_id = pctype[i].protocols[j];
14644 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14645 for (n = 0; n < proto_num; n++) {
14646 if (proto[n].proto_id == proto_id) {
14647 printf(" %s", proto[n].name);
14660 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14662 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14663 if (ret || !ptype_num)
14664 goto no_print_return;
14666 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14667 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14669 goto no_print_return;
14671 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14673 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14676 goto no_print_return;
14678 printf("List of defined packet types:\n");
14679 for (i = 0; i < ptype_num; i++) {
14680 printf(" %2u:", ptype[i].ptype_id);
14681 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14682 proto_id = ptype[i].protocols[j];
14683 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14684 for (n = 0; n < proto_num; n++) {
14685 if (proto[n].proto_id == proto_id) {
14686 printf(" %s", proto[n].name);
14702 if (ret == -ENOTSUP)
14703 fprintf(stderr, "Function not supported in PMD\n");
14707 cmdline_parse_inst_t cmd_ddp_get_info = {
14708 .f = cmd_ddp_info_parsed,
14710 .help_str = "ddp get info <profile_path>",
14712 (void *)&cmd_ddp_info_ddp,
14713 (void *)&cmd_ddp_info_get,
14714 (void *)&cmd_ddp_info_info,
14715 (void *)&cmd_ddp_info_filepath,
14720 /* Get dynamic device personalization profile info list*/
14721 #define PROFILE_INFO_SIZE 48
14722 #define MAX_PROFILE_NUM 16
14724 struct cmd_ddp_get_list_result {
14725 cmdline_fixed_string_t ddp;
14726 cmdline_fixed_string_t get;
14727 cmdline_fixed_string_t list;
14731 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14732 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14733 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14734 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14735 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14736 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14737 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14738 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14742 cmd_ddp_get_list_parsed(
14743 __rte_unused void *parsed_result,
14744 __rte_unused struct cmdline *cl,
14745 __rte_unused void *data)
14747 #ifdef RTE_NET_I40E
14748 struct cmd_ddp_get_list_result *res = parsed_result;
14749 struct rte_pmd_i40e_profile_list *p_list;
14750 struct rte_pmd_i40e_profile_info *p_info;
14755 int ret = -ENOTSUP;
14757 #ifdef RTE_NET_I40E
14758 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14759 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14761 fprintf(stderr, "%s: Failed to malloc buffer\n", __func__);
14765 if (ret == -ENOTSUP)
14766 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14767 (uint8_t *)p_list, size);
14770 p_num = p_list->p_count;
14771 printf("Profile number is: %d\n\n", p_num);
14773 for (i = 0; i < p_num; i++) {
14774 p_info = &p_list->p_info[i];
14775 printf("Profile %d:\n", i);
14776 printf("Track id: 0x%x\n", p_info->track_id);
14777 printf("Version: %d.%d.%d.%d\n",
14778 p_info->version.major,
14779 p_info->version.minor,
14780 p_info->version.update,
14781 p_info->version.draft);
14782 printf("Profile name: %s\n\n", p_info->name);
14790 fprintf(stderr, "Failed to get ddp list\n");
14793 cmdline_parse_inst_t cmd_ddp_get_list = {
14794 .f = cmd_ddp_get_list_parsed,
14796 .help_str = "ddp get list <port_id>",
14798 (void *)&cmd_ddp_get_list_ddp,
14799 (void *)&cmd_ddp_get_list_get,
14800 (void *)&cmd_ddp_get_list_list,
14801 (void *)&cmd_ddp_get_list_port_id,
14806 /* Configure input set */
14807 struct cmd_cfg_input_set_result {
14808 cmdline_fixed_string_t port;
14809 cmdline_fixed_string_t cfg;
14811 cmdline_fixed_string_t pctype;
14813 cmdline_fixed_string_t inset_type;
14814 cmdline_fixed_string_t opt;
14815 cmdline_fixed_string_t field;
14820 cmd_cfg_input_set_parsed(
14821 __rte_unused void *parsed_result,
14822 __rte_unused struct cmdline *cl,
14823 __rte_unused void *data)
14825 #ifdef RTE_NET_I40E
14826 struct cmd_cfg_input_set_result *res = parsed_result;
14827 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14828 struct rte_pmd_i40e_inset inset;
14830 int ret = -ENOTSUP;
14832 if (!all_ports_stopped()) {
14833 fprintf(stderr, "Please stop all ports first\n");
14837 #ifdef RTE_NET_I40E
14838 if (!strcmp(res->inset_type, "hash_inset"))
14839 inset_type = INSET_HASH;
14840 else if (!strcmp(res->inset_type, "fdir_inset"))
14841 inset_type = INSET_FDIR;
14842 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14843 inset_type = INSET_FDIR_FLX;
14844 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14845 &inset, inset_type);
14847 fprintf(stderr, "Failed to get input set.\n");
14851 if (!strcmp(res->opt, "get")) {
14852 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14855 printf("Field index %d is enabled.\n", res->field_idx);
14857 printf("Field index %d is disabled.\n", res->field_idx);
14859 } else if (!strcmp(res->opt, "set"))
14860 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14862 else if (!strcmp(res->opt, "clear"))
14863 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14866 fprintf(stderr, "Failed to configure input set field.\n");
14870 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14871 &inset, inset_type);
14873 fprintf(stderr, "Failed to set input set.\n");
14878 if (ret == -ENOTSUP)
14879 fprintf(stderr, "Function not supported\n");
14882 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14883 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14885 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14886 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14888 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14889 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14890 port_id, RTE_UINT16);
14891 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14892 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14894 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14895 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14896 pctype_id, RTE_UINT8);
14897 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14898 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14900 "hash_inset#fdir_inset#fdir_flx_inset");
14901 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14902 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14903 opt, "get#set#clear");
14904 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14905 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14907 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14908 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14909 field_idx, RTE_UINT8);
14911 cmdline_parse_inst_t cmd_cfg_input_set = {
14912 .f = cmd_cfg_input_set_parsed,
14914 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14915 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
14917 (void *)&cmd_cfg_input_set_port,
14918 (void *)&cmd_cfg_input_set_cfg,
14919 (void *)&cmd_cfg_input_set_port_id,
14920 (void *)&cmd_cfg_input_set_pctype,
14921 (void *)&cmd_cfg_input_set_pctype_id,
14922 (void *)&cmd_cfg_input_set_inset_type,
14923 (void *)&cmd_cfg_input_set_opt,
14924 (void *)&cmd_cfg_input_set_field,
14925 (void *)&cmd_cfg_input_set_field_idx,
14930 /* Clear input set */
14931 struct cmd_clear_input_set_result {
14932 cmdline_fixed_string_t port;
14933 cmdline_fixed_string_t cfg;
14935 cmdline_fixed_string_t pctype;
14937 cmdline_fixed_string_t inset_type;
14938 cmdline_fixed_string_t clear;
14939 cmdline_fixed_string_t all;
14943 cmd_clear_input_set_parsed(
14944 __rte_unused void *parsed_result,
14945 __rte_unused struct cmdline *cl,
14946 __rte_unused void *data)
14948 #ifdef RTE_NET_I40E
14949 struct cmd_clear_input_set_result *res = parsed_result;
14950 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14951 struct rte_pmd_i40e_inset inset;
14953 int ret = -ENOTSUP;
14955 if (!all_ports_stopped()) {
14956 fprintf(stderr, "Please stop all ports first\n");
14960 #ifdef RTE_NET_I40E
14961 if (!strcmp(res->inset_type, "hash_inset"))
14962 inset_type = INSET_HASH;
14963 else if (!strcmp(res->inset_type, "fdir_inset"))
14964 inset_type = INSET_FDIR;
14965 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14966 inset_type = INSET_FDIR_FLX;
14968 memset(&inset, 0, sizeof(inset));
14970 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14971 &inset, inset_type);
14973 fprintf(stderr, "Failed to clear input set.\n");
14979 if (ret == -ENOTSUP)
14980 fprintf(stderr, "Function not supported\n");
14983 cmdline_parse_token_string_t cmd_clear_input_set_port =
14984 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14986 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
14987 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14989 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
14990 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14991 port_id, RTE_UINT16);
14992 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
14993 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14995 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
14996 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14997 pctype_id, RTE_UINT8);
14998 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
14999 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15001 "hash_inset#fdir_inset#fdir_flx_inset");
15002 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15003 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15005 cmdline_parse_token_string_t cmd_clear_input_set_all =
15006 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15009 cmdline_parse_inst_t cmd_clear_input_set = {
15010 .f = cmd_clear_input_set_parsed,
15012 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15013 "fdir_inset|fdir_flx_inset clear all",
15015 (void *)&cmd_clear_input_set_port,
15016 (void *)&cmd_clear_input_set_cfg,
15017 (void *)&cmd_clear_input_set_port_id,
15018 (void *)&cmd_clear_input_set_pctype,
15019 (void *)&cmd_clear_input_set_pctype_id,
15020 (void *)&cmd_clear_input_set_inset_type,
15021 (void *)&cmd_clear_input_set_clear,
15022 (void *)&cmd_clear_input_set_all,
15027 /* show vf stats */
15029 /* Common result structure for show vf stats */
15030 struct cmd_show_vf_stats_result {
15031 cmdline_fixed_string_t show;
15032 cmdline_fixed_string_t vf;
15033 cmdline_fixed_string_t stats;
15038 /* Common CLI fields show vf stats*/
15039 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15040 TOKEN_STRING_INITIALIZER
15041 (struct cmd_show_vf_stats_result,
15043 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15044 TOKEN_STRING_INITIALIZER
15045 (struct cmd_show_vf_stats_result,
15047 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15048 TOKEN_STRING_INITIALIZER
15049 (struct cmd_show_vf_stats_result,
15051 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15052 TOKEN_NUM_INITIALIZER
15053 (struct cmd_show_vf_stats_result,
15054 port_id, RTE_UINT16);
15055 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15056 TOKEN_NUM_INITIALIZER
15057 (struct cmd_show_vf_stats_result,
15058 vf_id, RTE_UINT16);
15061 cmd_show_vf_stats_parsed(
15062 void *parsed_result,
15063 __rte_unused struct cmdline *cl,
15064 __rte_unused void *data)
15066 struct cmd_show_vf_stats_result *res = parsed_result;
15067 struct rte_eth_stats stats;
15068 int ret = -ENOTSUP;
15069 static const char *nic_stats_border = "########################";
15071 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15074 memset(&stats, 0, sizeof(stats));
15076 #ifdef RTE_NET_I40E
15077 if (ret == -ENOTSUP)
15078 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15082 #ifdef RTE_NET_BNXT
15083 if (ret == -ENOTSUP)
15084 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15093 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15096 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15099 fprintf(stderr, "function not implemented\n");
15102 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15105 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15106 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15108 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15110 stats.ipackets, stats.imissed, stats.ibytes);
15111 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15112 printf(" RX-nombuf: %-10"PRIu64"\n",
15114 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15116 stats.opackets, stats.oerrors, stats.obytes);
15118 printf(" %s############################%s\n",
15119 nic_stats_border, nic_stats_border);
15122 cmdline_parse_inst_t cmd_show_vf_stats = {
15123 .f = cmd_show_vf_stats_parsed,
15125 .help_str = "show vf stats <port_id> <vf_id>",
15127 (void *)&cmd_show_vf_stats_show,
15128 (void *)&cmd_show_vf_stats_vf,
15129 (void *)&cmd_show_vf_stats_stats,
15130 (void *)&cmd_show_vf_stats_port_id,
15131 (void *)&cmd_show_vf_stats_vf_id,
15136 /* clear vf stats */
15138 /* Common result structure for clear vf stats */
15139 struct cmd_clear_vf_stats_result {
15140 cmdline_fixed_string_t clear;
15141 cmdline_fixed_string_t vf;
15142 cmdline_fixed_string_t stats;
15147 /* Common CLI fields clear vf stats*/
15148 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15149 TOKEN_STRING_INITIALIZER
15150 (struct cmd_clear_vf_stats_result,
15152 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15153 TOKEN_STRING_INITIALIZER
15154 (struct cmd_clear_vf_stats_result,
15156 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15157 TOKEN_STRING_INITIALIZER
15158 (struct cmd_clear_vf_stats_result,
15160 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15161 TOKEN_NUM_INITIALIZER
15162 (struct cmd_clear_vf_stats_result,
15163 port_id, RTE_UINT16);
15164 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15165 TOKEN_NUM_INITIALIZER
15166 (struct cmd_clear_vf_stats_result,
15167 vf_id, RTE_UINT16);
15170 cmd_clear_vf_stats_parsed(
15171 void *parsed_result,
15172 __rte_unused struct cmdline *cl,
15173 __rte_unused void *data)
15175 struct cmd_clear_vf_stats_result *res = parsed_result;
15176 int ret = -ENOTSUP;
15178 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15181 #ifdef RTE_NET_I40E
15182 if (ret == -ENOTSUP)
15183 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15186 #ifdef RTE_NET_BNXT
15187 if (ret == -ENOTSUP)
15188 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15196 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15199 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15202 fprintf(stderr, "function not implemented\n");
15205 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15209 cmdline_parse_inst_t cmd_clear_vf_stats = {
15210 .f = cmd_clear_vf_stats_parsed,
15212 .help_str = "clear vf stats <port_id> <vf_id>",
15214 (void *)&cmd_clear_vf_stats_clear,
15215 (void *)&cmd_clear_vf_stats_vf,
15216 (void *)&cmd_clear_vf_stats_stats,
15217 (void *)&cmd_clear_vf_stats_port_id,
15218 (void *)&cmd_clear_vf_stats_vf_id,
15223 /* port config pctype mapping reset */
15225 /* Common result structure for port config pctype mapping reset */
15226 struct cmd_pctype_mapping_reset_result {
15227 cmdline_fixed_string_t port;
15228 cmdline_fixed_string_t config;
15230 cmdline_fixed_string_t pctype;
15231 cmdline_fixed_string_t mapping;
15232 cmdline_fixed_string_t reset;
15235 /* Common CLI fields for port config pctype mapping reset*/
15236 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15237 TOKEN_STRING_INITIALIZER
15238 (struct cmd_pctype_mapping_reset_result,
15240 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15241 TOKEN_STRING_INITIALIZER
15242 (struct cmd_pctype_mapping_reset_result,
15244 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15245 TOKEN_NUM_INITIALIZER
15246 (struct cmd_pctype_mapping_reset_result,
15247 port_id, RTE_UINT16);
15248 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15249 TOKEN_STRING_INITIALIZER
15250 (struct cmd_pctype_mapping_reset_result,
15252 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15253 TOKEN_STRING_INITIALIZER
15254 (struct cmd_pctype_mapping_reset_result,
15255 mapping, "mapping");
15256 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15257 TOKEN_STRING_INITIALIZER
15258 (struct cmd_pctype_mapping_reset_result,
15262 cmd_pctype_mapping_reset_parsed(
15263 void *parsed_result,
15264 __rte_unused struct cmdline *cl,
15265 __rte_unused void *data)
15267 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15268 int ret = -ENOTSUP;
15270 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15273 #ifdef RTE_NET_I40E
15274 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15281 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15284 fprintf(stderr, "function not implemented\n");
15287 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15291 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15292 .f = cmd_pctype_mapping_reset_parsed,
15294 .help_str = "port config <port_id> pctype mapping reset",
15296 (void *)&cmd_pctype_mapping_reset_port,
15297 (void *)&cmd_pctype_mapping_reset_config,
15298 (void *)&cmd_pctype_mapping_reset_port_id,
15299 (void *)&cmd_pctype_mapping_reset_pctype,
15300 (void *)&cmd_pctype_mapping_reset_mapping,
15301 (void *)&cmd_pctype_mapping_reset_reset,
15306 /* show port pctype mapping */
15308 /* Common result structure for show port pctype mapping */
15309 struct cmd_pctype_mapping_get_result {
15310 cmdline_fixed_string_t show;
15311 cmdline_fixed_string_t port;
15313 cmdline_fixed_string_t pctype;
15314 cmdline_fixed_string_t mapping;
15317 /* Common CLI fields for pctype mapping get */
15318 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15319 TOKEN_STRING_INITIALIZER
15320 (struct cmd_pctype_mapping_get_result,
15322 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15323 TOKEN_STRING_INITIALIZER
15324 (struct cmd_pctype_mapping_get_result,
15326 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15327 TOKEN_NUM_INITIALIZER
15328 (struct cmd_pctype_mapping_get_result,
15329 port_id, RTE_UINT16);
15330 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15331 TOKEN_STRING_INITIALIZER
15332 (struct cmd_pctype_mapping_get_result,
15334 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15335 TOKEN_STRING_INITIALIZER
15336 (struct cmd_pctype_mapping_get_result,
15337 mapping, "mapping");
15340 cmd_pctype_mapping_get_parsed(
15341 void *parsed_result,
15342 __rte_unused struct cmdline *cl,
15343 __rte_unused void *data)
15345 struct cmd_pctype_mapping_get_result *res = parsed_result;
15346 int ret = -ENOTSUP;
15347 #ifdef RTE_NET_I40E
15348 struct rte_pmd_i40e_flow_type_mapping
15349 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15350 int i, j, first_pctype;
15353 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15356 #ifdef RTE_NET_I40E
15357 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15364 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15367 fprintf(stderr, "function not implemented\n");
15370 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15374 #ifdef RTE_NET_I40E
15375 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15376 if (mapping[i].pctype != 0ULL) {
15379 printf("pctype: ");
15380 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15381 if (mapping[i].pctype & (1ULL << j)) {
15382 printf(first_pctype ?
15383 "%02d" : ",%02d", j);
15387 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15393 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15394 .f = cmd_pctype_mapping_get_parsed,
15396 .help_str = "show port <port_id> pctype mapping",
15398 (void *)&cmd_pctype_mapping_get_show,
15399 (void *)&cmd_pctype_mapping_get_port,
15400 (void *)&cmd_pctype_mapping_get_port_id,
15401 (void *)&cmd_pctype_mapping_get_pctype,
15402 (void *)&cmd_pctype_mapping_get_mapping,
15407 /* port config pctype mapping update */
15409 /* Common result structure for port config pctype mapping update */
15410 struct cmd_pctype_mapping_update_result {
15411 cmdline_fixed_string_t port;
15412 cmdline_fixed_string_t config;
15414 cmdline_fixed_string_t pctype;
15415 cmdline_fixed_string_t mapping;
15416 cmdline_fixed_string_t update;
15417 cmdline_fixed_string_t pctype_list;
15418 uint16_t flow_type;
15421 /* Common CLI fields for pctype mapping update*/
15422 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15423 TOKEN_STRING_INITIALIZER
15424 (struct cmd_pctype_mapping_update_result,
15426 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15427 TOKEN_STRING_INITIALIZER
15428 (struct cmd_pctype_mapping_update_result,
15430 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15431 TOKEN_NUM_INITIALIZER
15432 (struct cmd_pctype_mapping_update_result,
15433 port_id, RTE_UINT16);
15434 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15435 TOKEN_STRING_INITIALIZER
15436 (struct cmd_pctype_mapping_update_result,
15438 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15439 TOKEN_STRING_INITIALIZER
15440 (struct cmd_pctype_mapping_update_result,
15441 mapping, "mapping");
15442 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15443 TOKEN_STRING_INITIALIZER
15444 (struct cmd_pctype_mapping_update_result,
15446 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15447 TOKEN_STRING_INITIALIZER
15448 (struct cmd_pctype_mapping_update_result,
15449 pctype_list, NULL);
15450 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15451 TOKEN_NUM_INITIALIZER
15452 (struct cmd_pctype_mapping_update_result,
15453 flow_type, RTE_UINT16);
15456 cmd_pctype_mapping_update_parsed(
15457 void *parsed_result,
15458 __rte_unused struct cmdline *cl,
15459 __rte_unused void *data)
15461 struct cmd_pctype_mapping_update_result *res = parsed_result;
15462 int ret = -ENOTSUP;
15463 #ifdef RTE_NET_I40E
15464 struct rte_pmd_i40e_flow_type_mapping mapping;
15466 unsigned int nb_item;
15467 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15470 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15473 #ifdef RTE_NET_I40E
15474 nb_item = parse_item_list(res->pctype_list, "pctypes",
15475 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15476 mapping.flow_type = res->flow_type;
15477 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15478 mapping.pctype |= (1ULL << pctype_list[i]);
15479 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15489 fprintf(stderr, "invalid pctype or flow type\n");
15492 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15495 fprintf(stderr, "function not implemented\n");
15498 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15502 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15503 .f = cmd_pctype_mapping_update_parsed,
15505 .help_str = "port config <port_id> pctype mapping update"
15506 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15508 (void *)&cmd_pctype_mapping_update_port,
15509 (void *)&cmd_pctype_mapping_update_config,
15510 (void *)&cmd_pctype_mapping_update_port_id,
15511 (void *)&cmd_pctype_mapping_update_pctype,
15512 (void *)&cmd_pctype_mapping_update_mapping,
15513 (void *)&cmd_pctype_mapping_update_update,
15514 (void *)&cmd_pctype_mapping_update_pc_type,
15515 (void *)&cmd_pctype_mapping_update_flow_type,
15520 /* ptype mapping get */
15522 /* Common result structure for ptype mapping get */
15523 struct cmd_ptype_mapping_get_result {
15524 cmdline_fixed_string_t ptype;
15525 cmdline_fixed_string_t mapping;
15526 cmdline_fixed_string_t get;
15528 uint8_t valid_only;
15531 /* Common CLI fields for ptype mapping get */
15532 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15533 TOKEN_STRING_INITIALIZER
15534 (struct cmd_ptype_mapping_get_result,
15536 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15537 TOKEN_STRING_INITIALIZER
15538 (struct cmd_ptype_mapping_get_result,
15539 mapping, "mapping");
15540 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15541 TOKEN_STRING_INITIALIZER
15542 (struct cmd_ptype_mapping_get_result,
15544 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15545 TOKEN_NUM_INITIALIZER
15546 (struct cmd_ptype_mapping_get_result,
15547 port_id, RTE_UINT16);
15548 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15549 TOKEN_NUM_INITIALIZER
15550 (struct cmd_ptype_mapping_get_result,
15551 valid_only, RTE_UINT8);
15554 cmd_ptype_mapping_get_parsed(
15555 void *parsed_result,
15556 __rte_unused struct cmdline *cl,
15557 __rte_unused void *data)
15559 struct cmd_ptype_mapping_get_result *res = parsed_result;
15560 int ret = -ENOTSUP;
15561 #ifdef RTE_NET_I40E
15562 int max_ptype_num = 256;
15563 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15568 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15571 #ifdef RTE_NET_I40E
15572 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15583 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15586 fprintf(stderr, "function not implemented\n");
15589 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15592 #ifdef RTE_NET_I40E
15594 for (i = 0; i < count; i++)
15595 printf("%3d\t0x%08x\n",
15596 mapping[i].hw_ptype, mapping[i].sw_ptype);
15601 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15602 .f = cmd_ptype_mapping_get_parsed,
15604 .help_str = "ptype mapping get <port_id> <valid_only>",
15606 (void *)&cmd_ptype_mapping_get_ptype,
15607 (void *)&cmd_ptype_mapping_get_mapping,
15608 (void *)&cmd_ptype_mapping_get_get,
15609 (void *)&cmd_ptype_mapping_get_port_id,
15610 (void *)&cmd_ptype_mapping_get_valid_only,
15615 /* ptype mapping replace */
15617 /* Common result structure for ptype mapping replace */
15618 struct cmd_ptype_mapping_replace_result {
15619 cmdline_fixed_string_t ptype;
15620 cmdline_fixed_string_t mapping;
15621 cmdline_fixed_string_t replace;
15628 /* Common CLI fields for ptype mapping replace */
15629 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15630 TOKEN_STRING_INITIALIZER
15631 (struct cmd_ptype_mapping_replace_result,
15633 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15634 TOKEN_STRING_INITIALIZER
15635 (struct cmd_ptype_mapping_replace_result,
15636 mapping, "mapping");
15637 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15638 TOKEN_STRING_INITIALIZER
15639 (struct cmd_ptype_mapping_replace_result,
15640 replace, "replace");
15641 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15642 TOKEN_NUM_INITIALIZER
15643 (struct cmd_ptype_mapping_replace_result,
15644 port_id, RTE_UINT16);
15645 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15646 TOKEN_NUM_INITIALIZER
15647 (struct cmd_ptype_mapping_replace_result,
15648 target, RTE_UINT32);
15649 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15650 TOKEN_NUM_INITIALIZER
15651 (struct cmd_ptype_mapping_replace_result,
15653 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15654 TOKEN_NUM_INITIALIZER
15655 (struct cmd_ptype_mapping_replace_result,
15656 pkt_type, RTE_UINT32);
15659 cmd_ptype_mapping_replace_parsed(
15660 void *parsed_result,
15661 __rte_unused struct cmdline *cl,
15662 __rte_unused void *data)
15664 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15665 int ret = -ENOTSUP;
15667 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15670 #ifdef RTE_NET_I40E
15671 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15681 fprintf(stderr, "invalid ptype 0x%8x or 0x%8x\n",
15682 res->target, res->pkt_type);
15685 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15688 fprintf(stderr, "function not implemented\n");
15691 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15695 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15696 .f = cmd_ptype_mapping_replace_parsed,
15699 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15701 (void *)&cmd_ptype_mapping_replace_ptype,
15702 (void *)&cmd_ptype_mapping_replace_mapping,
15703 (void *)&cmd_ptype_mapping_replace_replace,
15704 (void *)&cmd_ptype_mapping_replace_port_id,
15705 (void *)&cmd_ptype_mapping_replace_target,
15706 (void *)&cmd_ptype_mapping_replace_mask,
15707 (void *)&cmd_ptype_mapping_replace_pkt_type,
15712 /* ptype mapping reset */
15714 /* Common result structure for ptype mapping reset */
15715 struct cmd_ptype_mapping_reset_result {
15716 cmdline_fixed_string_t ptype;
15717 cmdline_fixed_string_t mapping;
15718 cmdline_fixed_string_t reset;
15722 /* Common CLI fields for ptype mapping reset*/
15723 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15724 TOKEN_STRING_INITIALIZER
15725 (struct cmd_ptype_mapping_reset_result,
15727 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15728 TOKEN_STRING_INITIALIZER
15729 (struct cmd_ptype_mapping_reset_result,
15730 mapping, "mapping");
15731 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15732 TOKEN_STRING_INITIALIZER
15733 (struct cmd_ptype_mapping_reset_result,
15735 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15736 TOKEN_NUM_INITIALIZER
15737 (struct cmd_ptype_mapping_reset_result,
15738 port_id, RTE_UINT16);
15741 cmd_ptype_mapping_reset_parsed(
15742 void *parsed_result,
15743 __rte_unused struct cmdline *cl,
15744 __rte_unused void *data)
15746 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15747 int ret = -ENOTSUP;
15749 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15752 #ifdef RTE_NET_I40E
15753 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15760 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15763 fprintf(stderr, "function not implemented\n");
15766 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15770 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15771 .f = cmd_ptype_mapping_reset_parsed,
15773 .help_str = "ptype mapping reset <port_id>",
15775 (void *)&cmd_ptype_mapping_reset_ptype,
15776 (void *)&cmd_ptype_mapping_reset_mapping,
15777 (void *)&cmd_ptype_mapping_reset_reset,
15778 (void *)&cmd_ptype_mapping_reset_port_id,
15783 /* ptype mapping update */
15785 /* Common result structure for ptype mapping update */
15786 struct cmd_ptype_mapping_update_result {
15787 cmdline_fixed_string_t ptype;
15788 cmdline_fixed_string_t mapping;
15789 cmdline_fixed_string_t reset;
15795 /* Common CLI fields for ptype mapping update*/
15796 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15797 TOKEN_STRING_INITIALIZER
15798 (struct cmd_ptype_mapping_update_result,
15800 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15801 TOKEN_STRING_INITIALIZER
15802 (struct cmd_ptype_mapping_update_result,
15803 mapping, "mapping");
15804 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15805 TOKEN_STRING_INITIALIZER
15806 (struct cmd_ptype_mapping_update_result,
15808 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15809 TOKEN_NUM_INITIALIZER
15810 (struct cmd_ptype_mapping_update_result,
15811 port_id, RTE_UINT16);
15812 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15813 TOKEN_NUM_INITIALIZER
15814 (struct cmd_ptype_mapping_update_result,
15815 hw_ptype, RTE_UINT8);
15816 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15817 TOKEN_NUM_INITIALIZER
15818 (struct cmd_ptype_mapping_update_result,
15819 sw_ptype, RTE_UINT32);
15822 cmd_ptype_mapping_update_parsed(
15823 void *parsed_result,
15824 __rte_unused struct cmdline *cl,
15825 __rte_unused void *data)
15827 struct cmd_ptype_mapping_update_result *res = parsed_result;
15828 int ret = -ENOTSUP;
15829 #ifdef RTE_NET_I40E
15830 struct rte_pmd_i40e_ptype_mapping mapping;
15832 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15835 #ifdef RTE_NET_I40E
15836 mapping.hw_ptype = res->hw_ptype;
15837 mapping.sw_ptype = res->sw_ptype;
15838 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15848 fprintf(stderr, "invalid ptype 0x%8x\n", res->sw_ptype);
15851 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15854 fprintf(stderr, "function not implemented\n");
15857 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15861 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15862 .f = cmd_ptype_mapping_update_parsed,
15864 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15866 (void *)&cmd_ptype_mapping_update_ptype,
15867 (void *)&cmd_ptype_mapping_update_mapping,
15868 (void *)&cmd_ptype_mapping_update_update,
15869 (void *)&cmd_ptype_mapping_update_port_id,
15870 (void *)&cmd_ptype_mapping_update_hw_ptype,
15871 (void *)&cmd_ptype_mapping_update_sw_ptype,
15876 /* Common result structure for file commands */
15877 struct cmd_cmdfile_result {
15878 cmdline_fixed_string_t load;
15879 cmdline_fixed_string_t filename;
15882 /* Common CLI fields for file commands */
15883 cmdline_parse_token_string_t cmd_load_cmdfile =
15884 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15885 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15886 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15889 cmd_load_from_file_parsed(
15890 void *parsed_result,
15891 __rte_unused struct cmdline *cl,
15892 __rte_unused void *data)
15894 struct cmd_cmdfile_result *res = parsed_result;
15896 cmdline_read_from_file(res->filename);
15899 cmdline_parse_inst_t cmd_load_from_file = {
15900 .f = cmd_load_from_file_parsed,
15902 .help_str = "load <filename>",
15904 (void *)&cmd_load_cmdfile,
15905 (void *)&cmd_load_cmdfile_filename,
15910 /* Get Rx offloads capabilities */
15911 struct cmd_rx_offload_get_capa_result {
15912 cmdline_fixed_string_t show;
15913 cmdline_fixed_string_t port;
15915 cmdline_fixed_string_t rx_offload;
15916 cmdline_fixed_string_t capabilities;
15919 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
15920 TOKEN_STRING_INITIALIZER
15921 (struct cmd_rx_offload_get_capa_result,
15923 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
15924 TOKEN_STRING_INITIALIZER
15925 (struct cmd_rx_offload_get_capa_result,
15927 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
15928 TOKEN_NUM_INITIALIZER
15929 (struct cmd_rx_offload_get_capa_result,
15930 port_id, RTE_UINT16);
15931 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
15932 TOKEN_STRING_INITIALIZER
15933 (struct cmd_rx_offload_get_capa_result,
15934 rx_offload, "rx_offload");
15935 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
15936 TOKEN_STRING_INITIALIZER
15937 (struct cmd_rx_offload_get_capa_result,
15938 capabilities, "capabilities");
15941 print_rx_offloads(uint64_t offloads)
15943 uint64_t single_offload;
15951 begin = __builtin_ctzll(offloads);
15952 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15954 single_offload = 1ULL << begin;
15955 for (bit = begin; bit < end; bit++) {
15956 if (offloads & single_offload)
15958 rte_eth_dev_rx_offload_name(single_offload));
15959 single_offload <<= 1;
15964 cmd_rx_offload_get_capa_parsed(
15965 void *parsed_result,
15966 __rte_unused struct cmdline *cl,
15967 __rte_unused void *data)
15969 struct cmd_rx_offload_get_capa_result *res = parsed_result;
15970 struct rte_eth_dev_info dev_info;
15971 portid_t port_id = res->port_id;
15972 uint64_t queue_offloads;
15973 uint64_t port_offloads;
15976 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15980 queue_offloads = dev_info.rx_queue_offload_capa;
15981 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
15983 printf("Rx Offloading Capabilities of port %d :\n", port_id);
15984 printf(" Per Queue :");
15985 print_rx_offloads(queue_offloads);
15988 printf(" Per Port :");
15989 print_rx_offloads(port_offloads);
15993 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
15994 .f = cmd_rx_offload_get_capa_parsed,
15996 .help_str = "show port <port_id> rx_offload capabilities",
15998 (void *)&cmd_rx_offload_get_capa_show,
15999 (void *)&cmd_rx_offload_get_capa_port,
16000 (void *)&cmd_rx_offload_get_capa_port_id,
16001 (void *)&cmd_rx_offload_get_capa_rx_offload,
16002 (void *)&cmd_rx_offload_get_capa_capabilities,
16007 /* Get Rx offloads configuration */
16008 struct cmd_rx_offload_get_configuration_result {
16009 cmdline_fixed_string_t show;
16010 cmdline_fixed_string_t port;
16012 cmdline_fixed_string_t rx_offload;
16013 cmdline_fixed_string_t configuration;
16016 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
16017 TOKEN_STRING_INITIALIZER
16018 (struct cmd_rx_offload_get_configuration_result,
16020 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
16021 TOKEN_STRING_INITIALIZER
16022 (struct cmd_rx_offload_get_configuration_result,
16024 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
16025 TOKEN_NUM_INITIALIZER
16026 (struct cmd_rx_offload_get_configuration_result,
16027 port_id, RTE_UINT16);
16028 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
16029 TOKEN_STRING_INITIALIZER
16030 (struct cmd_rx_offload_get_configuration_result,
16031 rx_offload, "rx_offload");
16032 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
16033 TOKEN_STRING_INITIALIZER
16034 (struct cmd_rx_offload_get_configuration_result,
16035 configuration, "configuration");
16038 cmd_rx_offload_get_configuration_parsed(
16039 void *parsed_result,
16040 __rte_unused struct cmdline *cl,
16041 __rte_unused void *data)
16043 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
16044 struct rte_eth_dev_info dev_info;
16045 portid_t port_id = res->port_id;
16046 struct rte_port *port = &ports[port_id];
16047 struct rte_eth_conf dev_conf;
16048 uint64_t port_offloads;
16049 uint64_t queue_offloads;
16050 uint16_t nb_rx_queues;
16054 printf("Rx Offloading Configuration of port %d :\n", port_id);
16056 ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
16060 port_offloads = dev_conf.rxmode.offloads;
16062 print_rx_offloads(port_offloads);
16065 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16069 nb_rx_queues = dev_info.nb_rx_queues;
16070 for (q = 0; q < nb_rx_queues; q++) {
16071 queue_offloads = port->rx_conf[q].offloads;
16072 printf(" Queue[%2d] :", q);
16073 print_rx_offloads(queue_offloads);
16079 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
16080 .f = cmd_rx_offload_get_configuration_parsed,
16082 .help_str = "show port <port_id> rx_offload configuration",
16084 (void *)&cmd_rx_offload_get_configuration_show,
16085 (void *)&cmd_rx_offload_get_configuration_port,
16086 (void *)&cmd_rx_offload_get_configuration_port_id,
16087 (void *)&cmd_rx_offload_get_configuration_rx_offload,
16088 (void *)&cmd_rx_offload_get_configuration_configuration,
16093 /* Enable/Disable a per port offloading */
16094 struct cmd_config_per_port_rx_offload_result {
16095 cmdline_fixed_string_t port;
16096 cmdline_fixed_string_t config;
16098 cmdline_fixed_string_t rx_offload;
16099 cmdline_fixed_string_t offload;
16100 cmdline_fixed_string_t on_off;
16103 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
16104 TOKEN_STRING_INITIALIZER
16105 (struct cmd_config_per_port_rx_offload_result,
16107 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
16108 TOKEN_STRING_INITIALIZER
16109 (struct cmd_config_per_port_rx_offload_result,
16111 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
16112 TOKEN_NUM_INITIALIZER
16113 (struct cmd_config_per_port_rx_offload_result,
16114 port_id, RTE_UINT16);
16115 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
16116 TOKEN_STRING_INITIALIZER
16117 (struct cmd_config_per_port_rx_offload_result,
16118 rx_offload, "rx_offload");
16119 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
16120 TOKEN_STRING_INITIALIZER
16121 (struct cmd_config_per_port_rx_offload_result,
16122 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16123 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16124 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16125 "scatter#buffer_split#timestamp#security#"
16126 "keep_crc#rss_hash");
16127 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
16128 TOKEN_STRING_INITIALIZER
16129 (struct cmd_config_per_port_rx_offload_result,
16133 search_rx_offload(const char *name)
16135 uint64_t single_offload;
16136 const char *single_name;
16140 single_offload = 1;
16141 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16142 single_name = rte_eth_dev_rx_offload_name(single_offload);
16143 if (!strcasecmp(single_name, name)) {
16147 single_offload <<= 1;
16151 return single_offload;
16157 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16158 __rte_unused struct cmdline *cl,
16159 __rte_unused void *data)
16161 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16162 portid_t port_id = res->port_id;
16163 struct rte_eth_dev_info dev_info;
16164 struct rte_port *port = &ports[port_id];
16165 uint64_t single_offload;
16166 uint16_t nb_rx_queues;
16170 if (port->port_status != RTE_PORT_STOPPED) {
16172 "Error: Can't config offload when Port %d is not stopped\n",
16177 single_offload = search_rx_offload(res->offload);
16178 if (single_offload == 0) {
16179 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16183 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16187 nb_rx_queues = dev_info.nb_rx_queues;
16188 if (!strcmp(res->on_off, "on")) {
16189 port->dev_conf.rxmode.offloads |= single_offload;
16190 for (q = 0; q < nb_rx_queues; q++)
16191 port->rx_conf[q].offloads |= single_offload;
16193 port->dev_conf.rxmode.offloads &= ~single_offload;
16194 for (q = 0; q < nb_rx_queues; q++)
16195 port->rx_conf[q].offloads &= ~single_offload;
16198 cmd_reconfig_device_queue(port_id, 1, 1);
16201 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16202 .f = cmd_config_per_port_rx_offload_parsed,
16204 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16205 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16206 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16207 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16208 "keep_crc|rss_hash on|off",
16210 (void *)&cmd_config_per_port_rx_offload_result_port,
16211 (void *)&cmd_config_per_port_rx_offload_result_config,
16212 (void *)&cmd_config_per_port_rx_offload_result_port_id,
16213 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16214 (void *)&cmd_config_per_port_rx_offload_result_offload,
16215 (void *)&cmd_config_per_port_rx_offload_result_on_off,
16220 /* Enable/Disable a per queue offloading */
16221 struct cmd_config_per_queue_rx_offload_result {
16222 cmdline_fixed_string_t port;
16224 cmdline_fixed_string_t rxq;
16226 cmdline_fixed_string_t rx_offload;
16227 cmdline_fixed_string_t offload;
16228 cmdline_fixed_string_t on_off;
16231 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16232 TOKEN_STRING_INITIALIZER
16233 (struct cmd_config_per_queue_rx_offload_result,
16235 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16236 TOKEN_NUM_INITIALIZER
16237 (struct cmd_config_per_queue_rx_offload_result,
16238 port_id, RTE_UINT16);
16239 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16240 TOKEN_STRING_INITIALIZER
16241 (struct cmd_config_per_queue_rx_offload_result,
16243 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16244 TOKEN_NUM_INITIALIZER
16245 (struct cmd_config_per_queue_rx_offload_result,
16246 queue_id, RTE_UINT16);
16247 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16248 TOKEN_STRING_INITIALIZER
16249 (struct cmd_config_per_queue_rx_offload_result,
16250 rx_offload, "rx_offload");
16251 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16252 TOKEN_STRING_INITIALIZER
16253 (struct cmd_config_per_queue_rx_offload_result,
16254 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16255 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16256 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16257 "scatter#buffer_split#timestamp#security#keep_crc");
16258 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16259 TOKEN_STRING_INITIALIZER
16260 (struct cmd_config_per_queue_rx_offload_result,
16264 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16265 __rte_unused struct cmdline *cl,
16266 __rte_unused void *data)
16268 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16269 struct rte_eth_dev_info dev_info;
16270 portid_t port_id = res->port_id;
16271 uint16_t queue_id = res->queue_id;
16272 struct rte_port *port = &ports[port_id];
16273 uint64_t single_offload;
16276 if (port->port_status != RTE_PORT_STOPPED) {
16278 "Error: Can't config offload when Port %d is not stopped\n",
16283 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16287 if (queue_id >= dev_info.nb_rx_queues) {
16289 "Error: input queue_id should be 0 ... %d\n",
16290 dev_info.nb_rx_queues - 1);
16294 single_offload = search_rx_offload(res->offload);
16295 if (single_offload == 0) {
16296 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16300 if (!strcmp(res->on_off, "on"))
16301 port->rx_conf[queue_id].offloads |= single_offload;
16303 port->rx_conf[queue_id].offloads &= ~single_offload;
16305 cmd_reconfig_device_queue(port_id, 1, 1);
16308 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16309 .f = cmd_config_per_queue_rx_offload_parsed,
16311 .help_str = "port <port_id> rxq <queue_id> rx_offload "
16312 "vlan_strip|ipv4_cksum|"
16313 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16314 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16315 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16318 (void *)&cmd_config_per_queue_rx_offload_result_port,
16319 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
16320 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
16321 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16322 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16323 (void *)&cmd_config_per_queue_rx_offload_result_offload,
16324 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
16329 /* Get Tx offloads capabilities */
16330 struct cmd_tx_offload_get_capa_result {
16331 cmdline_fixed_string_t show;
16332 cmdline_fixed_string_t port;
16334 cmdline_fixed_string_t tx_offload;
16335 cmdline_fixed_string_t capabilities;
16338 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16339 TOKEN_STRING_INITIALIZER
16340 (struct cmd_tx_offload_get_capa_result,
16342 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16343 TOKEN_STRING_INITIALIZER
16344 (struct cmd_tx_offload_get_capa_result,
16346 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16347 TOKEN_NUM_INITIALIZER
16348 (struct cmd_tx_offload_get_capa_result,
16349 port_id, RTE_UINT16);
16350 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16351 TOKEN_STRING_INITIALIZER
16352 (struct cmd_tx_offload_get_capa_result,
16353 tx_offload, "tx_offload");
16354 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16355 TOKEN_STRING_INITIALIZER
16356 (struct cmd_tx_offload_get_capa_result,
16357 capabilities, "capabilities");
16360 print_tx_offloads(uint64_t offloads)
16362 uint64_t single_offload;
16370 begin = __builtin_ctzll(offloads);
16371 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16373 single_offload = 1ULL << begin;
16374 for (bit = begin; bit < end; bit++) {
16375 if (offloads & single_offload)
16377 rte_eth_dev_tx_offload_name(single_offload));
16378 single_offload <<= 1;
16383 cmd_tx_offload_get_capa_parsed(
16384 void *parsed_result,
16385 __rte_unused struct cmdline *cl,
16386 __rte_unused void *data)
16388 struct cmd_tx_offload_get_capa_result *res = parsed_result;
16389 struct rte_eth_dev_info dev_info;
16390 portid_t port_id = res->port_id;
16391 uint64_t queue_offloads;
16392 uint64_t port_offloads;
16395 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16399 queue_offloads = dev_info.tx_queue_offload_capa;
16400 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16402 printf("Tx Offloading Capabilities of port %d :\n", port_id);
16403 printf(" Per Queue :");
16404 print_tx_offloads(queue_offloads);
16407 printf(" Per Port :");
16408 print_tx_offloads(port_offloads);
16412 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16413 .f = cmd_tx_offload_get_capa_parsed,
16415 .help_str = "show port <port_id> tx_offload capabilities",
16417 (void *)&cmd_tx_offload_get_capa_show,
16418 (void *)&cmd_tx_offload_get_capa_port,
16419 (void *)&cmd_tx_offload_get_capa_port_id,
16420 (void *)&cmd_tx_offload_get_capa_tx_offload,
16421 (void *)&cmd_tx_offload_get_capa_capabilities,
16426 /* Get Tx offloads configuration */
16427 struct cmd_tx_offload_get_configuration_result {
16428 cmdline_fixed_string_t show;
16429 cmdline_fixed_string_t port;
16431 cmdline_fixed_string_t tx_offload;
16432 cmdline_fixed_string_t configuration;
16435 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16436 TOKEN_STRING_INITIALIZER
16437 (struct cmd_tx_offload_get_configuration_result,
16439 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16440 TOKEN_STRING_INITIALIZER
16441 (struct cmd_tx_offload_get_configuration_result,
16443 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16444 TOKEN_NUM_INITIALIZER
16445 (struct cmd_tx_offload_get_configuration_result,
16446 port_id, RTE_UINT16);
16447 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16448 TOKEN_STRING_INITIALIZER
16449 (struct cmd_tx_offload_get_configuration_result,
16450 tx_offload, "tx_offload");
16451 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16452 TOKEN_STRING_INITIALIZER
16453 (struct cmd_tx_offload_get_configuration_result,
16454 configuration, "configuration");
16457 cmd_tx_offload_get_configuration_parsed(
16458 void *parsed_result,
16459 __rte_unused struct cmdline *cl,
16460 __rte_unused void *data)
16462 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16463 struct rte_eth_dev_info dev_info;
16464 portid_t port_id = res->port_id;
16465 struct rte_port *port = &ports[port_id];
16466 struct rte_eth_conf dev_conf;
16467 uint64_t port_offloads;
16468 uint64_t queue_offloads;
16469 uint16_t nb_tx_queues;
16473 printf("Tx Offloading Configuration of port %d :\n", port_id);
16475 ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
16479 port_offloads = dev_conf.txmode.offloads;
16481 print_tx_offloads(port_offloads);
16484 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16488 nb_tx_queues = dev_info.nb_tx_queues;
16489 for (q = 0; q < nb_tx_queues; q++) {
16490 queue_offloads = port->tx_conf[q].offloads;
16491 printf(" Queue[%2d] :", q);
16492 print_tx_offloads(queue_offloads);
16498 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16499 .f = cmd_tx_offload_get_configuration_parsed,
16501 .help_str = "show port <port_id> tx_offload configuration",
16503 (void *)&cmd_tx_offload_get_configuration_show,
16504 (void *)&cmd_tx_offload_get_configuration_port,
16505 (void *)&cmd_tx_offload_get_configuration_port_id,
16506 (void *)&cmd_tx_offload_get_configuration_tx_offload,
16507 (void *)&cmd_tx_offload_get_configuration_configuration,
16512 /* Enable/Disable a per port offloading */
16513 struct cmd_config_per_port_tx_offload_result {
16514 cmdline_fixed_string_t port;
16515 cmdline_fixed_string_t config;
16517 cmdline_fixed_string_t tx_offload;
16518 cmdline_fixed_string_t offload;
16519 cmdline_fixed_string_t on_off;
16522 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16523 TOKEN_STRING_INITIALIZER
16524 (struct cmd_config_per_port_tx_offload_result,
16526 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16527 TOKEN_STRING_INITIALIZER
16528 (struct cmd_config_per_port_tx_offload_result,
16530 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16531 TOKEN_NUM_INITIALIZER
16532 (struct cmd_config_per_port_tx_offload_result,
16533 port_id, RTE_UINT16);
16534 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16535 TOKEN_STRING_INITIALIZER
16536 (struct cmd_config_per_port_tx_offload_result,
16537 tx_offload, "tx_offload");
16538 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16539 TOKEN_STRING_INITIALIZER
16540 (struct cmd_config_per_port_tx_offload_result,
16541 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16542 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16543 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16544 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16545 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16546 "send_on_timestamp");
16547 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16548 TOKEN_STRING_INITIALIZER
16549 (struct cmd_config_per_port_tx_offload_result,
16553 search_tx_offload(const char *name)
16555 uint64_t single_offload;
16556 const char *single_name;
16560 single_offload = 1;
16561 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16562 single_name = rte_eth_dev_tx_offload_name(single_offload);
16563 if (single_name == NULL)
16565 if (!strcasecmp(single_name, name)) {
16568 } else if (!strcasecmp(single_name, "UNKNOWN"))
16570 single_offload <<= 1;
16574 return single_offload;
16580 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16581 __rte_unused struct cmdline *cl,
16582 __rte_unused void *data)
16584 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16585 portid_t port_id = res->port_id;
16586 struct rte_eth_dev_info dev_info;
16587 struct rte_port *port = &ports[port_id];
16588 uint64_t single_offload;
16589 uint16_t nb_tx_queues;
16593 if (port->port_status != RTE_PORT_STOPPED) {
16595 "Error: Can't config offload when Port %d is not stopped\n",
16600 single_offload = search_tx_offload(res->offload);
16601 if (single_offload == 0) {
16602 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16606 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16610 nb_tx_queues = dev_info.nb_tx_queues;
16611 if (!strcmp(res->on_off, "on")) {
16612 port->dev_conf.txmode.offloads |= single_offload;
16613 for (q = 0; q < nb_tx_queues; q++)
16614 port->tx_conf[q].offloads |= single_offload;
16616 port->dev_conf.txmode.offloads &= ~single_offload;
16617 for (q = 0; q < nb_tx_queues; q++)
16618 port->tx_conf[q].offloads &= ~single_offload;
16621 cmd_reconfig_device_queue(port_id, 1, 1);
16624 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16625 .f = cmd_config_per_port_tx_offload_parsed,
16627 .help_str = "port config <port_id> tx_offload "
16628 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16629 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16630 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16631 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16632 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16633 "send_on_timestamp on|off",
16635 (void *)&cmd_config_per_port_tx_offload_result_port,
16636 (void *)&cmd_config_per_port_tx_offload_result_config,
16637 (void *)&cmd_config_per_port_tx_offload_result_port_id,
16638 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16639 (void *)&cmd_config_per_port_tx_offload_result_offload,
16640 (void *)&cmd_config_per_port_tx_offload_result_on_off,
16645 /* Enable/Disable a per queue offloading */
16646 struct cmd_config_per_queue_tx_offload_result {
16647 cmdline_fixed_string_t port;
16649 cmdline_fixed_string_t txq;
16651 cmdline_fixed_string_t tx_offload;
16652 cmdline_fixed_string_t offload;
16653 cmdline_fixed_string_t on_off;
16656 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16657 TOKEN_STRING_INITIALIZER
16658 (struct cmd_config_per_queue_tx_offload_result,
16660 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16661 TOKEN_NUM_INITIALIZER
16662 (struct cmd_config_per_queue_tx_offload_result,
16663 port_id, RTE_UINT16);
16664 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16665 TOKEN_STRING_INITIALIZER
16666 (struct cmd_config_per_queue_tx_offload_result,
16668 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16669 TOKEN_NUM_INITIALIZER
16670 (struct cmd_config_per_queue_tx_offload_result,
16671 queue_id, RTE_UINT16);
16672 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16673 TOKEN_STRING_INITIALIZER
16674 (struct cmd_config_per_queue_tx_offload_result,
16675 tx_offload, "tx_offload");
16676 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16677 TOKEN_STRING_INITIALIZER
16678 (struct cmd_config_per_queue_tx_offload_result,
16679 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16680 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16681 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16682 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16683 "mt_lockfree#multi_segs#mbuf_fast_free#security");
16684 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16685 TOKEN_STRING_INITIALIZER
16686 (struct cmd_config_per_queue_tx_offload_result,
16690 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16691 __rte_unused struct cmdline *cl,
16692 __rte_unused void *data)
16694 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16695 struct rte_eth_dev_info dev_info;
16696 portid_t port_id = res->port_id;
16697 uint16_t queue_id = res->queue_id;
16698 struct rte_port *port = &ports[port_id];
16699 uint64_t single_offload;
16702 if (port->port_status != RTE_PORT_STOPPED) {
16704 "Error: Can't config offload when Port %d is not stopped\n",
16709 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16713 if (queue_id >= dev_info.nb_tx_queues) {
16715 "Error: input queue_id should be 0 ... %d\n",
16716 dev_info.nb_tx_queues - 1);
16720 single_offload = search_tx_offload(res->offload);
16721 if (single_offload == 0) {
16722 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16726 if (!strcmp(res->on_off, "on"))
16727 port->tx_conf[queue_id].offloads |= single_offload;
16729 port->tx_conf[queue_id].offloads &= ~single_offload;
16731 cmd_reconfig_device_queue(port_id, 1, 1);
16734 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16735 .f = cmd_config_per_queue_tx_offload_parsed,
16737 .help_str = "port <port_id> txq <queue_id> tx_offload "
16738 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16739 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16740 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16741 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16742 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16745 (void *)&cmd_config_per_queue_tx_offload_result_port,
16746 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16747 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16748 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16749 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16750 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16751 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16756 /* *** configure tx_metadata for specific port *** */
16757 struct cmd_config_tx_metadata_specific_result {
16758 cmdline_fixed_string_t port;
16759 cmdline_fixed_string_t keyword;
16761 cmdline_fixed_string_t item;
16766 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16767 __rte_unused struct cmdline *cl,
16768 __rte_unused void *data)
16770 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16772 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16774 ports[res->port_id].tx_metadata = res->value;
16775 /* Add/remove callback to insert valid metadata in every Tx packet. */
16776 if (ports[res->port_id].tx_metadata)
16777 add_tx_md_callback(res->port_id);
16779 remove_tx_md_callback(res->port_id);
16780 rte_flow_dynf_metadata_register();
16783 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16784 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16786 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16787 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16788 keyword, "config");
16789 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16790 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16791 port_id, RTE_UINT16);
16792 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16793 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16794 item, "tx_metadata");
16795 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16796 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16797 value, RTE_UINT32);
16799 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16800 .f = cmd_config_tx_metadata_specific_parsed,
16802 .help_str = "port config <port_id> tx_metadata <value>",
16804 (void *)&cmd_config_tx_metadata_specific_port,
16805 (void *)&cmd_config_tx_metadata_specific_keyword,
16806 (void *)&cmd_config_tx_metadata_specific_id,
16807 (void *)&cmd_config_tx_metadata_specific_item,
16808 (void *)&cmd_config_tx_metadata_specific_value,
16813 /* *** set dynf *** */
16814 struct cmd_config_tx_dynf_specific_result {
16815 cmdline_fixed_string_t port;
16816 cmdline_fixed_string_t keyword;
16818 cmdline_fixed_string_t item;
16819 cmdline_fixed_string_t name;
16820 cmdline_fixed_string_t value;
16824 cmd_config_dynf_specific_parsed(void *parsed_result,
16825 __rte_unused struct cmdline *cl,
16826 __rte_unused void *data)
16828 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16829 struct rte_mbuf_dynflag desc_flag;
16831 uint64_t old_port_flags;
16833 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16835 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16837 if (strlcpy(desc_flag.name, res->name,
16838 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16839 fprintf(stderr, "Flag name too long\n");
16842 desc_flag.flags = 0;
16843 flag = rte_mbuf_dynflag_register(&desc_flag);
16845 fprintf(stderr, "Can't register flag\n");
16848 strcpy(dynf_names[flag], desc_flag.name);
16850 old_port_flags = ports[res->port_id].mbuf_dynf;
16851 if (!strcmp(res->value, "set")) {
16852 ports[res->port_id].mbuf_dynf |= 1UL << flag;
16853 if (old_port_flags == 0)
16854 add_tx_dynf_callback(res->port_id);
16856 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16857 if (ports[res->port_id].mbuf_dynf == 0)
16858 remove_tx_dynf_callback(res->port_id);
16862 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16863 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16865 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16866 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16867 keyword, "config");
16868 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
16869 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16870 port_id, RTE_UINT16);
16871 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
16872 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16874 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
16875 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16877 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
16878 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16879 value, "set#clear");
16881 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
16882 .f = cmd_config_dynf_specific_parsed,
16884 .help_str = "port config <port id> dynf <name> set|clear",
16886 (void *)&cmd_config_tx_dynf_specific_port,
16887 (void *)&cmd_config_tx_dynf_specific_keyword,
16888 (void *)&cmd_config_tx_dynf_specific_port_id,
16889 (void *)&cmd_config_tx_dynf_specific_item,
16890 (void *)&cmd_config_tx_dynf_specific_name,
16891 (void *)&cmd_config_tx_dynf_specific_value,
16896 /* *** display tx_metadata per port configuration *** */
16897 struct cmd_show_tx_metadata_result {
16898 cmdline_fixed_string_t cmd_show;
16899 cmdline_fixed_string_t cmd_port;
16900 cmdline_fixed_string_t cmd_keyword;
16905 cmd_show_tx_metadata_parsed(void *parsed_result,
16906 __rte_unused struct cmdline *cl,
16907 __rte_unused void *data)
16909 struct cmd_show_tx_metadata_result *res = parsed_result;
16911 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16912 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
16915 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
16916 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
16917 ports[res->cmd_pid].tx_metadata);
16921 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
16922 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16924 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
16925 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16927 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
16928 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
16929 cmd_pid, RTE_UINT16);
16930 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
16931 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16932 cmd_keyword, "tx_metadata");
16934 cmdline_parse_inst_t cmd_show_tx_metadata = {
16935 .f = cmd_show_tx_metadata_parsed,
16937 .help_str = "show port <port_id> tx_metadata",
16939 (void *)&cmd_show_tx_metadata_show,
16940 (void *)&cmd_show_tx_metadata_port,
16941 (void *)&cmd_show_tx_metadata_pid,
16942 (void *)&cmd_show_tx_metadata_keyword,
16947 /* *** show fec capability per port configuration *** */
16948 struct cmd_show_fec_capability_result {
16949 cmdline_fixed_string_t cmd_show;
16950 cmdline_fixed_string_t cmd_port;
16951 cmdline_fixed_string_t cmd_fec;
16952 cmdline_fixed_string_t cmd_keyword;
16957 cmd_show_fec_capability_parsed(void *parsed_result,
16958 __rte_unused struct cmdline *cl,
16959 __rte_unused void *data)
16961 struct cmd_show_fec_capability_result *res = parsed_result;
16962 struct rte_eth_fec_capa *speed_fec_capa;
16966 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16967 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
16971 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
16972 if (ret == -ENOTSUP) {
16973 fprintf(stderr, "Function not implemented\n");
16975 } else if (ret < 0) {
16976 fprintf(stderr, "Get FEC capability failed: %d\n", ret);
16980 num = (unsigned int)ret;
16981 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
16982 if (speed_fec_capa == NULL) {
16983 fprintf(stderr, "Failed to alloc FEC capability buffer\n");
16987 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
16989 fprintf(stderr, "Error getting FEC capability: %d\n", ret);
16993 show_fec_capability(num, speed_fec_capa);
16995 free(speed_fec_capa);
16998 cmdline_parse_token_string_t cmd_show_fec_capability_show =
16999 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17001 cmdline_parse_token_string_t cmd_show_fec_capability_port =
17002 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17004 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
17005 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
17006 cmd_pid, RTE_UINT16);
17007 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
17008 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17010 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
17011 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17012 cmd_keyword, "capabilities");
17014 cmdline_parse_inst_t cmd_show_capability = {
17015 .f = cmd_show_fec_capability_parsed,
17017 .help_str = "show port <port_id> fec capabilities",
17019 (void *)&cmd_show_fec_capability_show,
17020 (void *)&cmd_show_fec_capability_port,
17021 (void *)&cmd_show_fec_capability_pid,
17022 (void *)&cmd_show_fec_capability_fec,
17023 (void *)&cmd_show_fec_capability_keyword,
17028 /* *** show fec mode per port configuration *** */
17029 struct cmd_show_fec_metadata_result {
17030 cmdline_fixed_string_t cmd_show;
17031 cmdline_fixed_string_t cmd_port;
17032 cmdline_fixed_string_t cmd_keyword;
17037 cmd_show_fec_mode_parsed(void *parsed_result,
17038 __rte_unused struct cmdline *cl,
17039 __rte_unused void *data)
17041 #define FEC_NAME_SIZE 16
17042 struct cmd_show_fec_metadata_result *res = parsed_result;
17044 char buf[FEC_NAME_SIZE];
17047 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17048 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
17051 ret = rte_eth_fec_get(res->cmd_pid, &mode);
17052 if (ret == -ENOTSUP) {
17053 fprintf(stderr, "Function not implemented\n");
17055 } else if (ret < 0) {
17056 fprintf(stderr, "Get FEC mode failed\n");
17061 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
17062 strlcpy(buf, "off", sizeof(buf));
17064 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
17065 strlcpy(buf, "auto", sizeof(buf));
17067 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
17068 strlcpy(buf, "baser", sizeof(buf));
17070 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
17071 strlcpy(buf, "rs", sizeof(buf));
17077 printf("%s\n", buf);
17080 cmdline_parse_token_string_t cmd_show_fec_mode_show =
17081 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17083 cmdline_parse_token_string_t cmd_show_fec_mode_port =
17084 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17086 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
17087 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
17088 cmd_pid, RTE_UINT16);
17089 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
17090 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17091 cmd_keyword, "fec_mode");
17093 cmdline_parse_inst_t cmd_show_fec_mode = {
17094 .f = cmd_show_fec_mode_parsed,
17096 .help_str = "show port <port_id> fec_mode",
17098 (void *)&cmd_show_fec_mode_show,
17099 (void *)&cmd_show_fec_mode_port,
17100 (void *)&cmd_show_fec_mode_pid,
17101 (void *)&cmd_show_fec_mode_keyword,
17106 /* *** set fec mode per port configuration *** */
17107 struct cmd_set_port_fec_mode {
17108 cmdline_fixed_string_t set;
17109 cmdline_fixed_string_t port;
17111 cmdline_fixed_string_t fec_mode;
17112 cmdline_fixed_string_t fec_value;
17115 /* Common CLI fields for set fec mode */
17116 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
17117 TOKEN_STRING_INITIALIZER
17118 (struct cmd_set_port_fec_mode,
17120 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
17121 TOKEN_STRING_INITIALIZER
17122 (struct cmd_set_port_fec_mode,
17124 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
17125 TOKEN_NUM_INITIALIZER
17126 (struct cmd_set_port_fec_mode,
17127 port_id, RTE_UINT16);
17128 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
17129 TOKEN_STRING_INITIALIZER
17130 (struct cmd_set_port_fec_mode,
17131 fec_mode, "fec_mode");
17132 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
17133 TOKEN_STRING_INITIALIZER
17134 (struct cmd_set_port_fec_mode,
17138 cmd_set_port_fec_mode_parsed(
17139 void *parsed_result,
17140 __rte_unused struct cmdline *cl,
17141 __rte_unused void *data)
17143 struct cmd_set_port_fec_mode *res = parsed_result;
17144 uint16_t port_id = res->port_id;
17148 ret = parse_fec_mode(res->fec_value, &fec_capa);
17150 fprintf(stderr, "Unknown fec mode: %s for port %d\n",
17151 res->fec_value, port_id);
17155 ret = rte_eth_fec_set(port_id, fec_capa);
17156 if (ret == -ENOTSUP) {
17157 fprintf(stderr, "Function not implemented\n");
17159 } else if (ret < 0) {
17160 fprintf(stderr, "Set FEC mode failed\n");
17165 cmdline_parse_inst_t cmd_set_fec_mode = {
17166 .f = cmd_set_port_fec_mode_parsed,
17168 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
17170 (void *)&cmd_set_port_fec_mode_set,
17171 (void *)&cmd_set_port_fec_mode_port,
17172 (void *)&cmd_set_port_fec_mode_port_id,
17173 (void *)&cmd_set_port_fec_mode_str,
17174 (void *)&cmd_set_port_fec_mode_value,
17179 /* show port supported ptypes */
17181 /* Common result structure for show port ptypes */
17182 struct cmd_show_port_supported_ptypes_result {
17183 cmdline_fixed_string_t show;
17184 cmdline_fixed_string_t port;
17186 cmdline_fixed_string_t ptypes;
17189 /* Common CLI fields for show port ptypes */
17190 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
17191 TOKEN_STRING_INITIALIZER
17192 (struct cmd_show_port_supported_ptypes_result,
17194 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
17195 TOKEN_STRING_INITIALIZER
17196 (struct cmd_show_port_supported_ptypes_result,
17198 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
17199 TOKEN_NUM_INITIALIZER
17200 (struct cmd_show_port_supported_ptypes_result,
17201 port_id, RTE_UINT16);
17202 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
17203 TOKEN_STRING_INITIALIZER
17204 (struct cmd_show_port_supported_ptypes_result,
17208 cmd_show_port_supported_ptypes_parsed(
17209 void *parsed_result,
17210 __rte_unused struct cmdline *cl,
17211 __rte_unused void *data)
17213 #define RSVD_PTYPE_MASK 0xf0000000
17214 #define MAX_PTYPES_PER_LAYER 16
17215 #define LTYPE_NAMESIZE 32
17216 #define PTYPE_NAMESIZE 256
17217 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
17218 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
17219 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
17220 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
17221 uint16_t port_id = res->port_id;
17224 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
17228 while (ptype_mask != RSVD_PTYPE_MASK) {
17230 switch (ptype_mask) {
17231 case RTE_PTYPE_L2_MASK:
17232 strlcpy(ltype, "L2", sizeof(ltype));
17234 case RTE_PTYPE_L3_MASK:
17235 strlcpy(ltype, "L3", sizeof(ltype));
17237 case RTE_PTYPE_L4_MASK:
17238 strlcpy(ltype, "L4", sizeof(ltype));
17240 case RTE_PTYPE_TUNNEL_MASK:
17241 strlcpy(ltype, "Tunnel", sizeof(ltype));
17243 case RTE_PTYPE_INNER_L2_MASK:
17244 strlcpy(ltype, "Inner L2", sizeof(ltype));
17246 case RTE_PTYPE_INNER_L3_MASK:
17247 strlcpy(ltype, "Inner L3", sizeof(ltype));
17249 case RTE_PTYPE_INNER_L4_MASK:
17250 strlcpy(ltype, "Inner L4", sizeof(ltype));
17256 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
17257 ptype_mask, ptypes,
17258 MAX_PTYPES_PER_LAYER);
17261 printf("Supported %s ptypes:\n", ltype);
17263 printf("%s ptypes unsupported\n", ltype);
17265 for (i = 0; i < ret; ++i) {
17266 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
17267 printf("%s\n", buf);
17274 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
17275 .f = cmd_show_port_supported_ptypes_parsed,
17277 .help_str = "show port <port_id> ptypes",
17279 (void *)&cmd_show_port_supported_ptypes_show,
17280 (void *)&cmd_show_port_supported_ptypes_port,
17281 (void *)&cmd_show_port_supported_ptypes_port_id,
17282 (void *)&cmd_show_port_supported_ptypes_ptypes,
17287 /* *** display rx/tx descriptor status *** */
17288 struct cmd_show_rx_tx_desc_status_result {
17289 cmdline_fixed_string_t cmd_show;
17290 cmdline_fixed_string_t cmd_port;
17291 cmdline_fixed_string_t cmd_keyword;
17292 cmdline_fixed_string_t cmd_desc;
17293 cmdline_fixed_string_t cmd_status;
17300 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
17301 __rte_unused struct cmdline *cl,
17302 __rte_unused void *data)
17304 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
17307 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17308 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17312 if (!strcmp(res->cmd_keyword, "rxq")) {
17313 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
17317 "Invalid input: queue id = %d, desc id = %d\n",
17318 res->cmd_qid, res->cmd_did);
17321 if (rc == RTE_ETH_RX_DESC_AVAIL)
17322 printf("Desc status = AVAILABLE\n");
17323 else if (rc == RTE_ETH_RX_DESC_DONE)
17324 printf("Desc status = DONE\n");
17326 printf("Desc status = UNAVAILABLE\n");
17327 } else if (!strcmp(res->cmd_keyword, "txq")) {
17328 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17332 "Invalid input: queue id = %d, desc id = %d\n",
17333 res->cmd_qid, res->cmd_did);
17336 if (rc == RTE_ETH_TX_DESC_FULL)
17337 printf("Desc status = FULL\n");
17338 else if (rc == RTE_ETH_TX_DESC_DONE)
17339 printf("Desc status = DONE\n");
17341 printf("Desc status = UNAVAILABLE\n");
17345 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17346 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17348 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17349 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17351 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17352 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17353 cmd_pid, RTE_UINT16);
17354 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17355 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17356 cmd_keyword, "rxq#txq");
17357 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17358 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17359 cmd_qid, RTE_UINT16);
17360 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17361 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17363 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17364 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17365 cmd_did, RTE_UINT16);
17366 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17367 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17368 cmd_status, "status");
17369 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17370 .f = cmd_show_rx_tx_desc_status_parsed,
17372 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17375 (void *)&cmd_show_rx_tx_desc_status_show,
17376 (void *)&cmd_show_rx_tx_desc_status_port,
17377 (void *)&cmd_show_rx_tx_desc_status_pid,
17378 (void *)&cmd_show_rx_tx_desc_status_keyword,
17379 (void *)&cmd_show_rx_tx_desc_status_qid,
17380 (void *)&cmd_show_rx_tx_desc_status_desc,
17381 (void *)&cmd_show_rx_tx_desc_status_did,
17382 (void *)&cmd_show_rx_tx_desc_status_status,
17387 /* *** display rx queue desc used count *** */
17388 struct cmd_show_rx_queue_desc_used_count_result {
17389 cmdline_fixed_string_t cmd_show;
17390 cmdline_fixed_string_t cmd_port;
17391 cmdline_fixed_string_t cmd_rxq;
17392 cmdline_fixed_string_t cmd_desc;
17393 cmdline_fixed_string_t cmd_used;
17394 cmdline_fixed_string_t cmd_count;
17400 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17401 __rte_unused struct cmdline *cl,
17402 __rte_unused void *data)
17404 struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17407 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17408 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17412 rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17414 fprintf(stderr, "Invalid queueid = %d\n", res->cmd_qid);
17417 printf("Used desc count = %d\n", rc);
17420 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17421 TOKEN_STRING_INITIALIZER
17422 (struct cmd_show_rx_queue_desc_used_count_result,
17424 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17425 TOKEN_STRING_INITIALIZER
17426 (struct cmd_show_rx_queue_desc_used_count_result,
17428 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17429 TOKEN_NUM_INITIALIZER
17430 (struct cmd_show_rx_queue_desc_used_count_result,
17431 cmd_pid, RTE_UINT16);
17432 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17433 TOKEN_STRING_INITIALIZER
17434 (struct cmd_show_rx_queue_desc_used_count_result,
17436 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17437 TOKEN_NUM_INITIALIZER
17438 (struct cmd_show_rx_queue_desc_used_count_result,
17439 cmd_qid, RTE_UINT16);
17440 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17441 TOKEN_STRING_INITIALIZER
17442 (struct cmd_show_rx_queue_desc_used_count_result,
17443 cmd_count, "desc");
17444 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17445 TOKEN_STRING_INITIALIZER
17446 (struct cmd_show_rx_queue_desc_used_count_result,
17447 cmd_count, "used");
17448 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17449 TOKEN_STRING_INITIALIZER
17450 (struct cmd_show_rx_queue_desc_used_count_result,
17451 cmd_count, "count");
17452 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17453 .f = cmd_show_rx_queue_desc_used_count_parsed,
17455 .help_str = "show port <port_id> rxq <queue_id> desc used count",
17457 (void *)&cmd_show_rx_queue_desc_used_count_show,
17458 (void *)&cmd_show_rx_queue_desc_used_count_port,
17459 (void *)&cmd_show_rx_queue_desc_used_count_pid,
17460 (void *)&cmd_show_rx_queue_desc_used_count_rxq,
17461 (void *)&cmd_show_rx_queue_desc_used_count_qid,
17462 (void *)&cmd_show_rx_queue_desc_used_count_desc,
17463 (void *)&cmd_show_rx_queue_desc_used_count_used,
17464 (void *)&cmd_show_rx_queue_desc_used_count_count,
17469 /* Common result structure for set port ptypes */
17470 struct cmd_set_port_ptypes_result {
17471 cmdline_fixed_string_t set;
17472 cmdline_fixed_string_t port;
17474 cmdline_fixed_string_t ptype_mask;
17478 /* Common CLI fields for set port ptypes */
17479 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17480 TOKEN_STRING_INITIALIZER
17481 (struct cmd_set_port_ptypes_result,
17483 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17484 TOKEN_STRING_INITIALIZER
17485 (struct cmd_set_port_ptypes_result,
17487 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17488 TOKEN_NUM_INITIALIZER
17489 (struct cmd_set_port_ptypes_result,
17490 port_id, RTE_UINT16);
17491 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17492 TOKEN_STRING_INITIALIZER
17493 (struct cmd_set_port_ptypes_result,
17494 ptype_mask, "ptype_mask");
17495 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17496 TOKEN_NUM_INITIALIZER
17497 (struct cmd_set_port_ptypes_result,
17501 cmd_set_port_ptypes_parsed(
17502 void *parsed_result,
17503 __rte_unused struct cmdline *cl,
17504 __rte_unused void *data)
17506 struct cmd_set_port_ptypes_result *res = parsed_result;
17507 #define PTYPE_NAMESIZE 256
17508 char ptype_name[PTYPE_NAMESIZE];
17509 uint16_t port_id = res->port_id;
17510 uint32_t ptype_mask = res->mask;
17513 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17516 fprintf(stderr, "Port %d doesn't support any ptypes.\n",
17521 uint32_t ptypes[ret];
17523 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17525 fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
17530 printf("Successfully set following ptypes for Port %d\n", port_id);
17531 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17532 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17533 printf("%s\n", ptype_name);
17536 clear_ptypes = false;
17539 cmdline_parse_inst_t cmd_set_port_ptypes = {
17540 .f = cmd_set_port_ptypes_parsed,
17542 .help_str = "set port <port_id> ptype_mask <mask>",
17544 (void *)&cmd_set_port_ptypes_set,
17545 (void *)&cmd_set_port_ptypes_port,
17546 (void *)&cmd_set_port_ptypes_port_id,
17547 (void *)&cmd_set_port_ptypes_mask_str,
17548 (void *)&cmd_set_port_ptypes_mask_u32,
17553 /* *** display mac addresses added to a port *** */
17554 struct cmd_showport_macs_result {
17555 cmdline_fixed_string_t cmd_show;
17556 cmdline_fixed_string_t cmd_port;
17557 cmdline_fixed_string_t cmd_keyword;
17562 cmd_showport_macs_parsed(void *parsed_result,
17563 __rte_unused struct cmdline *cl,
17564 __rte_unused void *data)
17566 struct cmd_showport_macs_result *res = parsed_result;
17568 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17571 if (!strcmp(res->cmd_keyword, "macs"))
17572 show_macs(res->cmd_pid);
17573 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17574 show_mcast_macs(res->cmd_pid);
17577 cmdline_parse_token_string_t cmd_showport_macs_show =
17578 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17580 cmdline_parse_token_string_t cmd_showport_macs_port =
17581 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17583 cmdline_parse_token_num_t cmd_showport_macs_pid =
17584 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17585 cmd_pid, RTE_UINT16);
17586 cmdline_parse_token_string_t cmd_showport_macs_keyword =
17587 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17588 cmd_keyword, "macs#mcast_macs");
17590 cmdline_parse_inst_t cmd_showport_macs = {
17591 .f = cmd_showport_macs_parsed,
17593 .help_str = "show port <port_id> macs|mcast_macs",
17595 (void *)&cmd_showport_macs_show,
17596 (void *)&cmd_showport_macs_port,
17597 (void *)&cmd_showport_macs_pid,
17598 (void *)&cmd_showport_macs_keyword,
17603 /* *** show flow transfer proxy port ID for the given port *** */
17604 struct cmd_show_port_flow_transfer_proxy_result {
17605 cmdline_fixed_string_t show;
17606 cmdline_fixed_string_t port;
17608 cmdline_fixed_string_t flow;
17609 cmdline_fixed_string_t transfer;
17610 cmdline_fixed_string_t proxy;
17613 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_show =
17614 TOKEN_STRING_INITIALIZER
17615 (struct cmd_show_port_flow_transfer_proxy_result,
17617 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_port =
17618 TOKEN_STRING_INITIALIZER
17619 (struct cmd_show_port_flow_transfer_proxy_result,
17621 cmdline_parse_token_num_t cmd_show_port_flow_transfer_proxy_port_id =
17622 TOKEN_NUM_INITIALIZER
17623 (struct cmd_show_port_flow_transfer_proxy_result,
17624 port_id, RTE_UINT16);
17625 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_flow =
17626 TOKEN_STRING_INITIALIZER
17627 (struct cmd_show_port_flow_transfer_proxy_result,
17629 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_transfer =
17630 TOKEN_STRING_INITIALIZER
17631 (struct cmd_show_port_flow_transfer_proxy_result,
17632 transfer, "transfer");
17633 cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_proxy =
17634 TOKEN_STRING_INITIALIZER
17635 (struct cmd_show_port_flow_transfer_proxy_result,
17639 cmd_show_port_flow_transfer_proxy_parsed(void *parsed_result,
17640 __rte_unused struct cmdline *cl,
17641 __rte_unused void *data)
17643 struct cmd_show_port_flow_transfer_proxy_result *res = parsed_result;
17644 portid_t proxy_port_id;
17649 ret = rte_flow_pick_transfer_proxy(res->port_id, &proxy_port_id, NULL);
17651 fprintf(stderr, "Failed to pick transfer proxy: %s\n",
17652 rte_strerror(-ret));
17656 printf("Transfer proxy port ID: %u\n\n", proxy_port_id);
17659 cmdline_parse_inst_t cmd_show_port_flow_transfer_proxy = {
17660 .f = cmd_show_port_flow_transfer_proxy_parsed,
17662 .help_str = "show port <port_id> flow transfer proxy",
17664 (void *)&cmd_show_port_flow_transfer_proxy_show,
17665 (void *)&cmd_show_port_flow_transfer_proxy_port,
17666 (void *)&cmd_show_port_flow_transfer_proxy_port_id,
17667 (void *)&cmd_show_port_flow_transfer_proxy_flow,
17668 (void *)&cmd_show_port_flow_transfer_proxy_transfer,
17669 (void *)&cmd_show_port_flow_transfer_proxy_proxy,
17674 /* ******************************************************************************** */
17676 /* list of instructions */
17677 cmdline_parse_ctx_t main_ctx[] = {
17678 (cmdline_parse_inst_t *)&cmd_help_brief,
17679 (cmdline_parse_inst_t *)&cmd_help_long,
17680 (cmdline_parse_inst_t *)&cmd_quit,
17681 (cmdline_parse_inst_t *)&cmd_load_from_file,
17682 (cmdline_parse_inst_t *)&cmd_showport,
17683 (cmdline_parse_inst_t *)&cmd_showqueue,
17684 (cmdline_parse_inst_t *)&cmd_showeeprom,
17685 (cmdline_parse_inst_t *)&cmd_showportall,
17686 (cmdline_parse_inst_t *)&cmd_representor_info,
17687 (cmdline_parse_inst_t *)&cmd_showdevice,
17688 (cmdline_parse_inst_t *)&cmd_showcfg,
17689 (cmdline_parse_inst_t *)&cmd_showfwdall,
17690 (cmdline_parse_inst_t *)&cmd_start,
17691 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17692 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17693 (cmdline_parse_inst_t *)&cmd_set_link_up,
17694 (cmdline_parse_inst_t *)&cmd_set_link_down,
17695 (cmdline_parse_inst_t *)&cmd_reset,
17696 (cmdline_parse_inst_t *)&cmd_set_numbers,
17697 (cmdline_parse_inst_t *)&cmd_set_log,
17698 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
17699 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
17700 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17701 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17702 (cmdline_parse_inst_t *)&cmd_set_txtimes,
17703 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17704 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17705 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17706 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17707 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17708 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17709 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17710 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17711 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17712 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17713 (cmdline_parse_inst_t *)&cmd_set_link_check,
17714 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17715 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17716 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17717 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17718 #ifdef RTE_NET_BOND
17719 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17720 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17721 (cmdline_parse_inst_t *) &cmd_show_bonding_lacp_info,
17722 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17723 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17724 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17725 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17726 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17727 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17728 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17729 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17730 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17732 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17733 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17734 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17735 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17736 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17737 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17738 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17739 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17740 (cmdline_parse_inst_t *)&cmd_csum_set,
17741 (cmdline_parse_inst_t *)&cmd_csum_show,
17742 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17743 (cmdline_parse_inst_t *)&cmd_tso_set,
17744 (cmdline_parse_inst_t *)&cmd_tso_show,
17745 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17746 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17748 (cmdline_parse_inst_t *)&cmd_gro_enable,
17749 (cmdline_parse_inst_t *)&cmd_gro_flush,
17750 (cmdline_parse_inst_t *)&cmd_gro_show,
17753 (cmdline_parse_inst_t *)&cmd_gso_enable,
17754 (cmdline_parse_inst_t *)&cmd_gso_size,
17755 (cmdline_parse_inst_t *)&cmd_gso_show,
17757 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17758 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17759 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17760 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17761 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17762 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17763 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17764 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17765 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17766 (cmdline_parse_inst_t *)&cmd_link_flow_control_show,
17767 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17768 (cmdline_parse_inst_t *)&cmd_config_dcb,
17769 (cmdline_parse_inst_t *)&cmd_read_reg,
17770 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17771 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17772 (cmdline_parse_inst_t *)&cmd_write_reg,
17773 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17774 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17775 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17776 (cmdline_parse_inst_t *)&cmd_stop,
17777 (cmdline_parse_inst_t *)&cmd_mac_addr,
17778 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17779 (cmdline_parse_inst_t *)&cmd_set_qmap,
17780 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17781 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17782 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17783 (cmdline_parse_inst_t *)&cmd_operate_port,
17784 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17785 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17786 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17787 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
17788 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17789 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17790 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17791 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17792 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17793 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17794 (cmdline_parse_inst_t *)&cmd_config_mtu,
17795 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17796 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17797 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17798 (cmdline_parse_inst_t *)&cmd_config_rss,
17799 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17800 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17801 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17802 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17803 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17804 (cmdline_parse_inst_t *)&cmd_showport_reta,
17805 (cmdline_parse_inst_t *)&cmd_showport_macs,
17806 (cmdline_parse_inst_t *)&cmd_show_port_flow_transfer_proxy,
17807 (cmdline_parse_inst_t *)&cmd_config_burst,
17808 (cmdline_parse_inst_t *)&cmd_config_thresh,
17809 (cmdline_parse_inst_t *)&cmd_config_threshold,
17810 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17811 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17812 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17813 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17814 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17815 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17816 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17817 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17818 (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
17819 (cmdline_parse_inst_t *)&cmd_dump,
17820 (cmdline_parse_inst_t *)&cmd_dump_one,
17821 #ifdef RTE_NET_I40E
17822 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17824 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17825 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17826 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17827 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17828 (cmdline_parse_inst_t *)&cmd_flow,
17829 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17830 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17831 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17832 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17833 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17834 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17835 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17836 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17837 (cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
17838 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17839 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17840 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17841 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17842 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17843 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17844 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17845 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17846 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17847 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17848 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17849 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17850 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17851 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17852 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17853 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17854 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17855 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17856 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17857 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17858 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17859 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17860 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17861 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17862 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17863 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17864 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17865 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17866 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
17867 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
17868 (cmdline_parse_inst_t *)&cmd_set_vxlan,
17869 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
17870 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17871 (cmdline_parse_inst_t *)&cmd_set_nvgre,
17872 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17873 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
17874 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
17875 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
17876 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
17877 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
17878 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
17879 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
17880 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
17881 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
17882 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
17883 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
17884 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
17885 (cmdline_parse_inst_t *)&cmd_set_conntrack_common,
17886 (cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
17887 (cmdline_parse_inst_t *)&cmd_ddp_add,
17888 (cmdline_parse_inst_t *)&cmd_ddp_del,
17889 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
17890 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
17891 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
17892 (cmdline_parse_inst_t *)&cmd_clear_input_set,
17893 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
17894 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17895 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
17896 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
17897 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17898 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17899 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17900 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17902 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17903 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17904 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17905 (cmdline_parse_inst_t *)&cmd_queue_region,
17906 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17907 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17908 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17909 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17910 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17911 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17912 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17913 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17914 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17915 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17916 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17917 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17918 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17919 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17920 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17921 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17922 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17923 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
17924 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17925 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17926 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17927 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17928 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17929 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17930 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
17931 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
17932 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
17933 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17934 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17935 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17936 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17937 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17938 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17939 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17940 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17941 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17943 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17944 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17946 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
17947 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
17948 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
17949 (cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
17950 (cmdline_parse_inst_t *)&cmd_set_raw,
17951 (cmdline_parse_inst_t *)&cmd_show_set_raw,
17952 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
17953 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
17954 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
17955 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
17956 (cmdline_parse_inst_t *)&cmd_show_capability,
17957 (cmdline_parse_inst_t *)&cmd_set_flex_is_pattern,
17958 (cmdline_parse_inst_t *)&cmd_set_flex_spec_pattern,
17962 /* read cmdline commands from file */
17964 cmdline_read_from_file(const char *filename)
17966 struct cmdline *cl;
17968 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17971 "Failed to create file based cmdline context: %s\n",
17976 cmdline_interact(cl);
17981 printf("Read CLI commands from %s\n", filename);
17984 /* prompt function, called from main on MAIN lcore */
17989 /* initialize non-constant commands */
17990 cmd_set_fwd_mode_init();
17991 cmd_set_fwd_retry_mode_init();
17993 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17994 if (testpmd_cl == NULL)
17997 ret = atexit(prompt_exit);
17999 fprintf(stderr, "Cannot set exit function for cmdline\n");
18001 cmdline_interact(testpmd_cl);
18003 cmdline_stdin_exit(testpmd_cl);
18009 if (testpmd_cl != NULL) {
18010 cmdline_quit(testpmd_cl);
18011 cmdline_stdin_exit(testpmd_cl);
18016 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
18018 if (id == (portid_t)RTE_PORT_ALL) {
18021 RTE_ETH_FOREACH_DEV(pid) {
18022 /* check if need_reconfig has been set to 1 */
18023 if (ports[pid].need_reconfig == 0)
18024 ports[pid].need_reconfig = dev;
18025 /* check if need_reconfig_queues has been set to 1 */
18026 if (ports[pid].need_reconfig_queues == 0)
18027 ports[pid].need_reconfig_queues = queue;
18029 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
18030 /* check if need_reconfig has been set to 1 */
18031 if (ports[id].need_reconfig == 0)
18032 ports[id].need_reconfig = dev;
18033 /* check if need_reconfig_queues has been set to 1 */
18034 if (ports[id].need_reconfig_queues == 0)
18035 ports[id].need_reconfig_queues = queue;