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) fec capabilities"
257 " Show fec capabilities of a port.\n\n"
259 "show port (port_id) fec_mode"
260 " Show fec mode of a port.\n\n"
262 "show port (port_id) flow_ctrl"
263 " Show flow control info of a port.\n\n"
267 if (show_all || !strcmp(res->section, "config")) {
273 "Configuration changes only become active when"
274 " forwarding is started/restarted.\n\n"
277 " Reset forwarding to the default configuration.\n\n"
279 "set verbose (level)\n"
280 " Set the debug verbosity level X.\n\n"
282 "set log global|(type) (level)\n"
283 " Set the log level.\n\n"
286 " Set number of ports.\n\n"
289 " Set number of cores.\n\n"
291 "set coremask (mask)\n"
292 " Set the forwarding cores hexadecimal mask.\n\n"
294 "set portmask (mask)\n"
295 " Set the forwarding ports hexadecimal mask.\n\n"
298 " Set number of packets per burst.\n\n"
300 "set burst tx delay (microseconds) retry (num)\n"
301 " Set the transmit delay time and number of retries,"
302 " effective when retry is enabled.\n\n"
304 "set rxoffs (x[,y]*)\n"
305 " Set the offset of each packet segment on"
306 " receiving if split feature is engaged."
307 " Affects only the queues configured with split"
310 "set rxpkts (x[,y]*)\n"
311 " Set the length of each segment to scatter"
312 " packets on receiving if split feature is engaged."
313 " Affects only the queues configured with split"
316 "set txpkts (x[,y]*)\n"
317 " Set the length of each segment of TXONLY"
318 " and optionally CSUM packets.\n\n"
320 "set txsplit (off|on|rand)\n"
321 " Set the split policy for the TX packets."
322 " Right now only applicable for CSUM and TXONLY"
325 "set txtimes (x, y)\n"
326 " Set the scheduling on timestamps"
327 " timings for the TXONLY mode\n\n"
329 "set corelist (x[,y]*)\n"
330 " Set the list of forwarding cores.\n\n"
332 "set portlist (x[,y]*)\n"
333 " Set the list of forwarding ports.\n\n"
335 "set port setup on (iterator|event)\n"
336 " Select how attached port is retrieved for setup.\n\n"
338 "set tx loopback (port_id) (on|off)\n"
339 " Enable or disable tx loopback.\n\n"
341 "set all queues drop (port_id) (on|off)\n"
342 " Set drop enable bit for all queues.\n\n"
344 "set vf split drop (port_id) (vf_id) (on|off)\n"
345 " Set split drop enable bit for a VF from the PF.\n\n"
347 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
348 " Set MAC antispoof for a VF from the PF.\n\n"
350 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
351 " Enable MACsec offload.\n\n"
353 "set macsec offload (port_id) off\n"
354 " Disable MACsec offload.\n\n"
356 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
357 " Configure MACsec secure connection (SC).\n\n"
359 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
360 " Configure MACsec secure association (SA).\n\n"
362 "set vf broadcast (port_id) (vf_id) (on|off)\n"
363 " Set VF broadcast for a VF from the PF.\n\n"
365 "vlan set stripq (on|off) (port_id,queue_id)\n"
366 " Set the VLAN strip for a queue on a port.\n\n"
368 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
369 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
371 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
372 " Set VLAN insert for a VF from the PF.\n\n"
374 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
375 " Set VLAN antispoof for a VF from the PF.\n\n"
377 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
378 " Set VLAN tag for a VF from the PF.\n\n"
380 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
381 " Set a VF's max bandwidth(Mbps).\n\n"
383 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
384 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
386 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
387 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
389 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
390 " Set some TCs' strict link priority mode on a physical port.\n\n"
392 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
393 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
395 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
396 " Set the VLAN strip or filter or qinq strip or extend\n\n"
398 "vlan set (inner|outer) tpid (value) (port_id)\n"
399 " Set the VLAN TPID for Packet Filtering on"
402 "rx_vlan add (vlan_id|all) (port_id)\n"
403 " Add a vlan_id, or all identifiers, to the set"
404 " of VLAN identifiers filtered by port_id.\n\n"
406 "rx_vlan rm (vlan_id|all) (port_id)\n"
407 " Remove a vlan_id, or all identifiers, from the set"
408 " of VLAN identifiers filtered by port_id.\n\n"
410 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
411 " Add a vlan_id, to the set of VLAN identifiers"
412 "filtered for VF(s) from port_id.\n\n"
414 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
415 " Remove a vlan_id, to the set of VLAN identifiers"
416 "filtered for VF(s) from port_id.\n\n"
418 "rx_vxlan_port add (udp_port) (port_id)\n"
419 " Add an UDP port for VXLAN packet filter on a port\n\n"
421 "rx_vxlan_port rm (udp_port) (port_id)\n"
422 " Remove an UDP port for VXLAN packet filter on a port\n\n"
424 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
425 " Set hardware insertion of VLAN IDs (single or double VLAN "
426 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
428 "tx_vlan set pvid port_id vlan_id (on|off)\n"
429 " Set port based TX VLAN insertion.\n\n"
431 "tx_vlan reset (port_id)\n"
432 " Disable hardware insertion of a VLAN header in"
433 " packets sent on a port.\n\n"
435 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
436 " Select hardware or software calculation of the"
437 " checksum when transmitting a packet using the"
438 " csum forward engine.\n"
439 " ip|udp|tcp|sctp always concern the inner layer.\n"
440 " outer-ip concerns the outer IP layer in"
441 " outer-udp concerns the outer UDP layer in"
442 " case the packet is recognized as a tunnel packet by"
443 " the forward engine (vxlan, gre and ipip are supported)\n"
444 " Please check the NIC datasheet for HW limits.\n\n"
446 "csum parse-tunnel (on|off) (tx_port_id)\n"
447 " If disabled, treat tunnel packets as non-tunneled"
448 " packets (treat inner headers as payload). The port\n"
449 " argument is the port used for TX in csum forward"
452 "csum show (port_id)\n"
453 " Display tx checksum offload configuration\n\n"
455 "tso set (segsize) (portid)\n"
456 " Enable TCP Segmentation Offload in csum forward"
458 " Please check the NIC datasheet for HW limits.\n\n"
461 " Display the status of TCP Segmentation Offload.\n\n"
464 "set port (port_id) gro on|off\n"
465 " Enable or disable Generic Receive Offload in"
466 " csum forwarding engine.\n\n"
468 "show port (port_id) gro\n"
469 " Display GRO configuration.\n\n"
471 "set gro flush (cycles)\n"
472 " Set the cycle to flush GROed packets from"
473 " reassembly tables.\n\n"
477 "set port (port_id) gso (on|off)"
478 " Enable or disable Generic Segmentation Offload in"
479 " csum forwarding engine.\n\n"
481 "set gso segsz (length)\n"
482 " Set max packet length for output GSO segments,"
483 " including packet header and payload.\n\n"
485 "show port (port_id) gso\n"
486 " Show GSO configuration.\n\n"
490 " Set packet forwarding mode.\n\n"
492 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
493 " Add a MAC address on port_id.\n\n"
495 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
496 " Remove a MAC address from port_id.\n\n"
498 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
499 " Set the default MAC address for port_id.\n\n"
501 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
502 " Add a MAC address for a VF on the port.\n\n"
504 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
505 " Set the MAC address for a VF from the PF.\n\n"
507 "set eth-peer (port_id) (peer_addr)\n"
508 " set the peer address for certain port.\n\n"
510 "set port (port_id) uta (mac_address|all) (on|off)\n"
511 " Add/Remove a or all unicast hash filter(s)"
514 "set promisc (port_id|all) (on|off)\n"
515 " Set the promiscuous mode on port_id, or all.\n\n"
517 "set allmulti (port_id|all) (on|off)\n"
518 " Set the allmulti mode on port_id, or all.\n\n"
520 "set vf promisc (port_id) (vf_id) (on|off)\n"
521 " Set unicast promiscuous mode for a VF from the PF.\n\n"
523 "set vf allmulti (port_id) (vf_id) (on|off)\n"
524 " Set multicast promiscuous mode for a VF from the PF.\n\n"
526 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
527 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
528 " (on|off) autoneg (on|off) (port_id)\n"
529 "set flow_ctrl rx (on|off) (portid)\n"
530 "set flow_ctrl tx (on|off) (portid)\n"
531 "set flow_ctrl high_water (high_water) (portid)\n"
532 "set flow_ctrl low_water (low_water) (portid)\n"
533 "set flow_ctrl pause_time (pause_time) (portid)\n"
534 "set flow_ctrl send_xon (send_xon) (portid)\n"
535 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
536 "set flow_ctrl autoneg (on|off) (port_id)\n"
537 " Set the link flow control parameter on a port.\n\n"
539 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
540 " (low_water) (pause_time) (priority) (port_id)\n"
541 " Set the priority flow control parameter on a"
544 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
545 " Set statistics mapping (qmapping 0..15) for RX/TX"
547 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
548 " on port 0 to mapping 5.\n\n"
550 "set xstats-hide-zero on|off\n"
551 " Set the option to hide the zero values"
552 " for xstats display.\n"
554 "set record-core-cycles on|off\n"
555 " Set the option to enable measurement of CPU cycles.\n"
557 "set record-burst-stats on|off\n"
558 " Set the option to enable display of RX and TX bursts.\n"
560 "set port (port_id) vf (vf_id) rx|tx on|off\n"
561 " Enable/Disable a VF receive/tranmit from a port\n\n"
563 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
565 " AUPE:accepts untagged VLAN;"
566 "ROPE:accept unicast hash\n\n"
567 " BAM:accepts broadcast packets;"
568 "MPE:accepts all multicast packets\n\n"
569 " Enable/Disable a VF receive mode of a port\n\n"
571 "set port (port_id) queue (queue_id) rate (rate_num)\n"
572 " Set rate limit for a queue of a port\n\n"
574 "set port (port_id) vf (vf_id) rate (rate_num) "
575 "queue_mask (queue_mask_value)\n"
576 " Set rate limit for queues in VF of a port\n\n"
578 "set flush_rx (on|off)\n"
579 " Flush (default) or don't flush RX streams before"
580 " forwarding. Mainly used with PCAP drivers.\n\n"
582 "set bypass mode (normal|bypass|isolate) (port_id)\n"
583 " Set the bypass mode for the lowest port on bypass enabled"
586 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
587 "mode (normal|bypass|isolate) (port_id)\n"
588 " Set the event required to initiate specified bypass mode for"
589 " the lowest port on a bypass enabled NIC where:\n"
590 " timeout = enable bypass after watchdog timeout.\n"
591 " os_on = enable bypass when OS/board is powered on.\n"
592 " os_off = enable bypass when OS/board is powered off.\n"
593 " power_on = enable bypass when power supply is turned on.\n"
594 " power_off = enable bypass when power supply is turned off."
597 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
598 " Set the bypass watchdog timeout to 'n' seconds"
599 " where 0 = instant.\n\n"
601 "show bypass config (port_id)\n"
602 " Show the bypass configuration for a bypass enabled NIC"
603 " using the lowest port on the NIC.\n\n"
606 "create bonded device (mode) (socket)\n"
607 " Create a new bonded device with specific bonding mode and socket.\n\n"
609 "add bonding slave (slave_id) (port_id)\n"
610 " Add a slave device to a bonded device.\n\n"
612 "remove bonding slave (slave_id) (port_id)\n"
613 " Remove a slave device from a bonded device.\n\n"
615 "set bonding mode (value) (port_id)\n"
616 " Set the bonding mode on a bonded device.\n\n"
618 "set bonding primary (slave_id) (port_id)\n"
619 " Set the primary slave for a bonded device.\n\n"
621 "show bonding config (port_id)\n"
622 " Show the bonding config for port_id.\n\n"
624 "show bonding lacp info (port_id)\n"
625 " Show the bonding lacp information for port_id.\n\n"
627 "set bonding mac_addr (port_id) (address)\n"
628 " Set the MAC address of a bonded device.\n\n"
630 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
631 " Set Aggregation mode for IEEE802.3AD (mode 4)"
633 "set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
634 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
636 "set bonding mon_period (port_id) (value)\n"
637 " Set the bonding link status monitoring polling period in ms.\n\n"
639 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
640 " Enable/disable dedicated queues for LACP control traffic.\n\n"
643 "set link-up port (port_id)\n"
644 " Set link up for a port.\n\n"
646 "set link-down port (port_id)\n"
647 " Set link down for a port.\n\n"
649 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
650 " Load a profile package on a port\n\n"
652 "ddp del (port_id) (backup_profile_path)\n"
653 " Delete a profile package from a port\n\n"
655 "ptype mapping get (port_id) (valid_only)\n"
656 " Get ptype mapping on a port\n\n"
658 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
659 " Replace target with the pkt_type in ptype mapping\n\n"
661 "ptype mapping reset (port_id)\n"
662 " Reset ptype mapping on a port\n\n"
664 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
665 " Update a ptype mapping item on a port\n\n"
667 "set port (port_id) ptype_mask (ptype_mask)\n"
668 " set packet types classification for a specific port\n\n"
670 "set port (port_id) queue-region region_id (value) "
671 "queue_start_index (value) queue_num (value)\n"
672 " Set a queue region on a port\n\n"
674 "set port (port_id) queue-region region_id (value) "
676 " Set a flowtype region index on a port\n\n"
678 "set port (port_id) queue-region UP (value) region_id (value)\n"
679 " Set the mapping of User Priority to "
680 "queue region on a port\n\n"
682 "set port (port_id) queue-region flush (on|off)\n"
683 " flush all queue region related configuration\n\n"
685 "show port meter cap (port_id)\n"
686 " Show port meter capability information\n\n"
688 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
689 " meter profile add - srtcm rfc 2697\n\n"
691 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
692 " meter profile add - trtcm rfc 2698\n\n"
694 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
695 " meter profile add - trtcm rfc 4115\n\n"
697 "del port meter profile (port_id) (profile_id)\n"
698 " meter profile delete\n\n"
700 "create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
701 "(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
702 "(dscp_tbl_entry63)]\n"
705 "enable port meter (port_id) (mtr_id)\n"
708 "disable port meter (port_id) (mtr_id)\n"
711 "del port meter (port_id) (mtr_id)\n"
714 "add port meter policy (port_id) (policy_id) g_actions (actions)\n"
715 "y_actions (actions) r_actions (actions)\n"
716 " meter policy add\n\n"
718 "del port meter policy (port_id) (policy_id)\n"
719 " meter policy delete\n\n"
721 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
722 " meter update meter profile\n\n"
724 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
725 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
726 " update meter dscp table entries\n\n"
728 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
729 "(action0) [(action1) (action2)]\n"
730 " meter update policer action\n\n"
732 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
733 " meter update stats\n\n"
735 "show port (port_id) queue-region\n"
736 " show all queue region related configuration info\n\n"
738 "set port (port_id) fec_mode auto|off|rs|baser\n"
739 " set fec mode for a specific port\n\n"
741 , list_pkt_forwarding_modes()
745 if (show_all || !strcmp(res->section, "ports")) {
751 "----------------\n\n"
753 "port start (port_id|all)\n"
754 " Start all ports or port_id.\n\n"
756 "port stop (port_id|all)\n"
757 " Stop all ports or port_id.\n\n"
759 "port close (port_id|all)\n"
760 " Close all ports or port_id.\n\n"
762 "port reset (port_id|all)\n"
763 " Reset all ports or port_id.\n\n"
765 "port attach (ident)\n"
766 " Attach physical or virtual dev by pci address or virtual device name\n\n"
768 "port detach (port_id)\n"
769 " Detach physical or virtual dev by port_id\n\n"
771 "port config (port_id|all)"
772 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
773 " duplex (half|full|auto)\n"
774 " Set speed and duplex for all ports or port_id\n\n"
776 "port config (port_id|all) loopback (mode)\n"
777 " Set loopback mode for all ports or port_id\n\n"
779 "port config all (rxq|txq|rxd|txd) (value)\n"
780 " Set number for rxq/txq/rxd/txd.\n\n"
782 "port config all max-pkt-len (value)\n"
783 " Set the max packet length.\n\n"
785 "port config all max-lro-pkt-size (value)\n"
786 " Set the max LRO aggregated packet size.\n\n"
788 "port config all drop-en (on|off)\n"
789 " Enable or disable packet drop on all RX queues of all ports when no "
790 "receive buffers available.\n\n"
792 "port config all rss (all|default|ip|tcp|udp|sctp|"
793 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|none|level-default|"
794 "level-outer|level-inner|<flowtype_id>)\n"
795 " Set the RSS mode.\n\n"
797 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
798 " Set the RSS redirection table.\n\n"
800 "port config (port_id) dcb vt (on|off) (traffic_class)"
802 " Set the DCB mode.\n\n"
804 "port config all burst (value)\n"
805 " Set the number of packets per burst.\n\n"
807 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
809 " Set the ring prefetch/host/writeback threshold"
810 " for tx/rx queue.\n\n"
812 "port config all (txfreet|txrst|rxfreet) (value)\n"
813 " Set free threshold for rx/tx, or set"
814 " tx rs bit threshold.\n\n"
815 "port config mtu X value\n"
816 " Set the MTU of port X to a given value\n\n"
818 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
819 " Set a rx/tx queue's ring size configuration, the new"
820 " value will take effect after command that (re-)start the port"
821 " or command that setup the specific queue\n\n"
823 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
824 " Start/stop a rx/tx queue of port X. Only take effect"
825 " when port X is started\n\n"
827 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
828 " Switch on/off a deferred start of port X rx/tx queue. Only"
829 " take effect when port X is stopped.\n\n"
831 "port (port_id) (rxq|txq) (queue_id) setup\n"
832 " Setup a rx/tx queue of port X.\n\n"
834 "port config (port_id) pctype mapping reset\n"
835 " Reset flow type to pctype mapping on a port\n\n"
837 "port config (port_id) pctype mapping update"
838 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
839 " Update a flow type to pctype mapping item on a port\n\n"
841 "port config (port_id) pctype (pctype_id) hash_inset|"
842 "fdir_inset|fdir_flx_inset get|set|clear field\n"
844 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
846 "port config (port_id) pctype (pctype_id) hash_inset|"
847 "fdir_inset|fdir_flx_inset clear all"
848 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
850 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
851 " Add/remove UDP tunnel port for tunneling offload\n\n"
853 "port config <port_id> rx_offload vlan_strip|"
854 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
855 "outer_ipv4_cksum|macsec_strip|header_split|"
856 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
857 "buffer_split|timestamp|security|keep_crc on|off\n"
858 " Enable or disable a per port Rx offloading"
859 " on all Rx queues of a port\n\n"
861 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
862 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
863 "outer_ipv4_cksum|macsec_strip|header_split|"
864 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
865 "buffer_split|timestamp|security|keep_crc on|off\n"
866 " Enable or disable a per queue Rx offloading"
867 " only on a specific Rx queue\n\n"
869 "port config (port_id) tx_offload vlan_insert|"
870 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
871 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
872 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
873 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
875 " Enable or disable a per port Tx offloading"
876 " on all Tx queues of a port\n\n"
878 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
879 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
880 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
881 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
882 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
884 " Enable or disable a per queue Tx offloading"
885 " only on a specific Tx queue\n\n"
887 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
888 " Load an eBPF program as a callback"
889 " for particular RX/TX queue\n\n"
891 "bpf-unload rx|tx (port) (queue)\n"
892 " Unload previously loaded eBPF program"
893 " for particular RX/TX queue\n\n"
895 "port config (port_id) tx_metadata (value)\n"
896 " Set Tx metadata value per port. Testpmd will add this value"
897 " to any Tx packet sent from this port\n\n"
899 "port config (port_id) dynf (name) set|clear\n"
900 " Register a dynf and Set/clear this flag on Tx. "
901 "Testpmd will set this value to any Tx packet "
902 "sent from this port\n\n"
904 "port cleanup (port_id) txq (queue_id) (free_cnt)\n"
905 " Cleanup txq mbufs for a specific Tx queue\n\n"
909 if (show_all || !strcmp(res->section, "registers")) {
917 "read reg (port_id) (address)\n"
918 " Display value of a port register.\n\n"
920 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
921 " Display a port register bit field.\n\n"
923 "read regbit (port_id) (address) (bit_x)\n"
924 " Display a single port register bit.\n\n"
926 "write reg (port_id) (address) (value)\n"
927 " Set value of a port register.\n\n"
929 "write regfield (port_id) (address) (bit_x) (bit_y)"
931 " Set bit field of a port register.\n\n"
933 "write regbit (port_id) (address) (bit_x) (value)\n"
934 " Set single bit value of a port register.\n\n"
937 if (show_all || !strcmp(res->section, "filters")) {
946 "flow_director_filter (port_id) mode raw (add|del|update)"
947 " flow (flow_id) (drop|fwd) queue (queue_id)"
948 " fd_id (fd_id_value) packet (packet file name)\n"
949 " Add/Del a raw type flow director filter.\n\n"
952 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
953 " src_mask (ipv4_src) (ipv6_src) (src_port)"
954 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
955 " Set flow director IP mask.\n\n"
957 "flow_director_mask (port_id) mode MAC-VLAN"
958 " vlan (vlan_value)\n"
959 " Set flow director MAC-VLAN mask.\n\n"
961 "flow_director_mask (port_id) mode Tunnel"
962 " vlan (vlan_value) mac (mac_value)"
963 " tunnel-type (tunnel_type_value)"
964 " tunnel-id (tunnel_id_value)\n"
965 " Set flow director Tunnel mask.\n\n"
967 "flow_director_flex_payload (port_id)"
968 " (raw|l2|l3|l4) (config)\n"
969 " Configure flex payload selection.\n\n"
971 "flow validate {port_id}"
972 " [group {group_id}] [priority {level}]"
973 " [ingress] [egress]"
974 " pattern {item} [/ {item} [...]] / end"
975 " actions {action} [/ {action} [...]] / end\n"
976 " Check whether a flow rule can be created.\n\n"
978 "flow create {port_id}"
979 " [group {group_id}] [priority {level}]"
980 " [ingress] [egress]"
981 " pattern {item} [/ {item} [...]] / end"
982 " actions {action} [/ {action} [...]] / end\n"
983 " Create a flow rule.\n\n"
985 "flow destroy {port_id} rule {rule_id} [...]\n"
986 " Destroy specific flow rules.\n\n"
988 "flow flush {port_id}\n"
989 " Destroy all flow rules.\n\n"
991 "flow query {port_id} {rule_id} {action}\n"
992 " Query an existing flow rule.\n\n"
994 "flow list {port_id} [group {group_id}] [...]\n"
995 " List existing flow rules sorted by priority,"
996 " filtered by group identifiers.\n\n"
998 "flow isolate {port_id} {boolean}\n"
999 " Restrict ingress traffic to the defined"
1002 "flow aged {port_id} [destroy]\n"
1003 " List and destroy aged flows"
1006 "flow indirect_action {port_id} create"
1007 " [action_id {indirect_action_id}]"
1008 " [ingress] [egress]"
1009 " action {action} / end\n"
1010 " Create indirect action.\n\n"
1012 "flow indirect_action {port_id} update"
1013 " {indirect_action_id} action {action} / end\n"
1014 " Update indirect action.\n\n"
1016 "flow indirect_action {port_id} destroy"
1017 " action_id {indirect_action_id} [...]\n"
1018 " Destroy specific indirect actions.\n\n"
1020 "flow indirect_action {port_id} query"
1021 " {indirect_action_id}\n"
1022 " Query an existing indirect action.\n\n"
1024 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1025 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1026 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1027 " Configure the VXLAN encapsulation for flows.\n\n"
1029 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1030 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1031 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1032 " eth-dst (eth-dst)\n"
1033 " Configure the VXLAN encapsulation for flows.\n\n"
1035 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1036 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1037 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1038 " eth-dst (eth-dst)\n"
1039 " Configure the VXLAN encapsulation for flows.\n\n"
1041 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1042 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1044 " Configure the NVGRE encapsulation for flows.\n\n"
1046 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1047 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1048 " eth-src (eth-src) eth-dst (eth-dst)\n"
1049 " Configure the NVGRE encapsulation for flows.\n\n"
1051 "set raw_encap {flow items}\n"
1052 " Configure the encapsulation with raw data.\n\n"
1054 "set raw_decap {flow items}\n"
1055 " Configure the decapsulation with raw data.\n\n"
1060 if (show_all || !strcmp(res->section, "traffic_management")) {
1064 "Traffic Management:\n"
1066 "show port tm cap (port_id)\n"
1067 " Display the port TM capability.\n\n"
1069 "show port tm level cap (port_id) (level_id)\n"
1070 " Display the port TM hierarchical level capability.\n\n"
1072 "show port tm node cap (port_id) (node_id)\n"
1073 " Display the port TM node capability.\n\n"
1075 "show port tm node type (port_id) (node_id)\n"
1076 " Display the port TM node type.\n\n"
1078 "show port tm node stats (port_id) (node_id) (clear)\n"
1079 " Display the port TM node stats.\n\n"
1081 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1082 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1083 " (packet_length_adjust) (packet_mode)\n"
1084 " Add port tm node private shaper profile.\n\n"
1086 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1087 " Delete port tm node private shaper profile.\n\n"
1089 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1090 " (shaper_profile_id)\n"
1091 " Add/update port tm node shared shaper.\n\n"
1093 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1094 " Delete port tm node shared shaper.\n\n"
1096 "set port tm node shaper profile (port_id) (node_id)"
1097 " (shaper_profile_id)\n"
1098 " Set port tm node shaper profile.\n\n"
1100 "add port tm node wred profile (port_id) (wred_profile_id)"
1101 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1102 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1103 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1104 " Add port tm node wred profile.\n\n"
1106 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1107 " Delete port tm node wred profile.\n\n"
1109 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1110 " (priority) (weight) (level_id) (shaper_profile_id)"
1111 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1112 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1113 " Add port tm nonleaf node.\n\n"
1115 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1116 " (priority) (weight) (level_id) (shaper_profile_id)"
1117 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1118 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1119 " Add port tm nonleaf node with pkt mode enabled.\n\n"
1121 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1122 " (priority) (weight) (level_id) (shaper_profile_id)"
1123 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1124 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1125 " Add port tm leaf node.\n\n"
1127 "del port tm node (port_id) (node_id)\n"
1128 " Delete port tm node.\n\n"
1130 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1131 " (priority) (weight)\n"
1132 " Set port tm node parent.\n\n"
1134 "suspend port tm node (port_id) (node_id)"
1135 " Suspend tm node.\n\n"
1137 "resume port tm node (port_id) (node_id)"
1138 " Resume tm node.\n\n"
1140 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1141 " Commit tm hierarchy.\n\n"
1143 "set port tm mark ip_ecn (port) (green) (yellow)"
1145 " Enables/Disables the traffic management marking"
1146 " for IP ECN (Explicit Congestion Notification)"
1147 " packets on a given port\n\n"
1149 "set port tm mark ip_dscp (port) (green) (yellow)"
1151 " Enables/Disables the traffic management marking"
1152 " on the port for IP dscp packets\n\n"
1154 "set port tm mark vlan_dei (port) (green) (yellow)"
1156 " Enables/Disables the traffic management marking"
1157 " on the port for VLAN packets with DEI enabled\n\n"
1161 if (show_all || !strcmp(res->section, "devices")) {
1165 "Device Operations:\n"
1167 "device detach (identifier)\n"
1168 " Detach device by identifier.\n\n"
1174 cmdline_parse_token_string_t cmd_help_long_help =
1175 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1177 cmdline_parse_token_string_t cmd_help_long_section =
1178 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1179 "all#control#display#config#"
1180 "ports#registers#filters#traffic_management#devices");
1182 cmdline_parse_inst_t cmd_help_long = {
1183 .f = cmd_help_long_parsed,
1185 .help_str = "help all|control|display|config|ports|register|"
1186 "filters|traffic_management|devices: "
1189 (void *)&cmd_help_long_help,
1190 (void *)&cmd_help_long_section,
1196 /* *** start/stop/close all ports *** */
1197 struct cmd_operate_port_result {
1198 cmdline_fixed_string_t keyword;
1199 cmdline_fixed_string_t name;
1200 cmdline_fixed_string_t value;
1203 static void cmd_operate_port_parsed(void *parsed_result,
1204 __rte_unused struct cmdline *cl,
1205 __rte_unused void *data)
1207 struct cmd_operate_port_result *res = parsed_result;
1209 if (!strcmp(res->name, "start"))
1210 start_port(RTE_PORT_ALL);
1211 else if (!strcmp(res->name, "stop"))
1212 stop_port(RTE_PORT_ALL);
1213 else if (!strcmp(res->name, "close"))
1214 close_port(RTE_PORT_ALL);
1215 else if (!strcmp(res->name, "reset"))
1216 reset_port(RTE_PORT_ALL);
1218 fprintf(stderr, "Unknown parameter\n");
1221 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1222 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1224 cmdline_parse_token_string_t cmd_operate_port_all_port =
1225 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1226 "start#stop#close#reset");
1227 cmdline_parse_token_string_t cmd_operate_port_all_all =
1228 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1230 cmdline_parse_inst_t cmd_operate_port = {
1231 .f = cmd_operate_port_parsed,
1233 .help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports",
1235 (void *)&cmd_operate_port_all_cmd,
1236 (void *)&cmd_operate_port_all_port,
1237 (void *)&cmd_operate_port_all_all,
1242 /* *** start/stop/close specific port *** */
1243 struct cmd_operate_specific_port_result {
1244 cmdline_fixed_string_t keyword;
1245 cmdline_fixed_string_t name;
1249 static void cmd_operate_specific_port_parsed(void *parsed_result,
1250 __rte_unused struct cmdline *cl,
1251 __rte_unused void *data)
1253 struct cmd_operate_specific_port_result *res = parsed_result;
1255 if (!strcmp(res->name, "start"))
1256 start_port(res->value);
1257 else if (!strcmp(res->name, "stop"))
1258 stop_port(res->value);
1259 else if (!strcmp(res->name, "close"))
1260 close_port(res->value);
1261 else if (!strcmp(res->name, "reset"))
1262 reset_port(res->value);
1264 fprintf(stderr, "Unknown parameter\n");
1267 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1268 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1270 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1271 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1272 name, "start#stop#close#reset");
1273 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1274 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1277 cmdline_parse_inst_t cmd_operate_specific_port = {
1278 .f = cmd_operate_specific_port_parsed,
1280 .help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id",
1282 (void *)&cmd_operate_specific_port_cmd,
1283 (void *)&cmd_operate_specific_port_port,
1284 (void *)&cmd_operate_specific_port_id,
1289 /* *** enable port setup (after attach) via iterator or event *** */
1290 struct cmd_set_port_setup_on_result {
1291 cmdline_fixed_string_t set;
1292 cmdline_fixed_string_t port;
1293 cmdline_fixed_string_t setup;
1294 cmdline_fixed_string_t on;
1295 cmdline_fixed_string_t mode;
1298 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1299 __rte_unused struct cmdline *cl,
1300 __rte_unused void *data)
1302 struct cmd_set_port_setup_on_result *res = parsed_result;
1304 if (strcmp(res->mode, "event") == 0)
1305 setup_on_probe_event = true;
1306 else if (strcmp(res->mode, "iterator") == 0)
1307 setup_on_probe_event = false;
1309 fprintf(stderr, "Unknown mode\n");
1312 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1313 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1315 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1316 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1318 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1319 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1321 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1322 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1324 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1325 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1326 mode, "iterator#event");
1328 cmdline_parse_inst_t cmd_set_port_setup_on = {
1329 .f = cmd_set_port_setup_on_parsed,
1331 .help_str = "set port setup on iterator|event",
1333 (void *)&cmd_set_port_setup_on_set,
1334 (void *)&cmd_set_port_setup_on_port,
1335 (void *)&cmd_set_port_setup_on_setup,
1336 (void *)&cmd_set_port_setup_on_on,
1337 (void *)&cmd_set_port_setup_on_mode,
1342 /* *** attach a specified port *** */
1343 struct cmd_operate_attach_port_result {
1344 cmdline_fixed_string_t port;
1345 cmdline_fixed_string_t keyword;
1346 cmdline_multi_string_t identifier;
1349 static void cmd_operate_attach_port_parsed(void *parsed_result,
1350 __rte_unused struct cmdline *cl,
1351 __rte_unused void *data)
1353 struct cmd_operate_attach_port_result *res = parsed_result;
1355 if (!strcmp(res->keyword, "attach"))
1356 attach_port(res->identifier);
1358 fprintf(stderr, "Unknown parameter\n");
1361 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1362 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1364 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1365 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1367 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1368 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1369 identifier, TOKEN_STRING_MULTI);
1371 cmdline_parse_inst_t cmd_operate_attach_port = {
1372 .f = cmd_operate_attach_port_parsed,
1374 .help_str = "port attach <identifier>: "
1375 "(identifier: pci address or virtual dev name)",
1377 (void *)&cmd_operate_attach_port_port,
1378 (void *)&cmd_operate_attach_port_keyword,
1379 (void *)&cmd_operate_attach_port_identifier,
1384 /* *** detach a specified port *** */
1385 struct cmd_operate_detach_port_result {
1386 cmdline_fixed_string_t port;
1387 cmdline_fixed_string_t keyword;
1391 static void cmd_operate_detach_port_parsed(void *parsed_result,
1392 __rte_unused struct cmdline *cl,
1393 __rte_unused void *data)
1395 struct cmd_operate_detach_port_result *res = parsed_result;
1397 if (!strcmp(res->keyword, "detach")) {
1398 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1399 detach_port_device(res->port_id);
1401 fprintf(stderr, "Unknown parameter\n");
1405 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1406 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1408 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1409 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1411 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1412 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1413 port_id, RTE_UINT16);
1415 cmdline_parse_inst_t cmd_operate_detach_port = {
1416 .f = cmd_operate_detach_port_parsed,
1418 .help_str = "port detach <port_id>",
1420 (void *)&cmd_operate_detach_port_port,
1421 (void *)&cmd_operate_detach_port_keyword,
1422 (void *)&cmd_operate_detach_port_port_id,
1427 /* *** detach device by identifier *** */
1428 struct cmd_operate_detach_device_result {
1429 cmdline_fixed_string_t device;
1430 cmdline_fixed_string_t keyword;
1431 cmdline_fixed_string_t identifier;
1434 static void cmd_operate_detach_device_parsed(void *parsed_result,
1435 __rte_unused struct cmdline *cl,
1436 __rte_unused void *data)
1438 struct cmd_operate_detach_device_result *res = parsed_result;
1440 if (!strcmp(res->keyword, "detach"))
1441 detach_devargs(res->identifier);
1443 fprintf(stderr, "Unknown parameter\n");
1446 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1447 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1449 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1450 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1452 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1453 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1456 cmdline_parse_inst_t cmd_operate_detach_device = {
1457 .f = cmd_operate_detach_device_parsed,
1459 .help_str = "device detach <identifier>:"
1460 "(identifier: pci address or virtual dev name)",
1462 (void *)&cmd_operate_detach_device_device,
1463 (void *)&cmd_operate_detach_device_keyword,
1464 (void *)&cmd_operate_detach_device_identifier,
1468 /* *** configure speed for all ports *** */
1469 struct cmd_config_speed_all {
1470 cmdline_fixed_string_t port;
1471 cmdline_fixed_string_t keyword;
1472 cmdline_fixed_string_t all;
1473 cmdline_fixed_string_t item1;
1474 cmdline_fixed_string_t item2;
1475 cmdline_fixed_string_t value1;
1476 cmdline_fixed_string_t value2;
1480 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1485 if (!strcmp(duplexstr, "half")) {
1486 duplex = RTE_ETH_LINK_HALF_DUPLEX;
1487 } else if (!strcmp(duplexstr, "full")) {
1488 duplex = RTE_ETH_LINK_FULL_DUPLEX;
1489 } else if (!strcmp(duplexstr, "auto")) {
1490 duplex = RTE_ETH_LINK_FULL_DUPLEX;
1492 fprintf(stderr, "Unknown duplex parameter\n");
1496 if (!strcmp(speedstr, "10")) {
1497 *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1498 RTE_ETH_LINK_SPEED_10M_HD : RTE_ETH_LINK_SPEED_10M;
1499 } else if (!strcmp(speedstr, "100")) {
1500 *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1501 RTE_ETH_LINK_SPEED_100M_HD : RTE_ETH_LINK_SPEED_100M;
1503 if (duplex != RTE_ETH_LINK_FULL_DUPLEX) {
1504 fprintf(stderr, "Invalid speed/duplex parameters\n");
1507 if (!strcmp(speedstr, "1000")) {
1508 *speed = RTE_ETH_LINK_SPEED_1G;
1509 } else if (!strcmp(speedstr, "10000")) {
1510 *speed = RTE_ETH_LINK_SPEED_10G;
1511 } else if (!strcmp(speedstr, "25000")) {
1512 *speed = RTE_ETH_LINK_SPEED_25G;
1513 } else if (!strcmp(speedstr, "40000")) {
1514 *speed = RTE_ETH_LINK_SPEED_40G;
1515 } else if (!strcmp(speedstr, "50000")) {
1516 *speed = RTE_ETH_LINK_SPEED_50G;
1517 } else if (!strcmp(speedstr, "100000")) {
1518 *speed = RTE_ETH_LINK_SPEED_100G;
1519 } else if (!strcmp(speedstr, "200000")) {
1520 *speed = RTE_ETH_LINK_SPEED_200G;
1521 } else if (!strcmp(speedstr, "auto")) {
1522 *speed = RTE_ETH_LINK_SPEED_AUTONEG;
1524 fprintf(stderr, "Unknown speed parameter\n");
1529 if (*speed != RTE_ETH_LINK_SPEED_AUTONEG)
1530 *speed |= RTE_ETH_LINK_SPEED_FIXED;
1536 cmd_config_speed_all_parsed(void *parsed_result,
1537 __rte_unused struct cmdline *cl,
1538 __rte_unused void *data)
1540 struct cmd_config_speed_all *res = parsed_result;
1541 uint32_t link_speed;
1544 if (!all_ports_stopped()) {
1545 fprintf(stderr, "Please stop all ports first\n");
1549 if (parse_and_check_speed_duplex(res->value1, res->value2,
1553 RTE_ETH_FOREACH_DEV(pid) {
1554 ports[pid].dev_conf.link_speeds = link_speed;
1557 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1560 cmdline_parse_token_string_t cmd_config_speed_all_port =
1561 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1562 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1563 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1565 cmdline_parse_token_string_t cmd_config_speed_all_all =
1566 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1567 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1568 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1569 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1570 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1571 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1572 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1573 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1574 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1575 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1578 cmdline_parse_inst_t cmd_config_speed_all = {
1579 .f = cmd_config_speed_all_parsed,
1581 .help_str = "port config all speed "
1582 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1585 (void *)&cmd_config_speed_all_port,
1586 (void *)&cmd_config_speed_all_keyword,
1587 (void *)&cmd_config_speed_all_all,
1588 (void *)&cmd_config_speed_all_item1,
1589 (void *)&cmd_config_speed_all_value1,
1590 (void *)&cmd_config_speed_all_item2,
1591 (void *)&cmd_config_speed_all_value2,
1596 /* *** configure speed for specific port *** */
1597 struct cmd_config_speed_specific {
1598 cmdline_fixed_string_t port;
1599 cmdline_fixed_string_t keyword;
1601 cmdline_fixed_string_t item1;
1602 cmdline_fixed_string_t item2;
1603 cmdline_fixed_string_t value1;
1604 cmdline_fixed_string_t value2;
1608 cmd_config_speed_specific_parsed(void *parsed_result,
1609 __rte_unused struct cmdline *cl,
1610 __rte_unused void *data)
1612 struct cmd_config_speed_specific *res = parsed_result;
1613 uint32_t link_speed;
1615 if (port_id_is_invalid(res->id, ENABLED_WARN))
1618 if (!port_is_stopped(res->id)) {
1619 fprintf(stderr, "Please stop port %d first\n", res->id);
1623 if (parse_and_check_speed_duplex(res->value1, res->value2,
1627 ports[res->id].dev_conf.link_speeds = link_speed;
1629 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1633 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1634 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1636 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1637 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1639 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1640 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1641 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1642 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1644 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1645 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1646 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1647 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1648 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1650 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1651 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1654 cmdline_parse_inst_t cmd_config_speed_specific = {
1655 .f = cmd_config_speed_specific_parsed,
1657 .help_str = "port config <port_id> speed "
1658 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1661 (void *)&cmd_config_speed_specific_port,
1662 (void *)&cmd_config_speed_specific_keyword,
1663 (void *)&cmd_config_speed_specific_id,
1664 (void *)&cmd_config_speed_specific_item1,
1665 (void *)&cmd_config_speed_specific_value1,
1666 (void *)&cmd_config_speed_specific_item2,
1667 (void *)&cmd_config_speed_specific_value2,
1672 /* *** configure loopback for all ports *** */
1673 struct cmd_config_loopback_all {
1674 cmdline_fixed_string_t port;
1675 cmdline_fixed_string_t keyword;
1676 cmdline_fixed_string_t all;
1677 cmdline_fixed_string_t item;
1682 cmd_config_loopback_all_parsed(void *parsed_result,
1683 __rte_unused struct cmdline *cl,
1684 __rte_unused void *data)
1686 struct cmd_config_loopback_all *res = parsed_result;
1689 if (!all_ports_stopped()) {
1690 fprintf(stderr, "Please stop all ports first\n");
1694 RTE_ETH_FOREACH_DEV(pid) {
1695 ports[pid].dev_conf.lpbk_mode = res->mode;
1698 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1701 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1702 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1703 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1704 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1706 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1707 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1708 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1709 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1711 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1712 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1714 cmdline_parse_inst_t cmd_config_loopback_all = {
1715 .f = cmd_config_loopback_all_parsed,
1717 .help_str = "port config all loopback <mode>",
1719 (void *)&cmd_config_loopback_all_port,
1720 (void *)&cmd_config_loopback_all_keyword,
1721 (void *)&cmd_config_loopback_all_all,
1722 (void *)&cmd_config_loopback_all_item,
1723 (void *)&cmd_config_loopback_all_mode,
1728 /* *** configure loopback for specific port *** */
1729 struct cmd_config_loopback_specific {
1730 cmdline_fixed_string_t port;
1731 cmdline_fixed_string_t keyword;
1733 cmdline_fixed_string_t item;
1738 cmd_config_loopback_specific_parsed(void *parsed_result,
1739 __rte_unused struct cmdline *cl,
1740 __rte_unused void *data)
1742 struct cmd_config_loopback_specific *res = parsed_result;
1744 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1747 if (!port_is_stopped(res->port_id)) {
1748 fprintf(stderr, "Please stop port %u first\n", res->port_id);
1752 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1754 cmd_reconfig_device_queue(res->port_id, 1, 1);
1758 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1759 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1761 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1762 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1764 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1765 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1767 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1768 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1770 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1771 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1774 cmdline_parse_inst_t cmd_config_loopback_specific = {
1775 .f = cmd_config_loopback_specific_parsed,
1777 .help_str = "port config <port_id> loopback <mode>",
1779 (void *)&cmd_config_loopback_specific_port,
1780 (void *)&cmd_config_loopback_specific_keyword,
1781 (void *)&cmd_config_loopback_specific_id,
1782 (void *)&cmd_config_loopback_specific_item,
1783 (void *)&cmd_config_loopback_specific_mode,
1788 /* *** configure txq/rxq, txd/rxd *** */
1789 struct cmd_config_rx_tx {
1790 cmdline_fixed_string_t port;
1791 cmdline_fixed_string_t keyword;
1792 cmdline_fixed_string_t all;
1793 cmdline_fixed_string_t name;
1798 cmd_config_rx_tx_parsed(void *parsed_result,
1799 __rte_unused struct cmdline *cl,
1800 __rte_unused void *data)
1802 struct cmd_config_rx_tx *res = parsed_result;
1804 if (!all_ports_stopped()) {
1805 fprintf(stderr, "Please stop all ports first\n");
1808 if (!strcmp(res->name, "rxq")) {
1809 if (!res->value && !nb_txq) {
1810 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1813 if (check_nb_rxq(res->value) != 0)
1815 nb_rxq = res->value;
1817 else if (!strcmp(res->name, "txq")) {
1818 if (!res->value && !nb_rxq) {
1819 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1822 if (check_nb_txq(res->value) != 0)
1824 nb_txq = res->value;
1826 else if (!strcmp(res->name, "rxd")) {
1827 if (check_nb_rxd(res->value) != 0)
1829 nb_rxd = res->value;
1830 } else if (!strcmp(res->name, "txd")) {
1831 if (check_nb_txd(res->value) != 0)
1834 nb_txd = res->value;
1836 fprintf(stderr, "Unknown parameter\n");
1844 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1847 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1848 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1849 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1850 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1851 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1852 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1853 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1854 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1856 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1857 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
1859 cmdline_parse_inst_t cmd_config_rx_tx = {
1860 .f = cmd_config_rx_tx_parsed,
1862 .help_str = "port config all rxq|txq|rxd|txd <value>",
1864 (void *)&cmd_config_rx_tx_port,
1865 (void *)&cmd_config_rx_tx_keyword,
1866 (void *)&cmd_config_rx_tx_all,
1867 (void *)&cmd_config_rx_tx_name,
1868 (void *)&cmd_config_rx_tx_value,
1873 /* *** config max packet length *** */
1874 struct cmd_config_max_pkt_len_result {
1875 cmdline_fixed_string_t port;
1876 cmdline_fixed_string_t keyword;
1877 cmdline_fixed_string_t all;
1878 cmdline_fixed_string_t name;
1883 cmd_config_max_pkt_len_parsed(void *parsed_result,
1884 __rte_unused struct cmdline *cl,
1885 __rte_unused void *data)
1887 struct cmd_config_max_pkt_len_result *res = parsed_result;
1891 if (strcmp(res->name, "max-pkt-len") != 0) {
1892 printf("Unknown parameter\n");
1896 if (!all_ports_stopped()) {
1897 fprintf(stderr, "Please stop all ports first\n");
1901 RTE_ETH_FOREACH_DEV(port_id) {
1902 struct rte_port *port = &ports[port_id];
1904 if (res->value < RTE_ETHER_MIN_LEN) {
1906 "max-pkt-len can not be less than %d\n",
1911 ret = eth_dev_info_get_print_err(port_id, &port->dev_info);
1914 "rte_eth_dev_info_get() failed for port %u\n",
1919 update_mtu_from_frame_size(port_id, res->value);
1924 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1927 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1928 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1930 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1931 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1933 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1934 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1936 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1937 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1939 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1940 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1943 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1944 .f = cmd_config_max_pkt_len_parsed,
1946 .help_str = "port config all max-pkt-len <value>",
1948 (void *)&cmd_config_max_pkt_len_port,
1949 (void *)&cmd_config_max_pkt_len_keyword,
1950 (void *)&cmd_config_max_pkt_len_all,
1951 (void *)&cmd_config_max_pkt_len_name,
1952 (void *)&cmd_config_max_pkt_len_value,
1957 /* *** config max LRO aggregated packet size *** */
1958 struct cmd_config_max_lro_pkt_size_result {
1959 cmdline_fixed_string_t port;
1960 cmdline_fixed_string_t keyword;
1961 cmdline_fixed_string_t all;
1962 cmdline_fixed_string_t name;
1967 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1968 __rte_unused struct cmdline *cl,
1969 __rte_unused void *data)
1971 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1974 if (!all_ports_stopped()) {
1975 fprintf(stderr, "Please stop all ports first\n");
1979 RTE_ETH_FOREACH_DEV(pid) {
1980 struct rte_port *port = &ports[pid];
1982 if (!strcmp(res->name, "max-lro-pkt-size")) {
1984 port->dev_conf.rxmode.max_lro_pkt_size)
1987 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
1989 fprintf(stderr, "Unknown parameter\n");
1996 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1999 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2000 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2002 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2003 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2005 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2006 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2008 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2009 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2010 name, "max-lro-pkt-size");
2011 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2012 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2015 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2016 .f = cmd_config_max_lro_pkt_size_parsed,
2018 .help_str = "port config all max-lro-pkt-size <value>",
2020 (void *)&cmd_config_max_lro_pkt_size_port,
2021 (void *)&cmd_config_max_lro_pkt_size_keyword,
2022 (void *)&cmd_config_max_lro_pkt_size_all,
2023 (void *)&cmd_config_max_lro_pkt_size_name,
2024 (void *)&cmd_config_max_lro_pkt_size_value,
2029 /* *** configure port MTU *** */
2030 struct cmd_config_mtu_result {
2031 cmdline_fixed_string_t port;
2032 cmdline_fixed_string_t keyword;
2033 cmdline_fixed_string_t mtu;
2039 cmd_config_mtu_parsed(void *parsed_result,
2040 __rte_unused struct cmdline *cl,
2041 __rte_unused void *data)
2043 struct cmd_config_mtu_result *res = parsed_result;
2045 if (res->value < RTE_ETHER_MIN_LEN) {
2046 fprintf(stderr, "mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2049 port_mtu_set(res->port_id, res->value);
2052 cmdline_parse_token_string_t cmd_config_mtu_port =
2053 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2055 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2056 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2058 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2059 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2061 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2062 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2064 cmdline_parse_token_num_t cmd_config_mtu_value =
2065 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2068 cmdline_parse_inst_t cmd_config_mtu = {
2069 .f = cmd_config_mtu_parsed,
2071 .help_str = "port config mtu <port_id> <value>",
2073 (void *)&cmd_config_mtu_port,
2074 (void *)&cmd_config_mtu_keyword,
2075 (void *)&cmd_config_mtu_mtu,
2076 (void *)&cmd_config_mtu_port_id,
2077 (void *)&cmd_config_mtu_value,
2082 /* *** configure rx mode *** */
2083 struct cmd_config_rx_mode_flag {
2084 cmdline_fixed_string_t port;
2085 cmdline_fixed_string_t keyword;
2086 cmdline_fixed_string_t all;
2087 cmdline_fixed_string_t name;
2088 cmdline_fixed_string_t value;
2092 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2093 __rte_unused struct cmdline *cl,
2094 __rte_unused void *data)
2096 struct cmd_config_rx_mode_flag *res = parsed_result;
2098 if (!all_ports_stopped()) {
2099 fprintf(stderr, "Please stop all ports first\n");
2103 if (!strcmp(res->name, "drop-en")) {
2104 if (!strcmp(res->value, "on"))
2106 else if (!strcmp(res->value, "off"))
2109 fprintf(stderr, "Unknown parameter\n");
2113 fprintf(stderr, "Unknown parameter\n");
2119 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2122 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2123 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2124 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2125 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2127 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2128 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2129 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2130 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2132 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2133 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2136 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2137 .f = cmd_config_rx_mode_flag_parsed,
2139 .help_str = "port config all drop-en on|off",
2141 (void *)&cmd_config_rx_mode_flag_port,
2142 (void *)&cmd_config_rx_mode_flag_keyword,
2143 (void *)&cmd_config_rx_mode_flag_all,
2144 (void *)&cmd_config_rx_mode_flag_name,
2145 (void *)&cmd_config_rx_mode_flag_value,
2150 /* *** configure rss *** */
2151 struct cmd_config_rss {
2152 cmdline_fixed_string_t port;
2153 cmdline_fixed_string_t keyword;
2154 cmdline_fixed_string_t all;
2155 cmdline_fixed_string_t name;
2156 cmdline_fixed_string_t value;
2160 cmd_config_rss_parsed(void *parsed_result,
2161 __rte_unused struct cmdline *cl,
2162 __rte_unused void *data)
2164 struct cmd_config_rss *res = parsed_result;
2165 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2166 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2167 int use_default = 0;
2168 int all_updated = 1;
2173 if (!strcmp(res->value, "all"))
2174 rss_conf.rss_hf = RTE_ETH_RSS_ETH | RTE_ETH_RSS_VLAN | RTE_ETH_RSS_IP |
2175 RTE_ETH_RSS_TCP | RTE_ETH_RSS_UDP | RTE_ETH_RSS_SCTP |
2176 RTE_ETH_RSS_L2_PAYLOAD | RTE_ETH_RSS_L2TPV3 | RTE_ETH_RSS_ESP |
2177 RTE_ETH_RSS_AH | RTE_ETH_RSS_PFCP | RTE_ETH_RSS_GTPU |
2179 else if (!strcmp(res->value, "eth"))
2180 rss_conf.rss_hf = RTE_ETH_RSS_ETH;
2181 else if (!strcmp(res->value, "vlan"))
2182 rss_conf.rss_hf = RTE_ETH_RSS_VLAN;
2183 else if (!strcmp(res->value, "ip"))
2184 rss_conf.rss_hf = RTE_ETH_RSS_IP;
2185 else if (!strcmp(res->value, "udp"))
2186 rss_conf.rss_hf = RTE_ETH_RSS_UDP;
2187 else if (!strcmp(res->value, "tcp"))
2188 rss_conf.rss_hf = RTE_ETH_RSS_TCP;
2189 else if (!strcmp(res->value, "sctp"))
2190 rss_conf.rss_hf = RTE_ETH_RSS_SCTP;
2191 else if (!strcmp(res->value, "ether"))
2192 rss_conf.rss_hf = RTE_ETH_RSS_L2_PAYLOAD;
2193 else if (!strcmp(res->value, "port"))
2194 rss_conf.rss_hf = RTE_ETH_RSS_PORT;
2195 else if (!strcmp(res->value, "vxlan"))
2196 rss_conf.rss_hf = RTE_ETH_RSS_VXLAN;
2197 else if (!strcmp(res->value, "geneve"))
2198 rss_conf.rss_hf = RTE_ETH_RSS_GENEVE;
2199 else if (!strcmp(res->value, "nvgre"))
2200 rss_conf.rss_hf = RTE_ETH_RSS_NVGRE;
2201 else if (!strcmp(res->value, "l3-pre32"))
2202 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2203 else if (!strcmp(res->value, "l3-pre40"))
2204 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2205 else if (!strcmp(res->value, "l3-pre48"))
2206 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2207 else if (!strcmp(res->value, "l3-pre56"))
2208 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2209 else if (!strcmp(res->value, "l3-pre64"))
2210 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2211 else if (!strcmp(res->value, "l3-pre96"))
2212 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2213 else if (!strcmp(res->value, "l3-src-only"))
2214 rss_conf.rss_hf = RTE_ETH_RSS_L3_SRC_ONLY;
2215 else if (!strcmp(res->value, "l3-dst-only"))
2216 rss_conf.rss_hf = RTE_ETH_RSS_L3_DST_ONLY;
2217 else if (!strcmp(res->value, "l4-src-only"))
2218 rss_conf.rss_hf = RTE_ETH_RSS_L4_SRC_ONLY;
2219 else if (!strcmp(res->value, "l4-dst-only"))
2220 rss_conf.rss_hf = RTE_ETH_RSS_L4_DST_ONLY;
2221 else if (!strcmp(res->value, "l2-src-only"))
2222 rss_conf.rss_hf = RTE_ETH_RSS_L2_SRC_ONLY;
2223 else if (!strcmp(res->value, "l2-dst-only"))
2224 rss_conf.rss_hf = RTE_ETH_RSS_L2_DST_ONLY;
2225 else if (!strcmp(res->value, "l2tpv3"))
2226 rss_conf.rss_hf = RTE_ETH_RSS_L2TPV3;
2227 else if (!strcmp(res->value, "esp"))
2228 rss_conf.rss_hf = RTE_ETH_RSS_ESP;
2229 else if (!strcmp(res->value, "ah"))
2230 rss_conf.rss_hf = RTE_ETH_RSS_AH;
2231 else if (!strcmp(res->value, "pfcp"))
2232 rss_conf.rss_hf = RTE_ETH_RSS_PFCP;
2233 else if (!strcmp(res->value, "pppoe"))
2234 rss_conf.rss_hf = RTE_ETH_RSS_PPPOE;
2235 else if (!strcmp(res->value, "gtpu"))
2236 rss_conf.rss_hf = RTE_ETH_RSS_GTPU;
2237 else if (!strcmp(res->value, "ecpri"))
2238 rss_conf.rss_hf = RTE_ETH_RSS_ECPRI;
2239 else if (!strcmp(res->value, "mpls"))
2240 rss_conf.rss_hf = RTE_ETH_RSS_MPLS;
2241 else if (!strcmp(res->value, "ipv4-chksum"))
2242 rss_conf.rss_hf = RTE_ETH_RSS_IPV4_CHKSUM;
2243 else if (!strcmp(res->value, "none"))
2244 rss_conf.rss_hf = 0;
2245 else if (!strcmp(res->value, "level-default")) {
2246 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2247 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_PMD_DEFAULT);
2248 } else if (!strcmp(res->value, "level-outer")) {
2249 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2250 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_OUTERMOST);
2251 } else if (!strcmp(res->value, "level-inner")) {
2252 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2253 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_INNERMOST);
2254 } else if (!strcmp(res->value, "default"))
2256 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2257 atoi(res->value) < 64)
2258 rss_conf.rss_hf = 1ULL << atoi(res->value);
2260 fprintf(stderr, "Unknown parameter\n");
2263 rss_conf.rss_key = NULL;
2264 /* Update global configuration for RSS types. */
2265 RTE_ETH_FOREACH_DEV(i) {
2266 struct rte_eth_rss_conf local_rss_conf;
2268 ret = eth_dev_info_get_print_err(i, &dev_info);
2273 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2275 local_rss_conf = rss_conf;
2276 local_rss_conf.rss_hf = rss_conf.rss_hf &
2277 dev_info.flow_type_rss_offloads;
2278 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2279 printf("Port %u modified RSS hash function based on hardware support,"
2280 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2281 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2283 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2287 "Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n",
2288 i, -diag, strerror(-diag));
2291 if (all_updated && !use_default) {
2292 rss_hf = rss_conf.rss_hf;
2293 printf("rss_hf %#"PRIx64"\n", rss_hf);
2297 cmdline_parse_token_string_t cmd_config_rss_port =
2298 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2299 cmdline_parse_token_string_t cmd_config_rss_keyword =
2300 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2301 cmdline_parse_token_string_t cmd_config_rss_all =
2302 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2303 cmdline_parse_token_string_t cmd_config_rss_name =
2304 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2305 cmdline_parse_token_string_t cmd_config_rss_value =
2306 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2308 cmdline_parse_inst_t cmd_config_rss = {
2309 .f = cmd_config_rss_parsed,
2311 .help_str = "port config all rss "
2312 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2313 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none|level-default|"
2314 "level-outer|level-inner|ipv4-chksum|<flowtype_id>",
2316 (void *)&cmd_config_rss_port,
2317 (void *)&cmd_config_rss_keyword,
2318 (void *)&cmd_config_rss_all,
2319 (void *)&cmd_config_rss_name,
2320 (void *)&cmd_config_rss_value,
2325 /* *** configure rss hash key *** */
2326 struct cmd_config_rss_hash_key {
2327 cmdline_fixed_string_t port;
2328 cmdline_fixed_string_t config;
2330 cmdline_fixed_string_t rss_hash_key;
2331 cmdline_fixed_string_t rss_type;
2332 cmdline_fixed_string_t key;
2336 hexa_digit_to_value(char hexa_digit)
2338 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2339 return (uint8_t) (hexa_digit - '0');
2340 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2341 return (uint8_t) ((hexa_digit - 'a') + 10);
2342 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2343 return (uint8_t) ((hexa_digit - 'A') + 10);
2344 /* Invalid hexa digit */
2349 parse_and_check_key_hexa_digit(char *key, int idx)
2353 hexa_v = hexa_digit_to_value(key[idx]);
2356 "invalid key: character %c at position %d is not a valid hexa digit\n",
2362 cmd_config_rss_hash_key_parsed(void *parsed_result,
2363 __rte_unused struct cmdline *cl,
2364 __rte_unused void *data)
2366 struct cmd_config_rss_hash_key *res = parsed_result;
2367 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2371 struct rte_eth_dev_info dev_info;
2372 uint8_t hash_key_size;
2376 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2380 if (dev_info.hash_key_size > 0 &&
2381 dev_info.hash_key_size <= sizeof(hash_key))
2382 hash_key_size = dev_info.hash_key_size;
2385 "dev_info did not provide a valid hash key size\n");
2388 /* Check the length of the RSS hash key */
2389 key_len = strlen(res->key);
2390 if (key_len != (hash_key_size * 2)) {
2392 "key length: %d invalid - key must be a string of %d hexa-decimal numbers\n",
2393 (int)key_len, hash_key_size * 2);
2396 /* Translate RSS hash key into binary representation */
2397 for (i = 0; i < hash_key_size; i++) {
2398 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2401 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2404 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2406 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2410 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2411 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2412 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2413 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2415 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2416 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2418 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2419 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2420 rss_hash_key, "rss-hash-key");
2421 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2422 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2423 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2424 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2425 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2426 "ipv6-tcp-ex#ipv6-udp-ex#"
2427 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2428 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2429 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls");
2430 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2431 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2433 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2434 .f = cmd_config_rss_hash_key_parsed,
2436 .help_str = "port config <port_id> rss-hash-key "
2437 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2438 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2439 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2440 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2441 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2442 "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls "
2443 "<string of hex digits (variable length, NIC dependent)>",
2445 (void *)&cmd_config_rss_hash_key_port,
2446 (void *)&cmd_config_rss_hash_key_config,
2447 (void *)&cmd_config_rss_hash_key_port_id,
2448 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2449 (void *)&cmd_config_rss_hash_key_rss_type,
2450 (void *)&cmd_config_rss_hash_key_value,
2455 /* *** cleanup txq mbufs *** */
2456 struct cmd_cleanup_txq_mbufs_result {
2457 cmdline_fixed_string_t port;
2458 cmdline_fixed_string_t keyword;
2459 cmdline_fixed_string_t name;
2466 cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2467 __rte_unused struct cmdline *cl,
2468 __rte_unused void *data)
2470 struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2471 uint16_t port_id = res->port_id;
2472 uint16_t queue_id = res->queue_id;
2473 uint32_t free_cnt = res->free_cnt;
2474 struct rte_eth_txq_info qinfo;
2477 if (test_done == 0) {
2478 fprintf(stderr, "Please stop forwarding first\n");
2482 if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2483 fprintf(stderr, "Failed to get port %u Tx queue %u info\n",
2488 if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2489 fprintf(stderr, "Tx queue %u not started\n", queue_id);
2493 ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2496 "Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n",
2497 port_id, queue_id, strerror(-ret), ret);
2501 printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2502 port_id, queue_id, ret);
2505 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2506 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2508 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2509 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2511 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2512 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2514 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2515 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2517 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2518 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2520 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2521 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2524 cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2525 .f = cmd_cleanup_txq_mbufs_parsed,
2527 .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2529 (void *)&cmd_cleanup_txq_mbufs_port,
2530 (void *)&cmd_cleanup_txq_mbufs_cleanup,
2531 (void *)&cmd_cleanup_txq_mbufs_port_id,
2532 (void *)&cmd_cleanup_txq_mbufs_txq,
2533 (void *)&cmd_cleanup_txq_mbufs_queue_id,
2534 (void *)&cmd_cleanup_txq_mbufs_free_cnt,
2539 /* *** configure port rxq/txq ring size *** */
2540 struct cmd_config_rxtx_ring_size {
2541 cmdline_fixed_string_t port;
2542 cmdline_fixed_string_t config;
2544 cmdline_fixed_string_t rxtxq;
2546 cmdline_fixed_string_t rsize;
2551 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2552 __rte_unused struct cmdline *cl,
2553 __rte_unused void *data)
2555 struct cmd_config_rxtx_ring_size *res = parsed_result;
2556 struct rte_port *port;
2559 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2562 if (res->portid == (portid_t)RTE_PORT_ALL) {
2563 fprintf(stderr, "Invalid port id\n");
2567 port = &ports[res->portid];
2569 if (!strcmp(res->rxtxq, "rxq"))
2571 else if (!strcmp(res->rxtxq, "txq"))
2574 fprintf(stderr, "Unknown parameter\n");
2578 if (isrx && rx_queue_id_is_invalid(res->qid))
2580 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2583 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2585 "Invalid rx ring_size, must > rx_free_thresh: %d\n",
2591 port->nb_rx_desc[res->qid] = res->size;
2593 port->nb_tx_desc[res->qid] = res->size;
2595 cmd_reconfig_device_queue(res->portid, 0, 1);
2598 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2599 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2601 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2602 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2604 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2605 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2606 portid, RTE_UINT16);
2607 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2608 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2610 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2611 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2613 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2614 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2615 rsize, "ring_size");
2616 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2617 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2620 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2621 .f = cmd_config_rxtx_ring_size_parsed,
2623 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2625 (void *)&cmd_config_rxtx_ring_size_port,
2626 (void *)&cmd_config_rxtx_ring_size_config,
2627 (void *)&cmd_config_rxtx_ring_size_portid,
2628 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2629 (void *)&cmd_config_rxtx_ring_size_qid,
2630 (void *)&cmd_config_rxtx_ring_size_rsize,
2631 (void *)&cmd_config_rxtx_ring_size_size,
2636 /* *** configure port rxq/txq start/stop *** */
2637 struct cmd_config_rxtx_queue {
2638 cmdline_fixed_string_t port;
2640 cmdline_fixed_string_t rxtxq;
2642 cmdline_fixed_string_t opname;
2646 cmd_config_rxtx_queue_parsed(void *parsed_result,
2647 __rte_unused struct cmdline *cl,
2648 __rte_unused void *data)
2650 struct cmd_config_rxtx_queue *res = parsed_result;
2655 if (test_done == 0) {
2656 fprintf(stderr, "Please stop forwarding first\n");
2660 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2663 if (port_is_started(res->portid) != 1) {
2664 fprintf(stderr, "Please start port %u first\n", res->portid);
2668 if (!strcmp(res->rxtxq, "rxq"))
2670 else if (!strcmp(res->rxtxq, "txq"))
2673 fprintf(stderr, "Unknown parameter\n");
2677 if (isrx && rx_queue_id_is_invalid(res->qid))
2679 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2682 if (!strcmp(res->opname, "start"))
2684 else if (!strcmp(res->opname, "stop"))
2687 fprintf(stderr, "Unknown parameter\n");
2691 if (isstart && isrx)
2692 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2693 else if (!isstart && isrx)
2694 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2695 else if (isstart && !isrx)
2696 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2698 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2700 if (ret == -ENOTSUP)
2701 fprintf(stderr, "Function not supported in PMD driver\n");
2704 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2705 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2706 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2707 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2708 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2709 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2710 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2711 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2712 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2713 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2716 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2717 .f = cmd_config_rxtx_queue_parsed,
2719 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2721 (void *)&cmd_config_rxtx_queue_port,
2722 (void *)&cmd_config_rxtx_queue_portid,
2723 (void *)&cmd_config_rxtx_queue_rxtxq,
2724 (void *)&cmd_config_rxtx_queue_qid,
2725 (void *)&cmd_config_rxtx_queue_opname,
2730 /* *** configure port rxq/txq deferred start on/off *** */
2731 struct cmd_config_deferred_start_rxtx_queue {
2732 cmdline_fixed_string_t port;
2734 cmdline_fixed_string_t rxtxq;
2736 cmdline_fixed_string_t opname;
2737 cmdline_fixed_string_t state;
2741 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2742 __rte_unused struct cmdline *cl,
2743 __rte_unused void *data)
2745 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2746 struct rte_port *port;
2749 uint8_t needreconfig = 0;
2751 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2754 if (port_is_started(res->port_id) != 0) {
2755 fprintf(stderr, "Please stop port %u first\n", res->port_id);
2759 port = &ports[res->port_id];
2761 isrx = !strcmp(res->rxtxq, "rxq");
2763 if (isrx && rx_queue_id_is_invalid(res->qid))
2765 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2768 ison = !strcmp(res->state, "on");
2770 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2771 port->rx_conf[res->qid].rx_deferred_start = ison;
2773 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2774 port->tx_conf[res->qid].tx_deferred_start = ison;
2779 cmd_reconfig_device_queue(res->port_id, 0, 1);
2782 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2783 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2785 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2786 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2787 port_id, RTE_UINT16);
2788 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2789 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2791 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2792 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2794 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2795 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2796 opname, "deferred_start");
2797 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2798 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2801 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2802 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2804 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2806 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2807 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2808 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2809 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2810 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2811 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2816 /* *** configure port rxq/txq setup *** */
2817 struct cmd_setup_rxtx_queue {
2818 cmdline_fixed_string_t port;
2820 cmdline_fixed_string_t rxtxq;
2822 cmdline_fixed_string_t setup;
2825 /* Common CLI fields for queue setup */
2826 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2827 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2828 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2829 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2830 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2831 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2832 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2833 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2834 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2835 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2838 cmd_setup_rxtx_queue_parsed(
2839 void *parsed_result,
2840 __rte_unused struct cmdline *cl,
2841 __rte_unused void *data)
2843 struct cmd_setup_rxtx_queue *res = parsed_result;
2844 struct rte_port *port;
2845 struct rte_mempool *mp;
2846 unsigned int socket_id;
2850 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2853 if (res->portid == (portid_t)RTE_PORT_ALL) {
2854 fprintf(stderr, "Invalid port id\n");
2858 if (!strcmp(res->rxtxq, "rxq"))
2860 else if (!strcmp(res->rxtxq, "txq"))
2863 fprintf(stderr, "Unknown parameter\n");
2867 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2868 fprintf(stderr, "Invalid rx queue\n");
2870 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2871 fprintf(stderr, "Invalid tx queue\n");
2875 port = &ports[res->portid];
2877 socket_id = rxring_numa[res->portid];
2878 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2879 socket_id = port->socket_id;
2881 mp = mbuf_pool_find(socket_id, 0);
2884 "Failed to setup RX queue: No mempool allocation on the socket %d\n",
2885 rxring_numa[res->portid]);
2888 ret = rx_queue_setup(res->portid,
2890 port->nb_rx_desc[res->qid],
2892 &port->rx_conf[res->qid],
2895 fprintf(stderr, "Failed to setup RX queue\n");
2897 socket_id = txring_numa[res->portid];
2898 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2899 socket_id = port->socket_id;
2901 if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
2903 "Failed to setup TX queue: not enough descriptors\n");
2906 ret = rte_eth_tx_queue_setup(res->portid,
2908 port->nb_tx_desc[res->qid],
2910 &port->tx_conf[res->qid]);
2912 fprintf(stderr, "Failed to setup TX queue\n");
2916 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2917 .f = cmd_setup_rxtx_queue_parsed,
2919 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2921 (void *)&cmd_setup_rxtx_queue_port,
2922 (void *)&cmd_setup_rxtx_queue_portid,
2923 (void *)&cmd_setup_rxtx_queue_rxtxq,
2924 (void *)&cmd_setup_rxtx_queue_qid,
2925 (void *)&cmd_setup_rxtx_queue_setup,
2931 /* *** Configure RSS RETA *** */
2932 struct cmd_config_rss_reta {
2933 cmdline_fixed_string_t port;
2934 cmdline_fixed_string_t keyword;
2936 cmdline_fixed_string_t name;
2937 cmdline_fixed_string_t list_name;
2938 cmdline_fixed_string_t list_of_items;
2942 parse_reta_config(const char *str,
2943 struct rte_eth_rss_reta_entry64 *reta_conf,
2944 uint16_t nb_entries)
2948 uint16_t hash_index, idx, shift;
2951 const char *p, *p0 = str;
2958 unsigned long int_fld[_NUM_FLD];
2959 char *str_fld[_NUM_FLD];
2961 while ((p = strchr(p0,'(')) != NULL) {
2963 if((p0 = strchr(p,')')) == NULL)
2967 if(size >= sizeof(s))
2970 snprintf(s, sizeof(s), "%.*s", size, p);
2971 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2973 for (i = 0; i < _NUM_FLD; i++) {
2975 int_fld[i] = strtoul(str_fld[i], &end, 0);
2976 if (errno != 0 || end == str_fld[i] ||
2981 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2982 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2984 if (hash_index >= nb_entries) {
2985 fprintf(stderr, "Invalid RETA hash index=%d\n",
2990 idx = hash_index / RTE_ETH_RETA_GROUP_SIZE;
2991 shift = hash_index % RTE_ETH_RETA_GROUP_SIZE;
2992 reta_conf[idx].mask |= (1ULL << shift);
2993 reta_conf[idx].reta[shift] = nb_queue;
3000 cmd_set_rss_reta_parsed(void *parsed_result,
3001 __rte_unused struct cmdline *cl,
3002 __rte_unused void *data)
3005 struct rte_eth_dev_info dev_info;
3006 struct rte_eth_rss_reta_entry64 reta_conf[8];
3007 struct cmd_config_rss_reta *res = parsed_result;
3009 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3013 if (dev_info.reta_size == 0) {
3015 "Redirection table size is 0 which is invalid for RSS\n");
3018 printf("The reta size of port %d is %u\n",
3019 res->port_id, dev_info.reta_size);
3020 if (dev_info.reta_size > RTE_ETH_RSS_RETA_SIZE_512) {
3022 "Currently do not support more than %u entries of redirection table\n",
3023 RTE_ETH_RSS_RETA_SIZE_512);
3027 memset(reta_conf, 0, sizeof(reta_conf));
3028 if (!strcmp(res->list_name, "reta")) {
3029 if (parse_reta_config(res->list_of_items, reta_conf,
3030 dev_info.reta_size)) {
3032 "Invalid RSS Redirection Table config entered\n");
3035 ret = rte_eth_dev_rss_reta_update(res->port_id,
3036 reta_conf, dev_info.reta_size);
3039 "Bad redirection table parameter, return code = %d\n",
3044 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3045 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3046 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3047 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3048 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3049 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3050 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3051 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3052 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3053 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3054 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3055 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3057 cmdline_parse_inst_t cmd_config_rss_reta = {
3058 .f = cmd_set_rss_reta_parsed,
3060 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3062 (void *)&cmd_config_rss_reta_port,
3063 (void *)&cmd_config_rss_reta_keyword,
3064 (void *)&cmd_config_rss_reta_port_id,
3065 (void *)&cmd_config_rss_reta_name,
3066 (void *)&cmd_config_rss_reta_list_name,
3067 (void *)&cmd_config_rss_reta_list_of_items,
3072 /* *** SHOW PORT RETA INFO *** */
3073 struct cmd_showport_reta {
3074 cmdline_fixed_string_t show;
3075 cmdline_fixed_string_t port;
3077 cmdline_fixed_string_t rss;
3078 cmdline_fixed_string_t reta;
3080 cmdline_fixed_string_t list_of_items;
3084 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3085 uint16_t nb_entries,
3089 const char *p, *p0 = str;
3094 uint16_t num = (nb_entries + RTE_ETH_RETA_GROUP_SIZE - 1) /
3095 RTE_ETH_RETA_GROUP_SIZE;
3098 p = strchr(p0, '(');
3102 p0 = strchr(p, ')');
3106 if (size >= sizeof(s)) {
3108 "The string size exceeds the internal buffer size\n");
3111 snprintf(s, sizeof(s), "%.*s", size, p);
3112 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3113 if (ret <= 0 || ret != num) {
3115 "The bits of masks do not match the number of reta entries: %u\n",
3119 for (i = 0; i < ret; i++)
3120 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3126 cmd_showport_reta_parsed(void *parsed_result,
3127 __rte_unused struct cmdline *cl,
3128 __rte_unused void *data)
3130 struct cmd_showport_reta *res = parsed_result;
3131 struct rte_eth_rss_reta_entry64 reta_conf[8];
3132 struct rte_eth_dev_info dev_info;
3133 uint16_t max_reta_size;
3136 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3140 max_reta_size = RTE_MIN(dev_info.reta_size, RTE_ETH_RSS_RETA_SIZE_512);
3141 if (res->size == 0 || res->size > max_reta_size) {
3142 fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n",
3143 res->size, max_reta_size);
3147 memset(reta_conf, 0, sizeof(reta_conf));
3148 if (showport_parse_reta_config(reta_conf, res->size,
3149 res->list_of_items) < 0) {
3150 fprintf(stderr, "Invalid string: %s for reta masks\n",
3151 res->list_of_items);
3154 port_rss_reta_info(res->port_id, reta_conf, res->size);
3157 cmdline_parse_token_string_t cmd_showport_reta_show =
3158 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3159 cmdline_parse_token_string_t cmd_showport_reta_port =
3160 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3161 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3162 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3163 cmdline_parse_token_string_t cmd_showport_reta_rss =
3164 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3165 cmdline_parse_token_string_t cmd_showport_reta_reta =
3166 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3167 cmdline_parse_token_num_t cmd_showport_reta_size =
3168 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3169 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3170 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3171 list_of_items, NULL);
3173 cmdline_parse_inst_t cmd_showport_reta = {
3174 .f = cmd_showport_reta_parsed,
3176 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3178 (void *)&cmd_showport_reta_show,
3179 (void *)&cmd_showport_reta_port,
3180 (void *)&cmd_showport_reta_port_id,
3181 (void *)&cmd_showport_reta_rss,
3182 (void *)&cmd_showport_reta_reta,
3183 (void *)&cmd_showport_reta_size,
3184 (void *)&cmd_showport_reta_list_of_items,
3189 /* *** Show RSS hash configuration *** */
3190 struct cmd_showport_rss_hash {
3191 cmdline_fixed_string_t show;
3192 cmdline_fixed_string_t port;
3194 cmdline_fixed_string_t rss_hash;
3195 cmdline_fixed_string_t rss_type;
3196 cmdline_fixed_string_t key; /* optional argument */
3199 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3200 __rte_unused struct cmdline *cl,
3203 struct cmd_showport_rss_hash *res = parsed_result;
3205 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3208 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3209 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3210 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3211 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3212 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3213 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3215 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3216 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3218 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3219 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3221 cmdline_parse_inst_t cmd_showport_rss_hash = {
3222 .f = cmd_showport_rss_hash_parsed,
3224 .help_str = "show port <port_id> rss-hash",
3226 (void *)&cmd_showport_rss_hash_show,
3227 (void *)&cmd_showport_rss_hash_port,
3228 (void *)&cmd_showport_rss_hash_port_id,
3229 (void *)&cmd_showport_rss_hash_rss_hash,
3234 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3235 .f = cmd_showport_rss_hash_parsed,
3237 .help_str = "show port <port_id> rss-hash key",
3239 (void *)&cmd_showport_rss_hash_show,
3240 (void *)&cmd_showport_rss_hash_port,
3241 (void *)&cmd_showport_rss_hash_port_id,
3242 (void *)&cmd_showport_rss_hash_rss_hash,
3243 (void *)&cmd_showport_rss_hash_rss_key,
3248 /* *** Configure DCB *** */
3249 struct cmd_config_dcb {
3250 cmdline_fixed_string_t port;
3251 cmdline_fixed_string_t config;
3253 cmdline_fixed_string_t dcb;
3254 cmdline_fixed_string_t vt;
3255 cmdline_fixed_string_t vt_en;
3257 cmdline_fixed_string_t pfc;
3258 cmdline_fixed_string_t pfc_en;
3262 cmd_config_dcb_parsed(void *parsed_result,
3263 __rte_unused struct cmdline *cl,
3264 __rte_unused void *data)
3266 struct cmd_config_dcb *res = parsed_result;
3267 struct rte_eth_dcb_info dcb_info;
3268 portid_t port_id = res->port_id;
3269 struct rte_port *port;
3273 port = &ports[port_id];
3274 /** Check if the port is not started **/
3275 if (port->port_status != RTE_PORT_STOPPED) {
3276 fprintf(stderr, "Please stop port %d first\n", port_id);
3280 if ((res->num_tcs != RTE_ETH_4_TCS) && (res->num_tcs != RTE_ETH_8_TCS)) {
3282 "The invalid number of traffic class, only 4 or 8 allowed.\n");
3286 if (nb_fwd_lcores < res->num_tcs) {
3288 "nb_cores shouldn't be less than number of TCs.\n");
3292 /* Check whether the port supports the report of DCB info. */
3293 ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3294 if (ret == -ENOTSUP) {
3295 fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n");
3299 if (!strncmp(res->pfc_en, "on", 2))
3304 /* DCB in VT mode */
3305 if (!strncmp(res->vt_en, "on", 2))
3306 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3307 (enum rte_eth_nb_tcs)res->num_tcs,
3310 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3311 (enum rte_eth_nb_tcs)res->num_tcs,
3314 fprintf(stderr, "Cannot initialize network ports.\n");
3320 cmd_reconfig_device_queue(port_id, 1, 1);
3323 cmdline_parse_token_string_t cmd_config_dcb_port =
3324 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3325 cmdline_parse_token_string_t cmd_config_dcb_config =
3326 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3327 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3328 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3329 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3330 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3331 cmdline_parse_token_string_t cmd_config_dcb_vt =
3332 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3333 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3334 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3335 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3336 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3337 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3338 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3339 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3340 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3342 cmdline_parse_inst_t cmd_config_dcb = {
3343 .f = cmd_config_dcb_parsed,
3345 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3347 (void *)&cmd_config_dcb_port,
3348 (void *)&cmd_config_dcb_config,
3349 (void *)&cmd_config_dcb_port_id,
3350 (void *)&cmd_config_dcb_dcb,
3351 (void *)&cmd_config_dcb_vt,
3352 (void *)&cmd_config_dcb_vt_en,
3353 (void *)&cmd_config_dcb_num_tcs,
3354 (void *)&cmd_config_dcb_pfc,
3355 (void *)&cmd_config_dcb_pfc_en,
3360 /* *** configure number of packets per burst *** */
3361 struct cmd_config_burst {
3362 cmdline_fixed_string_t port;
3363 cmdline_fixed_string_t keyword;
3364 cmdline_fixed_string_t all;
3365 cmdline_fixed_string_t name;
3370 cmd_config_burst_parsed(void *parsed_result,
3371 __rte_unused struct cmdline *cl,
3372 __rte_unused void *data)
3374 struct cmd_config_burst *res = parsed_result;
3375 struct rte_eth_dev_info dev_info;
3376 uint16_t rec_nb_pkts;
3379 if (!all_ports_stopped()) {
3380 fprintf(stderr, "Please stop all ports first\n");
3384 if (!strcmp(res->name, "burst")) {
3385 if (res->value == 0) {
3386 /* If user gives a value of zero, query the PMD for
3387 * its recommended Rx burst size. Testpmd uses a single
3388 * size for all ports, so assume all ports are the same
3389 * NIC model and use the values from Port 0.
3391 ret = eth_dev_info_get_print_err(0, &dev_info);
3395 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3397 if (rec_nb_pkts == 0) {
3398 printf("PMD does not recommend a burst size.\n"
3399 "User provided value must be between"
3400 " 1 and %d\n", MAX_PKT_BURST);
3402 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3403 printf("PMD recommended burst size of %d"
3404 " exceeds maximum value of %d\n",
3405 rec_nb_pkts, MAX_PKT_BURST);
3408 printf("Using PMD-provided burst value of %d\n",
3410 nb_pkt_per_burst = rec_nb_pkts;
3411 } else if (res->value > MAX_PKT_BURST) {
3412 fprintf(stderr, "burst must be >= 1 && <= %d\n",
3416 nb_pkt_per_burst = res->value;
3418 fprintf(stderr, "Unknown parameter\n");
3424 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3427 cmdline_parse_token_string_t cmd_config_burst_port =
3428 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3429 cmdline_parse_token_string_t cmd_config_burst_keyword =
3430 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3431 cmdline_parse_token_string_t cmd_config_burst_all =
3432 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3433 cmdline_parse_token_string_t cmd_config_burst_name =
3434 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3435 cmdline_parse_token_num_t cmd_config_burst_value =
3436 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3438 cmdline_parse_inst_t cmd_config_burst = {
3439 .f = cmd_config_burst_parsed,
3441 .help_str = "port config all burst <value>",
3443 (void *)&cmd_config_burst_port,
3444 (void *)&cmd_config_burst_keyword,
3445 (void *)&cmd_config_burst_all,
3446 (void *)&cmd_config_burst_name,
3447 (void *)&cmd_config_burst_value,
3452 /* *** configure rx/tx queues *** */
3453 struct cmd_config_thresh {
3454 cmdline_fixed_string_t port;
3455 cmdline_fixed_string_t keyword;
3456 cmdline_fixed_string_t all;
3457 cmdline_fixed_string_t name;
3462 cmd_config_thresh_parsed(void *parsed_result,
3463 __rte_unused struct cmdline *cl,
3464 __rte_unused void *data)
3466 struct cmd_config_thresh *res = parsed_result;
3468 if (!all_ports_stopped()) {
3469 fprintf(stderr, "Please stop all ports first\n");
3473 if (!strcmp(res->name, "txpt"))
3474 tx_pthresh = res->value;
3475 else if(!strcmp(res->name, "txht"))
3476 tx_hthresh = res->value;
3477 else if(!strcmp(res->name, "txwt"))
3478 tx_wthresh = res->value;
3479 else if(!strcmp(res->name, "rxpt"))
3480 rx_pthresh = res->value;
3481 else if(!strcmp(res->name, "rxht"))
3482 rx_hthresh = res->value;
3483 else if(!strcmp(res->name, "rxwt"))
3484 rx_wthresh = res->value;
3486 fprintf(stderr, "Unknown parameter\n");
3492 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3495 cmdline_parse_token_string_t cmd_config_thresh_port =
3496 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3497 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3498 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3499 cmdline_parse_token_string_t cmd_config_thresh_all =
3500 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3501 cmdline_parse_token_string_t cmd_config_thresh_name =
3502 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3503 "txpt#txht#txwt#rxpt#rxht#rxwt");
3504 cmdline_parse_token_num_t cmd_config_thresh_value =
3505 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3507 cmdline_parse_inst_t cmd_config_thresh = {
3508 .f = cmd_config_thresh_parsed,
3510 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3512 (void *)&cmd_config_thresh_port,
3513 (void *)&cmd_config_thresh_keyword,
3514 (void *)&cmd_config_thresh_all,
3515 (void *)&cmd_config_thresh_name,
3516 (void *)&cmd_config_thresh_value,
3521 /* *** configure free/rs threshold *** */
3522 struct cmd_config_threshold {
3523 cmdline_fixed_string_t port;
3524 cmdline_fixed_string_t keyword;
3525 cmdline_fixed_string_t all;
3526 cmdline_fixed_string_t name;
3531 cmd_config_threshold_parsed(void *parsed_result,
3532 __rte_unused struct cmdline *cl,
3533 __rte_unused void *data)
3535 struct cmd_config_threshold *res = parsed_result;
3537 if (!all_ports_stopped()) {
3538 fprintf(stderr, "Please stop all ports first\n");
3542 if (!strcmp(res->name, "txfreet"))
3543 tx_free_thresh = res->value;
3544 else if (!strcmp(res->name, "txrst"))
3545 tx_rs_thresh = res->value;
3546 else if (!strcmp(res->name, "rxfreet"))
3547 rx_free_thresh = res->value;
3549 fprintf(stderr, "Unknown parameter\n");
3555 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3558 cmdline_parse_token_string_t cmd_config_threshold_port =
3559 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3560 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3561 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3563 cmdline_parse_token_string_t cmd_config_threshold_all =
3564 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3565 cmdline_parse_token_string_t cmd_config_threshold_name =
3566 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3567 "txfreet#txrst#rxfreet");
3568 cmdline_parse_token_num_t cmd_config_threshold_value =
3569 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3571 cmdline_parse_inst_t cmd_config_threshold = {
3572 .f = cmd_config_threshold_parsed,
3574 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3576 (void *)&cmd_config_threshold_port,
3577 (void *)&cmd_config_threshold_keyword,
3578 (void *)&cmd_config_threshold_all,
3579 (void *)&cmd_config_threshold_name,
3580 (void *)&cmd_config_threshold_value,
3586 struct cmd_stop_result {
3587 cmdline_fixed_string_t stop;
3590 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3591 __rte_unused struct cmdline *cl,
3592 __rte_unused void *data)
3594 stop_packet_forwarding();
3597 cmdline_parse_token_string_t cmd_stop_stop =
3598 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3600 cmdline_parse_inst_t cmd_stop = {
3601 .f = cmd_stop_parsed,
3603 .help_str = "stop: Stop packet forwarding",
3605 (void *)&cmd_stop_stop,
3610 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3613 parse_item_list(const char *str, const char *item_name, unsigned int max_items,
3614 unsigned int *parsed_items, int check_unique_values)
3616 unsigned int nb_item;
3624 * First parse all items in the list and store their value.
3629 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3631 if ((c >= '0') && (c <= '9')) {
3632 value = (unsigned int) (value * 10 + (c - '0'));
3637 fprintf(stderr, "character %c is not a decimal digit\n", c);
3641 fprintf(stderr, "No valid value before comma\n");
3644 if (nb_item < max_items) {
3645 parsed_items[nb_item] = value;
3651 if (nb_item >= max_items) {
3652 fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
3653 item_name, nb_item + 1, max_items);
3656 parsed_items[nb_item++] = value;
3657 if (! check_unique_values)
3661 * Then, check that all values in the list are different.
3662 * No optimization here...
3664 for (i = 0; i < nb_item; i++) {
3665 for (j = i + 1; j < nb_item; j++) {
3666 if (parsed_items[j] == parsed_items[i]) {
3668 "duplicated %s %u at index %u and %u\n",
3669 item_name, parsed_items[i], i, j);
3677 struct cmd_set_list_result {
3678 cmdline_fixed_string_t cmd_keyword;
3679 cmdline_fixed_string_t list_name;
3680 cmdline_fixed_string_t list_of_items;
3683 static void cmd_set_list_parsed(void *parsed_result,
3684 __rte_unused struct cmdline *cl,
3685 __rte_unused void *data)
3687 struct cmd_set_list_result *res;
3689 unsigned int lcorelist[RTE_MAX_LCORE];
3690 unsigned int portlist[RTE_MAX_ETHPORTS];
3692 unsigned int nb_item;
3694 if (test_done == 0) {
3695 fprintf(stderr, "Please stop forwarding first\n");
3699 res = parsed_result;
3700 if (!strcmp(res->list_name, "corelist")) {
3701 nb_item = parse_item_list(res->list_of_items, "core",
3703 parsed_items.lcorelist, 1);
3705 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3710 if (!strcmp(res->list_name, "portlist")) {
3711 nb_item = parse_item_list(res->list_of_items, "port",
3713 parsed_items.portlist, 1);
3715 set_fwd_ports_list(parsed_items.portlist, nb_item);
3721 cmdline_parse_token_string_t cmd_set_list_keyword =
3722 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3724 cmdline_parse_token_string_t cmd_set_list_name =
3725 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3726 "corelist#portlist");
3727 cmdline_parse_token_string_t cmd_set_list_of_items =
3728 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3731 cmdline_parse_inst_t cmd_set_fwd_list = {
3732 .f = cmd_set_list_parsed,
3734 .help_str = "set corelist|portlist <list0[,list1]*>",
3736 (void *)&cmd_set_list_keyword,
3737 (void *)&cmd_set_list_name,
3738 (void *)&cmd_set_list_of_items,
3743 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3745 struct cmd_setmask_result {
3746 cmdline_fixed_string_t set;
3747 cmdline_fixed_string_t mask;
3751 static void cmd_set_mask_parsed(void *parsed_result,
3752 __rte_unused struct cmdline *cl,
3753 __rte_unused void *data)
3755 struct cmd_setmask_result *res = parsed_result;
3757 if (test_done == 0) {
3758 fprintf(stderr, "Please stop forwarding first\n");
3761 if (!strcmp(res->mask, "coremask")) {
3762 set_fwd_lcores_mask(res->hexavalue);
3764 } else if (!strcmp(res->mask, "portmask")) {
3765 set_fwd_ports_mask(res->hexavalue);
3770 cmdline_parse_token_string_t cmd_setmask_set =
3771 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3772 cmdline_parse_token_string_t cmd_setmask_mask =
3773 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3774 "coremask#portmask");
3775 cmdline_parse_token_num_t cmd_setmask_value =
3776 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3778 cmdline_parse_inst_t cmd_set_fwd_mask = {
3779 .f = cmd_set_mask_parsed,
3781 .help_str = "set coremask|portmask <hexadecimal value>",
3783 (void *)&cmd_setmask_set,
3784 (void *)&cmd_setmask_mask,
3785 (void *)&cmd_setmask_value,
3791 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3793 struct cmd_set_result {
3794 cmdline_fixed_string_t set;
3795 cmdline_fixed_string_t what;
3799 static void cmd_set_parsed(void *parsed_result,
3800 __rte_unused struct cmdline *cl,
3801 __rte_unused void *data)
3803 struct cmd_set_result *res = parsed_result;
3804 if (!strcmp(res->what, "nbport")) {
3805 set_fwd_ports_number(res->value);
3807 } else if (!strcmp(res->what, "nbcore")) {
3808 set_fwd_lcores_number(res->value);
3810 } else if (!strcmp(res->what, "burst"))
3811 set_nb_pkt_per_burst(res->value);
3812 else if (!strcmp(res->what, "verbose"))
3813 set_verbose_level(res->value);
3816 cmdline_parse_token_string_t cmd_set_set =
3817 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3818 cmdline_parse_token_string_t cmd_set_what =
3819 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3820 "nbport#nbcore#burst#verbose");
3821 cmdline_parse_token_num_t cmd_set_value =
3822 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3824 cmdline_parse_inst_t cmd_set_numbers = {
3825 .f = cmd_set_parsed,
3827 .help_str = "set nbport|nbcore|burst|verbose <value>",
3829 (void *)&cmd_set_set,
3830 (void *)&cmd_set_what,
3831 (void *)&cmd_set_value,
3836 /* *** SET LOG LEVEL CONFIGURATION *** */
3838 struct cmd_set_log_result {
3839 cmdline_fixed_string_t set;
3840 cmdline_fixed_string_t log;
3841 cmdline_fixed_string_t type;
3846 cmd_set_log_parsed(void *parsed_result,
3847 __rte_unused struct cmdline *cl,
3848 __rte_unused void *data)
3850 struct cmd_set_log_result *res;
3853 res = parsed_result;
3854 if (!strcmp(res->type, "global"))
3855 rte_log_set_global_level(res->level);
3857 ret = rte_log_set_level_regexp(res->type, res->level);
3859 fprintf(stderr, "Unable to set log level\n");
3863 cmdline_parse_token_string_t cmd_set_log_set =
3864 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3865 cmdline_parse_token_string_t cmd_set_log_log =
3866 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3867 cmdline_parse_token_string_t cmd_set_log_type =
3868 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3869 cmdline_parse_token_num_t cmd_set_log_level =
3870 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3872 cmdline_parse_inst_t cmd_set_log = {
3873 .f = cmd_set_log_parsed,
3875 .help_str = "set log global|<type> <level>",
3877 (void *)&cmd_set_log_set,
3878 (void *)&cmd_set_log_log,
3879 (void *)&cmd_set_log_type,
3880 (void *)&cmd_set_log_level,
3885 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3887 struct cmd_set_rxoffs_result {
3888 cmdline_fixed_string_t cmd_keyword;
3889 cmdline_fixed_string_t rxoffs;
3890 cmdline_fixed_string_t seg_offsets;
3894 cmd_set_rxoffs_parsed(void *parsed_result,
3895 __rte_unused struct cmdline *cl,
3896 __rte_unused void *data)
3898 struct cmd_set_rxoffs_result *res;
3899 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3900 unsigned int nb_segs;
3902 res = parsed_result;
3903 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3904 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3906 set_rx_pkt_offsets(seg_offsets, nb_segs);
3907 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3910 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3911 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3912 cmd_keyword, "set");
3913 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3914 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3916 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3917 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3920 cmdline_parse_inst_t cmd_set_rxoffs = {
3921 .f = cmd_set_rxoffs_parsed,
3923 .help_str = "set rxoffs <len0[,len1]*>",
3925 (void *)&cmd_set_rxoffs_keyword,
3926 (void *)&cmd_set_rxoffs_name,
3927 (void *)&cmd_set_rxoffs_offsets,
3932 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3934 struct cmd_set_rxpkts_result {
3935 cmdline_fixed_string_t cmd_keyword;
3936 cmdline_fixed_string_t rxpkts;
3937 cmdline_fixed_string_t seg_lengths;
3941 cmd_set_rxpkts_parsed(void *parsed_result,
3942 __rte_unused struct cmdline *cl,
3943 __rte_unused void *data)
3945 struct cmd_set_rxpkts_result *res;
3946 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3947 unsigned int nb_segs;
3949 res = parsed_result;
3950 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3951 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3953 set_rx_pkt_segments(seg_lengths, nb_segs);
3954 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3957 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3958 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3959 cmd_keyword, "set");
3960 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3961 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3963 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3964 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3967 cmdline_parse_inst_t cmd_set_rxpkts = {
3968 .f = cmd_set_rxpkts_parsed,
3970 .help_str = "set rxpkts <len0[,len1]*>",
3972 (void *)&cmd_set_rxpkts_keyword,
3973 (void *)&cmd_set_rxpkts_name,
3974 (void *)&cmd_set_rxpkts_lengths,
3979 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3981 struct cmd_set_txpkts_result {
3982 cmdline_fixed_string_t cmd_keyword;
3983 cmdline_fixed_string_t txpkts;
3984 cmdline_fixed_string_t seg_lengths;
3988 cmd_set_txpkts_parsed(void *parsed_result,
3989 __rte_unused struct cmdline *cl,
3990 __rte_unused void *data)
3992 struct cmd_set_txpkts_result *res;
3993 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3994 unsigned int nb_segs;
3996 res = parsed_result;
3997 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3998 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4000 set_tx_pkt_segments(seg_lengths, nb_segs);
4003 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4004 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4005 cmd_keyword, "set");
4006 cmdline_parse_token_string_t cmd_set_txpkts_name =
4007 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4009 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4010 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4013 cmdline_parse_inst_t cmd_set_txpkts = {
4014 .f = cmd_set_txpkts_parsed,
4016 .help_str = "set txpkts <len0[,len1]*>",
4018 (void *)&cmd_set_txpkts_keyword,
4019 (void *)&cmd_set_txpkts_name,
4020 (void *)&cmd_set_txpkts_lengths,
4025 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4027 struct cmd_set_txsplit_result {
4028 cmdline_fixed_string_t cmd_keyword;
4029 cmdline_fixed_string_t txsplit;
4030 cmdline_fixed_string_t mode;
4034 cmd_set_txsplit_parsed(void *parsed_result,
4035 __rte_unused struct cmdline *cl,
4036 __rte_unused void *data)
4038 struct cmd_set_txsplit_result *res;
4040 res = parsed_result;
4041 set_tx_pkt_split(res->mode);
4044 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4045 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4046 cmd_keyword, "set");
4047 cmdline_parse_token_string_t cmd_set_txsplit_name =
4048 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4049 txsplit, "txsplit");
4050 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4051 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4054 cmdline_parse_inst_t cmd_set_txsplit = {
4055 .f = cmd_set_txsplit_parsed,
4057 .help_str = "set txsplit on|off|rand",
4059 (void *)&cmd_set_txsplit_keyword,
4060 (void *)&cmd_set_txsplit_name,
4061 (void *)&cmd_set_txsplit_mode,
4066 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4068 struct cmd_set_txtimes_result {
4069 cmdline_fixed_string_t cmd_keyword;
4070 cmdline_fixed_string_t txtimes;
4071 cmdline_fixed_string_t tx_times;
4075 cmd_set_txtimes_parsed(void *parsed_result,
4076 __rte_unused struct cmdline *cl,
4077 __rte_unused void *data)
4079 struct cmd_set_txtimes_result *res;
4080 unsigned int tx_times[2] = {0, 0};
4081 unsigned int n_times;
4083 res = parsed_result;
4084 n_times = parse_item_list(res->tx_times, "tx times",
4087 set_tx_pkt_times(tx_times);
4090 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4091 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4092 cmd_keyword, "set");
4093 cmdline_parse_token_string_t cmd_set_txtimes_name =
4094 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4095 txtimes, "txtimes");
4096 cmdline_parse_token_string_t cmd_set_txtimes_value =
4097 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4100 cmdline_parse_inst_t cmd_set_txtimes = {
4101 .f = cmd_set_txtimes_parsed,
4103 .help_str = "set txtimes <inter_burst>,<intra_burst>",
4105 (void *)&cmd_set_txtimes_keyword,
4106 (void *)&cmd_set_txtimes_name,
4107 (void *)&cmd_set_txtimes_value,
4112 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4113 struct cmd_rx_vlan_filter_all_result {
4114 cmdline_fixed_string_t rx_vlan;
4115 cmdline_fixed_string_t what;
4116 cmdline_fixed_string_t all;
4121 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4122 __rte_unused struct cmdline *cl,
4123 __rte_unused void *data)
4125 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4127 if (!strcmp(res->what, "add"))
4128 rx_vlan_all_filter_set(res->port_id, 1);
4130 rx_vlan_all_filter_set(res->port_id, 0);
4133 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4134 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4135 rx_vlan, "rx_vlan");
4136 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4137 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4139 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4140 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4142 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4143 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4144 port_id, RTE_UINT16);
4146 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4147 .f = cmd_rx_vlan_filter_all_parsed,
4149 .help_str = "rx_vlan add|rm all <port_id>: "
4150 "Add/Remove all identifiers to/from the set of VLAN "
4151 "identifiers filtered by a port",
4153 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4154 (void *)&cmd_rx_vlan_filter_all_what,
4155 (void *)&cmd_rx_vlan_filter_all_all,
4156 (void *)&cmd_rx_vlan_filter_all_portid,
4161 /* *** VLAN OFFLOAD SET ON A PORT *** */
4162 struct cmd_vlan_offload_result {
4163 cmdline_fixed_string_t vlan;
4164 cmdline_fixed_string_t set;
4165 cmdline_fixed_string_t vlan_type;
4166 cmdline_fixed_string_t what;
4167 cmdline_fixed_string_t on;
4168 cmdline_fixed_string_t port_id;
4172 cmd_vlan_offload_parsed(void *parsed_result,
4173 __rte_unused struct cmdline *cl,
4174 __rte_unused void *data)
4177 struct cmd_vlan_offload_result *res = parsed_result;
4180 portid_t port_id = 0;
4184 len = strnlen(str, STR_TOKEN_SIZE);
4186 /* Get port_id first */
4194 tmp = strtoul(str, NULL, 0);
4195 /* If port_id greater that what portid_t can represent, return */
4196 if(tmp >= RTE_MAX_ETHPORTS)
4198 port_id = (portid_t)tmp;
4200 if (!strcmp(res->on, "on"))
4205 if (!strcmp(res->what, "strip"))
4206 rx_vlan_strip_set(port_id, on);
4207 else if(!strcmp(res->what, "stripq")){
4208 uint16_t queue_id = 0;
4210 /* No queue_id, return */
4212 fprintf(stderr, "must specify (port,queue_id)\n");
4215 tmp = strtoul(str + i + 1, NULL, 0);
4216 /* If queue_id greater that what 16-bits can represent, return */
4220 queue_id = (uint16_t)tmp;
4221 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4223 else if (!strcmp(res->what, "filter"))
4224 rx_vlan_filter_set(port_id, on);
4225 else if (!strcmp(res->what, "qinq_strip"))
4226 rx_vlan_qinq_strip_set(port_id, on);
4228 vlan_extend_set(port_id, on);
4233 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4234 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4236 cmdline_parse_token_string_t cmd_vlan_offload_set =
4237 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4239 cmdline_parse_token_string_t cmd_vlan_offload_what =
4240 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4241 what, "strip#filter#qinq_strip#extend#stripq");
4242 cmdline_parse_token_string_t cmd_vlan_offload_on =
4243 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4245 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4246 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4249 cmdline_parse_inst_t cmd_vlan_offload = {
4250 .f = cmd_vlan_offload_parsed,
4252 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4253 "<port_id[,queue_id]>: "
4254 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4256 (void *)&cmd_vlan_offload_vlan,
4257 (void *)&cmd_vlan_offload_set,
4258 (void *)&cmd_vlan_offload_what,
4259 (void *)&cmd_vlan_offload_on,
4260 (void *)&cmd_vlan_offload_portid,
4265 /* *** VLAN TPID SET ON A PORT *** */
4266 struct cmd_vlan_tpid_result {
4267 cmdline_fixed_string_t vlan;
4268 cmdline_fixed_string_t set;
4269 cmdline_fixed_string_t vlan_type;
4270 cmdline_fixed_string_t what;
4276 cmd_vlan_tpid_parsed(void *parsed_result,
4277 __rte_unused struct cmdline *cl,
4278 __rte_unused void *data)
4280 struct cmd_vlan_tpid_result *res = parsed_result;
4281 enum rte_vlan_type vlan_type;
4283 if (!strcmp(res->vlan_type, "inner"))
4284 vlan_type = RTE_ETH_VLAN_TYPE_INNER;
4285 else if (!strcmp(res->vlan_type, "outer"))
4286 vlan_type = RTE_ETH_VLAN_TYPE_OUTER;
4288 fprintf(stderr, "Unknown vlan type\n");
4291 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4294 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4295 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4297 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4298 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4300 cmdline_parse_token_string_t cmd_vlan_type =
4301 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4302 vlan_type, "inner#outer");
4303 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4304 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4306 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4307 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4309 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4310 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4311 port_id, RTE_UINT16);
4313 cmdline_parse_inst_t cmd_vlan_tpid = {
4314 .f = cmd_vlan_tpid_parsed,
4316 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4317 "Set the VLAN Ether type",
4319 (void *)&cmd_vlan_tpid_vlan,
4320 (void *)&cmd_vlan_tpid_set,
4321 (void *)&cmd_vlan_type,
4322 (void *)&cmd_vlan_tpid_what,
4323 (void *)&cmd_vlan_tpid_tpid,
4324 (void *)&cmd_vlan_tpid_portid,
4329 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4330 struct cmd_rx_vlan_filter_result {
4331 cmdline_fixed_string_t rx_vlan;
4332 cmdline_fixed_string_t what;
4338 cmd_rx_vlan_filter_parsed(void *parsed_result,
4339 __rte_unused struct cmdline *cl,
4340 __rte_unused void *data)
4342 struct cmd_rx_vlan_filter_result *res = parsed_result;
4344 if (!strcmp(res->what, "add"))
4345 rx_vft_set(res->port_id, res->vlan_id, 1);
4347 rx_vft_set(res->port_id, res->vlan_id, 0);
4350 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4351 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4352 rx_vlan, "rx_vlan");
4353 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4354 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4356 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4357 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4358 vlan_id, RTE_UINT16);
4359 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4360 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4361 port_id, RTE_UINT16);
4363 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4364 .f = cmd_rx_vlan_filter_parsed,
4366 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4367 "Add/Remove a VLAN identifier to/from the set of VLAN "
4368 "identifiers filtered by a port",
4370 (void *)&cmd_rx_vlan_filter_rx_vlan,
4371 (void *)&cmd_rx_vlan_filter_what,
4372 (void *)&cmd_rx_vlan_filter_vlanid,
4373 (void *)&cmd_rx_vlan_filter_portid,
4378 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4379 struct cmd_tx_vlan_set_result {
4380 cmdline_fixed_string_t tx_vlan;
4381 cmdline_fixed_string_t set;
4387 cmd_tx_vlan_set_parsed(void *parsed_result,
4388 __rte_unused struct cmdline *cl,
4389 __rte_unused void *data)
4391 struct cmd_tx_vlan_set_result *res = parsed_result;
4393 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4396 if (!port_is_stopped(res->port_id)) {
4397 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4401 tx_vlan_set(res->port_id, res->vlan_id);
4403 cmd_reconfig_device_queue(res->port_id, 1, 1);
4406 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4407 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4408 tx_vlan, "tx_vlan");
4409 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4410 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4412 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4413 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4414 port_id, RTE_UINT16);
4415 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4416 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4417 vlan_id, RTE_UINT16);
4419 cmdline_parse_inst_t cmd_tx_vlan_set = {
4420 .f = cmd_tx_vlan_set_parsed,
4422 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4423 "Enable hardware insertion of a single VLAN header "
4424 "with a given TAG Identifier in packets sent on a port",
4426 (void *)&cmd_tx_vlan_set_tx_vlan,
4427 (void *)&cmd_tx_vlan_set_set,
4428 (void *)&cmd_tx_vlan_set_portid,
4429 (void *)&cmd_tx_vlan_set_vlanid,
4434 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4435 struct cmd_tx_vlan_set_qinq_result {
4436 cmdline_fixed_string_t tx_vlan;
4437 cmdline_fixed_string_t set;
4440 uint16_t vlan_id_outer;
4444 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4445 __rte_unused struct cmdline *cl,
4446 __rte_unused void *data)
4448 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4450 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4453 if (!port_is_stopped(res->port_id)) {
4454 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4458 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4460 cmd_reconfig_device_queue(res->port_id, 1, 1);
4463 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4464 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4465 tx_vlan, "tx_vlan");
4466 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4467 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4469 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4470 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4471 port_id, RTE_UINT16);
4472 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4473 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4474 vlan_id, RTE_UINT16);
4475 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4476 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4477 vlan_id_outer, RTE_UINT16);
4479 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4480 .f = cmd_tx_vlan_set_qinq_parsed,
4482 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4483 "Enable hardware insertion of double VLAN header "
4484 "with given TAG Identifiers in packets sent on a port",
4486 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4487 (void *)&cmd_tx_vlan_set_qinq_set,
4488 (void *)&cmd_tx_vlan_set_qinq_portid,
4489 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4490 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4495 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4496 struct cmd_tx_vlan_set_pvid_result {
4497 cmdline_fixed_string_t tx_vlan;
4498 cmdline_fixed_string_t set;
4499 cmdline_fixed_string_t pvid;
4502 cmdline_fixed_string_t mode;
4506 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4507 __rte_unused struct cmdline *cl,
4508 __rte_unused void *data)
4510 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4512 if (strcmp(res->mode, "on") == 0)
4513 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4515 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4518 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4519 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4520 tx_vlan, "tx_vlan");
4521 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4522 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4524 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4525 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4527 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4528 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4529 port_id, RTE_UINT16);
4530 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4531 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4532 vlan_id, RTE_UINT16);
4533 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4534 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4537 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4538 .f = cmd_tx_vlan_set_pvid_parsed,
4540 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4542 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4543 (void *)&cmd_tx_vlan_set_pvid_set,
4544 (void *)&cmd_tx_vlan_set_pvid_pvid,
4545 (void *)&cmd_tx_vlan_set_pvid_port_id,
4546 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4547 (void *)&cmd_tx_vlan_set_pvid_mode,
4552 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4553 struct cmd_tx_vlan_reset_result {
4554 cmdline_fixed_string_t tx_vlan;
4555 cmdline_fixed_string_t reset;
4560 cmd_tx_vlan_reset_parsed(void *parsed_result,
4561 __rte_unused struct cmdline *cl,
4562 __rte_unused void *data)
4564 struct cmd_tx_vlan_reset_result *res = parsed_result;
4566 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4569 if (!port_is_stopped(res->port_id)) {
4570 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4574 tx_vlan_reset(res->port_id);
4576 cmd_reconfig_device_queue(res->port_id, 1, 1);
4579 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4580 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4581 tx_vlan, "tx_vlan");
4582 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4583 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4585 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4586 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4587 port_id, RTE_UINT16);
4589 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4590 .f = cmd_tx_vlan_reset_parsed,
4592 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4593 "VLAN header in packets sent on a port",
4595 (void *)&cmd_tx_vlan_reset_tx_vlan,
4596 (void *)&cmd_tx_vlan_reset_reset,
4597 (void *)&cmd_tx_vlan_reset_portid,
4603 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4604 struct cmd_csum_result {
4605 cmdline_fixed_string_t csum;
4606 cmdline_fixed_string_t mode;
4607 cmdline_fixed_string_t proto;
4608 cmdline_fixed_string_t hwsw;
4613 csum_show(int port_id)
4615 struct rte_eth_dev_info dev_info;
4616 uint64_t tx_offloads;
4619 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4620 printf("Parse tunnel is %s\n",
4621 (ports[port_id].parse_tunnel) ? "on" : "off");
4622 printf("IP checksum offload is %s\n",
4623 (tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4624 printf("UDP checksum offload is %s\n",
4625 (tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4626 printf("TCP checksum offload is %s\n",
4627 (tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4628 printf("SCTP checksum offload is %s\n",
4629 (tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4630 printf("Outer-Ip checksum offload is %s\n",
4631 (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4632 printf("Outer-Udp checksum offload is %s\n",
4633 (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4635 /* display warnings if configuration is not supported by the NIC */
4636 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4640 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) &&
4641 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4643 "Warning: hardware IP checksum enabled but not supported by port %d\n",
4646 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) &&
4647 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) == 0) {
4649 "Warning: hardware UDP checksum enabled but not supported by port %d\n",
4652 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) &&
4653 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) == 0) {
4655 "Warning: hardware TCP checksum enabled but not supported by port %d\n",
4658 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) &&
4659 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4661 "Warning: hardware SCTP checksum enabled but not supported by port %d\n",
4664 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4665 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4667 "Warning: hardware outer IP checksum enabled but not supported by port %d\n",
4670 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4671 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)
4674 "Warning: hardware outer UDP checksum enabled but not supported by port %d\n",
4680 cmd_config_queue_tx_offloads(struct rte_port *port)
4684 /* Apply queue tx offloads configuration */
4685 for (k = 0; k < port->dev_info.max_tx_queues; k++)
4686 port->tx_conf[k].offloads =
4687 port->dev_conf.txmode.offloads;
4691 cmd_csum_parsed(void *parsed_result,
4692 __rte_unused struct cmdline *cl,
4693 __rte_unused void *data)
4695 struct cmd_csum_result *res = parsed_result;
4697 uint64_t csum_offloads = 0;
4698 struct rte_eth_dev_info dev_info;
4701 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4702 fprintf(stderr, "invalid port %d\n", res->port_id);
4705 if (!port_is_stopped(res->port_id)) {
4706 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4710 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4714 if (!strcmp(res->mode, "set")) {
4716 if (!strcmp(res->hwsw, "hw"))
4719 if (!strcmp(res->proto, "ip")) {
4720 if (hw == 0 || (dev_info.tx_offload_capa &
4721 RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)) {
4722 csum_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
4725 "IP checksum offload is not supported by port %u\n",
4728 } else if (!strcmp(res->proto, "udp")) {
4729 if (hw == 0 || (dev_info.tx_offload_capa &
4730 RTE_ETH_TX_OFFLOAD_UDP_CKSUM)) {
4731 csum_offloads |= RTE_ETH_TX_OFFLOAD_UDP_CKSUM;
4734 "UDP checksum offload is not supported by port %u\n",
4737 } else if (!strcmp(res->proto, "tcp")) {
4738 if (hw == 0 || (dev_info.tx_offload_capa &
4739 RTE_ETH_TX_OFFLOAD_TCP_CKSUM)) {
4740 csum_offloads |= RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
4743 "TCP checksum offload is not supported by port %u\n",
4746 } else if (!strcmp(res->proto, "sctp")) {
4747 if (hw == 0 || (dev_info.tx_offload_capa &
4748 RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) {
4749 csum_offloads |= RTE_ETH_TX_OFFLOAD_SCTP_CKSUM;
4752 "SCTP checksum offload is not supported by port %u\n",
4755 } else if (!strcmp(res->proto, "outer-ip")) {
4756 if (hw == 0 || (dev_info.tx_offload_capa &
4757 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4759 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4762 "Outer IP checksum offload is not supported by port %u\n",
4765 } else if (!strcmp(res->proto, "outer-udp")) {
4766 if (hw == 0 || (dev_info.tx_offload_capa &
4767 RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4769 RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM;
4772 "Outer UDP checksum offload is not supported by port %u\n",
4778 ports[res->port_id].dev_conf.txmode.offloads |=
4781 ports[res->port_id].dev_conf.txmode.offloads &=
4784 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4786 csum_show(res->port_id);
4788 cmd_reconfig_device_queue(res->port_id, 1, 1);
4791 cmdline_parse_token_string_t cmd_csum_csum =
4792 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4794 cmdline_parse_token_string_t cmd_csum_mode =
4795 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4797 cmdline_parse_token_string_t cmd_csum_proto =
4798 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4799 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4800 cmdline_parse_token_string_t cmd_csum_hwsw =
4801 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4803 cmdline_parse_token_num_t cmd_csum_portid =
4804 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4805 port_id, RTE_UINT16);
4807 cmdline_parse_inst_t cmd_csum_set = {
4808 .f = cmd_csum_parsed,
4810 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4811 "Enable/Disable hardware calculation of L3/L4 checksum when "
4812 "using csum forward engine",
4814 (void *)&cmd_csum_csum,
4815 (void *)&cmd_csum_mode,
4816 (void *)&cmd_csum_proto,
4817 (void *)&cmd_csum_hwsw,
4818 (void *)&cmd_csum_portid,
4823 cmdline_parse_token_string_t cmd_csum_mode_show =
4824 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4827 cmdline_parse_inst_t cmd_csum_show = {
4828 .f = cmd_csum_parsed,
4830 .help_str = "csum show <port_id>: Show checksum offload configuration",
4832 (void *)&cmd_csum_csum,
4833 (void *)&cmd_csum_mode_show,
4834 (void *)&cmd_csum_portid,
4839 /* Enable/disable tunnel parsing */
4840 struct cmd_csum_tunnel_result {
4841 cmdline_fixed_string_t csum;
4842 cmdline_fixed_string_t parse;
4843 cmdline_fixed_string_t onoff;
4848 cmd_csum_tunnel_parsed(void *parsed_result,
4849 __rte_unused struct cmdline *cl,
4850 __rte_unused void *data)
4852 struct cmd_csum_tunnel_result *res = parsed_result;
4854 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4857 if (!strcmp(res->onoff, "on"))
4858 ports[res->port_id].parse_tunnel = 1;
4860 ports[res->port_id].parse_tunnel = 0;
4862 csum_show(res->port_id);
4865 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4866 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4868 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4869 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4870 parse, "parse-tunnel");
4871 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4872 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4874 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4875 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4876 port_id, RTE_UINT16);
4878 cmdline_parse_inst_t cmd_csum_tunnel = {
4879 .f = cmd_csum_tunnel_parsed,
4881 .help_str = "csum parse-tunnel on|off <port_id>: "
4882 "Enable/Disable parsing of tunnels for csum engine",
4884 (void *)&cmd_csum_tunnel_csum,
4885 (void *)&cmd_csum_tunnel_parse,
4886 (void *)&cmd_csum_tunnel_onoff,
4887 (void *)&cmd_csum_tunnel_portid,
4892 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4893 struct cmd_tso_set_result {
4894 cmdline_fixed_string_t tso;
4895 cmdline_fixed_string_t mode;
4901 cmd_tso_set_parsed(void *parsed_result,
4902 __rte_unused struct cmdline *cl,
4903 __rte_unused void *data)
4905 struct cmd_tso_set_result *res = parsed_result;
4906 struct rte_eth_dev_info dev_info;
4909 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4911 if (!port_is_stopped(res->port_id)) {
4912 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4916 if (!strcmp(res->mode, "set"))
4917 ports[res->port_id].tso_segsz = res->tso_segsz;
4919 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4923 if ((ports[res->port_id].tso_segsz != 0) &&
4924 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) {
4925 fprintf(stderr, "Error: TSO is not supported by port %d\n",
4930 if (ports[res->port_id].tso_segsz == 0) {
4931 ports[res->port_id].dev_conf.txmode.offloads &=
4932 ~RTE_ETH_TX_OFFLOAD_TCP_TSO;
4933 printf("TSO for non-tunneled packets is disabled\n");
4935 ports[res->port_id].dev_conf.txmode.offloads |=
4936 RTE_ETH_TX_OFFLOAD_TCP_TSO;
4937 printf("TSO segment size for non-tunneled packets is %d\n",
4938 ports[res->port_id].tso_segsz);
4940 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4942 /* display warnings if configuration is not supported by the NIC */
4943 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4947 if ((ports[res->port_id].tso_segsz != 0) &&
4948 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) {
4950 "Warning: TSO enabled but not supported by port %d\n",
4954 cmd_reconfig_device_queue(res->port_id, 1, 1);
4957 cmdline_parse_token_string_t cmd_tso_set_tso =
4958 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4960 cmdline_parse_token_string_t cmd_tso_set_mode =
4961 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4963 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4964 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4965 tso_segsz, RTE_UINT16);
4966 cmdline_parse_token_num_t cmd_tso_set_portid =
4967 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4968 port_id, RTE_UINT16);
4970 cmdline_parse_inst_t cmd_tso_set = {
4971 .f = cmd_tso_set_parsed,
4973 .help_str = "tso set <tso_segsz> <port_id>: "
4974 "Set TSO segment size of non-tunneled packets for csum engine "
4977 (void *)&cmd_tso_set_tso,
4978 (void *)&cmd_tso_set_mode,
4979 (void *)&cmd_tso_set_tso_segsz,
4980 (void *)&cmd_tso_set_portid,
4985 cmdline_parse_token_string_t cmd_tso_show_mode =
4986 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4990 cmdline_parse_inst_t cmd_tso_show = {
4991 .f = cmd_tso_set_parsed,
4993 .help_str = "tso show <port_id>: "
4994 "Show TSO segment size of non-tunneled packets for csum engine",
4996 (void *)&cmd_tso_set_tso,
4997 (void *)&cmd_tso_show_mode,
4998 (void *)&cmd_tso_set_portid,
5003 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5004 struct cmd_tunnel_tso_set_result {
5005 cmdline_fixed_string_t tso;
5006 cmdline_fixed_string_t mode;
5011 static struct rte_eth_dev_info
5012 check_tunnel_tso_nic_support(portid_t port_id)
5014 struct rte_eth_dev_info dev_info;
5016 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
5019 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO))
5021 "Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n",
5023 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO))
5025 "Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n",
5027 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO))
5029 "Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n",
5031 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO))
5033 "Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n",
5035 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IP_TNL_TSO))
5037 "Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n",
5039 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO))
5041 "Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n",
5047 cmd_tunnel_tso_set_parsed(void *parsed_result,
5048 __rte_unused struct cmdline *cl,
5049 __rte_unused void *data)
5051 struct cmd_tunnel_tso_set_result *res = parsed_result;
5052 struct rte_eth_dev_info dev_info;
5054 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5056 if (!port_is_stopped(res->port_id)) {
5057 fprintf(stderr, "Please stop port %d first\n", res->port_id);
5061 if (!strcmp(res->mode, "set"))
5062 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5064 dev_info = check_tunnel_tso_nic_support(res->port_id);
5065 if (ports[res->port_id].tunnel_tso_segsz == 0) {
5066 ports[res->port_id].dev_conf.txmode.offloads &=
5067 ~(RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5068 RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5069 RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5070 RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5071 RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5072 RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO);
5073 printf("TSO for tunneled packets is disabled\n");
5075 uint64_t tso_offloads = (RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5076 RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5077 RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5078 RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5079 RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5080 RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO);
5082 ports[res->port_id].dev_conf.txmode.offloads |=
5083 (tso_offloads & dev_info.tx_offload_capa);
5084 printf("TSO segment size for tunneled packets is %d\n",
5085 ports[res->port_id].tunnel_tso_segsz);
5087 /* Below conditions are needed to make it work:
5088 * (1) tunnel TSO is supported by the NIC;
5089 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5091 * (3) for tunneled pkts with outer L3 of IPv4,
5092 * "csum set outer-ip" must be set to hw, because after tso,
5093 * total_len of outer IP header is changed, and the checksum
5094 * of outer IP header calculated by sw should be wrong; that
5095 * is not necessary for IPv6 tunneled pkts because there's no
5096 * checksum in IP header anymore.
5099 if (!ports[res->port_id].parse_tunnel)
5101 "Warning: csum parse_tunnel must be set so that tunneled packets are recognized\n");
5102 if (!(ports[res->port_id].dev_conf.txmode.offloads &
5103 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5105 "Warning: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n");
5108 cmd_config_queue_tx_offloads(&ports[res->port_id]);
5109 cmd_reconfig_device_queue(res->port_id, 1, 1);
5112 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5113 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5115 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5116 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5118 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5119 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5120 tso_segsz, RTE_UINT16);
5121 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5122 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5123 port_id, RTE_UINT16);
5125 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5126 .f = cmd_tunnel_tso_set_parsed,
5128 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5129 "Set TSO segment size of tunneled packets for csum engine "
5132 (void *)&cmd_tunnel_tso_set_tso,
5133 (void *)&cmd_tunnel_tso_set_mode,
5134 (void *)&cmd_tunnel_tso_set_tso_segsz,
5135 (void *)&cmd_tunnel_tso_set_portid,
5140 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5141 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5145 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5146 .f = cmd_tunnel_tso_set_parsed,
5148 .help_str = "tunnel_tso show <port_id> "
5149 "Show TSO segment size of tunneled packets for csum engine",
5151 (void *)&cmd_tunnel_tso_set_tso,
5152 (void *)&cmd_tunnel_tso_show_mode,
5153 (void *)&cmd_tunnel_tso_set_portid,
5159 /* *** SET GRO FOR A PORT *** */
5160 struct cmd_gro_enable_result {
5161 cmdline_fixed_string_t cmd_set;
5162 cmdline_fixed_string_t cmd_port;
5163 cmdline_fixed_string_t cmd_keyword;
5164 cmdline_fixed_string_t cmd_onoff;
5169 cmd_gro_enable_parsed(void *parsed_result,
5170 __rte_unused struct cmdline *cl,
5171 __rte_unused void *data)
5173 struct cmd_gro_enable_result *res;
5175 res = parsed_result;
5176 if (!strcmp(res->cmd_keyword, "gro"))
5177 setup_gro(res->cmd_onoff, res->cmd_pid);
5180 cmdline_parse_token_string_t cmd_gro_enable_set =
5181 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5183 cmdline_parse_token_string_t cmd_gro_enable_port =
5184 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5185 cmd_keyword, "port");
5186 cmdline_parse_token_num_t cmd_gro_enable_pid =
5187 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5188 cmd_pid, RTE_UINT16);
5189 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5190 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5191 cmd_keyword, "gro");
5192 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5193 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5194 cmd_onoff, "on#off");
5196 cmdline_parse_inst_t cmd_gro_enable = {
5197 .f = cmd_gro_enable_parsed,
5199 .help_str = "set port <port_id> gro on|off",
5201 (void *)&cmd_gro_enable_set,
5202 (void *)&cmd_gro_enable_port,
5203 (void *)&cmd_gro_enable_pid,
5204 (void *)&cmd_gro_enable_keyword,
5205 (void *)&cmd_gro_enable_onoff,
5210 /* *** DISPLAY GRO CONFIGURATION *** */
5211 struct cmd_gro_show_result {
5212 cmdline_fixed_string_t cmd_show;
5213 cmdline_fixed_string_t cmd_port;
5214 cmdline_fixed_string_t cmd_keyword;
5219 cmd_gro_show_parsed(void *parsed_result,
5220 __rte_unused struct cmdline *cl,
5221 __rte_unused void *data)
5223 struct cmd_gro_show_result *res;
5225 res = parsed_result;
5226 if (!strcmp(res->cmd_keyword, "gro"))
5227 show_gro(res->cmd_pid);
5230 cmdline_parse_token_string_t cmd_gro_show_show =
5231 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5233 cmdline_parse_token_string_t cmd_gro_show_port =
5234 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5236 cmdline_parse_token_num_t cmd_gro_show_pid =
5237 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5238 cmd_pid, RTE_UINT16);
5239 cmdline_parse_token_string_t cmd_gro_show_keyword =
5240 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5241 cmd_keyword, "gro");
5243 cmdline_parse_inst_t cmd_gro_show = {
5244 .f = cmd_gro_show_parsed,
5246 .help_str = "show port <port_id> gro",
5248 (void *)&cmd_gro_show_show,
5249 (void *)&cmd_gro_show_port,
5250 (void *)&cmd_gro_show_pid,
5251 (void *)&cmd_gro_show_keyword,
5256 /* *** SET FLUSH CYCLES FOR GRO *** */
5257 struct cmd_gro_flush_result {
5258 cmdline_fixed_string_t cmd_set;
5259 cmdline_fixed_string_t cmd_keyword;
5260 cmdline_fixed_string_t cmd_flush;
5265 cmd_gro_flush_parsed(void *parsed_result,
5266 __rte_unused struct cmdline *cl,
5267 __rte_unused void *data)
5269 struct cmd_gro_flush_result *res;
5271 res = parsed_result;
5272 if ((!strcmp(res->cmd_keyword, "gro")) &&
5273 (!strcmp(res->cmd_flush, "flush")))
5274 setup_gro_flush_cycles(res->cmd_cycles);
5277 cmdline_parse_token_string_t cmd_gro_flush_set =
5278 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5280 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5281 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5282 cmd_keyword, "gro");
5283 cmdline_parse_token_string_t cmd_gro_flush_flush =
5284 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5285 cmd_flush, "flush");
5286 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5287 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5288 cmd_cycles, RTE_UINT8);
5290 cmdline_parse_inst_t cmd_gro_flush = {
5291 .f = cmd_gro_flush_parsed,
5293 .help_str = "set gro flush <cycles>",
5295 (void *)&cmd_gro_flush_set,
5296 (void *)&cmd_gro_flush_keyword,
5297 (void *)&cmd_gro_flush_flush,
5298 (void *)&cmd_gro_flush_cycles,
5302 #endif /* RTE_LIB_GRO */
5305 /* *** ENABLE/DISABLE GSO *** */
5306 struct cmd_gso_enable_result {
5307 cmdline_fixed_string_t cmd_set;
5308 cmdline_fixed_string_t cmd_port;
5309 cmdline_fixed_string_t cmd_keyword;
5310 cmdline_fixed_string_t cmd_mode;
5315 cmd_gso_enable_parsed(void *parsed_result,
5316 __rte_unused struct cmdline *cl,
5317 __rte_unused void *data)
5319 struct cmd_gso_enable_result *res;
5321 res = parsed_result;
5322 if (!strcmp(res->cmd_keyword, "gso"))
5323 setup_gso(res->cmd_mode, res->cmd_pid);
5326 cmdline_parse_token_string_t cmd_gso_enable_set =
5327 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5329 cmdline_parse_token_string_t cmd_gso_enable_port =
5330 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5332 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5333 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5334 cmd_keyword, "gso");
5335 cmdline_parse_token_string_t cmd_gso_enable_mode =
5336 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5337 cmd_mode, "on#off");
5338 cmdline_parse_token_num_t cmd_gso_enable_pid =
5339 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5340 cmd_pid, RTE_UINT16);
5342 cmdline_parse_inst_t cmd_gso_enable = {
5343 .f = cmd_gso_enable_parsed,
5345 .help_str = "set port <port_id> gso on|off",
5347 (void *)&cmd_gso_enable_set,
5348 (void *)&cmd_gso_enable_port,
5349 (void *)&cmd_gso_enable_pid,
5350 (void *)&cmd_gso_enable_keyword,
5351 (void *)&cmd_gso_enable_mode,
5356 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5357 struct cmd_gso_size_result {
5358 cmdline_fixed_string_t cmd_set;
5359 cmdline_fixed_string_t cmd_keyword;
5360 cmdline_fixed_string_t cmd_segsz;
5365 cmd_gso_size_parsed(void *parsed_result,
5366 __rte_unused struct cmdline *cl,
5367 __rte_unused void *data)
5369 struct cmd_gso_size_result *res = parsed_result;
5371 if (test_done == 0) {
5373 "Before setting GSO segsz, please first stop forwarding\n");
5377 if (!strcmp(res->cmd_keyword, "gso") &&
5378 !strcmp(res->cmd_segsz, "segsz")) {
5379 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5381 "gso_size should be larger than %zu. Please input a legal value\n",
5382 RTE_GSO_SEG_SIZE_MIN);
5384 gso_max_segment_size = res->cmd_size;
5388 cmdline_parse_token_string_t cmd_gso_size_set =
5389 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5391 cmdline_parse_token_string_t cmd_gso_size_keyword =
5392 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5393 cmd_keyword, "gso");
5394 cmdline_parse_token_string_t cmd_gso_size_segsz =
5395 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5396 cmd_segsz, "segsz");
5397 cmdline_parse_token_num_t cmd_gso_size_size =
5398 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5399 cmd_size, RTE_UINT16);
5401 cmdline_parse_inst_t cmd_gso_size = {
5402 .f = cmd_gso_size_parsed,
5404 .help_str = "set gso segsz <length>",
5406 (void *)&cmd_gso_size_set,
5407 (void *)&cmd_gso_size_keyword,
5408 (void *)&cmd_gso_size_segsz,
5409 (void *)&cmd_gso_size_size,
5414 /* *** SHOW GSO CONFIGURATION *** */
5415 struct cmd_gso_show_result {
5416 cmdline_fixed_string_t cmd_show;
5417 cmdline_fixed_string_t cmd_port;
5418 cmdline_fixed_string_t cmd_keyword;
5423 cmd_gso_show_parsed(void *parsed_result,
5424 __rte_unused struct cmdline *cl,
5425 __rte_unused void *data)
5427 struct cmd_gso_show_result *res = parsed_result;
5429 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5430 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
5433 if (!strcmp(res->cmd_keyword, "gso")) {
5434 if (gso_ports[res->cmd_pid].enable) {
5435 printf("Max GSO'd packet size: %uB\n"
5436 "Supported GSO types: TCP/IPv4, "
5437 "UDP/IPv4, VxLAN with inner "
5438 "TCP/IPv4 packet, GRE with inner "
5439 "TCP/IPv4 packet\n",
5440 gso_max_segment_size);
5442 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5446 cmdline_parse_token_string_t cmd_gso_show_show =
5447 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5449 cmdline_parse_token_string_t cmd_gso_show_port =
5450 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5452 cmdline_parse_token_string_t cmd_gso_show_keyword =
5453 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5454 cmd_keyword, "gso");
5455 cmdline_parse_token_num_t cmd_gso_show_pid =
5456 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5457 cmd_pid, RTE_UINT16);
5459 cmdline_parse_inst_t cmd_gso_show = {
5460 .f = cmd_gso_show_parsed,
5462 .help_str = "show port <port_id> gso",
5464 (void *)&cmd_gso_show_show,
5465 (void *)&cmd_gso_show_port,
5466 (void *)&cmd_gso_show_pid,
5467 (void *)&cmd_gso_show_keyword,
5471 #endif /* RTE_LIB_GSO */
5473 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5474 struct cmd_set_flush_rx {
5475 cmdline_fixed_string_t set;
5476 cmdline_fixed_string_t flush_rx;
5477 cmdline_fixed_string_t mode;
5481 cmd_set_flush_rx_parsed(void *parsed_result,
5482 __rte_unused struct cmdline *cl,
5483 __rte_unused void *data)
5485 struct cmd_set_flush_rx *res = parsed_result;
5487 if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) {
5488 printf("multi-process doesn't support to flush Rx queues.\n");
5492 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5495 cmdline_parse_token_string_t cmd_setflushrx_set =
5496 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5498 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5499 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5500 flush_rx, "flush_rx");
5501 cmdline_parse_token_string_t cmd_setflushrx_mode =
5502 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5506 cmdline_parse_inst_t cmd_set_flush_rx = {
5507 .f = cmd_set_flush_rx_parsed,
5508 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5511 (void *)&cmd_setflushrx_set,
5512 (void *)&cmd_setflushrx_flush_rx,
5513 (void *)&cmd_setflushrx_mode,
5518 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5519 struct cmd_set_link_check {
5520 cmdline_fixed_string_t set;
5521 cmdline_fixed_string_t link_check;
5522 cmdline_fixed_string_t mode;
5526 cmd_set_link_check_parsed(void *parsed_result,
5527 __rte_unused struct cmdline *cl,
5528 __rte_unused void *data)
5530 struct cmd_set_link_check *res = parsed_result;
5531 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5534 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5535 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5537 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5538 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5539 link_check, "link_check");
5540 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5541 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5545 cmdline_parse_inst_t cmd_set_link_check = {
5546 .f = cmd_set_link_check_parsed,
5547 .help_str = "set link_check on|off: Enable/Disable link status check "
5548 "when starting/stopping a port",
5551 (void *)&cmd_setlinkcheck_set,
5552 (void *)&cmd_setlinkcheck_link_check,
5553 (void *)&cmd_setlinkcheck_mode,
5558 /* *** SET NIC BYPASS MODE *** */
5559 struct cmd_set_bypass_mode_result {
5560 cmdline_fixed_string_t set;
5561 cmdline_fixed_string_t bypass;
5562 cmdline_fixed_string_t mode;
5563 cmdline_fixed_string_t value;
5568 cmd_set_bypass_mode_parsed(void *parsed_result,
5569 __rte_unused struct cmdline *cl,
5570 __rte_unused void *data)
5572 struct cmd_set_bypass_mode_result *res = parsed_result;
5573 portid_t port_id = res->port_id;
5574 int32_t rc = -EINVAL;
5576 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5577 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5579 if (!strcmp(res->value, "bypass"))
5580 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5581 else if (!strcmp(res->value, "isolate"))
5582 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5584 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5586 /* Set the bypass mode for the relevant port. */
5587 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5590 fprintf(stderr, "\t Failed to set bypass mode for port = %d.\n",
5594 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5595 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5597 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5598 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5600 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5601 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5603 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5604 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5605 value, "normal#bypass#isolate");
5606 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5607 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5608 port_id, RTE_UINT16);
5610 cmdline_parse_inst_t cmd_set_bypass_mode = {
5611 .f = cmd_set_bypass_mode_parsed,
5612 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5613 "Set the NIC bypass mode for port_id",
5616 (void *)&cmd_setbypass_mode_set,
5617 (void *)&cmd_setbypass_mode_bypass,
5618 (void *)&cmd_setbypass_mode_mode,
5619 (void *)&cmd_setbypass_mode_value,
5620 (void *)&cmd_setbypass_mode_port,
5625 /* *** SET NIC BYPASS EVENT *** */
5626 struct cmd_set_bypass_event_result {
5627 cmdline_fixed_string_t set;
5628 cmdline_fixed_string_t bypass;
5629 cmdline_fixed_string_t event;
5630 cmdline_fixed_string_t event_value;
5631 cmdline_fixed_string_t mode;
5632 cmdline_fixed_string_t mode_value;
5637 cmd_set_bypass_event_parsed(void *parsed_result,
5638 __rte_unused struct cmdline *cl,
5639 __rte_unused void *data)
5641 int32_t rc = -EINVAL;
5642 struct cmd_set_bypass_event_result *res = parsed_result;
5643 portid_t port_id = res->port_id;
5645 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5646 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5647 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5649 if (!strcmp(res->event_value, "timeout"))
5650 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5651 else if (!strcmp(res->event_value, "os_on"))
5652 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5653 else if (!strcmp(res->event_value, "os_off"))
5654 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5655 else if (!strcmp(res->event_value, "power_on"))
5656 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5657 else if (!strcmp(res->event_value, "power_off"))
5658 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5660 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5662 if (!strcmp(res->mode_value, "bypass"))
5663 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5664 else if (!strcmp(res->mode_value, "isolate"))
5665 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5667 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5669 /* Set the watchdog timeout. */
5670 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5673 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5674 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5679 "Failed to set timeout value %u for port %d, errto code: %d.\n",
5680 bypass_timeout, port_id, rc);
5684 /* Set the bypass event to transition to bypass mode. */
5685 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5690 fprintf(stderr, "\t Failed to set bypass event for port = %d.\n",
5694 cmdline_parse_token_string_t cmd_setbypass_event_set =
5695 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5697 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5698 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5700 cmdline_parse_token_string_t cmd_setbypass_event_event =
5701 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5703 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5704 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5705 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5706 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5707 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5709 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5710 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5711 mode_value, "normal#bypass#isolate");
5712 cmdline_parse_token_num_t cmd_setbypass_event_port =
5713 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5714 port_id, RTE_UINT16);
5716 cmdline_parse_inst_t cmd_set_bypass_event = {
5717 .f = cmd_set_bypass_event_parsed,
5718 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5719 "power_off mode normal|bypass|isolate <port_id>: "
5720 "Set the NIC bypass event mode for port_id",
5723 (void *)&cmd_setbypass_event_set,
5724 (void *)&cmd_setbypass_event_bypass,
5725 (void *)&cmd_setbypass_event_event,
5726 (void *)&cmd_setbypass_event_event_value,
5727 (void *)&cmd_setbypass_event_mode,
5728 (void *)&cmd_setbypass_event_mode_value,
5729 (void *)&cmd_setbypass_event_port,
5735 /* *** SET NIC BYPASS TIMEOUT *** */
5736 struct cmd_set_bypass_timeout_result {
5737 cmdline_fixed_string_t set;
5738 cmdline_fixed_string_t bypass;
5739 cmdline_fixed_string_t timeout;
5740 cmdline_fixed_string_t value;
5744 cmd_set_bypass_timeout_parsed(void *parsed_result,
5745 __rte_unused struct cmdline *cl,
5746 __rte_unused void *data)
5748 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5750 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5751 if (!strcmp(res->value, "1.5"))
5752 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5753 else if (!strcmp(res->value, "2"))
5754 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5755 else if (!strcmp(res->value, "3"))
5756 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5757 else if (!strcmp(res->value, "4"))
5758 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5759 else if (!strcmp(res->value, "8"))
5760 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5761 else if (!strcmp(res->value, "16"))
5762 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5763 else if (!strcmp(res->value, "32"))
5764 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5766 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5770 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5771 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5773 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5774 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5776 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5777 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5778 timeout, "timeout");
5779 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5780 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5781 value, "0#1.5#2#3#4#8#16#32");
5783 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5784 .f = cmd_set_bypass_timeout_parsed,
5785 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5786 "Set the NIC bypass watchdog timeout in seconds",
5789 (void *)&cmd_setbypass_timeout_set,
5790 (void *)&cmd_setbypass_timeout_bypass,
5791 (void *)&cmd_setbypass_timeout_timeout,
5792 (void *)&cmd_setbypass_timeout_value,
5797 /* *** SHOW NIC BYPASS MODE *** */
5798 struct cmd_show_bypass_config_result {
5799 cmdline_fixed_string_t show;
5800 cmdline_fixed_string_t bypass;
5801 cmdline_fixed_string_t config;
5806 cmd_show_bypass_config_parsed(void *parsed_result,
5807 __rte_unused struct cmdline *cl,
5808 __rte_unused void *data)
5810 struct cmd_show_bypass_config_result *res = parsed_result;
5811 portid_t port_id = res->port_id;
5813 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5814 uint32_t event_mode;
5815 uint32_t bypass_mode;
5816 uint32_t timeout = bypass_timeout;
5819 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5820 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5821 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5822 {"UNKNOWN", "normal", "bypass", "isolate"};
5823 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5831 /* Display the bypass mode.*/
5832 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5833 fprintf(stderr, "\tFailed to get bypass mode for port = %d\n",
5838 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5839 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5841 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5844 /* Display the bypass timeout.*/
5845 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5846 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5848 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5850 /* Display the bypass events and associated modes. */
5851 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5853 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5855 "\tFailed to get bypass mode for event = %s\n",
5858 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5859 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5861 printf("\tbypass event: %-16s = %s\n", events[i],
5868 "\tFailed to get bypass configuration for port = %d\n",
5872 cmdline_parse_token_string_t cmd_showbypass_config_show =
5873 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5875 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5876 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5878 cmdline_parse_token_string_t cmd_showbypass_config_config =
5879 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5881 cmdline_parse_token_num_t cmd_showbypass_config_port =
5882 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5883 port_id, RTE_UINT16);
5885 cmdline_parse_inst_t cmd_show_bypass_config = {
5886 .f = cmd_show_bypass_config_parsed,
5887 .help_str = "show bypass config <port_id>: "
5888 "Show the NIC bypass config for port_id",
5891 (void *)&cmd_showbypass_config_show,
5892 (void *)&cmd_showbypass_config_bypass,
5893 (void *)&cmd_showbypass_config_config,
5894 (void *)&cmd_showbypass_config_port,
5900 /* *** SET BONDING MODE *** */
5901 struct cmd_set_bonding_mode_result {
5902 cmdline_fixed_string_t set;
5903 cmdline_fixed_string_t bonding;
5904 cmdline_fixed_string_t mode;
5909 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5910 __rte_unused struct cmdline *cl,
5911 __rte_unused void *data)
5913 struct cmd_set_bonding_mode_result *res = parsed_result;
5914 portid_t port_id = res->port_id;
5916 /* Set the bonding mode for the relevant port. */
5917 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5918 fprintf(stderr, "\t Failed to set bonding mode for port = %d.\n",
5922 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5923 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5925 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5926 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5927 bonding, "bonding");
5928 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5929 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5931 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5932 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5934 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5935 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5936 port_id, RTE_UINT16);
5938 cmdline_parse_inst_t cmd_set_bonding_mode = {
5939 .f = cmd_set_bonding_mode_parsed,
5940 .help_str = "set bonding mode <mode_value> <port_id>: "
5941 "Set the bonding mode for port_id",
5944 (void *) &cmd_setbonding_mode_set,
5945 (void *) &cmd_setbonding_mode_bonding,
5946 (void *) &cmd_setbonding_mode_mode,
5947 (void *) &cmd_setbonding_mode_value,
5948 (void *) &cmd_setbonding_mode_port,
5953 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5954 struct cmd_set_bonding_lacp_dedicated_queues_result {
5955 cmdline_fixed_string_t set;
5956 cmdline_fixed_string_t bonding;
5957 cmdline_fixed_string_t lacp;
5958 cmdline_fixed_string_t dedicated_queues;
5960 cmdline_fixed_string_t mode;
5963 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5964 __rte_unused struct cmdline *cl,
5965 __rte_unused void *data)
5967 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5968 portid_t port_id = res->port_id;
5969 struct rte_port *port;
5971 port = &ports[port_id];
5973 /** Check if the port is not started **/
5974 if (port->port_status != RTE_PORT_STOPPED) {
5975 fprintf(stderr, "Please stop port %d first\n", port_id);
5979 if (!strcmp(res->mode, "enable")) {
5980 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5981 printf("Dedicate queues for LACP control packets"
5984 printf("Enabling dedicate queues for LACP control "
5985 "packets on port %d failed\n", port_id);
5986 } else if (!strcmp(res->mode, "disable")) {
5987 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5988 printf("Dedicated queues for LACP control packets "
5991 printf("Disabling dedicated queues for LACP control "
5992 "traffic on port %d failed\n", port_id);
5996 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5997 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5999 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
6000 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6001 bonding, "bonding");
6002 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
6003 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6005 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
6006 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6007 dedicated_queues, "dedicated_queues");
6008 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
6009 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6010 port_id, RTE_UINT16);
6011 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
6012 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6013 mode, "enable#disable");
6015 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
6016 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
6017 .help_str = "set bonding lacp dedicated_queues <port_id> "
6019 "Enable/disable dedicated queues for LACP control traffic for port_id",
6022 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
6023 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
6024 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
6025 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
6026 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
6027 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
6032 /* *** SET BALANCE XMIT POLICY *** */
6033 struct cmd_set_bonding_balance_xmit_policy_result {
6034 cmdline_fixed_string_t set;
6035 cmdline_fixed_string_t bonding;
6036 cmdline_fixed_string_t balance_xmit_policy;
6038 cmdline_fixed_string_t policy;
6041 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
6042 __rte_unused struct cmdline *cl,
6043 __rte_unused void *data)
6045 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6046 portid_t port_id = res->port_id;
6049 if (!strcmp(res->policy, "l2")) {
6050 policy = BALANCE_XMIT_POLICY_LAYER2;
6051 } else if (!strcmp(res->policy, "l23")) {
6052 policy = BALANCE_XMIT_POLICY_LAYER23;
6053 } else if (!strcmp(res->policy, "l34")) {
6054 policy = BALANCE_XMIT_POLICY_LAYER34;
6056 fprintf(stderr, "\t Invalid xmit policy selection");
6060 /* Set the bonding mode for the relevant port. */
6061 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6063 "\t Failed to set bonding balance xmit policy for port = %d.\n",
6068 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6069 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6071 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6072 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6073 bonding, "bonding");
6074 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6075 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6076 balance_xmit_policy, "balance_xmit_policy");
6077 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6078 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6079 port_id, RTE_UINT16);
6080 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6081 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6082 policy, "l2#l23#l34");
6084 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6085 .f = cmd_set_bonding_balance_xmit_policy_parsed,
6086 .help_str = "set bonding balance_xmit_policy <port_id> "
6088 "Set the bonding balance_xmit_policy for port_id",
6091 (void *)&cmd_setbonding_balance_xmit_policy_set,
6092 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
6093 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6094 (void *)&cmd_setbonding_balance_xmit_policy_port,
6095 (void *)&cmd_setbonding_balance_xmit_policy_policy,
6100 /* *** SHOW IEEE802.3 BONDING INFORMATION *** */
6101 struct cmd_show_bonding_lacp_info_result {
6102 cmdline_fixed_string_t show;
6103 cmdline_fixed_string_t bonding;
6104 cmdline_fixed_string_t lacp;
6105 cmdline_fixed_string_t info;
6109 static void port_param_show(struct port_params *params)
6111 char buf[RTE_ETHER_ADDR_FMT_SIZE];
6113 printf("\t\tsystem priority: %u\n", params->system_priority);
6114 rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, ¶ms->system);
6115 printf("\t\tsystem mac address: %s\n", buf);
6116 printf("\t\tport key: %u\n", params->key);
6117 printf("\t\tport priority: %u\n", params->port_priority);
6118 printf("\t\tport number: %u\n", params->port_number);
6121 static void lacp_slave_info_show(struct rte_eth_bond_8023ad_slave_info *info)
6123 char a_state[256] = { 0 };
6124 char p_state[256] = { 0 };
6129 static const char * const state[] = {
6139 static const char * const selection[] = {
6145 for (i = 0; i < RTE_DIM(state); i++) {
6146 if ((info->actor_state >> i) & 1)
6147 a_len += snprintf(&a_state[a_len],
6148 RTE_DIM(a_state) - a_len, "%s ",
6151 if ((info->partner_state >> i) & 1)
6152 p_len += snprintf(&p_state[p_len],
6153 RTE_DIM(p_state) - p_len, "%s ",
6156 printf("\tAggregator port id: %u\n", info->agg_port_id);
6157 printf("\tselection: %s\n", selection[info->selected]);
6158 printf("\tActor detail info:\n");
6159 port_param_show(&info->actor);
6160 printf("\t\tport state: %s\n", a_state);
6161 printf("\tPartner detail info:\n");
6162 port_param_show(&info->partner);
6163 printf("\t\tport state: %s\n", p_state);
6167 static void lacp_conf_show(struct rte_eth_bond_8023ad_conf *conf)
6169 printf("\tfast period: %u ms\n", conf->fast_periodic_ms);
6170 printf("\tslow period: %u ms\n", conf->slow_periodic_ms);
6171 printf("\tshort timeout: %u ms\n", conf->short_timeout_ms);
6172 printf("\tlong timeout: %u ms\n", conf->long_timeout_ms);
6173 printf("\taggregate wait timeout: %u ms\n",
6174 conf->aggregate_wait_timeout_ms);
6175 printf("\ttx period: %u ms\n", conf->tx_period_ms);
6176 printf("\trx marker period: %u ms\n", conf->rx_marker_period_ms);
6177 printf("\tupdate timeout: %u ms\n", conf->update_timeout_ms);
6178 switch (conf->agg_selection) {
6180 printf("\taggregation mode: bandwidth\n");
6183 printf("\taggregation mode: stable\n");
6186 printf("\taggregation mode: count\n");
6189 printf("\taggregation mode: invalid\n");
6196 static void cmd_show_bonding_lacp_info_parsed(void *parsed_result,
6197 __rte_unused struct cmdline *cl,
6198 __rte_unused void *data)
6200 struct cmd_show_bonding_lacp_info_result *res = parsed_result;
6201 struct rte_eth_bond_8023ad_slave_info slave_info;
6202 struct rte_eth_bond_8023ad_conf port_conf;
6203 portid_t slaves[RTE_MAX_ETHPORTS];
6204 portid_t port_id = res->port_id;
6205 int num_active_slaves;
6210 bonding_mode = rte_eth_bond_mode_get(port_id);
6211 if (bonding_mode != BONDING_MODE_8023AD) {
6212 fprintf(stderr, "\tBonding mode is not mode 4\n");
6216 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6218 if (num_active_slaves < 0) {
6219 fprintf(stderr, "\tFailed to get active slave list for port = %u\n",
6223 if (num_active_slaves == 0)
6224 fprintf(stderr, "\tIEEE802.3 port %u has no active slave\n",
6227 printf("\tIEEE802.3 port: %u\n", port_id);
6228 ret = rte_eth_bond_8023ad_conf_get(port_id, &port_conf);
6230 fprintf(stderr, "\tGet bonded device %u info failed\n",
6234 lacp_conf_show(&port_conf);
6236 for (i = 0; i < num_active_slaves; i++) {
6237 ret = rte_eth_bond_8023ad_slave_info(port_id, slaves[i],
6240 fprintf(stderr, "\tGet slave device %u info failed\n",
6244 printf("\tSlave Port: %u\n", slaves[i]);
6245 lacp_slave_info_show(&slave_info);
6249 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_show =
6250 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6252 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_bonding =
6253 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6254 bonding, "bonding");
6255 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_lacp =
6256 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6258 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_info =
6259 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6261 cmdline_parse_token_num_t cmd_show_bonding_lacp_info_port_id =
6262 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6263 port_id, RTE_UINT16);
6265 cmdline_parse_inst_t cmd_show_bonding_lacp_info = {
6266 .f = cmd_show_bonding_lacp_info_parsed,
6267 .help_str = "show bonding lacp info <port_id> : "
6268 "Show bonding IEEE802.3 information for port_id",
6271 (void *)&cmd_show_bonding_lacp_info_show,
6272 (void *)&cmd_show_bonding_lacp_info_bonding,
6273 (void *)&cmd_show_bonding_lacp_info_lacp,
6274 (void *)&cmd_show_bonding_lacp_info_info,
6275 (void *)&cmd_show_bonding_lacp_info_port_id,
6280 /* *** SHOW NIC BONDING CONFIGURATION *** */
6281 struct cmd_show_bonding_config_result {
6282 cmdline_fixed_string_t show;
6283 cmdline_fixed_string_t bonding;
6284 cmdline_fixed_string_t config;
6288 static void cmd_show_bonding_config_parsed(void *parsed_result,
6289 __rte_unused struct cmdline *cl,
6290 __rte_unused void *data)
6292 struct cmd_show_bonding_config_result *res = parsed_result;
6293 int bonding_mode, agg_mode;
6294 portid_t slaves[RTE_MAX_ETHPORTS];
6295 int num_slaves, num_active_slaves;
6298 portid_t port_id = res->port_id;
6300 /* Display the bonding mode.*/
6301 bonding_mode = rte_eth_bond_mode_get(port_id);
6302 if (bonding_mode < 0) {
6303 fprintf(stderr, "\tFailed to get bonding mode for port = %d\n",
6307 printf("\tBonding mode: %d\n", bonding_mode);
6309 if (bonding_mode == BONDING_MODE_BALANCE ||
6310 bonding_mode == BONDING_MODE_8023AD) {
6311 int balance_xmit_policy;
6313 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6314 if (balance_xmit_policy < 0) {
6316 "\tFailed to get balance xmit policy for port = %d\n",
6320 printf("\tBalance Xmit Policy: ");
6322 switch (balance_xmit_policy) {
6323 case BALANCE_XMIT_POLICY_LAYER2:
6324 printf("BALANCE_XMIT_POLICY_LAYER2");
6326 case BALANCE_XMIT_POLICY_LAYER23:
6327 printf("BALANCE_XMIT_POLICY_LAYER23");
6329 case BALANCE_XMIT_POLICY_LAYER34:
6330 printf("BALANCE_XMIT_POLICY_LAYER34");
6337 if (bonding_mode == BONDING_MODE_8023AD) {
6338 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6339 printf("\tIEEE802.3AD Aggregator Mode: ");
6342 printf("bandwidth");
6354 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6356 if (num_slaves < 0) {
6357 fprintf(stderr, "\tFailed to get slave list for port = %d\n",
6361 if (num_slaves > 0) {
6362 printf("\tSlaves (%d): [", num_slaves);
6363 for (i = 0; i < num_slaves - 1; i++)
6364 printf("%d ", slaves[i]);
6366 printf("%d]\n", slaves[num_slaves - 1]);
6368 printf("\tSlaves: []\n");
6372 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6375 if (num_active_slaves < 0) {
6377 "\tFailed to get active slave list for port = %d\n",
6381 if (num_active_slaves > 0) {
6382 printf("\tActive Slaves (%d): [", num_active_slaves);
6383 for (i = 0; i < num_active_slaves - 1; i++)
6384 printf("%d ", slaves[i]);
6386 printf("%d]\n", slaves[num_active_slaves - 1]);
6389 printf("\tActive Slaves: []\n");
6393 primary_id = rte_eth_bond_primary_get(port_id);
6394 if (primary_id < 0) {
6395 fprintf(stderr, "\tFailed to get primary slave for port = %d\n",
6399 printf("\tPrimary: [%d]\n", primary_id);
6403 cmdline_parse_token_string_t cmd_showbonding_config_show =
6404 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6406 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6407 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6408 bonding, "bonding");
6409 cmdline_parse_token_string_t cmd_showbonding_config_config =
6410 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6412 cmdline_parse_token_num_t cmd_showbonding_config_port =
6413 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6414 port_id, RTE_UINT16);
6416 cmdline_parse_inst_t cmd_show_bonding_config = {
6417 .f = cmd_show_bonding_config_parsed,
6418 .help_str = "show bonding config <port_id>: "
6419 "Show the bonding config for port_id",
6422 (void *)&cmd_showbonding_config_show,
6423 (void *)&cmd_showbonding_config_bonding,
6424 (void *)&cmd_showbonding_config_config,
6425 (void *)&cmd_showbonding_config_port,
6430 /* *** SET BONDING PRIMARY *** */
6431 struct cmd_set_bonding_primary_result {
6432 cmdline_fixed_string_t set;
6433 cmdline_fixed_string_t bonding;
6434 cmdline_fixed_string_t primary;
6439 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6440 __rte_unused struct cmdline *cl,
6441 __rte_unused void *data)
6443 struct cmd_set_bonding_primary_result *res = parsed_result;
6444 portid_t master_port_id = res->port_id;
6445 portid_t slave_port_id = res->slave_id;
6447 /* Set the primary slave for a bonded device. */
6448 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6449 fprintf(stderr, "\t Failed to set primary slave for port = %d.\n",
6456 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6457 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6459 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6460 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6461 bonding, "bonding");
6462 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6463 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6464 primary, "primary");
6465 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6466 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6467 slave_id, RTE_UINT16);
6468 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6469 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6470 port_id, RTE_UINT16);
6472 cmdline_parse_inst_t cmd_set_bonding_primary = {
6473 .f = cmd_set_bonding_primary_parsed,
6474 .help_str = "set bonding primary <slave_id> <port_id>: "
6475 "Set the primary slave for port_id",
6478 (void *)&cmd_setbonding_primary_set,
6479 (void *)&cmd_setbonding_primary_bonding,
6480 (void *)&cmd_setbonding_primary_primary,
6481 (void *)&cmd_setbonding_primary_slave,
6482 (void *)&cmd_setbonding_primary_port,
6487 /* *** ADD SLAVE *** */
6488 struct cmd_add_bonding_slave_result {
6489 cmdline_fixed_string_t add;
6490 cmdline_fixed_string_t bonding;
6491 cmdline_fixed_string_t slave;
6496 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6497 __rte_unused struct cmdline *cl,
6498 __rte_unused void *data)
6500 struct cmd_add_bonding_slave_result *res = parsed_result;
6501 portid_t master_port_id = res->port_id;
6502 portid_t slave_port_id = res->slave_id;
6504 /* add the slave for a bonded device. */
6505 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6507 "\t Failed to add slave %d to master port = %d.\n",
6508 slave_port_id, master_port_id);
6512 set_port_slave_flag(slave_port_id);
6515 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6516 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6518 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6519 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6520 bonding, "bonding");
6521 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6522 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6524 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6525 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6526 slave_id, RTE_UINT16);
6527 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6528 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6529 port_id, RTE_UINT16);
6531 cmdline_parse_inst_t cmd_add_bonding_slave = {
6532 .f = cmd_add_bonding_slave_parsed,
6533 .help_str = "add bonding slave <slave_id> <port_id>: "
6534 "Add a slave device to a bonded device",
6537 (void *)&cmd_addbonding_slave_add,
6538 (void *)&cmd_addbonding_slave_bonding,
6539 (void *)&cmd_addbonding_slave_slave,
6540 (void *)&cmd_addbonding_slave_slaveid,
6541 (void *)&cmd_addbonding_slave_port,
6546 /* *** REMOVE SLAVE *** */
6547 struct cmd_remove_bonding_slave_result {
6548 cmdline_fixed_string_t remove;
6549 cmdline_fixed_string_t bonding;
6550 cmdline_fixed_string_t slave;
6555 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6556 __rte_unused struct cmdline *cl,
6557 __rte_unused void *data)
6559 struct cmd_remove_bonding_slave_result *res = parsed_result;
6560 portid_t master_port_id = res->port_id;
6561 portid_t slave_port_id = res->slave_id;
6563 /* remove the slave from a bonded device. */
6564 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6566 "\t Failed to remove slave %d from master port = %d.\n",
6567 slave_port_id, master_port_id);
6571 clear_port_slave_flag(slave_port_id);
6574 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6575 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6577 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6578 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6579 bonding, "bonding");
6580 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6581 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6583 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6584 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6585 slave_id, RTE_UINT16);
6586 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6587 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6588 port_id, RTE_UINT16);
6590 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6591 .f = cmd_remove_bonding_slave_parsed,
6592 .help_str = "remove bonding slave <slave_id> <port_id>: "
6593 "Remove a slave device from a bonded device",
6596 (void *)&cmd_removebonding_slave_remove,
6597 (void *)&cmd_removebonding_slave_bonding,
6598 (void *)&cmd_removebonding_slave_slave,
6599 (void *)&cmd_removebonding_slave_slaveid,
6600 (void *)&cmd_removebonding_slave_port,
6605 /* *** CREATE BONDED DEVICE *** */
6606 struct cmd_create_bonded_device_result {
6607 cmdline_fixed_string_t create;
6608 cmdline_fixed_string_t bonded;
6609 cmdline_fixed_string_t device;
6614 static int bond_dev_num = 0;
6616 static void cmd_create_bonded_device_parsed(void *parsed_result,
6617 __rte_unused struct cmdline *cl,
6618 __rte_unused void *data)
6620 struct cmd_create_bonded_device_result *res = parsed_result;
6621 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6625 if (test_done == 0) {
6626 fprintf(stderr, "Please stop forwarding first\n");
6630 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6633 /* Create a new bonded device. */
6634 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6636 fprintf(stderr, "\t Failed to create bonded device.\n");
6639 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6642 /* Update number of ports */
6643 nb_ports = rte_eth_dev_count_avail();
6644 reconfig(port_id, res->socket);
6645 ret = rte_eth_promiscuous_enable(port_id);
6648 "Failed to enable promiscuous mode for port %u: %s - ignore\n",
6649 port_id, rte_strerror(-ret));
6651 ports[port_id].need_setup = 0;
6652 ports[port_id].port_status = RTE_PORT_STOPPED;
6657 cmdline_parse_token_string_t cmd_createbonded_device_create =
6658 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6660 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6661 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6663 cmdline_parse_token_string_t cmd_createbonded_device_device =
6664 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6666 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6667 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6669 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6670 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6673 cmdline_parse_inst_t cmd_create_bonded_device = {
6674 .f = cmd_create_bonded_device_parsed,
6675 .help_str = "create bonded device <mode> <socket>: "
6676 "Create a new bonded device with specific bonding mode and socket",
6679 (void *)&cmd_createbonded_device_create,
6680 (void *)&cmd_createbonded_device_bonded,
6681 (void *)&cmd_createbonded_device_device,
6682 (void *)&cmd_createbonded_device_mode,
6683 (void *)&cmd_createbonded_device_socket,
6688 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6689 struct cmd_set_bond_mac_addr_result {
6690 cmdline_fixed_string_t set;
6691 cmdline_fixed_string_t bonding;
6692 cmdline_fixed_string_t mac_addr;
6694 struct rte_ether_addr address;
6697 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6698 __rte_unused struct cmdline *cl,
6699 __rte_unused void *data)
6701 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6704 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6707 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6709 /* check the return value and print it if is < 0 */
6711 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6715 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6716 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6717 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6718 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6720 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6721 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6723 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6724 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6725 port_num, RTE_UINT16);
6726 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6727 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6729 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6730 .f = cmd_set_bond_mac_addr_parsed,
6732 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6734 (void *)&cmd_set_bond_mac_addr_set,
6735 (void *)&cmd_set_bond_mac_addr_bonding,
6736 (void *)&cmd_set_bond_mac_addr_mac,
6737 (void *)&cmd_set_bond_mac_addr_portnum,
6738 (void *)&cmd_set_bond_mac_addr_addr,
6744 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6745 struct cmd_set_bond_mon_period_result {
6746 cmdline_fixed_string_t set;
6747 cmdline_fixed_string_t bonding;
6748 cmdline_fixed_string_t mon_period;
6753 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6754 __rte_unused struct cmdline *cl,
6755 __rte_unused void *data)
6757 struct cmd_set_bond_mon_period_result *res = parsed_result;
6760 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6762 /* check the return value and print it if is < 0 */
6764 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6768 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6769 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6771 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6772 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6773 bonding, "bonding");
6774 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6775 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6776 mon_period, "mon_period");
6777 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6778 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6779 port_num, RTE_UINT16);
6780 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6781 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6782 period_ms, RTE_UINT32);
6784 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6785 .f = cmd_set_bond_mon_period_parsed,
6787 .help_str = "set bonding mon_period <port_id> <period_ms>",
6789 (void *)&cmd_set_bond_mon_period_set,
6790 (void *)&cmd_set_bond_mon_period_bonding,
6791 (void *)&cmd_set_bond_mon_period_mon_period,
6792 (void *)&cmd_set_bond_mon_period_portnum,
6793 (void *)&cmd_set_bond_mon_period_period_ms,
6800 struct cmd_set_bonding_agg_mode_policy_result {
6801 cmdline_fixed_string_t set;
6802 cmdline_fixed_string_t bonding;
6803 cmdline_fixed_string_t agg_mode;
6805 cmdline_fixed_string_t policy;
6810 cmd_set_bonding_agg_mode(void *parsed_result,
6811 __rte_unused struct cmdline *cl,
6812 __rte_unused void *data)
6814 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6815 uint8_t policy = AGG_BANDWIDTH;
6817 if (!strcmp(res->policy, "bandwidth"))
6818 policy = AGG_BANDWIDTH;
6819 else if (!strcmp(res->policy, "stable"))
6820 policy = AGG_STABLE;
6821 else if (!strcmp(res->policy, "count"))
6824 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6828 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6829 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6831 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6832 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6833 bonding, "bonding");
6835 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6836 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6837 agg_mode, "agg_mode");
6839 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6840 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6841 port_num, RTE_UINT16);
6843 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6844 TOKEN_STRING_INITIALIZER(
6845 struct cmd_set_bonding_balance_xmit_policy_result,
6846 policy, "stable#bandwidth#count");
6848 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6849 .f = cmd_set_bonding_agg_mode,
6851 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6853 (void *)&cmd_set_bonding_agg_mode_set,
6854 (void *)&cmd_set_bonding_agg_mode_bonding,
6855 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6856 (void *)&cmd_set_bonding_agg_mode_portnum,
6857 (void *)&cmd_set_bonding_agg_mode_policy_string,
6863 #endif /* RTE_NET_BOND */
6865 /* *** SET FORWARDING MODE *** */
6866 struct cmd_set_fwd_mode_result {
6867 cmdline_fixed_string_t set;
6868 cmdline_fixed_string_t fwd;
6869 cmdline_fixed_string_t mode;
6872 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6873 __rte_unused struct cmdline *cl,
6874 __rte_unused void *data)
6876 struct cmd_set_fwd_mode_result *res = parsed_result;
6879 set_pkt_forwarding_mode(res->mode);
6882 cmdline_parse_token_string_t cmd_setfwd_set =
6883 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6884 cmdline_parse_token_string_t cmd_setfwd_fwd =
6885 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6886 cmdline_parse_token_string_t cmd_setfwd_mode =
6887 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6888 "" /* defined at init */);
6890 cmdline_parse_inst_t cmd_set_fwd_mode = {
6891 .f = cmd_set_fwd_mode_parsed,
6893 .help_str = NULL, /* defined at init */
6895 (void *)&cmd_setfwd_set,
6896 (void *)&cmd_setfwd_fwd,
6897 (void *)&cmd_setfwd_mode,
6902 static void cmd_set_fwd_mode_init(void)
6905 static char token[128];
6906 static char help[256];
6907 cmdline_parse_token_string_t *token_struct;
6909 modes = list_pkt_forwarding_modes();
6910 snprintf(help, sizeof(help), "set fwd %s: "
6911 "Set packet forwarding mode", modes);
6912 cmd_set_fwd_mode.help_str = help;
6914 /* string token separator is # */
6915 for (c = token; *modes != '\0'; modes++)
6920 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6921 token_struct->string_data.str = token;
6924 /* *** SET RETRY FORWARDING MODE *** */
6925 struct cmd_set_fwd_retry_mode_result {
6926 cmdline_fixed_string_t set;
6927 cmdline_fixed_string_t fwd;
6928 cmdline_fixed_string_t mode;
6929 cmdline_fixed_string_t retry;
6932 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6933 __rte_unused struct cmdline *cl,
6934 __rte_unused void *data)
6936 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6939 set_pkt_forwarding_mode(res->mode);
6942 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6943 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6945 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6946 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6948 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6949 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6951 "" /* defined at init */);
6952 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6953 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6956 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6957 .f = cmd_set_fwd_retry_mode_parsed,
6959 .help_str = NULL, /* defined at init */
6961 (void *)&cmd_setfwd_retry_set,
6962 (void *)&cmd_setfwd_retry_fwd,
6963 (void *)&cmd_setfwd_retry_mode,
6964 (void *)&cmd_setfwd_retry_retry,
6969 static void cmd_set_fwd_retry_mode_init(void)
6972 static char token[128];
6973 static char help[256];
6974 cmdline_parse_token_string_t *token_struct;
6976 modes = list_pkt_forwarding_retry_modes();
6977 snprintf(help, sizeof(help), "set fwd %s retry: "
6978 "Set packet forwarding mode with retry", modes);
6979 cmd_set_fwd_retry_mode.help_str = help;
6981 /* string token separator is # */
6982 for (c = token; *modes != '\0'; modes++)
6987 token_struct = (cmdline_parse_token_string_t *)
6988 cmd_set_fwd_retry_mode.tokens[2];
6989 token_struct->string_data.str = token;
6992 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6993 struct cmd_set_burst_tx_retry_result {
6994 cmdline_fixed_string_t set;
6995 cmdline_fixed_string_t burst;
6996 cmdline_fixed_string_t tx;
6997 cmdline_fixed_string_t delay;
6999 cmdline_fixed_string_t retry;
7003 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
7004 __rte_unused struct cmdline *cl,
7005 __rte_unused void *data)
7007 struct cmd_set_burst_tx_retry_result *res = parsed_result;
7009 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
7010 && !strcmp(res->tx, "tx")) {
7011 if (!strcmp(res->delay, "delay"))
7012 burst_tx_delay_time = res->time;
7013 if (!strcmp(res->retry, "retry"))
7014 burst_tx_retry_num = res->retry_num;
7019 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
7020 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
7021 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
7022 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
7024 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
7025 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
7026 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
7027 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
7028 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
7029 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
7031 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
7032 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
7033 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
7034 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
7037 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
7038 .f = cmd_set_burst_tx_retry_parsed,
7039 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
7041 (void *)&cmd_set_burst_tx_retry_set,
7042 (void *)&cmd_set_burst_tx_retry_burst,
7043 (void *)&cmd_set_burst_tx_retry_tx,
7044 (void *)&cmd_set_burst_tx_retry_delay,
7045 (void *)&cmd_set_burst_tx_retry_time,
7046 (void *)&cmd_set_burst_tx_retry_retry,
7047 (void *)&cmd_set_burst_tx_retry_retry_num,
7052 /* *** SET PROMISC MODE *** */
7053 struct cmd_set_promisc_mode_result {
7054 cmdline_fixed_string_t set;
7055 cmdline_fixed_string_t promisc;
7056 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
7057 uint16_t port_num; /* valid if "allports" argument == 0 */
7058 cmdline_fixed_string_t mode;
7061 static void cmd_set_promisc_mode_parsed(void *parsed_result,
7062 __rte_unused struct cmdline *cl,
7065 struct cmd_set_promisc_mode_result *res = parsed_result;
7069 if (!strcmp(res->mode, "on"))
7076 RTE_ETH_FOREACH_DEV(i)
7077 eth_set_promisc_mode(i, enable);
7079 eth_set_promisc_mode(res->port_num, enable);
7083 cmdline_parse_token_string_t cmd_setpromisc_set =
7084 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
7085 cmdline_parse_token_string_t cmd_setpromisc_promisc =
7086 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
7088 cmdline_parse_token_string_t cmd_setpromisc_portall =
7089 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
7091 cmdline_parse_token_num_t cmd_setpromisc_portnum =
7092 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
7094 cmdline_parse_token_string_t cmd_setpromisc_mode =
7095 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
7098 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
7099 .f = cmd_set_promisc_mode_parsed,
7101 .help_str = "set promisc all on|off: Set promisc mode for all ports",
7103 (void *)&cmd_setpromisc_set,
7104 (void *)&cmd_setpromisc_promisc,
7105 (void *)&cmd_setpromisc_portall,
7106 (void *)&cmd_setpromisc_mode,
7111 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
7112 .f = cmd_set_promisc_mode_parsed,
7114 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
7116 (void *)&cmd_setpromisc_set,
7117 (void *)&cmd_setpromisc_promisc,
7118 (void *)&cmd_setpromisc_portnum,
7119 (void *)&cmd_setpromisc_mode,
7124 /* *** SET ALLMULTI MODE *** */
7125 struct cmd_set_allmulti_mode_result {
7126 cmdline_fixed_string_t set;
7127 cmdline_fixed_string_t allmulti;
7128 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
7129 uint16_t port_num; /* valid if "allports" argument == 0 */
7130 cmdline_fixed_string_t mode;
7133 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
7134 __rte_unused struct cmdline *cl,
7137 struct cmd_set_allmulti_mode_result *res = parsed_result;
7141 if (!strcmp(res->mode, "on"))
7148 RTE_ETH_FOREACH_DEV(i) {
7149 eth_set_allmulticast_mode(i, enable);
7153 eth_set_allmulticast_mode(res->port_num, enable);
7157 cmdline_parse_token_string_t cmd_setallmulti_set =
7158 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
7159 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
7160 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
7162 cmdline_parse_token_string_t cmd_setallmulti_portall =
7163 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
7165 cmdline_parse_token_num_t cmd_setallmulti_portnum =
7166 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
7168 cmdline_parse_token_string_t cmd_setallmulti_mode =
7169 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
7172 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
7173 .f = cmd_set_allmulti_mode_parsed,
7175 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
7177 (void *)&cmd_setallmulti_set,
7178 (void *)&cmd_setallmulti_allmulti,
7179 (void *)&cmd_setallmulti_portall,
7180 (void *)&cmd_setallmulti_mode,
7185 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
7186 .f = cmd_set_allmulti_mode_parsed,
7188 .help_str = "set allmulti <port_id> on|off: "
7189 "Set allmulti mode on port_id",
7191 (void *)&cmd_setallmulti_set,
7192 (void *)&cmd_setallmulti_allmulti,
7193 (void *)&cmd_setallmulti_portnum,
7194 (void *)&cmd_setallmulti_mode,
7199 /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
7200 struct cmd_link_flow_ctrl_show {
7201 cmdline_fixed_string_t show;
7202 cmdline_fixed_string_t port;
7204 cmdline_fixed_string_t flow_ctrl;
7207 cmdline_parse_token_string_t cmd_lfc_show_show =
7208 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7210 cmdline_parse_token_string_t cmd_lfc_show_port =
7211 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7213 cmdline_parse_token_num_t cmd_lfc_show_portid =
7214 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
7215 port_id, RTE_UINT16);
7216 cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
7217 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7218 flow_ctrl, "flow_ctrl");
7221 cmd_link_flow_ctrl_show_parsed(void *parsed_result,
7222 __rte_unused struct cmdline *cl,
7223 __rte_unused void *data)
7225 struct cmd_link_flow_ctrl_show *res = parsed_result;
7226 static const char *info_border = "*********************";
7227 struct rte_eth_fc_conf fc_conf;
7228 bool rx_fc_en = false;
7229 bool tx_fc_en = false;
7232 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7235 "Failed to get current flow ctrl information: err = %d\n",
7240 if (fc_conf.mode == RTE_ETH_FC_RX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
7242 if (fc_conf.mode == RTE_ETH_FC_TX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
7245 printf("\n%s Flow control infos for port %-2d %s\n",
7246 info_border, res->port_id, info_border);
7247 printf("FC mode:\n");
7248 printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
7249 printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
7250 printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
7251 printf("Pause time: 0x%x\n", fc_conf.pause_time);
7252 printf("High waterline: 0x%x\n", fc_conf.high_water);
7253 printf("Low waterline: 0x%x\n", fc_conf.low_water);
7254 printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
7255 printf("Forward MAC control frames: %s\n",
7256 fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
7257 printf("\n%s************** End ***********%s\n",
7258 info_border, info_border);
7261 cmdline_parse_inst_t cmd_link_flow_control_show = {
7262 .f = cmd_link_flow_ctrl_show_parsed,
7264 .help_str = "show port <port_id> flow_ctrl",
7266 (void *)&cmd_lfc_show_show,
7267 (void *)&cmd_lfc_show_port,
7268 (void *)&cmd_lfc_show_portid,
7269 (void *)&cmd_lfc_show_flow_ctrl,
7274 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
7275 struct cmd_link_flow_ctrl_set_result {
7276 cmdline_fixed_string_t set;
7277 cmdline_fixed_string_t flow_ctrl;
7278 cmdline_fixed_string_t rx;
7279 cmdline_fixed_string_t rx_lfc_mode;
7280 cmdline_fixed_string_t tx;
7281 cmdline_fixed_string_t tx_lfc_mode;
7282 cmdline_fixed_string_t mac_ctrl_frame_fwd;
7283 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
7284 cmdline_fixed_string_t autoneg_str;
7285 cmdline_fixed_string_t autoneg;
7286 cmdline_fixed_string_t hw_str;
7287 uint32_t high_water;
7288 cmdline_fixed_string_t lw_str;
7290 cmdline_fixed_string_t pt_str;
7291 uint16_t pause_time;
7292 cmdline_fixed_string_t xon_str;
7297 cmdline_parse_token_string_t cmd_lfc_set_set =
7298 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7300 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
7301 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7302 flow_ctrl, "flow_ctrl");
7303 cmdline_parse_token_string_t cmd_lfc_set_rx =
7304 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7306 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
7307 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7308 rx_lfc_mode, "on#off");
7309 cmdline_parse_token_string_t cmd_lfc_set_tx =
7310 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7312 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7313 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7314 tx_lfc_mode, "on#off");
7315 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7316 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7317 hw_str, "high_water");
7318 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7319 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7320 high_water, RTE_UINT32);
7321 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7322 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7323 lw_str, "low_water");
7324 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7325 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7326 low_water, RTE_UINT32);
7327 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7328 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7329 pt_str, "pause_time");
7330 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7331 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7332 pause_time, RTE_UINT16);
7333 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7334 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7335 xon_str, "send_xon");
7336 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7337 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7338 send_xon, RTE_UINT16);
7339 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7340 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7341 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7342 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7343 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7344 mac_ctrl_frame_fwd_mode, "on#off");
7345 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7346 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7347 autoneg_str, "autoneg");
7348 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7349 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7351 cmdline_parse_token_num_t cmd_lfc_set_portid =
7352 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7353 port_id, RTE_UINT16);
7355 /* forward declaration */
7357 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7360 cmdline_parse_inst_t cmd_link_flow_control_set = {
7361 .f = cmd_link_flow_ctrl_set_parsed,
7363 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7364 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7365 "autoneg on|off <port_id>: Configure the Ethernet flow control",
7367 (void *)&cmd_lfc_set_set,
7368 (void *)&cmd_lfc_set_flow_ctrl,
7369 (void *)&cmd_lfc_set_rx,
7370 (void *)&cmd_lfc_set_rx_mode,
7371 (void *)&cmd_lfc_set_tx,
7372 (void *)&cmd_lfc_set_tx_mode,
7373 (void *)&cmd_lfc_set_high_water,
7374 (void *)&cmd_lfc_set_low_water,
7375 (void *)&cmd_lfc_set_pause_time,
7376 (void *)&cmd_lfc_set_send_xon,
7377 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7378 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7379 (void *)&cmd_lfc_set_autoneg_str,
7380 (void *)&cmd_lfc_set_autoneg,
7381 (void *)&cmd_lfc_set_portid,
7386 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7387 .f = cmd_link_flow_ctrl_set_parsed,
7388 .data = (void *)&cmd_link_flow_control_set_rx,
7389 .help_str = "set flow_ctrl rx on|off <port_id>: "
7390 "Change rx flow control parameter",
7392 (void *)&cmd_lfc_set_set,
7393 (void *)&cmd_lfc_set_flow_ctrl,
7394 (void *)&cmd_lfc_set_rx,
7395 (void *)&cmd_lfc_set_rx_mode,
7396 (void *)&cmd_lfc_set_portid,
7401 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7402 .f = cmd_link_flow_ctrl_set_parsed,
7403 .data = (void *)&cmd_link_flow_control_set_tx,
7404 .help_str = "set flow_ctrl tx on|off <port_id>: "
7405 "Change tx flow control parameter",
7407 (void *)&cmd_lfc_set_set,
7408 (void *)&cmd_lfc_set_flow_ctrl,
7409 (void *)&cmd_lfc_set_tx,
7410 (void *)&cmd_lfc_set_tx_mode,
7411 (void *)&cmd_lfc_set_portid,
7416 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7417 .f = cmd_link_flow_ctrl_set_parsed,
7418 .data = (void *)&cmd_link_flow_control_set_hw,
7419 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7420 "Change high water flow control parameter",
7422 (void *)&cmd_lfc_set_set,
7423 (void *)&cmd_lfc_set_flow_ctrl,
7424 (void *)&cmd_lfc_set_high_water_str,
7425 (void *)&cmd_lfc_set_high_water,
7426 (void *)&cmd_lfc_set_portid,
7431 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7432 .f = cmd_link_flow_ctrl_set_parsed,
7433 .data = (void *)&cmd_link_flow_control_set_lw,
7434 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7435 "Change low water flow control parameter",
7437 (void *)&cmd_lfc_set_set,
7438 (void *)&cmd_lfc_set_flow_ctrl,
7439 (void *)&cmd_lfc_set_low_water_str,
7440 (void *)&cmd_lfc_set_low_water,
7441 (void *)&cmd_lfc_set_portid,
7446 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7447 .f = cmd_link_flow_ctrl_set_parsed,
7448 .data = (void *)&cmd_link_flow_control_set_pt,
7449 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7450 "Change pause time flow control parameter",
7452 (void *)&cmd_lfc_set_set,
7453 (void *)&cmd_lfc_set_flow_ctrl,
7454 (void *)&cmd_lfc_set_pause_time_str,
7455 (void *)&cmd_lfc_set_pause_time,
7456 (void *)&cmd_lfc_set_portid,
7461 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7462 .f = cmd_link_flow_ctrl_set_parsed,
7463 .data = (void *)&cmd_link_flow_control_set_xon,
7464 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7465 "Change send_xon flow control parameter",
7467 (void *)&cmd_lfc_set_set,
7468 (void *)&cmd_lfc_set_flow_ctrl,
7469 (void *)&cmd_lfc_set_send_xon_str,
7470 (void *)&cmd_lfc_set_send_xon,
7471 (void *)&cmd_lfc_set_portid,
7476 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7477 .f = cmd_link_flow_ctrl_set_parsed,
7478 .data = (void *)&cmd_link_flow_control_set_macfwd,
7479 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7480 "Change mac ctrl fwd flow control parameter",
7482 (void *)&cmd_lfc_set_set,
7483 (void *)&cmd_lfc_set_flow_ctrl,
7484 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7485 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7486 (void *)&cmd_lfc_set_portid,
7491 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7492 .f = cmd_link_flow_ctrl_set_parsed,
7493 .data = (void *)&cmd_link_flow_control_set_autoneg,
7494 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7495 "Change autoneg flow control parameter",
7497 (void *)&cmd_lfc_set_set,
7498 (void *)&cmd_lfc_set_flow_ctrl,
7499 (void *)&cmd_lfc_set_autoneg_str,
7500 (void *)&cmd_lfc_set_autoneg,
7501 (void *)&cmd_lfc_set_portid,
7507 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7508 __rte_unused struct cmdline *cl,
7511 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7512 cmdline_parse_inst_t *cmd = data;
7513 struct rte_eth_fc_conf fc_conf;
7519 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7520 * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7521 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7522 * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7524 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7525 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7528 /* Partial command line, retrieve current configuration */
7530 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7533 "cannot get current flow ctrl parameters, return code = %d\n",
7538 if ((fc_conf.mode == RTE_ETH_FC_RX_PAUSE) ||
7539 (fc_conf.mode == RTE_ETH_FC_FULL))
7541 if ((fc_conf.mode == RTE_ETH_FC_TX_PAUSE) ||
7542 (fc_conf.mode == RTE_ETH_FC_FULL))
7546 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7547 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7549 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7550 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7552 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7554 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7555 fc_conf.high_water = res->high_water;
7557 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7558 fc_conf.low_water = res->low_water;
7560 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7561 fc_conf.pause_time = res->pause_time;
7563 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7564 fc_conf.send_xon = res->send_xon;
7566 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7567 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7568 fc_conf.mac_ctrl_frame_fwd = 1;
7570 fc_conf.mac_ctrl_frame_fwd = 0;
7573 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7574 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7576 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7579 "bad flow control parameter, return code = %d\n",
7583 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7584 struct cmd_priority_flow_ctrl_set_result {
7585 cmdline_fixed_string_t set;
7586 cmdline_fixed_string_t pfc_ctrl;
7587 cmdline_fixed_string_t rx;
7588 cmdline_fixed_string_t rx_pfc_mode;
7589 cmdline_fixed_string_t tx;
7590 cmdline_fixed_string_t tx_pfc_mode;
7591 uint32_t high_water;
7593 uint16_t pause_time;
7599 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7600 __rte_unused struct cmdline *cl,
7601 __rte_unused void *data)
7603 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7604 struct rte_eth_pfc_conf pfc_conf;
7605 int rx_fc_enable, tx_fc_enable;
7609 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7610 * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7611 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7612 * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7614 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7615 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7618 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7619 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7620 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7621 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7622 pfc_conf.fc.high_water = res->high_water;
7623 pfc_conf.fc.low_water = res->low_water;
7624 pfc_conf.fc.pause_time = res->pause_time;
7625 pfc_conf.priority = res->priority;
7627 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7630 "bad priority flow control parameter, return code = %d\n",
7634 cmdline_parse_token_string_t cmd_pfc_set_set =
7635 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7637 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7638 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7639 pfc_ctrl, "pfc_ctrl");
7640 cmdline_parse_token_string_t cmd_pfc_set_rx =
7641 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7643 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7644 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7645 rx_pfc_mode, "on#off");
7646 cmdline_parse_token_string_t cmd_pfc_set_tx =
7647 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7649 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7650 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7651 tx_pfc_mode, "on#off");
7652 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7653 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7654 high_water, RTE_UINT32);
7655 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7656 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7657 low_water, RTE_UINT32);
7658 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7659 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7660 pause_time, RTE_UINT16);
7661 cmdline_parse_token_num_t cmd_pfc_set_priority =
7662 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7663 priority, RTE_UINT8);
7664 cmdline_parse_token_num_t cmd_pfc_set_portid =
7665 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7666 port_id, RTE_UINT16);
7668 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7669 .f = cmd_priority_flow_ctrl_set_parsed,
7671 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7672 "<pause_time> <priority> <port_id>: "
7673 "Configure the Ethernet priority flow control",
7675 (void *)&cmd_pfc_set_set,
7676 (void *)&cmd_pfc_set_flow_ctrl,
7677 (void *)&cmd_pfc_set_rx,
7678 (void *)&cmd_pfc_set_rx_mode,
7679 (void *)&cmd_pfc_set_tx,
7680 (void *)&cmd_pfc_set_tx_mode,
7681 (void *)&cmd_pfc_set_high_water,
7682 (void *)&cmd_pfc_set_low_water,
7683 (void *)&cmd_pfc_set_pause_time,
7684 (void *)&cmd_pfc_set_priority,
7685 (void *)&cmd_pfc_set_portid,
7690 /* *** RESET CONFIGURATION *** */
7691 struct cmd_reset_result {
7692 cmdline_fixed_string_t reset;
7693 cmdline_fixed_string_t def;
7696 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7698 __rte_unused void *data)
7700 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7701 set_def_fwd_config();
7704 cmdline_parse_token_string_t cmd_reset_set =
7705 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7706 cmdline_parse_token_string_t cmd_reset_def =
7707 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7710 cmdline_parse_inst_t cmd_reset = {
7711 .f = cmd_reset_parsed,
7713 .help_str = "set default: Reset default forwarding configuration",
7715 (void *)&cmd_reset_set,
7716 (void *)&cmd_reset_def,
7721 /* *** START FORWARDING *** */
7722 struct cmd_start_result {
7723 cmdline_fixed_string_t start;
7726 cmdline_parse_token_string_t cmd_start_start =
7727 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7729 static void cmd_start_parsed(__rte_unused void *parsed_result,
7730 __rte_unused struct cmdline *cl,
7731 __rte_unused void *data)
7733 start_packet_forwarding(0);
7736 cmdline_parse_inst_t cmd_start = {
7737 .f = cmd_start_parsed,
7739 .help_str = "start: Start packet forwarding",
7741 (void *)&cmd_start_start,
7746 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7747 struct cmd_start_tx_first_result {
7748 cmdline_fixed_string_t start;
7749 cmdline_fixed_string_t tx_first;
7753 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7754 __rte_unused struct cmdline *cl,
7755 __rte_unused void *data)
7757 start_packet_forwarding(1);
7760 cmdline_parse_token_string_t cmd_start_tx_first_start =
7761 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7763 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7764 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7765 tx_first, "tx_first");
7767 cmdline_parse_inst_t cmd_start_tx_first = {
7768 .f = cmd_start_tx_first_parsed,
7770 .help_str = "start tx_first: Start packet forwarding, "
7771 "after sending 1 burst of packets",
7773 (void *)&cmd_start_tx_first_start,
7774 (void *)&cmd_start_tx_first_tx_first,
7779 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7780 struct cmd_start_tx_first_n_result {
7781 cmdline_fixed_string_t start;
7782 cmdline_fixed_string_t tx_first;
7787 cmd_start_tx_first_n_parsed(void *parsed_result,
7788 __rte_unused struct cmdline *cl,
7789 __rte_unused void *data)
7791 struct cmd_start_tx_first_n_result *res = parsed_result;
7793 start_packet_forwarding(res->tx_num);
7796 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7797 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7799 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7800 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7801 tx_first, "tx_first");
7802 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7803 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7804 tx_num, RTE_UINT32);
7806 cmdline_parse_inst_t cmd_start_tx_first_n = {
7807 .f = cmd_start_tx_first_n_parsed,
7809 .help_str = "start tx_first <num>: "
7810 "packet forwarding, after sending <num> bursts of packets",
7812 (void *)&cmd_start_tx_first_n_start,
7813 (void *)&cmd_start_tx_first_n_tx_first,
7814 (void *)&cmd_start_tx_first_n_tx_num,
7819 /* *** SET LINK UP *** */
7820 struct cmd_set_link_up_result {
7821 cmdline_fixed_string_t set;
7822 cmdline_fixed_string_t link_up;
7823 cmdline_fixed_string_t port;
7827 cmdline_parse_token_string_t cmd_set_link_up_set =
7828 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7829 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7830 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7832 cmdline_parse_token_string_t cmd_set_link_up_port =
7833 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7834 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7835 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7838 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7839 __rte_unused struct cmdline *cl,
7840 __rte_unused void *data)
7842 struct cmd_set_link_up_result *res = parsed_result;
7843 dev_set_link_up(res->port_id);
7846 cmdline_parse_inst_t cmd_set_link_up = {
7847 .f = cmd_set_link_up_parsed,
7849 .help_str = "set link-up port <port id>",
7851 (void *)&cmd_set_link_up_set,
7852 (void *)&cmd_set_link_up_link_up,
7853 (void *)&cmd_set_link_up_port,
7854 (void *)&cmd_set_link_up_port_id,
7859 /* *** SET LINK DOWN *** */
7860 struct cmd_set_link_down_result {
7861 cmdline_fixed_string_t set;
7862 cmdline_fixed_string_t link_down;
7863 cmdline_fixed_string_t port;
7867 cmdline_parse_token_string_t cmd_set_link_down_set =
7868 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7869 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7870 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7872 cmdline_parse_token_string_t cmd_set_link_down_port =
7873 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7874 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7875 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7878 static void cmd_set_link_down_parsed(
7879 __rte_unused void *parsed_result,
7880 __rte_unused struct cmdline *cl,
7881 __rte_unused void *data)
7883 struct cmd_set_link_down_result *res = parsed_result;
7884 dev_set_link_down(res->port_id);
7887 cmdline_parse_inst_t cmd_set_link_down = {
7888 .f = cmd_set_link_down_parsed,
7890 .help_str = "set link-down port <port id>",
7892 (void *)&cmd_set_link_down_set,
7893 (void *)&cmd_set_link_down_link_down,
7894 (void *)&cmd_set_link_down_port,
7895 (void *)&cmd_set_link_down_port_id,
7900 /* *** SHOW CFG *** */
7901 struct cmd_showcfg_result {
7902 cmdline_fixed_string_t show;
7903 cmdline_fixed_string_t cfg;
7904 cmdline_fixed_string_t what;
7907 static void cmd_showcfg_parsed(void *parsed_result,
7908 __rte_unused struct cmdline *cl,
7909 __rte_unused void *data)
7911 struct cmd_showcfg_result *res = parsed_result;
7912 if (!strcmp(res->what, "rxtx"))
7913 rxtx_config_display();
7914 else if (!strcmp(res->what, "cores"))
7915 fwd_lcores_config_display();
7916 else if (!strcmp(res->what, "fwd"))
7917 pkt_fwd_config_display(&cur_fwd_config);
7918 else if (!strcmp(res->what, "rxoffs"))
7919 show_rx_pkt_offsets();
7920 else if (!strcmp(res->what, "rxpkts"))
7921 show_rx_pkt_segments();
7922 else if (!strcmp(res->what, "txpkts"))
7923 show_tx_pkt_segments();
7924 else if (!strcmp(res->what, "txtimes"))
7925 show_tx_pkt_times();
7928 cmdline_parse_token_string_t cmd_showcfg_show =
7929 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7930 cmdline_parse_token_string_t cmd_showcfg_port =
7931 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7932 cmdline_parse_token_string_t cmd_showcfg_what =
7933 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7934 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7936 cmdline_parse_inst_t cmd_showcfg = {
7937 .f = cmd_showcfg_parsed,
7939 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7941 (void *)&cmd_showcfg_show,
7942 (void *)&cmd_showcfg_port,
7943 (void *)&cmd_showcfg_what,
7948 /* *** SHOW ALL PORT INFO *** */
7949 struct cmd_showportall_result {
7950 cmdline_fixed_string_t show;
7951 cmdline_fixed_string_t port;
7952 cmdline_fixed_string_t what;
7953 cmdline_fixed_string_t all;
7956 static void cmd_showportall_parsed(void *parsed_result,
7957 __rte_unused struct cmdline *cl,
7958 __rte_unused void *data)
7962 struct cmd_showportall_result *res = parsed_result;
7963 if (!strcmp(res->show, "clear")) {
7964 if (!strcmp(res->what, "stats"))
7965 RTE_ETH_FOREACH_DEV(i)
7967 else if (!strcmp(res->what, "xstats"))
7968 RTE_ETH_FOREACH_DEV(i)
7969 nic_xstats_clear(i);
7970 } else if (!strcmp(res->what, "info"))
7971 RTE_ETH_FOREACH_DEV(i)
7972 port_infos_display(i);
7973 else if (!strcmp(res->what, "summary")) {
7974 port_summary_header_display();
7975 RTE_ETH_FOREACH_DEV(i)
7976 port_summary_display(i);
7978 else if (!strcmp(res->what, "stats"))
7979 RTE_ETH_FOREACH_DEV(i)
7980 nic_stats_display(i);
7981 else if (!strcmp(res->what, "xstats"))
7982 RTE_ETH_FOREACH_DEV(i)
7983 nic_xstats_display(i);
7984 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7985 else if (!strcmp(res->what, "fdir"))
7986 RTE_ETH_FOREACH_DEV(i)
7989 else if (!strcmp(res->what, "dcb_tc"))
7990 RTE_ETH_FOREACH_DEV(i)
7991 port_dcb_info_display(i);
7994 cmdline_parse_token_string_t cmd_showportall_show =
7995 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7997 cmdline_parse_token_string_t cmd_showportall_port =
7998 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7999 cmdline_parse_token_string_t cmd_showportall_what =
8000 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
8001 "info#summary#stats#xstats#fdir#dcb_tc");
8002 cmdline_parse_token_string_t cmd_showportall_all =
8003 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
8004 cmdline_parse_inst_t cmd_showportall = {
8005 .f = cmd_showportall_parsed,
8007 .help_str = "show|clear port "
8008 "info|summary|stats|xstats|fdir|dcb_tc all",
8010 (void *)&cmd_showportall_show,
8011 (void *)&cmd_showportall_port,
8012 (void *)&cmd_showportall_what,
8013 (void *)&cmd_showportall_all,
8018 /* *** SHOW PORT INFO *** */
8019 struct cmd_showport_result {
8020 cmdline_fixed_string_t show;
8021 cmdline_fixed_string_t port;
8022 cmdline_fixed_string_t what;
8026 static void cmd_showport_parsed(void *parsed_result,
8027 __rte_unused struct cmdline *cl,
8028 __rte_unused void *data)
8030 struct cmd_showport_result *res = parsed_result;
8031 if (!strcmp(res->show, "clear")) {
8032 if (!strcmp(res->what, "stats"))
8033 nic_stats_clear(res->portnum);
8034 else if (!strcmp(res->what, "xstats"))
8035 nic_xstats_clear(res->portnum);
8036 } else if (!strcmp(res->what, "info"))
8037 port_infos_display(res->portnum);
8038 else if (!strcmp(res->what, "summary")) {
8039 port_summary_header_display();
8040 port_summary_display(res->portnum);
8042 else if (!strcmp(res->what, "stats"))
8043 nic_stats_display(res->portnum);
8044 else if (!strcmp(res->what, "xstats"))
8045 nic_xstats_display(res->portnum);
8046 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
8047 else if (!strcmp(res->what, "fdir"))
8048 fdir_get_infos(res->portnum);
8050 else if (!strcmp(res->what, "dcb_tc"))
8051 port_dcb_info_display(res->portnum);
8054 cmdline_parse_token_string_t cmd_showport_show =
8055 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
8057 cmdline_parse_token_string_t cmd_showport_port =
8058 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
8059 cmdline_parse_token_string_t cmd_showport_what =
8060 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
8061 "info#summary#stats#xstats#fdir#dcb_tc");
8062 cmdline_parse_token_num_t cmd_showport_portnum =
8063 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
8065 cmdline_parse_inst_t cmd_showport = {
8066 .f = cmd_showport_parsed,
8068 .help_str = "show|clear port "
8069 "info|summary|stats|xstats|fdir|dcb_tc "
8072 (void *)&cmd_showport_show,
8073 (void *)&cmd_showport_port,
8074 (void *)&cmd_showport_what,
8075 (void *)&cmd_showport_portnum,
8080 /* *** show port representors information *** */
8081 struct cmd_representor_info_result {
8082 cmdline_fixed_string_t cmd_show;
8083 cmdline_fixed_string_t cmd_port;
8084 cmdline_fixed_string_t cmd_info;
8085 cmdline_fixed_string_t cmd_keyword;
8090 cmd_representor_info_parsed(void *parsed_result,
8091 __rte_unused struct cmdline *cl,
8092 __rte_unused void *data)
8094 struct cmd_representor_info_result *res = parsed_result;
8095 struct rte_eth_representor_info *info;
8096 struct rte_eth_representor_range *range;
8097 uint32_t range_diff;
8102 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
8103 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
8107 ret = rte_eth_representor_info_get(res->cmd_pid, NULL);
8110 "Failed to get the number of representor info ranges for port %hu: %s\n",
8111 res->cmd_pid, rte_strerror(-ret));
8116 info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0]));
8119 "Failed to allocate memory for representor info for port %hu\n",
8123 info->nb_ranges_alloc = num;
8125 ret = rte_eth_representor_info_get(res->cmd_pid, info);
8128 "Failed to get the representor info for port %hu: %s\n",
8129 res->cmd_pid, rte_strerror(-ret));
8134 printf("Port controller: %hu\n", info->controller);
8135 printf("Port PF: %hu\n", info->pf);
8137 printf("Ranges: %u\n", info->nb_ranges);
8138 for (i = 0; i < info->nb_ranges; i++) {
8139 range = &info->ranges[i];
8140 range_diff = range->id_end - range->id_base;
8142 printf("%u. ", i + 1);
8143 printf("'%s' ", range->name);
8145 printf("[%u-%u]: ", range->id_base, range->id_end);
8147 printf("[%u]: ", range->id_base);
8149 printf("Controller %d, PF %d", range->controller, range->pf);
8151 switch (range->type) {
8152 case RTE_ETH_REPRESENTOR_NONE:
8155 case RTE_ETH_REPRESENTOR_VF:
8157 printf(", VF %d..%d\n", range->vf,
8158 range->vf + range_diff);
8160 printf(", VF %d\n", range->vf);
8162 case RTE_ETH_REPRESENTOR_SF:
8163 printf(", SF %d\n", range->sf);
8165 case RTE_ETH_REPRESENTOR_PF:
8167 printf("..%d\n", range->pf + range_diff);
8172 printf(", UNKNOWN TYPE %d\n", range->type);
8180 cmdline_parse_token_string_t cmd_representor_info_show =
8181 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8183 cmdline_parse_token_string_t cmd_representor_info_port =
8184 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8186 cmdline_parse_token_string_t cmd_representor_info_info =
8187 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8189 cmdline_parse_token_num_t cmd_representor_info_pid =
8190 TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result,
8191 cmd_pid, RTE_UINT16);
8192 cmdline_parse_token_string_t cmd_representor_info_keyword =
8193 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8194 cmd_keyword, "representor");
8196 cmdline_parse_inst_t cmd_representor_info = {
8197 .f = cmd_representor_info_parsed,
8199 .help_str = "show port info <port_id> representor",
8201 (void *)&cmd_representor_info_show,
8202 (void *)&cmd_representor_info_port,
8203 (void *)&cmd_representor_info_info,
8204 (void *)&cmd_representor_info_pid,
8205 (void *)&cmd_representor_info_keyword,
8211 /* *** SHOW DEVICE INFO *** */
8212 struct cmd_showdevice_result {
8213 cmdline_fixed_string_t show;
8214 cmdline_fixed_string_t device;
8215 cmdline_fixed_string_t what;
8216 cmdline_fixed_string_t identifier;
8219 static void cmd_showdevice_parsed(void *parsed_result,
8220 __rte_unused struct cmdline *cl,
8221 __rte_unused void *data)
8223 struct cmd_showdevice_result *res = parsed_result;
8224 if (!strcmp(res->what, "info")) {
8225 if (!strcmp(res->identifier, "all"))
8226 device_infos_display(NULL);
8228 device_infos_display(res->identifier);
8232 cmdline_parse_token_string_t cmd_showdevice_show =
8233 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
8235 cmdline_parse_token_string_t cmd_showdevice_device =
8236 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
8237 cmdline_parse_token_string_t cmd_showdevice_what =
8238 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
8240 cmdline_parse_token_string_t cmd_showdevice_identifier =
8241 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
8244 cmdline_parse_inst_t cmd_showdevice = {
8245 .f = cmd_showdevice_parsed,
8247 .help_str = "show device info <identifier>|all",
8249 (void *)&cmd_showdevice_show,
8250 (void *)&cmd_showdevice_device,
8251 (void *)&cmd_showdevice_what,
8252 (void *)&cmd_showdevice_identifier,
8257 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
8258 struct cmd_showeeprom_result {
8259 cmdline_fixed_string_t show;
8260 cmdline_fixed_string_t port;
8262 cmdline_fixed_string_t type;
8265 static void cmd_showeeprom_parsed(void *parsed_result,
8266 __rte_unused struct cmdline *cl,
8267 __rte_unused void *data)
8269 struct cmd_showeeprom_result *res = parsed_result;
8271 if (!strcmp(res->type, "eeprom"))
8272 port_eeprom_display(res->portnum);
8273 else if (!strcmp(res->type, "module_eeprom"))
8274 port_module_eeprom_display(res->portnum);
8276 fprintf(stderr, "Unknown argument\n");
8279 cmdline_parse_token_string_t cmd_showeeprom_show =
8280 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
8281 cmdline_parse_token_string_t cmd_showeeprom_port =
8282 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
8283 cmdline_parse_token_num_t cmd_showeeprom_portnum =
8284 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
8286 cmdline_parse_token_string_t cmd_showeeprom_type =
8287 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
8289 cmdline_parse_inst_t cmd_showeeprom = {
8290 .f = cmd_showeeprom_parsed,
8292 .help_str = "show port <port_id> module_eeprom|eeprom",
8294 (void *)&cmd_showeeprom_show,
8295 (void *)&cmd_showeeprom_port,
8296 (void *)&cmd_showeeprom_portnum,
8297 (void *)&cmd_showeeprom_type,
8302 /* *** SHOW QUEUE INFO *** */
8303 struct cmd_showqueue_result {
8304 cmdline_fixed_string_t show;
8305 cmdline_fixed_string_t type;
8306 cmdline_fixed_string_t what;
8312 cmd_showqueue_parsed(void *parsed_result,
8313 __rte_unused struct cmdline *cl,
8314 __rte_unused void *data)
8316 struct cmd_showqueue_result *res = parsed_result;
8318 if (!strcmp(res->type, "rxq"))
8319 rx_queue_infos_display(res->portnum, res->queuenum);
8320 else if (!strcmp(res->type, "txq"))
8321 tx_queue_infos_display(res->portnum, res->queuenum);
8324 cmdline_parse_token_string_t cmd_showqueue_show =
8325 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
8326 cmdline_parse_token_string_t cmd_showqueue_type =
8327 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
8328 cmdline_parse_token_string_t cmd_showqueue_what =
8329 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
8330 cmdline_parse_token_num_t cmd_showqueue_portnum =
8331 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
8333 cmdline_parse_token_num_t cmd_showqueue_queuenum =
8334 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
8337 cmdline_parse_inst_t cmd_showqueue = {
8338 .f = cmd_showqueue_parsed,
8340 .help_str = "show rxq|txq info <port_id> <queue_id>",
8342 (void *)&cmd_showqueue_show,
8343 (void *)&cmd_showqueue_type,
8344 (void *)&cmd_showqueue_what,
8345 (void *)&cmd_showqueue_portnum,
8346 (void *)&cmd_showqueue_queuenum,
8351 /* show/clear fwd engine statistics */
8353 cmdline_fixed_string_t action;
8354 cmdline_fixed_string_t fwd;
8355 cmdline_fixed_string_t stats;
8356 cmdline_fixed_string_t all;
8359 cmdline_parse_token_string_t cmd_fwd_action =
8360 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
8361 cmdline_parse_token_string_t cmd_fwd_fwd =
8362 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
8363 cmdline_parse_token_string_t cmd_fwd_stats =
8364 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
8365 cmdline_parse_token_string_t cmd_fwd_all =
8366 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
8369 cmd_showfwdall_parsed(void *parsed_result,
8370 __rte_unused struct cmdline *cl,
8371 __rte_unused void *data)
8373 struct fwd_result *res = parsed_result;
8375 if (!strcmp(res->action, "show"))
8376 fwd_stats_display();
8381 static cmdline_parse_inst_t cmd_showfwdall = {
8382 .f = cmd_showfwdall_parsed,
8384 .help_str = "show|clear fwd stats all",
8386 (void *)&cmd_fwd_action,
8387 (void *)&cmd_fwd_fwd,
8388 (void *)&cmd_fwd_stats,
8389 (void *)&cmd_fwd_all,
8394 /* *** READ PORT REGISTER *** */
8395 struct cmd_read_reg_result {
8396 cmdline_fixed_string_t read;
8397 cmdline_fixed_string_t reg;
8403 cmd_read_reg_parsed(void *parsed_result,
8404 __rte_unused struct cmdline *cl,
8405 __rte_unused void *data)
8407 struct cmd_read_reg_result *res = parsed_result;
8408 port_reg_display(res->port_id, res->reg_off);
8411 cmdline_parse_token_string_t cmd_read_reg_read =
8412 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
8413 cmdline_parse_token_string_t cmd_read_reg_reg =
8414 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
8415 cmdline_parse_token_num_t cmd_read_reg_port_id =
8416 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
8417 cmdline_parse_token_num_t cmd_read_reg_reg_off =
8418 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
8420 cmdline_parse_inst_t cmd_read_reg = {
8421 .f = cmd_read_reg_parsed,
8423 .help_str = "read reg <port_id> <reg_off>",
8425 (void *)&cmd_read_reg_read,
8426 (void *)&cmd_read_reg_reg,
8427 (void *)&cmd_read_reg_port_id,
8428 (void *)&cmd_read_reg_reg_off,
8433 /* *** READ PORT REGISTER BIT FIELD *** */
8434 struct cmd_read_reg_bit_field_result {
8435 cmdline_fixed_string_t read;
8436 cmdline_fixed_string_t regfield;
8444 cmd_read_reg_bit_field_parsed(void *parsed_result,
8445 __rte_unused struct cmdline *cl,
8446 __rte_unused void *data)
8448 struct cmd_read_reg_bit_field_result *res = parsed_result;
8449 port_reg_bit_field_display(res->port_id, res->reg_off,
8450 res->bit1_pos, res->bit2_pos);
8453 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8454 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8456 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8457 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8458 regfield, "regfield");
8459 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8460 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8462 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8463 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8465 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8466 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8468 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8469 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8472 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8473 .f = cmd_read_reg_bit_field_parsed,
8475 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8476 "Read register bit field between bit_x and bit_y included",
8478 (void *)&cmd_read_reg_bit_field_read,
8479 (void *)&cmd_read_reg_bit_field_regfield,
8480 (void *)&cmd_read_reg_bit_field_port_id,
8481 (void *)&cmd_read_reg_bit_field_reg_off,
8482 (void *)&cmd_read_reg_bit_field_bit1_pos,
8483 (void *)&cmd_read_reg_bit_field_bit2_pos,
8488 /* *** READ PORT REGISTER BIT *** */
8489 struct cmd_read_reg_bit_result {
8490 cmdline_fixed_string_t read;
8491 cmdline_fixed_string_t regbit;
8498 cmd_read_reg_bit_parsed(void *parsed_result,
8499 __rte_unused struct cmdline *cl,
8500 __rte_unused void *data)
8502 struct cmd_read_reg_bit_result *res = parsed_result;
8503 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8506 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8507 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8508 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8509 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8511 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8512 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
8514 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8515 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
8517 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8518 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
8521 cmdline_parse_inst_t cmd_read_reg_bit = {
8522 .f = cmd_read_reg_bit_parsed,
8524 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8526 (void *)&cmd_read_reg_bit_read,
8527 (void *)&cmd_read_reg_bit_regbit,
8528 (void *)&cmd_read_reg_bit_port_id,
8529 (void *)&cmd_read_reg_bit_reg_off,
8530 (void *)&cmd_read_reg_bit_bit_pos,
8535 /* *** WRITE PORT REGISTER *** */
8536 struct cmd_write_reg_result {
8537 cmdline_fixed_string_t write;
8538 cmdline_fixed_string_t reg;
8545 cmd_write_reg_parsed(void *parsed_result,
8546 __rte_unused struct cmdline *cl,
8547 __rte_unused void *data)
8549 struct cmd_write_reg_result *res = parsed_result;
8550 port_reg_set(res->port_id, res->reg_off, res->value);
8553 cmdline_parse_token_string_t cmd_write_reg_write =
8554 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8555 cmdline_parse_token_string_t cmd_write_reg_reg =
8556 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8557 cmdline_parse_token_num_t cmd_write_reg_port_id =
8558 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8559 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8560 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8561 cmdline_parse_token_num_t cmd_write_reg_value =
8562 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8564 cmdline_parse_inst_t cmd_write_reg = {
8565 .f = cmd_write_reg_parsed,
8567 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8569 (void *)&cmd_write_reg_write,
8570 (void *)&cmd_write_reg_reg,
8571 (void *)&cmd_write_reg_port_id,
8572 (void *)&cmd_write_reg_reg_off,
8573 (void *)&cmd_write_reg_value,
8578 /* *** WRITE PORT REGISTER BIT FIELD *** */
8579 struct cmd_write_reg_bit_field_result {
8580 cmdline_fixed_string_t write;
8581 cmdline_fixed_string_t regfield;
8590 cmd_write_reg_bit_field_parsed(void *parsed_result,
8591 __rte_unused struct cmdline *cl,
8592 __rte_unused void *data)
8594 struct cmd_write_reg_bit_field_result *res = parsed_result;
8595 port_reg_bit_field_set(res->port_id, res->reg_off,
8596 res->bit1_pos, res->bit2_pos, res->value);
8599 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8600 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8602 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8603 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8604 regfield, "regfield");
8605 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8606 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8608 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8609 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8611 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8612 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8614 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8615 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8617 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8618 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8621 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8622 .f = cmd_write_reg_bit_field_parsed,
8624 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8626 "Set register bit field between bit_x and bit_y included",
8628 (void *)&cmd_write_reg_bit_field_write,
8629 (void *)&cmd_write_reg_bit_field_regfield,
8630 (void *)&cmd_write_reg_bit_field_port_id,
8631 (void *)&cmd_write_reg_bit_field_reg_off,
8632 (void *)&cmd_write_reg_bit_field_bit1_pos,
8633 (void *)&cmd_write_reg_bit_field_bit2_pos,
8634 (void *)&cmd_write_reg_bit_field_value,
8639 /* *** WRITE PORT REGISTER BIT *** */
8640 struct cmd_write_reg_bit_result {
8641 cmdline_fixed_string_t write;
8642 cmdline_fixed_string_t regbit;
8650 cmd_write_reg_bit_parsed(void *parsed_result,
8651 __rte_unused struct cmdline *cl,
8652 __rte_unused void *data)
8654 struct cmd_write_reg_bit_result *res = parsed_result;
8655 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8658 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8659 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8661 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8662 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8664 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8665 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8667 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8668 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8670 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8671 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8673 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8674 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8677 cmdline_parse_inst_t cmd_write_reg_bit = {
8678 .f = cmd_write_reg_bit_parsed,
8680 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8683 (void *)&cmd_write_reg_bit_write,
8684 (void *)&cmd_write_reg_bit_regbit,
8685 (void *)&cmd_write_reg_bit_port_id,
8686 (void *)&cmd_write_reg_bit_reg_off,
8687 (void *)&cmd_write_reg_bit_bit_pos,
8688 (void *)&cmd_write_reg_bit_value,
8693 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8694 struct cmd_read_rxd_txd_result {
8695 cmdline_fixed_string_t read;
8696 cmdline_fixed_string_t rxd_txd;
8703 cmd_read_rxd_txd_parsed(void *parsed_result,
8704 __rte_unused struct cmdline *cl,
8705 __rte_unused void *data)
8707 struct cmd_read_rxd_txd_result *res = parsed_result;
8709 if (!strcmp(res->rxd_txd, "rxd"))
8710 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8711 else if (!strcmp(res->rxd_txd, "txd"))
8712 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8715 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8716 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8717 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8718 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8720 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8721 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8723 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8724 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8726 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8727 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8730 cmdline_parse_inst_t cmd_read_rxd_txd = {
8731 .f = cmd_read_rxd_txd_parsed,
8733 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8735 (void *)&cmd_read_rxd_txd_read,
8736 (void *)&cmd_read_rxd_txd_rxd_txd,
8737 (void *)&cmd_read_rxd_txd_port_id,
8738 (void *)&cmd_read_rxd_txd_queue_id,
8739 (void *)&cmd_read_rxd_txd_desc_id,
8745 struct cmd_quit_result {
8746 cmdline_fixed_string_t quit;
8749 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8751 __rte_unused void *data)
8756 cmdline_parse_token_string_t cmd_quit_quit =
8757 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8759 cmdline_parse_inst_t cmd_quit = {
8760 .f = cmd_quit_parsed,
8762 .help_str = "quit: Exit application",
8764 (void *)&cmd_quit_quit,
8769 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8770 struct cmd_mac_addr_result {
8771 cmdline_fixed_string_t mac_addr_cmd;
8772 cmdline_fixed_string_t what;
8774 struct rte_ether_addr address;
8777 static void cmd_mac_addr_parsed(void *parsed_result,
8778 __rte_unused struct cmdline *cl,
8779 __rte_unused void *data)
8781 struct cmd_mac_addr_result *res = parsed_result;
8784 if (strcmp(res->what, "add") == 0)
8785 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8786 else if (strcmp(res->what, "set") == 0)
8787 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8790 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8792 /* check the return value and print it if is < 0 */
8794 fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
8798 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8799 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8801 cmdline_parse_token_string_t cmd_mac_addr_what =
8802 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8804 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8805 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8807 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8808 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8810 cmdline_parse_inst_t cmd_mac_addr = {
8811 .f = cmd_mac_addr_parsed,
8813 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8814 "Add/Remove/Set MAC address on port_id",
8816 (void *)&cmd_mac_addr_cmd,
8817 (void *)&cmd_mac_addr_what,
8818 (void *)&cmd_mac_addr_portnum,
8819 (void *)&cmd_mac_addr_addr,
8824 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8825 struct cmd_eth_peer_result {
8826 cmdline_fixed_string_t set;
8827 cmdline_fixed_string_t eth_peer;
8829 cmdline_fixed_string_t peer_addr;
8832 static void cmd_set_eth_peer_parsed(void *parsed_result,
8833 __rte_unused struct cmdline *cl,
8834 __rte_unused void *data)
8836 struct cmd_eth_peer_result *res = parsed_result;
8838 if (test_done == 0) {
8839 fprintf(stderr, "Please stop forwarding first\n");
8842 if (!strcmp(res->eth_peer, "eth-peer")) {
8843 set_fwd_eth_peer(res->port_id, res->peer_addr);
8847 cmdline_parse_token_string_t cmd_eth_peer_set =
8848 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8849 cmdline_parse_token_string_t cmd_eth_peer =
8850 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8851 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8852 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8854 cmdline_parse_token_string_t cmd_eth_peer_addr =
8855 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8857 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8858 .f = cmd_set_eth_peer_parsed,
8860 .help_str = "set eth-peer <port_id> <peer_mac>",
8862 (void *)&cmd_eth_peer_set,
8863 (void *)&cmd_eth_peer,
8864 (void *)&cmd_eth_peer_port_id,
8865 (void *)&cmd_eth_peer_addr,
8870 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8871 struct cmd_set_qmap_result {
8872 cmdline_fixed_string_t set;
8873 cmdline_fixed_string_t qmap;
8874 cmdline_fixed_string_t what;
8881 cmd_set_qmap_parsed(void *parsed_result,
8882 __rte_unused struct cmdline *cl,
8883 __rte_unused void *data)
8885 struct cmd_set_qmap_result *res = parsed_result;
8886 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8888 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8891 cmdline_parse_token_string_t cmd_setqmap_set =
8892 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8894 cmdline_parse_token_string_t cmd_setqmap_qmap =
8895 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8897 cmdline_parse_token_string_t cmd_setqmap_what =
8898 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8900 cmdline_parse_token_num_t cmd_setqmap_portid =
8901 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8902 port_id, RTE_UINT16);
8903 cmdline_parse_token_num_t cmd_setqmap_queueid =
8904 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8905 queue_id, RTE_UINT16);
8906 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8907 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8908 map_value, RTE_UINT8);
8910 cmdline_parse_inst_t cmd_set_qmap = {
8911 .f = cmd_set_qmap_parsed,
8913 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8914 "Set statistics mapping value on tx|rx queue_id of port_id",
8916 (void *)&cmd_setqmap_set,
8917 (void *)&cmd_setqmap_qmap,
8918 (void *)&cmd_setqmap_what,
8919 (void *)&cmd_setqmap_portid,
8920 (void *)&cmd_setqmap_queueid,
8921 (void *)&cmd_setqmap_mapvalue,
8926 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8927 struct cmd_set_xstats_hide_zero_result {
8928 cmdline_fixed_string_t keyword;
8929 cmdline_fixed_string_t name;
8930 cmdline_fixed_string_t on_off;
8934 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8935 __rte_unused struct cmdline *cl,
8936 __rte_unused void *data)
8938 struct cmd_set_xstats_hide_zero_result *res;
8939 uint16_t on_off = 0;
8941 res = parsed_result;
8942 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8943 set_xstats_hide_zero(on_off);
8946 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8947 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8949 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8950 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8951 name, "xstats-hide-zero");
8952 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8953 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8956 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8957 .f = cmd_set_xstats_hide_zero_parsed,
8959 .help_str = "set xstats-hide-zero on|off",
8961 (void *)&cmd_set_xstats_hide_zero_keyword,
8962 (void *)&cmd_set_xstats_hide_zero_name,
8963 (void *)&cmd_set_xstats_hide_zero_on_off,
8968 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8969 struct cmd_set_record_core_cycles_result {
8970 cmdline_fixed_string_t keyword;
8971 cmdline_fixed_string_t name;
8972 cmdline_fixed_string_t on_off;
8976 cmd_set_record_core_cycles_parsed(void *parsed_result,
8977 __rte_unused struct cmdline *cl,
8978 __rte_unused void *data)
8980 struct cmd_set_record_core_cycles_result *res;
8981 uint16_t on_off = 0;
8983 res = parsed_result;
8984 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8985 set_record_core_cycles(on_off);
8988 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8989 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8991 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8992 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8993 name, "record-core-cycles");
8994 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8995 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8998 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8999 .f = cmd_set_record_core_cycles_parsed,
9001 .help_str = "set record-core-cycles on|off",
9003 (void *)&cmd_set_record_core_cycles_keyword,
9004 (void *)&cmd_set_record_core_cycles_name,
9005 (void *)&cmd_set_record_core_cycles_on_off,
9010 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
9011 struct cmd_set_record_burst_stats_result {
9012 cmdline_fixed_string_t keyword;
9013 cmdline_fixed_string_t name;
9014 cmdline_fixed_string_t on_off;
9018 cmd_set_record_burst_stats_parsed(void *parsed_result,
9019 __rte_unused struct cmdline *cl,
9020 __rte_unused void *data)
9022 struct cmd_set_record_burst_stats_result *res;
9023 uint16_t on_off = 0;
9025 res = parsed_result;
9026 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9027 set_record_burst_stats(on_off);
9030 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
9031 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9033 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
9034 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9035 name, "record-burst-stats");
9036 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
9037 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9040 cmdline_parse_inst_t cmd_set_record_burst_stats = {
9041 .f = cmd_set_record_burst_stats_parsed,
9043 .help_str = "set record-burst-stats on|off",
9045 (void *)&cmd_set_record_burst_stats_keyword,
9046 (void *)&cmd_set_record_burst_stats_name,
9047 (void *)&cmd_set_record_burst_stats_on_off,
9052 /* *** CONFIGURE UNICAST HASH TABLE *** */
9053 struct cmd_set_uc_hash_table {
9054 cmdline_fixed_string_t set;
9055 cmdline_fixed_string_t port;
9057 cmdline_fixed_string_t what;
9058 struct rte_ether_addr address;
9059 cmdline_fixed_string_t mode;
9063 cmd_set_uc_hash_parsed(void *parsed_result,
9064 __rte_unused struct cmdline *cl,
9065 __rte_unused void *data)
9068 struct cmd_set_uc_hash_table *res = parsed_result;
9070 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9072 if (strcmp(res->what, "uta") == 0)
9073 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
9074 &res->address,(uint8_t)is_on);
9077 "bad unicast hash table parameter, return code = %d\n",
9082 cmdline_parse_token_string_t cmd_set_uc_hash_set =
9083 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9085 cmdline_parse_token_string_t cmd_set_uc_hash_port =
9086 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9088 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
9089 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
9090 port_id, RTE_UINT16);
9091 cmdline_parse_token_string_t cmd_set_uc_hash_what =
9092 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9094 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
9095 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
9097 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
9098 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9101 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
9102 .f = cmd_set_uc_hash_parsed,
9104 .help_str = "set port <port_id> uta <mac_addr> on|off)",
9106 (void *)&cmd_set_uc_hash_set,
9107 (void *)&cmd_set_uc_hash_port,
9108 (void *)&cmd_set_uc_hash_portid,
9109 (void *)&cmd_set_uc_hash_what,
9110 (void *)&cmd_set_uc_hash_mac,
9111 (void *)&cmd_set_uc_hash_mode,
9116 struct cmd_set_uc_all_hash_table {
9117 cmdline_fixed_string_t set;
9118 cmdline_fixed_string_t port;
9120 cmdline_fixed_string_t what;
9121 cmdline_fixed_string_t value;
9122 cmdline_fixed_string_t mode;
9126 cmd_set_uc_all_hash_parsed(void *parsed_result,
9127 __rte_unused struct cmdline *cl,
9128 __rte_unused void *data)
9131 struct cmd_set_uc_all_hash_table *res = parsed_result;
9133 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9135 if ((strcmp(res->what, "uta") == 0) &&
9136 (strcmp(res->value, "all") == 0))
9137 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
9140 "bad unicast hash table parameter, return code = %d\n",
9144 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
9145 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9147 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
9148 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9150 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
9151 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
9152 port_id, RTE_UINT16);
9153 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
9154 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9156 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
9157 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9159 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
9160 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9163 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
9164 .f = cmd_set_uc_all_hash_parsed,
9166 .help_str = "set port <port_id> uta all on|off",
9168 (void *)&cmd_set_uc_all_hash_set,
9169 (void *)&cmd_set_uc_all_hash_port,
9170 (void *)&cmd_set_uc_all_hash_portid,
9171 (void *)&cmd_set_uc_all_hash_what,
9172 (void *)&cmd_set_uc_all_hash_value,
9173 (void *)&cmd_set_uc_all_hash_mode,
9178 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
9179 struct cmd_set_vf_traffic {
9180 cmdline_fixed_string_t set;
9181 cmdline_fixed_string_t port;
9183 cmdline_fixed_string_t vf;
9185 cmdline_fixed_string_t what;
9186 cmdline_fixed_string_t mode;
9190 cmd_set_vf_traffic_parsed(void *parsed_result,
9191 __rte_unused struct cmdline *cl,
9192 __rte_unused void *data)
9194 struct cmd_set_vf_traffic *res = parsed_result;
9195 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
9196 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9198 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
9201 cmdline_parse_token_string_t cmd_setvf_traffic_set =
9202 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9204 cmdline_parse_token_string_t cmd_setvf_traffic_port =
9205 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9207 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
9208 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9209 port_id, RTE_UINT16);
9210 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
9211 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9213 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
9214 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9216 cmdline_parse_token_string_t cmd_setvf_traffic_what =
9217 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9219 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
9220 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9223 cmdline_parse_inst_t cmd_set_vf_traffic = {
9224 .f = cmd_set_vf_traffic_parsed,
9226 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
9228 (void *)&cmd_setvf_traffic_set,
9229 (void *)&cmd_setvf_traffic_port,
9230 (void *)&cmd_setvf_traffic_portid,
9231 (void *)&cmd_setvf_traffic_vf,
9232 (void *)&cmd_setvf_traffic_vfid,
9233 (void *)&cmd_setvf_traffic_what,
9234 (void *)&cmd_setvf_traffic_mode,
9239 /* *** CONFIGURE VF RECEIVE MODE *** */
9240 struct cmd_set_vf_rxmode {
9241 cmdline_fixed_string_t set;
9242 cmdline_fixed_string_t port;
9244 cmdline_fixed_string_t vf;
9246 cmdline_fixed_string_t what;
9247 cmdline_fixed_string_t mode;
9248 cmdline_fixed_string_t on;
9252 cmd_set_vf_rxmode_parsed(void *parsed_result,
9253 __rte_unused struct cmdline *cl,
9254 __rte_unused void *data)
9257 uint16_t vf_rxmode = 0;
9258 struct cmd_set_vf_rxmode *res = parsed_result;
9260 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
9261 if (!strcmp(res->what,"rxmode")) {
9262 if (!strcmp(res->mode, "AUPE"))
9263 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_UNTAG;
9264 else if (!strcmp(res->mode, "ROPE"))
9265 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_HASH_UC;
9266 else if (!strcmp(res->mode, "BAM"))
9267 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_BROADCAST;
9268 else if (!strncmp(res->mode, "MPE",3))
9269 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_MULTICAST;
9272 RTE_SET_USED(is_on);
9274 #ifdef RTE_NET_IXGBE
9275 if (ret == -ENOTSUP)
9276 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
9277 vf_rxmode, (uint8_t)is_on);
9280 if (ret == -ENOTSUP)
9281 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
9282 vf_rxmode, (uint8_t)is_on);
9286 "bad VF receive mode parameter, return code = %d\n",
9290 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
9291 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9293 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
9294 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9296 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
9297 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9298 port_id, RTE_UINT16);
9299 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
9300 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9302 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
9303 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9305 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
9306 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9308 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
9309 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9310 mode, "AUPE#ROPE#BAM#MPE");
9311 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
9312 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9315 cmdline_parse_inst_t cmd_set_vf_rxmode = {
9316 .f = cmd_set_vf_rxmode_parsed,
9318 .help_str = "set port <port_id> vf <vf_id> rxmode "
9319 "AUPE|ROPE|BAM|MPE on|off",
9321 (void *)&cmd_set_vf_rxmode_set,
9322 (void *)&cmd_set_vf_rxmode_port,
9323 (void *)&cmd_set_vf_rxmode_portid,
9324 (void *)&cmd_set_vf_rxmode_vf,
9325 (void *)&cmd_set_vf_rxmode_vfid,
9326 (void *)&cmd_set_vf_rxmode_what,
9327 (void *)&cmd_set_vf_rxmode_mode,
9328 (void *)&cmd_set_vf_rxmode_on,
9333 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
9334 struct cmd_vf_mac_addr_result {
9335 cmdline_fixed_string_t mac_addr_cmd;
9336 cmdline_fixed_string_t what;
9337 cmdline_fixed_string_t port;
9339 cmdline_fixed_string_t vf;
9341 struct rte_ether_addr address;
9344 static void cmd_vf_mac_addr_parsed(void *parsed_result,
9345 __rte_unused struct cmdline *cl,
9346 __rte_unused void *data)
9348 struct cmd_vf_mac_addr_result *res = parsed_result;
9351 if (strcmp(res->what, "add") != 0)
9355 if (ret == -ENOTSUP)
9356 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
9360 if (ret == -ENOTSUP)
9361 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
9366 fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
9370 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
9371 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9372 mac_addr_cmd,"mac_addr");
9373 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
9374 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9376 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
9377 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9379 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
9380 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9381 port_num, RTE_UINT16);
9382 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
9383 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9385 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
9386 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9388 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
9389 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
9392 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
9393 .f = cmd_vf_mac_addr_parsed,
9395 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
9396 "Add MAC address filtering for a VF on port_id",
9398 (void *)&cmd_vf_mac_addr_cmd,
9399 (void *)&cmd_vf_mac_addr_what,
9400 (void *)&cmd_vf_mac_addr_port,
9401 (void *)&cmd_vf_mac_addr_portnum,
9402 (void *)&cmd_vf_mac_addr_vf,
9403 (void *)&cmd_vf_mac_addr_vfnum,
9404 (void *)&cmd_vf_mac_addr_addr,
9409 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
9410 struct cmd_vf_rx_vlan_filter {
9411 cmdline_fixed_string_t rx_vlan;
9412 cmdline_fixed_string_t what;
9414 cmdline_fixed_string_t port;
9416 cmdline_fixed_string_t vf;
9421 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
9422 __rte_unused struct cmdline *cl,
9423 __rte_unused void *data)
9425 struct cmd_vf_rx_vlan_filter *res = parsed_result;
9428 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9430 #ifdef RTE_NET_IXGBE
9431 if (ret == -ENOTSUP)
9432 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9433 res->vlan_id, res->vf_mask, is_add);
9436 if (ret == -ENOTSUP)
9437 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9438 res->vlan_id, res->vf_mask, is_add);
9441 if (ret == -ENOTSUP)
9442 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9443 res->vlan_id, res->vf_mask, is_add);
9450 fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
9451 res->vlan_id, res->vf_mask);
9454 fprintf(stderr, "invalid port_id %d\n", res->port_id);
9457 fprintf(stderr, "function not implemented or supported\n");
9460 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9464 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9465 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9466 rx_vlan, "rx_vlan");
9467 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9468 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9470 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9471 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9472 vlan_id, RTE_UINT16);
9473 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9474 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9476 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9477 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9478 port_id, RTE_UINT16);
9479 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9480 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9482 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9483 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9484 vf_mask, RTE_UINT64);
9486 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9487 .f = cmd_vf_rx_vlan_filter_parsed,
9489 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9490 "(vf_mask = hexadecimal VF mask)",
9492 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9493 (void *)&cmd_vf_rx_vlan_filter_what,
9494 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9495 (void *)&cmd_vf_rx_vlan_filter_port,
9496 (void *)&cmd_vf_rx_vlan_filter_portid,
9497 (void *)&cmd_vf_rx_vlan_filter_vf,
9498 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9503 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9504 struct cmd_queue_rate_limit_result {
9505 cmdline_fixed_string_t set;
9506 cmdline_fixed_string_t port;
9508 cmdline_fixed_string_t queue;
9510 cmdline_fixed_string_t rate;
9514 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9515 __rte_unused struct cmdline *cl,
9516 __rte_unused void *data)
9518 struct cmd_queue_rate_limit_result *res = parsed_result;
9521 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9522 && (strcmp(res->queue, "queue") == 0)
9523 && (strcmp(res->rate, "rate") == 0))
9524 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9527 fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
9532 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9533 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9535 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9536 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9538 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9539 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9540 port_num, RTE_UINT16);
9541 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9542 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9544 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9545 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9546 queue_num, RTE_UINT8);
9547 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9548 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9550 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9551 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9552 rate_num, RTE_UINT16);
9554 cmdline_parse_inst_t cmd_queue_rate_limit = {
9555 .f = cmd_queue_rate_limit_parsed,
9557 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9558 "Set rate limit for a queue on port_id",
9560 (void *)&cmd_queue_rate_limit_set,
9561 (void *)&cmd_queue_rate_limit_port,
9562 (void *)&cmd_queue_rate_limit_portnum,
9563 (void *)&cmd_queue_rate_limit_queue,
9564 (void *)&cmd_queue_rate_limit_queuenum,
9565 (void *)&cmd_queue_rate_limit_rate,
9566 (void *)&cmd_queue_rate_limit_ratenum,
9571 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9572 struct cmd_vf_rate_limit_result {
9573 cmdline_fixed_string_t set;
9574 cmdline_fixed_string_t port;
9576 cmdline_fixed_string_t vf;
9578 cmdline_fixed_string_t rate;
9580 cmdline_fixed_string_t q_msk;
9584 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9585 __rte_unused struct cmdline *cl,
9586 __rte_unused void *data)
9588 struct cmd_vf_rate_limit_result *res = parsed_result;
9591 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9592 && (strcmp(res->vf, "vf") == 0)
9593 && (strcmp(res->rate, "rate") == 0)
9594 && (strcmp(res->q_msk, "queue_mask") == 0))
9595 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9596 res->rate_num, res->q_msk_val);
9598 fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
9603 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9604 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9606 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9607 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9609 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9610 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9611 port_num, RTE_UINT16);
9612 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9613 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9615 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9616 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9618 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9619 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9621 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9622 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9623 rate_num, RTE_UINT16);
9624 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9625 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9626 q_msk, "queue_mask");
9627 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9628 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9629 q_msk_val, RTE_UINT64);
9631 cmdline_parse_inst_t cmd_vf_rate_limit = {
9632 .f = cmd_vf_rate_limit_parsed,
9634 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9635 "queue_mask <queue_mask_value>: "
9636 "Set rate limit for queues of VF on port_id",
9638 (void *)&cmd_vf_rate_limit_set,
9639 (void *)&cmd_vf_rate_limit_port,
9640 (void *)&cmd_vf_rate_limit_portnum,
9641 (void *)&cmd_vf_rate_limit_vf,
9642 (void *)&cmd_vf_rate_limit_vfnum,
9643 (void *)&cmd_vf_rate_limit_rate,
9644 (void *)&cmd_vf_rate_limit_ratenum,
9645 (void *)&cmd_vf_rate_limit_q_msk,
9646 (void *)&cmd_vf_rate_limit_q_msk_val,
9651 /* *** CONFIGURE TUNNEL UDP PORT *** */
9652 struct cmd_tunnel_udp_config {
9653 cmdline_fixed_string_t rx_vxlan_port;
9654 cmdline_fixed_string_t what;
9660 cmd_tunnel_udp_config_parsed(void *parsed_result,
9661 __rte_unused struct cmdline *cl,
9662 __rte_unused void *data)
9664 struct cmd_tunnel_udp_config *res = parsed_result;
9665 struct rte_eth_udp_tunnel tunnel_udp;
9668 tunnel_udp.udp_port = res->udp_port;
9669 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9671 if (!strcmp(res->what, "add"))
9672 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9675 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9679 fprintf(stderr, "udp tunneling add error: (%s)\n",
9683 cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9684 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9685 rx_vxlan_port, "rx_vxlan_port");
9686 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9687 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9689 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9690 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9691 udp_port, RTE_UINT16);
9692 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9693 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9694 port_id, RTE_UINT16);
9696 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9697 .f = cmd_tunnel_udp_config_parsed,
9699 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9700 "Add/Remove a tunneling UDP port filter",
9702 (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9703 (void *)&cmd_tunnel_udp_config_what,
9704 (void *)&cmd_tunnel_udp_config_udp_port,
9705 (void *)&cmd_tunnel_udp_config_port_id,
9710 struct cmd_config_tunnel_udp_port {
9711 cmdline_fixed_string_t port;
9712 cmdline_fixed_string_t config;
9714 cmdline_fixed_string_t udp_tunnel_port;
9715 cmdline_fixed_string_t action;
9716 cmdline_fixed_string_t tunnel_type;
9721 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9722 __rte_unused struct cmdline *cl,
9723 __rte_unused void *data)
9725 struct cmd_config_tunnel_udp_port *res = parsed_result;
9726 struct rte_eth_udp_tunnel tunnel_udp;
9729 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9732 tunnel_udp.udp_port = res->udp_port;
9734 if (!strcmp(res->tunnel_type, "vxlan")) {
9735 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9736 } else if (!strcmp(res->tunnel_type, "geneve")) {
9737 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_GENEVE;
9738 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9739 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN_GPE;
9740 } else if (!strcmp(res->tunnel_type, "ecpri")) {
9741 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_ECPRI;
9743 fprintf(stderr, "Invalid tunnel type\n");
9747 if (!strcmp(res->action, "add"))
9748 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9751 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9755 fprintf(stderr, "udp tunneling port add error: (%s)\n",
9759 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9760 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9762 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9763 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9765 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9766 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9768 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9769 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9772 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9773 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9775 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9776 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9777 "vxlan#geneve#vxlan-gpe#ecpri");
9778 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9779 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9782 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9783 .f = cmd_cfg_tunnel_udp_port_parsed,
9785 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9786 "geneve|vxlan-gpe|ecpri <udp_port>",
9788 (void *)&cmd_config_tunnel_udp_port_port,
9789 (void *)&cmd_config_tunnel_udp_port_config,
9790 (void *)&cmd_config_tunnel_udp_port_port_id,
9791 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9792 (void *)&cmd_config_tunnel_udp_port_action,
9793 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9794 (void *)&cmd_config_tunnel_udp_port_value,
9799 /* ******************************************************************************** */
9801 struct cmd_dump_result {
9802 cmdline_fixed_string_t dump;
9806 dump_struct_sizes(void)
9808 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9809 DUMP_SIZE(struct rte_mbuf);
9810 DUMP_SIZE(struct rte_mempool);
9811 DUMP_SIZE(struct rte_ring);
9816 /* Dump the socket memory statistics on console */
9818 dump_socket_mem(FILE *f)
9820 struct rte_malloc_socket_stats socket_stats;
9825 unsigned int n_alloc = 0;
9826 unsigned int n_free = 0;
9827 static size_t last_allocs;
9828 static size_t last_total;
9831 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9832 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9833 !socket_stats.heap_totalsz_bytes)
9835 total += socket_stats.heap_totalsz_bytes;
9836 alloc += socket_stats.heap_allocsz_bytes;
9837 free += socket_stats.heap_freesz_bytes;
9838 n_alloc += socket_stats.alloc_count;
9839 n_free += socket_stats.free_count;
9841 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9843 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9844 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9845 (double)socket_stats.heap_allocsz_bytes * 100 /
9846 (double)socket_stats.heap_totalsz_bytes,
9847 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9848 socket_stats.alloc_count,
9849 socket_stats.free_count);
9852 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9853 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9854 total ? ((double)alloc * 100 / (double)total) : 0,
9855 (double)free / (1024 * 1024),
9858 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9859 ((double)total - (double)last_total) / (1024 * 1024),
9860 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9861 last_allocs = alloc;
9865 static void cmd_dump_parsed(void *parsed_result,
9866 __rte_unused struct cmdline *cl,
9867 __rte_unused void *data)
9869 struct cmd_dump_result *res = parsed_result;
9871 if (!strcmp(res->dump, "dump_physmem"))
9872 rte_dump_physmem_layout(stdout);
9873 else if (!strcmp(res->dump, "dump_socket_mem"))
9874 dump_socket_mem(stdout);
9875 else if (!strcmp(res->dump, "dump_memzone"))
9876 rte_memzone_dump(stdout);
9877 else if (!strcmp(res->dump, "dump_struct_sizes"))
9878 dump_struct_sizes();
9879 else if (!strcmp(res->dump, "dump_ring"))
9880 rte_ring_list_dump(stdout);
9881 else if (!strcmp(res->dump, "dump_mempool"))
9882 rte_mempool_list_dump(stdout);
9883 else if (!strcmp(res->dump, "dump_devargs"))
9884 rte_devargs_dump(stdout);
9885 else if (!strcmp(res->dump, "dump_log_types"))
9886 rte_log_dump(stdout);
9889 cmdline_parse_token_string_t cmd_dump_dump =
9890 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9894 "dump_struct_sizes#"
9900 cmdline_parse_inst_t cmd_dump = {
9901 .f = cmd_dump_parsed, /* function to call */
9902 .data = NULL, /* 2nd arg of func */
9903 .help_str = "Dump status",
9904 .tokens = { /* token list, NULL terminated */
9905 (void *)&cmd_dump_dump,
9910 /* ******************************************************************************** */
9912 struct cmd_dump_one_result {
9913 cmdline_fixed_string_t dump;
9914 cmdline_fixed_string_t name;
9917 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9918 __rte_unused void *data)
9920 struct cmd_dump_one_result *res = parsed_result;
9922 if (!strcmp(res->dump, "dump_ring")) {
9924 r = rte_ring_lookup(res->name);
9926 cmdline_printf(cl, "Cannot find ring\n");
9929 rte_ring_dump(stdout, r);
9930 } else if (!strcmp(res->dump, "dump_mempool")) {
9931 struct rte_mempool *mp;
9932 mp = rte_mempool_lookup(res->name);
9934 cmdline_printf(cl, "Cannot find mempool\n");
9937 rte_mempool_dump(stdout, mp);
9941 cmdline_parse_token_string_t cmd_dump_one_dump =
9942 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9943 "dump_ring#dump_mempool");
9945 cmdline_parse_token_string_t cmd_dump_one_name =
9946 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9948 cmdline_parse_inst_t cmd_dump_one = {
9949 .f = cmd_dump_one_parsed, /* function to call */
9950 .data = NULL, /* 2nd arg of func */
9951 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9952 .tokens = { /* token list, NULL terminated */
9953 (void *)&cmd_dump_one_dump,
9954 (void *)&cmd_dump_one_name,
9959 /* *** queue region set *** */
9960 struct cmd_queue_region_result {
9961 cmdline_fixed_string_t set;
9962 cmdline_fixed_string_t port;
9964 cmdline_fixed_string_t cmd;
9965 cmdline_fixed_string_t region;
9967 cmdline_fixed_string_t queue_start_index;
9969 cmdline_fixed_string_t queue_num;
9970 uint8_t queue_num_value;
9974 cmd_queue_region_parsed(void *parsed_result,
9975 __rte_unused struct cmdline *cl,
9976 __rte_unused void *data)
9978 struct cmd_queue_region_result *res = parsed_result;
9981 struct rte_pmd_i40e_queue_region_conf region_conf;
9982 enum rte_pmd_i40e_queue_region_op op_type;
9985 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9989 memset(®ion_conf, 0, sizeof(region_conf));
9990 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9991 region_conf.region_id = res->region_id;
9992 region_conf.queue_num = res->queue_num_value;
9993 region_conf.queue_start_index = res->queue_id;
9995 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9996 op_type, ®ion_conf);
10003 fprintf(stderr, "function not implemented or supported\n");
10006 fprintf(stderr, "queue region config error: (%s)\n",
10011 cmdline_parse_token_string_t cmd_queue_region_set =
10012 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10014 cmdline_parse_token_string_t cmd_queue_region_port =
10015 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
10016 cmdline_parse_token_num_t cmd_queue_region_port_id =
10017 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10018 port_id, RTE_UINT16);
10019 cmdline_parse_token_string_t cmd_queue_region_cmd =
10020 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10021 cmd, "queue-region");
10022 cmdline_parse_token_string_t cmd_queue_region_id =
10023 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10024 region, "region_id");
10025 cmdline_parse_token_num_t cmd_queue_region_index =
10026 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10027 region_id, RTE_UINT8);
10028 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
10029 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10030 queue_start_index, "queue_start_index");
10031 cmdline_parse_token_num_t cmd_queue_region_queue_id =
10032 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10033 queue_id, RTE_UINT8);
10034 cmdline_parse_token_string_t cmd_queue_region_queue_num =
10035 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10036 queue_num, "queue_num");
10037 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
10038 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10039 queue_num_value, RTE_UINT8);
10041 cmdline_parse_inst_t cmd_queue_region = {
10042 .f = cmd_queue_region_parsed,
10044 .help_str = "set port <port_id> queue-region region_id <value> "
10045 "queue_start_index <value> queue_num <value>: Set a queue region",
10047 (void *)&cmd_queue_region_set,
10048 (void *)&cmd_queue_region_port,
10049 (void *)&cmd_queue_region_port_id,
10050 (void *)&cmd_queue_region_cmd,
10051 (void *)&cmd_queue_region_id,
10052 (void *)&cmd_queue_region_index,
10053 (void *)&cmd_queue_region_queue_start_index,
10054 (void *)&cmd_queue_region_queue_id,
10055 (void *)&cmd_queue_region_queue_num,
10056 (void *)&cmd_queue_region_queue_num_value,
10061 /* *** queue region and flowtype set *** */
10062 struct cmd_region_flowtype_result {
10063 cmdline_fixed_string_t set;
10064 cmdline_fixed_string_t port;
10066 cmdline_fixed_string_t cmd;
10067 cmdline_fixed_string_t region;
10069 cmdline_fixed_string_t flowtype;
10070 uint8_t flowtype_id;
10074 cmd_region_flowtype_parsed(void *parsed_result,
10075 __rte_unused struct cmdline *cl,
10076 __rte_unused void *data)
10078 struct cmd_region_flowtype_result *res = parsed_result;
10079 int ret = -ENOTSUP;
10080 #ifdef RTE_NET_I40E
10081 struct rte_pmd_i40e_queue_region_conf region_conf;
10082 enum rte_pmd_i40e_queue_region_op op_type;
10085 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10088 #ifdef RTE_NET_I40E
10089 memset(®ion_conf, 0, sizeof(region_conf));
10091 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10092 region_conf.region_id = res->region_id;
10093 region_conf.hw_flowtype = res->flowtype_id;
10095 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10096 op_type, ®ion_conf);
10103 fprintf(stderr, "function not implemented or supported\n");
10106 fprintf(stderr, "region flowtype config error: (%s)\n",
10111 cmdline_parse_token_string_t cmd_region_flowtype_set =
10112 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10114 cmdline_parse_token_string_t cmd_region_flowtype_port =
10115 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10117 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10118 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10119 port_id, RTE_UINT16);
10120 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10121 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10122 cmd, "queue-region");
10123 cmdline_parse_token_string_t cmd_region_flowtype_index =
10124 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10125 region, "region_id");
10126 cmdline_parse_token_num_t cmd_region_flowtype_id =
10127 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10128 region_id, RTE_UINT8);
10129 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10130 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10131 flowtype, "flowtype");
10132 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10133 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10134 flowtype_id, RTE_UINT8);
10135 cmdline_parse_inst_t cmd_region_flowtype = {
10136 .f = cmd_region_flowtype_parsed,
10138 .help_str = "set port <port_id> queue-region region_id <value> "
10139 "flowtype <value>: Set a flowtype region index",
10141 (void *)&cmd_region_flowtype_set,
10142 (void *)&cmd_region_flowtype_port,
10143 (void *)&cmd_region_flowtype_port_index,
10144 (void *)&cmd_region_flowtype_cmd,
10145 (void *)&cmd_region_flowtype_index,
10146 (void *)&cmd_region_flowtype_id,
10147 (void *)&cmd_region_flowtype_flow_index,
10148 (void *)&cmd_region_flowtype_flow_id,
10153 /* *** User Priority (UP) to queue region (region_id) set *** */
10154 struct cmd_user_priority_region_result {
10155 cmdline_fixed_string_t set;
10156 cmdline_fixed_string_t port;
10158 cmdline_fixed_string_t cmd;
10159 cmdline_fixed_string_t user_priority;
10160 uint8_t user_priority_id;
10161 cmdline_fixed_string_t region;
10166 cmd_user_priority_region_parsed(void *parsed_result,
10167 __rte_unused struct cmdline *cl,
10168 __rte_unused void *data)
10170 struct cmd_user_priority_region_result *res = parsed_result;
10171 int ret = -ENOTSUP;
10172 #ifdef RTE_NET_I40E
10173 struct rte_pmd_i40e_queue_region_conf region_conf;
10174 enum rte_pmd_i40e_queue_region_op op_type;
10177 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10180 #ifdef RTE_NET_I40E
10181 memset(®ion_conf, 0, sizeof(region_conf));
10182 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10183 region_conf.user_priority = res->user_priority_id;
10184 region_conf.region_id = res->region_id;
10186 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10187 op_type, ®ion_conf);
10194 fprintf(stderr, "function not implemented or supported\n");
10197 fprintf(stderr, "user_priority region config error: (%s)\n",
10202 cmdline_parse_token_string_t cmd_user_priority_region_set =
10203 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10205 cmdline_parse_token_string_t cmd_user_priority_region_port =
10206 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10208 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10209 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10210 port_id, RTE_UINT16);
10211 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10212 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10213 cmd, "queue-region");
10214 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10215 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10216 user_priority, "UP");
10217 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10218 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10219 user_priority_id, RTE_UINT8);
10220 cmdline_parse_token_string_t cmd_user_priority_region_region =
10221 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10222 region, "region_id");
10223 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10224 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10225 region_id, RTE_UINT8);
10227 cmdline_parse_inst_t cmd_user_priority_region = {
10228 .f = cmd_user_priority_region_parsed,
10230 .help_str = "set port <port_id> queue-region UP <value> "
10231 "region_id <value>: Set the mapping of User Priority (UP) "
10232 "to queue region (region_id) ",
10234 (void *)&cmd_user_priority_region_set,
10235 (void *)&cmd_user_priority_region_port,
10236 (void *)&cmd_user_priority_region_port_index,
10237 (void *)&cmd_user_priority_region_cmd,
10238 (void *)&cmd_user_priority_region_UP,
10239 (void *)&cmd_user_priority_region_UP_id,
10240 (void *)&cmd_user_priority_region_region,
10241 (void *)&cmd_user_priority_region_region_id,
10246 /* *** flush all queue region related configuration *** */
10247 struct cmd_flush_queue_region_result {
10248 cmdline_fixed_string_t set;
10249 cmdline_fixed_string_t port;
10251 cmdline_fixed_string_t cmd;
10252 cmdline_fixed_string_t flush;
10253 cmdline_fixed_string_t what;
10257 cmd_flush_queue_region_parsed(void *parsed_result,
10258 __rte_unused struct cmdline *cl,
10259 __rte_unused void *data)
10261 struct cmd_flush_queue_region_result *res = parsed_result;
10262 int ret = -ENOTSUP;
10263 #ifdef RTE_NET_I40E
10264 struct rte_pmd_i40e_queue_region_conf region_conf;
10265 enum rte_pmd_i40e_queue_region_op op_type;
10268 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10271 #ifdef RTE_NET_I40E
10272 memset(®ion_conf, 0, sizeof(region_conf));
10274 if (strcmp(res->what, "on") == 0)
10275 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10277 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10279 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10280 op_type, ®ion_conf);
10287 fprintf(stderr, "function not implemented or supported\n");
10290 fprintf(stderr, "queue region config flush error: (%s)\n",
10295 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10296 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10298 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10299 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10301 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10302 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10303 port_id, RTE_UINT16);
10304 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10305 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10306 cmd, "queue-region");
10307 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10308 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10310 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10311 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10314 cmdline_parse_inst_t cmd_flush_queue_region = {
10315 .f = cmd_flush_queue_region_parsed,
10317 .help_str = "set port <port_id> queue-region flush on|off"
10318 ": flush all queue region related configuration",
10320 (void *)&cmd_flush_queue_region_set,
10321 (void *)&cmd_flush_queue_region_port,
10322 (void *)&cmd_flush_queue_region_port_index,
10323 (void *)&cmd_flush_queue_region_cmd,
10324 (void *)&cmd_flush_queue_region_flush,
10325 (void *)&cmd_flush_queue_region_what,
10330 /* *** get all queue region related configuration info *** */
10331 struct cmd_show_queue_region_info {
10332 cmdline_fixed_string_t show;
10333 cmdline_fixed_string_t port;
10335 cmdline_fixed_string_t cmd;
10339 cmd_show_queue_region_info_parsed(void *parsed_result,
10340 __rte_unused struct cmdline *cl,
10341 __rte_unused void *data)
10343 struct cmd_show_queue_region_info *res = parsed_result;
10344 int ret = -ENOTSUP;
10345 #ifdef RTE_NET_I40E
10346 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10347 enum rte_pmd_i40e_queue_region_op op_type;
10350 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10353 #ifdef RTE_NET_I40E
10354 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10356 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10358 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10359 op_type, &rte_pmd_regions);
10361 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10368 fprintf(stderr, "function not implemented or supported\n");
10371 fprintf(stderr, "queue region config info show error: (%s)\n",
10376 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10377 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10379 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10380 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10382 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10383 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10384 port_id, RTE_UINT16);
10385 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10386 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10387 cmd, "queue-region");
10389 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10390 .f = cmd_show_queue_region_info_parsed,
10392 .help_str = "show port <port_id> queue-region"
10393 ": show all queue region related configuration info",
10395 (void *)&cmd_show_queue_region_info_get,
10396 (void *)&cmd_show_queue_region_info_port,
10397 (void *)&cmd_show_queue_region_info_port_index,
10398 (void *)&cmd_show_queue_region_info_cmd,
10403 /* *** Filters Control *** */
10405 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10407 if ((ip_addr).family == AF_INET) \
10408 (ip) = (ip_addr).addr.ipv4.s_addr; \
10410 fprintf(stderr, "invalid parameter.\n"); \
10415 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10417 if ((ip_addr).family == AF_INET6) \
10418 rte_memcpy(&(ip), \
10419 &((ip_addr).addr.ipv6), \
10420 sizeof(struct in6_addr)); \
10422 fprintf(stderr, "invalid parameter.\n"); \
10427 #ifdef RTE_NET_I40E
10430 str2flowtype(char *string)
10433 static const struct {
10436 } flowtype_str[] = {
10437 {"raw", RTE_ETH_FLOW_RAW},
10438 {"ipv4", RTE_ETH_FLOW_IPV4},
10439 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10440 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10441 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10442 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10443 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10444 {"ipv6", RTE_ETH_FLOW_IPV6},
10445 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10446 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10447 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10448 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10449 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10450 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10451 {"ipv6-ex", RTE_ETH_FLOW_IPV6_EX},
10452 {"ipv6-tcp-ex", RTE_ETH_FLOW_IPV6_TCP_EX},
10453 {"ipv6-udp-ex", RTE_ETH_FLOW_IPV6_UDP_EX},
10454 {"gtpu", RTE_ETH_FLOW_GTPU},
10457 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10458 if (!strcmp(flowtype_str[i].str, string))
10459 return flowtype_str[i].type;
10462 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10463 return (uint16_t)atoi(string);
10465 return RTE_ETH_FLOW_UNKNOWN;
10468 /* *** deal with flow director filter *** */
10469 struct cmd_flow_director_result {
10470 cmdline_fixed_string_t flow_director_filter;
10472 cmdline_fixed_string_t mode;
10473 cmdline_fixed_string_t mode_value;
10474 cmdline_fixed_string_t ops;
10475 cmdline_fixed_string_t flow;
10476 cmdline_fixed_string_t flow_type;
10477 cmdline_fixed_string_t drop;
10478 cmdline_fixed_string_t queue;
10480 cmdline_fixed_string_t fd_id;
10481 uint32_t fd_id_value;
10482 cmdline_fixed_string_t packet;
10487 cmd_flow_director_filter_parsed(void *parsed_result,
10488 __rte_unused struct cmdline *cl,
10489 __rte_unused void *data)
10491 struct cmd_flow_director_result *res = parsed_result;
10493 struct rte_pmd_i40e_flow_type_mapping
10494 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10495 struct rte_pmd_i40e_pkt_template_conf conf;
10496 uint16_t flow_type = str2flowtype(res->flow_type);
10497 uint16_t i, port = res->port_id;
10500 memset(&conf, 0, sizeof(conf));
10502 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10503 fprintf(stderr, "Invalid flow type specified.\n");
10506 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10510 if (mapping[flow_type].pctype == 0ULL) {
10511 fprintf(stderr, "Invalid flow type specified.\n");
10514 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10515 if (mapping[flow_type].pctype & (1ULL << i)) {
10516 conf.input.pctype = i;
10521 conf.input.packet = open_file(res->filepath,
10522 &conf.input.length);
10523 if (!conf.input.packet)
10525 if (!strcmp(res->drop, "drop"))
10526 conf.action.behavior =
10527 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10529 conf.action.behavior =
10530 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10531 conf.action.report_status =
10532 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10533 conf.action.rx_queue = res->queue_id;
10534 conf.soft_id = res->fd_id_value;
10535 add = strcmp(res->ops, "del") ? 1 : 0;
10536 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10540 fprintf(stderr, "flow director config error: (%s)\n",
10542 close_file(conf.input.packet);
10545 cmdline_parse_token_string_t cmd_flow_director_filter =
10546 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10547 flow_director_filter, "flow_director_filter");
10548 cmdline_parse_token_num_t cmd_flow_director_port_id =
10549 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10550 port_id, RTE_UINT16);
10551 cmdline_parse_token_string_t cmd_flow_director_ops =
10552 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10553 ops, "add#del#update");
10554 cmdline_parse_token_string_t cmd_flow_director_flow =
10555 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10557 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10558 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10560 cmdline_parse_token_string_t cmd_flow_director_drop =
10561 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10563 cmdline_parse_token_string_t cmd_flow_director_queue =
10564 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10566 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10567 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10568 queue_id, RTE_UINT16);
10569 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10570 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10572 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10573 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10574 fd_id_value, RTE_UINT32);
10576 cmdline_parse_token_string_t cmd_flow_director_mode =
10577 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10579 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10580 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10581 mode_value, "raw");
10582 cmdline_parse_token_string_t cmd_flow_director_packet =
10583 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10585 cmdline_parse_token_string_t cmd_flow_director_filepath =
10586 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10589 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10590 .f = cmd_flow_director_filter_parsed,
10592 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10593 "director entry on NIC",
10595 (void *)&cmd_flow_director_filter,
10596 (void *)&cmd_flow_director_port_id,
10597 (void *)&cmd_flow_director_mode,
10598 (void *)&cmd_flow_director_mode_raw,
10599 (void *)&cmd_flow_director_ops,
10600 (void *)&cmd_flow_director_flow,
10601 (void *)&cmd_flow_director_flow_type,
10602 (void *)&cmd_flow_director_drop,
10603 (void *)&cmd_flow_director_queue,
10604 (void *)&cmd_flow_director_queue_id,
10605 (void *)&cmd_flow_director_fd_id,
10606 (void *)&cmd_flow_director_fd_id_value,
10607 (void *)&cmd_flow_director_packet,
10608 (void *)&cmd_flow_director_filepath,
10613 #endif /* RTE_NET_I40E */
10615 /* *** deal with flow director mask *** */
10616 struct cmd_flow_director_mask_result {
10617 cmdline_fixed_string_t flow_director_mask;
10619 cmdline_fixed_string_t mode;
10620 cmdline_fixed_string_t mode_value;
10621 cmdline_fixed_string_t vlan;
10622 uint16_t vlan_mask;
10623 cmdline_fixed_string_t src_mask;
10624 cmdline_ipaddr_t ipv4_src;
10625 cmdline_ipaddr_t ipv6_src;
10627 cmdline_fixed_string_t dst_mask;
10628 cmdline_ipaddr_t ipv4_dst;
10629 cmdline_ipaddr_t ipv6_dst;
10631 cmdline_fixed_string_t mac;
10632 uint8_t mac_addr_byte_mask;
10633 cmdline_fixed_string_t tunnel_id;
10634 uint32_t tunnel_id_mask;
10635 cmdline_fixed_string_t tunnel_type;
10636 uint8_t tunnel_type_mask;
10640 cmd_flow_director_mask_parsed(void *parsed_result,
10641 __rte_unused struct cmdline *cl,
10642 __rte_unused void *data)
10644 struct cmd_flow_director_mask_result *res = parsed_result;
10645 struct rte_eth_fdir_masks *mask;
10646 struct rte_port *port;
10648 port = &ports[res->port_id];
10649 /** Check if the port is not started **/
10650 if (port->port_status != RTE_PORT_STOPPED) {
10651 fprintf(stderr, "Please stop port %d first\n", res->port_id);
10655 mask = &port->dev_conf.fdir_conf.mask;
10657 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10658 if (strcmp(res->mode_value, "MAC-VLAN")) {
10659 fprintf(stderr, "Please set mode to MAC-VLAN.\n");
10663 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10664 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10665 if (strcmp(res->mode_value, "Tunnel")) {
10666 fprintf(stderr, "Please set mode to Tunnel.\n");
10670 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10671 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10672 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10673 mask->tunnel_type_mask = res->tunnel_type_mask;
10675 if (strcmp(res->mode_value, "IP")) {
10676 fprintf(stderr, "Please set mode to IP.\n");
10680 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10681 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10682 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10683 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10684 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10685 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10686 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10689 cmd_reconfig_device_queue(res->port_id, 1, 1);
10692 cmdline_parse_token_string_t cmd_flow_director_mask =
10693 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10694 flow_director_mask, "flow_director_mask");
10695 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10696 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10697 port_id, RTE_UINT16);
10698 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10699 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10701 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10702 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10703 vlan_mask, RTE_UINT16);
10704 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10705 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10706 src_mask, "src_mask");
10707 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10708 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10710 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10711 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10713 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10714 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10715 port_src, RTE_UINT16);
10716 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10717 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10718 dst_mask, "dst_mask");
10719 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10720 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10722 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10723 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10725 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10726 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10727 port_dst, RTE_UINT16);
10729 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10730 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10732 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10733 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10735 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10736 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10737 mode_value, "MAC-VLAN");
10738 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10739 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10740 mode_value, "Tunnel");
10741 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10742 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10744 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10745 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10746 mac_addr_byte_mask, RTE_UINT8);
10747 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10748 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10749 tunnel_type, "tunnel-type");
10750 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10751 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10752 tunnel_type_mask, RTE_UINT8);
10753 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10754 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10755 tunnel_id, "tunnel-id");
10756 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10757 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10758 tunnel_id_mask, RTE_UINT32);
10760 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10761 .f = cmd_flow_director_mask_parsed,
10763 .help_str = "flow_director_mask ... : "
10764 "Set IP mode flow director's mask on NIC",
10766 (void *)&cmd_flow_director_mask,
10767 (void *)&cmd_flow_director_mask_port_id,
10768 (void *)&cmd_flow_director_mask_mode,
10769 (void *)&cmd_flow_director_mask_mode_ip,
10770 (void *)&cmd_flow_director_mask_vlan,
10771 (void *)&cmd_flow_director_mask_vlan_value,
10772 (void *)&cmd_flow_director_mask_src,
10773 (void *)&cmd_flow_director_mask_ipv4_src,
10774 (void *)&cmd_flow_director_mask_ipv6_src,
10775 (void *)&cmd_flow_director_mask_port_src,
10776 (void *)&cmd_flow_director_mask_dst,
10777 (void *)&cmd_flow_director_mask_ipv4_dst,
10778 (void *)&cmd_flow_director_mask_ipv6_dst,
10779 (void *)&cmd_flow_director_mask_port_dst,
10784 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10785 .f = cmd_flow_director_mask_parsed,
10787 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10788 "flow director's mask on NIC",
10790 (void *)&cmd_flow_director_mask,
10791 (void *)&cmd_flow_director_mask_port_id,
10792 (void *)&cmd_flow_director_mask_mode,
10793 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10794 (void *)&cmd_flow_director_mask_vlan,
10795 (void *)&cmd_flow_director_mask_vlan_value,
10800 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10801 .f = cmd_flow_director_mask_parsed,
10803 .help_str = "flow_director_mask ... : Set tunnel mode "
10804 "flow director's mask on NIC",
10806 (void *)&cmd_flow_director_mask,
10807 (void *)&cmd_flow_director_mask_port_id,
10808 (void *)&cmd_flow_director_mask_mode,
10809 (void *)&cmd_flow_director_mask_mode_tunnel,
10810 (void *)&cmd_flow_director_mask_vlan,
10811 (void *)&cmd_flow_director_mask_vlan_value,
10812 (void *)&cmd_flow_director_mask_mac,
10813 (void *)&cmd_flow_director_mask_mac_value,
10814 (void *)&cmd_flow_director_mask_tunnel_type,
10815 (void *)&cmd_flow_director_mask_tunnel_type_value,
10816 (void *)&cmd_flow_director_mask_tunnel_id,
10817 (void *)&cmd_flow_director_mask_tunnel_id_value,
10822 /* *** deal with flow director flexible payload configuration *** */
10823 struct cmd_flow_director_flexpayload_result {
10824 cmdline_fixed_string_t flow_director_flexpayload;
10826 cmdline_fixed_string_t payload_layer;
10827 cmdline_fixed_string_t payload_cfg;
10831 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10834 const char *p, *p0 = q_arg;
10836 unsigned long int_fld;
10837 char *str_fld[max_num];
10842 p = strchr(p0, '(');
10846 p0 = strchr(p, ')');
10851 if (size >= sizeof(s))
10854 snprintf(s, sizeof(s), "%.*s", size, p);
10855 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10856 if (ret < 0 || ret > max_num)
10858 for (i = 0; i < ret; i++) {
10860 int_fld = strtoul(str_fld[i], &end, 0);
10861 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10863 offsets[i] = (uint16_t)int_fld;
10869 cmd_flow_director_flxpld_parsed(void *parsed_result,
10870 __rte_unused struct cmdline *cl,
10871 __rte_unused void *data)
10873 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10874 struct rte_eth_flex_payload_cfg flex_cfg;
10875 struct rte_port *port;
10878 port = &ports[res->port_id];
10879 /** Check if the port is not started **/
10880 if (port->port_status != RTE_PORT_STOPPED) {
10881 fprintf(stderr, "Please stop port %d first\n", res->port_id);
10885 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10887 if (!strcmp(res->payload_layer, "raw"))
10888 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10889 else if (!strcmp(res->payload_layer, "l2"))
10890 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10891 else if (!strcmp(res->payload_layer, "l3"))
10892 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10893 else if (!strcmp(res->payload_layer, "l4"))
10894 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10896 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10897 RTE_ETH_FDIR_MAX_FLEXLEN);
10899 fprintf(stderr, "error: Cannot parse flex payload input.\n");
10903 fdir_set_flex_payload(res->port_id, &flex_cfg);
10904 cmd_reconfig_device_queue(res->port_id, 1, 1);
10907 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10908 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10909 flow_director_flexpayload,
10910 "flow_director_flex_payload");
10911 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10912 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10913 port_id, RTE_UINT16);
10914 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10915 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10916 payload_layer, "raw#l2#l3#l4");
10917 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10918 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10919 payload_cfg, NULL);
10921 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10922 .f = cmd_flow_director_flxpld_parsed,
10924 .help_str = "flow_director_flexpayload ... : "
10925 "Set flow director's flex payload on NIC",
10927 (void *)&cmd_flow_director_flexpayload,
10928 (void *)&cmd_flow_director_flexpayload_port_id,
10929 (void *)&cmd_flow_director_flexpayload_payload_layer,
10930 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10935 /* Generic flow interface command. */
10936 extern cmdline_parse_inst_t cmd_flow;
10938 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10939 struct cmd_mcast_addr_result {
10940 cmdline_fixed_string_t mcast_addr_cmd;
10941 cmdline_fixed_string_t what;
10943 struct rte_ether_addr mc_addr;
10946 static void cmd_mcast_addr_parsed(void *parsed_result,
10947 __rte_unused struct cmdline *cl,
10948 __rte_unused void *data)
10950 struct cmd_mcast_addr_result *res = parsed_result;
10952 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
10954 "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
10955 RTE_ETHER_ADDR_BYTES(&res->mc_addr));
10958 if (strcmp(res->what, "add") == 0)
10959 mcast_addr_add(res->port_num, &res->mc_addr);
10961 mcast_addr_remove(res->port_num, &res->mc_addr);
10964 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10965 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10966 mcast_addr_cmd, "mcast_addr");
10967 cmdline_parse_token_string_t cmd_mcast_addr_what =
10968 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10970 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10971 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
10973 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10974 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10976 cmdline_parse_inst_t cmd_mcast_addr = {
10977 .f = cmd_mcast_addr_parsed,
10979 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10980 "Add/Remove multicast MAC address on port_id",
10982 (void *)&cmd_mcast_addr_cmd,
10983 (void *)&cmd_mcast_addr_what,
10984 (void *)&cmd_mcast_addr_portnum,
10985 (void *)&cmd_mcast_addr_addr,
10990 /* vf vlan anti spoof configuration */
10992 /* Common result structure for vf vlan anti spoof */
10993 struct cmd_vf_vlan_anti_spoof_result {
10994 cmdline_fixed_string_t set;
10995 cmdline_fixed_string_t vf;
10996 cmdline_fixed_string_t vlan;
10997 cmdline_fixed_string_t antispoof;
11000 cmdline_fixed_string_t on_off;
11003 /* Common CLI fields for vf vlan anti spoof enable disable */
11004 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
11005 TOKEN_STRING_INITIALIZER
11006 (struct cmd_vf_vlan_anti_spoof_result,
11008 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
11009 TOKEN_STRING_INITIALIZER
11010 (struct cmd_vf_vlan_anti_spoof_result,
11012 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
11013 TOKEN_STRING_INITIALIZER
11014 (struct cmd_vf_vlan_anti_spoof_result,
11016 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
11017 TOKEN_STRING_INITIALIZER
11018 (struct cmd_vf_vlan_anti_spoof_result,
11019 antispoof, "antispoof");
11020 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
11021 TOKEN_NUM_INITIALIZER
11022 (struct cmd_vf_vlan_anti_spoof_result,
11023 port_id, RTE_UINT16);
11024 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
11025 TOKEN_NUM_INITIALIZER
11026 (struct cmd_vf_vlan_anti_spoof_result,
11027 vf_id, RTE_UINT32);
11028 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11029 TOKEN_STRING_INITIALIZER
11030 (struct cmd_vf_vlan_anti_spoof_result,
11034 cmd_set_vf_vlan_anti_spoof_parsed(
11035 void *parsed_result,
11036 __rte_unused struct cmdline *cl,
11037 __rte_unused void *data)
11039 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
11040 int ret = -ENOTSUP;
11042 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11044 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11047 #ifdef RTE_NET_IXGBE
11048 if (ret == -ENOTSUP)
11049 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11050 res->vf_id, is_on);
11052 #ifdef RTE_NET_I40E
11053 if (ret == -ENOTSUP)
11054 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11055 res->vf_id, is_on);
11057 #ifdef RTE_NET_BNXT
11058 if (ret == -ENOTSUP)
11059 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11060 res->vf_id, is_on);
11067 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11070 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11073 fprintf(stderr, "function not implemented\n");
11076 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11080 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11081 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11083 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11085 (void *)&cmd_vf_vlan_anti_spoof_set,
11086 (void *)&cmd_vf_vlan_anti_spoof_vf,
11087 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11088 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11089 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11090 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11091 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11096 /* vf mac anti spoof configuration */
11098 /* Common result structure for vf mac anti spoof */
11099 struct cmd_vf_mac_anti_spoof_result {
11100 cmdline_fixed_string_t set;
11101 cmdline_fixed_string_t vf;
11102 cmdline_fixed_string_t mac;
11103 cmdline_fixed_string_t antispoof;
11106 cmdline_fixed_string_t on_off;
11109 /* Common CLI fields for vf mac anti spoof enable disable */
11110 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11111 TOKEN_STRING_INITIALIZER
11112 (struct cmd_vf_mac_anti_spoof_result,
11114 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11115 TOKEN_STRING_INITIALIZER
11116 (struct cmd_vf_mac_anti_spoof_result,
11118 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11119 TOKEN_STRING_INITIALIZER
11120 (struct cmd_vf_mac_anti_spoof_result,
11122 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11123 TOKEN_STRING_INITIALIZER
11124 (struct cmd_vf_mac_anti_spoof_result,
11125 antispoof, "antispoof");
11126 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11127 TOKEN_NUM_INITIALIZER
11128 (struct cmd_vf_mac_anti_spoof_result,
11129 port_id, RTE_UINT16);
11130 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11131 TOKEN_NUM_INITIALIZER
11132 (struct cmd_vf_mac_anti_spoof_result,
11133 vf_id, RTE_UINT32);
11134 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11135 TOKEN_STRING_INITIALIZER
11136 (struct cmd_vf_mac_anti_spoof_result,
11140 cmd_set_vf_mac_anti_spoof_parsed(
11141 void *parsed_result,
11142 __rte_unused struct cmdline *cl,
11143 __rte_unused void *data)
11145 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11146 int ret = -ENOTSUP;
11148 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11150 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11153 #ifdef RTE_NET_IXGBE
11154 if (ret == -ENOTSUP)
11155 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11156 res->vf_id, is_on);
11158 #ifdef RTE_NET_I40E
11159 if (ret == -ENOTSUP)
11160 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11161 res->vf_id, is_on);
11163 #ifdef RTE_NET_BNXT
11164 if (ret == -ENOTSUP)
11165 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11166 res->vf_id, is_on);
11173 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11174 res->vf_id, is_on);
11177 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11180 fprintf(stderr, "function not implemented\n");
11183 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11187 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11188 .f = cmd_set_vf_mac_anti_spoof_parsed,
11190 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11192 (void *)&cmd_vf_mac_anti_spoof_set,
11193 (void *)&cmd_vf_mac_anti_spoof_vf,
11194 (void *)&cmd_vf_mac_anti_spoof_mac,
11195 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11196 (void *)&cmd_vf_mac_anti_spoof_port_id,
11197 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11198 (void *)&cmd_vf_mac_anti_spoof_on_off,
11203 /* vf vlan strip queue configuration */
11205 /* Common result structure for vf mac anti spoof */
11206 struct cmd_vf_vlan_stripq_result {
11207 cmdline_fixed_string_t set;
11208 cmdline_fixed_string_t vf;
11209 cmdline_fixed_string_t vlan;
11210 cmdline_fixed_string_t stripq;
11213 cmdline_fixed_string_t on_off;
11216 /* Common CLI fields for vf vlan strip enable disable */
11217 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11218 TOKEN_STRING_INITIALIZER
11219 (struct cmd_vf_vlan_stripq_result,
11221 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11222 TOKEN_STRING_INITIALIZER
11223 (struct cmd_vf_vlan_stripq_result,
11225 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11226 TOKEN_STRING_INITIALIZER
11227 (struct cmd_vf_vlan_stripq_result,
11229 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11230 TOKEN_STRING_INITIALIZER
11231 (struct cmd_vf_vlan_stripq_result,
11233 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11234 TOKEN_NUM_INITIALIZER
11235 (struct cmd_vf_vlan_stripq_result,
11236 port_id, RTE_UINT16);
11237 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11238 TOKEN_NUM_INITIALIZER
11239 (struct cmd_vf_vlan_stripq_result,
11240 vf_id, RTE_UINT16);
11241 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11242 TOKEN_STRING_INITIALIZER
11243 (struct cmd_vf_vlan_stripq_result,
11247 cmd_set_vf_vlan_stripq_parsed(
11248 void *parsed_result,
11249 __rte_unused struct cmdline *cl,
11250 __rte_unused void *data)
11252 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11253 int ret = -ENOTSUP;
11255 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11257 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11260 #ifdef RTE_NET_IXGBE
11261 if (ret == -ENOTSUP)
11262 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11263 res->vf_id, is_on);
11265 #ifdef RTE_NET_I40E
11266 if (ret == -ENOTSUP)
11267 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11268 res->vf_id, is_on);
11270 #ifdef RTE_NET_BNXT
11271 if (ret == -ENOTSUP)
11272 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11273 res->vf_id, is_on);
11280 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11281 res->vf_id, is_on);
11284 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11287 fprintf(stderr, "function not implemented\n");
11290 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11294 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11295 .f = cmd_set_vf_vlan_stripq_parsed,
11297 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11299 (void *)&cmd_vf_vlan_stripq_set,
11300 (void *)&cmd_vf_vlan_stripq_vf,
11301 (void *)&cmd_vf_vlan_stripq_vlan,
11302 (void *)&cmd_vf_vlan_stripq_stripq,
11303 (void *)&cmd_vf_vlan_stripq_port_id,
11304 (void *)&cmd_vf_vlan_stripq_vf_id,
11305 (void *)&cmd_vf_vlan_stripq_on_off,
11310 /* vf vlan insert configuration */
11312 /* Common result structure for vf vlan insert */
11313 struct cmd_vf_vlan_insert_result {
11314 cmdline_fixed_string_t set;
11315 cmdline_fixed_string_t vf;
11316 cmdline_fixed_string_t vlan;
11317 cmdline_fixed_string_t insert;
11323 /* Common CLI fields for vf vlan insert enable disable */
11324 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11325 TOKEN_STRING_INITIALIZER
11326 (struct cmd_vf_vlan_insert_result,
11328 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11329 TOKEN_STRING_INITIALIZER
11330 (struct cmd_vf_vlan_insert_result,
11332 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11333 TOKEN_STRING_INITIALIZER
11334 (struct cmd_vf_vlan_insert_result,
11336 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11337 TOKEN_STRING_INITIALIZER
11338 (struct cmd_vf_vlan_insert_result,
11340 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11341 TOKEN_NUM_INITIALIZER
11342 (struct cmd_vf_vlan_insert_result,
11343 port_id, RTE_UINT16);
11344 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11345 TOKEN_NUM_INITIALIZER
11346 (struct cmd_vf_vlan_insert_result,
11347 vf_id, RTE_UINT16);
11348 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11349 TOKEN_NUM_INITIALIZER
11350 (struct cmd_vf_vlan_insert_result,
11351 vlan_id, RTE_UINT16);
11354 cmd_set_vf_vlan_insert_parsed(
11355 void *parsed_result,
11356 __rte_unused struct cmdline *cl,
11357 __rte_unused void *data)
11359 struct cmd_vf_vlan_insert_result *res = parsed_result;
11360 int ret = -ENOTSUP;
11362 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11365 #ifdef RTE_NET_IXGBE
11366 if (ret == -ENOTSUP)
11367 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11370 #ifdef RTE_NET_I40E
11371 if (ret == -ENOTSUP)
11372 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11375 #ifdef RTE_NET_BNXT
11376 if (ret == -ENOTSUP)
11377 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11385 fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
11386 res->vf_id, res->vlan_id);
11389 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11392 fprintf(stderr, "function not implemented\n");
11395 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11399 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11400 .f = cmd_set_vf_vlan_insert_parsed,
11402 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11404 (void *)&cmd_vf_vlan_insert_set,
11405 (void *)&cmd_vf_vlan_insert_vf,
11406 (void *)&cmd_vf_vlan_insert_vlan,
11407 (void *)&cmd_vf_vlan_insert_insert,
11408 (void *)&cmd_vf_vlan_insert_port_id,
11409 (void *)&cmd_vf_vlan_insert_vf_id,
11410 (void *)&cmd_vf_vlan_insert_vlan_id,
11415 /* tx loopback configuration */
11417 /* Common result structure for tx loopback */
11418 struct cmd_tx_loopback_result {
11419 cmdline_fixed_string_t set;
11420 cmdline_fixed_string_t tx;
11421 cmdline_fixed_string_t loopback;
11423 cmdline_fixed_string_t on_off;
11426 /* Common CLI fields for tx loopback enable disable */
11427 cmdline_parse_token_string_t cmd_tx_loopback_set =
11428 TOKEN_STRING_INITIALIZER
11429 (struct cmd_tx_loopback_result,
11431 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11432 TOKEN_STRING_INITIALIZER
11433 (struct cmd_tx_loopback_result,
11435 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11436 TOKEN_STRING_INITIALIZER
11437 (struct cmd_tx_loopback_result,
11438 loopback, "loopback");
11439 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11440 TOKEN_NUM_INITIALIZER
11441 (struct cmd_tx_loopback_result,
11442 port_id, RTE_UINT16);
11443 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11444 TOKEN_STRING_INITIALIZER
11445 (struct cmd_tx_loopback_result,
11449 cmd_set_tx_loopback_parsed(
11450 void *parsed_result,
11451 __rte_unused struct cmdline *cl,
11452 __rte_unused void *data)
11454 struct cmd_tx_loopback_result *res = parsed_result;
11455 int ret = -ENOTSUP;
11457 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11459 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11462 #ifdef RTE_NET_IXGBE
11463 if (ret == -ENOTSUP)
11464 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11466 #ifdef RTE_NET_I40E
11467 if (ret == -ENOTSUP)
11468 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11470 #ifdef RTE_NET_BNXT
11471 if (ret == -ENOTSUP)
11472 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11474 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11475 if (ret == -ENOTSUP)
11476 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11483 fprintf(stderr, "invalid is_on %d\n", is_on);
11486 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11489 fprintf(stderr, "function not implemented\n");
11492 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11496 cmdline_parse_inst_t cmd_set_tx_loopback = {
11497 .f = cmd_set_tx_loopback_parsed,
11499 .help_str = "set tx loopback <port_id> on|off",
11501 (void *)&cmd_tx_loopback_set,
11502 (void *)&cmd_tx_loopback_tx,
11503 (void *)&cmd_tx_loopback_loopback,
11504 (void *)&cmd_tx_loopback_port_id,
11505 (void *)&cmd_tx_loopback_on_off,
11510 /* all queues drop enable configuration */
11512 /* Common result structure for all queues drop enable */
11513 struct cmd_all_queues_drop_en_result {
11514 cmdline_fixed_string_t set;
11515 cmdline_fixed_string_t all;
11516 cmdline_fixed_string_t queues;
11517 cmdline_fixed_string_t drop;
11519 cmdline_fixed_string_t on_off;
11522 /* Common CLI fields for tx loopback enable disable */
11523 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11524 TOKEN_STRING_INITIALIZER
11525 (struct cmd_all_queues_drop_en_result,
11527 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11528 TOKEN_STRING_INITIALIZER
11529 (struct cmd_all_queues_drop_en_result,
11531 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11532 TOKEN_STRING_INITIALIZER
11533 (struct cmd_all_queues_drop_en_result,
11535 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11536 TOKEN_STRING_INITIALIZER
11537 (struct cmd_all_queues_drop_en_result,
11539 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11540 TOKEN_NUM_INITIALIZER
11541 (struct cmd_all_queues_drop_en_result,
11542 port_id, RTE_UINT16);
11543 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11544 TOKEN_STRING_INITIALIZER
11545 (struct cmd_all_queues_drop_en_result,
11549 cmd_set_all_queues_drop_en_parsed(
11550 void *parsed_result,
11551 __rte_unused struct cmdline *cl,
11552 __rte_unused void *data)
11554 struct cmd_all_queues_drop_en_result *res = parsed_result;
11555 int ret = -ENOTSUP;
11556 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11558 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11561 #ifdef RTE_NET_IXGBE
11562 if (ret == -ENOTSUP)
11563 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11565 #ifdef RTE_NET_BNXT
11566 if (ret == -ENOTSUP)
11567 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11573 fprintf(stderr, "invalid is_on %d\n", is_on);
11576 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11579 fprintf(stderr, "function not implemented\n");
11582 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11586 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11587 .f = cmd_set_all_queues_drop_en_parsed,
11589 .help_str = "set all queues drop <port_id> on|off",
11591 (void *)&cmd_all_queues_drop_en_set,
11592 (void *)&cmd_all_queues_drop_en_all,
11593 (void *)&cmd_all_queues_drop_en_queues,
11594 (void *)&cmd_all_queues_drop_en_drop,
11595 (void *)&cmd_all_queues_drop_en_port_id,
11596 (void *)&cmd_all_queues_drop_en_on_off,
11601 /* vf split drop enable configuration */
11603 /* Common result structure for vf split drop enable */
11604 struct cmd_vf_split_drop_en_result {
11605 cmdline_fixed_string_t set;
11606 cmdline_fixed_string_t vf;
11607 cmdline_fixed_string_t split;
11608 cmdline_fixed_string_t drop;
11611 cmdline_fixed_string_t on_off;
11614 /* Common CLI fields for vf split drop enable disable */
11615 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11616 TOKEN_STRING_INITIALIZER
11617 (struct cmd_vf_split_drop_en_result,
11619 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11620 TOKEN_STRING_INITIALIZER
11621 (struct cmd_vf_split_drop_en_result,
11623 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11624 TOKEN_STRING_INITIALIZER
11625 (struct cmd_vf_split_drop_en_result,
11627 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11628 TOKEN_STRING_INITIALIZER
11629 (struct cmd_vf_split_drop_en_result,
11631 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11632 TOKEN_NUM_INITIALIZER
11633 (struct cmd_vf_split_drop_en_result,
11634 port_id, RTE_UINT16);
11635 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11636 TOKEN_NUM_INITIALIZER
11637 (struct cmd_vf_split_drop_en_result,
11638 vf_id, RTE_UINT16);
11639 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11640 TOKEN_STRING_INITIALIZER
11641 (struct cmd_vf_split_drop_en_result,
11645 cmd_set_vf_split_drop_en_parsed(
11646 void *parsed_result,
11647 __rte_unused struct cmdline *cl,
11648 __rte_unused void *data)
11650 struct cmd_vf_split_drop_en_result *res = parsed_result;
11651 int ret = -ENOTSUP;
11652 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11654 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11657 #ifdef RTE_NET_IXGBE
11658 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11665 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11666 res->vf_id, is_on);
11669 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11672 fprintf(stderr, "not supported on port %d\n", res->port_id);
11675 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11679 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11680 .f = cmd_set_vf_split_drop_en_parsed,
11682 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11684 (void *)&cmd_vf_split_drop_en_set,
11685 (void *)&cmd_vf_split_drop_en_vf,
11686 (void *)&cmd_vf_split_drop_en_split,
11687 (void *)&cmd_vf_split_drop_en_drop,
11688 (void *)&cmd_vf_split_drop_en_port_id,
11689 (void *)&cmd_vf_split_drop_en_vf_id,
11690 (void *)&cmd_vf_split_drop_en_on_off,
11695 /* vf mac address configuration */
11697 /* Common result structure for vf mac address */
11698 struct cmd_set_vf_mac_addr_result {
11699 cmdline_fixed_string_t set;
11700 cmdline_fixed_string_t vf;
11701 cmdline_fixed_string_t mac;
11702 cmdline_fixed_string_t addr;
11705 struct rte_ether_addr mac_addr;
11709 /* Common CLI fields for vf split drop enable disable */
11710 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11711 TOKEN_STRING_INITIALIZER
11712 (struct cmd_set_vf_mac_addr_result,
11714 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11715 TOKEN_STRING_INITIALIZER
11716 (struct cmd_set_vf_mac_addr_result,
11718 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11719 TOKEN_STRING_INITIALIZER
11720 (struct cmd_set_vf_mac_addr_result,
11722 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11723 TOKEN_STRING_INITIALIZER
11724 (struct cmd_set_vf_mac_addr_result,
11726 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11727 TOKEN_NUM_INITIALIZER
11728 (struct cmd_set_vf_mac_addr_result,
11729 port_id, RTE_UINT16);
11730 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11731 TOKEN_NUM_INITIALIZER
11732 (struct cmd_set_vf_mac_addr_result,
11733 vf_id, RTE_UINT16);
11734 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11735 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11739 cmd_set_vf_mac_addr_parsed(
11740 void *parsed_result,
11741 __rte_unused struct cmdline *cl,
11742 __rte_unused void *data)
11744 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11745 int ret = -ENOTSUP;
11747 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11750 #ifdef RTE_NET_IXGBE
11751 if (ret == -ENOTSUP)
11752 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11755 #ifdef RTE_NET_I40E
11756 if (ret == -ENOTSUP)
11757 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11760 #ifdef RTE_NET_BNXT
11761 if (ret == -ENOTSUP)
11762 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11770 fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
11773 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11776 fprintf(stderr, "function not implemented\n");
11779 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11783 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11784 .f = cmd_set_vf_mac_addr_parsed,
11786 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11788 (void *)&cmd_set_vf_mac_addr_set,
11789 (void *)&cmd_set_vf_mac_addr_vf,
11790 (void *)&cmd_set_vf_mac_addr_mac,
11791 (void *)&cmd_set_vf_mac_addr_addr,
11792 (void *)&cmd_set_vf_mac_addr_port_id,
11793 (void *)&cmd_set_vf_mac_addr_vf_id,
11794 (void *)&cmd_set_vf_mac_addr_mac_addr,
11799 /* MACsec configuration */
11801 /* Common result structure for MACsec offload enable */
11802 struct cmd_macsec_offload_on_result {
11803 cmdline_fixed_string_t set;
11804 cmdline_fixed_string_t macsec;
11805 cmdline_fixed_string_t offload;
11807 cmdline_fixed_string_t on;
11808 cmdline_fixed_string_t encrypt;
11809 cmdline_fixed_string_t en_on_off;
11810 cmdline_fixed_string_t replay_protect;
11811 cmdline_fixed_string_t rp_on_off;
11814 /* Common CLI fields for MACsec offload disable */
11815 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11816 TOKEN_STRING_INITIALIZER
11817 (struct cmd_macsec_offload_on_result,
11819 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11820 TOKEN_STRING_INITIALIZER
11821 (struct cmd_macsec_offload_on_result,
11823 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11824 TOKEN_STRING_INITIALIZER
11825 (struct cmd_macsec_offload_on_result,
11826 offload, "offload");
11827 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11828 TOKEN_NUM_INITIALIZER
11829 (struct cmd_macsec_offload_on_result,
11830 port_id, RTE_UINT16);
11831 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11832 TOKEN_STRING_INITIALIZER
11833 (struct cmd_macsec_offload_on_result,
11835 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11836 TOKEN_STRING_INITIALIZER
11837 (struct cmd_macsec_offload_on_result,
11838 encrypt, "encrypt");
11839 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11840 TOKEN_STRING_INITIALIZER
11841 (struct cmd_macsec_offload_on_result,
11842 en_on_off, "on#off");
11843 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11844 TOKEN_STRING_INITIALIZER
11845 (struct cmd_macsec_offload_on_result,
11846 replay_protect, "replay-protect");
11847 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11848 TOKEN_STRING_INITIALIZER
11849 (struct cmd_macsec_offload_on_result,
11850 rp_on_off, "on#off");
11853 cmd_set_macsec_offload_on_parsed(
11854 void *parsed_result,
11855 __rte_unused struct cmdline *cl,
11856 __rte_unused void *data)
11858 struct cmd_macsec_offload_on_result *res = parsed_result;
11859 int ret = -ENOTSUP;
11860 portid_t port_id = res->port_id;
11861 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11862 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11863 struct rte_eth_dev_info dev_info;
11865 if (port_id_is_invalid(port_id, ENABLED_WARN))
11867 if (!port_is_stopped(port_id)) {
11868 fprintf(stderr, "Please stop port %d first\n", port_id);
11872 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11876 if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) {
11877 #ifdef RTE_NET_IXGBE
11878 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11886 ports[port_id].dev_conf.txmode.offloads |=
11887 RTE_ETH_TX_OFFLOAD_MACSEC_INSERT;
11888 cmd_reconfig_device_queue(port_id, 1, 1);
11891 fprintf(stderr, "invalid port_id %d\n", port_id);
11894 fprintf(stderr, "not supported on port %d\n", port_id);
11897 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11901 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11902 .f = cmd_set_macsec_offload_on_parsed,
11904 .help_str = "set macsec offload <port_id> on "
11905 "encrypt on|off replay-protect on|off",
11907 (void *)&cmd_macsec_offload_on_set,
11908 (void *)&cmd_macsec_offload_on_macsec,
11909 (void *)&cmd_macsec_offload_on_offload,
11910 (void *)&cmd_macsec_offload_on_port_id,
11911 (void *)&cmd_macsec_offload_on_on,
11912 (void *)&cmd_macsec_offload_on_encrypt,
11913 (void *)&cmd_macsec_offload_on_en_on_off,
11914 (void *)&cmd_macsec_offload_on_replay_protect,
11915 (void *)&cmd_macsec_offload_on_rp_on_off,
11920 /* Common result structure for MACsec offload disable */
11921 struct cmd_macsec_offload_off_result {
11922 cmdline_fixed_string_t set;
11923 cmdline_fixed_string_t macsec;
11924 cmdline_fixed_string_t offload;
11926 cmdline_fixed_string_t off;
11929 /* Common CLI fields for MACsec offload disable */
11930 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11931 TOKEN_STRING_INITIALIZER
11932 (struct cmd_macsec_offload_off_result,
11934 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11935 TOKEN_STRING_INITIALIZER
11936 (struct cmd_macsec_offload_off_result,
11938 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11939 TOKEN_STRING_INITIALIZER
11940 (struct cmd_macsec_offload_off_result,
11941 offload, "offload");
11942 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11943 TOKEN_NUM_INITIALIZER
11944 (struct cmd_macsec_offload_off_result,
11945 port_id, RTE_UINT16);
11946 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11947 TOKEN_STRING_INITIALIZER
11948 (struct cmd_macsec_offload_off_result,
11952 cmd_set_macsec_offload_off_parsed(
11953 void *parsed_result,
11954 __rte_unused struct cmdline *cl,
11955 __rte_unused void *data)
11957 struct cmd_macsec_offload_off_result *res = parsed_result;
11958 int ret = -ENOTSUP;
11959 struct rte_eth_dev_info dev_info;
11960 portid_t port_id = res->port_id;
11962 if (port_id_is_invalid(port_id, ENABLED_WARN))
11964 if (!port_is_stopped(port_id)) {
11965 fprintf(stderr, "Please stop port %d first\n", port_id);
11969 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11973 if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) {
11974 #ifdef RTE_NET_IXGBE
11975 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11980 ports[port_id].dev_conf.txmode.offloads &=
11981 ~RTE_ETH_TX_OFFLOAD_MACSEC_INSERT;
11982 cmd_reconfig_device_queue(port_id, 1, 1);
11985 fprintf(stderr, "invalid port_id %d\n", port_id);
11988 fprintf(stderr, "not supported on port %d\n", port_id);
11991 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11995 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11996 .f = cmd_set_macsec_offload_off_parsed,
11998 .help_str = "set macsec offload <port_id> off",
12000 (void *)&cmd_macsec_offload_off_set,
12001 (void *)&cmd_macsec_offload_off_macsec,
12002 (void *)&cmd_macsec_offload_off_offload,
12003 (void *)&cmd_macsec_offload_off_port_id,
12004 (void *)&cmd_macsec_offload_off_off,
12009 /* Common result structure for MACsec secure connection configure */
12010 struct cmd_macsec_sc_result {
12011 cmdline_fixed_string_t set;
12012 cmdline_fixed_string_t macsec;
12013 cmdline_fixed_string_t sc;
12014 cmdline_fixed_string_t tx_rx;
12016 struct rte_ether_addr mac;
12020 /* Common CLI fields for MACsec secure connection configure */
12021 cmdline_parse_token_string_t cmd_macsec_sc_set =
12022 TOKEN_STRING_INITIALIZER
12023 (struct cmd_macsec_sc_result,
12025 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
12026 TOKEN_STRING_INITIALIZER
12027 (struct cmd_macsec_sc_result,
12029 cmdline_parse_token_string_t cmd_macsec_sc_sc =
12030 TOKEN_STRING_INITIALIZER
12031 (struct cmd_macsec_sc_result,
12033 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
12034 TOKEN_STRING_INITIALIZER
12035 (struct cmd_macsec_sc_result,
12037 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
12038 TOKEN_NUM_INITIALIZER
12039 (struct cmd_macsec_sc_result,
12040 port_id, RTE_UINT16);
12041 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
12042 TOKEN_ETHERADDR_INITIALIZER
12043 (struct cmd_macsec_sc_result,
12045 cmdline_parse_token_num_t cmd_macsec_sc_pi =
12046 TOKEN_NUM_INITIALIZER
12047 (struct cmd_macsec_sc_result,
12051 cmd_set_macsec_sc_parsed(
12052 void *parsed_result,
12053 __rte_unused struct cmdline *cl,
12054 __rte_unused void *data)
12056 struct cmd_macsec_sc_result *res = parsed_result;
12057 int ret = -ENOTSUP;
12058 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12060 #ifdef RTE_NET_IXGBE
12062 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12063 res->mac.addr_bytes) :
12064 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12065 res->mac.addr_bytes, res->pi);
12067 RTE_SET_USED(is_tx);
12073 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12076 fprintf(stderr, "not supported on port %d\n", res->port_id);
12079 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12083 cmdline_parse_inst_t cmd_set_macsec_sc = {
12084 .f = cmd_set_macsec_sc_parsed,
12086 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12088 (void *)&cmd_macsec_sc_set,
12089 (void *)&cmd_macsec_sc_macsec,
12090 (void *)&cmd_macsec_sc_sc,
12091 (void *)&cmd_macsec_sc_tx_rx,
12092 (void *)&cmd_macsec_sc_port_id,
12093 (void *)&cmd_macsec_sc_mac,
12094 (void *)&cmd_macsec_sc_pi,
12099 /* Common result structure for MACsec secure connection configure */
12100 struct cmd_macsec_sa_result {
12101 cmdline_fixed_string_t set;
12102 cmdline_fixed_string_t macsec;
12103 cmdline_fixed_string_t sa;
12104 cmdline_fixed_string_t tx_rx;
12109 cmdline_fixed_string_t key;
12112 /* Common CLI fields for MACsec secure connection configure */
12113 cmdline_parse_token_string_t cmd_macsec_sa_set =
12114 TOKEN_STRING_INITIALIZER
12115 (struct cmd_macsec_sa_result,
12117 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12118 TOKEN_STRING_INITIALIZER
12119 (struct cmd_macsec_sa_result,
12121 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12122 TOKEN_STRING_INITIALIZER
12123 (struct cmd_macsec_sa_result,
12125 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12126 TOKEN_STRING_INITIALIZER
12127 (struct cmd_macsec_sa_result,
12129 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12130 TOKEN_NUM_INITIALIZER
12131 (struct cmd_macsec_sa_result,
12132 port_id, RTE_UINT16);
12133 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12134 TOKEN_NUM_INITIALIZER
12135 (struct cmd_macsec_sa_result,
12137 cmdline_parse_token_num_t cmd_macsec_sa_an =
12138 TOKEN_NUM_INITIALIZER
12139 (struct cmd_macsec_sa_result,
12141 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12142 TOKEN_NUM_INITIALIZER
12143 (struct cmd_macsec_sa_result,
12145 cmdline_parse_token_string_t cmd_macsec_sa_key =
12146 TOKEN_STRING_INITIALIZER
12147 (struct cmd_macsec_sa_result,
12151 cmd_set_macsec_sa_parsed(
12152 void *parsed_result,
12153 __rte_unused struct cmdline *cl,
12154 __rte_unused void *data)
12156 struct cmd_macsec_sa_result *res = parsed_result;
12157 int ret = -ENOTSUP;
12158 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12159 uint8_t key[16] = { 0 };
12165 key_len = strlen(res->key) / 2;
12169 for (i = 0; i < key_len; i++) {
12170 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12173 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12176 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12179 #ifdef RTE_NET_IXGBE
12181 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12182 res->idx, res->an, res->pn, key) :
12183 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12184 res->idx, res->an, res->pn, key);
12186 RTE_SET_USED(is_tx);
12193 fprintf(stderr, "invalid idx %d or an %d\n", res->idx, res->an);
12196 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12199 fprintf(stderr, "not supported on port %d\n", res->port_id);
12202 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12206 cmdline_parse_inst_t cmd_set_macsec_sa = {
12207 .f = cmd_set_macsec_sa_parsed,
12209 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12211 (void *)&cmd_macsec_sa_set,
12212 (void *)&cmd_macsec_sa_macsec,
12213 (void *)&cmd_macsec_sa_sa,
12214 (void *)&cmd_macsec_sa_tx_rx,
12215 (void *)&cmd_macsec_sa_port_id,
12216 (void *)&cmd_macsec_sa_idx,
12217 (void *)&cmd_macsec_sa_an,
12218 (void *)&cmd_macsec_sa_pn,
12219 (void *)&cmd_macsec_sa_key,
12224 /* VF unicast promiscuous mode configuration */
12226 /* Common result structure for VF unicast promiscuous mode */
12227 struct cmd_vf_promisc_result {
12228 cmdline_fixed_string_t set;
12229 cmdline_fixed_string_t vf;
12230 cmdline_fixed_string_t promisc;
12233 cmdline_fixed_string_t on_off;
12236 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12237 cmdline_parse_token_string_t cmd_vf_promisc_set =
12238 TOKEN_STRING_INITIALIZER
12239 (struct cmd_vf_promisc_result,
12241 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12242 TOKEN_STRING_INITIALIZER
12243 (struct cmd_vf_promisc_result,
12245 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12246 TOKEN_STRING_INITIALIZER
12247 (struct cmd_vf_promisc_result,
12248 promisc, "promisc");
12249 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12250 TOKEN_NUM_INITIALIZER
12251 (struct cmd_vf_promisc_result,
12252 port_id, RTE_UINT16);
12253 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12254 TOKEN_NUM_INITIALIZER
12255 (struct cmd_vf_promisc_result,
12256 vf_id, RTE_UINT32);
12257 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12258 TOKEN_STRING_INITIALIZER
12259 (struct cmd_vf_promisc_result,
12263 cmd_set_vf_promisc_parsed(
12264 void *parsed_result,
12265 __rte_unused struct cmdline *cl,
12266 __rte_unused void *data)
12268 struct cmd_vf_promisc_result *res = parsed_result;
12269 int ret = -ENOTSUP;
12271 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12273 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12276 #ifdef RTE_NET_I40E
12277 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12278 res->vf_id, is_on);
12285 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12288 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12291 fprintf(stderr, "function not implemented\n");
12294 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12298 cmdline_parse_inst_t cmd_set_vf_promisc = {
12299 .f = cmd_set_vf_promisc_parsed,
12301 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12302 "Set unicast promiscuous mode for a VF from the PF",
12304 (void *)&cmd_vf_promisc_set,
12305 (void *)&cmd_vf_promisc_vf,
12306 (void *)&cmd_vf_promisc_promisc,
12307 (void *)&cmd_vf_promisc_port_id,
12308 (void *)&cmd_vf_promisc_vf_id,
12309 (void *)&cmd_vf_promisc_on_off,
12314 /* VF multicast promiscuous mode configuration */
12316 /* Common result structure for VF multicast promiscuous mode */
12317 struct cmd_vf_allmulti_result {
12318 cmdline_fixed_string_t set;
12319 cmdline_fixed_string_t vf;
12320 cmdline_fixed_string_t allmulti;
12323 cmdline_fixed_string_t on_off;
12326 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12327 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12328 TOKEN_STRING_INITIALIZER
12329 (struct cmd_vf_allmulti_result,
12331 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12332 TOKEN_STRING_INITIALIZER
12333 (struct cmd_vf_allmulti_result,
12335 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12336 TOKEN_STRING_INITIALIZER
12337 (struct cmd_vf_allmulti_result,
12338 allmulti, "allmulti");
12339 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12340 TOKEN_NUM_INITIALIZER
12341 (struct cmd_vf_allmulti_result,
12342 port_id, RTE_UINT16);
12343 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12344 TOKEN_NUM_INITIALIZER
12345 (struct cmd_vf_allmulti_result,
12346 vf_id, RTE_UINT32);
12347 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12348 TOKEN_STRING_INITIALIZER
12349 (struct cmd_vf_allmulti_result,
12353 cmd_set_vf_allmulti_parsed(
12354 void *parsed_result,
12355 __rte_unused struct cmdline *cl,
12356 __rte_unused void *data)
12358 struct cmd_vf_allmulti_result *res = parsed_result;
12359 int ret = -ENOTSUP;
12361 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12363 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12366 #ifdef RTE_NET_I40E
12367 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12368 res->vf_id, is_on);
12375 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12378 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12381 fprintf(stderr, "function not implemented\n");
12384 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12388 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12389 .f = cmd_set_vf_allmulti_parsed,
12391 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12392 "Set multicast promiscuous mode for a VF from the PF",
12394 (void *)&cmd_vf_allmulti_set,
12395 (void *)&cmd_vf_allmulti_vf,
12396 (void *)&cmd_vf_allmulti_allmulti,
12397 (void *)&cmd_vf_allmulti_port_id,
12398 (void *)&cmd_vf_allmulti_vf_id,
12399 (void *)&cmd_vf_allmulti_on_off,
12404 /* vf broadcast mode configuration */
12406 /* Common result structure for vf broadcast */
12407 struct cmd_set_vf_broadcast_result {
12408 cmdline_fixed_string_t set;
12409 cmdline_fixed_string_t vf;
12410 cmdline_fixed_string_t broadcast;
12413 cmdline_fixed_string_t on_off;
12416 /* Common CLI fields for vf broadcast enable disable */
12417 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12418 TOKEN_STRING_INITIALIZER
12419 (struct cmd_set_vf_broadcast_result,
12421 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12422 TOKEN_STRING_INITIALIZER
12423 (struct cmd_set_vf_broadcast_result,
12425 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12426 TOKEN_STRING_INITIALIZER
12427 (struct cmd_set_vf_broadcast_result,
12428 broadcast, "broadcast");
12429 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12430 TOKEN_NUM_INITIALIZER
12431 (struct cmd_set_vf_broadcast_result,
12432 port_id, RTE_UINT16);
12433 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12434 TOKEN_NUM_INITIALIZER
12435 (struct cmd_set_vf_broadcast_result,
12436 vf_id, RTE_UINT16);
12437 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12438 TOKEN_STRING_INITIALIZER
12439 (struct cmd_set_vf_broadcast_result,
12443 cmd_set_vf_broadcast_parsed(
12444 void *parsed_result,
12445 __rte_unused struct cmdline *cl,
12446 __rte_unused void *data)
12448 struct cmd_set_vf_broadcast_result *res = parsed_result;
12449 int ret = -ENOTSUP;
12451 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12453 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12456 #ifdef RTE_NET_I40E
12457 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12458 res->vf_id, is_on);
12465 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12466 res->vf_id, is_on);
12469 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12472 fprintf(stderr, "function not implemented\n");
12475 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12479 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12480 .f = cmd_set_vf_broadcast_parsed,
12482 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12484 (void *)&cmd_set_vf_broadcast_set,
12485 (void *)&cmd_set_vf_broadcast_vf,
12486 (void *)&cmd_set_vf_broadcast_broadcast,
12487 (void *)&cmd_set_vf_broadcast_port_id,
12488 (void *)&cmd_set_vf_broadcast_vf_id,
12489 (void *)&cmd_set_vf_broadcast_on_off,
12494 /* vf vlan tag configuration */
12496 /* Common result structure for vf vlan tag */
12497 struct cmd_set_vf_vlan_tag_result {
12498 cmdline_fixed_string_t set;
12499 cmdline_fixed_string_t vf;
12500 cmdline_fixed_string_t vlan;
12501 cmdline_fixed_string_t tag;
12504 cmdline_fixed_string_t on_off;
12507 /* Common CLI fields for vf vlan tag enable disable */
12508 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12509 TOKEN_STRING_INITIALIZER
12510 (struct cmd_set_vf_vlan_tag_result,
12512 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12513 TOKEN_STRING_INITIALIZER
12514 (struct cmd_set_vf_vlan_tag_result,
12516 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12517 TOKEN_STRING_INITIALIZER
12518 (struct cmd_set_vf_vlan_tag_result,
12520 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12521 TOKEN_STRING_INITIALIZER
12522 (struct cmd_set_vf_vlan_tag_result,
12524 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12525 TOKEN_NUM_INITIALIZER
12526 (struct cmd_set_vf_vlan_tag_result,
12527 port_id, RTE_UINT16);
12528 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12529 TOKEN_NUM_INITIALIZER
12530 (struct cmd_set_vf_vlan_tag_result,
12531 vf_id, RTE_UINT16);
12532 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12533 TOKEN_STRING_INITIALIZER
12534 (struct cmd_set_vf_vlan_tag_result,
12538 cmd_set_vf_vlan_tag_parsed(
12539 void *parsed_result,
12540 __rte_unused struct cmdline *cl,
12541 __rte_unused void *data)
12543 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12544 int ret = -ENOTSUP;
12546 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12548 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12551 #ifdef RTE_NET_I40E
12552 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12553 res->vf_id, is_on);
12560 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12561 res->vf_id, is_on);
12564 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12567 fprintf(stderr, "function not implemented\n");
12570 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12574 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12575 .f = cmd_set_vf_vlan_tag_parsed,
12577 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12579 (void *)&cmd_set_vf_vlan_tag_set,
12580 (void *)&cmd_set_vf_vlan_tag_vf,
12581 (void *)&cmd_set_vf_vlan_tag_vlan,
12582 (void *)&cmd_set_vf_vlan_tag_tag,
12583 (void *)&cmd_set_vf_vlan_tag_port_id,
12584 (void *)&cmd_set_vf_vlan_tag_vf_id,
12585 (void *)&cmd_set_vf_vlan_tag_on_off,
12590 /* Common definition of VF and TC TX bandwidth configuration */
12591 struct cmd_vf_tc_bw_result {
12592 cmdline_fixed_string_t set;
12593 cmdline_fixed_string_t vf;
12594 cmdline_fixed_string_t tc;
12595 cmdline_fixed_string_t tx;
12596 cmdline_fixed_string_t min_bw;
12597 cmdline_fixed_string_t max_bw;
12598 cmdline_fixed_string_t strict_link_prio;
12603 cmdline_fixed_string_t bw_list;
12607 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12608 TOKEN_STRING_INITIALIZER
12609 (struct cmd_vf_tc_bw_result,
12611 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12612 TOKEN_STRING_INITIALIZER
12613 (struct cmd_vf_tc_bw_result,
12615 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12616 TOKEN_STRING_INITIALIZER
12617 (struct cmd_vf_tc_bw_result,
12619 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12620 TOKEN_STRING_INITIALIZER
12621 (struct cmd_vf_tc_bw_result,
12623 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12624 TOKEN_STRING_INITIALIZER
12625 (struct cmd_vf_tc_bw_result,
12626 strict_link_prio, "strict-link-priority");
12627 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12628 TOKEN_STRING_INITIALIZER
12629 (struct cmd_vf_tc_bw_result,
12630 min_bw, "min-bandwidth");
12631 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12632 TOKEN_STRING_INITIALIZER
12633 (struct cmd_vf_tc_bw_result,
12634 max_bw, "max-bandwidth");
12635 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12636 TOKEN_NUM_INITIALIZER
12637 (struct cmd_vf_tc_bw_result,
12638 port_id, RTE_UINT16);
12639 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12640 TOKEN_NUM_INITIALIZER
12641 (struct cmd_vf_tc_bw_result,
12642 vf_id, RTE_UINT16);
12643 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12644 TOKEN_NUM_INITIALIZER
12645 (struct cmd_vf_tc_bw_result,
12647 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12648 TOKEN_NUM_INITIALIZER
12649 (struct cmd_vf_tc_bw_result,
12651 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12652 TOKEN_STRING_INITIALIZER
12653 (struct cmd_vf_tc_bw_result,
12655 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12656 TOKEN_NUM_INITIALIZER
12657 (struct cmd_vf_tc_bw_result,
12658 tc_map, RTE_UINT8);
12660 /* VF max bandwidth setting */
12662 cmd_vf_max_bw_parsed(
12663 void *parsed_result,
12664 __rte_unused struct cmdline *cl,
12665 __rte_unused void *data)
12667 struct cmd_vf_tc_bw_result *res = parsed_result;
12668 int ret = -ENOTSUP;
12670 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12673 #ifdef RTE_NET_I40E
12674 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12675 res->vf_id, res->bw);
12682 fprintf(stderr, "invalid vf_id %d or bandwidth %d\n",
12683 res->vf_id, res->bw);
12686 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12689 fprintf(stderr, "function not implemented\n");
12692 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12696 cmdline_parse_inst_t cmd_vf_max_bw = {
12697 .f = cmd_vf_max_bw_parsed,
12699 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12701 (void *)&cmd_vf_tc_bw_set,
12702 (void *)&cmd_vf_tc_bw_vf,
12703 (void *)&cmd_vf_tc_bw_tx,
12704 (void *)&cmd_vf_tc_bw_max_bw,
12705 (void *)&cmd_vf_tc_bw_port_id,
12706 (void *)&cmd_vf_tc_bw_vf_id,
12707 (void *)&cmd_vf_tc_bw_bw,
12713 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12718 const char *p, *p0 = str;
12725 p = strchr(p0, '(');
12728 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12732 p0 = strchr(p, ')');
12735 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12739 if (size >= sizeof(s)) {
12741 "The string size exceeds the internal buffer size\n");
12744 snprintf(s, sizeof(s), "%.*s", size, p);
12745 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12747 fprintf(stderr, "Failed to get the bandwidth list.\n");
12751 for (i = 0; i < ret; i++)
12752 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12757 /* TC min bandwidth setting */
12759 cmd_vf_tc_min_bw_parsed(
12760 void *parsed_result,
12761 __rte_unused struct cmdline *cl,
12762 __rte_unused void *data)
12764 struct cmd_vf_tc_bw_result *res = parsed_result;
12767 int ret = -ENOTSUP;
12769 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12772 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12776 #ifdef RTE_NET_I40E
12777 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12785 fprintf(stderr, "invalid vf_id %d or bandwidth\n", res->vf_id);
12788 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12791 fprintf(stderr, "function not implemented\n");
12794 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12798 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12799 .f = cmd_vf_tc_min_bw_parsed,
12801 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12802 " <bw1, bw2, ...>",
12804 (void *)&cmd_vf_tc_bw_set,
12805 (void *)&cmd_vf_tc_bw_vf,
12806 (void *)&cmd_vf_tc_bw_tc,
12807 (void *)&cmd_vf_tc_bw_tx,
12808 (void *)&cmd_vf_tc_bw_min_bw,
12809 (void *)&cmd_vf_tc_bw_port_id,
12810 (void *)&cmd_vf_tc_bw_vf_id,
12811 (void *)&cmd_vf_tc_bw_bw_list,
12817 cmd_tc_min_bw_parsed(
12818 void *parsed_result,
12819 __rte_unused struct cmdline *cl,
12820 __rte_unused void *data)
12822 struct cmd_vf_tc_bw_result *res = parsed_result;
12823 struct rte_port *port;
12826 int ret = -ENOTSUP;
12828 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12831 port = &ports[res->port_id];
12832 /** Check if the port is not started **/
12833 if (port->port_status != RTE_PORT_STOPPED) {
12834 fprintf(stderr, "Please stop port %d first\n", res->port_id);
12838 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12842 #ifdef RTE_NET_IXGBE
12843 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12850 fprintf(stderr, "invalid bandwidth\n");
12853 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12856 fprintf(stderr, "function not implemented\n");
12859 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12863 cmdline_parse_inst_t cmd_tc_min_bw = {
12864 .f = cmd_tc_min_bw_parsed,
12866 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12868 (void *)&cmd_vf_tc_bw_set,
12869 (void *)&cmd_vf_tc_bw_tc,
12870 (void *)&cmd_vf_tc_bw_tx,
12871 (void *)&cmd_vf_tc_bw_min_bw,
12872 (void *)&cmd_vf_tc_bw_port_id,
12873 (void *)&cmd_vf_tc_bw_bw_list,
12878 /* TC max bandwidth setting */
12880 cmd_vf_tc_max_bw_parsed(
12881 void *parsed_result,
12882 __rte_unused struct cmdline *cl,
12883 __rte_unused void *data)
12885 struct cmd_vf_tc_bw_result *res = parsed_result;
12886 int ret = -ENOTSUP;
12888 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12891 #ifdef RTE_NET_I40E
12892 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12893 res->tc_no, res->bw);
12901 "invalid vf_id %d, tc_no %d or bandwidth %d\n",
12902 res->vf_id, res->tc_no, res->bw);
12905 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12908 fprintf(stderr, "function not implemented\n");
12911 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12915 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12916 .f = cmd_vf_tc_max_bw_parsed,
12918 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12921 (void *)&cmd_vf_tc_bw_set,
12922 (void *)&cmd_vf_tc_bw_vf,
12923 (void *)&cmd_vf_tc_bw_tc,
12924 (void *)&cmd_vf_tc_bw_tx,
12925 (void *)&cmd_vf_tc_bw_max_bw,
12926 (void *)&cmd_vf_tc_bw_port_id,
12927 (void *)&cmd_vf_tc_bw_vf_id,
12928 (void *)&cmd_vf_tc_bw_tc_no,
12929 (void *)&cmd_vf_tc_bw_bw,
12934 /** Set VXLAN encapsulation details */
12935 struct cmd_set_vxlan_result {
12936 cmdline_fixed_string_t set;
12937 cmdline_fixed_string_t vxlan;
12938 cmdline_fixed_string_t pos_token;
12939 cmdline_fixed_string_t ip_version;
12940 uint32_t vlan_present:1;
12944 cmdline_ipaddr_t ip_src;
12945 cmdline_ipaddr_t ip_dst;
12949 struct rte_ether_addr eth_src;
12950 struct rte_ether_addr eth_dst;
12953 cmdline_parse_token_string_t cmd_set_vxlan_set =
12954 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
12955 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
12956 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
12957 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
12958 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12960 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
12961 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12962 "vxlan-with-vlan");
12963 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
12964 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12966 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
12967 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
12969 cmdline_parse_token_string_t cmd_set_vxlan_vni =
12970 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12972 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
12973 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
12974 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
12975 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12977 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
12978 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
12979 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
12980 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12982 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
12983 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
12984 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
12985 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12987 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
12988 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
12989 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
12990 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12992 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
12993 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
12994 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
12995 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12997 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
12998 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
12999 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
13000 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13002 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
13003 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
13004 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
13005 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13007 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
13008 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
13009 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
13010 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13012 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
13013 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
13014 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
13015 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13017 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
13018 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
13020 static void cmd_set_vxlan_parsed(void *parsed_result,
13021 __rte_unused struct cmdline *cl,
13022 __rte_unused void *data)
13024 struct cmd_set_vxlan_result *res = parsed_result;
13029 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
13032 vxlan_encap_conf.select_tos_ttl = 0;
13033 if (strcmp(res->vxlan, "vxlan") == 0)
13034 vxlan_encap_conf.select_vlan = 0;
13035 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
13036 vxlan_encap_conf.select_vlan = 1;
13037 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
13038 vxlan_encap_conf.select_vlan = 0;
13039 vxlan_encap_conf.select_tos_ttl = 1;
13041 if (strcmp(res->ip_version, "ipv4") == 0)
13042 vxlan_encap_conf.select_ipv4 = 1;
13043 else if (strcmp(res->ip_version, "ipv6") == 0)
13044 vxlan_encap_conf.select_ipv4 = 0;
13047 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
13048 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13049 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13050 vxlan_encap_conf.ip_tos = res->tos;
13051 vxlan_encap_conf.ip_ttl = res->ttl;
13052 if (vxlan_encap_conf.select_ipv4) {
13053 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
13054 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
13056 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
13057 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
13059 if (vxlan_encap_conf.select_vlan)
13060 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13061 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
13062 RTE_ETHER_ADDR_LEN);
13063 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13064 RTE_ETHER_ADDR_LEN);
13067 cmdline_parse_inst_t cmd_set_vxlan = {
13068 .f = cmd_set_vxlan_parsed,
13070 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
13071 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
13072 " eth-src <eth-src> eth-dst <eth-dst>",
13074 (void *)&cmd_set_vxlan_set,
13075 (void *)&cmd_set_vxlan_vxlan,
13076 (void *)&cmd_set_vxlan_ip_version,
13077 (void *)&cmd_set_vxlan_ip_version_value,
13078 (void *)&cmd_set_vxlan_vni,
13079 (void *)&cmd_set_vxlan_vni_value,
13080 (void *)&cmd_set_vxlan_udp_src,
13081 (void *)&cmd_set_vxlan_udp_src_value,
13082 (void *)&cmd_set_vxlan_udp_dst,
13083 (void *)&cmd_set_vxlan_udp_dst_value,
13084 (void *)&cmd_set_vxlan_ip_src,
13085 (void *)&cmd_set_vxlan_ip_src_value,
13086 (void *)&cmd_set_vxlan_ip_dst,
13087 (void *)&cmd_set_vxlan_ip_dst_value,
13088 (void *)&cmd_set_vxlan_eth_src,
13089 (void *)&cmd_set_vxlan_eth_src_value,
13090 (void *)&cmd_set_vxlan_eth_dst,
13091 (void *)&cmd_set_vxlan_eth_dst_value,
13096 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
13097 .f = cmd_set_vxlan_parsed,
13099 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
13100 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
13101 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13102 " eth-dst <eth-dst>",
13104 (void *)&cmd_set_vxlan_set,
13105 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
13106 (void *)&cmd_set_vxlan_ip_version,
13107 (void *)&cmd_set_vxlan_ip_version_value,
13108 (void *)&cmd_set_vxlan_vni,
13109 (void *)&cmd_set_vxlan_vni_value,
13110 (void *)&cmd_set_vxlan_udp_src,
13111 (void *)&cmd_set_vxlan_udp_src_value,
13112 (void *)&cmd_set_vxlan_udp_dst,
13113 (void *)&cmd_set_vxlan_udp_dst_value,
13114 (void *)&cmd_set_vxlan_ip_tos,
13115 (void *)&cmd_set_vxlan_ip_tos_value,
13116 (void *)&cmd_set_vxlan_ip_ttl,
13117 (void *)&cmd_set_vxlan_ip_ttl_value,
13118 (void *)&cmd_set_vxlan_ip_src,
13119 (void *)&cmd_set_vxlan_ip_src_value,
13120 (void *)&cmd_set_vxlan_ip_dst,
13121 (void *)&cmd_set_vxlan_ip_dst_value,
13122 (void *)&cmd_set_vxlan_eth_src,
13123 (void *)&cmd_set_vxlan_eth_src_value,
13124 (void *)&cmd_set_vxlan_eth_dst,
13125 (void *)&cmd_set_vxlan_eth_dst_value,
13130 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
13131 .f = cmd_set_vxlan_parsed,
13133 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
13134 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
13135 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
13138 (void *)&cmd_set_vxlan_set,
13139 (void *)&cmd_set_vxlan_vxlan_with_vlan,
13140 (void *)&cmd_set_vxlan_ip_version,
13141 (void *)&cmd_set_vxlan_ip_version_value,
13142 (void *)&cmd_set_vxlan_vni,
13143 (void *)&cmd_set_vxlan_vni_value,
13144 (void *)&cmd_set_vxlan_udp_src,
13145 (void *)&cmd_set_vxlan_udp_src_value,
13146 (void *)&cmd_set_vxlan_udp_dst,
13147 (void *)&cmd_set_vxlan_udp_dst_value,
13148 (void *)&cmd_set_vxlan_ip_src,
13149 (void *)&cmd_set_vxlan_ip_src_value,
13150 (void *)&cmd_set_vxlan_ip_dst,
13151 (void *)&cmd_set_vxlan_ip_dst_value,
13152 (void *)&cmd_set_vxlan_vlan,
13153 (void *)&cmd_set_vxlan_vlan_value,
13154 (void *)&cmd_set_vxlan_eth_src,
13155 (void *)&cmd_set_vxlan_eth_src_value,
13156 (void *)&cmd_set_vxlan_eth_dst,
13157 (void *)&cmd_set_vxlan_eth_dst_value,
13162 /** Set NVGRE encapsulation details */
13163 struct cmd_set_nvgre_result {
13164 cmdline_fixed_string_t set;
13165 cmdline_fixed_string_t nvgre;
13166 cmdline_fixed_string_t pos_token;
13167 cmdline_fixed_string_t ip_version;
13169 cmdline_ipaddr_t ip_src;
13170 cmdline_ipaddr_t ip_dst;
13172 struct rte_ether_addr eth_src;
13173 struct rte_ether_addr eth_dst;
13176 cmdline_parse_token_string_t cmd_set_nvgre_set =
13177 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
13178 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
13179 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
13180 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
13181 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
13182 "nvgre-with-vlan");
13183 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
13184 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13186 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
13187 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
13189 cmdline_parse_token_string_t cmd_set_nvgre_tni =
13190 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13192 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
13193 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
13194 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
13195 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13197 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
13198 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
13199 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
13200 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13202 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
13203 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
13204 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
13205 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13207 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
13208 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
13209 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
13210 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13212 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
13213 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
13214 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
13215 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13217 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
13218 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
13220 static void cmd_set_nvgre_parsed(void *parsed_result,
13221 __rte_unused struct cmdline *cl,
13222 __rte_unused void *data)
13224 struct cmd_set_nvgre_result *res = parsed_result;
13226 uint32_t nvgre_tni;
13229 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
13232 if (strcmp(res->nvgre, "nvgre") == 0)
13233 nvgre_encap_conf.select_vlan = 0;
13234 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
13235 nvgre_encap_conf.select_vlan = 1;
13236 if (strcmp(res->ip_version, "ipv4") == 0)
13237 nvgre_encap_conf.select_ipv4 = 1;
13238 else if (strcmp(res->ip_version, "ipv6") == 0)
13239 nvgre_encap_conf.select_ipv4 = 0;
13242 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
13243 if (nvgre_encap_conf.select_ipv4) {
13244 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
13245 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
13247 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
13248 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
13250 if (nvgre_encap_conf.select_vlan)
13251 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13252 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
13253 RTE_ETHER_ADDR_LEN);
13254 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13255 RTE_ETHER_ADDR_LEN);
13258 cmdline_parse_inst_t cmd_set_nvgre = {
13259 .f = cmd_set_nvgre_parsed,
13261 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
13262 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13263 " eth-dst <eth-dst>",
13265 (void *)&cmd_set_nvgre_set,
13266 (void *)&cmd_set_nvgre_nvgre,
13267 (void *)&cmd_set_nvgre_ip_version,
13268 (void *)&cmd_set_nvgre_ip_version_value,
13269 (void *)&cmd_set_nvgre_tni,
13270 (void *)&cmd_set_nvgre_tni_value,
13271 (void *)&cmd_set_nvgre_ip_src,
13272 (void *)&cmd_set_nvgre_ip_src_value,
13273 (void *)&cmd_set_nvgre_ip_dst,
13274 (void *)&cmd_set_nvgre_ip_dst_value,
13275 (void *)&cmd_set_nvgre_eth_src,
13276 (void *)&cmd_set_nvgre_eth_src_value,
13277 (void *)&cmd_set_nvgre_eth_dst,
13278 (void *)&cmd_set_nvgre_eth_dst_value,
13283 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
13284 .f = cmd_set_nvgre_parsed,
13286 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
13287 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13288 " eth-src <eth-src> eth-dst <eth-dst>",
13290 (void *)&cmd_set_nvgre_set,
13291 (void *)&cmd_set_nvgre_nvgre_with_vlan,
13292 (void *)&cmd_set_nvgre_ip_version,
13293 (void *)&cmd_set_nvgre_ip_version_value,
13294 (void *)&cmd_set_nvgre_tni,
13295 (void *)&cmd_set_nvgre_tni_value,
13296 (void *)&cmd_set_nvgre_ip_src,
13297 (void *)&cmd_set_nvgre_ip_src_value,
13298 (void *)&cmd_set_nvgre_ip_dst,
13299 (void *)&cmd_set_nvgre_ip_dst_value,
13300 (void *)&cmd_set_nvgre_vlan,
13301 (void *)&cmd_set_nvgre_vlan_value,
13302 (void *)&cmd_set_nvgre_eth_src,
13303 (void *)&cmd_set_nvgre_eth_src_value,
13304 (void *)&cmd_set_nvgre_eth_dst,
13305 (void *)&cmd_set_nvgre_eth_dst_value,
13310 /** Set L2 encapsulation details */
13311 struct cmd_set_l2_encap_result {
13312 cmdline_fixed_string_t set;
13313 cmdline_fixed_string_t l2_encap;
13314 cmdline_fixed_string_t pos_token;
13315 cmdline_fixed_string_t ip_version;
13316 uint32_t vlan_present:1;
13318 struct rte_ether_addr eth_src;
13319 struct rte_ether_addr eth_dst;
13322 cmdline_parse_token_string_t cmd_set_l2_encap_set =
13323 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13324 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13325 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13326 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13327 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13328 "l2_encap-with-vlan");
13329 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13330 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13332 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13333 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13335 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13336 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13338 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13339 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13340 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13341 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13343 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13344 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13345 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13346 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13348 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13349 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13351 static void cmd_set_l2_encap_parsed(void *parsed_result,
13352 __rte_unused struct cmdline *cl,
13353 __rte_unused void *data)
13355 struct cmd_set_l2_encap_result *res = parsed_result;
13357 if (strcmp(res->l2_encap, "l2_encap") == 0)
13358 l2_encap_conf.select_vlan = 0;
13359 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13360 l2_encap_conf.select_vlan = 1;
13361 if (strcmp(res->ip_version, "ipv4") == 0)
13362 l2_encap_conf.select_ipv4 = 1;
13363 else if (strcmp(res->ip_version, "ipv6") == 0)
13364 l2_encap_conf.select_ipv4 = 0;
13367 if (l2_encap_conf.select_vlan)
13368 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13369 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13370 RTE_ETHER_ADDR_LEN);
13371 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13372 RTE_ETHER_ADDR_LEN);
13375 cmdline_parse_inst_t cmd_set_l2_encap = {
13376 .f = cmd_set_l2_encap_parsed,
13378 .help_str = "set l2_encap ip-version ipv4|ipv6"
13379 " eth-src <eth-src> eth-dst <eth-dst>",
13381 (void *)&cmd_set_l2_encap_set,
13382 (void *)&cmd_set_l2_encap_l2_encap,
13383 (void *)&cmd_set_l2_encap_ip_version,
13384 (void *)&cmd_set_l2_encap_ip_version_value,
13385 (void *)&cmd_set_l2_encap_eth_src,
13386 (void *)&cmd_set_l2_encap_eth_src_value,
13387 (void *)&cmd_set_l2_encap_eth_dst,
13388 (void *)&cmd_set_l2_encap_eth_dst_value,
13393 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13394 .f = cmd_set_l2_encap_parsed,
13396 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13397 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13399 (void *)&cmd_set_l2_encap_set,
13400 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13401 (void *)&cmd_set_l2_encap_ip_version,
13402 (void *)&cmd_set_l2_encap_ip_version_value,
13403 (void *)&cmd_set_l2_encap_vlan,
13404 (void *)&cmd_set_l2_encap_vlan_value,
13405 (void *)&cmd_set_l2_encap_eth_src,
13406 (void *)&cmd_set_l2_encap_eth_src_value,
13407 (void *)&cmd_set_l2_encap_eth_dst,
13408 (void *)&cmd_set_l2_encap_eth_dst_value,
13413 /** Set L2 decapsulation details */
13414 struct cmd_set_l2_decap_result {
13415 cmdline_fixed_string_t set;
13416 cmdline_fixed_string_t l2_decap;
13417 cmdline_fixed_string_t pos_token;
13418 uint32_t vlan_present:1;
13421 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13422 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13423 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13424 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13426 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13427 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13428 "l2_decap-with-vlan");
13430 static void cmd_set_l2_decap_parsed(void *parsed_result,
13431 __rte_unused struct cmdline *cl,
13432 __rte_unused void *data)
13434 struct cmd_set_l2_decap_result *res = parsed_result;
13436 if (strcmp(res->l2_decap, "l2_decap") == 0)
13437 l2_decap_conf.select_vlan = 0;
13438 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13439 l2_decap_conf.select_vlan = 1;
13442 cmdline_parse_inst_t cmd_set_l2_decap = {
13443 .f = cmd_set_l2_decap_parsed,
13445 .help_str = "set l2_decap",
13447 (void *)&cmd_set_l2_decap_set,
13448 (void *)&cmd_set_l2_decap_l2_decap,
13453 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13454 .f = cmd_set_l2_decap_parsed,
13456 .help_str = "set l2_decap-with-vlan",
13458 (void *)&cmd_set_l2_decap_set,
13459 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13464 /** Set MPLSoGRE encapsulation details */
13465 struct cmd_set_mplsogre_encap_result {
13466 cmdline_fixed_string_t set;
13467 cmdline_fixed_string_t mplsogre;
13468 cmdline_fixed_string_t pos_token;
13469 cmdline_fixed_string_t ip_version;
13470 uint32_t vlan_present:1;
13472 cmdline_ipaddr_t ip_src;
13473 cmdline_ipaddr_t ip_dst;
13475 struct rte_ether_addr eth_src;
13476 struct rte_ether_addr eth_dst;
13479 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13480 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13482 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13483 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13485 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13486 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13487 mplsogre, "mplsogre_encap-with-vlan");
13488 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13489 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13490 pos_token, "ip-version");
13491 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13492 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13493 ip_version, "ipv4#ipv6");
13494 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13495 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13496 pos_token, "label");
13497 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13498 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13500 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13501 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13502 pos_token, "ip-src");
13503 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13504 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13505 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13506 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13507 pos_token, "ip-dst");
13508 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13509 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13510 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13511 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13512 pos_token, "vlan-tci");
13513 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13514 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13516 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13517 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13518 pos_token, "eth-src");
13519 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13520 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13522 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13523 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13524 pos_token, "eth-dst");
13525 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13526 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13529 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13530 __rte_unused struct cmdline *cl,
13531 __rte_unused void *data)
13533 struct cmd_set_mplsogre_encap_result *res = parsed_result;
13535 uint32_t mplsogre_label;
13538 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13541 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13542 mplsogre_encap_conf.select_vlan = 0;
13543 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13544 mplsogre_encap_conf.select_vlan = 1;
13545 if (strcmp(res->ip_version, "ipv4") == 0)
13546 mplsogre_encap_conf.select_ipv4 = 1;
13547 else if (strcmp(res->ip_version, "ipv6") == 0)
13548 mplsogre_encap_conf.select_ipv4 = 0;
13551 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13552 if (mplsogre_encap_conf.select_ipv4) {
13553 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13554 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13556 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13557 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13559 if (mplsogre_encap_conf.select_vlan)
13560 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13561 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13562 RTE_ETHER_ADDR_LEN);
13563 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13564 RTE_ETHER_ADDR_LEN);
13567 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13568 .f = cmd_set_mplsogre_encap_parsed,
13570 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13571 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13572 " eth-dst <eth-dst>",
13574 (void *)&cmd_set_mplsogre_encap_set,
13575 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13576 (void *)&cmd_set_mplsogre_encap_ip_version,
13577 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13578 (void *)&cmd_set_mplsogre_encap_label,
13579 (void *)&cmd_set_mplsogre_encap_label_value,
13580 (void *)&cmd_set_mplsogre_encap_ip_src,
13581 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13582 (void *)&cmd_set_mplsogre_encap_ip_dst,
13583 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13584 (void *)&cmd_set_mplsogre_encap_eth_src,
13585 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13586 (void *)&cmd_set_mplsogre_encap_eth_dst,
13587 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13592 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13593 .f = cmd_set_mplsogre_encap_parsed,
13595 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13596 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
13597 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13599 (void *)&cmd_set_mplsogre_encap_set,
13600 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13601 (void *)&cmd_set_mplsogre_encap_ip_version,
13602 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13603 (void *)&cmd_set_mplsogre_encap_label,
13604 (void *)&cmd_set_mplsogre_encap_label_value,
13605 (void *)&cmd_set_mplsogre_encap_ip_src,
13606 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13607 (void *)&cmd_set_mplsogre_encap_ip_dst,
13608 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13609 (void *)&cmd_set_mplsogre_encap_vlan,
13610 (void *)&cmd_set_mplsogre_encap_vlan_value,
13611 (void *)&cmd_set_mplsogre_encap_eth_src,
13612 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13613 (void *)&cmd_set_mplsogre_encap_eth_dst,
13614 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13619 /** Set MPLSoGRE decapsulation details */
13620 struct cmd_set_mplsogre_decap_result {
13621 cmdline_fixed_string_t set;
13622 cmdline_fixed_string_t mplsogre;
13623 cmdline_fixed_string_t pos_token;
13624 cmdline_fixed_string_t ip_version;
13625 uint32_t vlan_present:1;
13628 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13629 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13631 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13632 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13634 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13635 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13636 mplsogre, "mplsogre_decap-with-vlan");
13637 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13638 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13639 pos_token, "ip-version");
13640 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13641 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13642 ip_version, "ipv4#ipv6");
13644 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13645 __rte_unused struct cmdline *cl,
13646 __rte_unused void *data)
13648 struct cmd_set_mplsogre_decap_result *res = parsed_result;
13650 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13651 mplsogre_decap_conf.select_vlan = 0;
13652 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13653 mplsogre_decap_conf.select_vlan = 1;
13654 if (strcmp(res->ip_version, "ipv4") == 0)
13655 mplsogre_decap_conf.select_ipv4 = 1;
13656 else if (strcmp(res->ip_version, "ipv6") == 0)
13657 mplsogre_decap_conf.select_ipv4 = 0;
13660 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13661 .f = cmd_set_mplsogre_decap_parsed,
13663 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13665 (void *)&cmd_set_mplsogre_decap_set,
13666 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13667 (void *)&cmd_set_mplsogre_decap_ip_version,
13668 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13673 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13674 .f = cmd_set_mplsogre_decap_parsed,
13676 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13678 (void *)&cmd_set_mplsogre_decap_set,
13679 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13680 (void *)&cmd_set_mplsogre_decap_ip_version,
13681 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13686 /** Set MPLSoUDP encapsulation details */
13687 struct cmd_set_mplsoudp_encap_result {
13688 cmdline_fixed_string_t set;
13689 cmdline_fixed_string_t mplsoudp;
13690 cmdline_fixed_string_t pos_token;
13691 cmdline_fixed_string_t ip_version;
13692 uint32_t vlan_present:1;
13696 cmdline_ipaddr_t ip_src;
13697 cmdline_ipaddr_t ip_dst;
13699 struct rte_ether_addr eth_src;
13700 struct rte_ether_addr eth_dst;
13703 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13704 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13706 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13707 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13709 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13710 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13711 mplsoudp, "mplsoudp_encap-with-vlan");
13712 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13713 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13714 pos_token, "ip-version");
13715 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13716 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13717 ip_version, "ipv4#ipv6");
13718 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13719 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13720 pos_token, "label");
13721 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13722 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13724 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13725 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13726 pos_token, "udp-src");
13727 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13728 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13730 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13731 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13732 pos_token, "udp-dst");
13733 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13734 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13736 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13737 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13738 pos_token, "ip-src");
13739 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13740 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13741 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13742 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13743 pos_token, "ip-dst");
13744 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13745 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13746 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13747 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13748 pos_token, "vlan-tci");
13749 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13750 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13752 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13753 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13754 pos_token, "eth-src");
13755 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13756 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13758 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13759 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13760 pos_token, "eth-dst");
13761 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13762 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13765 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13766 __rte_unused struct cmdline *cl,
13767 __rte_unused void *data)
13769 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13771 uint32_t mplsoudp_label;
13774 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13777 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13778 mplsoudp_encap_conf.select_vlan = 0;
13779 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13780 mplsoudp_encap_conf.select_vlan = 1;
13781 if (strcmp(res->ip_version, "ipv4") == 0)
13782 mplsoudp_encap_conf.select_ipv4 = 1;
13783 else if (strcmp(res->ip_version, "ipv6") == 0)
13784 mplsoudp_encap_conf.select_ipv4 = 0;
13787 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13788 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13789 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13790 if (mplsoudp_encap_conf.select_ipv4) {
13791 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13792 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13794 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13795 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13797 if (mplsoudp_encap_conf.select_vlan)
13798 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13799 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13800 RTE_ETHER_ADDR_LEN);
13801 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13802 RTE_ETHER_ADDR_LEN);
13805 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13806 .f = cmd_set_mplsoudp_encap_parsed,
13808 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13809 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13810 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13812 (void *)&cmd_set_mplsoudp_encap_set,
13813 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13814 (void *)&cmd_set_mplsoudp_encap_ip_version,
13815 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13816 (void *)&cmd_set_mplsoudp_encap_label,
13817 (void *)&cmd_set_mplsoudp_encap_label_value,
13818 (void *)&cmd_set_mplsoudp_encap_udp_src,
13819 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13820 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13821 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13822 (void *)&cmd_set_mplsoudp_encap_ip_src,
13823 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13824 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13825 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13826 (void *)&cmd_set_mplsoudp_encap_eth_src,
13827 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13828 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13829 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13834 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13835 .f = cmd_set_mplsoudp_encap_parsed,
13837 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13838 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
13839 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13840 " eth-src <eth-src> eth-dst <eth-dst>",
13842 (void *)&cmd_set_mplsoudp_encap_set,
13843 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13844 (void *)&cmd_set_mplsoudp_encap_ip_version,
13845 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13846 (void *)&cmd_set_mplsoudp_encap_label,
13847 (void *)&cmd_set_mplsoudp_encap_label_value,
13848 (void *)&cmd_set_mplsoudp_encap_udp_src,
13849 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13850 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13851 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13852 (void *)&cmd_set_mplsoudp_encap_ip_src,
13853 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13854 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13855 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13856 (void *)&cmd_set_mplsoudp_encap_vlan,
13857 (void *)&cmd_set_mplsoudp_encap_vlan_value,
13858 (void *)&cmd_set_mplsoudp_encap_eth_src,
13859 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13860 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13861 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13866 /** Set MPLSoUDP decapsulation details */
13867 struct cmd_set_mplsoudp_decap_result {
13868 cmdline_fixed_string_t set;
13869 cmdline_fixed_string_t mplsoudp;
13870 cmdline_fixed_string_t pos_token;
13871 cmdline_fixed_string_t ip_version;
13872 uint32_t vlan_present:1;
13875 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
13876 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
13878 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
13879 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
13881 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
13882 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13883 mplsoudp, "mplsoudp_decap-with-vlan");
13884 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
13885 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13886 pos_token, "ip-version");
13887 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
13888 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13889 ip_version, "ipv4#ipv6");
13891 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
13892 __rte_unused struct cmdline *cl,
13893 __rte_unused void *data)
13895 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
13897 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
13898 mplsoudp_decap_conf.select_vlan = 0;
13899 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
13900 mplsoudp_decap_conf.select_vlan = 1;
13901 if (strcmp(res->ip_version, "ipv4") == 0)
13902 mplsoudp_decap_conf.select_ipv4 = 1;
13903 else if (strcmp(res->ip_version, "ipv6") == 0)
13904 mplsoudp_decap_conf.select_ipv4 = 0;
13907 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
13908 .f = cmd_set_mplsoudp_decap_parsed,
13910 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
13912 (void *)&cmd_set_mplsoudp_decap_set,
13913 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
13914 (void *)&cmd_set_mplsoudp_decap_ip_version,
13915 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13920 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
13921 .f = cmd_set_mplsoudp_decap_parsed,
13923 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
13925 (void *)&cmd_set_mplsoudp_decap_set,
13926 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
13927 (void *)&cmd_set_mplsoudp_decap_ip_version,
13928 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13933 /** Set connection tracking object common details */
13934 struct cmd_set_conntrack_common_result {
13935 cmdline_fixed_string_t set;
13936 cmdline_fixed_string_t conntrack;
13937 cmdline_fixed_string_t common;
13938 cmdline_fixed_string_t peer;
13939 cmdline_fixed_string_t is_orig;
13940 cmdline_fixed_string_t enable;
13941 cmdline_fixed_string_t live;
13942 cmdline_fixed_string_t sack;
13943 cmdline_fixed_string_t cack;
13944 cmdline_fixed_string_t last_dir;
13945 cmdline_fixed_string_t liberal;
13946 cmdline_fixed_string_t state;
13947 cmdline_fixed_string_t max_ack_win;
13948 cmdline_fixed_string_t retrans;
13949 cmdline_fixed_string_t last_win;
13950 cmdline_fixed_string_t last_seq;
13951 cmdline_fixed_string_t last_ack;
13952 cmdline_fixed_string_t last_end;
13953 cmdline_fixed_string_t last_index;
13956 uint16_t peer_port;
13957 uint32_t is_original;
13972 cmdline_parse_token_string_t cmd_set_conntrack_set =
13973 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13975 cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
13976 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13977 conntrack, "conntrack");
13978 cmdline_parse_token_string_t cmd_set_conntrack_common_com =
13979 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13981 cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
13982 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13984 cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
13985 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13986 peer_port, RTE_UINT16);
13987 cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
13988 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13989 is_orig, "is_orig");
13990 cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
13991 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13992 is_original, RTE_UINT32);
13993 cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
13994 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13996 cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
13997 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13999 cmdline_parse_token_string_t cmd_set_conntrack_common_live =
14000 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14002 cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
14003 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14004 is_live, RTE_UINT32);
14005 cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
14006 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14008 cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
14009 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14010 s_ack, RTE_UINT32);
14011 cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
14012 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14014 cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
14015 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14016 c_ack, RTE_UINT32);
14017 cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
14018 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14019 last_dir, "last_dir");
14020 cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
14021 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14023 cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
14024 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14025 liberal, "liberal");
14026 cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
14027 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14029 cmdline_parse_token_string_t cmd_set_conntrack_common_state =
14030 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14032 cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
14033 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14035 cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
14036 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14037 max_ack_win, "max_ack_win");
14038 cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
14039 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14040 factor, RTE_UINT8);
14041 cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
14042 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14044 cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
14045 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14046 re_num, RTE_UINT8);
14047 cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
14048 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14049 last_win, "last_win");
14050 cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
14051 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14053 cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
14054 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14055 last_seq, "last_seq");
14056 cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
14057 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14059 cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
14060 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14061 last_ack, "last_ack");
14062 cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
14063 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14065 cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
14066 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14067 last_end, "last_end");
14068 cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
14069 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14071 cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
14072 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14073 last_index, "last_index");
14074 cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
14075 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14078 static void cmd_set_conntrack_common_parsed(void *parsed_result,
14079 __rte_unused struct cmdline *cl,
14080 __rte_unused void *data)
14082 struct cmd_set_conntrack_common_result *res = parsed_result;
14084 /* No need to swap to big endian. */
14085 conntrack_context.peer_port = res->peer_port;
14086 conntrack_context.is_original_dir = res->is_original;
14087 conntrack_context.enable = res->en;
14088 conntrack_context.live_connection = res->is_live;
14089 conntrack_context.selective_ack = res->s_ack;
14090 conntrack_context.challenge_ack_passed = res->c_ack;
14091 conntrack_context.last_direction = res->ld;
14092 conntrack_context.liberal_mode = res->lb;
14093 conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
14094 conntrack_context.max_ack_window = res->factor;
14095 conntrack_context.retransmission_limit = res->re_num;
14096 conntrack_context.last_window = res->lw;
14097 conntrack_context.last_index =
14098 (enum rte_flow_conntrack_tcp_last_index)res->li;
14099 conntrack_context.last_seq = res->ls;
14100 conntrack_context.last_ack = res->la;
14101 conntrack_context.last_end = res->le;
14104 cmdline_parse_inst_t cmd_set_conntrack_common = {
14105 .f = cmd_set_conntrack_common_parsed,
14107 .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
14108 " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
14109 " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
14110 " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
14111 " last_index <flag>",
14113 (void *)&cmd_set_conntrack_set,
14114 (void *)&cmd_set_conntrack_conntrack,
14115 (void *)&cmd_set_conntrack_common_com,
14116 (void *)&cmd_set_conntrack_common_peer,
14117 (void *)&cmd_set_conntrack_common_peer_value,
14118 (void *)&cmd_set_conntrack_common_is_orig,
14119 (void *)&cmd_set_conntrack_common_is_orig_value,
14120 (void *)&cmd_set_conntrack_common_enable,
14121 (void *)&cmd_set_conntrack_common_enable_value,
14122 (void *)&cmd_set_conntrack_common_live,
14123 (void *)&cmd_set_conntrack_common_live_value,
14124 (void *)&cmd_set_conntrack_common_sack,
14125 (void *)&cmd_set_conntrack_common_sack_value,
14126 (void *)&cmd_set_conntrack_common_cack,
14127 (void *)&cmd_set_conntrack_common_cack_value,
14128 (void *)&cmd_set_conntrack_common_last_dir,
14129 (void *)&cmd_set_conntrack_common_last_dir_value,
14130 (void *)&cmd_set_conntrack_common_liberal,
14131 (void *)&cmd_set_conntrack_common_liberal_value,
14132 (void *)&cmd_set_conntrack_common_state,
14133 (void *)&cmd_set_conntrack_common_state_value,
14134 (void *)&cmd_set_conntrack_common_max_ackwin,
14135 (void *)&cmd_set_conntrack_common_max_ackwin_value,
14136 (void *)&cmd_set_conntrack_common_retrans,
14137 (void *)&cmd_set_conntrack_common_retrans_value,
14138 (void *)&cmd_set_conntrack_common_last_win,
14139 (void *)&cmd_set_conntrack_common_last_win_value,
14140 (void *)&cmd_set_conntrack_common_last_seq,
14141 (void *)&cmd_set_conntrack_common_last_seq_value,
14142 (void *)&cmd_set_conntrack_common_last_ack,
14143 (void *)&cmd_set_conntrack_common_last_ack_value,
14144 (void *)&cmd_set_conntrack_common_last_end,
14145 (void *)&cmd_set_conntrack_common_last_end_value,
14146 (void *)&cmd_set_conntrack_common_last_index,
14147 (void *)&cmd_set_conntrack_common_last_index_value,
14152 /** Set connection tracking object both directions' details */
14153 struct cmd_set_conntrack_dir_result {
14154 cmdline_fixed_string_t set;
14155 cmdline_fixed_string_t conntrack;
14156 cmdline_fixed_string_t dir;
14157 cmdline_fixed_string_t scale;
14158 cmdline_fixed_string_t fin;
14159 cmdline_fixed_string_t ack_seen;
14160 cmdline_fixed_string_t unack;
14161 cmdline_fixed_string_t sent_end;
14162 cmdline_fixed_string_t reply_end;
14163 cmdline_fixed_string_t max_win;
14164 cmdline_fixed_string_t max_ack;
14175 cmdline_parse_token_string_t cmd_set_conntrack_dir_set =
14176 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14178 cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack =
14179 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14180 conntrack, "conntrack");
14181 cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
14182 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14184 cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
14185 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14187 cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
14188 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14189 factor, RTE_UINT32);
14190 cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
14191 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14193 cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
14194 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14196 cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
14197 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14198 ack_seen, "acked");
14199 cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
14200 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14202 cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
14203 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14204 unack, "unack_data");
14205 cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
14206 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14208 cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
14209 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14210 sent_end, "sent_end");
14211 cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
14212 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14214 cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
14215 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14216 reply_end, "reply_end");
14217 cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
14218 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14220 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
14221 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14222 max_win, "max_win");
14223 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
14224 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14226 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
14227 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14228 max_ack, "max_ack");
14229 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
14230 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14233 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
14234 __rte_unused struct cmdline *cl,
14235 __rte_unused void *data)
14237 struct cmd_set_conntrack_dir_result *res = parsed_result;
14238 struct rte_flow_tcp_dir_param *dir = NULL;
14240 if (strcmp(res->dir, "orig") == 0)
14241 dir = &conntrack_context.original_dir;
14242 else if (strcmp(res->dir, "rply") == 0)
14243 dir = &conntrack_context.reply_dir;
14246 dir->scale = res->factor;
14247 dir->close_initiated = res->f;
14248 dir->last_ack_seen = res->as;
14249 dir->data_unacked = res->un;
14250 dir->sent_end = res->se;
14251 dir->reply_end = res->re;
14252 dir->max_ack = res->ma;
14253 dir->max_win = res->mw;
14256 cmdline_parse_inst_t cmd_set_conntrack_dir = {
14257 .f = cmd_set_conntrack_dir_parsed,
14259 .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
14260 " acked <seen> unack_data <unack> sent_end <sent>"
14261 " reply_end <reply> max_win <win> max_ack <ack>",
14263 (void *)&cmd_set_conntrack_set,
14264 (void *)&cmd_set_conntrack_conntrack,
14265 (void *)&cmd_set_conntrack_dir_dir,
14266 (void *)&cmd_set_conntrack_dir_scale,
14267 (void *)&cmd_set_conntrack_dir_scale_value,
14268 (void *)&cmd_set_conntrack_dir_fin,
14269 (void *)&cmd_set_conntrack_dir_fin_value,
14270 (void *)&cmd_set_conntrack_dir_ack,
14271 (void *)&cmd_set_conntrack_dir_ack_value,
14272 (void *)&cmd_set_conntrack_dir_unack_data,
14273 (void *)&cmd_set_conntrack_dir_unack_data_value,
14274 (void *)&cmd_set_conntrack_dir_sent_end,
14275 (void *)&cmd_set_conntrack_dir_sent_end_value,
14276 (void *)&cmd_set_conntrack_dir_reply_end,
14277 (void *)&cmd_set_conntrack_dir_reply_end_value,
14278 (void *)&cmd_set_conntrack_dir_max_win,
14279 (void *)&cmd_set_conntrack_dir_max_win_value,
14280 (void *)&cmd_set_conntrack_dir_max_ack,
14281 (void *)&cmd_set_conntrack_dir_max_ack_value,
14286 /* Strict link priority scheduling mode setting */
14288 cmd_strict_link_prio_parsed(
14289 void *parsed_result,
14290 __rte_unused struct cmdline *cl,
14291 __rte_unused void *data)
14293 struct cmd_vf_tc_bw_result *res = parsed_result;
14294 int ret = -ENOTSUP;
14296 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14299 #ifdef RTE_NET_I40E
14300 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14307 fprintf(stderr, "invalid tc_bitmap 0x%x\n", res->tc_map);
14310 fprintf(stderr, "invalid port_id %d\n", res->port_id);
14313 fprintf(stderr, "function not implemented\n");
14316 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
14320 cmdline_parse_inst_t cmd_strict_link_prio = {
14321 .f = cmd_strict_link_prio_parsed,
14323 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14325 (void *)&cmd_vf_tc_bw_set,
14326 (void *)&cmd_vf_tc_bw_tx,
14327 (void *)&cmd_vf_tc_bw_strict_link_prio,
14328 (void *)&cmd_vf_tc_bw_port_id,
14329 (void *)&cmd_vf_tc_bw_tc_map,
14334 /* Load dynamic device personalization*/
14335 struct cmd_ddp_add_result {
14336 cmdline_fixed_string_t ddp;
14337 cmdline_fixed_string_t add;
14342 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14343 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14344 cmdline_parse_token_string_t cmd_ddp_add_add =
14345 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14346 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14347 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
14349 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14350 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14353 cmd_ddp_add_parsed(
14354 void *parsed_result,
14355 __rte_unused struct cmdline *cl,
14356 __rte_unused void *data)
14358 struct cmd_ddp_add_result *res = parsed_result;
14364 int ret = -ENOTSUP;
14366 if (!all_ports_stopped()) {
14367 fprintf(stderr, "Please stop all ports first\n");
14371 filepath = strdup(res->filepath);
14372 if (filepath == NULL) {
14373 fprintf(stderr, "Failed to allocate memory\n");
14376 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14378 buff = open_file(file_fld[0], &size);
14380 free((void *)filepath);
14384 #ifdef RTE_NET_I40E
14385 if (ret == -ENOTSUP)
14386 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14388 RTE_PMD_I40E_PKG_OP_WR_ADD);
14391 if (ret == -EEXIST)
14392 fprintf(stderr, "Profile has already existed.\n");
14394 fprintf(stderr, "Failed to load profile.\n");
14395 else if (file_num == 2)
14396 save_file(file_fld[1], buff, size);
14399 free((void *)filepath);
14402 cmdline_parse_inst_t cmd_ddp_add = {
14403 .f = cmd_ddp_add_parsed,
14405 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14407 (void *)&cmd_ddp_add_ddp,
14408 (void *)&cmd_ddp_add_add,
14409 (void *)&cmd_ddp_add_port_id,
14410 (void *)&cmd_ddp_add_filepath,
14415 /* Delete dynamic device personalization*/
14416 struct cmd_ddp_del_result {
14417 cmdline_fixed_string_t ddp;
14418 cmdline_fixed_string_t del;
14423 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14424 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14425 cmdline_parse_token_string_t cmd_ddp_del_del =
14426 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14427 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14428 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
14429 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14430 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14433 cmd_ddp_del_parsed(
14434 void *parsed_result,
14435 __rte_unused struct cmdline *cl,
14436 __rte_unused void *data)
14438 struct cmd_ddp_del_result *res = parsed_result;
14441 int ret = -ENOTSUP;
14443 if (!all_ports_stopped()) {
14444 fprintf(stderr, "Please stop all ports first\n");
14448 buff = open_file(res->filepath, &size);
14452 #ifdef RTE_NET_I40E
14453 if (ret == -ENOTSUP)
14454 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14456 RTE_PMD_I40E_PKG_OP_WR_DEL);
14459 if (ret == -EACCES)
14460 fprintf(stderr, "Profile does not exist.\n");
14462 fprintf(stderr, "Failed to delete profile.\n");
14467 cmdline_parse_inst_t cmd_ddp_del = {
14468 .f = cmd_ddp_del_parsed,
14470 .help_str = "ddp del <port_id> <backup_profile_path>",
14472 (void *)&cmd_ddp_del_ddp,
14473 (void *)&cmd_ddp_del_del,
14474 (void *)&cmd_ddp_del_port_id,
14475 (void *)&cmd_ddp_del_filepath,
14480 /* Get dynamic device personalization profile info */
14481 struct cmd_ddp_info_result {
14482 cmdline_fixed_string_t ddp;
14483 cmdline_fixed_string_t get;
14484 cmdline_fixed_string_t info;
14488 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14489 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14490 cmdline_parse_token_string_t cmd_ddp_info_get =
14491 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14492 cmdline_parse_token_string_t cmd_ddp_info_info =
14493 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14494 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14495 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14498 cmd_ddp_info_parsed(
14499 void *parsed_result,
14500 __rte_unused struct cmdline *cl,
14501 __rte_unused void *data)
14503 struct cmd_ddp_info_result *res = parsed_result;
14506 int ret = -ENOTSUP;
14507 #ifdef RTE_NET_I40E
14510 uint32_t buff_size = 0;
14511 struct rte_pmd_i40e_profile_info info;
14512 uint32_t dev_num = 0;
14513 struct rte_pmd_i40e_ddp_device_id *devs;
14514 uint32_t proto_num = 0;
14515 struct rte_pmd_i40e_proto_info *proto = NULL;
14516 uint32_t pctype_num = 0;
14517 struct rte_pmd_i40e_ptype_info *pctype;
14518 uint32_t ptype_num = 0;
14519 struct rte_pmd_i40e_ptype_info *ptype;
14524 pkg = open_file(res->filepath, &pkg_size);
14528 #ifdef RTE_NET_I40E
14529 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14530 (uint8_t *)&info, sizeof(info),
14531 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14533 printf("Global Track id: 0x%x\n", info.track_id);
14534 printf("Global Version: %d.%d.%d.%d\n",
14535 info.version.major,
14536 info.version.minor,
14537 info.version.update,
14538 info.version.draft);
14539 printf("Global Package name: %s\n\n", info.name);
14542 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14543 (uint8_t *)&info, sizeof(info),
14544 RTE_PMD_I40E_PKG_INFO_HEADER);
14546 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14547 printf("i40e Profile Version: %d.%d.%d.%d\n",
14548 info.version.major,
14549 info.version.minor,
14550 info.version.update,
14551 info.version.draft);
14552 printf("i40e Profile name: %s\n\n", info.name);
14555 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14556 (uint8_t *)&buff_size, sizeof(buff_size),
14557 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14558 if (!ret && buff_size) {
14559 buff = (uint8_t *)malloc(buff_size);
14561 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14563 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14565 printf("Package Notes:\n%s\n\n", buff);
14570 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14571 (uint8_t *)&dev_num, sizeof(dev_num),
14572 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14573 if (!ret && dev_num) {
14574 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14575 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14577 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14578 (uint8_t *)devs, buff_size,
14579 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14581 printf("List of supported devices:\n");
14582 for (i = 0; i < dev_num; i++) {
14583 printf(" %04X:%04X %04X:%04X\n",
14584 devs[i].vendor_dev_id >> 16,
14585 devs[i].vendor_dev_id & 0xFFFF,
14586 devs[i].sub_vendor_dev_id >> 16,
14587 devs[i].sub_vendor_dev_id & 0xFFFF);
14595 /* get information about protocols and packet types */
14596 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14597 (uint8_t *)&proto_num, sizeof(proto_num),
14598 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14599 if (ret || !proto_num)
14600 goto no_print_return;
14602 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14603 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14605 goto no_print_return;
14607 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14609 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14611 printf("List of used protocols:\n");
14612 for (i = 0; i < proto_num; i++)
14613 printf(" %2u: %s\n", proto[i].proto_id,
14617 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14618 (uint8_t *)&pctype_num, sizeof(pctype_num),
14619 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14620 if (ret || !pctype_num)
14621 goto no_print_pctypes;
14623 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14624 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14626 goto no_print_pctypes;
14628 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14630 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14633 goto no_print_pctypes;
14636 printf("List of defined packet classification types:\n");
14637 for (i = 0; i < pctype_num; i++) {
14638 printf(" %2u:", pctype[i].ptype_id);
14639 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14640 proto_id = pctype[i].protocols[j];
14641 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14642 for (n = 0; n < proto_num; n++) {
14643 if (proto[n].proto_id == proto_id) {
14644 printf(" %s", proto[n].name);
14657 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14659 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14660 if (ret || !ptype_num)
14661 goto no_print_return;
14663 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14664 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14666 goto no_print_return;
14668 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14670 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14673 goto no_print_return;
14675 printf("List of defined packet types:\n");
14676 for (i = 0; i < ptype_num; i++) {
14677 printf(" %2u:", ptype[i].ptype_id);
14678 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14679 proto_id = ptype[i].protocols[j];
14680 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14681 for (n = 0; n < proto_num; n++) {
14682 if (proto[n].proto_id == proto_id) {
14683 printf(" %s", proto[n].name);
14699 if (ret == -ENOTSUP)
14700 fprintf(stderr, "Function not supported in PMD driver\n");
14704 cmdline_parse_inst_t cmd_ddp_get_info = {
14705 .f = cmd_ddp_info_parsed,
14707 .help_str = "ddp get info <profile_path>",
14709 (void *)&cmd_ddp_info_ddp,
14710 (void *)&cmd_ddp_info_get,
14711 (void *)&cmd_ddp_info_info,
14712 (void *)&cmd_ddp_info_filepath,
14717 /* Get dynamic device personalization profile info list*/
14718 #define PROFILE_INFO_SIZE 48
14719 #define MAX_PROFILE_NUM 16
14721 struct cmd_ddp_get_list_result {
14722 cmdline_fixed_string_t ddp;
14723 cmdline_fixed_string_t get;
14724 cmdline_fixed_string_t list;
14728 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14729 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14730 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14731 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14732 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14733 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14734 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14735 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14739 cmd_ddp_get_list_parsed(
14740 __rte_unused void *parsed_result,
14741 __rte_unused struct cmdline *cl,
14742 __rte_unused void *data)
14744 #ifdef RTE_NET_I40E
14745 struct cmd_ddp_get_list_result *res = parsed_result;
14746 struct rte_pmd_i40e_profile_list *p_list;
14747 struct rte_pmd_i40e_profile_info *p_info;
14752 int ret = -ENOTSUP;
14754 #ifdef RTE_NET_I40E
14755 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14756 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14758 fprintf(stderr, "%s: Failed to malloc buffer\n", __func__);
14762 if (ret == -ENOTSUP)
14763 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14764 (uint8_t *)p_list, size);
14767 p_num = p_list->p_count;
14768 printf("Profile number is: %d\n\n", p_num);
14770 for (i = 0; i < p_num; i++) {
14771 p_info = &p_list->p_info[i];
14772 printf("Profile %d:\n", i);
14773 printf("Track id: 0x%x\n", p_info->track_id);
14774 printf("Version: %d.%d.%d.%d\n",
14775 p_info->version.major,
14776 p_info->version.minor,
14777 p_info->version.update,
14778 p_info->version.draft);
14779 printf("Profile name: %s\n\n", p_info->name);
14787 fprintf(stderr, "Failed to get ddp list\n");
14790 cmdline_parse_inst_t cmd_ddp_get_list = {
14791 .f = cmd_ddp_get_list_parsed,
14793 .help_str = "ddp get list <port_id>",
14795 (void *)&cmd_ddp_get_list_ddp,
14796 (void *)&cmd_ddp_get_list_get,
14797 (void *)&cmd_ddp_get_list_list,
14798 (void *)&cmd_ddp_get_list_port_id,
14803 /* Configure input set */
14804 struct cmd_cfg_input_set_result {
14805 cmdline_fixed_string_t port;
14806 cmdline_fixed_string_t cfg;
14808 cmdline_fixed_string_t pctype;
14810 cmdline_fixed_string_t inset_type;
14811 cmdline_fixed_string_t opt;
14812 cmdline_fixed_string_t field;
14817 cmd_cfg_input_set_parsed(
14818 __rte_unused void *parsed_result,
14819 __rte_unused struct cmdline *cl,
14820 __rte_unused void *data)
14822 #ifdef RTE_NET_I40E
14823 struct cmd_cfg_input_set_result *res = parsed_result;
14824 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14825 struct rte_pmd_i40e_inset inset;
14827 int ret = -ENOTSUP;
14829 if (!all_ports_stopped()) {
14830 fprintf(stderr, "Please stop all ports first\n");
14834 #ifdef RTE_NET_I40E
14835 if (!strcmp(res->inset_type, "hash_inset"))
14836 inset_type = INSET_HASH;
14837 else if (!strcmp(res->inset_type, "fdir_inset"))
14838 inset_type = INSET_FDIR;
14839 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14840 inset_type = INSET_FDIR_FLX;
14841 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14842 &inset, inset_type);
14844 fprintf(stderr, "Failed to get input set.\n");
14848 if (!strcmp(res->opt, "get")) {
14849 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14852 printf("Field index %d is enabled.\n", res->field_idx);
14854 printf("Field index %d is disabled.\n", res->field_idx);
14856 } else if (!strcmp(res->opt, "set"))
14857 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14859 else if (!strcmp(res->opt, "clear"))
14860 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14863 fprintf(stderr, "Failed to configure input set field.\n");
14867 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14868 &inset, inset_type);
14870 fprintf(stderr, "Failed to set input set.\n");
14875 if (ret == -ENOTSUP)
14876 fprintf(stderr, "Function not supported\n");
14879 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14880 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14882 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14883 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14885 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14886 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14887 port_id, RTE_UINT16);
14888 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14889 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14891 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14892 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14893 pctype_id, RTE_UINT8);
14894 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14895 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14897 "hash_inset#fdir_inset#fdir_flx_inset");
14898 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14899 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14900 opt, "get#set#clear");
14901 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14902 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14904 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14905 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14906 field_idx, RTE_UINT8);
14908 cmdline_parse_inst_t cmd_cfg_input_set = {
14909 .f = cmd_cfg_input_set_parsed,
14911 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14912 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
14914 (void *)&cmd_cfg_input_set_port,
14915 (void *)&cmd_cfg_input_set_cfg,
14916 (void *)&cmd_cfg_input_set_port_id,
14917 (void *)&cmd_cfg_input_set_pctype,
14918 (void *)&cmd_cfg_input_set_pctype_id,
14919 (void *)&cmd_cfg_input_set_inset_type,
14920 (void *)&cmd_cfg_input_set_opt,
14921 (void *)&cmd_cfg_input_set_field,
14922 (void *)&cmd_cfg_input_set_field_idx,
14927 /* Clear input set */
14928 struct cmd_clear_input_set_result {
14929 cmdline_fixed_string_t port;
14930 cmdline_fixed_string_t cfg;
14932 cmdline_fixed_string_t pctype;
14934 cmdline_fixed_string_t inset_type;
14935 cmdline_fixed_string_t clear;
14936 cmdline_fixed_string_t all;
14940 cmd_clear_input_set_parsed(
14941 __rte_unused void *parsed_result,
14942 __rte_unused struct cmdline *cl,
14943 __rte_unused void *data)
14945 #ifdef RTE_NET_I40E
14946 struct cmd_clear_input_set_result *res = parsed_result;
14947 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14948 struct rte_pmd_i40e_inset inset;
14950 int ret = -ENOTSUP;
14952 if (!all_ports_stopped()) {
14953 fprintf(stderr, "Please stop all ports first\n");
14957 #ifdef RTE_NET_I40E
14958 if (!strcmp(res->inset_type, "hash_inset"))
14959 inset_type = INSET_HASH;
14960 else if (!strcmp(res->inset_type, "fdir_inset"))
14961 inset_type = INSET_FDIR;
14962 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14963 inset_type = INSET_FDIR_FLX;
14965 memset(&inset, 0, sizeof(inset));
14967 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14968 &inset, inset_type);
14970 fprintf(stderr, "Failed to clear input set.\n");
14976 if (ret == -ENOTSUP)
14977 fprintf(stderr, "Function not supported\n");
14980 cmdline_parse_token_string_t cmd_clear_input_set_port =
14981 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14983 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
14984 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14986 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
14987 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14988 port_id, RTE_UINT16);
14989 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
14990 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14992 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
14993 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14994 pctype_id, RTE_UINT8);
14995 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
14996 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14998 "hash_inset#fdir_inset#fdir_flx_inset");
14999 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15000 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15002 cmdline_parse_token_string_t cmd_clear_input_set_all =
15003 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15006 cmdline_parse_inst_t cmd_clear_input_set = {
15007 .f = cmd_clear_input_set_parsed,
15009 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15010 "fdir_inset|fdir_flx_inset clear all",
15012 (void *)&cmd_clear_input_set_port,
15013 (void *)&cmd_clear_input_set_cfg,
15014 (void *)&cmd_clear_input_set_port_id,
15015 (void *)&cmd_clear_input_set_pctype,
15016 (void *)&cmd_clear_input_set_pctype_id,
15017 (void *)&cmd_clear_input_set_inset_type,
15018 (void *)&cmd_clear_input_set_clear,
15019 (void *)&cmd_clear_input_set_all,
15024 /* show vf stats */
15026 /* Common result structure for show vf stats */
15027 struct cmd_show_vf_stats_result {
15028 cmdline_fixed_string_t show;
15029 cmdline_fixed_string_t vf;
15030 cmdline_fixed_string_t stats;
15035 /* Common CLI fields show vf stats*/
15036 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15037 TOKEN_STRING_INITIALIZER
15038 (struct cmd_show_vf_stats_result,
15040 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15041 TOKEN_STRING_INITIALIZER
15042 (struct cmd_show_vf_stats_result,
15044 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15045 TOKEN_STRING_INITIALIZER
15046 (struct cmd_show_vf_stats_result,
15048 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15049 TOKEN_NUM_INITIALIZER
15050 (struct cmd_show_vf_stats_result,
15051 port_id, RTE_UINT16);
15052 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15053 TOKEN_NUM_INITIALIZER
15054 (struct cmd_show_vf_stats_result,
15055 vf_id, RTE_UINT16);
15058 cmd_show_vf_stats_parsed(
15059 void *parsed_result,
15060 __rte_unused struct cmdline *cl,
15061 __rte_unused void *data)
15063 struct cmd_show_vf_stats_result *res = parsed_result;
15064 struct rte_eth_stats stats;
15065 int ret = -ENOTSUP;
15066 static const char *nic_stats_border = "########################";
15068 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15071 memset(&stats, 0, sizeof(stats));
15073 #ifdef RTE_NET_I40E
15074 if (ret == -ENOTSUP)
15075 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15079 #ifdef RTE_NET_BNXT
15080 if (ret == -ENOTSUP)
15081 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15090 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15093 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15096 fprintf(stderr, "function not implemented\n");
15099 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15102 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15103 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15105 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15107 stats.ipackets, stats.imissed, stats.ibytes);
15108 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15109 printf(" RX-nombuf: %-10"PRIu64"\n",
15111 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15113 stats.opackets, stats.oerrors, stats.obytes);
15115 printf(" %s############################%s\n",
15116 nic_stats_border, nic_stats_border);
15119 cmdline_parse_inst_t cmd_show_vf_stats = {
15120 .f = cmd_show_vf_stats_parsed,
15122 .help_str = "show vf stats <port_id> <vf_id>",
15124 (void *)&cmd_show_vf_stats_show,
15125 (void *)&cmd_show_vf_stats_vf,
15126 (void *)&cmd_show_vf_stats_stats,
15127 (void *)&cmd_show_vf_stats_port_id,
15128 (void *)&cmd_show_vf_stats_vf_id,
15133 /* clear vf stats */
15135 /* Common result structure for clear vf stats */
15136 struct cmd_clear_vf_stats_result {
15137 cmdline_fixed_string_t clear;
15138 cmdline_fixed_string_t vf;
15139 cmdline_fixed_string_t stats;
15144 /* Common CLI fields clear vf stats*/
15145 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15146 TOKEN_STRING_INITIALIZER
15147 (struct cmd_clear_vf_stats_result,
15149 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15150 TOKEN_STRING_INITIALIZER
15151 (struct cmd_clear_vf_stats_result,
15153 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15154 TOKEN_STRING_INITIALIZER
15155 (struct cmd_clear_vf_stats_result,
15157 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15158 TOKEN_NUM_INITIALIZER
15159 (struct cmd_clear_vf_stats_result,
15160 port_id, RTE_UINT16);
15161 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15162 TOKEN_NUM_INITIALIZER
15163 (struct cmd_clear_vf_stats_result,
15164 vf_id, RTE_UINT16);
15167 cmd_clear_vf_stats_parsed(
15168 void *parsed_result,
15169 __rte_unused struct cmdline *cl,
15170 __rte_unused void *data)
15172 struct cmd_clear_vf_stats_result *res = parsed_result;
15173 int ret = -ENOTSUP;
15175 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15178 #ifdef RTE_NET_I40E
15179 if (ret == -ENOTSUP)
15180 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15183 #ifdef RTE_NET_BNXT
15184 if (ret == -ENOTSUP)
15185 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15193 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15196 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15199 fprintf(stderr, "function not implemented\n");
15202 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15206 cmdline_parse_inst_t cmd_clear_vf_stats = {
15207 .f = cmd_clear_vf_stats_parsed,
15209 .help_str = "clear vf stats <port_id> <vf_id>",
15211 (void *)&cmd_clear_vf_stats_clear,
15212 (void *)&cmd_clear_vf_stats_vf,
15213 (void *)&cmd_clear_vf_stats_stats,
15214 (void *)&cmd_clear_vf_stats_port_id,
15215 (void *)&cmd_clear_vf_stats_vf_id,
15220 /* port config pctype mapping reset */
15222 /* Common result structure for port config pctype mapping reset */
15223 struct cmd_pctype_mapping_reset_result {
15224 cmdline_fixed_string_t port;
15225 cmdline_fixed_string_t config;
15227 cmdline_fixed_string_t pctype;
15228 cmdline_fixed_string_t mapping;
15229 cmdline_fixed_string_t reset;
15232 /* Common CLI fields for port config pctype mapping reset*/
15233 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15234 TOKEN_STRING_INITIALIZER
15235 (struct cmd_pctype_mapping_reset_result,
15237 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15238 TOKEN_STRING_INITIALIZER
15239 (struct cmd_pctype_mapping_reset_result,
15241 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15242 TOKEN_NUM_INITIALIZER
15243 (struct cmd_pctype_mapping_reset_result,
15244 port_id, RTE_UINT16);
15245 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15246 TOKEN_STRING_INITIALIZER
15247 (struct cmd_pctype_mapping_reset_result,
15249 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15250 TOKEN_STRING_INITIALIZER
15251 (struct cmd_pctype_mapping_reset_result,
15252 mapping, "mapping");
15253 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15254 TOKEN_STRING_INITIALIZER
15255 (struct cmd_pctype_mapping_reset_result,
15259 cmd_pctype_mapping_reset_parsed(
15260 void *parsed_result,
15261 __rte_unused struct cmdline *cl,
15262 __rte_unused void *data)
15264 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15265 int ret = -ENOTSUP;
15267 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15270 #ifdef RTE_NET_I40E
15271 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15278 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15281 fprintf(stderr, "function not implemented\n");
15284 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15288 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15289 .f = cmd_pctype_mapping_reset_parsed,
15291 .help_str = "port config <port_id> pctype mapping reset",
15293 (void *)&cmd_pctype_mapping_reset_port,
15294 (void *)&cmd_pctype_mapping_reset_config,
15295 (void *)&cmd_pctype_mapping_reset_port_id,
15296 (void *)&cmd_pctype_mapping_reset_pctype,
15297 (void *)&cmd_pctype_mapping_reset_mapping,
15298 (void *)&cmd_pctype_mapping_reset_reset,
15303 /* show port pctype mapping */
15305 /* Common result structure for show port pctype mapping */
15306 struct cmd_pctype_mapping_get_result {
15307 cmdline_fixed_string_t show;
15308 cmdline_fixed_string_t port;
15310 cmdline_fixed_string_t pctype;
15311 cmdline_fixed_string_t mapping;
15314 /* Common CLI fields for pctype mapping get */
15315 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15316 TOKEN_STRING_INITIALIZER
15317 (struct cmd_pctype_mapping_get_result,
15319 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15320 TOKEN_STRING_INITIALIZER
15321 (struct cmd_pctype_mapping_get_result,
15323 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15324 TOKEN_NUM_INITIALIZER
15325 (struct cmd_pctype_mapping_get_result,
15326 port_id, RTE_UINT16);
15327 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15328 TOKEN_STRING_INITIALIZER
15329 (struct cmd_pctype_mapping_get_result,
15331 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15332 TOKEN_STRING_INITIALIZER
15333 (struct cmd_pctype_mapping_get_result,
15334 mapping, "mapping");
15337 cmd_pctype_mapping_get_parsed(
15338 void *parsed_result,
15339 __rte_unused struct cmdline *cl,
15340 __rte_unused void *data)
15342 struct cmd_pctype_mapping_get_result *res = parsed_result;
15343 int ret = -ENOTSUP;
15344 #ifdef RTE_NET_I40E
15345 struct rte_pmd_i40e_flow_type_mapping
15346 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15347 int i, j, first_pctype;
15350 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15353 #ifdef RTE_NET_I40E
15354 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15361 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15364 fprintf(stderr, "function not implemented\n");
15367 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15371 #ifdef RTE_NET_I40E
15372 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15373 if (mapping[i].pctype != 0ULL) {
15376 printf("pctype: ");
15377 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15378 if (mapping[i].pctype & (1ULL << j)) {
15379 printf(first_pctype ?
15380 "%02d" : ",%02d", j);
15384 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15390 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15391 .f = cmd_pctype_mapping_get_parsed,
15393 .help_str = "show port <port_id> pctype mapping",
15395 (void *)&cmd_pctype_mapping_get_show,
15396 (void *)&cmd_pctype_mapping_get_port,
15397 (void *)&cmd_pctype_mapping_get_port_id,
15398 (void *)&cmd_pctype_mapping_get_pctype,
15399 (void *)&cmd_pctype_mapping_get_mapping,
15404 /* port config pctype mapping update */
15406 /* Common result structure for port config pctype mapping update */
15407 struct cmd_pctype_mapping_update_result {
15408 cmdline_fixed_string_t port;
15409 cmdline_fixed_string_t config;
15411 cmdline_fixed_string_t pctype;
15412 cmdline_fixed_string_t mapping;
15413 cmdline_fixed_string_t update;
15414 cmdline_fixed_string_t pctype_list;
15415 uint16_t flow_type;
15418 /* Common CLI fields for pctype mapping update*/
15419 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15420 TOKEN_STRING_INITIALIZER
15421 (struct cmd_pctype_mapping_update_result,
15423 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15424 TOKEN_STRING_INITIALIZER
15425 (struct cmd_pctype_mapping_update_result,
15427 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15428 TOKEN_NUM_INITIALIZER
15429 (struct cmd_pctype_mapping_update_result,
15430 port_id, RTE_UINT16);
15431 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15432 TOKEN_STRING_INITIALIZER
15433 (struct cmd_pctype_mapping_update_result,
15435 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15436 TOKEN_STRING_INITIALIZER
15437 (struct cmd_pctype_mapping_update_result,
15438 mapping, "mapping");
15439 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15440 TOKEN_STRING_INITIALIZER
15441 (struct cmd_pctype_mapping_update_result,
15443 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15444 TOKEN_STRING_INITIALIZER
15445 (struct cmd_pctype_mapping_update_result,
15446 pctype_list, NULL);
15447 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15448 TOKEN_NUM_INITIALIZER
15449 (struct cmd_pctype_mapping_update_result,
15450 flow_type, RTE_UINT16);
15453 cmd_pctype_mapping_update_parsed(
15454 void *parsed_result,
15455 __rte_unused struct cmdline *cl,
15456 __rte_unused void *data)
15458 struct cmd_pctype_mapping_update_result *res = parsed_result;
15459 int ret = -ENOTSUP;
15460 #ifdef RTE_NET_I40E
15461 struct rte_pmd_i40e_flow_type_mapping mapping;
15463 unsigned int nb_item;
15464 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15467 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15470 #ifdef RTE_NET_I40E
15471 nb_item = parse_item_list(res->pctype_list, "pctypes",
15472 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15473 mapping.flow_type = res->flow_type;
15474 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15475 mapping.pctype |= (1ULL << pctype_list[i]);
15476 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15486 fprintf(stderr, "invalid pctype or flow type\n");
15489 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15492 fprintf(stderr, "function not implemented\n");
15495 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15499 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15500 .f = cmd_pctype_mapping_update_parsed,
15502 .help_str = "port config <port_id> pctype mapping update"
15503 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15505 (void *)&cmd_pctype_mapping_update_port,
15506 (void *)&cmd_pctype_mapping_update_config,
15507 (void *)&cmd_pctype_mapping_update_port_id,
15508 (void *)&cmd_pctype_mapping_update_pctype,
15509 (void *)&cmd_pctype_mapping_update_mapping,
15510 (void *)&cmd_pctype_mapping_update_update,
15511 (void *)&cmd_pctype_mapping_update_pc_type,
15512 (void *)&cmd_pctype_mapping_update_flow_type,
15517 /* ptype mapping get */
15519 /* Common result structure for ptype mapping get */
15520 struct cmd_ptype_mapping_get_result {
15521 cmdline_fixed_string_t ptype;
15522 cmdline_fixed_string_t mapping;
15523 cmdline_fixed_string_t get;
15525 uint8_t valid_only;
15528 /* Common CLI fields for ptype mapping get */
15529 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15530 TOKEN_STRING_INITIALIZER
15531 (struct cmd_ptype_mapping_get_result,
15533 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15534 TOKEN_STRING_INITIALIZER
15535 (struct cmd_ptype_mapping_get_result,
15536 mapping, "mapping");
15537 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15538 TOKEN_STRING_INITIALIZER
15539 (struct cmd_ptype_mapping_get_result,
15541 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15542 TOKEN_NUM_INITIALIZER
15543 (struct cmd_ptype_mapping_get_result,
15544 port_id, RTE_UINT16);
15545 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15546 TOKEN_NUM_INITIALIZER
15547 (struct cmd_ptype_mapping_get_result,
15548 valid_only, RTE_UINT8);
15551 cmd_ptype_mapping_get_parsed(
15552 void *parsed_result,
15553 __rte_unused struct cmdline *cl,
15554 __rte_unused void *data)
15556 struct cmd_ptype_mapping_get_result *res = parsed_result;
15557 int ret = -ENOTSUP;
15558 #ifdef RTE_NET_I40E
15559 int max_ptype_num = 256;
15560 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15565 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15568 #ifdef RTE_NET_I40E
15569 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15580 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15583 fprintf(stderr, "function not implemented\n");
15586 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15589 #ifdef RTE_NET_I40E
15591 for (i = 0; i < count; i++)
15592 printf("%3d\t0x%08x\n",
15593 mapping[i].hw_ptype, mapping[i].sw_ptype);
15598 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15599 .f = cmd_ptype_mapping_get_parsed,
15601 .help_str = "ptype mapping get <port_id> <valid_only>",
15603 (void *)&cmd_ptype_mapping_get_ptype,
15604 (void *)&cmd_ptype_mapping_get_mapping,
15605 (void *)&cmd_ptype_mapping_get_get,
15606 (void *)&cmd_ptype_mapping_get_port_id,
15607 (void *)&cmd_ptype_mapping_get_valid_only,
15612 /* ptype mapping replace */
15614 /* Common result structure for ptype mapping replace */
15615 struct cmd_ptype_mapping_replace_result {
15616 cmdline_fixed_string_t ptype;
15617 cmdline_fixed_string_t mapping;
15618 cmdline_fixed_string_t replace;
15625 /* Common CLI fields for ptype mapping replace */
15626 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15627 TOKEN_STRING_INITIALIZER
15628 (struct cmd_ptype_mapping_replace_result,
15630 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15631 TOKEN_STRING_INITIALIZER
15632 (struct cmd_ptype_mapping_replace_result,
15633 mapping, "mapping");
15634 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15635 TOKEN_STRING_INITIALIZER
15636 (struct cmd_ptype_mapping_replace_result,
15637 replace, "replace");
15638 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15639 TOKEN_NUM_INITIALIZER
15640 (struct cmd_ptype_mapping_replace_result,
15641 port_id, RTE_UINT16);
15642 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15643 TOKEN_NUM_INITIALIZER
15644 (struct cmd_ptype_mapping_replace_result,
15645 target, RTE_UINT32);
15646 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15647 TOKEN_NUM_INITIALIZER
15648 (struct cmd_ptype_mapping_replace_result,
15650 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15651 TOKEN_NUM_INITIALIZER
15652 (struct cmd_ptype_mapping_replace_result,
15653 pkt_type, RTE_UINT32);
15656 cmd_ptype_mapping_replace_parsed(
15657 void *parsed_result,
15658 __rte_unused struct cmdline *cl,
15659 __rte_unused void *data)
15661 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15662 int ret = -ENOTSUP;
15664 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15667 #ifdef RTE_NET_I40E
15668 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15678 fprintf(stderr, "invalid ptype 0x%8x or 0x%8x\n",
15679 res->target, res->pkt_type);
15682 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15685 fprintf(stderr, "function not implemented\n");
15688 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15692 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15693 .f = cmd_ptype_mapping_replace_parsed,
15696 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15698 (void *)&cmd_ptype_mapping_replace_ptype,
15699 (void *)&cmd_ptype_mapping_replace_mapping,
15700 (void *)&cmd_ptype_mapping_replace_replace,
15701 (void *)&cmd_ptype_mapping_replace_port_id,
15702 (void *)&cmd_ptype_mapping_replace_target,
15703 (void *)&cmd_ptype_mapping_replace_mask,
15704 (void *)&cmd_ptype_mapping_replace_pkt_type,
15709 /* ptype mapping reset */
15711 /* Common result structure for ptype mapping reset */
15712 struct cmd_ptype_mapping_reset_result {
15713 cmdline_fixed_string_t ptype;
15714 cmdline_fixed_string_t mapping;
15715 cmdline_fixed_string_t reset;
15719 /* Common CLI fields for ptype mapping reset*/
15720 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15721 TOKEN_STRING_INITIALIZER
15722 (struct cmd_ptype_mapping_reset_result,
15724 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15725 TOKEN_STRING_INITIALIZER
15726 (struct cmd_ptype_mapping_reset_result,
15727 mapping, "mapping");
15728 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15729 TOKEN_STRING_INITIALIZER
15730 (struct cmd_ptype_mapping_reset_result,
15732 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15733 TOKEN_NUM_INITIALIZER
15734 (struct cmd_ptype_mapping_reset_result,
15735 port_id, RTE_UINT16);
15738 cmd_ptype_mapping_reset_parsed(
15739 void *parsed_result,
15740 __rte_unused struct cmdline *cl,
15741 __rte_unused void *data)
15743 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15744 int ret = -ENOTSUP;
15746 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15749 #ifdef RTE_NET_I40E
15750 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15757 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15760 fprintf(stderr, "function not implemented\n");
15763 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15767 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15768 .f = cmd_ptype_mapping_reset_parsed,
15770 .help_str = "ptype mapping reset <port_id>",
15772 (void *)&cmd_ptype_mapping_reset_ptype,
15773 (void *)&cmd_ptype_mapping_reset_mapping,
15774 (void *)&cmd_ptype_mapping_reset_reset,
15775 (void *)&cmd_ptype_mapping_reset_port_id,
15780 /* ptype mapping update */
15782 /* Common result structure for ptype mapping update */
15783 struct cmd_ptype_mapping_update_result {
15784 cmdline_fixed_string_t ptype;
15785 cmdline_fixed_string_t mapping;
15786 cmdline_fixed_string_t reset;
15792 /* Common CLI fields for ptype mapping update*/
15793 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15794 TOKEN_STRING_INITIALIZER
15795 (struct cmd_ptype_mapping_update_result,
15797 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15798 TOKEN_STRING_INITIALIZER
15799 (struct cmd_ptype_mapping_update_result,
15800 mapping, "mapping");
15801 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15802 TOKEN_STRING_INITIALIZER
15803 (struct cmd_ptype_mapping_update_result,
15805 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15806 TOKEN_NUM_INITIALIZER
15807 (struct cmd_ptype_mapping_update_result,
15808 port_id, RTE_UINT16);
15809 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15810 TOKEN_NUM_INITIALIZER
15811 (struct cmd_ptype_mapping_update_result,
15812 hw_ptype, RTE_UINT8);
15813 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15814 TOKEN_NUM_INITIALIZER
15815 (struct cmd_ptype_mapping_update_result,
15816 sw_ptype, RTE_UINT32);
15819 cmd_ptype_mapping_update_parsed(
15820 void *parsed_result,
15821 __rte_unused struct cmdline *cl,
15822 __rte_unused void *data)
15824 struct cmd_ptype_mapping_update_result *res = parsed_result;
15825 int ret = -ENOTSUP;
15826 #ifdef RTE_NET_I40E
15827 struct rte_pmd_i40e_ptype_mapping mapping;
15829 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15832 #ifdef RTE_NET_I40E
15833 mapping.hw_ptype = res->hw_ptype;
15834 mapping.sw_ptype = res->sw_ptype;
15835 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15845 fprintf(stderr, "invalid ptype 0x%8x\n", res->sw_ptype);
15848 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15851 fprintf(stderr, "function not implemented\n");
15854 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15858 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15859 .f = cmd_ptype_mapping_update_parsed,
15861 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15863 (void *)&cmd_ptype_mapping_update_ptype,
15864 (void *)&cmd_ptype_mapping_update_mapping,
15865 (void *)&cmd_ptype_mapping_update_update,
15866 (void *)&cmd_ptype_mapping_update_port_id,
15867 (void *)&cmd_ptype_mapping_update_hw_ptype,
15868 (void *)&cmd_ptype_mapping_update_sw_ptype,
15873 /* Common result structure for file commands */
15874 struct cmd_cmdfile_result {
15875 cmdline_fixed_string_t load;
15876 cmdline_fixed_string_t filename;
15879 /* Common CLI fields for file commands */
15880 cmdline_parse_token_string_t cmd_load_cmdfile =
15881 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15882 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15883 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15886 cmd_load_from_file_parsed(
15887 void *parsed_result,
15888 __rte_unused struct cmdline *cl,
15889 __rte_unused void *data)
15891 struct cmd_cmdfile_result *res = parsed_result;
15893 cmdline_read_from_file(res->filename);
15896 cmdline_parse_inst_t cmd_load_from_file = {
15897 .f = cmd_load_from_file_parsed,
15899 .help_str = "load <filename>",
15901 (void *)&cmd_load_cmdfile,
15902 (void *)&cmd_load_cmdfile_filename,
15907 /* Get Rx offloads capabilities */
15908 struct cmd_rx_offload_get_capa_result {
15909 cmdline_fixed_string_t show;
15910 cmdline_fixed_string_t port;
15912 cmdline_fixed_string_t rx_offload;
15913 cmdline_fixed_string_t capabilities;
15916 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
15917 TOKEN_STRING_INITIALIZER
15918 (struct cmd_rx_offload_get_capa_result,
15920 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
15921 TOKEN_STRING_INITIALIZER
15922 (struct cmd_rx_offload_get_capa_result,
15924 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
15925 TOKEN_NUM_INITIALIZER
15926 (struct cmd_rx_offload_get_capa_result,
15927 port_id, RTE_UINT16);
15928 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
15929 TOKEN_STRING_INITIALIZER
15930 (struct cmd_rx_offload_get_capa_result,
15931 rx_offload, "rx_offload");
15932 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
15933 TOKEN_STRING_INITIALIZER
15934 (struct cmd_rx_offload_get_capa_result,
15935 capabilities, "capabilities");
15938 print_rx_offloads(uint64_t offloads)
15940 uint64_t single_offload;
15948 begin = __builtin_ctzll(offloads);
15949 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15951 single_offload = 1ULL << begin;
15952 for (bit = begin; bit < end; bit++) {
15953 if (offloads & single_offload)
15955 rte_eth_dev_rx_offload_name(single_offload));
15956 single_offload <<= 1;
15961 cmd_rx_offload_get_capa_parsed(
15962 void *parsed_result,
15963 __rte_unused struct cmdline *cl,
15964 __rte_unused void *data)
15966 struct cmd_rx_offload_get_capa_result *res = parsed_result;
15967 struct rte_eth_dev_info dev_info;
15968 portid_t port_id = res->port_id;
15969 uint64_t queue_offloads;
15970 uint64_t port_offloads;
15973 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15977 queue_offloads = dev_info.rx_queue_offload_capa;
15978 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
15980 printf("Rx Offloading Capabilities of port %d :\n", port_id);
15981 printf(" Per Queue :");
15982 print_rx_offloads(queue_offloads);
15985 printf(" Per Port :");
15986 print_rx_offloads(port_offloads);
15990 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
15991 .f = cmd_rx_offload_get_capa_parsed,
15993 .help_str = "show port <port_id> rx_offload capabilities",
15995 (void *)&cmd_rx_offload_get_capa_show,
15996 (void *)&cmd_rx_offload_get_capa_port,
15997 (void *)&cmd_rx_offload_get_capa_port_id,
15998 (void *)&cmd_rx_offload_get_capa_rx_offload,
15999 (void *)&cmd_rx_offload_get_capa_capabilities,
16004 /* Get Rx offloads configuration */
16005 struct cmd_rx_offload_get_configuration_result {
16006 cmdline_fixed_string_t show;
16007 cmdline_fixed_string_t port;
16009 cmdline_fixed_string_t rx_offload;
16010 cmdline_fixed_string_t configuration;
16013 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
16014 TOKEN_STRING_INITIALIZER
16015 (struct cmd_rx_offload_get_configuration_result,
16017 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
16018 TOKEN_STRING_INITIALIZER
16019 (struct cmd_rx_offload_get_configuration_result,
16021 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
16022 TOKEN_NUM_INITIALIZER
16023 (struct cmd_rx_offload_get_configuration_result,
16024 port_id, RTE_UINT16);
16025 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
16026 TOKEN_STRING_INITIALIZER
16027 (struct cmd_rx_offload_get_configuration_result,
16028 rx_offload, "rx_offload");
16029 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
16030 TOKEN_STRING_INITIALIZER
16031 (struct cmd_rx_offload_get_configuration_result,
16032 configuration, "configuration");
16035 cmd_rx_offload_get_configuration_parsed(
16036 void *parsed_result,
16037 __rte_unused struct cmdline *cl,
16038 __rte_unused void *data)
16040 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
16041 struct rte_eth_dev_info dev_info;
16042 portid_t port_id = res->port_id;
16043 struct rte_port *port = &ports[port_id];
16044 struct rte_eth_conf dev_conf;
16045 uint64_t port_offloads;
16046 uint64_t queue_offloads;
16047 uint16_t nb_rx_queues;
16051 printf("Rx Offloading Configuration of port %d :\n", port_id);
16053 ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
16057 port_offloads = dev_conf.rxmode.offloads;
16059 print_rx_offloads(port_offloads);
16062 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16066 nb_rx_queues = dev_info.nb_rx_queues;
16067 for (q = 0; q < nb_rx_queues; q++) {
16068 queue_offloads = port->rx_conf[q].offloads;
16069 printf(" Queue[%2d] :", q);
16070 print_rx_offloads(queue_offloads);
16076 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
16077 .f = cmd_rx_offload_get_configuration_parsed,
16079 .help_str = "show port <port_id> rx_offload configuration",
16081 (void *)&cmd_rx_offload_get_configuration_show,
16082 (void *)&cmd_rx_offload_get_configuration_port,
16083 (void *)&cmd_rx_offload_get_configuration_port_id,
16084 (void *)&cmd_rx_offload_get_configuration_rx_offload,
16085 (void *)&cmd_rx_offload_get_configuration_configuration,
16090 /* Enable/Disable a per port offloading */
16091 struct cmd_config_per_port_rx_offload_result {
16092 cmdline_fixed_string_t port;
16093 cmdline_fixed_string_t config;
16095 cmdline_fixed_string_t rx_offload;
16096 cmdline_fixed_string_t offload;
16097 cmdline_fixed_string_t on_off;
16100 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
16101 TOKEN_STRING_INITIALIZER
16102 (struct cmd_config_per_port_rx_offload_result,
16104 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
16105 TOKEN_STRING_INITIALIZER
16106 (struct cmd_config_per_port_rx_offload_result,
16108 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
16109 TOKEN_NUM_INITIALIZER
16110 (struct cmd_config_per_port_rx_offload_result,
16111 port_id, RTE_UINT16);
16112 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
16113 TOKEN_STRING_INITIALIZER
16114 (struct cmd_config_per_port_rx_offload_result,
16115 rx_offload, "rx_offload");
16116 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
16117 TOKEN_STRING_INITIALIZER
16118 (struct cmd_config_per_port_rx_offload_result,
16119 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16120 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16121 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16122 "scatter#buffer_split#timestamp#security#"
16123 "keep_crc#rss_hash");
16124 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
16125 TOKEN_STRING_INITIALIZER
16126 (struct cmd_config_per_port_rx_offload_result,
16130 search_rx_offload(const char *name)
16132 uint64_t single_offload;
16133 const char *single_name;
16137 single_offload = 1;
16138 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16139 single_name = rte_eth_dev_rx_offload_name(single_offload);
16140 if (!strcasecmp(single_name, name)) {
16144 single_offload <<= 1;
16148 return single_offload;
16154 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16155 __rte_unused struct cmdline *cl,
16156 __rte_unused void *data)
16158 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16159 portid_t port_id = res->port_id;
16160 struct rte_eth_dev_info dev_info;
16161 struct rte_port *port = &ports[port_id];
16162 uint64_t single_offload;
16163 uint16_t nb_rx_queues;
16167 if (port->port_status != RTE_PORT_STOPPED) {
16169 "Error: Can't config offload when Port %d is not stopped\n",
16174 single_offload = search_rx_offload(res->offload);
16175 if (single_offload == 0) {
16176 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16180 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16184 nb_rx_queues = dev_info.nb_rx_queues;
16185 if (!strcmp(res->on_off, "on")) {
16186 port->dev_conf.rxmode.offloads |= single_offload;
16187 for (q = 0; q < nb_rx_queues; q++)
16188 port->rx_conf[q].offloads |= single_offload;
16190 port->dev_conf.rxmode.offloads &= ~single_offload;
16191 for (q = 0; q < nb_rx_queues; q++)
16192 port->rx_conf[q].offloads &= ~single_offload;
16195 cmd_reconfig_device_queue(port_id, 1, 1);
16198 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16199 .f = cmd_config_per_port_rx_offload_parsed,
16201 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16202 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16203 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16204 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16205 "keep_crc|rss_hash on|off",
16207 (void *)&cmd_config_per_port_rx_offload_result_port,
16208 (void *)&cmd_config_per_port_rx_offload_result_config,
16209 (void *)&cmd_config_per_port_rx_offload_result_port_id,
16210 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16211 (void *)&cmd_config_per_port_rx_offload_result_offload,
16212 (void *)&cmd_config_per_port_rx_offload_result_on_off,
16217 /* Enable/Disable a per queue offloading */
16218 struct cmd_config_per_queue_rx_offload_result {
16219 cmdline_fixed_string_t port;
16221 cmdline_fixed_string_t rxq;
16223 cmdline_fixed_string_t rx_offload;
16224 cmdline_fixed_string_t offload;
16225 cmdline_fixed_string_t on_off;
16228 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16229 TOKEN_STRING_INITIALIZER
16230 (struct cmd_config_per_queue_rx_offload_result,
16232 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16233 TOKEN_NUM_INITIALIZER
16234 (struct cmd_config_per_queue_rx_offload_result,
16235 port_id, RTE_UINT16);
16236 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16237 TOKEN_STRING_INITIALIZER
16238 (struct cmd_config_per_queue_rx_offload_result,
16240 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16241 TOKEN_NUM_INITIALIZER
16242 (struct cmd_config_per_queue_rx_offload_result,
16243 queue_id, RTE_UINT16);
16244 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16245 TOKEN_STRING_INITIALIZER
16246 (struct cmd_config_per_queue_rx_offload_result,
16247 rx_offload, "rx_offload");
16248 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16249 TOKEN_STRING_INITIALIZER
16250 (struct cmd_config_per_queue_rx_offload_result,
16251 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16252 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16253 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16254 "scatter#buffer_split#timestamp#security#keep_crc");
16255 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16256 TOKEN_STRING_INITIALIZER
16257 (struct cmd_config_per_queue_rx_offload_result,
16261 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16262 __rte_unused struct cmdline *cl,
16263 __rte_unused void *data)
16265 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16266 struct rte_eth_dev_info dev_info;
16267 portid_t port_id = res->port_id;
16268 uint16_t queue_id = res->queue_id;
16269 struct rte_port *port = &ports[port_id];
16270 uint64_t single_offload;
16273 if (port->port_status != RTE_PORT_STOPPED) {
16275 "Error: Can't config offload when Port %d is not stopped\n",
16280 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16284 if (queue_id >= dev_info.nb_rx_queues) {
16286 "Error: input queue_id should be 0 ... %d\n",
16287 dev_info.nb_rx_queues - 1);
16291 single_offload = search_rx_offload(res->offload);
16292 if (single_offload == 0) {
16293 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16297 if (!strcmp(res->on_off, "on"))
16298 port->rx_conf[queue_id].offloads |= single_offload;
16300 port->rx_conf[queue_id].offloads &= ~single_offload;
16302 cmd_reconfig_device_queue(port_id, 1, 1);
16305 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16306 .f = cmd_config_per_queue_rx_offload_parsed,
16308 .help_str = "port <port_id> rxq <queue_id> rx_offload "
16309 "vlan_strip|ipv4_cksum|"
16310 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16311 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16312 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16315 (void *)&cmd_config_per_queue_rx_offload_result_port,
16316 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
16317 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
16318 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16319 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16320 (void *)&cmd_config_per_queue_rx_offload_result_offload,
16321 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
16326 /* Get Tx offloads capabilities */
16327 struct cmd_tx_offload_get_capa_result {
16328 cmdline_fixed_string_t show;
16329 cmdline_fixed_string_t port;
16331 cmdline_fixed_string_t tx_offload;
16332 cmdline_fixed_string_t capabilities;
16335 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16336 TOKEN_STRING_INITIALIZER
16337 (struct cmd_tx_offload_get_capa_result,
16339 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16340 TOKEN_STRING_INITIALIZER
16341 (struct cmd_tx_offload_get_capa_result,
16343 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16344 TOKEN_NUM_INITIALIZER
16345 (struct cmd_tx_offload_get_capa_result,
16346 port_id, RTE_UINT16);
16347 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16348 TOKEN_STRING_INITIALIZER
16349 (struct cmd_tx_offload_get_capa_result,
16350 tx_offload, "tx_offload");
16351 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16352 TOKEN_STRING_INITIALIZER
16353 (struct cmd_tx_offload_get_capa_result,
16354 capabilities, "capabilities");
16357 print_tx_offloads(uint64_t offloads)
16359 uint64_t single_offload;
16367 begin = __builtin_ctzll(offloads);
16368 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16370 single_offload = 1ULL << begin;
16371 for (bit = begin; bit < end; bit++) {
16372 if (offloads & single_offload)
16374 rte_eth_dev_tx_offload_name(single_offload));
16375 single_offload <<= 1;
16380 cmd_tx_offload_get_capa_parsed(
16381 void *parsed_result,
16382 __rte_unused struct cmdline *cl,
16383 __rte_unused void *data)
16385 struct cmd_tx_offload_get_capa_result *res = parsed_result;
16386 struct rte_eth_dev_info dev_info;
16387 portid_t port_id = res->port_id;
16388 uint64_t queue_offloads;
16389 uint64_t port_offloads;
16392 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16396 queue_offloads = dev_info.tx_queue_offload_capa;
16397 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16399 printf("Tx Offloading Capabilities of port %d :\n", port_id);
16400 printf(" Per Queue :");
16401 print_tx_offloads(queue_offloads);
16404 printf(" Per Port :");
16405 print_tx_offloads(port_offloads);
16409 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16410 .f = cmd_tx_offload_get_capa_parsed,
16412 .help_str = "show port <port_id> tx_offload capabilities",
16414 (void *)&cmd_tx_offload_get_capa_show,
16415 (void *)&cmd_tx_offload_get_capa_port,
16416 (void *)&cmd_tx_offload_get_capa_port_id,
16417 (void *)&cmd_tx_offload_get_capa_tx_offload,
16418 (void *)&cmd_tx_offload_get_capa_capabilities,
16423 /* Get Tx offloads configuration */
16424 struct cmd_tx_offload_get_configuration_result {
16425 cmdline_fixed_string_t show;
16426 cmdline_fixed_string_t port;
16428 cmdline_fixed_string_t tx_offload;
16429 cmdline_fixed_string_t configuration;
16432 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16433 TOKEN_STRING_INITIALIZER
16434 (struct cmd_tx_offload_get_configuration_result,
16436 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16437 TOKEN_STRING_INITIALIZER
16438 (struct cmd_tx_offload_get_configuration_result,
16440 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16441 TOKEN_NUM_INITIALIZER
16442 (struct cmd_tx_offload_get_configuration_result,
16443 port_id, RTE_UINT16);
16444 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16445 TOKEN_STRING_INITIALIZER
16446 (struct cmd_tx_offload_get_configuration_result,
16447 tx_offload, "tx_offload");
16448 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16449 TOKEN_STRING_INITIALIZER
16450 (struct cmd_tx_offload_get_configuration_result,
16451 configuration, "configuration");
16454 cmd_tx_offload_get_configuration_parsed(
16455 void *parsed_result,
16456 __rte_unused struct cmdline *cl,
16457 __rte_unused void *data)
16459 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16460 struct rte_eth_dev_info dev_info;
16461 portid_t port_id = res->port_id;
16462 struct rte_port *port = &ports[port_id];
16463 struct rte_eth_conf dev_conf;
16464 uint64_t port_offloads;
16465 uint64_t queue_offloads;
16466 uint16_t nb_tx_queues;
16470 printf("Tx Offloading Configuration of port %d :\n", port_id);
16472 ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
16476 port_offloads = dev_conf.txmode.offloads;
16478 print_tx_offloads(port_offloads);
16481 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16485 nb_tx_queues = dev_info.nb_tx_queues;
16486 for (q = 0; q < nb_tx_queues; q++) {
16487 queue_offloads = port->tx_conf[q].offloads;
16488 printf(" Queue[%2d] :", q);
16489 print_tx_offloads(queue_offloads);
16495 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16496 .f = cmd_tx_offload_get_configuration_parsed,
16498 .help_str = "show port <port_id> tx_offload configuration",
16500 (void *)&cmd_tx_offload_get_configuration_show,
16501 (void *)&cmd_tx_offload_get_configuration_port,
16502 (void *)&cmd_tx_offload_get_configuration_port_id,
16503 (void *)&cmd_tx_offload_get_configuration_tx_offload,
16504 (void *)&cmd_tx_offload_get_configuration_configuration,
16509 /* Enable/Disable a per port offloading */
16510 struct cmd_config_per_port_tx_offload_result {
16511 cmdline_fixed_string_t port;
16512 cmdline_fixed_string_t config;
16514 cmdline_fixed_string_t tx_offload;
16515 cmdline_fixed_string_t offload;
16516 cmdline_fixed_string_t on_off;
16519 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16520 TOKEN_STRING_INITIALIZER
16521 (struct cmd_config_per_port_tx_offload_result,
16523 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16524 TOKEN_STRING_INITIALIZER
16525 (struct cmd_config_per_port_tx_offload_result,
16527 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16528 TOKEN_NUM_INITIALIZER
16529 (struct cmd_config_per_port_tx_offload_result,
16530 port_id, RTE_UINT16);
16531 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16532 TOKEN_STRING_INITIALIZER
16533 (struct cmd_config_per_port_tx_offload_result,
16534 tx_offload, "tx_offload");
16535 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16536 TOKEN_STRING_INITIALIZER
16537 (struct cmd_config_per_port_tx_offload_result,
16538 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16539 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16540 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16541 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16542 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16543 "send_on_timestamp");
16544 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16545 TOKEN_STRING_INITIALIZER
16546 (struct cmd_config_per_port_tx_offload_result,
16550 search_tx_offload(const char *name)
16552 uint64_t single_offload;
16553 const char *single_name;
16557 single_offload = 1;
16558 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16559 single_name = rte_eth_dev_tx_offload_name(single_offload);
16560 if (single_name == NULL)
16562 if (!strcasecmp(single_name, name)) {
16565 } else if (!strcasecmp(single_name, "UNKNOWN"))
16567 single_offload <<= 1;
16571 return single_offload;
16577 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16578 __rte_unused struct cmdline *cl,
16579 __rte_unused void *data)
16581 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16582 portid_t port_id = res->port_id;
16583 struct rte_eth_dev_info dev_info;
16584 struct rte_port *port = &ports[port_id];
16585 uint64_t single_offload;
16586 uint16_t nb_tx_queues;
16590 if (port->port_status != RTE_PORT_STOPPED) {
16592 "Error: Can't config offload when Port %d is not stopped\n",
16597 single_offload = search_tx_offload(res->offload);
16598 if (single_offload == 0) {
16599 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16603 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16607 nb_tx_queues = dev_info.nb_tx_queues;
16608 if (!strcmp(res->on_off, "on")) {
16609 port->dev_conf.txmode.offloads |= single_offload;
16610 for (q = 0; q < nb_tx_queues; q++)
16611 port->tx_conf[q].offloads |= single_offload;
16613 port->dev_conf.txmode.offloads &= ~single_offload;
16614 for (q = 0; q < nb_tx_queues; q++)
16615 port->tx_conf[q].offloads &= ~single_offload;
16618 cmd_reconfig_device_queue(port_id, 1, 1);
16621 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16622 .f = cmd_config_per_port_tx_offload_parsed,
16624 .help_str = "port config <port_id> tx_offload "
16625 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16626 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16627 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16628 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16629 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16630 "send_on_timestamp on|off",
16632 (void *)&cmd_config_per_port_tx_offload_result_port,
16633 (void *)&cmd_config_per_port_tx_offload_result_config,
16634 (void *)&cmd_config_per_port_tx_offload_result_port_id,
16635 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16636 (void *)&cmd_config_per_port_tx_offload_result_offload,
16637 (void *)&cmd_config_per_port_tx_offload_result_on_off,
16642 /* Enable/Disable a per queue offloading */
16643 struct cmd_config_per_queue_tx_offload_result {
16644 cmdline_fixed_string_t port;
16646 cmdline_fixed_string_t txq;
16648 cmdline_fixed_string_t tx_offload;
16649 cmdline_fixed_string_t offload;
16650 cmdline_fixed_string_t on_off;
16653 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16654 TOKEN_STRING_INITIALIZER
16655 (struct cmd_config_per_queue_tx_offload_result,
16657 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16658 TOKEN_NUM_INITIALIZER
16659 (struct cmd_config_per_queue_tx_offload_result,
16660 port_id, RTE_UINT16);
16661 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16662 TOKEN_STRING_INITIALIZER
16663 (struct cmd_config_per_queue_tx_offload_result,
16665 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16666 TOKEN_NUM_INITIALIZER
16667 (struct cmd_config_per_queue_tx_offload_result,
16668 queue_id, RTE_UINT16);
16669 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16670 TOKEN_STRING_INITIALIZER
16671 (struct cmd_config_per_queue_tx_offload_result,
16672 tx_offload, "tx_offload");
16673 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16674 TOKEN_STRING_INITIALIZER
16675 (struct cmd_config_per_queue_tx_offload_result,
16676 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16677 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16678 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16679 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16680 "mt_lockfree#multi_segs#mbuf_fast_free#security");
16681 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16682 TOKEN_STRING_INITIALIZER
16683 (struct cmd_config_per_queue_tx_offload_result,
16687 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16688 __rte_unused struct cmdline *cl,
16689 __rte_unused void *data)
16691 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16692 struct rte_eth_dev_info dev_info;
16693 portid_t port_id = res->port_id;
16694 uint16_t queue_id = res->queue_id;
16695 struct rte_port *port = &ports[port_id];
16696 uint64_t single_offload;
16699 if (port->port_status != RTE_PORT_STOPPED) {
16701 "Error: Can't config offload when Port %d is not stopped\n",
16706 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16710 if (queue_id >= dev_info.nb_tx_queues) {
16712 "Error: input queue_id should be 0 ... %d\n",
16713 dev_info.nb_tx_queues - 1);
16717 single_offload = search_tx_offload(res->offload);
16718 if (single_offload == 0) {
16719 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16723 if (!strcmp(res->on_off, "on"))
16724 port->tx_conf[queue_id].offloads |= single_offload;
16726 port->tx_conf[queue_id].offloads &= ~single_offload;
16728 cmd_reconfig_device_queue(port_id, 1, 1);
16731 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16732 .f = cmd_config_per_queue_tx_offload_parsed,
16734 .help_str = "port <port_id> txq <queue_id> tx_offload "
16735 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16736 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16737 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16738 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16739 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16742 (void *)&cmd_config_per_queue_tx_offload_result_port,
16743 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16744 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16745 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16746 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16747 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16748 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16753 /* *** configure tx_metadata for specific port *** */
16754 struct cmd_config_tx_metadata_specific_result {
16755 cmdline_fixed_string_t port;
16756 cmdline_fixed_string_t keyword;
16758 cmdline_fixed_string_t item;
16763 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16764 __rte_unused struct cmdline *cl,
16765 __rte_unused void *data)
16767 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16769 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16771 ports[res->port_id].tx_metadata = res->value;
16772 /* Add/remove callback to insert valid metadata in every Tx packet. */
16773 if (ports[res->port_id].tx_metadata)
16774 add_tx_md_callback(res->port_id);
16776 remove_tx_md_callback(res->port_id);
16777 rte_flow_dynf_metadata_register();
16780 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16781 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16783 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16784 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16785 keyword, "config");
16786 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16787 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16788 port_id, RTE_UINT16);
16789 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16790 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16791 item, "tx_metadata");
16792 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16793 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16794 value, RTE_UINT32);
16796 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16797 .f = cmd_config_tx_metadata_specific_parsed,
16799 .help_str = "port config <port_id> tx_metadata <value>",
16801 (void *)&cmd_config_tx_metadata_specific_port,
16802 (void *)&cmd_config_tx_metadata_specific_keyword,
16803 (void *)&cmd_config_tx_metadata_specific_id,
16804 (void *)&cmd_config_tx_metadata_specific_item,
16805 (void *)&cmd_config_tx_metadata_specific_value,
16810 /* *** set dynf *** */
16811 struct cmd_config_tx_dynf_specific_result {
16812 cmdline_fixed_string_t port;
16813 cmdline_fixed_string_t keyword;
16815 cmdline_fixed_string_t item;
16816 cmdline_fixed_string_t name;
16817 cmdline_fixed_string_t value;
16821 cmd_config_dynf_specific_parsed(void *parsed_result,
16822 __rte_unused struct cmdline *cl,
16823 __rte_unused void *data)
16825 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16826 struct rte_mbuf_dynflag desc_flag;
16828 uint64_t old_port_flags;
16830 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16832 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16834 if (strlcpy(desc_flag.name, res->name,
16835 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16836 fprintf(stderr, "Flag name too long\n");
16839 desc_flag.flags = 0;
16840 flag = rte_mbuf_dynflag_register(&desc_flag);
16842 fprintf(stderr, "Can't register flag\n");
16845 strcpy(dynf_names[flag], desc_flag.name);
16847 old_port_flags = ports[res->port_id].mbuf_dynf;
16848 if (!strcmp(res->value, "set")) {
16849 ports[res->port_id].mbuf_dynf |= 1UL << flag;
16850 if (old_port_flags == 0)
16851 add_tx_dynf_callback(res->port_id);
16853 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16854 if (ports[res->port_id].mbuf_dynf == 0)
16855 remove_tx_dynf_callback(res->port_id);
16859 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16860 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16862 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16863 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16864 keyword, "config");
16865 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
16866 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16867 port_id, RTE_UINT16);
16868 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
16869 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16871 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
16872 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16874 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
16875 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16876 value, "set#clear");
16878 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
16879 .f = cmd_config_dynf_specific_parsed,
16881 .help_str = "port config <port id> dynf <name> set|clear",
16883 (void *)&cmd_config_tx_dynf_specific_port,
16884 (void *)&cmd_config_tx_dynf_specific_keyword,
16885 (void *)&cmd_config_tx_dynf_specific_port_id,
16886 (void *)&cmd_config_tx_dynf_specific_item,
16887 (void *)&cmd_config_tx_dynf_specific_name,
16888 (void *)&cmd_config_tx_dynf_specific_value,
16893 /* *** display tx_metadata per port configuration *** */
16894 struct cmd_show_tx_metadata_result {
16895 cmdline_fixed_string_t cmd_show;
16896 cmdline_fixed_string_t cmd_port;
16897 cmdline_fixed_string_t cmd_keyword;
16902 cmd_show_tx_metadata_parsed(void *parsed_result,
16903 __rte_unused struct cmdline *cl,
16904 __rte_unused void *data)
16906 struct cmd_show_tx_metadata_result *res = parsed_result;
16908 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16909 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
16912 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
16913 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
16914 ports[res->cmd_pid].tx_metadata);
16918 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
16919 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16921 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
16922 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16924 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
16925 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
16926 cmd_pid, RTE_UINT16);
16927 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
16928 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16929 cmd_keyword, "tx_metadata");
16931 cmdline_parse_inst_t cmd_show_tx_metadata = {
16932 .f = cmd_show_tx_metadata_parsed,
16934 .help_str = "show port <port_id> tx_metadata",
16936 (void *)&cmd_show_tx_metadata_show,
16937 (void *)&cmd_show_tx_metadata_port,
16938 (void *)&cmd_show_tx_metadata_pid,
16939 (void *)&cmd_show_tx_metadata_keyword,
16944 /* *** show fec capability per port configuration *** */
16945 struct cmd_show_fec_capability_result {
16946 cmdline_fixed_string_t cmd_show;
16947 cmdline_fixed_string_t cmd_port;
16948 cmdline_fixed_string_t cmd_fec;
16949 cmdline_fixed_string_t cmd_keyword;
16954 cmd_show_fec_capability_parsed(void *parsed_result,
16955 __rte_unused struct cmdline *cl,
16956 __rte_unused void *data)
16958 struct cmd_show_fec_capability_result *res = parsed_result;
16959 struct rte_eth_fec_capa *speed_fec_capa;
16963 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16964 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
16968 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
16969 if (ret == -ENOTSUP) {
16970 fprintf(stderr, "Function not implemented\n");
16972 } else if (ret < 0) {
16973 fprintf(stderr, "Get FEC capability failed: %d\n", ret);
16977 num = (unsigned int)ret;
16978 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
16979 if (speed_fec_capa == NULL) {
16980 fprintf(stderr, "Failed to alloc FEC capability buffer\n");
16984 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
16986 fprintf(stderr, "Error getting FEC capability: %d\n", ret);
16990 show_fec_capability(num, speed_fec_capa);
16992 free(speed_fec_capa);
16995 cmdline_parse_token_string_t cmd_show_fec_capability_show =
16996 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16998 cmdline_parse_token_string_t cmd_show_fec_capability_port =
16999 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17001 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
17002 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
17003 cmd_pid, RTE_UINT16);
17004 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
17005 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17007 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
17008 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17009 cmd_keyword, "capabilities");
17011 cmdline_parse_inst_t cmd_show_capability = {
17012 .f = cmd_show_fec_capability_parsed,
17014 .help_str = "show port <port_id> fec capabilities",
17016 (void *)&cmd_show_fec_capability_show,
17017 (void *)&cmd_show_fec_capability_port,
17018 (void *)&cmd_show_fec_capability_pid,
17019 (void *)&cmd_show_fec_capability_fec,
17020 (void *)&cmd_show_fec_capability_keyword,
17025 /* *** show fec mode per port configuration *** */
17026 struct cmd_show_fec_metadata_result {
17027 cmdline_fixed_string_t cmd_show;
17028 cmdline_fixed_string_t cmd_port;
17029 cmdline_fixed_string_t cmd_keyword;
17034 cmd_show_fec_mode_parsed(void *parsed_result,
17035 __rte_unused struct cmdline *cl,
17036 __rte_unused void *data)
17038 #define FEC_NAME_SIZE 16
17039 struct cmd_show_fec_metadata_result *res = parsed_result;
17041 char buf[FEC_NAME_SIZE];
17044 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17045 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
17048 ret = rte_eth_fec_get(res->cmd_pid, &mode);
17049 if (ret == -ENOTSUP) {
17050 fprintf(stderr, "Function not implemented\n");
17052 } else if (ret < 0) {
17053 fprintf(stderr, "Get FEC mode failed\n");
17058 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
17059 strlcpy(buf, "off", sizeof(buf));
17061 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
17062 strlcpy(buf, "auto", sizeof(buf));
17064 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
17065 strlcpy(buf, "baser", sizeof(buf));
17067 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
17068 strlcpy(buf, "rs", sizeof(buf));
17074 printf("%s\n", buf);
17077 cmdline_parse_token_string_t cmd_show_fec_mode_show =
17078 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17080 cmdline_parse_token_string_t cmd_show_fec_mode_port =
17081 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17083 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
17084 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
17085 cmd_pid, RTE_UINT16);
17086 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
17087 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17088 cmd_keyword, "fec_mode");
17090 cmdline_parse_inst_t cmd_show_fec_mode = {
17091 .f = cmd_show_fec_mode_parsed,
17093 .help_str = "show port <port_id> fec_mode",
17095 (void *)&cmd_show_fec_mode_show,
17096 (void *)&cmd_show_fec_mode_port,
17097 (void *)&cmd_show_fec_mode_pid,
17098 (void *)&cmd_show_fec_mode_keyword,
17103 /* *** set fec mode per port configuration *** */
17104 struct cmd_set_port_fec_mode {
17105 cmdline_fixed_string_t set;
17106 cmdline_fixed_string_t port;
17108 cmdline_fixed_string_t fec_mode;
17109 cmdline_fixed_string_t fec_value;
17112 /* Common CLI fields for set fec mode */
17113 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
17114 TOKEN_STRING_INITIALIZER
17115 (struct cmd_set_port_fec_mode,
17117 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
17118 TOKEN_STRING_INITIALIZER
17119 (struct cmd_set_port_fec_mode,
17121 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
17122 TOKEN_NUM_INITIALIZER
17123 (struct cmd_set_port_fec_mode,
17124 port_id, RTE_UINT16);
17125 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
17126 TOKEN_STRING_INITIALIZER
17127 (struct cmd_set_port_fec_mode,
17128 fec_mode, "fec_mode");
17129 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
17130 TOKEN_STRING_INITIALIZER
17131 (struct cmd_set_port_fec_mode,
17135 cmd_set_port_fec_mode_parsed(
17136 void *parsed_result,
17137 __rte_unused struct cmdline *cl,
17138 __rte_unused void *data)
17140 struct cmd_set_port_fec_mode *res = parsed_result;
17141 uint16_t port_id = res->port_id;
17145 ret = parse_fec_mode(res->fec_value, &fec_capa);
17147 fprintf(stderr, "Unknown fec mode: %s for port %d\n",
17148 res->fec_value, port_id);
17152 ret = rte_eth_fec_set(port_id, fec_capa);
17153 if (ret == -ENOTSUP) {
17154 fprintf(stderr, "Function not implemented\n");
17156 } else if (ret < 0) {
17157 fprintf(stderr, "Set FEC mode failed\n");
17162 cmdline_parse_inst_t cmd_set_fec_mode = {
17163 .f = cmd_set_port_fec_mode_parsed,
17165 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
17167 (void *)&cmd_set_port_fec_mode_set,
17168 (void *)&cmd_set_port_fec_mode_port,
17169 (void *)&cmd_set_port_fec_mode_port_id,
17170 (void *)&cmd_set_port_fec_mode_str,
17171 (void *)&cmd_set_port_fec_mode_value,
17176 /* show port supported ptypes */
17178 /* Common result structure for show port ptypes */
17179 struct cmd_show_port_supported_ptypes_result {
17180 cmdline_fixed_string_t show;
17181 cmdline_fixed_string_t port;
17183 cmdline_fixed_string_t ptypes;
17186 /* Common CLI fields for show port ptypes */
17187 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
17188 TOKEN_STRING_INITIALIZER
17189 (struct cmd_show_port_supported_ptypes_result,
17191 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
17192 TOKEN_STRING_INITIALIZER
17193 (struct cmd_show_port_supported_ptypes_result,
17195 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
17196 TOKEN_NUM_INITIALIZER
17197 (struct cmd_show_port_supported_ptypes_result,
17198 port_id, RTE_UINT16);
17199 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
17200 TOKEN_STRING_INITIALIZER
17201 (struct cmd_show_port_supported_ptypes_result,
17205 cmd_show_port_supported_ptypes_parsed(
17206 void *parsed_result,
17207 __rte_unused struct cmdline *cl,
17208 __rte_unused void *data)
17210 #define RSVD_PTYPE_MASK 0xf0000000
17211 #define MAX_PTYPES_PER_LAYER 16
17212 #define LTYPE_NAMESIZE 32
17213 #define PTYPE_NAMESIZE 256
17214 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
17215 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
17216 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
17217 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
17218 uint16_t port_id = res->port_id;
17221 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
17225 while (ptype_mask != RSVD_PTYPE_MASK) {
17227 switch (ptype_mask) {
17228 case RTE_PTYPE_L2_MASK:
17229 strlcpy(ltype, "L2", sizeof(ltype));
17231 case RTE_PTYPE_L3_MASK:
17232 strlcpy(ltype, "L3", sizeof(ltype));
17234 case RTE_PTYPE_L4_MASK:
17235 strlcpy(ltype, "L4", sizeof(ltype));
17237 case RTE_PTYPE_TUNNEL_MASK:
17238 strlcpy(ltype, "Tunnel", sizeof(ltype));
17240 case RTE_PTYPE_INNER_L2_MASK:
17241 strlcpy(ltype, "Inner L2", sizeof(ltype));
17243 case RTE_PTYPE_INNER_L3_MASK:
17244 strlcpy(ltype, "Inner L3", sizeof(ltype));
17246 case RTE_PTYPE_INNER_L4_MASK:
17247 strlcpy(ltype, "Inner L4", sizeof(ltype));
17253 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
17254 ptype_mask, ptypes,
17255 MAX_PTYPES_PER_LAYER);
17258 printf("Supported %s ptypes:\n", ltype);
17260 printf("%s ptypes unsupported\n", ltype);
17262 for (i = 0; i < ret; ++i) {
17263 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
17264 printf("%s\n", buf);
17271 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
17272 .f = cmd_show_port_supported_ptypes_parsed,
17274 .help_str = "show port <port_id> ptypes",
17276 (void *)&cmd_show_port_supported_ptypes_show,
17277 (void *)&cmd_show_port_supported_ptypes_port,
17278 (void *)&cmd_show_port_supported_ptypes_port_id,
17279 (void *)&cmd_show_port_supported_ptypes_ptypes,
17284 /* *** display rx/tx descriptor status *** */
17285 struct cmd_show_rx_tx_desc_status_result {
17286 cmdline_fixed_string_t cmd_show;
17287 cmdline_fixed_string_t cmd_port;
17288 cmdline_fixed_string_t cmd_keyword;
17289 cmdline_fixed_string_t cmd_desc;
17290 cmdline_fixed_string_t cmd_status;
17297 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
17298 __rte_unused struct cmdline *cl,
17299 __rte_unused void *data)
17301 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
17304 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17305 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17309 if (!strcmp(res->cmd_keyword, "rxq")) {
17310 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
17314 "Invalid input: queue id = %d, desc id = %d\n",
17315 res->cmd_qid, res->cmd_did);
17318 if (rc == RTE_ETH_RX_DESC_AVAIL)
17319 printf("Desc status = AVAILABLE\n");
17320 else if (rc == RTE_ETH_RX_DESC_DONE)
17321 printf("Desc status = DONE\n");
17323 printf("Desc status = UNAVAILABLE\n");
17324 } else if (!strcmp(res->cmd_keyword, "txq")) {
17325 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17329 "Invalid input: queue id = %d, desc id = %d\n",
17330 res->cmd_qid, res->cmd_did);
17333 if (rc == RTE_ETH_TX_DESC_FULL)
17334 printf("Desc status = FULL\n");
17335 else if (rc == RTE_ETH_TX_DESC_DONE)
17336 printf("Desc status = DONE\n");
17338 printf("Desc status = UNAVAILABLE\n");
17342 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17343 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17345 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17346 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17348 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17349 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17350 cmd_pid, RTE_UINT16);
17351 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17352 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17353 cmd_keyword, "rxq#txq");
17354 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17355 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17356 cmd_qid, RTE_UINT16);
17357 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17358 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17360 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17361 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17362 cmd_did, RTE_UINT16);
17363 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17364 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17365 cmd_status, "status");
17366 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17367 .f = cmd_show_rx_tx_desc_status_parsed,
17369 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17372 (void *)&cmd_show_rx_tx_desc_status_show,
17373 (void *)&cmd_show_rx_tx_desc_status_port,
17374 (void *)&cmd_show_rx_tx_desc_status_pid,
17375 (void *)&cmd_show_rx_tx_desc_status_keyword,
17376 (void *)&cmd_show_rx_tx_desc_status_qid,
17377 (void *)&cmd_show_rx_tx_desc_status_desc,
17378 (void *)&cmd_show_rx_tx_desc_status_did,
17379 (void *)&cmd_show_rx_tx_desc_status_status,
17384 /* *** display rx queue desc used count *** */
17385 struct cmd_show_rx_queue_desc_used_count_result {
17386 cmdline_fixed_string_t cmd_show;
17387 cmdline_fixed_string_t cmd_port;
17388 cmdline_fixed_string_t cmd_rxq;
17389 cmdline_fixed_string_t cmd_desc;
17390 cmdline_fixed_string_t cmd_used;
17391 cmdline_fixed_string_t cmd_count;
17397 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17398 __rte_unused struct cmdline *cl,
17399 __rte_unused void *data)
17401 struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17404 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17405 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17409 rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17411 fprintf(stderr, "Invalid queueid = %d\n", res->cmd_qid);
17414 printf("Used desc count = %d\n", rc);
17417 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17418 TOKEN_STRING_INITIALIZER
17419 (struct cmd_show_rx_queue_desc_used_count_result,
17421 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17422 TOKEN_STRING_INITIALIZER
17423 (struct cmd_show_rx_queue_desc_used_count_result,
17425 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17426 TOKEN_NUM_INITIALIZER
17427 (struct cmd_show_rx_queue_desc_used_count_result,
17428 cmd_pid, RTE_UINT16);
17429 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17430 TOKEN_STRING_INITIALIZER
17431 (struct cmd_show_rx_queue_desc_used_count_result,
17433 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17434 TOKEN_NUM_INITIALIZER
17435 (struct cmd_show_rx_queue_desc_used_count_result,
17436 cmd_qid, RTE_UINT16);
17437 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17438 TOKEN_STRING_INITIALIZER
17439 (struct cmd_show_rx_queue_desc_used_count_result,
17440 cmd_count, "desc");
17441 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17442 TOKEN_STRING_INITIALIZER
17443 (struct cmd_show_rx_queue_desc_used_count_result,
17444 cmd_count, "used");
17445 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17446 TOKEN_STRING_INITIALIZER
17447 (struct cmd_show_rx_queue_desc_used_count_result,
17448 cmd_count, "count");
17449 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17450 .f = cmd_show_rx_queue_desc_used_count_parsed,
17452 .help_str = "show port <port_id> rxq <queue_id> desc used count",
17454 (void *)&cmd_show_rx_queue_desc_used_count_show,
17455 (void *)&cmd_show_rx_queue_desc_used_count_port,
17456 (void *)&cmd_show_rx_queue_desc_used_count_pid,
17457 (void *)&cmd_show_rx_queue_desc_used_count_rxq,
17458 (void *)&cmd_show_rx_queue_desc_used_count_qid,
17459 (void *)&cmd_show_rx_queue_desc_used_count_desc,
17460 (void *)&cmd_show_rx_queue_desc_used_count_used,
17461 (void *)&cmd_show_rx_queue_desc_used_count_count,
17466 /* Common result structure for set port ptypes */
17467 struct cmd_set_port_ptypes_result {
17468 cmdline_fixed_string_t set;
17469 cmdline_fixed_string_t port;
17471 cmdline_fixed_string_t ptype_mask;
17475 /* Common CLI fields for set port ptypes */
17476 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17477 TOKEN_STRING_INITIALIZER
17478 (struct cmd_set_port_ptypes_result,
17480 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17481 TOKEN_STRING_INITIALIZER
17482 (struct cmd_set_port_ptypes_result,
17484 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17485 TOKEN_NUM_INITIALIZER
17486 (struct cmd_set_port_ptypes_result,
17487 port_id, RTE_UINT16);
17488 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17489 TOKEN_STRING_INITIALIZER
17490 (struct cmd_set_port_ptypes_result,
17491 ptype_mask, "ptype_mask");
17492 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17493 TOKEN_NUM_INITIALIZER
17494 (struct cmd_set_port_ptypes_result,
17498 cmd_set_port_ptypes_parsed(
17499 void *parsed_result,
17500 __rte_unused struct cmdline *cl,
17501 __rte_unused void *data)
17503 struct cmd_set_port_ptypes_result *res = parsed_result;
17504 #define PTYPE_NAMESIZE 256
17505 char ptype_name[PTYPE_NAMESIZE];
17506 uint16_t port_id = res->port_id;
17507 uint32_t ptype_mask = res->mask;
17510 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17513 fprintf(stderr, "Port %d doesn't support any ptypes.\n",
17518 uint32_t ptypes[ret];
17520 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17522 fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
17527 printf("Successfully set following ptypes for Port %d\n", port_id);
17528 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17529 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17530 printf("%s\n", ptype_name);
17533 clear_ptypes = false;
17536 cmdline_parse_inst_t cmd_set_port_ptypes = {
17537 .f = cmd_set_port_ptypes_parsed,
17539 .help_str = "set port <port_id> ptype_mask <mask>",
17541 (void *)&cmd_set_port_ptypes_set,
17542 (void *)&cmd_set_port_ptypes_port,
17543 (void *)&cmd_set_port_ptypes_port_id,
17544 (void *)&cmd_set_port_ptypes_mask_str,
17545 (void *)&cmd_set_port_ptypes_mask_u32,
17550 /* *** display mac addresses added to a port *** */
17551 struct cmd_showport_macs_result {
17552 cmdline_fixed_string_t cmd_show;
17553 cmdline_fixed_string_t cmd_port;
17554 cmdline_fixed_string_t cmd_keyword;
17559 cmd_showport_macs_parsed(void *parsed_result,
17560 __rte_unused struct cmdline *cl,
17561 __rte_unused void *data)
17563 struct cmd_showport_macs_result *res = parsed_result;
17565 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17568 if (!strcmp(res->cmd_keyword, "macs"))
17569 show_macs(res->cmd_pid);
17570 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17571 show_mcast_macs(res->cmd_pid);
17574 cmdline_parse_token_string_t cmd_showport_macs_show =
17575 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17577 cmdline_parse_token_string_t cmd_showport_macs_port =
17578 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17580 cmdline_parse_token_num_t cmd_showport_macs_pid =
17581 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17582 cmd_pid, RTE_UINT16);
17583 cmdline_parse_token_string_t cmd_showport_macs_keyword =
17584 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17585 cmd_keyword, "macs#mcast_macs");
17587 cmdline_parse_inst_t cmd_showport_macs = {
17588 .f = cmd_showport_macs_parsed,
17590 .help_str = "show port <port_id> macs|mcast_macs",
17592 (void *)&cmd_showport_macs_show,
17593 (void *)&cmd_showport_macs_port,
17594 (void *)&cmd_showport_macs_pid,
17595 (void *)&cmd_showport_macs_keyword,
17600 /* ******************************************************************************** */
17602 /* list of instructions */
17603 cmdline_parse_ctx_t main_ctx[] = {
17604 (cmdline_parse_inst_t *)&cmd_help_brief,
17605 (cmdline_parse_inst_t *)&cmd_help_long,
17606 (cmdline_parse_inst_t *)&cmd_quit,
17607 (cmdline_parse_inst_t *)&cmd_load_from_file,
17608 (cmdline_parse_inst_t *)&cmd_showport,
17609 (cmdline_parse_inst_t *)&cmd_showqueue,
17610 (cmdline_parse_inst_t *)&cmd_showeeprom,
17611 (cmdline_parse_inst_t *)&cmd_showportall,
17612 (cmdline_parse_inst_t *)&cmd_representor_info,
17613 (cmdline_parse_inst_t *)&cmd_showdevice,
17614 (cmdline_parse_inst_t *)&cmd_showcfg,
17615 (cmdline_parse_inst_t *)&cmd_showfwdall,
17616 (cmdline_parse_inst_t *)&cmd_start,
17617 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17618 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17619 (cmdline_parse_inst_t *)&cmd_set_link_up,
17620 (cmdline_parse_inst_t *)&cmd_set_link_down,
17621 (cmdline_parse_inst_t *)&cmd_reset,
17622 (cmdline_parse_inst_t *)&cmd_set_numbers,
17623 (cmdline_parse_inst_t *)&cmd_set_log,
17624 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
17625 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
17626 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17627 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17628 (cmdline_parse_inst_t *)&cmd_set_txtimes,
17629 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17630 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17631 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17632 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17633 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17634 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17635 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17636 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17637 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17638 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17639 (cmdline_parse_inst_t *)&cmd_set_link_check,
17640 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17641 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17642 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17643 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17644 #ifdef RTE_NET_BOND
17645 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17646 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17647 (cmdline_parse_inst_t *) &cmd_show_bonding_lacp_info,
17648 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17649 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17650 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17651 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17652 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17653 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17654 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17655 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17656 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17658 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17659 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17660 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17661 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17662 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17663 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17664 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17665 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17666 (cmdline_parse_inst_t *)&cmd_csum_set,
17667 (cmdline_parse_inst_t *)&cmd_csum_show,
17668 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17669 (cmdline_parse_inst_t *)&cmd_tso_set,
17670 (cmdline_parse_inst_t *)&cmd_tso_show,
17671 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17672 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17674 (cmdline_parse_inst_t *)&cmd_gro_enable,
17675 (cmdline_parse_inst_t *)&cmd_gro_flush,
17676 (cmdline_parse_inst_t *)&cmd_gro_show,
17679 (cmdline_parse_inst_t *)&cmd_gso_enable,
17680 (cmdline_parse_inst_t *)&cmd_gso_size,
17681 (cmdline_parse_inst_t *)&cmd_gso_show,
17683 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17684 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17685 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17686 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17687 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17688 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17689 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17690 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17691 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17692 (cmdline_parse_inst_t *)&cmd_link_flow_control_show,
17693 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17694 (cmdline_parse_inst_t *)&cmd_config_dcb,
17695 (cmdline_parse_inst_t *)&cmd_read_reg,
17696 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17697 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17698 (cmdline_parse_inst_t *)&cmd_write_reg,
17699 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17700 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17701 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17702 (cmdline_parse_inst_t *)&cmd_stop,
17703 (cmdline_parse_inst_t *)&cmd_mac_addr,
17704 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17705 (cmdline_parse_inst_t *)&cmd_set_qmap,
17706 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17707 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17708 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17709 (cmdline_parse_inst_t *)&cmd_operate_port,
17710 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17711 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17712 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17713 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
17714 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17715 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17716 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17717 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17718 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17719 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17720 (cmdline_parse_inst_t *)&cmd_config_mtu,
17721 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17722 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17723 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17724 (cmdline_parse_inst_t *)&cmd_config_rss,
17725 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17726 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17727 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17728 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17729 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17730 (cmdline_parse_inst_t *)&cmd_showport_reta,
17731 (cmdline_parse_inst_t *)&cmd_showport_macs,
17732 (cmdline_parse_inst_t *)&cmd_config_burst,
17733 (cmdline_parse_inst_t *)&cmd_config_thresh,
17734 (cmdline_parse_inst_t *)&cmd_config_threshold,
17735 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17736 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17737 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17738 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17739 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17740 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17741 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17742 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17743 (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
17744 (cmdline_parse_inst_t *)&cmd_dump,
17745 (cmdline_parse_inst_t *)&cmd_dump_one,
17746 #ifdef RTE_NET_I40E
17747 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17749 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17750 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17751 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17752 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17753 (cmdline_parse_inst_t *)&cmd_flow,
17754 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17755 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17756 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17757 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17758 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17759 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17760 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17761 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17762 (cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
17763 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17764 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17765 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17766 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17767 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17768 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17769 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17770 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17771 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17772 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17773 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17774 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17775 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17776 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17777 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17778 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17779 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17780 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17781 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17782 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17783 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17784 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17785 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17786 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17787 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17788 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17789 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17790 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17791 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
17792 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
17793 (cmdline_parse_inst_t *)&cmd_set_vxlan,
17794 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
17795 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17796 (cmdline_parse_inst_t *)&cmd_set_nvgre,
17797 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17798 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
17799 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
17800 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
17801 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
17802 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
17803 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
17804 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
17805 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
17806 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
17807 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
17808 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
17809 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
17810 (cmdline_parse_inst_t *)&cmd_set_conntrack_common,
17811 (cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
17812 (cmdline_parse_inst_t *)&cmd_ddp_add,
17813 (cmdline_parse_inst_t *)&cmd_ddp_del,
17814 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
17815 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
17816 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
17817 (cmdline_parse_inst_t *)&cmd_clear_input_set,
17818 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
17819 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17820 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
17821 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
17822 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17823 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17824 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17825 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17827 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17828 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17829 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17830 (cmdline_parse_inst_t *)&cmd_queue_region,
17831 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17832 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17833 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17834 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17835 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17836 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17837 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17838 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17839 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17840 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17841 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17842 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17843 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17844 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17845 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17846 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17847 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17848 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
17849 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17850 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17851 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17852 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17853 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17854 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17855 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
17856 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
17857 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
17858 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17859 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17860 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17861 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17862 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17863 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17864 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17865 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17866 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17868 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17869 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17871 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
17872 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
17873 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
17874 (cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
17875 (cmdline_parse_inst_t *)&cmd_set_raw,
17876 (cmdline_parse_inst_t *)&cmd_show_set_raw,
17877 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
17878 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
17879 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
17880 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
17881 (cmdline_parse_inst_t *)&cmd_show_capability,
17882 (cmdline_parse_inst_t *)&cmd_set_flex_is_pattern,
17883 (cmdline_parse_inst_t *)&cmd_set_flex_spec_pattern,
17887 /* read cmdline commands from file */
17889 cmdline_read_from_file(const char *filename)
17891 struct cmdline *cl;
17893 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17896 "Failed to create file based cmdline context: %s\n",
17901 cmdline_interact(cl);
17906 printf("Read CLI commands from %s\n", filename);
17909 /* prompt function, called from main on MAIN lcore */
17914 /* initialize non-constant commands */
17915 cmd_set_fwd_mode_init();
17916 cmd_set_fwd_retry_mode_init();
17918 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17919 if (testpmd_cl == NULL)
17922 ret = atexit(prompt_exit);
17924 fprintf(stderr, "Cannot set exit function for cmdline\n");
17926 cmdline_interact(testpmd_cl);
17928 cmdline_stdin_exit(testpmd_cl);
17934 if (testpmd_cl != NULL) {
17935 cmdline_quit(testpmd_cl);
17936 cmdline_stdin_exit(testpmd_cl);
17941 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17943 if (id == (portid_t)RTE_PORT_ALL) {
17946 RTE_ETH_FOREACH_DEV(pid) {
17947 /* check if need_reconfig has been set to 1 */
17948 if (ports[pid].need_reconfig == 0)
17949 ports[pid].need_reconfig = dev;
17950 /* check if need_reconfig_queues has been set to 1 */
17951 if (ports[pid].need_reconfig_queues == 0)
17952 ports[pid].need_reconfig_queues = queue;
17954 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17955 /* check if need_reconfig has been set to 1 */
17956 if (ports[id].need_reconfig == 0)
17957 ports[id].need_reconfig = dev;
17958 /* check if need_reconfig_queues has been set to 1 */
17959 if (ports[id].need_reconfig_queues == 0)
17960 ports[id].need_reconfig_queues = queue;