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_atomic.h>
28 #include <rte_branch_prediction.h>
30 #include <rte_mempool.h>
31 #include <rte_interrupts.h>
33 #include <rte_ether.h>
34 #include <rte_ethdev.h>
35 #include <rte_string_fns.h>
36 #include <rte_devargs.h>
39 #include <rte_mbuf_dyn.h>
41 #include <cmdline_rdline.h>
42 #include <cmdline_parse.h>
43 #include <cmdline_parse_num.h>
44 #include <cmdline_parse_string.h>
45 #include <cmdline_parse_ipaddr.h>
46 #include <cmdline_parse_etheraddr.h>
47 #include <cmdline_socket.h>
50 #include <rte_eth_bond.h>
51 #include <rte_eth_bond_8023ad.h>
53 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
54 #include <rte_pmd_dpaa.h>
57 #include <rte_pmd_ixgbe.h>
60 #include <rte_pmd_i40e.h>
63 #include <rte_pmd_bnxt.h>
66 #include "cmdline_mtr.h"
67 #include "cmdline_tm.h"
70 static struct cmdline *testpmd_cl;
72 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
74 /* *** Help command with introduction. *** */
75 struct cmd_help_brief_result {
76 cmdline_fixed_string_t help;
79 static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
81 __rte_unused void *data)
86 "Help is available for the following sections:\n\n"
87 " help control : Start and stop forwarding.\n"
88 " help display : Displaying port, stats and config "
90 " help config : Configuration information.\n"
91 " help ports : Configuring ports.\n"
92 " help registers : Reading and setting port registers.\n"
93 " help filters : Filters configuration help.\n"
94 " help traffic_management : Traffic Management commands.\n"
95 " help devices : Device related cmds.\n"
96 " help all : All of the above sections.\n\n"
101 cmdline_parse_token_string_t cmd_help_brief_help =
102 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
104 cmdline_parse_inst_t cmd_help_brief = {
105 .f = cmd_help_brief_parsed,
107 .help_str = "help: Show help",
109 (void *)&cmd_help_brief_help,
114 /* *** Help command with help sections. *** */
115 struct cmd_help_long_result {
116 cmdline_fixed_string_t help;
117 cmdline_fixed_string_t section;
120 static void cmd_help_long_parsed(void *parsed_result,
122 __rte_unused void *data)
125 struct cmd_help_long_result *res = parsed_result;
127 if (!strcmp(res->section, "all"))
130 if (show_all || !strcmp(res->section, "control")) {
135 "Control forwarding:\n"
136 "-------------------\n\n"
139 " Start packet forwarding with current configuration.\n\n"
142 " Start packet forwarding with current config"
143 " after sending one burst of packets.\n\n"
146 " Stop packet forwarding, and display accumulated"
150 " Quit to prompt.\n\n"
154 if (show_all || !strcmp(res->section, "display")) {
162 "show port (info|stats|summary|xstats|fdir|dcb_tc) (port_id|all)\n"
163 " Display information for port_id, or all.\n\n"
165 "show port info (port_id) representor\n"
166 " Show supported representors for a specific port\n\n"
168 "show port port_id (module_eeprom|eeprom)\n"
169 " Display the module EEPROM or EEPROM information for port_id.\n\n"
171 "show port X rss reta (size) (mask0,mask1,...)\n"
172 " Display the rss redirection table entry indicated"
173 " by masks on port X. size is used to indicate the"
174 " hardware supported reta size\n\n"
176 "show port (port_id) rss-hash [key]\n"
177 " Display the RSS hash functions and RSS hash key of port\n\n"
179 "clear port (info|stats|xstats|fdir) (port_id|all)\n"
180 " Clear information for port_id, or all.\n\n"
182 "show (rxq|txq) info (port_id) (queue_id)\n"
183 " Display information for configured RX/TX queue.\n\n"
185 "show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n"
186 " Display the given configuration.\n\n"
188 "read rxd (port_id) (queue_id) (rxd_id)\n"
189 " Display an RX descriptor of a port RX queue.\n\n"
191 "read txd (port_id) (queue_id) (txd_id)\n"
192 " Display a TX descriptor of a port TX queue.\n\n"
194 "ddp get list (port_id)\n"
195 " Get ddp profile info list\n\n"
197 "ddp get info (profile_path)\n"
198 " Get ddp profile information.\n\n"
200 "show vf stats (port_id) (vf_id)\n"
201 " Display a VF's statistics.\n\n"
203 "clear vf stats (port_id) (vf_id)\n"
204 " Reset a VF's statistics.\n\n"
206 "show port (port_id) pctype mapping\n"
207 " Get flow ptype to pctype mapping on a port\n\n"
209 "show port meter stats (port_id) (meter_id) (clear)\n"
210 " Get meter stats on a port\n\n"
212 "show fwd stats all\n"
213 " Display statistics for all fwd engines.\n\n"
215 "clear fwd stats all\n"
216 " Clear statistics for all fwd engines.\n\n"
218 "show port (port_id) rx_offload capabilities\n"
219 " List all per queue and per port Rx offloading"
220 " capabilities of a port\n\n"
222 "show port (port_id) rx_offload configuration\n"
223 " List port level and all queue level"
224 " Rx offloading configuration\n\n"
226 "show port (port_id) tx_offload capabilities\n"
227 " List all per queue and per port"
228 " Tx offloading capabilities of a port\n\n"
230 "show port (port_id) tx_offload configuration\n"
231 " List port level and all queue level"
232 " Tx offloading configuration\n\n"
234 "show port (port_id) tx_metadata\n"
235 " Show Tx metadata value set"
236 " for a specific port\n\n"
238 "show port (port_id) ptypes\n"
239 " Show port supported ptypes"
240 " for a specific port\n\n"
242 "show device info (<identifier>|all)"
243 " Show general information about devices probed.\n\n"
245 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
246 " Show status of rx|tx descriptor.\n\n"
248 "show port (port_id) rxq (queue_id) desc used count\n"
249 " Show current number of filled receive"
250 " packet descriptors.\n\n"
252 "show port (port_id) macs|mcast_macs"
253 " Display list of mac addresses added to port.\n\n"
255 "show port (port_id) fec capabilities"
256 " Show fec capabilities of a port.\n\n"
258 "show port (port_id) fec_mode"
259 " Show fec mode of a port.\n\n"
261 "show port (port_id) flow_ctrl"
262 " Show flow control info of a port.\n\n"
266 if (show_all || !strcmp(res->section, "config")) {
272 "Configuration changes only become active when"
273 " forwarding is started/restarted.\n\n"
276 " Reset forwarding to the default configuration.\n\n"
278 "set verbose (level)\n"
279 " Set the debug verbosity level X.\n\n"
281 "set log global|(type) (level)\n"
282 " Set the log level.\n\n"
285 " Set number of ports.\n\n"
288 " Set number of cores.\n\n"
290 "set coremask (mask)\n"
291 " Set the forwarding cores hexadecimal mask.\n\n"
293 "set portmask (mask)\n"
294 " Set the forwarding ports hexadecimal mask.\n\n"
297 " Set number of packets per burst.\n\n"
299 "set burst tx delay (microseconds) retry (num)\n"
300 " Set the transmit delay time and number of retries,"
301 " effective when retry is enabled.\n\n"
303 "set rxoffs (x[,y]*)\n"
304 " Set the offset of each packet segment on"
305 " receiving if split feature is engaged."
306 " Affects only the queues configured with split"
309 "set rxpkts (x[,y]*)\n"
310 " Set the length of each segment to scatter"
311 " packets on receiving if split feature is engaged."
312 " Affects only the queues configured with split"
315 "set txpkts (x[,y]*)\n"
316 " Set the length of each segment of TXONLY"
317 " and optionally CSUM packets.\n\n"
319 "set txsplit (off|on|rand)\n"
320 " Set the split policy for the TX packets."
321 " Right now only applicable for CSUM and TXONLY"
324 "set txtimes (x, y)\n"
325 " Set the scheduling on timestamps"
326 " timings for the TXONLY mode\n\n"
328 "set corelist (x[,y]*)\n"
329 " Set the list of forwarding cores.\n\n"
331 "set portlist (x[,y]*)\n"
332 " Set the list of forwarding ports.\n\n"
334 "set port setup on (iterator|event)\n"
335 " Select how attached port is retrieved for setup.\n\n"
337 "set tx loopback (port_id) (on|off)\n"
338 " Enable or disable tx loopback.\n\n"
340 "set all queues drop (port_id) (on|off)\n"
341 " Set drop enable bit for all queues.\n\n"
343 "set vf split drop (port_id) (vf_id) (on|off)\n"
344 " Set split drop enable bit for a VF from the PF.\n\n"
346 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
347 " Set MAC antispoof for a VF from the PF.\n\n"
349 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
350 " Enable MACsec offload.\n\n"
352 "set macsec offload (port_id) off\n"
353 " Disable MACsec offload.\n\n"
355 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
356 " Configure MACsec secure connection (SC).\n\n"
358 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
359 " Configure MACsec secure association (SA).\n\n"
361 "set vf broadcast (port_id) (vf_id) (on|off)\n"
362 " Set VF broadcast for a VF from the PF.\n\n"
364 "vlan set stripq (on|off) (port_id,queue_id)\n"
365 " Set the VLAN strip for a queue on a port.\n\n"
367 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
368 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
370 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
371 " Set VLAN insert for a VF from the PF.\n\n"
373 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
374 " Set VLAN antispoof for a VF from the PF.\n\n"
376 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
377 " Set VLAN tag for a VF from the PF.\n\n"
379 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
380 " Set a VF's max bandwidth(Mbps).\n\n"
382 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
383 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
385 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
386 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
388 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
389 " Set some TCs' strict link priority mode on a physical port.\n\n"
391 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
392 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
394 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
395 " Set the VLAN strip or filter or qinq strip or extend\n\n"
397 "vlan set (inner|outer) tpid (value) (port_id)\n"
398 " Set the VLAN TPID for Packet Filtering on"
401 "rx_vlan add (vlan_id|all) (port_id)\n"
402 " Add a vlan_id, or all identifiers, to the set"
403 " of VLAN identifiers filtered by port_id.\n\n"
405 "rx_vlan rm (vlan_id|all) (port_id)\n"
406 " Remove a vlan_id, or all identifiers, from the set"
407 " of VLAN identifiers filtered by port_id.\n\n"
409 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
410 " Add a vlan_id, to the set of VLAN identifiers"
411 "filtered for VF(s) from port_id.\n\n"
413 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
414 " Remove a vlan_id, to the set of VLAN identifiers"
415 "filtered for VF(s) from port_id.\n\n"
417 "rx_vxlan_port add (udp_port) (port_id)\n"
418 " Add an UDP port for VXLAN packet filter on a port\n\n"
420 "rx_vxlan_port rm (udp_port) (port_id)\n"
421 " Remove an UDP port for VXLAN packet filter on a port\n\n"
423 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
424 " Set hardware insertion of VLAN IDs (single or double VLAN "
425 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
427 "tx_vlan set pvid port_id vlan_id (on|off)\n"
428 " Set port based TX VLAN insertion.\n\n"
430 "tx_vlan reset (port_id)\n"
431 " Disable hardware insertion of a VLAN header in"
432 " packets sent on a port.\n\n"
434 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
435 " Select hardware or software calculation of the"
436 " checksum when transmitting a packet using the"
437 " csum forward engine.\n"
438 " ip|udp|tcp|sctp always concern the inner layer.\n"
439 " outer-ip concerns the outer IP layer in"
440 " outer-udp concerns the outer UDP layer in"
441 " case the packet is recognized as a tunnel packet by"
442 " the forward engine (vxlan, gre and ipip are supported)\n"
443 " Please check the NIC datasheet for HW limits.\n\n"
445 "csum parse-tunnel (on|off) (tx_port_id)\n"
446 " If disabled, treat tunnel packets as non-tunneled"
447 " packets (treat inner headers as payload). The port\n"
448 " argument is the port used for TX in csum forward"
451 "csum show (port_id)\n"
452 " Display tx checksum offload configuration\n\n"
454 "tso set (segsize) (portid)\n"
455 " Enable TCP Segmentation Offload in csum forward"
457 " Please check the NIC datasheet for HW limits.\n\n"
460 " Display the status of TCP Segmentation Offload.\n\n"
462 "set port (port_id) gro on|off\n"
463 " Enable or disable Generic Receive Offload in"
464 " csum forwarding engine.\n\n"
466 "show port (port_id) gro\n"
467 " Display GRO configuration.\n\n"
469 "set gro flush (cycles)\n"
470 " Set the cycle to flush GROed packets from"
471 " reassembly tables.\n\n"
473 "set port (port_id) gso (on|off)"
474 " Enable or disable Generic Segmentation Offload in"
475 " csum forwarding engine.\n\n"
477 "set gso segsz (length)\n"
478 " Set max packet length for output GSO segments,"
479 " including packet header and payload.\n\n"
481 "show port (port_id) gso\n"
482 " Show GSO configuration.\n\n"
485 " Set packet forwarding mode.\n\n"
487 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
488 " Add a MAC address on port_id.\n\n"
490 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
491 " Remove a MAC address from port_id.\n\n"
493 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
494 " Set the default MAC address for port_id.\n\n"
496 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
497 " Add a MAC address for a VF on the port.\n\n"
499 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
500 " Set the MAC address for a VF from the PF.\n\n"
502 "set eth-peer (port_id) (peer_addr)\n"
503 " set the peer address for certain port.\n\n"
505 "set port (port_id) uta (mac_address|all) (on|off)\n"
506 " Add/Remove a or all unicast hash filter(s)"
509 "set promisc (port_id|all) (on|off)\n"
510 " Set the promiscuous mode on port_id, or all.\n\n"
512 "set allmulti (port_id|all) (on|off)\n"
513 " Set the allmulti mode on port_id, or all.\n\n"
515 "set vf promisc (port_id) (vf_id) (on|off)\n"
516 " Set unicast promiscuous mode for a VF from the PF.\n\n"
518 "set vf allmulti (port_id) (vf_id) (on|off)\n"
519 " Set multicast promiscuous mode for a VF from the PF.\n\n"
521 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
522 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
523 " (on|off) autoneg (on|off) (port_id)\n"
524 "set flow_ctrl rx (on|off) (portid)\n"
525 "set flow_ctrl tx (on|off) (portid)\n"
526 "set flow_ctrl high_water (high_water) (portid)\n"
527 "set flow_ctrl low_water (low_water) (portid)\n"
528 "set flow_ctrl pause_time (pause_time) (portid)\n"
529 "set flow_ctrl send_xon (send_xon) (portid)\n"
530 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
531 "set flow_ctrl autoneg (on|off) (port_id)\n"
532 " Set the link flow control parameter on a port.\n\n"
534 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
535 " (low_water) (pause_time) (priority) (port_id)\n"
536 " Set the priority flow control parameter on a"
539 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
540 " Set statistics mapping (qmapping 0..15) for RX/TX"
542 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
543 " on port 0 to mapping 5.\n\n"
545 "set xstats-hide-zero on|off\n"
546 " Set the option to hide the zero values"
547 " for xstats display.\n"
549 "set record-core-cycles on|off\n"
550 " Set the option to enable measurement of CPU cycles.\n"
552 "set record-burst-stats on|off\n"
553 " Set the option to enable display of RX and TX bursts.\n"
555 "set port (port_id) vf (vf_id) rx|tx on|off\n"
556 " Enable/Disable a VF receive/tranmit from a port\n\n"
558 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
560 " AUPE:accepts untagged VLAN;"
561 "ROPE:accept unicast hash\n\n"
562 " BAM:accepts broadcast packets;"
563 "MPE:accepts all multicast packets\n\n"
564 " Enable/Disable a VF receive mode of a port\n\n"
566 "set port (port_id) queue (queue_id) rate (rate_num)\n"
567 " Set rate limit for a queue of a port\n\n"
569 "set port (port_id) vf (vf_id) rate (rate_num) "
570 "queue_mask (queue_mask_value)\n"
571 " Set rate limit for queues in VF of a port\n\n"
573 "set flush_rx (on|off)\n"
574 " Flush (default) or don't flush RX streams before"
575 " forwarding. Mainly used with PCAP drivers.\n\n"
577 "set bypass mode (normal|bypass|isolate) (port_id)\n"
578 " Set the bypass mode for the lowest port on bypass enabled"
581 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
582 "mode (normal|bypass|isolate) (port_id)\n"
583 " Set the event required to initiate specified bypass mode for"
584 " the lowest port on a bypass enabled NIC where:\n"
585 " timeout = enable bypass after watchdog timeout.\n"
586 " os_on = enable bypass when OS/board is powered on.\n"
587 " os_off = enable bypass when OS/board is powered off.\n"
588 " power_on = enable bypass when power supply is turned on.\n"
589 " power_off = enable bypass when power supply is turned off."
592 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
593 " Set the bypass watchdog timeout to 'n' seconds"
594 " where 0 = instant.\n\n"
596 "show bypass config (port_id)\n"
597 " Show the bypass configuration for a bypass enabled NIC"
598 " using the lowest port on the NIC.\n\n"
601 "create bonded device (mode) (socket)\n"
602 " Create a new bonded device with specific bonding mode and socket.\n\n"
604 "add bonding slave (slave_id) (port_id)\n"
605 " Add a slave device to a bonded device.\n\n"
607 "remove bonding slave (slave_id) (port_id)\n"
608 " Remove a slave device from a bonded device.\n\n"
610 "set bonding mode (value) (port_id)\n"
611 " Set the bonding mode on a bonded device.\n\n"
613 "set bonding primary (slave_id) (port_id)\n"
614 " Set the primary slave for a bonded device.\n\n"
616 "show bonding config (port_id)\n"
617 " Show the bonding config for port_id.\n\n"
619 "show bonding lacp info (port_id)\n"
620 " Show the bonding lacp information for port_id.\n\n"
622 "set bonding mac_addr (port_id) (address)\n"
623 " Set the MAC address of a bonded device.\n\n"
625 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
626 " Set Aggregation mode for IEEE802.3AD (mode 4)"
628 "set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
629 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
631 "set bonding mon_period (port_id) (value)\n"
632 " Set the bonding link status monitoring polling period in ms.\n\n"
634 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
635 " Enable/disable dedicated queues for LACP control traffic.\n\n"
638 "set link-up port (port_id)\n"
639 " Set link up for a port.\n\n"
641 "set link-down port (port_id)\n"
642 " Set link down for a port.\n\n"
644 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
645 " Load a profile package on a port\n\n"
647 "ddp del (port_id) (backup_profile_path)\n"
648 " Delete a profile package from a port\n\n"
650 "ptype mapping get (port_id) (valid_only)\n"
651 " Get ptype mapping on a port\n\n"
653 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
654 " Replace target with the pkt_type in ptype mapping\n\n"
656 "ptype mapping reset (port_id)\n"
657 " Reset ptype mapping on a port\n\n"
659 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
660 " Update a ptype mapping item on a port\n\n"
662 "set port (port_id) ptype_mask (ptype_mask)\n"
663 " set packet types classification for a specific port\n\n"
665 "set port (port_id) queue-region region_id (value) "
666 "queue_start_index (value) queue_num (value)\n"
667 " Set a queue region on a port\n\n"
669 "set port (port_id) queue-region region_id (value) "
671 " Set a flowtype region index on a port\n\n"
673 "set port (port_id) queue-region UP (value) region_id (value)\n"
674 " Set the mapping of User Priority to "
675 "queue region on a port\n\n"
677 "set port (port_id) queue-region flush (on|off)\n"
678 " flush all queue region related configuration\n\n"
680 "show port meter cap (port_id)\n"
681 " Show port meter capability information\n\n"
683 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
684 " meter profile add - srtcm rfc 2697\n\n"
686 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
687 " meter profile add - trtcm rfc 2698\n\n"
689 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
690 " meter profile add - trtcm rfc 4115\n\n"
692 "del port meter profile (port_id) (profile_id)\n"
693 " meter profile delete\n\n"
695 "create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
696 "(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
697 "(dscp_tbl_entry63)]\n"
700 "enable port meter (port_id) (mtr_id)\n"
703 "disable port meter (port_id) (mtr_id)\n"
706 "del port meter (port_id) (mtr_id)\n"
709 "add port meter policy (port_id) (policy_id) g_actions (actions)\n"
710 "y_actions (actions) r_actions (actions)\n"
711 " meter policy add\n\n"
713 "del port meter policy (port_id) (policy_id)\n"
714 " meter policy delete\n\n"
716 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
717 " meter update meter profile\n\n"
719 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
720 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
721 " update meter dscp table entries\n\n"
723 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
724 "(action0) [(action1) (action2)]\n"
725 " meter update policer action\n\n"
727 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
728 " meter update stats\n\n"
730 "show port (port_id) queue-region\n"
731 " show all queue region related configuration info\n\n"
733 "set port (port_id) fec_mode auto|off|rs|baser\n"
734 " set fec mode for a specific port\n\n"
736 , list_pkt_forwarding_modes()
740 if (show_all || !strcmp(res->section, "ports")) {
746 "----------------\n\n"
748 "port start (port_id|all)\n"
749 " Start all ports or port_id.\n\n"
751 "port stop (port_id|all)\n"
752 " Stop all ports or port_id.\n\n"
754 "port close (port_id|all)\n"
755 " Close all ports or port_id.\n\n"
757 "port reset (port_id|all)\n"
758 " Reset all ports or port_id.\n\n"
760 "port attach (ident)\n"
761 " Attach physical or virtual dev by pci address or virtual device name\n\n"
763 "port detach (port_id)\n"
764 " Detach physical or virtual dev by port_id\n\n"
766 "port config (port_id|all)"
767 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
768 " duplex (half|full|auto)\n"
769 " Set speed and duplex for all ports or port_id\n\n"
771 "port config (port_id|all) loopback (mode)\n"
772 " Set loopback mode for all ports or port_id\n\n"
774 "port config all (rxq|txq|rxd|txd) (value)\n"
775 " Set number for rxq/txq/rxd/txd.\n\n"
777 "port config all max-pkt-len (value)\n"
778 " Set the max packet length.\n\n"
780 "port config all max-lro-pkt-size (value)\n"
781 " Set the max LRO aggregated packet size.\n\n"
783 "port config all drop-en (on|off)\n"
784 " Enable or disable packet drop on all RX queues of all ports when no "
785 "receive buffers available.\n\n"
787 "port config all rss (all|default|ip|tcp|udp|sctp|"
788 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|none|level-default|"
789 "level-outer|level-inner|<flowtype_id>)\n"
790 " Set the RSS mode.\n\n"
792 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
793 " Set the RSS redirection table.\n\n"
795 "port config (port_id) dcb vt (on|off) (traffic_class)"
797 " Set the DCB mode.\n\n"
799 "port config all burst (value)\n"
800 " Set the number of packets per burst.\n\n"
802 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
804 " Set the ring prefetch/host/writeback threshold"
805 " for tx/rx queue.\n\n"
807 "port config all (txfreet|txrst|rxfreet) (value)\n"
808 " Set free threshold for rx/tx, or set"
809 " tx rs bit threshold.\n\n"
810 "port config mtu X value\n"
811 " Set the MTU of port X to a given value\n\n"
813 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
814 " Set a rx/tx queue's ring size configuration, the new"
815 " value will take effect after command that (re-)start the port"
816 " or command that setup the specific queue\n\n"
818 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
819 " Start/stop a rx/tx queue of port X. Only take effect"
820 " when port X is started\n\n"
822 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
823 " Switch on/off a deferred start of port X rx/tx queue. Only"
824 " take effect when port X is stopped.\n\n"
826 "port (port_id) (rxq|txq) (queue_id) setup\n"
827 " Setup a rx/tx queue of port X.\n\n"
829 "port config (port_id) pctype mapping reset\n"
830 " Reset flow type to pctype mapping on a port\n\n"
832 "port config (port_id) pctype mapping update"
833 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
834 " Update a flow type to pctype mapping item on a port\n\n"
836 "port config (port_id) pctype (pctype_id) hash_inset|"
837 "fdir_inset|fdir_flx_inset get|set|clear field\n"
839 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
841 "port config (port_id) pctype (pctype_id) hash_inset|"
842 "fdir_inset|fdir_flx_inset clear all"
843 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
845 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
846 " Add/remove UDP tunnel port for tunneling offload\n\n"
848 "port config <port_id> rx_offload vlan_strip|"
849 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
850 "outer_ipv4_cksum|macsec_strip|header_split|"
851 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
852 "buffer_split|timestamp|security|keep_crc on|off\n"
853 " Enable or disable a per port Rx offloading"
854 " on all Rx queues of a port\n\n"
856 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
857 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
858 "outer_ipv4_cksum|macsec_strip|header_split|"
859 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
860 "buffer_split|timestamp|security|keep_crc on|off\n"
861 " Enable or disable a per queue Rx offloading"
862 " only on a specific Rx queue\n\n"
864 "port config (port_id) tx_offload vlan_insert|"
865 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
866 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
867 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
868 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
870 " Enable or disable a per port Tx offloading"
871 " on all Tx queues of a port\n\n"
873 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
874 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
875 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
876 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
877 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
879 " Enable or disable a per queue Tx offloading"
880 " only on a specific Tx queue\n\n"
882 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
883 " Load an eBPF program as a callback"
884 " for particular RX/TX queue\n\n"
886 "bpf-unload rx|tx (port) (queue)\n"
887 " Unload previously loaded eBPF program"
888 " for particular RX/TX queue\n\n"
890 "port config (port_id) tx_metadata (value)\n"
891 " Set Tx metadata value per port. Testpmd will add this value"
892 " to any Tx packet sent from this port\n\n"
894 "port config (port_id) dynf (name) set|clear\n"
895 " Register a dynf and Set/clear this flag on Tx. "
896 "Testpmd will set this value to any Tx packet "
897 "sent from this port\n\n"
899 "port cleanup (port_id) txq (queue_id) (free_cnt)\n"
900 " Cleanup txq mbufs for a specific Tx queue\n\n"
904 if (show_all || !strcmp(res->section, "registers")) {
912 "read reg (port_id) (address)\n"
913 " Display value of a port register.\n\n"
915 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
916 " Display a port register bit field.\n\n"
918 "read regbit (port_id) (address) (bit_x)\n"
919 " Display a single port register bit.\n\n"
921 "write reg (port_id) (address) (value)\n"
922 " Set value of a port register.\n\n"
924 "write regfield (port_id) (address) (bit_x) (bit_y)"
926 " Set bit field of a port register.\n\n"
928 "write regbit (port_id) (address) (bit_x) (value)\n"
929 " Set single bit value of a port register.\n\n"
932 if (show_all || !strcmp(res->section, "filters")) {
941 "flow_director_filter (port_id) mode raw (add|del|update)"
942 " flow (flow_id) (drop|fwd) queue (queue_id)"
943 " fd_id (fd_id_value) packet (packet file name)\n"
944 " Add/Del a raw type flow director filter.\n\n"
947 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
948 " src_mask (ipv4_src) (ipv6_src) (src_port)"
949 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
950 " Set flow director IP mask.\n\n"
952 "flow_director_mask (port_id) mode MAC-VLAN"
953 " vlan (vlan_value)\n"
954 " Set flow director MAC-VLAN mask.\n\n"
956 "flow_director_mask (port_id) mode Tunnel"
957 " vlan (vlan_value) mac (mac_value)"
958 " tunnel-type (tunnel_type_value)"
959 " tunnel-id (tunnel_id_value)\n"
960 " Set flow director Tunnel mask.\n\n"
962 "flow_director_flex_payload (port_id)"
963 " (raw|l2|l3|l4) (config)\n"
964 " Configure flex payload selection.\n\n"
966 "flow validate {port_id}"
967 " [group {group_id}] [priority {level}]"
968 " [ingress] [egress]"
969 " pattern {item} [/ {item} [...]] / end"
970 " actions {action} [/ {action} [...]] / end\n"
971 " Check whether a flow rule can be created.\n\n"
973 "flow create {port_id}"
974 " [group {group_id}] [priority {level}]"
975 " [ingress] [egress]"
976 " pattern {item} [/ {item} [...]] / end"
977 " actions {action} [/ {action} [...]] / end\n"
978 " Create a flow rule.\n\n"
980 "flow destroy {port_id} rule {rule_id} [...]\n"
981 " Destroy specific flow rules.\n\n"
983 "flow flush {port_id}\n"
984 " Destroy all flow rules.\n\n"
986 "flow query {port_id} {rule_id} {action}\n"
987 " Query an existing flow rule.\n\n"
989 "flow list {port_id} [group {group_id}] [...]\n"
990 " List existing flow rules sorted by priority,"
991 " filtered by group identifiers.\n\n"
993 "flow isolate {port_id} {boolean}\n"
994 " Restrict ingress traffic to the defined"
997 "flow aged {port_id} [destroy]\n"
998 " List and destroy aged flows"
1001 "flow indirect_action {port_id} create"
1002 " [action_id {indirect_action_id}]"
1003 " [ingress] [egress]"
1004 " action {action} / end\n"
1005 " Create indirect action.\n\n"
1007 "flow indirect_action {port_id} update"
1008 " {indirect_action_id} action {action} / end\n"
1009 " Update indirect action.\n\n"
1011 "flow indirect_action {port_id} destroy"
1012 " action_id {indirect_action_id} [...]\n"
1013 " Destroy specific indirect actions.\n\n"
1015 "flow indirect_action {port_id} query"
1016 " {indirect_action_id}\n"
1017 " Query an existing indirect action.\n\n"
1019 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1020 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1021 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1022 " Configure the VXLAN encapsulation for flows.\n\n"
1024 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1025 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1026 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1027 " eth-dst (eth-dst)\n"
1028 " Configure the VXLAN encapsulation for flows.\n\n"
1030 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1031 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1032 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1033 " eth-dst (eth-dst)\n"
1034 " Configure the VXLAN encapsulation for flows.\n\n"
1036 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1037 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1039 " Configure the NVGRE encapsulation for flows.\n\n"
1041 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1042 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1043 " eth-src (eth-src) eth-dst (eth-dst)\n"
1044 " Configure the NVGRE encapsulation for flows.\n\n"
1046 "set raw_encap {flow items}\n"
1047 " Configure the encapsulation with raw data.\n\n"
1049 "set raw_decap {flow items}\n"
1050 " Configure the decapsulation with raw data.\n\n"
1055 if (show_all || !strcmp(res->section, "traffic_management")) {
1059 "Traffic Management:\n"
1061 "show port tm cap (port_id)\n"
1062 " Display the port TM capability.\n\n"
1064 "show port tm level cap (port_id) (level_id)\n"
1065 " Display the port TM hierarchical level capability.\n\n"
1067 "show port tm node cap (port_id) (node_id)\n"
1068 " Display the port TM node capability.\n\n"
1070 "show port tm node type (port_id) (node_id)\n"
1071 " Display the port TM node type.\n\n"
1073 "show port tm node stats (port_id) (node_id) (clear)\n"
1074 " Display the port TM node stats.\n\n"
1076 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1077 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1078 " (packet_length_adjust) (packet_mode)\n"
1079 " Add port tm node private shaper profile.\n\n"
1081 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1082 " Delete port tm node private shaper profile.\n\n"
1084 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1085 " (shaper_profile_id)\n"
1086 " Add/update port tm node shared shaper.\n\n"
1088 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1089 " Delete port tm node shared shaper.\n\n"
1091 "set port tm node shaper profile (port_id) (node_id)"
1092 " (shaper_profile_id)\n"
1093 " Set port tm node shaper profile.\n\n"
1095 "add port tm node wred profile (port_id) (wred_profile_id)"
1096 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1097 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1098 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1099 " Add port tm node wred profile.\n\n"
1101 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1102 " Delete port tm node wred profile.\n\n"
1104 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1105 " (priority) (weight) (level_id) (shaper_profile_id)"
1106 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1107 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1108 " Add port tm nonleaf node.\n\n"
1110 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1111 " (priority) (weight) (level_id) (shaper_profile_id)"
1112 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1113 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1114 " Add port tm nonleaf node with pkt mode enabled.\n\n"
1116 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1117 " (priority) (weight) (level_id) (shaper_profile_id)"
1118 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1119 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1120 " Add port tm leaf node.\n\n"
1122 "del port tm node (port_id) (node_id)\n"
1123 " Delete port tm node.\n\n"
1125 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1126 " (priority) (weight)\n"
1127 " Set port tm node parent.\n\n"
1129 "suspend port tm node (port_id) (node_id)"
1130 " Suspend tm node.\n\n"
1132 "resume port tm node (port_id) (node_id)"
1133 " Resume tm node.\n\n"
1135 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1136 " Commit tm hierarchy.\n\n"
1138 "set port tm mark ip_ecn (port) (green) (yellow)"
1140 " Enables/Disables the traffic management marking"
1141 " for IP ECN (Explicit Congestion Notification)"
1142 " packets on a given port\n\n"
1144 "set port tm mark ip_dscp (port) (green) (yellow)"
1146 " Enables/Disables the traffic management marking"
1147 " on the port for IP dscp packets\n\n"
1149 "set port tm mark vlan_dei (port) (green) (yellow)"
1151 " Enables/Disables the traffic management marking"
1152 " on the port for VLAN packets with DEI enabled\n\n"
1156 if (show_all || !strcmp(res->section, "devices")) {
1160 "Device Operations:\n"
1162 "device detach (identifier)\n"
1163 " Detach device by identifier.\n\n"
1169 cmdline_parse_token_string_t cmd_help_long_help =
1170 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1172 cmdline_parse_token_string_t cmd_help_long_section =
1173 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1174 "all#control#display#config#"
1175 "ports#registers#filters#traffic_management#devices");
1177 cmdline_parse_inst_t cmd_help_long = {
1178 .f = cmd_help_long_parsed,
1180 .help_str = "help all|control|display|config|ports|register|"
1181 "filters|traffic_management|devices: "
1184 (void *)&cmd_help_long_help,
1185 (void *)&cmd_help_long_section,
1191 /* *** start/stop/close all ports *** */
1192 struct cmd_operate_port_result {
1193 cmdline_fixed_string_t keyword;
1194 cmdline_fixed_string_t name;
1195 cmdline_fixed_string_t value;
1198 static void cmd_operate_port_parsed(void *parsed_result,
1199 __rte_unused struct cmdline *cl,
1200 __rte_unused void *data)
1202 struct cmd_operate_port_result *res = parsed_result;
1204 if (!strcmp(res->name, "start"))
1205 start_port(RTE_PORT_ALL);
1206 else if (!strcmp(res->name, "stop"))
1207 stop_port(RTE_PORT_ALL);
1208 else if (!strcmp(res->name, "close"))
1209 close_port(RTE_PORT_ALL);
1210 else if (!strcmp(res->name, "reset"))
1211 reset_port(RTE_PORT_ALL);
1213 fprintf(stderr, "Unknown parameter\n");
1216 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1217 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1219 cmdline_parse_token_string_t cmd_operate_port_all_port =
1220 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1221 "start#stop#close#reset");
1222 cmdline_parse_token_string_t cmd_operate_port_all_all =
1223 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1225 cmdline_parse_inst_t cmd_operate_port = {
1226 .f = cmd_operate_port_parsed,
1228 .help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports",
1230 (void *)&cmd_operate_port_all_cmd,
1231 (void *)&cmd_operate_port_all_port,
1232 (void *)&cmd_operate_port_all_all,
1237 /* *** start/stop/close specific port *** */
1238 struct cmd_operate_specific_port_result {
1239 cmdline_fixed_string_t keyword;
1240 cmdline_fixed_string_t name;
1244 static void cmd_operate_specific_port_parsed(void *parsed_result,
1245 __rte_unused struct cmdline *cl,
1246 __rte_unused void *data)
1248 struct cmd_operate_specific_port_result *res = parsed_result;
1250 if (!strcmp(res->name, "start"))
1251 start_port(res->value);
1252 else if (!strcmp(res->name, "stop"))
1253 stop_port(res->value);
1254 else if (!strcmp(res->name, "close"))
1255 close_port(res->value);
1256 else if (!strcmp(res->name, "reset"))
1257 reset_port(res->value);
1259 fprintf(stderr, "Unknown parameter\n");
1262 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1263 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1265 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1266 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1267 name, "start#stop#close#reset");
1268 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1269 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1272 cmdline_parse_inst_t cmd_operate_specific_port = {
1273 .f = cmd_operate_specific_port_parsed,
1275 .help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id",
1277 (void *)&cmd_operate_specific_port_cmd,
1278 (void *)&cmd_operate_specific_port_port,
1279 (void *)&cmd_operate_specific_port_id,
1284 /* *** enable port setup (after attach) via iterator or event *** */
1285 struct cmd_set_port_setup_on_result {
1286 cmdline_fixed_string_t set;
1287 cmdline_fixed_string_t port;
1288 cmdline_fixed_string_t setup;
1289 cmdline_fixed_string_t on;
1290 cmdline_fixed_string_t mode;
1293 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1294 __rte_unused struct cmdline *cl,
1295 __rte_unused void *data)
1297 struct cmd_set_port_setup_on_result *res = parsed_result;
1299 if (strcmp(res->mode, "event") == 0)
1300 setup_on_probe_event = true;
1301 else if (strcmp(res->mode, "iterator") == 0)
1302 setup_on_probe_event = false;
1304 fprintf(stderr, "Unknown mode\n");
1307 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1308 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1310 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1311 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1313 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1314 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1316 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1317 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1319 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1320 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1321 mode, "iterator#event");
1323 cmdline_parse_inst_t cmd_set_port_setup_on = {
1324 .f = cmd_set_port_setup_on_parsed,
1326 .help_str = "set port setup on iterator|event",
1328 (void *)&cmd_set_port_setup_on_set,
1329 (void *)&cmd_set_port_setup_on_port,
1330 (void *)&cmd_set_port_setup_on_setup,
1331 (void *)&cmd_set_port_setup_on_on,
1332 (void *)&cmd_set_port_setup_on_mode,
1337 /* *** attach a specified port *** */
1338 struct cmd_operate_attach_port_result {
1339 cmdline_fixed_string_t port;
1340 cmdline_fixed_string_t keyword;
1341 cmdline_multi_string_t identifier;
1344 static void cmd_operate_attach_port_parsed(void *parsed_result,
1345 __rte_unused struct cmdline *cl,
1346 __rte_unused void *data)
1348 struct cmd_operate_attach_port_result *res = parsed_result;
1350 if (!strcmp(res->keyword, "attach"))
1351 attach_port(res->identifier);
1353 fprintf(stderr, "Unknown parameter\n");
1356 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1357 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1359 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1360 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1362 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1363 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1364 identifier, TOKEN_STRING_MULTI);
1366 cmdline_parse_inst_t cmd_operate_attach_port = {
1367 .f = cmd_operate_attach_port_parsed,
1369 .help_str = "port attach <identifier>: "
1370 "(identifier: pci address or virtual dev name)",
1372 (void *)&cmd_operate_attach_port_port,
1373 (void *)&cmd_operate_attach_port_keyword,
1374 (void *)&cmd_operate_attach_port_identifier,
1379 /* *** detach a specified port *** */
1380 struct cmd_operate_detach_port_result {
1381 cmdline_fixed_string_t port;
1382 cmdline_fixed_string_t keyword;
1386 static void cmd_operate_detach_port_parsed(void *parsed_result,
1387 __rte_unused struct cmdline *cl,
1388 __rte_unused void *data)
1390 struct cmd_operate_detach_port_result *res = parsed_result;
1392 if (!strcmp(res->keyword, "detach")) {
1393 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1394 detach_port_device(res->port_id);
1396 fprintf(stderr, "Unknown parameter\n");
1400 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1401 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1403 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1404 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1406 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1407 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1408 port_id, RTE_UINT16);
1410 cmdline_parse_inst_t cmd_operate_detach_port = {
1411 .f = cmd_operate_detach_port_parsed,
1413 .help_str = "port detach <port_id>",
1415 (void *)&cmd_operate_detach_port_port,
1416 (void *)&cmd_operate_detach_port_keyword,
1417 (void *)&cmd_operate_detach_port_port_id,
1422 /* *** detach device by identifier *** */
1423 struct cmd_operate_detach_device_result {
1424 cmdline_fixed_string_t device;
1425 cmdline_fixed_string_t keyword;
1426 cmdline_fixed_string_t identifier;
1429 static void cmd_operate_detach_device_parsed(void *parsed_result,
1430 __rte_unused struct cmdline *cl,
1431 __rte_unused void *data)
1433 struct cmd_operate_detach_device_result *res = parsed_result;
1435 if (!strcmp(res->keyword, "detach"))
1436 detach_devargs(res->identifier);
1438 fprintf(stderr, "Unknown parameter\n");
1441 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1442 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1444 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1445 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1447 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1448 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1451 cmdline_parse_inst_t cmd_operate_detach_device = {
1452 .f = cmd_operate_detach_device_parsed,
1454 .help_str = "device detach <identifier>:"
1455 "(identifier: pci address or virtual dev name)",
1457 (void *)&cmd_operate_detach_device_device,
1458 (void *)&cmd_operate_detach_device_keyword,
1459 (void *)&cmd_operate_detach_device_identifier,
1463 /* *** configure speed for all ports *** */
1464 struct cmd_config_speed_all {
1465 cmdline_fixed_string_t port;
1466 cmdline_fixed_string_t keyword;
1467 cmdline_fixed_string_t all;
1468 cmdline_fixed_string_t item1;
1469 cmdline_fixed_string_t item2;
1470 cmdline_fixed_string_t value1;
1471 cmdline_fixed_string_t value2;
1475 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1480 if (!strcmp(duplexstr, "half")) {
1481 duplex = RTE_ETH_LINK_HALF_DUPLEX;
1482 } else if (!strcmp(duplexstr, "full")) {
1483 duplex = RTE_ETH_LINK_FULL_DUPLEX;
1484 } else if (!strcmp(duplexstr, "auto")) {
1485 duplex = RTE_ETH_LINK_FULL_DUPLEX;
1487 fprintf(stderr, "Unknown duplex parameter\n");
1491 if (!strcmp(speedstr, "10")) {
1492 *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1493 RTE_ETH_LINK_SPEED_10M_HD : RTE_ETH_LINK_SPEED_10M;
1494 } else if (!strcmp(speedstr, "100")) {
1495 *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1496 RTE_ETH_LINK_SPEED_100M_HD : RTE_ETH_LINK_SPEED_100M;
1498 if (duplex != RTE_ETH_LINK_FULL_DUPLEX) {
1499 fprintf(stderr, "Invalid speed/duplex parameters\n");
1502 if (!strcmp(speedstr, "1000")) {
1503 *speed = RTE_ETH_LINK_SPEED_1G;
1504 } else if (!strcmp(speedstr, "10000")) {
1505 *speed = RTE_ETH_LINK_SPEED_10G;
1506 } else if (!strcmp(speedstr, "25000")) {
1507 *speed = RTE_ETH_LINK_SPEED_25G;
1508 } else if (!strcmp(speedstr, "40000")) {
1509 *speed = RTE_ETH_LINK_SPEED_40G;
1510 } else if (!strcmp(speedstr, "50000")) {
1511 *speed = RTE_ETH_LINK_SPEED_50G;
1512 } else if (!strcmp(speedstr, "100000")) {
1513 *speed = RTE_ETH_LINK_SPEED_100G;
1514 } else if (!strcmp(speedstr, "200000")) {
1515 *speed = RTE_ETH_LINK_SPEED_200G;
1516 } else if (!strcmp(speedstr, "auto")) {
1517 *speed = RTE_ETH_LINK_SPEED_AUTONEG;
1519 fprintf(stderr, "Unknown speed parameter\n");
1524 if (*speed != RTE_ETH_LINK_SPEED_AUTONEG)
1525 *speed |= RTE_ETH_LINK_SPEED_FIXED;
1531 cmd_config_speed_all_parsed(void *parsed_result,
1532 __rte_unused struct cmdline *cl,
1533 __rte_unused void *data)
1535 struct cmd_config_speed_all *res = parsed_result;
1536 uint32_t link_speed;
1539 if (!all_ports_stopped()) {
1540 fprintf(stderr, "Please stop all ports first\n");
1544 if (parse_and_check_speed_duplex(res->value1, res->value2,
1548 RTE_ETH_FOREACH_DEV(pid) {
1549 ports[pid].dev_conf.link_speeds = link_speed;
1552 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1555 cmdline_parse_token_string_t cmd_config_speed_all_port =
1556 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1557 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1558 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1560 cmdline_parse_token_string_t cmd_config_speed_all_all =
1561 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1562 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1563 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1564 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1565 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1566 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1567 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1568 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1569 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1570 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1573 cmdline_parse_inst_t cmd_config_speed_all = {
1574 .f = cmd_config_speed_all_parsed,
1576 .help_str = "port config all speed "
1577 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1580 (void *)&cmd_config_speed_all_port,
1581 (void *)&cmd_config_speed_all_keyword,
1582 (void *)&cmd_config_speed_all_all,
1583 (void *)&cmd_config_speed_all_item1,
1584 (void *)&cmd_config_speed_all_value1,
1585 (void *)&cmd_config_speed_all_item2,
1586 (void *)&cmd_config_speed_all_value2,
1591 /* *** configure speed for specific port *** */
1592 struct cmd_config_speed_specific {
1593 cmdline_fixed_string_t port;
1594 cmdline_fixed_string_t keyword;
1596 cmdline_fixed_string_t item1;
1597 cmdline_fixed_string_t item2;
1598 cmdline_fixed_string_t value1;
1599 cmdline_fixed_string_t value2;
1603 cmd_config_speed_specific_parsed(void *parsed_result,
1604 __rte_unused struct cmdline *cl,
1605 __rte_unused void *data)
1607 struct cmd_config_speed_specific *res = parsed_result;
1608 uint32_t link_speed;
1610 if (port_id_is_invalid(res->id, ENABLED_WARN))
1613 if (!port_is_stopped(res->id)) {
1614 fprintf(stderr, "Please stop port %d first\n", res->id);
1618 if (parse_and_check_speed_duplex(res->value1, res->value2,
1622 ports[res->id].dev_conf.link_speeds = link_speed;
1624 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1628 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1629 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1631 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1632 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1634 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1635 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1636 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1637 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1639 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1640 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1641 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1642 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1643 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1645 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1646 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1649 cmdline_parse_inst_t cmd_config_speed_specific = {
1650 .f = cmd_config_speed_specific_parsed,
1652 .help_str = "port config <port_id> speed "
1653 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1656 (void *)&cmd_config_speed_specific_port,
1657 (void *)&cmd_config_speed_specific_keyword,
1658 (void *)&cmd_config_speed_specific_id,
1659 (void *)&cmd_config_speed_specific_item1,
1660 (void *)&cmd_config_speed_specific_value1,
1661 (void *)&cmd_config_speed_specific_item2,
1662 (void *)&cmd_config_speed_specific_value2,
1667 /* *** configure loopback for all ports *** */
1668 struct cmd_config_loopback_all {
1669 cmdline_fixed_string_t port;
1670 cmdline_fixed_string_t keyword;
1671 cmdline_fixed_string_t all;
1672 cmdline_fixed_string_t item;
1677 cmd_config_loopback_all_parsed(void *parsed_result,
1678 __rte_unused struct cmdline *cl,
1679 __rte_unused void *data)
1681 struct cmd_config_loopback_all *res = parsed_result;
1684 if (!all_ports_stopped()) {
1685 fprintf(stderr, "Please stop all ports first\n");
1689 RTE_ETH_FOREACH_DEV(pid) {
1690 ports[pid].dev_conf.lpbk_mode = res->mode;
1693 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1696 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1697 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1698 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1699 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1701 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1702 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1703 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1704 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1706 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1707 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1709 cmdline_parse_inst_t cmd_config_loopback_all = {
1710 .f = cmd_config_loopback_all_parsed,
1712 .help_str = "port config all loopback <mode>",
1714 (void *)&cmd_config_loopback_all_port,
1715 (void *)&cmd_config_loopback_all_keyword,
1716 (void *)&cmd_config_loopback_all_all,
1717 (void *)&cmd_config_loopback_all_item,
1718 (void *)&cmd_config_loopback_all_mode,
1723 /* *** configure loopback for specific port *** */
1724 struct cmd_config_loopback_specific {
1725 cmdline_fixed_string_t port;
1726 cmdline_fixed_string_t keyword;
1728 cmdline_fixed_string_t item;
1733 cmd_config_loopback_specific_parsed(void *parsed_result,
1734 __rte_unused struct cmdline *cl,
1735 __rte_unused void *data)
1737 struct cmd_config_loopback_specific *res = parsed_result;
1739 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1742 if (!port_is_stopped(res->port_id)) {
1743 fprintf(stderr, "Please stop port %u first\n", res->port_id);
1747 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1749 cmd_reconfig_device_queue(res->port_id, 1, 1);
1753 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1754 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1756 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1757 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1759 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1760 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1762 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1763 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1765 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1766 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1769 cmdline_parse_inst_t cmd_config_loopback_specific = {
1770 .f = cmd_config_loopback_specific_parsed,
1772 .help_str = "port config <port_id> loopback <mode>",
1774 (void *)&cmd_config_loopback_specific_port,
1775 (void *)&cmd_config_loopback_specific_keyword,
1776 (void *)&cmd_config_loopback_specific_id,
1777 (void *)&cmd_config_loopback_specific_item,
1778 (void *)&cmd_config_loopback_specific_mode,
1783 /* *** configure txq/rxq, txd/rxd *** */
1784 struct cmd_config_rx_tx {
1785 cmdline_fixed_string_t port;
1786 cmdline_fixed_string_t keyword;
1787 cmdline_fixed_string_t all;
1788 cmdline_fixed_string_t name;
1793 cmd_config_rx_tx_parsed(void *parsed_result,
1794 __rte_unused struct cmdline *cl,
1795 __rte_unused void *data)
1797 struct cmd_config_rx_tx *res = parsed_result;
1799 if (!all_ports_stopped()) {
1800 fprintf(stderr, "Please stop all ports first\n");
1803 if (!strcmp(res->name, "rxq")) {
1804 if (!res->value && !nb_txq) {
1805 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1808 if (check_nb_rxq(res->value) != 0)
1810 nb_rxq = res->value;
1812 else if (!strcmp(res->name, "txq")) {
1813 if (!res->value && !nb_rxq) {
1814 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1817 if (check_nb_txq(res->value) != 0)
1819 nb_txq = res->value;
1821 else if (!strcmp(res->name, "rxd")) {
1822 if (check_nb_rxd(res->value) != 0)
1824 nb_rxd = res->value;
1825 } else if (!strcmp(res->name, "txd")) {
1826 if (check_nb_txd(res->value) != 0)
1829 nb_txd = res->value;
1831 fprintf(stderr, "Unknown parameter\n");
1839 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1842 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1843 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1844 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1845 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1846 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1847 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1848 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1849 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1851 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1852 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
1854 cmdline_parse_inst_t cmd_config_rx_tx = {
1855 .f = cmd_config_rx_tx_parsed,
1857 .help_str = "port config all rxq|txq|rxd|txd <value>",
1859 (void *)&cmd_config_rx_tx_port,
1860 (void *)&cmd_config_rx_tx_keyword,
1861 (void *)&cmd_config_rx_tx_all,
1862 (void *)&cmd_config_rx_tx_name,
1863 (void *)&cmd_config_rx_tx_value,
1868 /* *** config max packet length *** */
1869 struct cmd_config_max_pkt_len_result {
1870 cmdline_fixed_string_t port;
1871 cmdline_fixed_string_t keyword;
1872 cmdline_fixed_string_t all;
1873 cmdline_fixed_string_t name;
1878 cmd_config_max_pkt_len_parsed(void *parsed_result,
1879 __rte_unused struct cmdline *cl,
1880 __rte_unused void *data)
1882 struct cmd_config_max_pkt_len_result *res = parsed_result;
1886 if (strcmp(res->name, "max-pkt-len") != 0) {
1887 printf("Unknown parameter\n");
1891 if (!all_ports_stopped()) {
1892 fprintf(stderr, "Please stop all ports first\n");
1896 RTE_ETH_FOREACH_DEV(port_id) {
1897 struct rte_port *port = &ports[port_id];
1899 if (res->value < RTE_ETHER_MIN_LEN) {
1901 "max-pkt-len can not be less than %d\n",
1906 ret = eth_dev_info_get_print_err(port_id, &port->dev_info);
1909 "rte_eth_dev_info_get() failed for port %u\n",
1914 update_mtu_from_frame_size(port_id, res->value);
1919 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1922 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1923 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1925 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1926 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1928 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1929 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1931 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1932 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1934 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1935 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1938 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1939 .f = cmd_config_max_pkt_len_parsed,
1941 .help_str = "port config all max-pkt-len <value>",
1943 (void *)&cmd_config_max_pkt_len_port,
1944 (void *)&cmd_config_max_pkt_len_keyword,
1945 (void *)&cmd_config_max_pkt_len_all,
1946 (void *)&cmd_config_max_pkt_len_name,
1947 (void *)&cmd_config_max_pkt_len_value,
1952 /* *** config max LRO aggregated packet size *** */
1953 struct cmd_config_max_lro_pkt_size_result {
1954 cmdline_fixed_string_t port;
1955 cmdline_fixed_string_t keyword;
1956 cmdline_fixed_string_t all;
1957 cmdline_fixed_string_t name;
1962 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1963 __rte_unused struct cmdline *cl,
1964 __rte_unused void *data)
1966 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1969 if (!all_ports_stopped()) {
1970 fprintf(stderr, "Please stop all ports first\n");
1974 RTE_ETH_FOREACH_DEV(pid) {
1975 struct rte_port *port = &ports[pid];
1977 if (!strcmp(res->name, "max-lro-pkt-size")) {
1979 port->dev_conf.rxmode.max_lro_pkt_size)
1982 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
1984 fprintf(stderr, "Unknown parameter\n");
1991 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1994 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
1995 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1997 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
1998 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2000 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2001 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2003 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2004 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2005 name, "max-lro-pkt-size");
2006 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2007 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2010 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2011 .f = cmd_config_max_lro_pkt_size_parsed,
2013 .help_str = "port config all max-lro-pkt-size <value>",
2015 (void *)&cmd_config_max_lro_pkt_size_port,
2016 (void *)&cmd_config_max_lro_pkt_size_keyword,
2017 (void *)&cmd_config_max_lro_pkt_size_all,
2018 (void *)&cmd_config_max_lro_pkt_size_name,
2019 (void *)&cmd_config_max_lro_pkt_size_value,
2024 /* *** configure port MTU *** */
2025 struct cmd_config_mtu_result {
2026 cmdline_fixed_string_t port;
2027 cmdline_fixed_string_t keyword;
2028 cmdline_fixed_string_t mtu;
2034 cmd_config_mtu_parsed(void *parsed_result,
2035 __rte_unused struct cmdline *cl,
2036 __rte_unused void *data)
2038 struct cmd_config_mtu_result *res = parsed_result;
2040 if (res->value < RTE_ETHER_MIN_LEN) {
2041 fprintf(stderr, "mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2044 port_mtu_set(res->port_id, res->value);
2047 cmdline_parse_token_string_t cmd_config_mtu_port =
2048 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2050 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2051 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2053 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2054 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2056 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2057 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2059 cmdline_parse_token_num_t cmd_config_mtu_value =
2060 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2063 cmdline_parse_inst_t cmd_config_mtu = {
2064 .f = cmd_config_mtu_parsed,
2066 .help_str = "port config mtu <port_id> <value>",
2068 (void *)&cmd_config_mtu_port,
2069 (void *)&cmd_config_mtu_keyword,
2070 (void *)&cmd_config_mtu_mtu,
2071 (void *)&cmd_config_mtu_port_id,
2072 (void *)&cmd_config_mtu_value,
2077 /* *** configure rx mode *** */
2078 struct cmd_config_rx_mode_flag {
2079 cmdline_fixed_string_t port;
2080 cmdline_fixed_string_t keyword;
2081 cmdline_fixed_string_t all;
2082 cmdline_fixed_string_t name;
2083 cmdline_fixed_string_t value;
2087 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2088 __rte_unused struct cmdline *cl,
2089 __rte_unused void *data)
2091 struct cmd_config_rx_mode_flag *res = parsed_result;
2093 if (!all_ports_stopped()) {
2094 fprintf(stderr, "Please stop all ports first\n");
2098 if (!strcmp(res->name, "drop-en")) {
2099 if (!strcmp(res->value, "on"))
2101 else if (!strcmp(res->value, "off"))
2104 fprintf(stderr, "Unknown parameter\n");
2108 fprintf(stderr, "Unknown parameter\n");
2114 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2117 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2118 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2119 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2120 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2122 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2123 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2124 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2125 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2127 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2128 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2131 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2132 .f = cmd_config_rx_mode_flag_parsed,
2134 .help_str = "port config all drop-en on|off",
2136 (void *)&cmd_config_rx_mode_flag_port,
2137 (void *)&cmd_config_rx_mode_flag_keyword,
2138 (void *)&cmd_config_rx_mode_flag_all,
2139 (void *)&cmd_config_rx_mode_flag_name,
2140 (void *)&cmd_config_rx_mode_flag_value,
2145 /* *** configure rss *** */
2146 struct cmd_config_rss {
2147 cmdline_fixed_string_t port;
2148 cmdline_fixed_string_t keyword;
2149 cmdline_fixed_string_t all;
2150 cmdline_fixed_string_t name;
2151 cmdline_fixed_string_t value;
2155 cmd_config_rss_parsed(void *parsed_result,
2156 __rte_unused struct cmdline *cl,
2157 __rte_unused void *data)
2159 struct cmd_config_rss *res = parsed_result;
2160 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2161 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2162 int use_default = 0;
2163 int all_updated = 1;
2168 if (!strcmp(res->value, "all"))
2169 rss_conf.rss_hf = RTE_ETH_RSS_ETH | RTE_ETH_RSS_VLAN | RTE_ETH_RSS_IP |
2170 RTE_ETH_RSS_TCP | RTE_ETH_RSS_UDP | RTE_ETH_RSS_SCTP |
2171 RTE_ETH_RSS_L2_PAYLOAD | RTE_ETH_RSS_L2TPV3 | RTE_ETH_RSS_ESP |
2172 RTE_ETH_RSS_AH | RTE_ETH_RSS_PFCP | RTE_ETH_RSS_GTPU |
2174 else if (!strcmp(res->value, "eth"))
2175 rss_conf.rss_hf = RTE_ETH_RSS_ETH;
2176 else if (!strcmp(res->value, "vlan"))
2177 rss_conf.rss_hf = RTE_ETH_RSS_VLAN;
2178 else if (!strcmp(res->value, "ip"))
2179 rss_conf.rss_hf = RTE_ETH_RSS_IP;
2180 else if (!strcmp(res->value, "udp"))
2181 rss_conf.rss_hf = RTE_ETH_RSS_UDP;
2182 else if (!strcmp(res->value, "tcp"))
2183 rss_conf.rss_hf = RTE_ETH_RSS_TCP;
2184 else if (!strcmp(res->value, "sctp"))
2185 rss_conf.rss_hf = RTE_ETH_RSS_SCTP;
2186 else if (!strcmp(res->value, "ether"))
2187 rss_conf.rss_hf = RTE_ETH_RSS_L2_PAYLOAD;
2188 else if (!strcmp(res->value, "port"))
2189 rss_conf.rss_hf = RTE_ETH_RSS_PORT;
2190 else if (!strcmp(res->value, "vxlan"))
2191 rss_conf.rss_hf = RTE_ETH_RSS_VXLAN;
2192 else if (!strcmp(res->value, "geneve"))
2193 rss_conf.rss_hf = RTE_ETH_RSS_GENEVE;
2194 else if (!strcmp(res->value, "nvgre"))
2195 rss_conf.rss_hf = RTE_ETH_RSS_NVGRE;
2196 else if (!strcmp(res->value, "l3-pre32"))
2197 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2198 else if (!strcmp(res->value, "l3-pre40"))
2199 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2200 else if (!strcmp(res->value, "l3-pre48"))
2201 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2202 else if (!strcmp(res->value, "l3-pre56"))
2203 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2204 else if (!strcmp(res->value, "l3-pre64"))
2205 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2206 else if (!strcmp(res->value, "l3-pre96"))
2207 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2208 else if (!strcmp(res->value, "l3-src-only"))
2209 rss_conf.rss_hf = RTE_ETH_RSS_L3_SRC_ONLY;
2210 else if (!strcmp(res->value, "l3-dst-only"))
2211 rss_conf.rss_hf = RTE_ETH_RSS_L3_DST_ONLY;
2212 else if (!strcmp(res->value, "l4-src-only"))
2213 rss_conf.rss_hf = RTE_ETH_RSS_L4_SRC_ONLY;
2214 else if (!strcmp(res->value, "l4-dst-only"))
2215 rss_conf.rss_hf = RTE_ETH_RSS_L4_DST_ONLY;
2216 else if (!strcmp(res->value, "l2-src-only"))
2217 rss_conf.rss_hf = RTE_ETH_RSS_L2_SRC_ONLY;
2218 else if (!strcmp(res->value, "l2-dst-only"))
2219 rss_conf.rss_hf = RTE_ETH_RSS_L2_DST_ONLY;
2220 else if (!strcmp(res->value, "l2tpv3"))
2221 rss_conf.rss_hf = RTE_ETH_RSS_L2TPV3;
2222 else if (!strcmp(res->value, "esp"))
2223 rss_conf.rss_hf = RTE_ETH_RSS_ESP;
2224 else if (!strcmp(res->value, "ah"))
2225 rss_conf.rss_hf = RTE_ETH_RSS_AH;
2226 else if (!strcmp(res->value, "pfcp"))
2227 rss_conf.rss_hf = RTE_ETH_RSS_PFCP;
2228 else if (!strcmp(res->value, "pppoe"))
2229 rss_conf.rss_hf = RTE_ETH_RSS_PPPOE;
2230 else if (!strcmp(res->value, "gtpu"))
2231 rss_conf.rss_hf = RTE_ETH_RSS_GTPU;
2232 else if (!strcmp(res->value, "ecpri"))
2233 rss_conf.rss_hf = RTE_ETH_RSS_ECPRI;
2234 else if (!strcmp(res->value, "mpls"))
2235 rss_conf.rss_hf = RTE_ETH_RSS_MPLS;
2236 else if (!strcmp(res->value, "ipv4-chksum"))
2237 rss_conf.rss_hf = RTE_ETH_RSS_IPV4_CHKSUM;
2238 else if (!strcmp(res->value, "none"))
2239 rss_conf.rss_hf = 0;
2240 else if (!strcmp(res->value, "level-default")) {
2241 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2242 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_PMD_DEFAULT);
2243 } else if (!strcmp(res->value, "level-outer")) {
2244 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2245 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_OUTERMOST);
2246 } else if (!strcmp(res->value, "level-inner")) {
2247 rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2248 rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_INNERMOST);
2249 } else if (!strcmp(res->value, "default"))
2251 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2252 atoi(res->value) < 64)
2253 rss_conf.rss_hf = 1ULL << atoi(res->value);
2255 fprintf(stderr, "Unknown parameter\n");
2258 rss_conf.rss_key = NULL;
2259 /* Update global configuration for RSS types. */
2260 RTE_ETH_FOREACH_DEV(i) {
2261 struct rte_eth_rss_conf local_rss_conf;
2263 ret = eth_dev_info_get_print_err(i, &dev_info);
2268 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2270 local_rss_conf = rss_conf;
2271 local_rss_conf.rss_hf = rss_conf.rss_hf &
2272 dev_info.flow_type_rss_offloads;
2273 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2274 printf("Port %u modified RSS hash function based on hardware support,"
2275 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2276 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2278 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2282 "Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n",
2283 i, -diag, strerror(-diag));
2286 if (all_updated && !use_default) {
2287 rss_hf = rss_conf.rss_hf;
2288 printf("rss_hf %#"PRIx64"\n", rss_hf);
2292 cmdline_parse_token_string_t cmd_config_rss_port =
2293 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2294 cmdline_parse_token_string_t cmd_config_rss_keyword =
2295 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2296 cmdline_parse_token_string_t cmd_config_rss_all =
2297 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2298 cmdline_parse_token_string_t cmd_config_rss_name =
2299 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2300 cmdline_parse_token_string_t cmd_config_rss_value =
2301 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2303 cmdline_parse_inst_t cmd_config_rss = {
2304 .f = cmd_config_rss_parsed,
2306 .help_str = "port config all rss "
2307 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2308 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none|level-default|"
2309 "level-outer|level-inner|ipv4-chksum|<flowtype_id>",
2311 (void *)&cmd_config_rss_port,
2312 (void *)&cmd_config_rss_keyword,
2313 (void *)&cmd_config_rss_all,
2314 (void *)&cmd_config_rss_name,
2315 (void *)&cmd_config_rss_value,
2320 /* *** configure rss hash key *** */
2321 struct cmd_config_rss_hash_key {
2322 cmdline_fixed_string_t port;
2323 cmdline_fixed_string_t config;
2325 cmdline_fixed_string_t rss_hash_key;
2326 cmdline_fixed_string_t rss_type;
2327 cmdline_fixed_string_t key;
2331 hexa_digit_to_value(char hexa_digit)
2333 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2334 return (uint8_t) (hexa_digit - '0');
2335 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2336 return (uint8_t) ((hexa_digit - 'a') + 10);
2337 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2338 return (uint8_t) ((hexa_digit - 'A') + 10);
2339 /* Invalid hexa digit */
2344 parse_and_check_key_hexa_digit(char *key, int idx)
2348 hexa_v = hexa_digit_to_value(key[idx]);
2351 "invalid key: character %c at position %d is not a valid hexa digit\n",
2357 cmd_config_rss_hash_key_parsed(void *parsed_result,
2358 __rte_unused struct cmdline *cl,
2359 __rte_unused void *data)
2361 struct cmd_config_rss_hash_key *res = parsed_result;
2362 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2366 struct rte_eth_dev_info dev_info;
2367 uint8_t hash_key_size;
2371 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2375 if (dev_info.hash_key_size > 0 &&
2376 dev_info.hash_key_size <= sizeof(hash_key))
2377 hash_key_size = dev_info.hash_key_size;
2380 "dev_info did not provide a valid hash key size\n");
2383 /* Check the length of the RSS hash key */
2384 key_len = strlen(res->key);
2385 if (key_len != (hash_key_size * 2)) {
2387 "key length: %d invalid - key must be a string of %d hexa-decimal numbers\n",
2388 (int)key_len, hash_key_size * 2);
2391 /* Translate RSS hash key into binary representation */
2392 for (i = 0; i < hash_key_size; i++) {
2393 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2396 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2399 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2401 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2405 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2406 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2407 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2408 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2410 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2411 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2413 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2414 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2415 rss_hash_key, "rss-hash-key");
2416 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2417 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2418 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2419 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2420 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2421 "ipv6-tcp-ex#ipv6-udp-ex#"
2422 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2423 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2424 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls");
2425 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2426 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2428 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2429 .f = cmd_config_rss_hash_key_parsed,
2431 .help_str = "port config <port_id> rss-hash-key "
2432 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2433 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2434 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2435 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2436 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2437 "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls "
2438 "<string of hex digits (variable length, NIC dependent)>",
2440 (void *)&cmd_config_rss_hash_key_port,
2441 (void *)&cmd_config_rss_hash_key_config,
2442 (void *)&cmd_config_rss_hash_key_port_id,
2443 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2444 (void *)&cmd_config_rss_hash_key_rss_type,
2445 (void *)&cmd_config_rss_hash_key_value,
2450 /* *** cleanup txq mbufs *** */
2451 struct cmd_cleanup_txq_mbufs_result {
2452 cmdline_fixed_string_t port;
2453 cmdline_fixed_string_t keyword;
2454 cmdline_fixed_string_t name;
2461 cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2462 __rte_unused struct cmdline *cl,
2463 __rte_unused void *data)
2465 struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2466 uint16_t port_id = res->port_id;
2467 uint16_t queue_id = res->queue_id;
2468 uint32_t free_cnt = res->free_cnt;
2469 struct rte_eth_txq_info qinfo;
2472 if (test_done == 0) {
2473 fprintf(stderr, "Please stop forwarding first\n");
2477 if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2478 fprintf(stderr, "Failed to get port %u Tx queue %u info\n",
2483 if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2484 fprintf(stderr, "Tx queue %u not started\n", queue_id);
2488 ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2491 "Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n",
2492 port_id, queue_id, strerror(-ret), ret);
2496 printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2497 port_id, queue_id, ret);
2500 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2501 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2503 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2504 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2506 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2507 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2509 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2510 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2512 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2513 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2515 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2516 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2519 cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2520 .f = cmd_cleanup_txq_mbufs_parsed,
2522 .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2524 (void *)&cmd_cleanup_txq_mbufs_port,
2525 (void *)&cmd_cleanup_txq_mbufs_cleanup,
2526 (void *)&cmd_cleanup_txq_mbufs_port_id,
2527 (void *)&cmd_cleanup_txq_mbufs_txq,
2528 (void *)&cmd_cleanup_txq_mbufs_queue_id,
2529 (void *)&cmd_cleanup_txq_mbufs_free_cnt,
2534 /* *** configure port rxq/txq ring size *** */
2535 struct cmd_config_rxtx_ring_size {
2536 cmdline_fixed_string_t port;
2537 cmdline_fixed_string_t config;
2539 cmdline_fixed_string_t rxtxq;
2541 cmdline_fixed_string_t rsize;
2546 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2547 __rte_unused struct cmdline *cl,
2548 __rte_unused void *data)
2550 struct cmd_config_rxtx_ring_size *res = parsed_result;
2551 struct rte_port *port;
2554 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2557 if (res->portid == (portid_t)RTE_PORT_ALL) {
2558 fprintf(stderr, "Invalid port id\n");
2562 port = &ports[res->portid];
2564 if (!strcmp(res->rxtxq, "rxq"))
2566 else if (!strcmp(res->rxtxq, "txq"))
2569 fprintf(stderr, "Unknown parameter\n");
2573 if (isrx && rx_queue_id_is_invalid(res->qid))
2575 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2578 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2580 "Invalid rx ring_size, must > rx_free_thresh: %d\n",
2586 port->nb_rx_desc[res->qid] = res->size;
2588 port->nb_tx_desc[res->qid] = res->size;
2590 cmd_reconfig_device_queue(res->portid, 0, 1);
2593 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2594 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2596 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2597 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2599 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2600 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2601 portid, RTE_UINT16);
2602 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2603 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2605 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2606 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2608 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2609 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2610 rsize, "ring_size");
2611 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2612 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2615 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2616 .f = cmd_config_rxtx_ring_size_parsed,
2618 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2620 (void *)&cmd_config_rxtx_ring_size_port,
2621 (void *)&cmd_config_rxtx_ring_size_config,
2622 (void *)&cmd_config_rxtx_ring_size_portid,
2623 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2624 (void *)&cmd_config_rxtx_ring_size_qid,
2625 (void *)&cmd_config_rxtx_ring_size_rsize,
2626 (void *)&cmd_config_rxtx_ring_size_size,
2631 /* *** configure port rxq/txq start/stop *** */
2632 struct cmd_config_rxtx_queue {
2633 cmdline_fixed_string_t port;
2635 cmdline_fixed_string_t rxtxq;
2637 cmdline_fixed_string_t opname;
2641 cmd_config_rxtx_queue_parsed(void *parsed_result,
2642 __rte_unused struct cmdline *cl,
2643 __rte_unused void *data)
2645 struct cmd_config_rxtx_queue *res = parsed_result;
2650 if (test_done == 0) {
2651 fprintf(stderr, "Please stop forwarding first\n");
2655 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2658 if (port_is_started(res->portid) != 1) {
2659 fprintf(stderr, "Please start port %u first\n", res->portid);
2663 if (!strcmp(res->rxtxq, "rxq"))
2665 else if (!strcmp(res->rxtxq, "txq"))
2668 fprintf(stderr, "Unknown parameter\n");
2672 if (isrx && rx_queue_id_is_invalid(res->qid))
2674 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2677 if (!strcmp(res->opname, "start"))
2679 else if (!strcmp(res->opname, "stop"))
2682 fprintf(stderr, "Unknown parameter\n");
2686 if (isstart && isrx)
2687 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2688 else if (!isstart && isrx)
2689 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2690 else if (isstart && !isrx)
2691 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2693 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2695 if (ret == -ENOTSUP)
2696 fprintf(stderr, "Function not supported in PMD driver\n");
2699 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2700 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2701 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2702 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2703 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2704 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2705 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2706 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2707 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2708 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2711 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2712 .f = cmd_config_rxtx_queue_parsed,
2714 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2716 (void *)&cmd_config_rxtx_queue_port,
2717 (void *)&cmd_config_rxtx_queue_portid,
2718 (void *)&cmd_config_rxtx_queue_rxtxq,
2719 (void *)&cmd_config_rxtx_queue_qid,
2720 (void *)&cmd_config_rxtx_queue_opname,
2725 /* *** configure port rxq/txq deferred start on/off *** */
2726 struct cmd_config_deferred_start_rxtx_queue {
2727 cmdline_fixed_string_t port;
2729 cmdline_fixed_string_t rxtxq;
2731 cmdline_fixed_string_t opname;
2732 cmdline_fixed_string_t state;
2736 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2737 __rte_unused struct cmdline *cl,
2738 __rte_unused void *data)
2740 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2741 struct rte_port *port;
2744 uint8_t needreconfig = 0;
2746 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2749 if (port_is_started(res->port_id) != 0) {
2750 fprintf(stderr, "Please stop port %u first\n", res->port_id);
2754 port = &ports[res->port_id];
2756 isrx = !strcmp(res->rxtxq, "rxq");
2758 if (isrx && rx_queue_id_is_invalid(res->qid))
2760 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2763 ison = !strcmp(res->state, "on");
2765 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2766 port->rx_conf[res->qid].rx_deferred_start = ison;
2768 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2769 port->tx_conf[res->qid].tx_deferred_start = ison;
2774 cmd_reconfig_device_queue(res->port_id, 0, 1);
2777 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2778 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2780 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2781 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2782 port_id, RTE_UINT16);
2783 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2784 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2786 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2787 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2789 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2790 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2791 opname, "deferred_start");
2792 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2793 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2796 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2797 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2799 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2801 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2802 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2803 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2804 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2805 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2806 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2811 /* *** configure port rxq/txq setup *** */
2812 struct cmd_setup_rxtx_queue {
2813 cmdline_fixed_string_t port;
2815 cmdline_fixed_string_t rxtxq;
2817 cmdline_fixed_string_t setup;
2820 /* Common CLI fields for queue setup */
2821 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2822 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2823 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2824 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2825 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2826 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2827 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2828 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2829 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2830 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2833 cmd_setup_rxtx_queue_parsed(
2834 void *parsed_result,
2835 __rte_unused struct cmdline *cl,
2836 __rte_unused void *data)
2838 struct cmd_setup_rxtx_queue *res = parsed_result;
2839 struct rte_port *port;
2840 struct rte_mempool *mp;
2841 unsigned int socket_id;
2845 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2848 if (res->portid == (portid_t)RTE_PORT_ALL) {
2849 fprintf(stderr, "Invalid port id\n");
2853 if (!strcmp(res->rxtxq, "rxq"))
2855 else if (!strcmp(res->rxtxq, "txq"))
2858 fprintf(stderr, "Unknown parameter\n");
2862 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2863 fprintf(stderr, "Invalid rx queue\n");
2865 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2866 fprintf(stderr, "Invalid tx queue\n");
2870 port = &ports[res->portid];
2872 socket_id = rxring_numa[res->portid];
2873 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2874 socket_id = port->socket_id;
2876 mp = mbuf_pool_find(socket_id, 0);
2879 "Failed to setup RX queue: No mempool allocation on the socket %d\n",
2880 rxring_numa[res->portid]);
2883 ret = rx_queue_setup(res->portid,
2885 port->nb_rx_desc[res->qid],
2887 &port->rx_conf[res->qid],
2890 fprintf(stderr, "Failed to setup RX queue\n");
2892 socket_id = txring_numa[res->portid];
2893 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2894 socket_id = port->socket_id;
2896 if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
2898 "Failed to setup TX queue: not enough descriptors\n");
2901 ret = rte_eth_tx_queue_setup(res->portid,
2903 port->nb_tx_desc[res->qid],
2905 &port->tx_conf[res->qid]);
2907 fprintf(stderr, "Failed to setup TX queue\n");
2911 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2912 .f = cmd_setup_rxtx_queue_parsed,
2914 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2916 (void *)&cmd_setup_rxtx_queue_port,
2917 (void *)&cmd_setup_rxtx_queue_portid,
2918 (void *)&cmd_setup_rxtx_queue_rxtxq,
2919 (void *)&cmd_setup_rxtx_queue_qid,
2920 (void *)&cmd_setup_rxtx_queue_setup,
2926 /* *** Configure RSS RETA *** */
2927 struct cmd_config_rss_reta {
2928 cmdline_fixed_string_t port;
2929 cmdline_fixed_string_t keyword;
2931 cmdline_fixed_string_t name;
2932 cmdline_fixed_string_t list_name;
2933 cmdline_fixed_string_t list_of_items;
2937 parse_reta_config(const char *str,
2938 struct rte_eth_rss_reta_entry64 *reta_conf,
2939 uint16_t nb_entries)
2943 uint16_t hash_index, idx, shift;
2946 const char *p, *p0 = str;
2953 unsigned long int_fld[_NUM_FLD];
2954 char *str_fld[_NUM_FLD];
2956 while ((p = strchr(p0,'(')) != NULL) {
2958 if((p0 = strchr(p,')')) == NULL)
2962 if(size >= sizeof(s))
2965 snprintf(s, sizeof(s), "%.*s", size, p);
2966 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2968 for (i = 0; i < _NUM_FLD; i++) {
2970 int_fld[i] = strtoul(str_fld[i], &end, 0);
2971 if (errno != 0 || end == str_fld[i] ||
2976 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2977 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2979 if (hash_index >= nb_entries) {
2980 fprintf(stderr, "Invalid RETA hash index=%d\n",
2985 idx = hash_index / RTE_ETH_RETA_GROUP_SIZE;
2986 shift = hash_index % RTE_ETH_RETA_GROUP_SIZE;
2987 reta_conf[idx].mask |= (1ULL << shift);
2988 reta_conf[idx].reta[shift] = nb_queue;
2995 cmd_set_rss_reta_parsed(void *parsed_result,
2996 __rte_unused struct cmdline *cl,
2997 __rte_unused void *data)
3000 struct rte_eth_dev_info dev_info;
3001 struct rte_eth_rss_reta_entry64 reta_conf[8];
3002 struct cmd_config_rss_reta *res = parsed_result;
3004 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3008 if (dev_info.reta_size == 0) {
3010 "Redirection table size is 0 which is invalid for RSS\n");
3013 printf("The reta size of port %d is %u\n",
3014 res->port_id, dev_info.reta_size);
3015 if (dev_info.reta_size > RTE_ETH_RSS_RETA_SIZE_512) {
3017 "Currently do not support more than %u entries of redirection table\n",
3018 RTE_ETH_RSS_RETA_SIZE_512);
3022 memset(reta_conf, 0, sizeof(reta_conf));
3023 if (!strcmp(res->list_name, "reta")) {
3024 if (parse_reta_config(res->list_of_items, reta_conf,
3025 dev_info.reta_size)) {
3027 "Invalid RSS Redirection Table config entered\n");
3030 ret = rte_eth_dev_rss_reta_update(res->port_id,
3031 reta_conf, dev_info.reta_size);
3034 "Bad redirection table parameter, return code = %d\n",
3039 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3040 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3041 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3042 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3043 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3044 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3045 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3046 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3047 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3048 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3049 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3050 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3052 cmdline_parse_inst_t cmd_config_rss_reta = {
3053 .f = cmd_set_rss_reta_parsed,
3055 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3057 (void *)&cmd_config_rss_reta_port,
3058 (void *)&cmd_config_rss_reta_keyword,
3059 (void *)&cmd_config_rss_reta_port_id,
3060 (void *)&cmd_config_rss_reta_name,
3061 (void *)&cmd_config_rss_reta_list_name,
3062 (void *)&cmd_config_rss_reta_list_of_items,
3067 /* *** SHOW PORT RETA INFO *** */
3068 struct cmd_showport_reta {
3069 cmdline_fixed_string_t show;
3070 cmdline_fixed_string_t port;
3072 cmdline_fixed_string_t rss;
3073 cmdline_fixed_string_t reta;
3075 cmdline_fixed_string_t list_of_items;
3079 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3080 uint16_t nb_entries,
3084 const char *p, *p0 = str;
3089 uint16_t num = (nb_entries + RTE_ETH_RETA_GROUP_SIZE - 1) /
3090 RTE_ETH_RETA_GROUP_SIZE;
3093 p = strchr(p0, '(');
3097 p0 = strchr(p, ')');
3101 if (size >= sizeof(s)) {
3103 "The string size exceeds the internal buffer size\n");
3106 snprintf(s, sizeof(s), "%.*s", size, p);
3107 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3108 if (ret <= 0 || ret != num) {
3110 "The bits of masks do not match the number of reta entries: %u\n",
3114 for (i = 0; i < ret; i++)
3115 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3121 cmd_showport_reta_parsed(void *parsed_result,
3122 __rte_unused struct cmdline *cl,
3123 __rte_unused void *data)
3125 struct cmd_showport_reta *res = parsed_result;
3126 struct rte_eth_rss_reta_entry64 reta_conf[8];
3127 struct rte_eth_dev_info dev_info;
3128 uint16_t max_reta_size;
3131 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3135 max_reta_size = RTE_MIN(dev_info.reta_size, RTE_ETH_RSS_RETA_SIZE_512);
3136 if (res->size == 0 || res->size > max_reta_size) {
3137 fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n",
3138 res->size, max_reta_size);
3142 memset(reta_conf, 0, sizeof(reta_conf));
3143 if (showport_parse_reta_config(reta_conf, res->size,
3144 res->list_of_items) < 0) {
3145 fprintf(stderr, "Invalid string: %s for reta masks\n",
3146 res->list_of_items);
3149 port_rss_reta_info(res->port_id, reta_conf, res->size);
3152 cmdline_parse_token_string_t cmd_showport_reta_show =
3153 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3154 cmdline_parse_token_string_t cmd_showport_reta_port =
3155 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3156 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3157 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3158 cmdline_parse_token_string_t cmd_showport_reta_rss =
3159 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3160 cmdline_parse_token_string_t cmd_showport_reta_reta =
3161 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3162 cmdline_parse_token_num_t cmd_showport_reta_size =
3163 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3164 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3165 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3166 list_of_items, NULL);
3168 cmdline_parse_inst_t cmd_showport_reta = {
3169 .f = cmd_showport_reta_parsed,
3171 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3173 (void *)&cmd_showport_reta_show,
3174 (void *)&cmd_showport_reta_port,
3175 (void *)&cmd_showport_reta_port_id,
3176 (void *)&cmd_showport_reta_rss,
3177 (void *)&cmd_showport_reta_reta,
3178 (void *)&cmd_showport_reta_size,
3179 (void *)&cmd_showport_reta_list_of_items,
3184 /* *** Show RSS hash configuration *** */
3185 struct cmd_showport_rss_hash {
3186 cmdline_fixed_string_t show;
3187 cmdline_fixed_string_t port;
3189 cmdline_fixed_string_t rss_hash;
3190 cmdline_fixed_string_t rss_type;
3191 cmdline_fixed_string_t key; /* optional argument */
3194 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3195 __rte_unused struct cmdline *cl,
3198 struct cmd_showport_rss_hash *res = parsed_result;
3200 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3203 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3204 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3205 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3206 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3207 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3208 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3210 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3211 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3213 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3214 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3216 cmdline_parse_inst_t cmd_showport_rss_hash = {
3217 .f = cmd_showport_rss_hash_parsed,
3219 .help_str = "show port <port_id> rss-hash",
3221 (void *)&cmd_showport_rss_hash_show,
3222 (void *)&cmd_showport_rss_hash_port,
3223 (void *)&cmd_showport_rss_hash_port_id,
3224 (void *)&cmd_showport_rss_hash_rss_hash,
3229 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3230 .f = cmd_showport_rss_hash_parsed,
3232 .help_str = "show port <port_id> rss-hash key",
3234 (void *)&cmd_showport_rss_hash_show,
3235 (void *)&cmd_showport_rss_hash_port,
3236 (void *)&cmd_showport_rss_hash_port_id,
3237 (void *)&cmd_showport_rss_hash_rss_hash,
3238 (void *)&cmd_showport_rss_hash_rss_key,
3243 /* *** Configure DCB *** */
3244 struct cmd_config_dcb {
3245 cmdline_fixed_string_t port;
3246 cmdline_fixed_string_t config;
3248 cmdline_fixed_string_t dcb;
3249 cmdline_fixed_string_t vt;
3250 cmdline_fixed_string_t vt_en;
3252 cmdline_fixed_string_t pfc;
3253 cmdline_fixed_string_t pfc_en;
3257 cmd_config_dcb_parsed(void *parsed_result,
3258 __rte_unused struct cmdline *cl,
3259 __rte_unused void *data)
3261 struct cmd_config_dcb *res = parsed_result;
3262 struct rte_eth_dcb_info dcb_info;
3263 portid_t port_id = res->port_id;
3264 struct rte_port *port;
3268 port = &ports[port_id];
3269 /** Check if the port is not started **/
3270 if (port->port_status != RTE_PORT_STOPPED) {
3271 fprintf(stderr, "Please stop port %d first\n", port_id);
3275 if ((res->num_tcs != RTE_ETH_4_TCS) && (res->num_tcs != RTE_ETH_8_TCS)) {
3277 "The invalid number of traffic class, only 4 or 8 allowed.\n");
3281 if (nb_fwd_lcores < res->num_tcs) {
3283 "nb_cores shouldn't be less than number of TCs.\n");
3287 /* Check whether the port supports the report of DCB info. */
3288 ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3289 if (ret == -ENOTSUP) {
3290 fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n");
3294 if (!strncmp(res->pfc_en, "on", 2))
3299 /* DCB in VT mode */
3300 if (!strncmp(res->vt_en, "on", 2))
3301 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3302 (enum rte_eth_nb_tcs)res->num_tcs,
3305 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3306 (enum rte_eth_nb_tcs)res->num_tcs,
3309 fprintf(stderr, "Cannot initialize network ports.\n");
3315 cmd_reconfig_device_queue(port_id, 1, 1);
3318 cmdline_parse_token_string_t cmd_config_dcb_port =
3319 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3320 cmdline_parse_token_string_t cmd_config_dcb_config =
3321 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3322 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3323 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3324 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3325 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3326 cmdline_parse_token_string_t cmd_config_dcb_vt =
3327 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3328 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3329 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3330 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3331 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3332 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3333 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3334 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3335 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3337 cmdline_parse_inst_t cmd_config_dcb = {
3338 .f = cmd_config_dcb_parsed,
3340 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3342 (void *)&cmd_config_dcb_port,
3343 (void *)&cmd_config_dcb_config,
3344 (void *)&cmd_config_dcb_port_id,
3345 (void *)&cmd_config_dcb_dcb,
3346 (void *)&cmd_config_dcb_vt,
3347 (void *)&cmd_config_dcb_vt_en,
3348 (void *)&cmd_config_dcb_num_tcs,
3349 (void *)&cmd_config_dcb_pfc,
3350 (void *)&cmd_config_dcb_pfc_en,
3355 /* *** configure number of packets per burst *** */
3356 struct cmd_config_burst {
3357 cmdline_fixed_string_t port;
3358 cmdline_fixed_string_t keyword;
3359 cmdline_fixed_string_t all;
3360 cmdline_fixed_string_t name;
3365 cmd_config_burst_parsed(void *parsed_result,
3366 __rte_unused struct cmdline *cl,
3367 __rte_unused void *data)
3369 struct cmd_config_burst *res = parsed_result;
3370 struct rte_eth_dev_info dev_info;
3371 uint16_t rec_nb_pkts;
3374 if (!all_ports_stopped()) {
3375 fprintf(stderr, "Please stop all ports first\n");
3379 if (!strcmp(res->name, "burst")) {
3380 if (res->value == 0) {
3381 /* If user gives a value of zero, query the PMD for
3382 * its recommended Rx burst size. Testpmd uses a single
3383 * size for all ports, so assume all ports are the same
3384 * NIC model and use the values from Port 0.
3386 ret = eth_dev_info_get_print_err(0, &dev_info);
3390 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3392 if (rec_nb_pkts == 0) {
3393 printf("PMD does not recommend a burst size.\n"
3394 "User provided value must be between"
3395 " 1 and %d\n", MAX_PKT_BURST);
3397 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3398 printf("PMD recommended burst size of %d"
3399 " exceeds maximum value of %d\n",
3400 rec_nb_pkts, MAX_PKT_BURST);
3403 printf("Using PMD-provided burst value of %d\n",
3405 nb_pkt_per_burst = rec_nb_pkts;
3406 } else if (res->value > MAX_PKT_BURST) {
3407 fprintf(stderr, "burst must be >= 1 && <= %d\n",
3411 nb_pkt_per_burst = res->value;
3413 fprintf(stderr, "Unknown parameter\n");
3419 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3422 cmdline_parse_token_string_t cmd_config_burst_port =
3423 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3424 cmdline_parse_token_string_t cmd_config_burst_keyword =
3425 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3426 cmdline_parse_token_string_t cmd_config_burst_all =
3427 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3428 cmdline_parse_token_string_t cmd_config_burst_name =
3429 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3430 cmdline_parse_token_num_t cmd_config_burst_value =
3431 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3433 cmdline_parse_inst_t cmd_config_burst = {
3434 .f = cmd_config_burst_parsed,
3436 .help_str = "port config all burst <value>",
3438 (void *)&cmd_config_burst_port,
3439 (void *)&cmd_config_burst_keyword,
3440 (void *)&cmd_config_burst_all,
3441 (void *)&cmd_config_burst_name,
3442 (void *)&cmd_config_burst_value,
3447 /* *** configure rx/tx queues *** */
3448 struct cmd_config_thresh {
3449 cmdline_fixed_string_t port;
3450 cmdline_fixed_string_t keyword;
3451 cmdline_fixed_string_t all;
3452 cmdline_fixed_string_t name;
3457 cmd_config_thresh_parsed(void *parsed_result,
3458 __rte_unused struct cmdline *cl,
3459 __rte_unused void *data)
3461 struct cmd_config_thresh *res = parsed_result;
3463 if (!all_ports_stopped()) {
3464 fprintf(stderr, "Please stop all ports first\n");
3468 if (!strcmp(res->name, "txpt"))
3469 tx_pthresh = res->value;
3470 else if(!strcmp(res->name, "txht"))
3471 tx_hthresh = res->value;
3472 else if(!strcmp(res->name, "txwt"))
3473 tx_wthresh = res->value;
3474 else if(!strcmp(res->name, "rxpt"))
3475 rx_pthresh = res->value;
3476 else if(!strcmp(res->name, "rxht"))
3477 rx_hthresh = res->value;
3478 else if(!strcmp(res->name, "rxwt"))
3479 rx_wthresh = res->value;
3481 fprintf(stderr, "Unknown parameter\n");
3487 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3490 cmdline_parse_token_string_t cmd_config_thresh_port =
3491 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3492 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3493 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3494 cmdline_parse_token_string_t cmd_config_thresh_all =
3495 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3496 cmdline_parse_token_string_t cmd_config_thresh_name =
3497 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3498 "txpt#txht#txwt#rxpt#rxht#rxwt");
3499 cmdline_parse_token_num_t cmd_config_thresh_value =
3500 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3502 cmdline_parse_inst_t cmd_config_thresh = {
3503 .f = cmd_config_thresh_parsed,
3505 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3507 (void *)&cmd_config_thresh_port,
3508 (void *)&cmd_config_thresh_keyword,
3509 (void *)&cmd_config_thresh_all,
3510 (void *)&cmd_config_thresh_name,
3511 (void *)&cmd_config_thresh_value,
3516 /* *** configure free/rs threshold *** */
3517 struct cmd_config_threshold {
3518 cmdline_fixed_string_t port;
3519 cmdline_fixed_string_t keyword;
3520 cmdline_fixed_string_t all;
3521 cmdline_fixed_string_t name;
3526 cmd_config_threshold_parsed(void *parsed_result,
3527 __rte_unused struct cmdline *cl,
3528 __rte_unused void *data)
3530 struct cmd_config_threshold *res = parsed_result;
3532 if (!all_ports_stopped()) {
3533 fprintf(stderr, "Please stop all ports first\n");
3537 if (!strcmp(res->name, "txfreet"))
3538 tx_free_thresh = res->value;
3539 else if (!strcmp(res->name, "txrst"))
3540 tx_rs_thresh = res->value;
3541 else if (!strcmp(res->name, "rxfreet"))
3542 rx_free_thresh = res->value;
3544 fprintf(stderr, "Unknown parameter\n");
3550 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3553 cmdline_parse_token_string_t cmd_config_threshold_port =
3554 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3555 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3556 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3558 cmdline_parse_token_string_t cmd_config_threshold_all =
3559 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3560 cmdline_parse_token_string_t cmd_config_threshold_name =
3561 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3562 "txfreet#txrst#rxfreet");
3563 cmdline_parse_token_num_t cmd_config_threshold_value =
3564 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3566 cmdline_parse_inst_t cmd_config_threshold = {
3567 .f = cmd_config_threshold_parsed,
3569 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3571 (void *)&cmd_config_threshold_port,
3572 (void *)&cmd_config_threshold_keyword,
3573 (void *)&cmd_config_threshold_all,
3574 (void *)&cmd_config_threshold_name,
3575 (void *)&cmd_config_threshold_value,
3581 struct cmd_stop_result {
3582 cmdline_fixed_string_t stop;
3585 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3586 __rte_unused struct cmdline *cl,
3587 __rte_unused void *data)
3589 stop_packet_forwarding();
3592 cmdline_parse_token_string_t cmd_stop_stop =
3593 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3595 cmdline_parse_inst_t cmd_stop = {
3596 .f = cmd_stop_parsed,
3598 .help_str = "stop: Stop packet forwarding",
3600 (void *)&cmd_stop_stop,
3605 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3608 parse_item_list(const char *str, const char *item_name, unsigned int max_items,
3609 unsigned int *parsed_items, int check_unique_values)
3611 unsigned int nb_item;
3619 * First parse all items in the list and store their value.
3624 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3626 if ((c >= '0') && (c <= '9')) {
3627 value = (unsigned int) (value * 10 + (c - '0'));
3632 fprintf(stderr, "character %c is not a decimal digit\n", c);
3636 fprintf(stderr, "No valid value before comma\n");
3639 if (nb_item < max_items) {
3640 parsed_items[nb_item] = value;
3646 if (nb_item >= max_items) {
3647 fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
3648 item_name, nb_item + 1, max_items);
3651 parsed_items[nb_item++] = value;
3652 if (! check_unique_values)
3656 * Then, check that all values in the list are differents.
3657 * No optimization here...
3659 for (i = 0; i < nb_item; i++) {
3660 for (j = i + 1; j < nb_item; j++) {
3661 if (parsed_items[j] == parsed_items[i]) {
3663 "duplicated %s %u at index %u and %u\n",
3664 item_name, parsed_items[i], i, j);
3672 struct cmd_set_list_result {
3673 cmdline_fixed_string_t cmd_keyword;
3674 cmdline_fixed_string_t list_name;
3675 cmdline_fixed_string_t list_of_items;
3678 static void cmd_set_list_parsed(void *parsed_result,
3679 __rte_unused struct cmdline *cl,
3680 __rte_unused void *data)
3682 struct cmd_set_list_result *res;
3684 unsigned int lcorelist[RTE_MAX_LCORE];
3685 unsigned int portlist[RTE_MAX_ETHPORTS];
3687 unsigned int nb_item;
3689 if (test_done == 0) {
3690 fprintf(stderr, "Please stop forwarding first\n");
3694 res = parsed_result;
3695 if (!strcmp(res->list_name, "corelist")) {
3696 nb_item = parse_item_list(res->list_of_items, "core",
3698 parsed_items.lcorelist, 1);
3700 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3705 if (!strcmp(res->list_name, "portlist")) {
3706 nb_item = parse_item_list(res->list_of_items, "port",
3708 parsed_items.portlist, 1);
3710 set_fwd_ports_list(parsed_items.portlist, nb_item);
3716 cmdline_parse_token_string_t cmd_set_list_keyword =
3717 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3719 cmdline_parse_token_string_t cmd_set_list_name =
3720 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3721 "corelist#portlist");
3722 cmdline_parse_token_string_t cmd_set_list_of_items =
3723 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3726 cmdline_parse_inst_t cmd_set_fwd_list = {
3727 .f = cmd_set_list_parsed,
3729 .help_str = "set corelist|portlist <list0[,list1]*>",
3731 (void *)&cmd_set_list_keyword,
3732 (void *)&cmd_set_list_name,
3733 (void *)&cmd_set_list_of_items,
3738 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3740 struct cmd_setmask_result {
3741 cmdline_fixed_string_t set;
3742 cmdline_fixed_string_t mask;
3746 static void cmd_set_mask_parsed(void *parsed_result,
3747 __rte_unused struct cmdline *cl,
3748 __rte_unused void *data)
3750 struct cmd_setmask_result *res = parsed_result;
3752 if (test_done == 0) {
3753 fprintf(stderr, "Please stop forwarding first\n");
3756 if (!strcmp(res->mask, "coremask")) {
3757 set_fwd_lcores_mask(res->hexavalue);
3759 } else if (!strcmp(res->mask, "portmask")) {
3760 set_fwd_ports_mask(res->hexavalue);
3765 cmdline_parse_token_string_t cmd_setmask_set =
3766 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3767 cmdline_parse_token_string_t cmd_setmask_mask =
3768 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3769 "coremask#portmask");
3770 cmdline_parse_token_num_t cmd_setmask_value =
3771 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3773 cmdline_parse_inst_t cmd_set_fwd_mask = {
3774 .f = cmd_set_mask_parsed,
3776 .help_str = "set coremask|portmask <hexadecimal value>",
3778 (void *)&cmd_setmask_set,
3779 (void *)&cmd_setmask_mask,
3780 (void *)&cmd_setmask_value,
3786 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3788 struct cmd_set_result {
3789 cmdline_fixed_string_t set;
3790 cmdline_fixed_string_t what;
3794 static void cmd_set_parsed(void *parsed_result,
3795 __rte_unused struct cmdline *cl,
3796 __rte_unused void *data)
3798 struct cmd_set_result *res = parsed_result;
3799 if (!strcmp(res->what, "nbport")) {
3800 set_fwd_ports_number(res->value);
3802 } else if (!strcmp(res->what, "nbcore")) {
3803 set_fwd_lcores_number(res->value);
3805 } else if (!strcmp(res->what, "burst"))
3806 set_nb_pkt_per_burst(res->value);
3807 else if (!strcmp(res->what, "verbose"))
3808 set_verbose_level(res->value);
3811 cmdline_parse_token_string_t cmd_set_set =
3812 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3813 cmdline_parse_token_string_t cmd_set_what =
3814 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3815 "nbport#nbcore#burst#verbose");
3816 cmdline_parse_token_num_t cmd_set_value =
3817 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3819 cmdline_parse_inst_t cmd_set_numbers = {
3820 .f = cmd_set_parsed,
3822 .help_str = "set nbport|nbcore|burst|verbose <value>",
3824 (void *)&cmd_set_set,
3825 (void *)&cmd_set_what,
3826 (void *)&cmd_set_value,
3831 /* *** SET LOG LEVEL CONFIGURATION *** */
3833 struct cmd_set_log_result {
3834 cmdline_fixed_string_t set;
3835 cmdline_fixed_string_t log;
3836 cmdline_fixed_string_t type;
3841 cmd_set_log_parsed(void *parsed_result,
3842 __rte_unused struct cmdline *cl,
3843 __rte_unused void *data)
3845 struct cmd_set_log_result *res;
3848 res = parsed_result;
3849 if (!strcmp(res->type, "global"))
3850 rte_log_set_global_level(res->level);
3852 ret = rte_log_set_level_regexp(res->type, res->level);
3854 fprintf(stderr, "Unable to set log level\n");
3858 cmdline_parse_token_string_t cmd_set_log_set =
3859 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3860 cmdline_parse_token_string_t cmd_set_log_log =
3861 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3862 cmdline_parse_token_string_t cmd_set_log_type =
3863 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3864 cmdline_parse_token_num_t cmd_set_log_level =
3865 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3867 cmdline_parse_inst_t cmd_set_log = {
3868 .f = cmd_set_log_parsed,
3870 .help_str = "set log global|<type> <level>",
3872 (void *)&cmd_set_log_set,
3873 (void *)&cmd_set_log_log,
3874 (void *)&cmd_set_log_type,
3875 (void *)&cmd_set_log_level,
3880 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3882 struct cmd_set_rxoffs_result {
3883 cmdline_fixed_string_t cmd_keyword;
3884 cmdline_fixed_string_t rxoffs;
3885 cmdline_fixed_string_t seg_offsets;
3889 cmd_set_rxoffs_parsed(void *parsed_result,
3890 __rte_unused struct cmdline *cl,
3891 __rte_unused void *data)
3893 struct cmd_set_rxoffs_result *res;
3894 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3895 unsigned int nb_segs;
3897 res = parsed_result;
3898 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3899 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3901 set_rx_pkt_offsets(seg_offsets, nb_segs);
3902 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3905 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3906 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3907 cmd_keyword, "set");
3908 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3909 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3911 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3912 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3915 cmdline_parse_inst_t cmd_set_rxoffs = {
3916 .f = cmd_set_rxoffs_parsed,
3918 .help_str = "set rxoffs <len0[,len1]*>",
3920 (void *)&cmd_set_rxoffs_keyword,
3921 (void *)&cmd_set_rxoffs_name,
3922 (void *)&cmd_set_rxoffs_offsets,
3927 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3929 struct cmd_set_rxpkts_result {
3930 cmdline_fixed_string_t cmd_keyword;
3931 cmdline_fixed_string_t rxpkts;
3932 cmdline_fixed_string_t seg_lengths;
3936 cmd_set_rxpkts_parsed(void *parsed_result,
3937 __rte_unused struct cmdline *cl,
3938 __rte_unused void *data)
3940 struct cmd_set_rxpkts_result *res;
3941 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3942 unsigned int nb_segs;
3944 res = parsed_result;
3945 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3946 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3948 set_rx_pkt_segments(seg_lengths, nb_segs);
3949 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3952 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3953 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3954 cmd_keyword, "set");
3955 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3956 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3958 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3959 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3962 cmdline_parse_inst_t cmd_set_rxpkts = {
3963 .f = cmd_set_rxpkts_parsed,
3965 .help_str = "set rxpkts <len0[,len1]*>",
3967 (void *)&cmd_set_rxpkts_keyword,
3968 (void *)&cmd_set_rxpkts_name,
3969 (void *)&cmd_set_rxpkts_lengths,
3974 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3976 struct cmd_set_txpkts_result {
3977 cmdline_fixed_string_t cmd_keyword;
3978 cmdline_fixed_string_t txpkts;
3979 cmdline_fixed_string_t seg_lengths;
3983 cmd_set_txpkts_parsed(void *parsed_result,
3984 __rte_unused struct cmdline *cl,
3985 __rte_unused void *data)
3987 struct cmd_set_txpkts_result *res;
3988 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3989 unsigned int nb_segs;
3991 res = parsed_result;
3992 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3993 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3995 set_tx_pkt_segments(seg_lengths, nb_segs);
3998 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3999 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4000 cmd_keyword, "set");
4001 cmdline_parse_token_string_t cmd_set_txpkts_name =
4002 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4004 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4005 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4008 cmdline_parse_inst_t cmd_set_txpkts = {
4009 .f = cmd_set_txpkts_parsed,
4011 .help_str = "set txpkts <len0[,len1]*>",
4013 (void *)&cmd_set_txpkts_keyword,
4014 (void *)&cmd_set_txpkts_name,
4015 (void *)&cmd_set_txpkts_lengths,
4020 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4022 struct cmd_set_txsplit_result {
4023 cmdline_fixed_string_t cmd_keyword;
4024 cmdline_fixed_string_t txsplit;
4025 cmdline_fixed_string_t mode;
4029 cmd_set_txsplit_parsed(void *parsed_result,
4030 __rte_unused struct cmdline *cl,
4031 __rte_unused void *data)
4033 struct cmd_set_txsplit_result *res;
4035 res = parsed_result;
4036 set_tx_pkt_split(res->mode);
4039 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4040 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4041 cmd_keyword, "set");
4042 cmdline_parse_token_string_t cmd_set_txsplit_name =
4043 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4044 txsplit, "txsplit");
4045 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4046 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4049 cmdline_parse_inst_t cmd_set_txsplit = {
4050 .f = cmd_set_txsplit_parsed,
4052 .help_str = "set txsplit on|off|rand",
4054 (void *)&cmd_set_txsplit_keyword,
4055 (void *)&cmd_set_txsplit_name,
4056 (void *)&cmd_set_txsplit_mode,
4061 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4063 struct cmd_set_txtimes_result {
4064 cmdline_fixed_string_t cmd_keyword;
4065 cmdline_fixed_string_t txtimes;
4066 cmdline_fixed_string_t tx_times;
4070 cmd_set_txtimes_parsed(void *parsed_result,
4071 __rte_unused struct cmdline *cl,
4072 __rte_unused void *data)
4074 struct cmd_set_txtimes_result *res;
4075 unsigned int tx_times[2] = {0, 0};
4076 unsigned int n_times;
4078 res = parsed_result;
4079 n_times = parse_item_list(res->tx_times, "tx times",
4082 set_tx_pkt_times(tx_times);
4085 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4086 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4087 cmd_keyword, "set");
4088 cmdline_parse_token_string_t cmd_set_txtimes_name =
4089 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4090 txtimes, "txtimes");
4091 cmdline_parse_token_string_t cmd_set_txtimes_value =
4092 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4095 cmdline_parse_inst_t cmd_set_txtimes = {
4096 .f = cmd_set_txtimes_parsed,
4098 .help_str = "set txtimes <inter_burst>,<intra_burst>",
4100 (void *)&cmd_set_txtimes_keyword,
4101 (void *)&cmd_set_txtimes_name,
4102 (void *)&cmd_set_txtimes_value,
4107 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4108 struct cmd_rx_vlan_filter_all_result {
4109 cmdline_fixed_string_t rx_vlan;
4110 cmdline_fixed_string_t what;
4111 cmdline_fixed_string_t all;
4116 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4117 __rte_unused struct cmdline *cl,
4118 __rte_unused void *data)
4120 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4122 if (!strcmp(res->what, "add"))
4123 rx_vlan_all_filter_set(res->port_id, 1);
4125 rx_vlan_all_filter_set(res->port_id, 0);
4128 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4129 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4130 rx_vlan, "rx_vlan");
4131 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4132 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4134 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4135 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4137 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4138 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4139 port_id, RTE_UINT16);
4141 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4142 .f = cmd_rx_vlan_filter_all_parsed,
4144 .help_str = "rx_vlan add|rm all <port_id>: "
4145 "Add/Remove all identifiers to/from the set of VLAN "
4146 "identifiers filtered by a port",
4148 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4149 (void *)&cmd_rx_vlan_filter_all_what,
4150 (void *)&cmd_rx_vlan_filter_all_all,
4151 (void *)&cmd_rx_vlan_filter_all_portid,
4156 /* *** VLAN OFFLOAD SET ON A PORT *** */
4157 struct cmd_vlan_offload_result {
4158 cmdline_fixed_string_t vlan;
4159 cmdline_fixed_string_t set;
4160 cmdline_fixed_string_t vlan_type;
4161 cmdline_fixed_string_t what;
4162 cmdline_fixed_string_t on;
4163 cmdline_fixed_string_t port_id;
4167 cmd_vlan_offload_parsed(void *parsed_result,
4168 __rte_unused struct cmdline *cl,
4169 __rte_unused void *data)
4172 struct cmd_vlan_offload_result *res = parsed_result;
4175 portid_t port_id = 0;
4179 len = strnlen(str, STR_TOKEN_SIZE);
4181 /* Get port_id first */
4189 tmp = strtoul(str, NULL, 0);
4190 /* If port_id greater that what portid_t can represent, return */
4191 if(tmp >= RTE_MAX_ETHPORTS)
4193 port_id = (portid_t)tmp;
4195 if (!strcmp(res->on, "on"))
4200 if (!strcmp(res->what, "strip"))
4201 rx_vlan_strip_set(port_id, on);
4202 else if(!strcmp(res->what, "stripq")){
4203 uint16_t queue_id = 0;
4205 /* No queue_id, return */
4207 fprintf(stderr, "must specify (port,queue_id)\n");
4210 tmp = strtoul(str + i + 1, NULL, 0);
4211 /* If queue_id greater that what 16-bits can represent, return */
4215 queue_id = (uint16_t)tmp;
4216 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4218 else if (!strcmp(res->what, "filter"))
4219 rx_vlan_filter_set(port_id, on);
4220 else if (!strcmp(res->what, "qinq_strip"))
4221 rx_vlan_qinq_strip_set(port_id, on);
4223 vlan_extend_set(port_id, on);
4228 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4229 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4231 cmdline_parse_token_string_t cmd_vlan_offload_set =
4232 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4234 cmdline_parse_token_string_t cmd_vlan_offload_what =
4235 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4236 what, "strip#filter#qinq_strip#extend#stripq");
4237 cmdline_parse_token_string_t cmd_vlan_offload_on =
4238 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4240 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4241 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4244 cmdline_parse_inst_t cmd_vlan_offload = {
4245 .f = cmd_vlan_offload_parsed,
4247 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4248 "<port_id[,queue_id]>: "
4249 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4251 (void *)&cmd_vlan_offload_vlan,
4252 (void *)&cmd_vlan_offload_set,
4253 (void *)&cmd_vlan_offload_what,
4254 (void *)&cmd_vlan_offload_on,
4255 (void *)&cmd_vlan_offload_portid,
4260 /* *** VLAN TPID SET ON A PORT *** */
4261 struct cmd_vlan_tpid_result {
4262 cmdline_fixed_string_t vlan;
4263 cmdline_fixed_string_t set;
4264 cmdline_fixed_string_t vlan_type;
4265 cmdline_fixed_string_t what;
4271 cmd_vlan_tpid_parsed(void *parsed_result,
4272 __rte_unused struct cmdline *cl,
4273 __rte_unused void *data)
4275 struct cmd_vlan_tpid_result *res = parsed_result;
4276 enum rte_vlan_type vlan_type;
4278 if (!strcmp(res->vlan_type, "inner"))
4279 vlan_type = RTE_ETH_VLAN_TYPE_INNER;
4280 else if (!strcmp(res->vlan_type, "outer"))
4281 vlan_type = RTE_ETH_VLAN_TYPE_OUTER;
4283 fprintf(stderr, "Unknown vlan type\n");
4286 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4289 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4290 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4292 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4293 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4295 cmdline_parse_token_string_t cmd_vlan_type =
4296 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4297 vlan_type, "inner#outer");
4298 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4299 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4301 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4302 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4304 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4305 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4306 port_id, RTE_UINT16);
4308 cmdline_parse_inst_t cmd_vlan_tpid = {
4309 .f = cmd_vlan_tpid_parsed,
4311 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4312 "Set the VLAN Ether type",
4314 (void *)&cmd_vlan_tpid_vlan,
4315 (void *)&cmd_vlan_tpid_set,
4316 (void *)&cmd_vlan_type,
4317 (void *)&cmd_vlan_tpid_what,
4318 (void *)&cmd_vlan_tpid_tpid,
4319 (void *)&cmd_vlan_tpid_portid,
4324 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4325 struct cmd_rx_vlan_filter_result {
4326 cmdline_fixed_string_t rx_vlan;
4327 cmdline_fixed_string_t what;
4333 cmd_rx_vlan_filter_parsed(void *parsed_result,
4334 __rte_unused struct cmdline *cl,
4335 __rte_unused void *data)
4337 struct cmd_rx_vlan_filter_result *res = parsed_result;
4339 if (!strcmp(res->what, "add"))
4340 rx_vft_set(res->port_id, res->vlan_id, 1);
4342 rx_vft_set(res->port_id, res->vlan_id, 0);
4345 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4346 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4347 rx_vlan, "rx_vlan");
4348 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4349 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4351 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4352 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4353 vlan_id, RTE_UINT16);
4354 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4355 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4356 port_id, RTE_UINT16);
4358 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4359 .f = cmd_rx_vlan_filter_parsed,
4361 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4362 "Add/Remove a VLAN identifier to/from the set of VLAN "
4363 "identifiers filtered by a port",
4365 (void *)&cmd_rx_vlan_filter_rx_vlan,
4366 (void *)&cmd_rx_vlan_filter_what,
4367 (void *)&cmd_rx_vlan_filter_vlanid,
4368 (void *)&cmd_rx_vlan_filter_portid,
4373 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4374 struct cmd_tx_vlan_set_result {
4375 cmdline_fixed_string_t tx_vlan;
4376 cmdline_fixed_string_t set;
4382 cmd_tx_vlan_set_parsed(void *parsed_result,
4383 __rte_unused struct cmdline *cl,
4384 __rte_unused void *data)
4386 struct cmd_tx_vlan_set_result *res = parsed_result;
4388 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4391 if (!port_is_stopped(res->port_id)) {
4392 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4396 tx_vlan_set(res->port_id, res->vlan_id);
4398 cmd_reconfig_device_queue(res->port_id, 1, 1);
4401 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4402 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4403 tx_vlan, "tx_vlan");
4404 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4405 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4407 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4408 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4409 port_id, RTE_UINT16);
4410 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4411 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4412 vlan_id, RTE_UINT16);
4414 cmdline_parse_inst_t cmd_tx_vlan_set = {
4415 .f = cmd_tx_vlan_set_parsed,
4417 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4418 "Enable hardware insertion of a single VLAN header "
4419 "with a given TAG Identifier in packets sent on a port",
4421 (void *)&cmd_tx_vlan_set_tx_vlan,
4422 (void *)&cmd_tx_vlan_set_set,
4423 (void *)&cmd_tx_vlan_set_portid,
4424 (void *)&cmd_tx_vlan_set_vlanid,
4429 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4430 struct cmd_tx_vlan_set_qinq_result {
4431 cmdline_fixed_string_t tx_vlan;
4432 cmdline_fixed_string_t set;
4435 uint16_t vlan_id_outer;
4439 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4440 __rte_unused struct cmdline *cl,
4441 __rte_unused void *data)
4443 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4445 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4448 if (!port_is_stopped(res->port_id)) {
4449 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4453 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4455 cmd_reconfig_device_queue(res->port_id, 1, 1);
4458 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4459 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4460 tx_vlan, "tx_vlan");
4461 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4462 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4464 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4465 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4466 port_id, RTE_UINT16);
4467 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4468 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4469 vlan_id, RTE_UINT16);
4470 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4471 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4472 vlan_id_outer, RTE_UINT16);
4474 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4475 .f = cmd_tx_vlan_set_qinq_parsed,
4477 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4478 "Enable hardware insertion of double VLAN header "
4479 "with given TAG Identifiers in packets sent on a port",
4481 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4482 (void *)&cmd_tx_vlan_set_qinq_set,
4483 (void *)&cmd_tx_vlan_set_qinq_portid,
4484 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4485 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4490 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4491 struct cmd_tx_vlan_set_pvid_result {
4492 cmdline_fixed_string_t tx_vlan;
4493 cmdline_fixed_string_t set;
4494 cmdline_fixed_string_t pvid;
4497 cmdline_fixed_string_t mode;
4501 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4502 __rte_unused struct cmdline *cl,
4503 __rte_unused void *data)
4505 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4507 if (strcmp(res->mode, "on") == 0)
4508 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4510 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4513 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4514 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4515 tx_vlan, "tx_vlan");
4516 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4517 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4519 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4520 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4522 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4523 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4524 port_id, RTE_UINT16);
4525 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4526 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4527 vlan_id, RTE_UINT16);
4528 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4529 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4532 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4533 .f = cmd_tx_vlan_set_pvid_parsed,
4535 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4537 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4538 (void *)&cmd_tx_vlan_set_pvid_set,
4539 (void *)&cmd_tx_vlan_set_pvid_pvid,
4540 (void *)&cmd_tx_vlan_set_pvid_port_id,
4541 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4542 (void *)&cmd_tx_vlan_set_pvid_mode,
4547 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4548 struct cmd_tx_vlan_reset_result {
4549 cmdline_fixed_string_t tx_vlan;
4550 cmdline_fixed_string_t reset;
4555 cmd_tx_vlan_reset_parsed(void *parsed_result,
4556 __rte_unused struct cmdline *cl,
4557 __rte_unused void *data)
4559 struct cmd_tx_vlan_reset_result *res = parsed_result;
4561 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4564 if (!port_is_stopped(res->port_id)) {
4565 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4569 tx_vlan_reset(res->port_id);
4571 cmd_reconfig_device_queue(res->port_id, 1, 1);
4574 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4575 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4576 tx_vlan, "tx_vlan");
4577 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4578 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4580 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4581 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4582 port_id, RTE_UINT16);
4584 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4585 .f = cmd_tx_vlan_reset_parsed,
4587 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4588 "VLAN header in packets sent on a port",
4590 (void *)&cmd_tx_vlan_reset_tx_vlan,
4591 (void *)&cmd_tx_vlan_reset_reset,
4592 (void *)&cmd_tx_vlan_reset_portid,
4598 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4599 struct cmd_csum_result {
4600 cmdline_fixed_string_t csum;
4601 cmdline_fixed_string_t mode;
4602 cmdline_fixed_string_t proto;
4603 cmdline_fixed_string_t hwsw;
4608 csum_show(int port_id)
4610 struct rte_eth_dev_info dev_info;
4611 uint64_t tx_offloads;
4614 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4615 printf("Parse tunnel is %s\n",
4616 (ports[port_id].parse_tunnel) ? "on" : "off");
4617 printf("IP checksum offload is %s\n",
4618 (tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4619 printf("UDP checksum offload is %s\n",
4620 (tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4621 printf("TCP checksum offload is %s\n",
4622 (tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4623 printf("SCTP checksum offload is %s\n",
4624 (tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4625 printf("Outer-Ip checksum offload is %s\n",
4626 (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4627 printf("Outer-Udp checksum offload is %s\n",
4628 (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4630 /* display warnings if configuration is not supported by the NIC */
4631 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4635 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) &&
4636 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4638 "Warning: hardware IP checksum enabled but not supported by port %d\n",
4641 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) &&
4642 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) == 0) {
4644 "Warning: hardware UDP checksum enabled but not supported by port %d\n",
4647 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) &&
4648 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) == 0) {
4650 "Warning: hardware TCP checksum enabled but not supported by port %d\n",
4653 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) &&
4654 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4656 "Warning: hardware SCTP checksum enabled but not supported by port %d\n",
4659 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4660 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4662 "Warning: hardware outer IP checksum enabled but not supported by port %d\n",
4665 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4666 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)
4669 "Warning: hardware outer UDP checksum enabled but not supported by port %d\n",
4675 cmd_config_queue_tx_offloads(struct rte_port *port)
4679 /* Apply queue tx offloads configuration */
4680 for (k = 0; k < port->dev_info.max_tx_queues; k++)
4681 port->tx_conf[k].offloads =
4682 port->dev_conf.txmode.offloads;
4686 cmd_csum_parsed(void *parsed_result,
4687 __rte_unused struct cmdline *cl,
4688 __rte_unused void *data)
4690 struct cmd_csum_result *res = parsed_result;
4692 uint64_t csum_offloads = 0;
4693 struct rte_eth_dev_info dev_info;
4696 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4697 fprintf(stderr, "invalid port %d\n", res->port_id);
4700 if (!port_is_stopped(res->port_id)) {
4701 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4705 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4709 if (!strcmp(res->mode, "set")) {
4711 if (!strcmp(res->hwsw, "hw"))
4714 if (!strcmp(res->proto, "ip")) {
4715 if (hw == 0 || (dev_info.tx_offload_capa &
4716 RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)) {
4717 csum_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
4720 "IP checksum offload is not supported by port %u\n",
4723 } else if (!strcmp(res->proto, "udp")) {
4724 if (hw == 0 || (dev_info.tx_offload_capa &
4725 RTE_ETH_TX_OFFLOAD_UDP_CKSUM)) {
4726 csum_offloads |= RTE_ETH_TX_OFFLOAD_UDP_CKSUM;
4729 "UDP checksum offload is not supported by port %u\n",
4732 } else if (!strcmp(res->proto, "tcp")) {
4733 if (hw == 0 || (dev_info.tx_offload_capa &
4734 RTE_ETH_TX_OFFLOAD_TCP_CKSUM)) {
4735 csum_offloads |= RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
4738 "TCP checksum offload is not supported by port %u\n",
4741 } else if (!strcmp(res->proto, "sctp")) {
4742 if (hw == 0 || (dev_info.tx_offload_capa &
4743 RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) {
4744 csum_offloads |= RTE_ETH_TX_OFFLOAD_SCTP_CKSUM;
4747 "SCTP checksum offload is not supported by port %u\n",
4750 } else if (!strcmp(res->proto, "outer-ip")) {
4751 if (hw == 0 || (dev_info.tx_offload_capa &
4752 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4754 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4757 "Outer IP checksum offload is not supported by port %u\n",
4760 } else if (!strcmp(res->proto, "outer-udp")) {
4761 if (hw == 0 || (dev_info.tx_offload_capa &
4762 RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4764 RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM;
4767 "Outer UDP checksum offload is not supported by port %u\n",
4773 ports[res->port_id].dev_conf.txmode.offloads |=
4776 ports[res->port_id].dev_conf.txmode.offloads &=
4779 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4781 csum_show(res->port_id);
4783 cmd_reconfig_device_queue(res->port_id, 1, 1);
4786 cmdline_parse_token_string_t cmd_csum_csum =
4787 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4789 cmdline_parse_token_string_t cmd_csum_mode =
4790 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4792 cmdline_parse_token_string_t cmd_csum_proto =
4793 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4794 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4795 cmdline_parse_token_string_t cmd_csum_hwsw =
4796 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4798 cmdline_parse_token_num_t cmd_csum_portid =
4799 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4800 port_id, RTE_UINT16);
4802 cmdline_parse_inst_t cmd_csum_set = {
4803 .f = cmd_csum_parsed,
4805 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4806 "Enable/Disable hardware calculation of L3/L4 checksum when "
4807 "using csum forward engine",
4809 (void *)&cmd_csum_csum,
4810 (void *)&cmd_csum_mode,
4811 (void *)&cmd_csum_proto,
4812 (void *)&cmd_csum_hwsw,
4813 (void *)&cmd_csum_portid,
4818 cmdline_parse_token_string_t cmd_csum_mode_show =
4819 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4822 cmdline_parse_inst_t cmd_csum_show = {
4823 .f = cmd_csum_parsed,
4825 .help_str = "csum show <port_id>: Show checksum offload configuration",
4827 (void *)&cmd_csum_csum,
4828 (void *)&cmd_csum_mode_show,
4829 (void *)&cmd_csum_portid,
4834 /* Enable/disable tunnel parsing */
4835 struct cmd_csum_tunnel_result {
4836 cmdline_fixed_string_t csum;
4837 cmdline_fixed_string_t parse;
4838 cmdline_fixed_string_t onoff;
4843 cmd_csum_tunnel_parsed(void *parsed_result,
4844 __rte_unused struct cmdline *cl,
4845 __rte_unused void *data)
4847 struct cmd_csum_tunnel_result *res = parsed_result;
4849 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4852 if (!strcmp(res->onoff, "on"))
4853 ports[res->port_id].parse_tunnel = 1;
4855 ports[res->port_id].parse_tunnel = 0;
4857 csum_show(res->port_id);
4860 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4861 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4863 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4864 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4865 parse, "parse-tunnel");
4866 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4867 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4869 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4870 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4871 port_id, RTE_UINT16);
4873 cmdline_parse_inst_t cmd_csum_tunnel = {
4874 .f = cmd_csum_tunnel_parsed,
4876 .help_str = "csum parse-tunnel on|off <port_id>: "
4877 "Enable/Disable parsing of tunnels for csum engine",
4879 (void *)&cmd_csum_tunnel_csum,
4880 (void *)&cmd_csum_tunnel_parse,
4881 (void *)&cmd_csum_tunnel_onoff,
4882 (void *)&cmd_csum_tunnel_portid,
4887 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4888 struct cmd_tso_set_result {
4889 cmdline_fixed_string_t tso;
4890 cmdline_fixed_string_t mode;
4896 cmd_tso_set_parsed(void *parsed_result,
4897 __rte_unused struct cmdline *cl,
4898 __rte_unused void *data)
4900 struct cmd_tso_set_result *res = parsed_result;
4901 struct rte_eth_dev_info dev_info;
4904 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4906 if (!port_is_stopped(res->port_id)) {
4907 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4911 if (!strcmp(res->mode, "set"))
4912 ports[res->port_id].tso_segsz = res->tso_segsz;
4914 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4918 if ((ports[res->port_id].tso_segsz != 0) &&
4919 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) {
4920 fprintf(stderr, "Error: TSO is not supported by port %d\n",
4925 if (ports[res->port_id].tso_segsz == 0) {
4926 ports[res->port_id].dev_conf.txmode.offloads &=
4927 ~RTE_ETH_TX_OFFLOAD_TCP_TSO;
4928 printf("TSO for non-tunneled packets is disabled\n");
4930 ports[res->port_id].dev_conf.txmode.offloads |=
4931 RTE_ETH_TX_OFFLOAD_TCP_TSO;
4932 printf("TSO segment size for non-tunneled packets is %d\n",
4933 ports[res->port_id].tso_segsz);
4935 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4937 /* display warnings if configuration is not supported by the NIC */
4938 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4942 if ((ports[res->port_id].tso_segsz != 0) &&
4943 (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0) {
4945 "Warning: TSO enabled but not supported by port %d\n",
4949 cmd_reconfig_device_queue(res->port_id, 1, 1);
4952 cmdline_parse_token_string_t cmd_tso_set_tso =
4953 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4955 cmdline_parse_token_string_t cmd_tso_set_mode =
4956 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4958 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4959 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4960 tso_segsz, RTE_UINT16);
4961 cmdline_parse_token_num_t cmd_tso_set_portid =
4962 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4963 port_id, RTE_UINT16);
4965 cmdline_parse_inst_t cmd_tso_set = {
4966 .f = cmd_tso_set_parsed,
4968 .help_str = "tso set <tso_segsz> <port_id>: "
4969 "Set TSO segment size of non-tunneled packets for csum engine "
4972 (void *)&cmd_tso_set_tso,
4973 (void *)&cmd_tso_set_mode,
4974 (void *)&cmd_tso_set_tso_segsz,
4975 (void *)&cmd_tso_set_portid,
4980 cmdline_parse_token_string_t cmd_tso_show_mode =
4981 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4985 cmdline_parse_inst_t cmd_tso_show = {
4986 .f = cmd_tso_set_parsed,
4988 .help_str = "tso show <port_id>: "
4989 "Show TSO segment size of non-tunneled packets for csum engine",
4991 (void *)&cmd_tso_set_tso,
4992 (void *)&cmd_tso_show_mode,
4993 (void *)&cmd_tso_set_portid,
4998 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4999 struct cmd_tunnel_tso_set_result {
5000 cmdline_fixed_string_t tso;
5001 cmdline_fixed_string_t mode;
5006 static struct rte_eth_dev_info
5007 check_tunnel_tso_nic_support(portid_t port_id)
5009 struct rte_eth_dev_info dev_info;
5011 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
5014 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO))
5016 "Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n",
5018 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO))
5020 "Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n",
5022 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO))
5024 "Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n",
5026 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO))
5028 "Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n",
5030 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IP_TNL_TSO))
5032 "Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n",
5034 if (!(dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO))
5036 "Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n",
5042 cmd_tunnel_tso_set_parsed(void *parsed_result,
5043 __rte_unused struct cmdline *cl,
5044 __rte_unused void *data)
5046 struct cmd_tunnel_tso_set_result *res = parsed_result;
5047 struct rte_eth_dev_info dev_info;
5049 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5051 if (!port_is_stopped(res->port_id)) {
5052 fprintf(stderr, "Please stop port %d first\n", res->port_id);
5056 if (!strcmp(res->mode, "set"))
5057 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5059 dev_info = check_tunnel_tso_nic_support(res->port_id);
5060 if (ports[res->port_id].tunnel_tso_segsz == 0) {
5061 ports[res->port_id].dev_conf.txmode.offloads &=
5062 ~(RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5063 RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5064 RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5065 RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5066 RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5067 RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO);
5068 printf("TSO for tunneled packets is disabled\n");
5070 uint64_t tso_offloads = (RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5071 RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5072 RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5073 RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5074 RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5075 RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO);
5077 ports[res->port_id].dev_conf.txmode.offloads |=
5078 (tso_offloads & dev_info.tx_offload_capa);
5079 printf("TSO segment size for tunneled packets is %d\n",
5080 ports[res->port_id].tunnel_tso_segsz);
5082 /* Below conditions are needed to make it work:
5083 * (1) tunnel TSO is supported by the NIC;
5084 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5086 * (3) for tunneled pkts with outer L3 of IPv4,
5087 * "csum set outer-ip" must be set to hw, because after tso,
5088 * total_len of outer IP header is changed, and the checksum
5089 * of outer IP header calculated by sw should be wrong; that
5090 * is not necessary for IPv6 tunneled pkts because there's no
5091 * checksum in IP header anymore.
5094 if (!ports[res->port_id].parse_tunnel)
5096 "Warning: csum parse_tunnel must be set so that tunneled packets are recognized\n");
5097 if (!(ports[res->port_id].dev_conf.txmode.offloads &
5098 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5100 "Warning: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n");
5103 cmd_config_queue_tx_offloads(&ports[res->port_id]);
5104 cmd_reconfig_device_queue(res->port_id, 1, 1);
5107 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5108 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5110 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5111 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5113 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5114 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5115 tso_segsz, RTE_UINT16);
5116 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5117 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5118 port_id, RTE_UINT16);
5120 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5121 .f = cmd_tunnel_tso_set_parsed,
5123 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5124 "Set TSO segment size of tunneled packets for csum engine "
5127 (void *)&cmd_tunnel_tso_set_tso,
5128 (void *)&cmd_tunnel_tso_set_mode,
5129 (void *)&cmd_tunnel_tso_set_tso_segsz,
5130 (void *)&cmd_tunnel_tso_set_portid,
5135 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5136 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5140 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5141 .f = cmd_tunnel_tso_set_parsed,
5143 .help_str = "tunnel_tso show <port_id> "
5144 "Show TSO segment size of tunneled packets for csum engine",
5146 (void *)&cmd_tunnel_tso_set_tso,
5147 (void *)&cmd_tunnel_tso_show_mode,
5148 (void *)&cmd_tunnel_tso_set_portid,
5153 /* *** SET GRO FOR A PORT *** */
5154 struct cmd_gro_enable_result {
5155 cmdline_fixed_string_t cmd_set;
5156 cmdline_fixed_string_t cmd_port;
5157 cmdline_fixed_string_t cmd_keyword;
5158 cmdline_fixed_string_t cmd_onoff;
5163 cmd_gro_enable_parsed(void *parsed_result,
5164 __rte_unused struct cmdline *cl,
5165 __rte_unused void *data)
5167 struct cmd_gro_enable_result *res;
5169 res = parsed_result;
5170 if (!strcmp(res->cmd_keyword, "gro"))
5171 setup_gro(res->cmd_onoff, res->cmd_pid);
5174 cmdline_parse_token_string_t cmd_gro_enable_set =
5175 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5177 cmdline_parse_token_string_t cmd_gro_enable_port =
5178 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5179 cmd_keyword, "port");
5180 cmdline_parse_token_num_t cmd_gro_enable_pid =
5181 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5182 cmd_pid, RTE_UINT16);
5183 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5184 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5185 cmd_keyword, "gro");
5186 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5187 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5188 cmd_onoff, "on#off");
5190 cmdline_parse_inst_t cmd_gro_enable = {
5191 .f = cmd_gro_enable_parsed,
5193 .help_str = "set port <port_id> gro on|off",
5195 (void *)&cmd_gro_enable_set,
5196 (void *)&cmd_gro_enable_port,
5197 (void *)&cmd_gro_enable_pid,
5198 (void *)&cmd_gro_enable_keyword,
5199 (void *)&cmd_gro_enable_onoff,
5204 /* *** DISPLAY GRO CONFIGURATION *** */
5205 struct cmd_gro_show_result {
5206 cmdline_fixed_string_t cmd_show;
5207 cmdline_fixed_string_t cmd_port;
5208 cmdline_fixed_string_t cmd_keyword;
5213 cmd_gro_show_parsed(void *parsed_result,
5214 __rte_unused struct cmdline *cl,
5215 __rte_unused void *data)
5217 struct cmd_gro_show_result *res;
5219 res = parsed_result;
5220 if (!strcmp(res->cmd_keyword, "gro"))
5221 show_gro(res->cmd_pid);
5224 cmdline_parse_token_string_t cmd_gro_show_show =
5225 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5227 cmdline_parse_token_string_t cmd_gro_show_port =
5228 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5230 cmdline_parse_token_num_t cmd_gro_show_pid =
5231 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5232 cmd_pid, RTE_UINT16);
5233 cmdline_parse_token_string_t cmd_gro_show_keyword =
5234 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5235 cmd_keyword, "gro");
5237 cmdline_parse_inst_t cmd_gro_show = {
5238 .f = cmd_gro_show_parsed,
5240 .help_str = "show port <port_id> gro",
5242 (void *)&cmd_gro_show_show,
5243 (void *)&cmd_gro_show_port,
5244 (void *)&cmd_gro_show_pid,
5245 (void *)&cmd_gro_show_keyword,
5250 /* *** SET FLUSH CYCLES FOR GRO *** */
5251 struct cmd_gro_flush_result {
5252 cmdline_fixed_string_t cmd_set;
5253 cmdline_fixed_string_t cmd_keyword;
5254 cmdline_fixed_string_t cmd_flush;
5259 cmd_gro_flush_parsed(void *parsed_result,
5260 __rte_unused struct cmdline *cl,
5261 __rte_unused void *data)
5263 struct cmd_gro_flush_result *res;
5265 res = parsed_result;
5266 if ((!strcmp(res->cmd_keyword, "gro")) &&
5267 (!strcmp(res->cmd_flush, "flush")))
5268 setup_gro_flush_cycles(res->cmd_cycles);
5271 cmdline_parse_token_string_t cmd_gro_flush_set =
5272 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5274 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5275 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5276 cmd_keyword, "gro");
5277 cmdline_parse_token_string_t cmd_gro_flush_flush =
5278 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5279 cmd_flush, "flush");
5280 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5281 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5282 cmd_cycles, RTE_UINT8);
5284 cmdline_parse_inst_t cmd_gro_flush = {
5285 .f = cmd_gro_flush_parsed,
5287 .help_str = "set gro flush <cycles>",
5289 (void *)&cmd_gro_flush_set,
5290 (void *)&cmd_gro_flush_keyword,
5291 (void *)&cmd_gro_flush_flush,
5292 (void *)&cmd_gro_flush_cycles,
5297 /* *** ENABLE/DISABLE GSO *** */
5298 struct cmd_gso_enable_result {
5299 cmdline_fixed_string_t cmd_set;
5300 cmdline_fixed_string_t cmd_port;
5301 cmdline_fixed_string_t cmd_keyword;
5302 cmdline_fixed_string_t cmd_mode;
5307 cmd_gso_enable_parsed(void *parsed_result,
5308 __rte_unused struct cmdline *cl,
5309 __rte_unused void *data)
5311 struct cmd_gso_enable_result *res;
5313 res = parsed_result;
5314 if (!strcmp(res->cmd_keyword, "gso"))
5315 setup_gso(res->cmd_mode, res->cmd_pid);
5318 cmdline_parse_token_string_t cmd_gso_enable_set =
5319 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5321 cmdline_parse_token_string_t cmd_gso_enable_port =
5322 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5324 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5325 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5326 cmd_keyword, "gso");
5327 cmdline_parse_token_string_t cmd_gso_enable_mode =
5328 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5329 cmd_mode, "on#off");
5330 cmdline_parse_token_num_t cmd_gso_enable_pid =
5331 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5332 cmd_pid, RTE_UINT16);
5334 cmdline_parse_inst_t cmd_gso_enable = {
5335 .f = cmd_gso_enable_parsed,
5337 .help_str = "set port <port_id> gso on|off",
5339 (void *)&cmd_gso_enable_set,
5340 (void *)&cmd_gso_enable_port,
5341 (void *)&cmd_gso_enable_pid,
5342 (void *)&cmd_gso_enable_keyword,
5343 (void *)&cmd_gso_enable_mode,
5348 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5349 struct cmd_gso_size_result {
5350 cmdline_fixed_string_t cmd_set;
5351 cmdline_fixed_string_t cmd_keyword;
5352 cmdline_fixed_string_t cmd_segsz;
5357 cmd_gso_size_parsed(void *parsed_result,
5358 __rte_unused struct cmdline *cl,
5359 __rte_unused void *data)
5361 struct cmd_gso_size_result *res = parsed_result;
5363 if (test_done == 0) {
5365 "Before setting GSO segsz, please first stop forwarding\n");
5369 if (!strcmp(res->cmd_keyword, "gso") &&
5370 !strcmp(res->cmd_segsz, "segsz")) {
5371 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5373 "gso_size should be larger than %zu. Please input a legal value\n",
5374 RTE_GSO_SEG_SIZE_MIN);
5376 gso_max_segment_size = res->cmd_size;
5380 cmdline_parse_token_string_t cmd_gso_size_set =
5381 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5383 cmdline_parse_token_string_t cmd_gso_size_keyword =
5384 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5385 cmd_keyword, "gso");
5386 cmdline_parse_token_string_t cmd_gso_size_segsz =
5387 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5388 cmd_segsz, "segsz");
5389 cmdline_parse_token_num_t cmd_gso_size_size =
5390 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5391 cmd_size, RTE_UINT16);
5393 cmdline_parse_inst_t cmd_gso_size = {
5394 .f = cmd_gso_size_parsed,
5396 .help_str = "set gso segsz <length>",
5398 (void *)&cmd_gso_size_set,
5399 (void *)&cmd_gso_size_keyword,
5400 (void *)&cmd_gso_size_segsz,
5401 (void *)&cmd_gso_size_size,
5406 /* *** SHOW GSO CONFIGURATION *** */
5407 struct cmd_gso_show_result {
5408 cmdline_fixed_string_t cmd_show;
5409 cmdline_fixed_string_t cmd_port;
5410 cmdline_fixed_string_t cmd_keyword;
5415 cmd_gso_show_parsed(void *parsed_result,
5416 __rte_unused struct cmdline *cl,
5417 __rte_unused void *data)
5419 struct cmd_gso_show_result *res = parsed_result;
5421 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5422 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
5425 if (!strcmp(res->cmd_keyword, "gso")) {
5426 if (gso_ports[res->cmd_pid].enable) {
5427 printf("Max GSO'd packet size: %uB\n"
5428 "Supported GSO types: TCP/IPv4, "
5429 "UDP/IPv4, VxLAN with inner "
5430 "TCP/IPv4 packet, GRE with inner "
5431 "TCP/IPv4 packet\n",
5432 gso_max_segment_size);
5434 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5438 cmdline_parse_token_string_t cmd_gso_show_show =
5439 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5441 cmdline_parse_token_string_t cmd_gso_show_port =
5442 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5444 cmdline_parse_token_string_t cmd_gso_show_keyword =
5445 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5446 cmd_keyword, "gso");
5447 cmdline_parse_token_num_t cmd_gso_show_pid =
5448 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5449 cmd_pid, RTE_UINT16);
5451 cmdline_parse_inst_t cmd_gso_show = {
5452 .f = cmd_gso_show_parsed,
5454 .help_str = "show port <port_id> gso",
5456 (void *)&cmd_gso_show_show,
5457 (void *)&cmd_gso_show_port,
5458 (void *)&cmd_gso_show_pid,
5459 (void *)&cmd_gso_show_keyword,
5464 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5465 struct cmd_set_flush_rx {
5466 cmdline_fixed_string_t set;
5467 cmdline_fixed_string_t flush_rx;
5468 cmdline_fixed_string_t mode;
5472 cmd_set_flush_rx_parsed(void *parsed_result,
5473 __rte_unused struct cmdline *cl,
5474 __rte_unused void *data)
5476 struct cmd_set_flush_rx *res = parsed_result;
5478 if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) {
5479 printf("multi-process doesn't support to flush Rx queues.\n");
5483 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5486 cmdline_parse_token_string_t cmd_setflushrx_set =
5487 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5489 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5490 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5491 flush_rx, "flush_rx");
5492 cmdline_parse_token_string_t cmd_setflushrx_mode =
5493 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5497 cmdline_parse_inst_t cmd_set_flush_rx = {
5498 .f = cmd_set_flush_rx_parsed,
5499 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5502 (void *)&cmd_setflushrx_set,
5503 (void *)&cmd_setflushrx_flush_rx,
5504 (void *)&cmd_setflushrx_mode,
5509 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5510 struct cmd_set_link_check {
5511 cmdline_fixed_string_t set;
5512 cmdline_fixed_string_t link_check;
5513 cmdline_fixed_string_t mode;
5517 cmd_set_link_check_parsed(void *parsed_result,
5518 __rte_unused struct cmdline *cl,
5519 __rte_unused void *data)
5521 struct cmd_set_link_check *res = parsed_result;
5522 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5525 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5526 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5528 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5529 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5530 link_check, "link_check");
5531 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5532 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5536 cmdline_parse_inst_t cmd_set_link_check = {
5537 .f = cmd_set_link_check_parsed,
5538 .help_str = "set link_check on|off: Enable/Disable link status check "
5539 "when starting/stopping a port",
5542 (void *)&cmd_setlinkcheck_set,
5543 (void *)&cmd_setlinkcheck_link_check,
5544 (void *)&cmd_setlinkcheck_mode,
5549 /* *** SET NIC BYPASS MODE *** */
5550 struct cmd_set_bypass_mode_result {
5551 cmdline_fixed_string_t set;
5552 cmdline_fixed_string_t bypass;
5553 cmdline_fixed_string_t mode;
5554 cmdline_fixed_string_t value;
5559 cmd_set_bypass_mode_parsed(void *parsed_result,
5560 __rte_unused struct cmdline *cl,
5561 __rte_unused void *data)
5563 struct cmd_set_bypass_mode_result *res = parsed_result;
5564 portid_t port_id = res->port_id;
5565 int32_t rc = -EINVAL;
5567 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5568 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5570 if (!strcmp(res->value, "bypass"))
5571 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5572 else if (!strcmp(res->value, "isolate"))
5573 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5575 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5577 /* Set the bypass mode for the relevant port. */
5578 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5581 fprintf(stderr, "\t Failed to set bypass mode for port = %d.\n",
5585 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5586 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5588 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5589 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5591 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5592 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5594 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5595 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5596 value, "normal#bypass#isolate");
5597 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5598 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5599 port_id, RTE_UINT16);
5601 cmdline_parse_inst_t cmd_set_bypass_mode = {
5602 .f = cmd_set_bypass_mode_parsed,
5603 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5604 "Set the NIC bypass mode for port_id",
5607 (void *)&cmd_setbypass_mode_set,
5608 (void *)&cmd_setbypass_mode_bypass,
5609 (void *)&cmd_setbypass_mode_mode,
5610 (void *)&cmd_setbypass_mode_value,
5611 (void *)&cmd_setbypass_mode_port,
5616 /* *** SET NIC BYPASS EVENT *** */
5617 struct cmd_set_bypass_event_result {
5618 cmdline_fixed_string_t set;
5619 cmdline_fixed_string_t bypass;
5620 cmdline_fixed_string_t event;
5621 cmdline_fixed_string_t event_value;
5622 cmdline_fixed_string_t mode;
5623 cmdline_fixed_string_t mode_value;
5628 cmd_set_bypass_event_parsed(void *parsed_result,
5629 __rte_unused struct cmdline *cl,
5630 __rte_unused void *data)
5632 int32_t rc = -EINVAL;
5633 struct cmd_set_bypass_event_result *res = parsed_result;
5634 portid_t port_id = res->port_id;
5636 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5637 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5638 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5640 if (!strcmp(res->event_value, "timeout"))
5641 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5642 else if (!strcmp(res->event_value, "os_on"))
5643 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5644 else if (!strcmp(res->event_value, "os_off"))
5645 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5646 else if (!strcmp(res->event_value, "power_on"))
5647 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5648 else if (!strcmp(res->event_value, "power_off"))
5649 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5651 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5653 if (!strcmp(res->mode_value, "bypass"))
5654 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5655 else if (!strcmp(res->mode_value, "isolate"))
5656 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5658 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5660 /* Set the watchdog timeout. */
5661 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5664 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5665 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5670 "Failed to set timeout value %u for port %d, errto code: %d.\n",
5671 bypass_timeout, port_id, rc);
5675 /* Set the bypass event to transition to bypass mode. */
5676 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5681 fprintf(stderr, "\t Failed to set bypass event for port = %d.\n",
5685 cmdline_parse_token_string_t cmd_setbypass_event_set =
5686 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5688 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5689 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5691 cmdline_parse_token_string_t cmd_setbypass_event_event =
5692 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5694 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5695 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5696 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5697 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5698 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5700 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5701 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5702 mode_value, "normal#bypass#isolate");
5703 cmdline_parse_token_num_t cmd_setbypass_event_port =
5704 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5705 port_id, RTE_UINT16);
5707 cmdline_parse_inst_t cmd_set_bypass_event = {
5708 .f = cmd_set_bypass_event_parsed,
5709 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5710 "power_off mode normal|bypass|isolate <port_id>: "
5711 "Set the NIC bypass event mode for port_id",
5714 (void *)&cmd_setbypass_event_set,
5715 (void *)&cmd_setbypass_event_bypass,
5716 (void *)&cmd_setbypass_event_event,
5717 (void *)&cmd_setbypass_event_event_value,
5718 (void *)&cmd_setbypass_event_mode,
5719 (void *)&cmd_setbypass_event_mode_value,
5720 (void *)&cmd_setbypass_event_port,
5726 /* *** SET NIC BYPASS TIMEOUT *** */
5727 struct cmd_set_bypass_timeout_result {
5728 cmdline_fixed_string_t set;
5729 cmdline_fixed_string_t bypass;
5730 cmdline_fixed_string_t timeout;
5731 cmdline_fixed_string_t value;
5735 cmd_set_bypass_timeout_parsed(void *parsed_result,
5736 __rte_unused struct cmdline *cl,
5737 __rte_unused void *data)
5739 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5741 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5742 if (!strcmp(res->value, "1.5"))
5743 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5744 else if (!strcmp(res->value, "2"))
5745 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5746 else if (!strcmp(res->value, "3"))
5747 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5748 else if (!strcmp(res->value, "4"))
5749 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5750 else if (!strcmp(res->value, "8"))
5751 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5752 else if (!strcmp(res->value, "16"))
5753 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5754 else if (!strcmp(res->value, "32"))
5755 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5757 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5761 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5762 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5764 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5765 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5767 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5768 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5769 timeout, "timeout");
5770 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5771 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5772 value, "0#1.5#2#3#4#8#16#32");
5774 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5775 .f = cmd_set_bypass_timeout_parsed,
5776 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5777 "Set the NIC bypass watchdog timeout in seconds",
5780 (void *)&cmd_setbypass_timeout_set,
5781 (void *)&cmd_setbypass_timeout_bypass,
5782 (void *)&cmd_setbypass_timeout_timeout,
5783 (void *)&cmd_setbypass_timeout_value,
5788 /* *** SHOW NIC BYPASS MODE *** */
5789 struct cmd_show_bypass_config_result {
5790 cmdline_fixed_string_t show;
5791 cmdline_fixed_string_t bypass;
5792 cmdline_fixed_string_t config;
5797 cmd_show_bypass_config_parsed(void *parsed_result,
5798 __rte_unused struct cmdline *cl,
5799 __rte_unused void *data)
5801 struct cmd_show_bypass_config_result *res = parsed_result;
5802 portid_t port_id = res->port_id;
5804 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5805 uint32_t event_mode;
5806 uint32_t bypass_mode;
5807 uint32_t timeout = bypass_timeout;
5810 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5811 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5812 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5813 {"UNKNOWN", "normal", "bypass", "isolate"};
5814 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5822 /* Display the bypass mode.*/
5823 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5824 fprintf(stderr, "\tFailed to get bypass mode for port = %d\n",
5829 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5830 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5832 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5835 /* Display the bypass timeout.*/
5836 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5837 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5839 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5841 /* Display the bypass events and associated modes. */
5842 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5844 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5846 "\tFailed to get bypass mode for event = %s\n",
5849 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5850 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5852 printf("\tbypass event: %-16s = %s\n", events[i],
5859 "\tFailed to get bypass configuration for port = %d\n",
5863 cmdline_parse_token_string_t cmd_showbypass_config_show =
5864 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5866 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5867 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5869 cmdline_parse_token_string_t cmd_showbypass_config_config =
5870 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5872 cmdline_parse_token_num_t cmd_showbypass_config_port =
5873 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5874 port_id, RTE_UINT16);
5876 cmdline_parse_inst_t cmd_show_bypass_config = {
5877 .f = cmd_show_bypass_config_parsed,
5878 .help_str = "show bypass config <port_id>: "
5879 "Show the NIC bypass config for port_id",
5882 (void *)&cmd_showbypass_config_show,
5883 (void *)&cmd_showbypass_config_bypass,
5884 (void *)&cmd_showbypass_config_config,
5885 (void *)&cmd_showbypass_config_port,
5891 /* *** SET BONDING MODE *** */
5892 struct cmd_set_bonding_mode_result {
5893 cmdline_fixed_string_t set;
5894 cmdline_fixed_string_t bonding;
5895 cmdline_fixed_string_t mode;
5900 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5901 __rte_unused struct cmdline *cl,
5902 __rte_unused void *data)
5904 struct cmd_set_bonding_mode_result *res = parsed_result;
5905 portid_t port_id = res->port_id;
5907 /* Set the bonding mode for the relevant port. */
5908 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5909 fprintf(stderr, "\t Failed to set bonding mode for port = %d.\n",
5913 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5914 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5916 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5917 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5918 bonding, "bonding");
5919 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5920 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5922 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5923 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5925 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5926 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5927 port_id, RTE_UINT16);
5929 cmdline_parse_inst_t cmd_set_bonding_mode = {
5930 .f = cmd_set_bonding_mode_parsed,
5931 .help_str = "set bonding mode <mode_value> <port_id>: "
5932 "Set the bonding mode for port_id",
5935 (void *) &cmd_setbonding_mode_set,
5936 (void *) &cmd_setbonding_mode_bonding,
5937 (void *) &cmd_setbonding_mode_mode,
5938 (void *) &cmd_setbonding_mode_value,
5939 (void *) &cmd_setbonding_mode_port,
5944 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5945 struct cmd_set_bonding_lacp_dedicated_queues_result {
5946 cmdline_fixed_string_t set;
5947 cmdline_fixed_string_t bonding;
5948 cmdline_fixed_string_t lacp;
5949 cmdline_fixed_string_t dedicated_queues;
5951 cmdline_fixed_string_t mode;
5954 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5955 __rte_unused struct cmdline *cl,
5956 __rte_unused void *data)
5958 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5959 portid_t port_id = res->port_id;
5960 struct rte_port *port;
5962 port = &ports[port_id];
5964 /** Check if the port is not started **/
5965 if (port->port_status != RTE_PORT_STOPPED) {
5966 fprintf(stderr, "Please stop port %d first\n", port_id);
5970 if (!strcmp(res->mode, "enable")) {
5971 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5972 printf("Dedicate queues for LACP control packets"
5975 printf("Enabling dedicate queues for LACP control "
5976 "packets on port %d failed\n", port_id);
5977 } else if (!strcmp(res->mode, "disable")) {
5978 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5979 printf("Dedicated queues for LACP control packets "
5982 printf("Disabling dedicated queues for LACP control "
5983 "traffic on port %d failed\n", port_id);
5987 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5988 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5990 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5991 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5992 bonding, "bonding");
5993 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5994 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5996 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5997 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5998 dedicated_queues, "dedicated_queues");
5999 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
6000 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6001 port_id, RTE_UINT16);
6002 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
6003 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6004 mode, "enable#disable");
6006 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
6007 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
6008 .help_str = "set bonding lacp dedicated_queues <port_id> "
6010 "Enable/disable dedicated queues for LACP control traffic for port_id",
6013 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
6014 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
6015 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
6016 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
6017 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
6018 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
6023 /* *** SET BALANCE XMIT POLICY *** */
6024 struct cmd_set_bonding_balance_xmit_policy_result {
6025 cmdline_fixed_string_t set;
6026 cmdline_fixed_string_t bonding;
6027 cmdline_fixed_string_t balance_xmit_policy;
6029 cmdline_fixed_string_t policy;
6032 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
6033 __rte_unused struct cmdline *cl,
6034 __rte_unused void *data)
6036 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6037 portid_t port_id = res->port_id;
6040 if (!strcmp(res->policy, "l2")) {
6041 policy = BALANCE_XMIT_POLICY_LAYER2;
6042 } else if (!strcmp(res->policy, "l23")) {
6043 policy = BALANCE_XMIT_POLICY_LAYER23;
6044 } else if (!strcmp(res->policy, "l34")) {
6045 policy = BALANCE_XMIT_POLICY_LAYER34;
6047 fprintf(stderr, "\t Invalid xmit policy selection");
6051 /* Set the bonding mode for the relevant port. */
6052 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6054 "\t Failed to set bonding balance xmit policy for port = %d.\n",
6059 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6060 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6062 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6063 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6064 bonding, "bonding");
6065 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6066 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6067 balance_xmit_policy, "balance_xmit_policy");
6068 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6069 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6070 port_id, RTE_UINT16);
6071 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6072 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6073 policy, "l2#l23#l34");
6075 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6076 .f = cmd_set_bonding_balance_xmit_policy_parsed,
6077 .help_str = "set bonding balance_xmit_policy <port_id> "
6079 "Set the bonding balance_xmit_policy for port_id",
6082 (void *)&cmd_setbonding_balance_xmit_policy_set,
6083 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
6084 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6085 (void *)&cmd_setbonding_balance_xmit_policy_port,
6086 (void *)&cmd_setbonding_balance_xmit_policy_policy,
6091 /* *** SHOW IEEE802.3 BONDING INFORMATION *** */
6092 struct cmd_show_bonding_lacp_info_result {
6093 cmdline_fixed_string_t show;
6094 cmdline_fixed_string_t bonding;
6095 cmdline_fixed_string_t lacp;
6096 cmdline_fixed_string_t info;
6100 static void port_param_show(struct port_params *params)
6102 char buf[RTE_ETHER_ADDR_FMT_SIZE];
6104 printf("\t\tsystem priority: %u\n", params->system_priority);
6105 rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, ¶ms->system);
6106 printf("\t\tsystem mac address: %s\n", buf);
6107 printf("\t\tport key: %u\n", params->key);
6108 printf("\t\tport priority: %u\n", params->port_priority);
6109 printf("\t\tport number: %u\n", params->port_number);
6112 static void lacp_slave_info_show(struct rte_eth_bond_8023ad_slave_info *info)
6114 char a_state[256] = { 0 };
6115 char p_state[256] = { 0 };
6120 static const char * const state[] = {
6130 static const char * const selection[] = {
6136 for (i = 0; i < RTE_DIM(state); i++) {
6137 if ((info->actor_state >> i) & 1)
6138 a_len += snprintf(&a_state[a_len],
6139 RTE_DIM(a_state) - a_len, "%s ",
6142 if ((info->partner_state >> i) & 1)
6143 p_len += snprintf(&p_state[p_len],
6144 RTE_DIM(p_state) - p_len, "%s ",
6147 printf("\tAggregator port id: %u\n", info->agg_port_id);
6148 printf("\tselection: %s\n", selection[info->selected]);
6149 printf("\tActor detail info:\n");
6150 port_param_show(&info->actor);
6151 printf("\t\tport state: %s\n", a_state);
6152 printf("\tPartner detail info:\n");
6153 port_param_show(&info->partner);
6154 printf("\t\tport state: %s\n", p_state);
6158 static void lacp_conf_show(struct rte_eth_bond_8023ad_conf *conf)
6160 printf("\tfast period: %u ms\n", conf->fast_periodic_ms);
6161 printf("\tslow period: %u ms\n", conf->slow_periodic_ms);
6162 printf("\tshort timeout: %u ms\n", conf->short_timeout_ms);
6163 printf("\tlong timeout: %u ms\n", conf->long_timeout_ms);
6164 printf("\taggregate wait timeout: %u ms\n",
6165 conf->aggregate_wait_timeout_ms);
6166 printf("\ttx period: %u ms\n", conf->tx_period_ms);
6167 printf("\trx marker period: %u ms\n", conf->rx_marker_period_ms);
6168 printf("\tupdate timeout: %u ms\n", conf->update_timeout_ms);
6169 switch (conf->agg_selection) {
6171 printf("\taggregation mode: bandwidth\n");
6174 printf("\taggregation mode: stable\n");
6177 printf("\taggregation mode: count\n");
6180 printf("\taggregation mode: invalid\n");
6187 static void cmd_show_bonding_lacp_info_parsed(void *parsed_result,
6188 __rte_unused struct cmdline *cl,
6189 __rte_unused void *data)
6191 struct cmd_show_bonding_lacp_info_result *res = parsed_result;
6192 struct rte_eth_bond_8023ad_slave_info slave_info;
6193 struct rte_eth_bond_8023ad_conf port_conf;
6194 portid_t slaves[RTE_MAX_ETHPORTS];
6195 portid_t port_id = res->port_id;
6196 int num_active_slaves;
6201 bonding_mode = rte_eth_bond_mode_get(port_id);
6202 if (bonding_mode != BONDING_MODE_8023AD) {
6203 fprintf(stderr, "\tBonding mode is not mode 4\n");
6207 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6209 if (num_active_slaves < 0) {
6210 fprintf(stderr, "\tFailed to get active slave list for port = %u\n",
6214 if (num_active_slaves == 0)
6215 fprintf(stderr, "\tIEEE802.3 port %u has no active slave\n",
6218 printf("\tIEEE802.3 port: %u\n", port_id);
6219 ret = rte_eth_bond_8023ad_conf_get(port_id, &port_conf);
6221 fprintf(stderr, "\tGet bonded device %u info failed\n",
6225 lacp_conf_show(&port_conf);
6227 for (i = 0; i < num_active_slaves; i++) {
6228 ret = rte_eth_bond_8023ad_slave_info(port_id, slaves[i],
6231 fprintf(stderr, "\tGet slave device %u info failed\n",
6235 printf("\tSlave Port: %u\n", slaves[i]);
6236 lacp_slave_info_show(&slave_info);
6240 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_show =
6241 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6243 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_bonding =
6244 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6245 bonding, "bonding");
6246 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_lacp =
6247 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6249 cmdline_parse_token_string_t cmd_show_bonding_lacp_info_info =
6250 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6252 cmdline_parse_token_num_t cmd_show_bonding_lacp_info_port_id =
6253 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
6254 port_id, RTE_UINT16);
6256 cmdline_parse_inst_t cmd_show_bonding_lacp_info = {
6257 .f = cmd_show_bonding_lacp_info_parsed,
6258 .help_str = "show bonding lacp info <port_id> : "
6259 "Show bonding IEEE802.3 information for port_id",
6262 (void *)&cmd_show_bonding_lacp_info_show,
6263 (void *)&cmd_show_bonding_lacp_info_bonding,
6264 (void *)&cmd_show_bonding_lacp_info_lacp,
6265 (void *)&cmd_show_bonding_lacp_info_info,
6266 (void *)&cmd_show_bonding_lacp_info_port_id,
6271 /* *** SHOW NIC BONDING CONFIGURATION *** */
6272 struct cmd_show_bonding_config_result {
6273 cmdline_fixed_string_t show;
6274 cmdline_fixed_string_t bonding;
6275 cmdline_fixed_string_t config;
6279 static void cmd_show_bonding_config_parsed(void *parsed_result,
6280 __rte_unused struct cmdline *cl,
6281 __rte_unused void *data)
6283 struct cmd_show_bonding_config_result *res = parsed_result;
6284 int bonding_mode, agg_mode;
6285 portid_t slaves[RTE_MAX_ETHPORTS];
6286 int num_slaves, num_active_slaves;
6289 portid_t port_id = res->port_id;
6291 /* Display the bonding mode.*/
6292 bonding_mode = rte_eth_bond_mode_get(port_id);
6293 if (bonding_mode < 0) {
6294 fprintf(stderr, "\tFailed to get bonding mode for port = %d\n",
6298 printf("\tBonding mode: %d\n", bonding_mode);
6300 if (bonding_mode == BONDING_MODE_BALANCE ||
6301 bonding_mode == BONDING_MODE_8023AD) {
6302 int balance_xmit_policy;
6304 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6305 if (balance_xmit_policy < 0) {
6307 "\tFailed to get balance xmit policy for port = %d\n",
6311 printf("\tBalance Xmit Policy: ");
6313 switch (balance_xmit_policy) {
6314 case BALANCE_XMIT_POLICY_LAYER2:
6315 printf("BALANCE_XMIT_POLICY_LAYER2");
6317 case BALANCE_XMIT_POLICY_LAYER23:
6318 printf("BALANCE_XMIT_POLICY_LAYER23");
6320 case BALANCE_XMIT_POLICY_LAYER34:
6321 printf("BALANCE_XMIT_POLICY_LAYER34");
6328 if (bonding_mode == BONDING_MODE_8023AD) {
6329 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6330 printf("\tIEEE802.3AD Aggregator Mode: ");
6333 printf("bandwidth");
6345 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6347 if (num_slaves < 0) {
6348 fprintf(stderr, "\tFailed to get slave list for port = %d\n",
6352 if (num_slaves > 0) {
6353 printf("\tSlaves (%d): [", num_slaves);
6354 for (i = 0; i < num_slaves - 1; i++)
6355 printf("%d ", slaves[i]);
6357 printf("%d]\n", slaves[num_slaves - 1]);
6359 printf("\tSlaves: []\n");
6363 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6366 if (num_active_slaves < 0) {
6368 "\tFailed to get active slave list for port = %d\n",
6372 if (num_active_slaves > 0) {
6373 printf("\tActive Slaves (%d): [", num_active_slaves);
6374 for (i = 0; i < num_active_slaves - 1; i++)
6375 printf("%d ", slaves[i]);
6377 printf("%d]\n", slaves[num_active_slaves - 1]);
6380 printf("\tActive Slaves: []\n");
6384 primary_id = rte_eth_bond_primary_get(port_id);
6385 if (primary_id < 0) {
6386 fprintf(stderr, "\tFailed to get primary slave for port = %d\n",
6390 printf("\tPrimary: [%d]\n", primary_id);
6394 cmdline_parse_token_string_t cmd_showbonding_config_show =
6395 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6397 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6398 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6399 bonding, "bonding");
6400 cmdline_parse_token_string_t cmd_showbonding_config_config =
6401 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6403 cmdline_parse_token_num_t cmd_showbonding_config_port =
6404 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6405 port_id, RTE_UINT16);
6407 cmdline_parse_inst_t cmd_show_bonding_config = {
6408 .f = cmd_show_bonding_config_parsed,
6409 .help_str = "show bonding config <port_id>: "
6410 "Show the bonding config for port_id",
6413 (void *)&cmd_showbonding_config_show,
6414 (void *)&cmd_showbonding_config_bonding,
6415 (void *)&cmd_showbonding_config_config,
6416 (void *)&cmd_showbonding_config_port,
6421 /* *** SET BONDING PRIMARY *** */
6422 struct cmd_set_bonding_primary_result {
6423 cmdline_fixed_string_t set;
6424 cmdline_fixed_string_t bonding;
6425 cmdline_fixed_string_t primary;
6430 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6431 __rte_unused struct cmdline *cl,
6432 __rte_unused void *data)
6434 struct cmd_set_bonding_primary_result *res = parsed_result;
6435 portid_t master_port_id = res->port_id;
6436 portid_t slave_port_id = res->slave_id;
6438 /* Set the primary slave for a bonded device. */
6439 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6440 fprintf(stderr, "\t Failed to set primary slave for port = %d.\n",
6447 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6448 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6450 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6451 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6452 bonding, "bonding");
6453 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6454 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6455 primary, "primary");
6456 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6457 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6458 slave_id, RTE_UINT16);
6459 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6460 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6461 port_id, RTE_UINT16);
6463 cmdline_parse_inst_t cmd_set_bonding_primary = {
6464 .f = cmd_set_bonding_primary_parsed,
6465 .help_str = "set bonding primary <slave_id> <port_id>: "
6466 "Set the primary slave for port_id",
6469 (void *)&cmd_setbonding_primary_set,
6470 (void *)&cmd_setbonding_primary_bonding,
6471 (void *)&cmd_setbonding_primary_primary,
6472 (void *)&cmd_setbonding_primary_slave,
6473 (void *)&cmd_setbonding_primary_port,
6478 /* *** ADD SLAVE *** */
6479 struct cmd_add_bonding_slave_result {
6480 cmdline_fixed_string_t add;
6481 cmdline_fixed_string_t bonding;
6482 cmdline_fixed_string_t slave;
6487 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6488 __rte_unused struct cmdline *cl,
6489 __rte_unused void *data)
6491 struct cmd_add_bonding_slave_result *res = parsed_result;
6492 portid_t master_port_id = res->port_id;
6493 portid_t slave_port_id = res->slave_id;
6495 /* add the slave for a bonded device. */
6496 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6498 "\t Failed to add slave %d to master port = %d.\n",
6499 slave_port_id, master_port_id);
6503 set_port_slave_flag(slave_port_id);
6506 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6507 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6509 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6510 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6511 bonding, "bonding");
6512 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6513 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6515 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6516 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6517 slave_id, RTE_UINT16);
6518 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6519 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6520 port_id, RTE_UINT16);
6522 cmdline_parse_inst_t cmd_add_bonding_slave = {
6523 .f = cmd_add_bonding_slave_parsed,
6524 .help_str = "add bonding slave <slave_id> <port_id>: "
6525 "Add a slave device to a bonded device",
6528 (void *)&cmd_addbonding_slave_add,
6529 (void *)&cmd_addbonding_slave_bonding,
6530 (void *)&cmd_addbonding_slave_slave,
6531 (void *)&cmd_addbonding_slave_slaveid,
6532 (void *)&cmd_addbonding_slave_port,
6537 /* *** REMOVE SLAVE *** */
6538 struct cmd_remove_bonding_slave_result {
6539 cmdline_fixed_string_t remove;
6540 cmdline_fixed_string_t bonding;
6541 cmdline_fixed_string_t slave;
6546 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6547 __rte_unused struct cmdline *cl,
6548 __rte_unused void *data)
6550 struct cmd_remove_bonding_slave_result *res = parsed_result;
6551 portid_t master_port_id = res->port_id;
6552 portid_t slave_port_id = res->slave_id;
6554 /* remove the slave from a bonded device. */
6555 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6557 "\t Failed to remove slave %d from master port = %d.\n",
6558 slave_port_id, master_port_id);
6562 clear_port_slave_flag(slave_port_id);
6565 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6566 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6568 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6569 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6570 bonding, "bonding");
6571 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6572 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6574 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6575 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6576 slave_id, RTE_UINT16);
6577 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6578 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6579 port_id, RTE_UINT16);
6581 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6582 .f = cmd_remove_bonding_slave_parsed,
6583 .help_str = "remove bonding slave <slave_id> <port_id>: "
6584 "Remove a slave device from a bonded device",
6587 (void *)&cmd_removebonding_slave_remove,
6588 (void *)&cmd_removebonding_slave_bonding,
6589 (void *)&cmd_removebonding_slave_slave,
6590 (void *)&cmd_removebonding_slave_slaveid,
6591 (void *)&cmd_removebonding_slave_port,
6596 /* *** CREATE BONDED DEVICE *** */
6597 struct cmd_create_bonded_device_result {
6598 cmdline_fixed_string_t create;
6599 cmdline_fixed_string_t bonded;
6600 cmdline_fixed_string_t device;
6605 static int bond_dev_num = 0;
6607 static void cmd_create_bonded_device_parsed(void *parsed_result,
6608 __rte_unused struct cmdline *cl,
6609 __rte_unused void *data)
6611 struct cmd_create_bonded_device_result *res = parsed_result;
6612 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6616 if (test_done == 0) {
6617 fprintf(stderr, "Please stop forwarding first\n");
6621 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6624 /* Create a new bonded device. */
6625 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6627 fprintf(stderr, "\t Failed to create bonded device.\n");
6630 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6633 /* Update number of ports */
6634 nb_ports = rte_eth_dev_count_avail();
6635 reconfig(port_id, res->socket);
6636 ret = rte_eth_promiscuous_enable(port_id);
6639 "Failed to enable promiscuous mode for port %u: %s - ignore\n",
6640 port_id, rte_strerror(-ret));
6642 ports[port_id].need_setup = 0;
6643 ports[port_id].port_status = RTE_PORT_STOPPED;
6648 cmdline_parse_token_string_t cmd_createbonded_device_create =
6649 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6651 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6652 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6654 cmdline_parse_token_string_t cmd_createbonded_device_device =
6655 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6657 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6658 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6660 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6661 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6664 cmdline_parse_inst_t cmd_create_bonded_device = {
6665 .f = cmd_create_bonded_device_parsed,
6666 .help_str = "create bonded device <mode> <socket>: "
6667 "Create a new bonded device with specific bonding mode and socket",
6670 (void *)&cmd_createbonded_device_create,
6671 (void *)&cmd_createbonded_device_bonded,
6672 (void *)&cmd_createbonded_device_device,
6673 (void *)&cmd_createbonded_device_mode,
6674 (void *)&cmd_createbonded_device_socket,
6679 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6680 struct cmd_set_bond_mac_addr_result {
6681 cmdline_fixed_string_t set;
6682 cmdline_fixed_string_t bonding;
6683 cmdline_fixed_string_t mac_addr;
6685 struct rte_ether_addr address;
6688 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6689 __rte_unused struct cmdline *cl,
6690 __rte_unused void *data)
6692 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6695 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6698 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6700 /* check the return value and print it if is < 0 */
6702 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6706 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6707 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6708 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6709 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6711 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6712 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6714 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6715 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6716 port_num, RTE_UINT16);
6717 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6718 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6720 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6721 .f = cmd_set_bond_mac_addr_parsed,
6723 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6725 (void *)&cmd_set_bond_mac_addr_set,
6726 (void *)&cmd_set_bond_mac_addr_bonding,
6727 (void *)&cmd_set_bond_mac_addr_mac,
6728 (void *)&cmd_set_bond_mac_addr_portnum,
6729 (void *)&cmd_set_bond_mac_addr_addr,
6735 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6736 struct cmd_set_bond_mon_period_result {
6737 cmdline_fixed_string_t set;
6738 cmdline_fixed_string_t bonding;
6739 cmdline_fixed_string_t mon_period;
6744 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6745 __rte_unused struct cmdline *cl,
6746 __rte_unused void *data)
6748 struct cmd_set_bond_mon_period_result *res = parsed_result;
6751 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6753 /* check the return value and print it if is < 0 */
6755 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6759 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6760 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6762 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6763 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6764 bonding, "bonding");
6765 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6766 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6767 mon_period, "mon_period");
6768 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6769 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6770 port_num, RTE_UINT16);
6771 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6772 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6773 period_ms, RTE_UINT32);
6775 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6776 .f = cmd_set_bond_mon_period_parsed,
6778 .help_str = "set bonding mon_period <port_id> <period_ms>",
6780 (void *)&cmd_set_bond_mon_period_set,
6781 (void *)&cmd_set_bond_mon_period_bonding,
6782 (void *)&cmd_set_bond_mon_period_mon_period,
6783 (void *)&cmd_set_bond_mon_period_portnum,
6784 (void *)&cmd_set_bond_mon_period_period_ms,
6791 struct cmd_set_bonding_agg_mode_policy_result {
6792 cmdline_fixed_string_t set;
6793 cmdline_fixed_string_t bonding;
6794 cmdline_fixed_string_t agg_mode;
6796 cmdline_fixed_string_t policy;
6801 cmd_set_bonding_agg_mode(void *parsed_result,
6802 __rte_unused struct cmdline *cl,
6803 __rte_unused void *data)
6805 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6806 uint8_t policy = AGG_BANDWIDTH;
6808 if (!strcmp(res->policy, "bandwidth"))
6809 policy = AGG_BANDWIDTH;
6810 else if (!strcmp(res->policy, "stable"))
6811 policy = AGG_STABLE;
6812 else if (!strcmp(res->policy, "count"))
6815 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6819 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6820 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6822 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6823 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6824 bonding, "bonding");
6826 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6827 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6828 agg_mode, "agg_mode");
6830 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6831 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6832 port_num, RTE_UINT16);
6834 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6835 TOKEN_STRING_INITIALIZER(
6836 struct cmd_set_bonding_balance_xmit_policy_result,
6837 policy, "stable#bandwidth#count");
6839 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6840 .f = cmd_set_bonding_agg_mode,
6842 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6844 (void *)&cmd_set_bonding_agg_mode_set,
6845 (void *)&cmd_set_bonding_agg_mode_bonding,
6846 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6847 (void *)&cmd_set_bonding_agg_mode_portnum,
6848 (void *)&cmd_set_bonding_agg_mode_policy_string,
6854 #endif /* RTE_NET_BOND */
6856 /* *** SET FORWARDING MODE *** */
6857 struct cmd_set_fwd_mode_result {
6858 cmdline_fixed_string_t set;
6859 cmdline_fixed_string_t fwd;
6860 cmdline_fixed_string_t mode;
6863 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6864 __rte_unused struct cmdline *cl,
6865 __rte_unused void *data)
6867 struct cmd_set_fwd_mode_result *res = parsed_result;
6870 set_pkt_forwarding_mode(res->mode);
6873 cmdline_parse_token_string_t cmd_setfwd_set =
6874 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6875 cmdline_parse_token_string_t cmd_setfwd_fwd =
6876 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6877 cmdline_parse_token_string_t cmd_setfwd_mode =
6878 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6879 "" /* defined at init */);
6881 cmdline_parse_inst_t cmd_set_fwd_mode = {
6882 .f = cmd_set_fwd_mode_parsed,
6884 .help_str = NULL, /* defined at init */
6886 (void *)&cmd_setfwd_set,
6887 (void *)&cmd_setfwd_fwd,
6888 (void *)&cmd_setfwd_mode,
6893 static void cmd_set_fwd_mode_init(void)
6896 static char token[128];
6897 static char help[256];
6898 cmdline_parse_token_string_t *token_struct;
6900 modes = list_pkt_forwarding_modes();
6901 snprintf(help, sizeof(help), "set fwd %s: "
6902 "Set packet forwarding mode", modes);
6903 cmd_set_fwd_mode.help_str = help;
6905 /* string token separator is # */
6906 for (c = token; *modes != '\0'; modes++)
6911 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6912 token_struct->string_data.str = token;
6915 /* *** SET RETRY FORWARDING MODE *** */
6916 struct cmd_set_fwd_retry_mode_result {
6917 cmdline_fixed_string_t set;
6918 cmdline_fixed_string_t fwd;
6919 cmdline_fixed_string_t mode;
6920 cmdline_fixed_string_t retry;
6923 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6924 __rte_unused struct cmdline *cl,
6925 __rte_unused void *data)
6927 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6930 set_pkt_forwarding_mode(res->mode);
6933 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6934 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6936 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6937 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6939 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6940 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6942 "" /* defined at init */);
6943 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6944 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6947 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6948 .f = cmd_set_fwd_retry_mode_parsed,
6950 .help_str = NULL, /* defined at init */
6952 (void *)&cmd_setfwd_retry_set,
6953 (void *)&cmd_setfwd_retry_fwd,
6954 (void *)&cmd_setfwd_retry_mode,
6955 (void *)&cmd_setfwd_retry_retry,
6960 static void cmd_set_fwd_retry_mode_init(void)
6963 static char token[128];
6964 static char help[256];
6965 cmdline_parse_token_string_t *token_struct;
6967 modes = list_pkt_forwarding_retry_modes();
6968 snprintf(help, sizeof(help), "set fwd %s retry: "
6969 "Set packet forwarding mode with retry", modes);
6970 cmd_set_fwd_retry_mode.help_str = help;
6972 /* string token separator is # */
6973 for (c = token; *modes != '\0'; modes++)
6978 token_struct = (cmdline_parse_token_string_t *)
6979 cmd_set_fwd_retry_mode.tokens[2];
6980 token_struct->string_data.str = token;
6983 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6984 struct cmd_set_burst_tx_retry_result {
6985 cmdline_fixed_string_t set;
6986 cmdline_fixed_string_t burst;
6987 cmdline_fixed_string_t tx;
6988 cmdline_fixed_string_t delay;
6990 cmdline_fixed_string_t retry;
6994 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6995 __rte_unused struct cmdline *cl,
6996 __rte_unused void *data)
6998 struct cmd_set_burst_tx_retry_result *res = parsed_result;
7000 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
7001 && !strcmp(res->tx, "tx")) {
7002 if (!strcmp(res->delay, "delay"))
7003 burst_tx_delay_time = res->time;
7004 if (!strcmp(res->retry, "retry"))
7005 burst_tx_retry_num = res->retry_num;
7010 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
7011 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
7012 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
7013 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
7015 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
7016 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
7017 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
7018 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
7019 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
7020 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
7022 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
7023 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
7024 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
7025 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
7028 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
7029 .f = cmd_set_burst_tx_retry_parsed,
7030 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
7032 (void *)&cmd_set_burst_tx_retry_set,
7033 (void *)&cmd_set_burst_tx_retry_burst,
7034 (void *)&cmd_set_burst_tx_retry_tx,
7035 (void *)&cmd_set_burst_tx_retry_delay,
7036 (void *)&cmd_set_burst_tx_retry_time,
7037 (void *)&cmd_set_burst_tx_retry_retry,
7038 (void *)&cmd_set_burst_tx_retry_retry_num,
7043 /* *** SET PROMISC MODE *** */
7044 struct cmd_set_promisc_mode_result {
7045 cmdline_fixed_string_t set;
7046 cmdline_fixed_string_t promisc;
7047 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
7048 uint16_t port_num; /* valid if "allports" argument == 0 */
7049 cmdline_fixed_string_t mode;
7052 static void cmd_set_promisc_mode_parsed(void *parsed_result,
7053 __rte_unused struct cmdline *cl,
7056 struct cmd_set_promisc_mode_result *res = parsed_result;
7060 if (!strcmp(res->mode, "on"))
7067 RTE_ETH_FOREACH_DEV(i)
7068 eth_set_promisc_mode(i, enable);
7070 eth_set_promisc_mode(res->port_num, enable);
7074 cmdline_parse_token_string_t cmd_setpromisc_set =
7075 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
7076 cmdline_parse_token_string_t cmd_setpromisc_promisc =
7077 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
7079 cmdline_parse_token_string_t cmd_setpromisc_portall =
7080 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
7082 cmdline_parse_token_num_t cmd_setpromisc_portnum =
7083 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
7085 cmdline_parse_token_string_t cmd_setpromisc_mode =
7086 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
7089 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
7090 .f = cmd_set_promisc_mode_parsed,
7092 .help_str = "set promisc all on|off: Set promisc mode for all ports",
7094 (void *)&cmd_setpromisc_set,
7095 (void *)&cmd_setpromisc_promisc,
7096 (void *)&cmd_setpromisc_portall,
7097 (void *)&cmd_setpromisc_mode,
7102 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
7103 .f = cmd_set_promisc_mode_parsed,
7105 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
7107 (void *)&cmd_setpromisc_set,
7108 (void *)&cmd_setpromisc_promisc,
7109 (void *)&cmd_setpromisc_portnum,
7110 (void *)&cmd_setpromisc_mode,
7115 /* *** SET ALLMULTI MODE *** */
7116 struct cmd_set_allmulti_mode_result {
7117 cmdline_fixed_string_t set;
7118 cmdline_fixed_string_t allmulti;
7119 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
7120 uint16_t port_num; /* valid if "allports" argument == 0 */
7121 cmdline_fixed_string_t mode;
7124 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
7125 __rte_unused struct cmdline *cl,
7128 struct cmd_set_allmulti_mode_result *res = parsed_result;
7132 if (!strcmp(res->mode, "on"))
7139 RTE_ETH_FOREACH_DEV(i) {
7140 eth_set_allmulticast_mode(i, enable);
7144 eth_set_allmulticast_mode(res->port_num, enable);
7148 cmdline_parse_token_string_t cmd_setallmulti_set =
7149 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
7150 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
7151 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
7153 cmdline_parse_token_string_t cmd_setallmulti_portall =
7154 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
7156 cmdline_parse_token_num_t cmd_setallmulti_portnum =
7157 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
7159 cmdline_parse_token_string_t cmd_setallmulti_mode =
7160 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
7163 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
7164 .f = cmd_set_allmulti_mode_parsed,
7166 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
7168 (void *)&cmd_setallmulti_set,
7169 (void *)&cmd_setallmulti_allmulti,
7170 (void *)&cmd_setallmulti_portall,
7171 (void *)&cmd_setallmulti_mode,
7176 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
7177 .f = cmd_set_allmulti_mode_parsed,
7179 .help_str = "set allmulti <port_id> on|off: "
7180 "Set allmulti mode on port_id",
7182 (void *)&cmd_setallmulti_set,
7183 (void *)&cmd_setallmulti_allmulti,
7184 (void *)&cmd_setallmulti_portnum,
7185 (void *)&cmd_setallmulti_mode,
7190 /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
7191 struct cmd_link_flow_ctrl_show {
7192 cmdline_fixed_string_t show;
7193 cmdline_fixed_string_t port;
7195 cmdline_fixed_string_t flow_ctrl;
7198 cmdline_parse_token_string_t cmd_lfc_show_show =
7199 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7201 cmdline_parse_token_string_t cmd_lfc_show_port =
7202 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7204 cmdline_parse_token_num_t cmd_lfc_show_portid =
7205 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
7206 port_id, RTE_UINT16);
7207 cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
7208 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7209 flow_ctrl, "flow_ctrl");
7212 cmd_link_flow_ctrl_show_parsed(void *parsed_result,
7213 __rte_unused struct cmdline *cl,
7214 __rte_unused void *data)
7216 struct cmd_link_flow_ctrl_show *res = parsed_result;
7217 static const char *info_border = "*********************";
7218 struct rte_eth_fc_conf fc_conf;
7219 bool rx_fc_en = false;
7220 bool tx_fc_en = false;
7223 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7226 "Failed to get current flow ctrl information: err = %d\n",
7231 if (fc_conf.mode == RTE_ETH_FC_RX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
7233 if (fc_conf.mode == RTE_ETH_FC_TX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
7236 printf("\n%s Flow control infos for port %-2d %s\n",
7237 info_border, res->port_id, info_border);
7238 printf("FC mode:\n");
7239 printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
7240 printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
7241 printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
7242 printf("Pause time: 0x%x\n", fc_conf.pause_time);
7243 printf("High waterline: 0x%x\n", fc_conf.high_water);
7244 printf("Low waterline: 0x%x\n", fc_conf.low_water);
7245 printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
7246 printf("Forward MAC control frames: %s\n",
7247 fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
7248 printf("\n%s************** End ***********%s\n",
7249 info_border, info_border);
7252 cmdline_parse_inst_t cmd_link_flow_control_show = {
7253 .f = cmd_link_flow_ctrl_show_parsed,
7255 .help_str = "show port <port_id> flow_ctrl",
7257 (void *)&cmd_lfc_show_show,
7258 (void *)&cmd_lfc_show_port,
7259 (void *)&cmd_lfc_show_portid,
7260 (void *)&cmd_lfc_show_flow_ctrl,
7265 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
7266 struct cmd_link_flow_ctrl_set_result {
7267 cmdline_fixed_string_t set;
7268 cmdline_fixed_string_t flow_ctrl;
7269 cmdline_fixed_string_t rx;
7270 cmdline_fixed_string_t rx_lfc_mode;
7271 cmdline_fixed_string_t tx;
7272 cmdline_fixed_string_t tx_lfc_mode;
7273 cmdline_fixed_string_t mac_ctrl_frame_fwd;
7274 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
7275 cmdline_fixed_string_t autoneg_str;
7276 cmdline_fixed_string_t autoneg;
7277 cmdline_fixed_string_t hw_str;
7278 uint32_t high_water;
7279 cmdline_fixed_string_t lw_str;
7281 cmdline_fixed_string_t pt_str;
7282 uint16_t pause_time;
7283 cmdline_fixed_string_t xon_str;
7288 cmdline_parse_token_string_t cmd_lfc_set_set =
7289 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7291 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
7292 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7293 flow_ctrl, "flow_ctrl");
7294 cmdline_parse_token_string_t cmd_lfc_set_rx =
7295 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7297 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
7298 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7299 rx_lfc_mode, "on#off");
7300 cmdline_parse_token_string_t cmd_lfc_set_tx =
7301 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7303 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7304 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7305 tx_lfc_mode, "on#off");
7306 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7307 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7308 hw_str, "high_water");
7309 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7310 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7311 high_water, RTE_UINT32);
7312 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7313 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7314 lw_str, "low_water");
7315 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7316 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7317 low_water, RTE_UINT32);
7318 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7319 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7320 pt_str, "pause_time");
7321 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7322 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7323 pause_time, RTE_UINT16);
7324 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7325 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7326 xon_str, "send_xon");
7327 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7328 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7329 send_xon, RTE_UINT16);
7330 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7331 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7332 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7333 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7334 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7335 mac_ctrl_frame_fwd_mode, "on#off");
7336 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7337 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7338 autoneg_str, "autoneg");
7339 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7340 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7342 cmdline_parse_token_num_t cmd_lfc_set_portid =
7343 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7344 port_id, RTE_UINT16);
7346 /* forward declaration */
7348 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7351 cmdline_parse_inst_t cmd_link_flow_control_set = {
7352 .f = cmd_link_flow_ctrl_set_parsed,
7354 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7355 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7356 "autoneg on|off <port_id>: Configure the Ethernet flow control",
7358 (void *)&cmd_lfc_set_set,
7359 (void *)&cmd_lfc_set_flow_ctrl,
7360 (void *)&cmd_lfc_set_rx,
7361 (void *)&cmd_lfc_set_rx_mode,
7362 (void *)&cmd_lfc_set_tx,
7363 (void *)&cmd_lfc_set_tx_mode,
7364 (void *)&cmd_lfc_set_high_water,
7365 (void *)&cmd_lfc_set_low_water,
7366 (void *)&cmd_lfc_set_pause_time,
7367 (void *)&cmd_lfc_set_send_xon,
7368 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7369 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7370 (void *)&cmd_lfc_set_autoneg_str,
7371 (void *)&cmd_lfc_set_autoneg,
7372 (void *)&cmd_lfc_set_portid,
7377 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7378 .f = cmd_link_flow_ctrl_set_parsed,
7379 .data = (void *)&cmd_link_flow_control_set_rx,
7380 .help_str = "set flow_ctrl rx on|off <port_id>: "
7381 "Change rx flow control parameter",
7383 (void *)&cmd_lfc_set_set,
7384 (void *)&cmd_lfc_set_flow_ctrl,
7385 (void *)&cmd_lfc_set_rx,
7386 (void *)&cmd_lfc_set_rx_mode,
7387 (void *)&cmd_lfc_set_portid,
7392 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7393 .f = cmd_link_flow_ctrl_set_parsed,
7394 .data = (void *)&cmd_link_flow_control_set_tx,
7395 .help_str = "set flow_ctrl tx on|off <port_id>: "
7396 "Change tx flow control parameter",
7398 (void *)&cmd_lfc_set_set,
7399 (void *)&cmd_lfc_set_flow_ctrl,
7400 (void *)&cmd_lfc_set_tx,
7401 (void *)&cmd_lfc_set_tx_mode,
7402 (void *)&cmd_lfc_set_portid,
7407 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7408 .f = cmd_link_flow_ctrl_set_parsed,
7409 .data = (void *)&cmd_link_flow_control_set_hw,
7410 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7411 "Change high water flow control parameter",
7413 (void *)&cmd_lfc_set_set,
7414 (void *)&cmd_lfc_set_flow_ctrl,
7415 (void *)&cmd_lfc_set_high_water_str,
7416 (void *)&cmd_lfc_set_high_water,
7417 (void *)&cmd_lfc_set_portid,
7422 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7423 .f = cmd_link_flow_ctrl_set_parsed,
7424 .data = (void *)&cmd_link_flow_control_set_lw,
7425 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7426 "Change low water flow control parameter",
7428 (void *)&cmd_lfc_set_set,
7429 (void *)&cmd_lfc_set_flow_ctrl,
7430 (void *)&cmd_lfc_set_low_water_str,
7431 (void *)&cmd_lfc_set_low_water,
7432 (void *)&cmd_lfc_set_portid,
7437 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7438 .f = cmd_link_flow_ctrl_set_parsed,
7439 .data = (void *)&cmd_link_flow_control_set_pt,
7440 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7441 "Change pause time flow control parameter",
7443 (void *)&cmd_lfc_set_set,
7444 (void *)&cmd_lfc_set_flow_ctrl,
7445 (void *)&cmd_lfc_set_pause_time_str,
7446 (void *)&cmd_lfc_set_pause_time,
7447 (void *)&cmd_lfc_set_portid,
7452 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7453 .f = cmd_link_flow_ctrl_set_parsed,
7454 .data = (void *)&cmd_link_flow_control_set_xon,
7455 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7456 "Change send_xon flow control parameter",
7458 (void *)&cmd_lfc_set_set,
7459 (void *)&cmd_lfc_set_flow_ctrl,
7460 (void *)&cmd_lfc_set_send_xon_str,
7461 (void *)&cmd_lfc_set_send_xon,
7462 (void *)&cmd_lfc_set_portid,
7467 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7468 .f = cmd_link_flow_ctrl_set_parsed,
7469 .data = (void *)&cmd_link_flow_control_set_macfwd,
7470 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7471 "Change mac ctrl fwd flow control parameter",
7473 (void *)&cmd_lfc_set_set,
7474 (void *)&cmd_lfc_set_flow_ctrl,
7475 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7476 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7477 (void *)&cmd_lfc_set_portid,
7482 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7483 .f = cmd_link_flow_ctrl_set_parsed,
7484 .data = (void *)&cmd_link_flow_control_set_autoneg,
7485 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7486 "Change autoneg flow control parameter",
7488 (void *)&cmd_lfc_set_set,
7489 (void *)&cmd_lfc_set_flow_ctrl,
7490 (void *)&cmd_lfc_set_autoneg_str,
7491 (void *)&cmd_lfc_set_autoneg,
7492 (void *)&cmd_lfc_set_portid,
7498 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7499 __rte_unused struct cmdline *cl,
7502 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7503 cmdline_parse_inst_t *cmd = data;
7504 struct rte_eth_fc_conf fc_conf;
7510 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7511 * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7512 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7513 * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7515 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7516 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7519 /* Partial command line, retrieve current configuration */
7521 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7524 "cannot get current flow ctrl parameters, return code = %d\n",
7529 if ((fc_conf.mode == RTE_ETH_FC_RX_PAUSE) ||
7530 (fc_conf.mode == RTE_ETH_FC_FULL))
7532 if ((fc_conf.mode == RTE_ETH_FC_TX_PAUSE) ||
7533 (fc_conf.mode == RTE_ETH_FC_FULL))
7537 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7538 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7540 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7541 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7543 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7545 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7546 fc_conf.high_water = res->high_water;
7548 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7549 fc_conf.low_water = res->low_water;
7551 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7552 fc_conf.pause_time = res->pause_time;
7554 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7555 fc_conf.send_xon = res->send_xon;
7557 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7558 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7559 fc_conf.mac_ctrl_frame_fwd = 1;
7561 fc_conf.mac_ctrl_frame_fwd = 0;
7564 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7565 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7567 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7570 "bad flow control parameter, return code = %d\n",
7574 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7575 struct cmd_priority_flow_ctrl_set_result {
7576 cmdline_fixed_string_t set;
7577 cmdline_fixed_string_t pfc_ctrl;
7578 cmdline_fixed_string_t rx;
7579 cmdline_fixed_string_t rx_pfc_mode;
7580 cmdline_fixed_string_t tx;
7581 cmdline_fixed_string_t tx_pfc_mode;
7582 uint32_t high_water;
7584 uint16_t pause_time;
7590 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7591 __rte_unused struct cmdline *cl,
7592 __rte_unused void *data)
7594 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7595 struct rte_eth_pfc_conf pfc_conf;
7596 int rx_fc_enable, tx_fc_enable;
7600 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7601 * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7602 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7603 * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7605 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7606 {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7609 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7610 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7611 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7612 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7613 pfc_conf.fc.high_water = res->high_water;
7614 pfc_conf.fc.low_water = res->low_water;
7615 pfc_conf.fc.pause_time = res->pause_time;
7616 pfc_conf.priority = res->priority;
7618 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7621 "bad priority flow control parameter, return code = %d\n",
7625 cmdline_parse_token_string_t cmd_pfc_set_set =
7626 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7628 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7629 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7630 pfc_ctrl, "pfc_ctrl");
7631 cmdline_parse_token_string_t cmd_pfc_set_rx =
7632 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7634 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7635 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7636 rx_pfc_mode, "on#off");
7637 cmdline_parse_token_string_t cmd_pfc_set_tx =
7638 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7640 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7641 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7642 tx_pfc_mode, "on#off");
7643 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7644 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7645 high_water, RTE_UINT32);
7646 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7647 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7648 low_water, RTE_UINT32);
7649 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7650 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7651 pause_time, RTE_UINT16);
7652 cmdline_parse_token_num_t cmd_pfc_set_priority =
7653 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7654 priority, RTE_UINT8);
7655 cmdline_parse_token_num_t cmd_pfc_set_portid =
7656 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7657 port_id, RTE_UINT16);
7659 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7660 .f = cmd_priority_flow_ctrl_set_parsed,
7662 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7663 "<pause_time> <priority> <port_id>: "
7664 "Configure the Ethernet priority flow control",
7666 (void *)&cmd_pfc_set_set,
7667 (void *)&cmd_pfc_set_flow_ctrl,
7668 (void *)&cmd_pfc_set_rx,
7669 (void *)&cmd_pfc_set_rx_mode,
7670 (void *)&cmd_pfc_set_tx,
7671 (void *)&cmd_pfc_set_tx_mode,
7672 (void *)&cmd_pfc_set_high_water,
7673 (void *)&cmd_pfc_set_low_water,
7674 (void *)&cmd_pfc_set_pause_time,
7675 (void *)&cmd_pfc_set_priority,
7676 (void *)&cmd_pfc_set_portid,
7681 /* *** RESET CONFIGURATION *** */
7682 struct cmd_reset_result {
7683 cmdline_fixed_string_t reset;
7684 cmdline_fixed_string_t def;
7687 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7689 __rte_unused void *data)
7691 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7692 set_def_fwd_config();
7695 cmdline_parse_token_string_t cmd_reset_set =
7696 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7697 cmdline_parse_token_string_t cmd_reset_def =
7698 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7701 cmdline_parse_inst_t cmd_reset = {
7702 .f = cmd_reset_parsed,
7704 .help_str = "set default: Reset default forwarding configuration",
7706 (void *)&cmd_reset_set,
7707 (void *)&cmd_reset_def,
7712 /* *** START FORWARDING *** */
7713 struct cmd_start_result {
7714 cmdline_fixed_string_t start;
7717 cmdline_parse_token_string_t cmd_start_start =
7718 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7720 static void cmd_start_parsed(__rte_unused void *parsed_result,
7721 __rte_unused struct cmdline *cl,
7722 __rte_unused void *data)
7724 start_packet_forwarding(0);
7727 cmdline_parse_inst_t cmd_start = {
7728 .f = cmd_start_parsed,
7730 .help_str = "start: Start packet forwarding",
7732 (void *)&cmd_start_start,
7737 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7738 struct cmd_start_tx_first_result {
7739 cmdline_fixed_string_t start;
7740 cmdline_fixed_string_t tx_first;
7744 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7745 __rte_unused struct cmdline *cl,
7746 __rte_unused void *data)
7748 start_packet_forwarding(1);
7751 cmdline_parse_token_string_t cmd_start_tx_first_start =
7752 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7754 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7755 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7756 tx_first, "tx_first");
7758 cmdline_parse_inst_t cmd_start_tx_first = {
7759 .f = cmd_start_tx_first_parsed,
7761 .help_str = "start tx_first: Start packet forwarding, "
7762 "after sending 1 burst of packets",
7764 (void *)&cmd_start_tx_first_start,
7765 (void *)&cmd_start_tx_first_tx_first,
7770 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7771 struct cmd_start_tx_first_n_result {
7772 cmdline_fixed_string_t start;
7773 cmdline_fixed_string_t tx_first;
7778 cmd_start_tx_first_n_parsed(void *parsed_result,
7779 __rte_unused struct cmdline *cl,
7780 __rte_unused void *data)
7782 struct cmd_start_tx_first_n_result *res = parsed_result;
7784 start_packet_forwarding(res->tx_num);
7787 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7788 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7790 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7791 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7792 tx_first, "tx_first");
7793 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7794 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7795 tx_num, RTE_UINT32);
7797 cmdline_parse_inst_t cmd_start_tx_first_n = {
7798 .f = cmd_start_tx_first_n_parsed,
7800 .help_str = "start tx_first <num>: "
7801 "packet forwarding, after sending <num> bursts of packets",
7803 (void *)&cmd_start_tx_first_n_start,
7804 (void *)&cmd_start_tx_first_n_tx_first,
7805 (void *)&cmd_start_tx_first_n_tx_num,
7810 /* *** SET LINK UP *** */
7811 struct cmd_set_link_up_result {
7812 cmdline_fixed_string_t set;
7813 cmdline_fixed_string_t link_up;
7814 cmdline_fixed_string_t port;
7818 cmdline_parse_token_string_t cmd_set_link_up_set =
7819 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7820 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7821 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7823 cmdline_parse_token_string_t cmd_set_link_up_port =
7824 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7825 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7826 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7829 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7830 __rte_unused struct cmdline *cl,
7831 __rte_unused void *data)
7833 struct cmd_set_link_up_result *res = parsed_result;
7834 dev_set_link_up(res->port_id);
7837 cmdline_parse_inst_t cmd_set_link_up = {
7838 .f = cmd_set_link_up_parsed,
7840 .help_str = "set link-up port <port id>",
7842 (void *)&cmd_set_link_up_set,
7843 (void *)&cmd_set_link_up_link_up,
7844 (void *)&cmd_set_link_up_port,
7845 (void *)&cmd_set_link_up_port_id,
7850 /* *** SET LINK DOWN *** */
7851 struct cmd_set_link_down_result {
7852 cmdline_fixed_string_t set;
7853 cmdline_fixed_string_t link_down;
7854 cmdline_fixed_string_t port;
7858 cmdline_parse_token_string_t cmd_set_link_down_set =
7859 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7860 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7861 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7863 cmdline_parse_token_string_t cmd_set_link_down_port =
7864 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7865 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7866 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7869 static void cmd_set_link_down_parsed(
7870 __rte_unused void *parsed_result,
7871 __rte_unused struct cmdline *cl,
7872 __rte_unused void *data)
7874 struct cmd_set_link_down_result *res = parsed_result;
7875 dev_set_link_down(res->port_id);
7878 cmdline_parse_inst_t cmd_set_link_down = {
7879 .f = cmd_set_link_down_parsed,
7881 .help_str = "set link-down port <port id>",
7883 (void *)&cmd_set_link_down_set,
7884 (void *)&cmd_set_link_down_link_down,
7885 (void *)&cmd_set_link_down_port,
7886 (void *)&cmd_set_link_down_port_id,
7891 /* *** SHOW CFG *** */
7892 struct cmd_showcfg_result {
7893 cmdline_fixed_string_t show;
7894 cmdline_fixed_string_t cfg;
7895 cmdline_fixed_string_t what;
7898 static void cmd_showcfg_parsed(void *parsed_result,
7899 __rte_unused struct cmdline *cl,
7900 __rte_unused void *data)
7902 struct cmd_showcfg_result *res = parsed_result;
7903 if (!strcmp(res->what, "rxtx"))
7904 rxtx_config_display();
7905 else if (!strcmp(res->what, "cores"))
7906 fwd_lcores_config_display();
7907 else if (!strcmp(res->what, "fwd"))
7908 pkt_fwd_config_display(&cur_fwd_config);
7909 else if (!strcmp(res->what, "rxoffs"))
7910 show_rx_pkt_offsets();
7911 else if (!strcmp(res->what, "rxpkts"))
7912 show_rx_pkt_segments();
7913 else if (!strcmp(res->what, "txpkts"))
7914 show_tx_pkt_segments();
7915 else if (!strcmp(res->what, "txtimes"))
7916 show_tx_pkt_times();
7919 cmdline_parse_token_string_t cmd_showcfg_show =
7920 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7921 cmdline_parse_token_string_t cmd_showcfg_port =
7922 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7923 cmdline_parse_token_string_t cmd_showcfg_what =
7924 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7925 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7927 cmdline_parse_inst_t cmd_showcfg = {
7928 .f = cmd_showcfg_parsed,
7930 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7932 (void *)&cmd_showcfg_show,
7933 (void *)&cmd_showcfg_port,
7934 (void *)&cmd_showcfg_what,
7939 /* *** SHOW ALL PORT INFO *** */
7940 struct cmd_showportall_result {
7941 cmdline_fixed_string_t show;
7942 cmdline_fixed_string_t port;
7943 cmdline_fixed_string_t what;
7944 cmdline_fixed_string_t all;
7947 static void cmd_showportall_parsed(void *parsed_result,
7948 __rte_unused struct cmdline *cl,
7949 __rte_unused void *data)
7953 struct cmd_showportall_result *res = parsed_result;
7954 if (!strcmp(res->show, "clear")) {
7955 if (!strcmp(res->what, "stats"))
7956 RTE_ETH_FOREACH_DEV(i)
7958 else if (!strcmp(res->what, "xstats"))
7959 RTE_ETH_FOREACH_DEV(i)
7960 nic_xstats_clear(i);
7961 } else if (!strcmp(res->what, "info"))
7962 RTE_ETH_FOREACH_DEV(i)
7963 port_infos_display(i);
7964 else if (!strcmp(res->what, "summary")) {
7965 port_summary_header_display();
7966 RTE_ETH_FOREACH_DEV(i)
7967 port_summary_display(i);
7969 else if (!strcmp(res->what, "stats"))
7970 RTE_ETH_FOREACH_DEV(i)
7971 nic_stats_display(i);
7972 else if (!strcmp(res->what, "xstats"))
7973 RTE_ETH_FOREACH_DEV(i)
7974 nic_xstats_display(i);
7975 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7976 else if (!strcmp(res->what, "fdir"))
7977 RTE_ETH_FOREACH_DEV(i)
7980 else if (!strcmp(res->what, "dcb_tc"))
7981 RTE_ETH_FOREACH_DEV(i)
7982 port_dcb_info_display(i);
7985 cmdline_parse_token_string_t cmd_showportall_show =
7986 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7988 cmdline_parse_token_string_t cmd_showportall_port =
7989 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7990 cmdline_parse_token_string_t cmd_showportall_what =
7991 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7992 "info#summary#stats#xstats#fdir#dcb_tc");
7993 cmdline_parse_token_string_t cmd_showportall_all =
7994 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7995 cmdline_parse_inst_t cmd_showportall = {
7996 .f = cmd_showportall_parsed,
7998 .help_str = "show|clear port "
7999 "info|summary|stats|xstats|fdir|dcb_tc all",
8001 (void *)&cmd_showportall_show,
8002 (void *)&cmd_showportall_port,
8003 (void *)&cmd_showportall_what,
8004 (void *)&cmd_showportall_all,
8009 /* *** SHOW PORT INFO *** */
8010 struct cmd_showport_result {
8011 cmdline_fixed_string_t show;
8012 cmdline_fixed_string_t port;
8013 cmdline_fixed_string_t what;
8017 static void cmd_showport_parsed(void *parsed_result,
8018 __rte_unused struct cmdline *cl,
8019 __rte_unused void *data)
8021 struct cmd_showport_result *res = parsed_result;
8022 if (!strcmp(res->show, "clear")) {
8023 if (!strcmp(res->what, "stats"))
8024 nic_stats_clear(res->portnum);
8025 else if (!strcmp(res->what, "xstats"))
8026 nic_xstats_clear(res->portnum);
8027 } else if (!strcmp(res->what, "info"))
8028 port_infos_display(res->portnum);
8029 else if (!strcmp(res->what, "summary")) {
8030 port_summary_header_display();
8031 port_summary_display(res->portnum);
8033 else if (!strcmp(res->what, "stats"))
8034 nic_stats_display(res->portnum);
8035 else if (!strcmp(res->what, "xstats"))
8036 nic_xstats_display(res->portnum);
8037 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
8038 else if (!strcmp(res->what, "fdir"))
8039 fdir_get_infos(res->portnum);
8041 else if (!strcmp(res->what, "dcb_tc"))
8042 port_dcb_info_display(res->portnum);
8045 cmdline_parse_token_string_t cmd_showport_show =
8046 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
8048 cmdline_parse_token_string_t cmd_showport_port =
8049 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
8050 cmdline_parse_token_string_t cmd_showport_what =
8051 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
8052 "info#summary#stats#xstats#fdir#dcb_tc");
8053 cmdline_parse_token_num_t cmd_showport_portnum =
8054 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
8056 cmdline_parse_inst_t cmd_showport = {
8057 .f = cmd_showport_parsed,
8059 .help_str = "show|clear port "
8060 "info|summary|stats|xstats|fdir|dcb_tc "
8063 (void *)&cmd_showport_show,
8064 (void *)&cmd_showport_port,
8065 (void *)&cmd_showport_what,
8066 (void *)&cmd_showport_portnum,
8071 /* *** show port representors information *** */
8072 struct cmd_representor_info_result {
8073 cmdline_fixed_string_t cmd_show;
8074 cmdline_fixed_string_t cmd_port;
8075 cmdline_fixed_string_t cmd_info;
8076 cmdline_fixed_string_t cmd_keyword;
8081 cmd_representor_info_parsed(void *parsed_result,
8082 __rte_unused struct cmdline *cl,
8083 __rte_unused void *data)
8085 struct cmd_representor_info_result *res = parsed_result;
8086 struct rte_eth_representor_info *info;
8087 struct rte_eth_representor_range *range;
8088 uint32_t range_diff;
8093 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
8094 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
8098 ret = rte_eth_representor_info_get(res->cmd_pid, NULL);
8101 "Failed to get the number of representor info ranges for port %hu: %s\n",
8102 res->cmd_pid, rte_strerror(-ret));
8107 info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0]));
8110 "Failed to allocate memory for representor info for port %hu\n",
8114 info->nb_ranges_alloc = num;
8116 ret = rte_eth_representor_info_get(res->cmd_pid, info);
8119 "Failed to get the representor info for port %hu: %s\n",
8120 res->cmd_pid, rte_strerror(-ret));
8125 printf("Port controller: %hu\n", info->controller);
8126 printf("Port PF: %hu\n", info->pf);
8128 printf("Ranges: %u\n", info->nb_ranges);
8129 for (i = 0; i < info->nb_ranges; i++) {
8130 range = &info->ranges[i];
8131 range_diff = range->id_end - range->id_base;
8133 printf("%u. ", i + 1);
8134 printf("'%s' ", range->name);
8136 printf("[%u-%u]: ", range->id_base, range->id_end);
8138 printf("[%u]: ", range->id_base);
8140 printf("Controller %d, PF %d", range->controller, range->pf);
8142 switch (range->type) {
8143 case RTE_ETH_REPRESENTOR_NONE:
8146 case RTE_ETH_REPRESENTOR_VF:
8148 printf(", VF %d..%d\n", range->vf,
8149 range->vf + range_diff);
8151 printf(", VF %d\n", range->vf);
8153 case RTE_ETH_REPRESENTOR_SF:
8154 printf(", SF %d\n", range->sf);
8156 case RTE_ETH_REPRESENTOR_PF:
8158 printf("..%d\n", range->pf + range_diff);
8163 printf(", UNKNOWN TYPE %d\n", range->type);
8171 cmdline_parse_token_string_t cmd_representor_info_show =
8172 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8174 cmdline_parse_token_string_t cmd_representor_info_port =
8175 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8177 cmdline_parse_token_string_t cmd_representor_info_info =
8178 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8180 cmdline_parse_token_num_t cmd_representor_info_pid =
8181 TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result,
8182 cmd_pid, RTE_UINT16);
8183 cmdline_parse_token_string_t cmd_representor_info_keyword =
8184 TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
8185 cmd_keyword, "representor");
8187 cmdline_parse_inst_t cmd_representor_info = {
8188 .f = cmd_representor_info_parsed,
8190 .help_str = "show port info <port_id> representor",
8192 (void *)&cmd_representor_info_show,
8193 (void *)&cmd_representor_info_port,
8194 (void *)&cmd_representor_info_info,
8195 (void *)&cmd_representor_info_pid,
8196 (void *)&cmd_representor_info_keyword,
8202 /* *** SHOW DEVICE INFO *** */
8203 struct cmd_showdevice_result {
8204 cmdline_fixed_string_t show;
8205 cmdline_fixed_string_t device;
8206 cmdline_fixed_string_t what;
8207 cmdline_fixed_string_t identifier;
8210 static void cmd_showdevice_parsed(void *parsed_result,
8211 __rte_unused struct cmdline *cl,
8212 __rte_unused void *data)
8214 struct cmd_showdevice_result *res = parsed_result;
8215 if (!strcmp(res->what, "info")) {
8216 if (!strcmp(res->identifier, "all"))
8217 device_infos_display(NULL);
8219 device_infos_display(res->identifier);
8223 cmdline_parse_token_string_t cmd_showdevice_show =
8224 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
8226 cmdline_parse_token_string_t cmd_showdevice_device =
8227 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
8228 cmdline_parse_token_string_t cmd_showdevice_what =
8229 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
8231 cmdline_parse_token_string_t cmd_showdevice_identifier =
8232 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
8235 cmdline_parse_inst_t cmd_showdevice = {
8236 .f = cmd_showdevice_parsed,
8238 .help_str = "show device info <identifier>|all",
8240 (void *)&cmd_showdevice_show,
8241 (void *)&cmd_showdevice_device,
8242 (void *)&cmd_showdevice_what,
8243 (void *)&cmd_showdevice_identifier,
8248 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
8249 struct cmd_showeeprom_result {
8250 cmdline_fixed_string_t show;
8251 cmdline_fixed_string_t port;
8253 cmdline_fixed_string_t type;
8256 static void cmd_showeeprom_parsed(void *parsed_result,
8257 __rte_unused struct cmdline *cl,
8258 __rte_unused void *data)
8260 struct cmd_showeeprom_result *res = parsed_result;
8262 if (!strcmp(res->type, "eeprom"))
8263 port_eeprom_display(res->portnum);
8264 else if (!strcmp(res->type, "module_eeprom"))
8265 port_module_eeprom_display(res->portnum);
8267 fprintf(stderr, "Unknown argument\n");
8270 cmdline_parse_token_string_t cmd_showeeprom_show =
8271 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
8272 cmdline_parse_token_string_t cmd_showeeprom_port =
8273 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
8274 cmdline_parse_token_num_t cmd_showeeprom_portnum =
8275 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
8277 cmdline_parse_token_string_t cmd_showeeprom_type =
8278 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
8280 cmdline_parse_inst_t cmd_showeeprom = {
8281 .f = cmd_showeeprom_parsed,
8283 .help_str = "show port <port_id> module_eeprom|eeprom",
8285 (void *)&cmd_showeeprom_show,
8286 (void *)&cmd_showeeprom_port,
8287 (void *)&cmd_showeeprom_portnum,
8288 (void *)&cmd_showeeprom_type,
8293 /* *** SHOW QUEUE INFO *** */
8294 struct cmd_showqueue_result {
8295 cmdline_fixed_string_t show;
8296 cmdline_fixed_string_t type;
8297 cmdline_fixed_string_t what;
8303 cmd_showqueue_parsed(void *parsed_result,
8304 __rte_unused struct cmdline *cl,
8305 __rte_unused void *data)
8307 struct cmd_showqueue_result *res = parsed_result;
8309 if (!strcmp(res->type, "rxq"))
8310 rx_queue_infos_display(res->portnum, res->queuenum);
8311 else if (!strcmp(res->type, "txq"))
8312 tx_queue_infos_display(res->portnum, res->queuenum);
8315 cmdline_parse_token_string_t cmd_showqueue_show =
8316 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
8317 cmdline_parse_token_string_t cmd_showqueue_type =
8318 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
8319 cmdline_parse_token_string_t cmd_showqueue_what =
8320 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
8321 cmdline_parse_token_num_t cmd_showqueue_portnum =
8322 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
8324 cmdline_parse_token_num_t cmd_showqueue_queuenum =
8325 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
8328 cmdline_parse_inst_t cmd_showqueue = {
8329 .f = cmd_showqueue_parsed,
8331 .help_str = "show rxq|txq info <port_id> <queue_id>",
8333 (void *)&cmd_showqueue_show,
8334 (void *)&cmd_showqueue_type,
8335 (void *)&cmd_showqueue_what,
8336 (void *)&cmd_showqueue_portnum,
8337 (void *)&cmd_showqueue_queuenum,
8342 /* show/clear fwd engine statistics */
8344 cmdline_fixed_string_t action;
8345 cmdline_fixed_string_t fwd;
8346 cmdline_fixed_string_t stats;
8347 cmdline_fixed_string_t all;
8350 cmdline_parse_token_string_t cmd_fwd_action =
8351 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
8352 cmdline_parse_token_string_t cmd_fwd_fwd =
8353 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
8354 cmdline_parse_token_string_t cmd_fwd_stats =
8355 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
8356 cmdline_parse_token_string_t cmd_fwd_all =
8357 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
8360 cmd_showfwdall_parsed(void *parsed_result,
8361 __rte_unused struct cmdline *cl,
8362 __rte_unused void *data)
8364 struct fwd_result *res = parsed_result;
8366 if (!strcmp(res->action, "show"))
8367 fwd_stats_display();
8372 static cmdline_parse_inst_t cmd_showfwdall = {
8373 .f = cmd_showfwdall_parsed,
8375 .help_str = "show|clear fwd stats all",
8377 (void *)&cmd_fwd_action,
8378 (void *)&cmd_fwd_fwd,
8379 (void *)&cmd_fwd_stats,
8380 (void *)&cmd_fwd_all,
8385 /* *** READ PORT REGISTER *** */
8386 struct cmd_read_reg_result {
8387 cmdline_fixed_string_t read;
8388 cmdline_fixed_string_t reg;
8394 cmd_read_reg_parsed(void *parsed_result,
8395 __rte_unused struct cmdline *cl,
8396 __rte_unused void *data)
8398 struct cmd_read_reg_result *res = parsed_result;
8399 port_reg_display(res->port_id, res->reg_off);
8402 cmdline_parse_token_string_t cmd_read_reg_read =
8403 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
8404 cmdline_parse_token_string_t cmd_read_reg_reg =
8405 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
8406 cmdline_parse_token_num_t cmd_read_reg_port_id =
8407 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
8408 cmdline_parse_token_num_t cmd_read_reg_reg_off =
8409 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
8411 cmdline_parse_inst_t cmd_read_reg = {
8412 .f = cmd_read_reg_parsed,
8414 .help_str = "read reg <port_id> <reg_off>",
8416 (void *)&cmd_read_reg_read,
8417 (void *)&cmd_read_reg_reg,
8418 (void *)&cmd_read_reg_port_id,
8419 (void *)&cmd_read_reg_reg_off,
8424 /* *** READ PORT REGISTER BIT FIELD *** */
8425 struct cmd_read_reg_bit_field_result {
8426 cmdline_fixed_string_t read;
8427 cmdline_fixed_string_t regfield;
8435 cmd_read_reg_bit_field_parsed(void *parsed_result,
8436 __rte_unused struct cmdline *cl,
8437 __rte_unused void *data)
8439 struct cmd_read_reg_bit_field_result *res = parsed_result;
8440 port_reg_bit_field_display(res->port_id, res->reg_off,
8441 res->bit1_pos, res->bit2_pos);
8444 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8445 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8447 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8448 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8449 regfield, "regfield");
8450 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8451 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8453 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8454 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8456 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8457 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8459 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8460 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8463 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8464 .f = cmd_read_reg_bit_field_parsed,
8466 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8467 "Read register bit field between bit_x and bit_y included",
8469 (void *)&cmd_read_reg_bit_field_read,
8470 (void *)&cmd_read_reg_bit_field_regfield,
8471 (void *)&cmd_read_reg_bit_field_port_id,
8472 (void *)&cmd_read_reg_bit_field_reg_off,
8473 (void *)&cmd_read_reg_bit_field_bit1_pos,
8474 (void *)&cmd_read_reg_bit_field_bit2_pos,
8479 /* *** READ PORT REGISTER BIT *** */
8480 struct cmd_read_reg_bit_result {
8481 cmdline_fixed_string_t read;
8482 cmdline_fixed_string_t regbit;
8489 cmd_read_reg_bit_parsed(void *parsed_result,
8490 __rte_unused struct cmdline *cl,
8491 __rte_unused void *data)
8493 struct cmd_read_reg_bit_result *res = parsed_result;
8494 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8497 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8498 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8499 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8500 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8502 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8503 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
8505 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8506 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
8508 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8509 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
8512 cmdline_parse_inst_t cmd_read_reg_bit = {
8513 .f = cmd_read_reg_bit_parsed,
8515 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8517 (void *)&cmd_read_reg_bit_read,
8518 (void *)&cmd_read_reg_bit_regbit,
8519 (void *)&cmd_read_reg_bit_port_id,
8520 (void *)&cmd_read_reg_bit_reg_off,
8521 (void *)&cmd_read_reg_bit_bit_pos,
8526 /* *** WRITE PORT REGISTER *** */
8527 struct cmd_write_reg_result {
8528 cmdline_fixed_string_t write;
8529 cmdline_fixed_string_t reg;
8536 cmd_write_reg_parsed(void *parsed_result,
8537 __rte_unused struct cmdline *cl,
8538 __rte_unused void *data)
8540 struct cmd_write_reg_result *res = parsed_result;
8541 port_reg_set(res->port_id, res->reg_off, res->value);
8544 cmdline_parse_token_string_t cmd_write_reg_write =
8545 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8546 cmdline_parse_token_string_t cmd_write_reg_reg =
8547 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8548 cmdline_parse_token_num_t cmd_write_reg_port_id =
8549 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8550 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8551 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8552 cmdline_parse_token_num_t cmd_write_reg_value =
8553 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8555 cmdline_parse_inst_t cmd_write_reg = {
8556 .f = cmd_write_reg_parsed,
8558 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8560 (void *)&cmd_write_reg_write,
8561 (void *)&cmd_write_reg_reg,
8562 (void *)&cmd_write_reg_port_id,
8563 (void *)&cmd_write_reg_reg_off,
8564 (void *)&cmd_write_reg_value,
8569 /* *** WRITE PORT REGISTER BIT FIELD *** */
8570 struct cmd_write_reg_bit_field_result {
8571 cmdline_fixed_string_t write;
8572 cmdline_fixed_string_t regfield;
8581 cmd_write_reg_bit_field_parsed(void *parsed_result,
8582 __rte_unused struct cmdline *cl,
8583 __rte_unused void *data)
8585 struct cmd_write_reg_bit_field_result *res = parsed_result;
8586 port_reg_bit_field_set(res->port_id, res->reg_off,
8587 res->bit1_pos, res->bit2_pos, res->value);
8590 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8591 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8593 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8594 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8595 regfield, "regfield");
8596 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8597 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8599 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8600 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8602 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8603 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8605 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8606 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8608 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8609 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8612 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8613 .f = cmd_write_reg_bit_field_parsed,
8615 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8617 "Set register bit field between bit_x and bit_y included",
8619 (void *)&cmd_write_reg_bit_field_write,
8620 (void *)&cmd_write_reg_bit_field_regfield,
8621 (void *)&cmd_write_reg_bit_field_port_id,
8622 (void *)&cmd_write_reg_bit_field_reg_off,
8623 (void *)&cmd_write_reg_bit_field_bit1_pos,
8624 (void *)&cmd_write_reg_bit_field_bit2_pos,
8625 (void *)&cmd_write_reg_bit_field_value,
8630 /* *** WRITE PORT REGISTER BIT *** */
8631 struct cmd_write_reg_bit_result {
8632 cmdline_fixed_string_t write;
8633 cmdline_fixed_string_t regbit;
8641 cmd_write_reg_bit_parsed(void *parsed_result,
8642 __rte_unused struct cmdline *cl,
8643 __rte_unused void *data)
8645 struct cmd_write_reg_bit_result *res = parsed_result;
8646 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8649 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8650 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8652 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8653 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8655 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8656 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8658 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8659 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8661 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8662 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8664 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8665 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8668 cmdline_parse_inst_t cmd_write_reg_bit = {
8669 .f = cmd_write_reg_bit_parsed,
8671 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8674 (void *)&cmd_write_reg_bit_write,
8675 (void *)&cmd_write_reg_bit_regbit,
8676 (void *)&cmd_write_reg_bit_port_id,
8677 (void *)&cmd_write_reg_bit_reg_off,
8678 (void *)&cmd_write_reg_bit_bit_pos,
8679 (void *)&cmd_write_reg_bit_value,
8684 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8685 struct cmd_read_rxd_txd_result {
8686 cmdline_fixed_string_t read;
8687 cmdline_fixed_string_t rxd_txd;
8694 cmd_read_rxd_txd_parsed(void *parsed_result,
8695 __rte_unused struct cmdline *cl,
8696 __rte_unused void *data)
8698 struct cmd_read_rxd_txd_result *res = parsed_result;
8700 if (!strcmp(res->rxd_txd, "rxd"))
8701 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8702 else if (!strcmp(res->rxd_txd, "txd"))
8703 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8706 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8707 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8708 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8709 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8711 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8712 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8714 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8715 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8717 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8718 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8721 cmdline_parse_inst_t cmd_read_rxd_txd = {
8722 .f = cmd_read_rxd_txd_parsed,
8724 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8726 (void *)&cmd_read_rxd_txd_read,
8727 (void *)&cmd_read_rxd_txd_rxd_txd,
8728 (void *)&cmd_read_rxd_txd_port_id,
8729 (void *)&cmd_read_rxd_txd_queue_id,
8730 (void *)&cmd_read_rxd_txd_desc_id,
8736 struct cmd_quit_result {
8737 cmdline_fixed_string_t quit;
8740 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8742 __rte_unused void *data)
8747 cmdline_parse_token_string_t cmd_quit_quit =
8748 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8750 cmdline_parse_inst_t cmd_quit = {
8751 .f = cmd_quit_parsed,
8753 .help_str = "quit: Exit application",
8755 (void *)&cmd_quit_quit,
8760 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8761 struct cmd_mac_addr_result {
8762 cmdline_fixed_string_t mac_addr_cmd;
8763 cmdline_fixed_string_t what;
8765 struct rte_ether_addr address;
8768 static void cmd_mac_addr_parsed(void *parsed_result,
8769 __rte_unused struct cmdline *cl,
8770 __rte_unused void *data)
8772 struct cmd_mac_addr_result *res = parsed_result;
8775 if (strcmp(res->what, "add") == 0)
8776 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8777 else if (strcmp(res->what, "set") == 0)
8778 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8781 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8783 /* check the return value and print it if is < 0 */
8785 fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
8789 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8790 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8792 cmdline_parse_token_string_t cmd_mac_addr_what =
8793 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8795 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8796 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8798 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8799 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8801 cmdline_parse_inst_t cmd_mac_addr = {
8802 .f = cmd_mac_addr_parsed,
8804 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8805 "Add/Remove/Set MAC address on port_id",
8807 (void *)&cmd_mac_addr_cmd,
8808 (void *)&cmd_mac_addr_what,
8809 (void *)&cmd_mac_addr_portnum,
8810 (void *)&cmd_mac_addr_addr,
8815 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8816 struct cmd_eth_peer_result {
8817 cmdline_fixed_string_t set;
8818 cmdline_fixed_string_t eth_peer;
8820 cmdline_fixed_string_t peer_addr;
8823 static void cmd_set_eth_peer_parsed(void *parsed_result,
8824 __rte_unused struct cmdline *cl,
8825 __rte_unused void *data)
8827 struct cmd_eth_peer_result *res = parsed_result;
8829 if (test_done == 0) {
8830 fprintf(stderr, "Please stop forwarding first\n");
8833 if (!strcmp(res->eth_peer, "eth-peer")) {
8834 set_fwd_eth_peer(res->port_id, res->peer_addr);
8838 cmdline_parse_token_string_t cmd_eth_peer_set =
8839 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8840 cmdline_parse_token_string_t cmd_eth_peer =
8841 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8842 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8843 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8845 cmdline_parse_token_string_t cmd_eth_peer_addr =
8846 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8848 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8849 .f = cmd_set_eth_peer_parsed,
8851 .help_str = "set eth-peer <port_id> <peer_mac>",
8853 (void *)&cmd_eth_peer_set,
8854 (void *)&cmd_eth_peer,
8855 (void *)&cmd_eth_peer_port_id,
8856 (void *)&cmd_eth_peer_addr,
8861 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8862 struct cmd_set_qmap_result {
8863 cmdline_fixed_string_t set;
8864 cmdline_fixed_string_t qmap;
8865 cmdline_fixed_string_t what;
8872 cmd_set_qmap_parsed(void *parsed_result,
8873 __rte_unused struct cmdline *cl,
8874 __rte_unused void *data)
8876 struct cmd_set_qmap_result *res = parsed_result;
8877 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8879 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8882 cmdline_parse_token_string_t cmd_setqmap_set =
8883 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8885 cmdline_parse_token_string_t cmd_setqmap_qmap =
8886 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8888 cmdline_parse_token_string_t cmd_setqmap_what =
8889 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8891 cmdline_parse_token_num_t cmd_setqmap_portid =
8892 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8893 port_id, RTE_UINT16);
8894 cmdline_parse_token_num_t cmd_setqmap_queueid =
8895 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8896 queue_id, RTE_UINT16);
8897 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8898 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8899 map_value, RTE_UINT8);
8901 cmdline_parse_inst_t cmd_set_qmap = {
8902 .f = cmd_set_qmap_parsed,
8904 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8905 "Set statistics mapping value on tx|rx queue_id of port_id",
8907 (void *)&cmd_setqmap_set,
8908 (void *)&cmd_setqmap_qmap,
8909 (void *)&cmd_setqmap_what,
8910 (void *)&cmd_setqmap_portid,
8911 (void *)&cmd_setqmap_queueid,
8912 (void *)&cmd_setqmap_mapvalue,
8917 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8918 struct cmd_set_xstats_hide_zero_result {
8919 cmdline_fixed_string_t keyword;
8920 cmdline_fixed_string_t name;
8921 cmdline_fixed_string_t on_off;
8925 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8926 __rte_unused struct cmdline *cl,
8927 __rte_unused void *data)
8929 struct cmd_set_xstats_hide_zero_result *res;
8930 uint16_t on_off = 0;
8932 res = parsed_result;
8933 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8934 set_xstats_hide_zero(on_off);
8937 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8938 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8940 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8941 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8942 name, "xstats-hide-zero");
8943 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8944 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8947 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8948 .f = cmd_set_xstats_hide_zero_parsed,
8950 .help_str = "set xstats-hide-zero on|off",
8952 (void *)&cmd_set_xstats_hide_zero_keyword,
8953 (void *)&cmd_set_xstats_hide_zero_name,
8954 (void *)&cmd_set_xstats_hide_zero_on_off,
8959 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8960 struct cmd_set_record_core_cycles_result {
8961 cmdline_fixed_string_t keyword;
8962 cmdline_fixed_string_t name;
8963 cmdline_fixed_string_t on_off;
8967 cmd_set_record_core_cycles_parsed(void *parsed_result,
8968 __rte_unused struct cmdline *cl,
8969 __rte_unused void *data)
8971 struct cmd_set_record_core_cycles_result *res;
8972 uint16_t on_off = 0;
8974 res = parsed_result;
8975 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8976 set_record_core_cycles(on_off);
8979 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8980 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8982 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8983 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8984 name, "record-core-cycles");
8985 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8986 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8989 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8990 .f = cmd_set_record_core_cycles_parsed,
8992 .help_str = "set record-core-cycles on|off",
8994 (void *)&cmd_set_record_core_cycles_keyword,
8995 (void *)&cmd_set_record_core_cycles_name,
8996 (void *)&cmd_set_record_core_cycles_on_off,
9001 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
9002 struct cmd_set_record_burst_stats_result {
9003 cmdline_fixed_string_t keyword;
9004 cmdline_fixed_string_t name;
9005 cmdline_fixed_string_t on_off;
9009 cmd_set_record_burst_stats_parsed(void *parsed_result,
9010 __rte_unused struct cmdline *cl,
9011 __rte_unused void *data)
9013 struct cmd_set_record_burst_stats_result *res;
9014 uint16_t on_off = 0;
9016 res = parsed_result;
9017 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
9018 set_record_burst_stats(on_off);
9021 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
9022 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9024 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
9025 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9026 name, "record-burst-stats");
9027 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
9028 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
9031 cmdline_parse_inst_t cmd_set_record_burst_stats = {
9032 .f = cmd_set_record_burst_stats_parsed,
9034 .help_str = "set record-burst-stats on|off",
9036 (void *)&cmd_set_record_burst_stats_keyword,
9037 (void *)&cmd_set_record_burst_stats_name,
9038 (void *)&cmd_set_record_burst_stats_on_off,
9043 /* *** CONFIGURE UNICAST HASH TABLE *** */
9044 struct cmd_set_uc_hash_table {
9045 cmdline_fixed_string_t set;
9046 cmdline_fixed_string_t port;
9048 cmdline_fixed_string_t what;
9049 struct rte_ether_addr address;
9050 cmdline_fixed_string_t mode;
9054 cmd_set_uc_hash_parsed(void *parsed_result,
9055 __rte_unused struct cmdline *cl,
9056 __rte_unused void *data)
9059 struct cmd_set_uc_hash_table *res = parsed_result;
9061 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9063 if (strcmp(res->what, "uta") == 0)
9064 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
9065 &res->address,(uint8_t)is_on);
9068 "bad unicast hash table parameter, return code = %d\n",
9073 cmdline_parse_token_string_t cmd_set_uc_hash_set =
9074 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9076 cmdline_parse_token_string_t cmd_set_uc_hash_port =
9077 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9079 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
9080 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
9081 port_id, RTE_UINT16);
9082 cmdline_parse_token_string_t cmd_set_uc_hash_what =
9083 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9085 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
9086 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
9088 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
9089 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
9092 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
9093 .f = cmd_set_uc_hash_parsed,
9095 .help_str = "set port <port_id> uta <mac_addr> on|off)",
9097 (void *)&cmd_set_uc_hash_set,
9098 (void *)&cmd_set_uc_hash_port,
9099 (void *)&cmd_set_uc_hash_portid,
9100 (void *)&cmd_set_uc_hash_what,
9101 (void *)&cmd_set_uc_hash_mac,
9102 (void *)&cmd_set_uc_hash_mode,
9107 struct cmd_set_uc_all_hash_table {
9108 cmdline_fixed_string_t set;
9109 cmdline_fixed_string_t port;
9111 cmdline_fixed_string_t what;
9112 cmdline_fixed_string_t value;
9113 cmdline_fixed_string_t mode;
9117 cmd_set_uc_all_hash_parsed(void *parsed_result,
9118 __rte_unused struct cmdline *cl,
9119 __rte_unused void *data)
9122 struct cmd_set_uc_all_hash_table *res = parsed_result;
9124 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9126 if ((strcmp(res->what, "uta") == 0) &&
9127 (strcmp(res->value, "all") == 0))
9128 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
9131 "bad unicast hash table parameter, return code = %d\n",
9135 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
9136 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9138 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
9139 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9141 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
9142 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
9143 port_id, RTE_UINT16);
9144 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
9145 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9147 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
9148 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9150 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
9151 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
9154 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
9155 .f = cmd_set_uc_all_hash_parsed,
9157 .help_str = "set port <port_id> uta all on|off",
9159 (void *)&cmd_set_uc_all_hash_set,
9160 (void *)&cmd_set_uc_all_hash_port,
9161 (void *)&cmd_set_uc_all_hash_portid,
9162 (void *)&cmd_set_uc_all_hash_what,
9163 (void *)&cmd_set_uc_all_hash_value,
9164 (void *)&cmd_set_uc_all_hash_mode,
9169 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
9170 struct cmd_set_vf_traffic {
9171 cmdline_fixed_string_t set;
9172 cmdline_fixed_string_t port;
9174 cmdline_fixed_string_t vf;
9176 cmdline_fixed_string_t what;
9177 cmdline_fixed_string_t mode;
9181 cmd_set_vf_traffic_parsed(void *parsed_result,
9182 __rte_unused struct cmdline *cl,
9183 __rte_unused void *data)
9185 struct cmd_set_vf_traffic *res = parsed_result;
9186 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
9187 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
9189 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
9192 cmdline_parse_token_string_t cmd_setvf_traffic_set =
9193 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9195 cmdline_parse_token_string_t cmd_setvf_traffic_port =
9196 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9198 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
9199 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9200 port_id, RTE_UINT16);
9201 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
9202 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9204 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
9205 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
9207 cmdline_parse_token_string_t cmd_setvf_traffic_what =
9208 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9210 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
9211 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
9214 cmdline_parse_inst_t cmd_set_vf_traffic = {
9215 .f = cmd_set_vf_traffic_parsed,
9217 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
9219 (void *)&cmd_setvf_traffic_set,
9220 (void *)&cmd_setvf_traffic_port,
9221 (void *)&cmd_setvf_traffic_portid,
9222 (void *)&cmd_setvf_traffic_vf,
9223 (void *)&cmd_setvf_traffic_vfid,
9224 (void *)&cmd_setvf_traffic_what,
9225 (void *)&cmd_setvf_traffic_mode,
9230 /* *** CONFIGURE VF RECEIVE MODE *** */
9231 struct cmd_set_vf_rxmode {
9232 cmdline_fixed_string_t set;
9233 cmdline_fixed_string_t port;
9235 cmdline_fixed_string_t vf;
9237 cmdline_fixed_string_t what;
9238 cmdline_fixed_string_t mode;
9239 cmdline_fixed_string_t on;
9243 cmd_set_vf_rxmode_parsed(void *parsed_result,
9244 __rte_unused struct cmdline *cl,
9245 __rte_unused void *data)
9248 uint16_t vf_rxmode = 0;
9249 struct cmd_set_vf_rxmode *res = parsed_result;
9251 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
9252 if (!strcmp(res->what,"rxmode")) {
9253 if (!strcmp(res->mode, "AUPE"))
9254 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_UNTAG;
9255 else if (!strcmp(res->mode, "ROPE"))
9256 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_HASH_UC;
9257 else if (!strcmp(res->mode, "BAM"))
9258 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_BROADCAST;
9259 else if (!strncmp(res->mode, "MPE",3))
9260 vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_MULTICAST;
9263 RTE_SET_USED(is_on);
9265 #ifdef RTE_NET_IXGBE
9266 if (ret == -ENOTSUP)
9267 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
9268 vf_rxmode, (uint8_t)is_on);
9271 if (ret == -ENOTSUP)
9272 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
9273 vf_rxmode, (uint8_t)is_on);
9277 "bad VF receive mode parameter, return code = %d\n",
9281 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
9282 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9284 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
9285 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9287 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
9288 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9289 port_id, RTE_UINT16);
9290 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
9291 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9293 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
9294 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9296 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
9297 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9299 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
9300 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9301 mode, "AUPE#ROPE#BAM#MPE");
9302 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
9303 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9306 cmdline_parse_inst_t cmd_set_vf_rxmode = {
9307 .f = cmd_set_vf_rxmode_parsed,
9309 .help_str = "set port <port_id> vf <vf_id> rxmode "
9310 "AUPE|ROPE|BAM|MPE on|off",
9312 (void *)&cmd_set_vf_rxmode_set,
9313 (void *)&cmd_set_vf_rxmode_port,
9314 (void *)&cmd_set_vf_rxmode_portid,
9315 (void *)&cmd_set_vf_rxmode_vf,
9316 (void *)&cmd_set_vf_rxmode_vfid,
9317 (void *)&cmd_set_vf_rxmode_what,
9318 (void *)&cmd_set_vf_rxmode_mode,
9319 (void *)&cmd_set_vf_rxmode_on,
9324 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
9325 struct cmd_vf_mac_addr_result {
9326 cmdline_fixed_string_t mac_addr_cmd;
9327 cmdline_fixed_string_t what;
9328 cmdline_fixed_string_t port;
9330 cmdline_fixed_string_t vf;
9332 struct rte_ether_addr address;
9335 static void cmd_vf_mac_addr_parsed(void *parsed_result,
9336 __rte_unused struct cmdline *cl,
9337 __rte_unused void *data)
9339 struct cmd_vf_mac_addr_result *res = parsed_result;
9342 if (strcmp(res->what, "add") != 0)
9346 if (ret == -ENOTSUP)
9347 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
9351 if (ret == -ENOTSUP)
9352 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
9357 fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
9361 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
9362 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9363 mac_addr_cmd,"mac_addr");
9364 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
9365 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9367 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
9368 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9370 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
9371 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9372 port_num, RTE_UINT16);
9373 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
9374 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9376 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
9377 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9379 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
9380 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
9383 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
9384 .f = cmd_vf_mac_addr_parsed,
9386 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
9387 "Add MAC address filtering for a VF on port_id",
9389 (void *)&cmd_vf_mac_addr_cmd,
9390 (void *)&cmd_vf_mac_addr_what,
9391 (void *)&cmd_vf_mac_addr_port,
9392 (void *)&cmd_vf_mac_addr_portnum,
9393 (void *)&cmd_vf_mac_addr_vf,
9394 (void *)&cmd_vf_mac_addr_vfnum,
9395 (void *)&cmd_vf_mac_addr_addr,
9400 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
9401 struct cmd_vf_rx_vlan_filter {
9402 cmdline_fixed_string_t rx_vlan;
9403 cmdline_fixed_string_t what;
9405 cmdline_fixed_string_t port;
9407 cmdline_fixed_string_t vf;
9412 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
9413 __rte_unused struct cmdline *cl,
9414 __rte_unused void *data)
9416 struct cmd_vf_rx_vlan_filter *res = parsed_result;
9419 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9421 #ifdef RTE_NET_IXGBE
9422 if (ret == -ENOTSUP)
9423 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9424 res->vlan_id, res->vf_mask, is_add);
9427 if (ret == -ENOTSUP)
9428 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9429 res->vlan_id, res->vf_mask, is_add);
9432 if (ret == -ENOTSUP)
9433 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9434 res->vlan_id, res->vf_mask, is_add);
9441 fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
9442 res->vlan_id, res->vf_mask);
9445 fprintf(stderr, "invalid port_id %d\n", res->port_id);
9448 fprintf(stderr, "function not implemented or supported\n");
9451 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9455 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9456 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9457 rx_vlan, "rx_vlan");
9458 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9459 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9461 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9462 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9463 vlan_id, RTE_UINT16);
9464 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9465 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9467 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9468 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9469 port_id, RTE_UINT16);
9470 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9471 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9473 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9474 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9475 vf_mask, RTE_UINT64);
9477 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9478 .f = cmd_vf_rx_vlan_filter_parsed,
9480 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9481 "(vf_mask = hexadecimal VF mask)",
9483 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9484 (void *)&cmd_vf_rx_vlan_filter_what,
9485 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9486 (void *)&cmd_vf_rx_vlan_filter_port,
9487 (void *)&cmd_vf_rx_vlan_filter_portid,
9488 (void *)&cmd_vf_rx_vlan_filter_vf,
9489 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9494 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9495 struct cmd_queue_rate_limit_result {
9496 cmdline_fixed_string_t set;
9497 cmdline_fixed_string_t port;
9499 cmdline_fixed_string_t queue;
9501 cmdline_fixed_string_t rate;
9505 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9506 __rte_unused struct cmdline *cl,
9507 __rte_unused void *data)
9509 struct cmd_queue_rate_limit_result *res = parsed_result;
9512 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9513 && (strcmp(res->queue, "queue") == 0)
9514 && (strcmp(res->rate, "rate") == 0))
9515 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9518 fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
9523 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9524 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9526 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9527 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9529 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9530 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9531 port_num, RTE_UINT16);
9532 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9533 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9535 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9536 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9537 queue_num, RTE_UINT8);
9538 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9539 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9541 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9542 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9543 rate_num, RTE_UINT16);
9545 cmdline_parse_inst_t cmd_queue_rate_limit = {
9546 .f = cmd_queue_rate_limit_parsed,
9548 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9549 "Set rate limit for a queue on port_id",
9551 (void *)&cmd_queue_rate_limit_set,
9552 (void *)&cmd_queue_rate_limit_port,
9553 (void *)&cmd_queue_rate_limit_portnum,
9554 (void *)&cmd_queue_rate_limit_queue,
9555 (void *)&cmd_queue_rate_limit_queuenum,
9556 (void *)&cmd_queue_rate_limit_rate,
9557 (void *)&cmd_queue_rate_limit_ratenum,
9562 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9563 struct cmd_vf_rate_limit_result {
9564 cmdline_fixed_string_t set;
9565 cmdline_fixed_string_t port;
9567 cmdline_fixed_string_t vf;
9569 cmdline_fixed_string_t rate;
9571 cmdline_fixed_string_t q_msk;
9575 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9576 __rte_unused struct cmdline *cl,
9577 __rte_unused void *data)
9579 struct cmd_vf_rate_limit_result *res = parsed_result;
9582 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9583 && (strcmp(res->vf, "vf") == 0)
9584 && (strcmp(res->rate, "rate") == 0)
9585 && (strcmp(res->q_msk, "queue_mask") == 0))
9586 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9587 res->rate_num, res->q_msk_val);
9589 fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
9594 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9595 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9597 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9598 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9600 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9601 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9602 port_num, RTE_UINT16);
9603 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9604 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9606 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9607 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9609 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9610 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9612 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9613 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9614 rate_num, RTE_UINT16);
9615 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9616 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9617 q_msk, "queue_mask");
9618 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9619 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9620 q_msk_val, RTE_UINT64);
9622 cmdline_parse_inst_t cmd_vf_rate_limit = {
9623 .f = cmd_vf_rate_limit_parsed,
9625 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9626 "queue_mask <queue_mask_value>: "
9627 "Set rate limit for queues of VF on port_id",
9629 (void *)&cmd_vf_rate_limit_set,
9630 (void *)&cmd_vf_rate_limit_port,
9631 (void *)&cmd_vf_rate_limit_portnum,
9632 (void *)&cmd_vf_rate_limit_vf,
9633 (void *)&cmd_vf_rate_limit_vfnum,
9634 (void *)&cmd_vf_rate_limit_rate,
9635 (void *)&cmd_vf_rate_limit_ratenum,
9636 (void *)&cmd_vf_rate_limit_q_msk,
9637 (void *)&cmd_vf_rate_limit_q_msk_val,
9642 /* *** CONFIGURE TUNNEL UDP PORT *** */
9643 struct cmd_tunnel_udp_config {
9644 cmdline_fixed_string_t rx_vxlan_port;
9645 cmdline_fixed_string_t what;
9651 cmd_tunnel_udp_config_parsed(void *parsed_result,
9652 __rte_unused struct cmdline *cl,
9653 __rte_unused void *data)
9655 struct cmd_tunnel_udp_config *res = parsed_result;
9656 struct rte_eth_udp_tunnel tunnel_udp;
9659 tunnel_udp.udp_port = res->udp_port;
9660 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9662 if (!strcmp(res->what, "add"))
9663 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9666 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9670 fprintf(stderr, "udp tunneling add error: (%s)\n",
9674 cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9675 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9676 rx_vxlan_port, "rx_vxlan_port");
9677 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9678 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9680 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9681 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9682 udp_port, RTE_UINT16);
9683 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9684 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9685 port_id, RTE_UINT16);
9687 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9688 .f = cmd_tunnel_udp_config_parsed,
9690 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9691 "Add/Remove a tunneling UDP port filter",
9693 (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9694 (void *)&cmd_tunnel_udp_config_what,
9695 (void *)&cmd_tunnel_udp_config_udp_port,
9696 (void *)&cmd_tunnel_udp_config_port_id,
9701 struct cmd_config_tunnel_udp_port {
9702 cmdline_fixed_string_t port;
9703 cmdline_fixed_string_t config;
9705 cmdline_fixed_string_t udp_tunnel_port;
9706 cmdline_fixed_string_t action;
9707 cmdline_fixed_string_t tunnel_type;
9712 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9713 __rte_unused struct cmdline *cl,
9714 __rte_unused void *data)
9716 struct cmd_config_tunnel_udp_port *res = parsed_result;
9717 struct rte_eth_udp_tunnel tunnel_udp;
9720 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9723 tunnel_udp.udp_port = res->udp_port;
9725 if (!strcmp(res->tunnel_type, "vxlan")) {
9726 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9727 } else if (!strcmp(res->tunnel_type, "geneve")) {
9728 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_GENEVE;
9729 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9730 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN_GPE;
9731 } else if (!strcmp(res->tunnel_type, "ecpri")) {
9732 tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_ECPRI;
9734 fprintf(stderr, "Invalid tunnel type\n");
9738 if (!strcmp(res->action, "add"))
9739 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9742 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9746 fprintf(stderr, "udp tunneling port add error: (%s)\n",
9750 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9751 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9753 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9754 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9756 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9757 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9759 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9760 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9763 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9764 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9766 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9767 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9768 "vxlan#geneve#vxlan-gpe#ecpri");
9769 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9770 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9773 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9774 .f = cmd_cfg_tunnel_udp_port_parsed,
9776 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9777 "geneve|vxlan-gpe|ecpri <udp_port>",
9779 (void *)&cmd_config_tunnel_udp_port_port,
9780 (void *)&cmd_config_tunnel_udp_port_config,
9781 (void *)&cmd_config_tunnel_udp_port_port_id,
9782 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9783 (void *)&cmd_config_tunnel_udp_port_action,
9784 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9785 (void *)&cmd_config_tunnel_udp_port_value,
9790 /* ******************************************************************************** */
9792 struct cmd_dump_result {
9793 cmdline_fixed_string_t dump;
9797 dump_struct_sizes(void)
9799 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9800 DUMP_SIZE(struct rte_mbuf);
9801 DUMP_SIZE(struct rte_mempool);
9802 DUMP_SIZE(struct rte_ring);
9807 /* Dump the socket memory statistics on console */
9809 dump_socket_mem(FILE *f)
9811 struct rte_malloc_socket_stats socket_stats;
9816 unsigned int n_alloc = 0;
9817 unsigned int n_free = 0;
9818 static size_t last_allocs;
9819 static size_t last_total;
9822 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9823 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9824 !socket_stats.heap_totalsz_bytes)
9826 total += socket_stats.heap_totalsz_bytes;
9827 alloc += socket_stats.heap_allocsz_bytes;
9828 free += socket_stats.heap_freesz_bytes;
9829 n_alloc += socket_stats.alloc_count;
9830 n_free += socket_stats.free_count;
9832 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9834 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9835 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9836 (double)socket_stats.heap_allocsz_bytes * 100 /
9837 (double)socket_stats.heap_totalsz_bytes,
9838 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9839 socket_stats.alloc_count,
9840 socket_stats.free_count);
9843 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9844 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9845 total ? ((double)alloc * 100 / (double)total) : 0,
9846 (double)free / (1024 * 1024),
9849 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9850 ((double)total - (double)last_total) / (1024 * 1024),
9851 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9852 last_allocs = alloc;
9856 static void cmd_dump_parsed(void *parsed_result,
9857 __rte_unused struct cmdline *cl,
9858 __rte_unused void *data)
9860 struct cmd_dump_result *res = parsed_result;
9862 if (!strcmp(res->dump, "dump_physmem"))
9863 rte_dump_physmem_layout(stdout);
9864 else if (!strcmp(res->dump, "dump_socket_mem"))
9865 dump_socket_mem(stdout);
9866 else if (!strcmp(res->dump, "dump_memzone"))
9867 rte_memzone_dump(stdout);
9868 else if (!strcmp(res->dump, "dump_struct_sizes"))
9869 dump_struct_sizes();
9870 else if (!strcmp(res->dump, "dump_ring"))
9871 rte_ring_list_dump(stdout);
9872 else if (!strcmp(res->dump, "dump_mempool"))
9873 rte_mempool_list_dump(stdout);
9874 else if (!strcmp(res->dump, "dump_devargs"))
9875 rte_devargs_dump(stdout);
9876 else if (!strcmp(res->dump, "dump_log_types"))
9877 rte_log_dump(stdout);
9880 cmdline_parse_token_string_t cmd_dump_dump =
9881 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9885 "dump_struct_sizes#"
9891 cmdline_parse_inst_t cmd_dump = {
9892 .f = cmd_dump_parsed, /* function to call */
9893 .data = NULL, /* 2nd arg of func */
9894 .help_str = "Dump status",
9895 .tokens = { /* token list, NULL terminated */
9896 (void *)&cmd_dump_dump,
9901 /* ******************************************************************************** */
9903 struct cmd_dump_one_result {
9904 cmdline_fixed_string_t dump;
9905 cmdline_fixed_string_t name;
9908 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9909 __rte_unused void *data)
9911 struct cmd_dump_one_result *res = parsed_result;
9913 if (!strcmp(res->dump, "dump_ring")) {
9915 r = rte_ring_lookup(res->name);
9917 cmdline_printf(cl, "Cannot find ring\n");
9920 rte_ring_dump(stdout, r);
9921 } else if (!strcmp(res->dump, "dump_mempool")) {
9922 struct rte_mempool *mp;
9923 mp = rte_mempool_lookup(res->name);
9925 cmdline_printf(cl, "Cannot find mempool\n");
9928 rte_mempool_dump(stdout, mp);
9932 cmdline_parse_token_string_t cmd_dump_one_dump =
9933 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9934 "dump_ring#dump_mempool");
9936 cmdline_parse_token_string_t cmd_dump_one_name =
9937 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9939 cmdline_parse_inst_t cmd_dump_one = {
9940 .f = cmd_dump_one_parsed, /* function to call */
9941 .data = NULL, /* 2nd arg of func */
9942 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9943 .tokens = { /* token list, NULL terminated */
9944 (void *)&cmd_dump_one_dump,
9945 (void *)&cmd_dump_one_name,
9950 /* *** queue region set *** */
9951 struct cmd_queue_region_result {
9952 cmdline_fixed_string_t set;
9953 cmdline_fixed_string_t port;
9955 cmdline_fixed_string_t cmd;
9956 cmdline_fixed_string_t region;
9958 cmdline_fixed_string_t queue_start_index;
9960 cmdline_fixed_string_t queue_num;
9961 uint8_t queue_num_value;
9965 cmd_queue_region_parsed(void *parsed_result,
9966 __rte_unused struct cmdline *cl,
9967 __rte_unused void *data)
9969 struct cmd_queue_region_result *res = parsed_result;
9972 struct rte_pmd_i40e_queue_region_conf region_conf;
9973 enum rte_pmd_i40e_queue_region_op op_type;
9976 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9980 memset(®ion_conf, 0, sizeof(region_conf));
9981 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9982 region_conf.region_id = res->region_id;
9983 region_conf.queue_num = res->queue_num_value;
9984 region_conf.queue_start_index = res->queue_id;
9986 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9987 op_type, ®ion_conf);
9994 fprintf(stderr, "function not implemented or supported\n");
9997 fprintf(stderr, "queue region config error: (%s)\n",
10002 cmdline_parse_token_string_t cmd_queue_region_set =
10003 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10005 cmdline_parse_token_string_t cmd_queue_region_port =
10006 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
10007 cmdline_parse_token_num_t cmd_queue_region_port_id =
10008 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10009 port_id, RTE_UINT16);
10010 cmdline_parse_token_string_t cmd_queue_region_cmd =
10011 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10012 cmd, "queue-region");
10013 cmdline_parse_token_string_t cmd_queue_region_id =
10014 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10015 region, "region_id");
10016 cmdline_parse_token_num_t cmd_queue_region_index =
10017 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10018 region_id, RTE_UINT8);
10019 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
10020 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10021 queue_start_index, "queue_start_index");
10022 cmdline_parse_token_num_t cmd_queue_region_queue_id =
10023 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10024 queue_id, RTE_UINT8);
10025 cmdline_parse_token_string_t cmd_queue_region_queue_num =
10026 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
10027 queue_num, "queue_num");
10028 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
10029 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
10030 queue_num_value, RTE_UINT8);
10032 cmdline_parse_inst_t cmd_queue_region = {
10033 .f = cmd_queue_region_parsed,
10035 .help_str = "set port <port_id> queue-region region_id <value> "
10036 "queue_start_index <value> queue_num <value>: Set a queue region",
10038 (void *)&cmd_queue_region_set,
10039 (void *)&cmd_queue_region_port,
10040 (void *)&cmd_queue_region_port_id,
10041 (void *)&cmd_queue_region_cmd,
10042 (void *)&cmd_queue_region_id,
10043 (void *)&cmd_queue_region_index,
10044 (void *)&cmd_queue_region_queue_start_index,
10045 (void *)&cmd_queue_region_queue_id,
10046 (void *)&cmd_queue_region_queue_num,
10047 (void *)&cmd_queue_region_queue_num_value,
10052 /* *** queue region and flowtype set *** */
10053 struct cmd_region_flowtype_result {
10054 cmdline_fixed_string_t set;
10055 cmdline_fixed_string_t port;
10057 cmdline_fixed_string_t cmd;
10058 cmdline_fixed_string_t region;
10060 cmdline_fixed_string_t flowtype;
10061 uint8_t flowtype_id;
10065 cmd_region_flowtype_parsed(void *parsed_result,
10066 __rte_unused struct cmdline *cl,
10067 __rte_unused void *data)
10069 struct cmd_region_flowtype_result *res = parsed_result;
10070 int ret = -ENOTSUP;
10071 #ifdef RTE_NET_I40E
10072 struct rte_pmd_i40e_queue_region_conf region_conf;
10073 enum rte_pmd_i40e_queue_region_op op_type;
10076 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10079 #ifdef RTE_NET_I40E
10080 memset(®ion_conf, 0, sizeof(region_conf));
10082 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10083 region_conf.region_id = res->region_id;
10084 region_conf.hw_flowtype = res->flowtype_id;
10086 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10087 op_type, ®ion_conf);
10094 fprintf(stderr, "function not implemented or supported\n");
10097 fprintf(stderr, "region flowtype config error: (%s)\n",
10102 cmdline_parse_token_string_t cmd_region_flowtype_set =
10103 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10105 cmdline_parse_token_string_t cmd_region_flowtype_port =
10106 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10108 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10109 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10110 port_id, RTE_UINT16);
10111 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10112 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10113 cmd, "queue-region");
10114 cmdline_parse_token_string_t cmd_region_flowtype_index =
10115 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10116 region, "region_id");
10117 cmdline_parse_token_num_t cmd_region_flowtype_id =
10118 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10119 region_id, RTE_UINT8);
10120 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10121 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10122 flowtype, "flowtype");
10123 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10124 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10125 flowtype_id, RTE_UINT8);
10126 cmdline_parse_inst_t cmd_region_flowtype = {
10127 .f = cmd_region_flowtype_parsed,
10129 .help_str = "set port <port_id> queue-region region_id <value> "
10130 "flowtype <value>: Set a flowtype region index",
10132 (void *)&cmd_region_flowtype_set,
10133 (void *)&cmd_region_flowtype_port,
10134 (void *)&cmd_region_flowtype_port_index,
10135 (void *)&cmd_region_flowtype_cmd,
10136 (void *)&cmd_region_flowtype_index,
10137 (void *)&cmd_region_flowtype_id,
10138 (void *)&cmd_region_flowtype_flow_index,
10139 (void *)&cmd_region_flowtype_flow_id,
10144 /* *** User Priority (UP) to queue region (region_id) set *** */
10145 struct cmd_user_priority_region_result {
10146 cmdline_fixed_string_t set;
10147 cmdline_fixed_string_t port;
10149 cmdline_fixed_string_t cmd;
10150 cmdline_fixed_string_t user_priority;
10151 uint8_t user_priority_id;
10152 cmdline_fixed_string_t region;
10157 cmd_user_priority_region_parsed(void *parsed_result,
10158 __rte_unused struct cmdline *cl,
10159 __rte_unused void *data)
10161 struct cmd_user_priority_region_result *res = parsed_result;
10162 int ret = -ENOTSUP;
10163 #ifdef RTE_NET_I40E
10164 struct rte_pmd_i40e_queue_region_conf region_conf;
10165 enum rte_pmd_i40e_queue_region_op op_type;
10168 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10171 #ifdef RTE_NET_I40E
10172 memset(®ion_conf, 0, sizeof(region_conf));
10173 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10174 region_conf.user_priority = res->user_priority_id;
10175 region_conf.region_id = res->region_id;
10177 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10178 op_type, ®ion_conf);
10185 fprintf(stderr, "function not implemented or supported\n");
10188 fprintf(stderr, "user_priority region config error: (%s)\n",
10193 cmdline_parse_token_string_t cmd_user_priority_region_set =
10194 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10196 cmdline_parse_token_string_t cmd_user_priority_region_port =
10197 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10199 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10200 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10201 port_id, RTE_UINT16);
10202 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10203 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10204 cmd, "queue-region");
10205 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10206 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10207 user_priority, "UP");
10208 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10209 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10210 user_priority_id, RTE_UINT8);
10211 cmdline_parse_token_string_t cmd_user_priority_region_region =
10212 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10213 region, "region_id");
10214 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10215 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10216 region_id, RTE_UINT8);
10218 cmdline_parse_inst_t cmd_user_priority_region = {
10219 .f = cmd_user_priority_region_parsed,
10221 .help_str = "set port <port_id> queue-region UP <value> "
10222 "region_id <value>: Set the mapping of User Priority (UP) "
10223 "to queue region (region_id) ",
10225 (void *)&cmd_user_priority_region_set,
10226 (void *)&cmd_user_priority_region_port,
10227 (void *)&cmd_user_priority_region_port_index,
10228 (void *)&cmd_user_priority_region_cmd,
10229 (void *)&cmd_user_priority_region_UP,
10230 (void *)&cmd_user_priority_region_UP_id,
10231 (void *)&cmd_user_priority_region_region,
10232 (void *)&cmd_user_priority_region_region_id,
10237 /* *** flush all queue region related configuration *** */
10238 struct cmd_flush_queue_region_result {
10239 cmdline_fixed_string_t set;
10240 cmdline_fixed_string_t port;
10242 cmdline_fixed_string_t cmd;
10243 cmdline_fixed_string_t flush;
10244 cmdline_fixed_string_t what;
10248 cmd_flush_queue_region_parsed(void *parsed_result,
10249 __rte_unused struct cmdline *cl,
10250 __rte_unused void *data)
10252 struct cmd_flush_queue_region_result *res = parsed_result;
10253 int ret = -ENOTSUP;
10254 #ifdef RTE_NET_I40E
10255 struct rte_pmd_i40e_queue_region_conf region_conf;
10256 enum rte_pmd_i40e_queue_region_op op_type;
10259 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10262 #ifdef RTE_NET_I40E
10263 memset(®ion_conf, 0, sizeof(region_conf));
10265 if (strcmp(res->what, "on") == 0)
10266 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10268 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10270 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10271 op_type, ®ion_conf);
10278 fprintf(stderr, "function not implemented or supported\n");
10281 fprintf(stderr, "queue region config flush error: (%s)\n",
10286 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10287 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10289 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10290 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10292 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10293 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10294 port_id, RTE_UINT16);
10295 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10296 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10297 cmd, "queue-region");
10298 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10299 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10301 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10302 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10305 cmdline_parse_inst_t cmd_flush_queue_region = {
10306 .f = cmd_flush_queue_region_parsed,
10308 .help_str = "set port <port_id> queue-region flush on|off"
10309 ": flush all queue region related configuration",
10311 (void *)&cmd_flush_queue_region_set,
10312 (void *)&cmd_flush_queue_region_port,
10313 (void *)&cmd_flush_queue_region_port_index,
10314 (void *)&cmd_flush_queue_region_cmd,
10315 (void *)&cmd_flush_queue_region_flush,
10316 (void *)&cmd_flush_queue_region_what,
10321 /* *** get all queue region related configuration info *** */
10322 struct cmd_show_queue_region_info {
10323 cmdline_fixed_string_t show;
10324 cmdline_fixed_string_t port;
10326 cmdline_fixed_string_t cmd;
10330 cmd_show_queue_region_info_parsed(void *parsed_result,
10331 __rte_unused struct cmdline *cl,
10332 __rte_unused void *data)
10334 struct cmd_show_queue_region_info *res = parsed_result;
10335 int ret = -ENOTSUP;
10336 #ifdef RTE_NET_I40E
10337 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10338 enum rte_pmd_i40e_queue_region_op op_type;
10341 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10344 #ifdef RTE_NET_I40E
10345 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10347 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10349 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10350 op_type, &rte_pmd_regions);
10352 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10359 fprintf(stderr, "function not implemented or supported\n");
10362 fprintf(stderr, "queue region config info show error: (%s)\n",
10367 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10368 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10370 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10371 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10373 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10374 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10375 port_id, RTE_UINT16);
10376 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10377 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10378 cmd, "queue-region");
10380 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10381 .f = cmd_show_queue_region_info_parsed,
10383 .help_str = "show port <port_id> queue-region"
10384 ": show all queue region related configuration info",
10386 (void *)&cmd_show_queue_region_info_get,
10387 (void *)&cmd_show_queue_region_info_port,
10388 (void *)&cmd_show_queue_region_info_port_index,
10389 (void *)&cmd_show_queue_region_info_cmd,
10394 /* *** Filters Control *** */
10396 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10398 if ((ip_addr).family == AF_INET) \
10399 (ip) = (ip_addr).addr.ipv4.s_addr; \
10401 fprintf(stderr, "invalid parameter.\n"); \
10406 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10408 if ((ip_addr).family == AF_INET6) \
10409 rte_memcpy(&(ip), \
10410 &((ip_addr).addr.ipv6), \
10411 sizeof(struct in6_addr)); \
10413 fprintf(stderr, "invalid parameter.\n"); \
10418 #ifdef RTE_NET_I40E
10421 str2flowtype(char *string)
10424 static const struct {
10427 } flowtype_str[] = {
10428 {"raw", RTE_ETH_FLOW_RAW},
10429 {"ipv4", RTE_ETH_FLOW_IPV4},
10430 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10431 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10432 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10433 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10434 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10435 {"ipv6", RTE_ETH_FLOW_IPV6},
10436 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10437 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10438 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10439 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10440 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10441 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10442 {"ipv6-ex", RTE_ETH_FLOW_IPV6_EX},
10443 {"ipv6-tcp-ex", RTE_ETH_FLOW_IPV6_TCP_EX},
10444 {"ipv6-udp-ex", RTE_ETH_FLOW_IPV6_UDP_EX},
10445 {"gtpu", RTE_ETH_FLOW_GTPU},
10448 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10449 if (!strcmp(flowtype_str[i].str, string))
10450 return flowtype_str[i].type;
10453 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10454 return (uint16_t)atoi(string);
10456 return RTE_ETH_FLOW_UNKNOWN;
10459 /* *** deal with flow director filter *** */
10460 struct cmd_flow_director_result {
10461 cmdline_fixed_string_t flow_director_filter;
10463 cmdline_fixed_string_t mode;
10464 cmdline_fixed_string_t mode_value;
10465 cmdline_fixed_string_t ops;
10466 cmdline_fixed_string_t flow;
10467 cmdline_fixed_string_t flow_type;
10468 cmdline_fixed_string_t drop;
10469 cmdline_fixed_string_t queue;
10471 cmdline_fixed_string_t fd_id;
10472 uint32_t fd_id_value;
10473 cmdline_fixed_string_t packet;
10478 cmd_flow_director_filter_parsed(void *parsed_result,
10479 __rte_unused struct cmdline *cl,
10480 __rte_unused void *data)
10482 struct cmd_flow_director_result *res = parsed_result;
10484 struct rte_pmd_i40e_flow_type_mapping
10485 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10486 struct rte_pmd_i40e_pkt_template_conf conf;
10487 uint16_t flow_type = str2flowtype(res->flow_type);
10488 uint16_t i, port = res->port_id;
10491 memset(&conf, 0, sizeof(conf));
10493 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10494 fprintf(stderr, "Invalid flow type specified.\n");
10497 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10501 if (mapping[flow_type].pctype == 0ULL) {
10502 fprintf(stderr, "Invalid flow type specified.\n");
10505 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10506 if (mapping[flow_type].pctype & (1ULL << i)) {
10507 conf.input.pctype = i;
10512 conf.input.packet = open_file(res->filepath,
10513 &conf.input.length);
10514 if (!conf.input.packet)
10516 if (!strcmp(res->drop, "drop"))
10517 conf.action.behavior =
10518 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10520 conf.action.behavior =
10521 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10522 conf.action.report_status =
10523 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10524 conf.action.rx_queue = res->queue_id;
10525 conf.soft_id = res->fd_id_value;
10526 add = strcmp(res->ops, "del") ? 1 : 0;
10527 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10531 fprintf(stderr, "flow director config error: (%s)\n",
10533 close_file(conf.input.packet);
10536 cmdline_parse_token_string_t cmd_flow_director_filter =
10537 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10538 flow_director_filter, "flow_director_filter");
10539 cmdline_parse_token_num_t cmd_flow_director_port_id =
10540 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10541 port_id, RTE_UINT16);
10542 cmdline_parse_token_string_t cmd_flow_director_ops =
10543 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10544 ops, "add#del#update");
10545 cmdline_parse_token_string_t cmd_flow_director_flow =
10546 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10548 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10549 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10551 cmdline_parse_token_string_t cmd_flow_director_drop =
10552 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10554 cmdline_parse_token_string_t cmd_flow_director_queue =
10555 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10557 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10558 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10559 queue_id, RTE_UINT16);
10560 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10561 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10563 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10564 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10565 fd_id_value, RTE_UINT32);
10567 cmdline_parse_token_string_t cmd_flow_director_mode =
10568 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10570 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10571 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10572 mode_value, "raw");
10573 cmdline_parse_token_string_t cmd_flow_director_packet =
10574 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10576 cmdline_parse_token_string_t cmd_flow_director_filepath =
10577 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10580 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10581 .f = cmd_flow_director_filter_parsed,
10583 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10584 "director entry on NIC",
10586 (void *)&cmd_flow_director_filter,
10587 (void *)&cmd_flow_director_port_id,
10588 (void *)&cmd_flow_director_mode,
10589 (void *)&cmd_flow_director_mode_raw,
10590 (void *)&cmd_flow_director_ops,
10591 (void *)&cmd_flow_director_flow,
10592 (void *)&cmd_flow_director_flow_type,
10593 (void *)&cmd_flow_director_drop,
10594 (void *)&cmd_flow_director_queue,
10595 (void *)&cmd_flow_director_queue_id,
10596 (void *)&cmd_flow_director_fd_id,
10597 (void *)&cmd_flow_director_fd_id_value,
10598 (void *)&cmd_flow_director_packet,
10599 (void *)&cmd_flow_director_filepath,
10604 #endif /* RTE_NET_I40E */
10606 /* *** deal with flow director mask *** */
10607 struct cmd_flow_director_mask_result {
10608 cmdline_fixed_string_t flow_director_mask;
10610 cmdline_fixed_string_t mode;
10611 cmdline_fixed_string_t mode_value;
10612 cmdline_fixed_string_t vlan;
10613 uint16_t vlan_mask;
10614 cmdline_fixed_string_t src_mask;
10615 cmdline_ipaddr_t ipv4_src;
10616 cmdline_ipaddr_t ipv6_src;
10618 cmdline_fixed_string_t dst_mask;
10619 cmdline_ipaddr_t ipv4_dst;
10620 cmdline_ipaddr_t ipv6_dst;
10622 cmdline_fixed_string_t mac;
10623 uint8_t mac_addr_byte_mask;
10624 cmdline_fixed_string_t tunnel_id;
10625 uint32_t tunnel_id_mask;
10626 cmdline_fixed_string_t tunnel_type;
10627 uint8_t tunnel_type_mask;
10631 cmd_flow_director_mask_parsed(void *parsed_result,
10632 __rte_unused struct cmdline *cl,
10633 __rte_unused void *data)
10635 struct cmd_flow_director_mask_result *res = parsed_result;
10636 struct rte_eth_fdir_masks *mask;
10637 struct rte_port *port;
10639 port = &ports[res->port_id];
10640 /** Check if the port is not started **/
10641 if (port->port_status != RTE_PORT_STOPPED) {
10642 fprintf(stderr, "Please stop port %d first\n", res->port_id);
10646 mask = &port->dev_conf.fdir_conf.mask;
10648 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10649 if (strcmp(res->mode_value, "MAC-VLAN")) {
10650 fprintf(stderr, "Please set mode to MAC-VLAN.\n");
10654 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10655 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10656 if (strcmp(res->mode_value, "Tunnel")) {
10657 fprintf(stderr, "Please set mode to Tunnel.\n");
10661 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10662 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10663 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10664 mask->tunnel_type_mask = res->tunnel_type_mask;
10666 if (strcmp(res->mode_value, "IP")) {
10667 fprintf(stderr, "Please set mode to IP.\n");
10671 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10672 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10673 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10674 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10675 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10676 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10677 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10680 cmd_reconfig_device_queue(res->port_id, 1, 1);
10683 cmdline_parse_token_string_t cmd_flow_director_mask =
10684 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10685 flow_director_mask, "flow_director_mask");
10686 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10687 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10688 port_id, RTE_UINT16);
10689 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10690 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10692 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10693 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10694 vlan_mask, RTE_UINT16);
10695 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10696 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10697 src_mask, "src_mask");
10698 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10699 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10701 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10702 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10704 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10705 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10706 port_src, RTE_UINT16);
10707 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10708 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10709 dst_mask, "dst_mask");
10710 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10711 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10713 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10714 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10716 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10717 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10718 port_dst, RTE_UINT16);
10720 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10721 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10723 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10724 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10726 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10727 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10728 mode_value, "MAC-VLAN");
10729 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10730 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10731 mode_value, "Tunnel");
10732 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10733 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10735 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10736 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10737 mac_addr_byte_mask, RTE_UINT8);
10738 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10739 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10740 tunnel_type, "tunnel-type");
10741 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10742 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10743 tunnel_type_mask, RTE_UINT8);
10744 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10745 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10746 tunnel_id, "tunnel-id");
10747 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10748 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10749 tunnel_id_mask, RTE_UINT32);
10751 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10752 .f = cmd_flow_director_mask_parsed,
10754 .help_str = "flow_director_mask ... : "
10755 "Set IP mode flow director's mask on NIC",
10757 (void *)&cmd_flow_director_mask,
10758 (void *)&cmd_flow_director_mask_port_id,
10759 (void *)&cmd_flow_director_mask_mode,
10760 (void *)&cmd_flow_director_mask_mode_ip,
10761 (void *)&cmd_flow_director_mask_vlan,
10762 (void *)&cmd_flow_director_mask_vlan_value,
10763 (void *)&cmd_flow_director_mask_src,
10764 (void *)&cmd_flow_director_mask_ipv4_src,
10765 (void *)&cmd_flow_director_mask_ipv6_src,
10766 (void *)&cmd_flow_director_mask_port_src,
10767 (void *)&cmd_flow_director_mask_dst,
10768 (void *)&cmd_flow_director_mask_ipv4_dst,
10769 (void *)&cmd_flow_director_mask_ipv6_dst,
10770 (void *)&cmd_flow_director_mask_port_dst,
10775 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10776 .f = cmd_flow_director_mask_parsed,
10778 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10779 "flow director's mask on NIC",
10781 (void *)&cmd_flow_director_mask,
10782 (void *)&cmd_flow_director_mask_port_id,
10783 (void *)&cmd_flow_director_mask_mode,
10784 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10785 (void *)&cmd_flow_director_mask_vlan,
10786 (void *)&cmd_flow_director_mask_vlan_value,
10791 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10792 .f = cmd_flow_director_mask_parsed,
10794 .help_str = "flow_director_mask ... : Set tunnel mode "
10795 "flow director's mask on NIC",
10797 (void *)&cmd_flow_director_mask,
10798 (void *)&cmd_flow_director_mask_port_id,
10799 (void *)&cmd_flow_director_mask_mode,
10800 (void *)&cmd_flow_director_mask_mode_tunnel,
10801 (void *)&cmd_flow_director_mask_vlan,
10802 (void *)&cmd_flow_director_mask_vlan_value,
10803 (void *)&cmd_flow_director_mask_mac,
10804 (void *)&cmd_flow_director_mask_mac_value,
10805 (void *)&cmd_flow_director_mask_tunnel_type,
10806 (void *)&cmd_flow_director_mask_tunnel_type_value,
10807 (void *)&cmd_flow_director_mask_tunnel_id,
10808 (void *)&cmd_flow_director_mask_tunnel_id_value,
10813 /* *** deal with flow director flexible payload configuration *** */
10814 struct cmd_flow_director_flexpayload_result {
10815 cmdline_fixed_string_t flow_director_flexpayload;
10817 cmdline_fixed_string_t payload_layer;
10818 cmdline_fixed_string_t payload_cfg;
10822 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10825 const char *p, *p0 = q_arg;
10827 unsigned long int_fld;
10828 char *str_fld[max_num];
10833 p = strchr(p0, '(');
10837 p0 = strchr(p, ')');
10842 if (size >= sizeof(s))
10845 snprintf(s, sizeof(s), "%.*s", size, p);
10846 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10847 if (ret < 0 || ret > max_num)
10849 for (i = 0; i < ret; i++) {
10851 int_fld = strtoul(str_fld[i], &end, 0);
10852 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10854 offsets[i] = (uint16_t)int_fld;
10860 cmd_flow_director_flxpld_parsed(void *parsed_result,
10861 __rte_unused struct cmdline *cl,
10862 __rte_unused void *data)
10864 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10865 struct rte_eth_flex_payload_cfg flex_cfg;
10866 struct rte_port *port;
10869 port = &ports[res->port_id];
10870 /** Check if the port is not started **/
10871 if (port->port_status != RTE_PORT_STOPPED) {
10872 fprintf(stderr, "Please stop port %d first\n", res->port_id);
10876 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10878 if (!strcmp(res->payload_layer, "raw"))
10879 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10880 else if (!strcmp(res->payload_layer, "l2"))
10881 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10882 else if (!strcmp(res->payload_layer, "l3"))
10883 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10884 else if (!strcmp(res->payload_layer, "l4"))
10885 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10887 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10888 RTE_ETH_FDIR_MAX_FLEXLEN);
10890 fprintf(stderr, "error: Cannot parse flex payload input.\n");
10894 fdir_set_flex_payload(res->port_id, &flex_cfg);
10895 cmd_reconfig_device_queue(res->port_id, 1, 1);
10898 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10899 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10900 flow_director_flexpayload,
10901 "flow_director_flex_payload");
10902 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10903 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10904 port_id, RTE_UINT16);
10905 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10906 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10907 payload_layer, "raw#l2#l3#l4");
10908 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10909 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10910 payload_cfg, NULL);
10912 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10913 .f = cmd_flow_director_flxpld_parsed,
10915 .help_str = "flow_director_flexpayload ... : "
10916 "Set flow director's flex payload on NIC",
10918 (void *)&cmd_flow_director_flexpayload,
10919 (void *)&cmd_flow_director_flexpayload_port_id,
10920 (void *)&cmd_flow_director_flexpayload_payload_layer,
10921 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10926 /* Generic flow interface command. */
10927 extern cmdline_parse_inst_t cmd_flow;
10929 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10930 struct cmd_mcast_addr_result {
10931 cmdline_fixed_string_t mcast_addr_cmd;
10932 cmdline_fixed_string_t what;
10934 struct rte_ether_addr mc_addr;
10937 static void cmd_mcast_addr_parsed(void *parsed_result,
10938 __rte_unused struct cmdline *cl,
10939 __rte_unused void *data)
10941 struct cmd_mcast_addr_result *res = parsed_result;
10943 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
10945 "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
10946 RTE_ETHER_ADDR_BYTES(&res->mc_addr));
10949 if (strcmp(res->what, "add") == 0)
10950 mcast_addr_add(res->port_num, &res->mc_addr);
10952 mcast_addr_remove(res->port_num, &res->mc_addr);
10955 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10956 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10957 mcast_addr_cmd, "mcast_addr");
10958 cmdline_parse_token_string_t cmd_mcast_addr_what =
10959 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10961 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10962 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
10964 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10965 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10967 cmdline_parse_inst_t cmd_mcast_addr = {
10968 .f = cmd_mcast_addr_parsed,
10970 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10971 "Add/Remove multicast MAC address on port_id",
10973 (void *)&cmd_mcast_addr_cmd,
10974 (void *)&cmd_mcast_addr_what,
10975 (void *)&cmd_mcast_addr_portnum,
10976 (void *)&cmd_mcast_addr_addr,
10981 /* vf vlan anti spoof configuration */
10983 /* Common result structure for vf vlan anti spoof */
10984 struct cmd_vf_vlan_anti_spoof_result {
10985 cmdline_fixed_string_t set;
10986 cmdline_fixed_string_t vf;
10987 cmdline_fixed_string_t vlan;
10988 cmdline_fixed_string_t antispoof;
10991 cmdline_fixed_string_t on_off;
10994 /* Common CLI fields for vf vlan anti spoof enable disable */
10995 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10996 TOKEN_STRING_INITIALIZER
10997 (struct cmd_vf_vlan_anti_spoof_result,
10999 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
11000 TOKEN_STRING_INITIALIZER
11001 (struct cmd_vf_vlan_anti_spoof_result,
11003 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
11004 TOKEN_STRING_INITIALIZER
11005 (struct cmd_vf_vlan_anti_spoof_result,
11007 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
11008 TOKEN_STRING_INITIALIZER
11009 (struct cmd_vf_vlan_anti_spoof_result,
11010 antispoof, "antispoof");
11011 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
11012 TOKEN_NUM_INITIALIZER
11013 (struct cmd_vf_vlan_anti_spoof_result,
11014 port_id, RTE_UINT16);
11015 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
11016 TOKEN_NUM_INITIALIZER
11017 (struct cmd_vf_vlan_anti_spoof_result,
11018 vf_id, RTE_UINT32);
11019 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11020 TOKEN_STRING_INITIALIZER
11021 (struct cmd_vf_vlan_anti_spoof_result,
11025 cmd_set_vf_vlan_anti_spoof_parsed(
11026 void *parsed_result,
11027 __rte_unused struct cmdline *cl,
11028 __rte_unused void *data)
11030 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
11031 int ret = -ENOTSUP;
11033 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11035 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11038 #ifdef RTE_NET_IXGBE
11039 if (ret == -ENOTSUP)
11040 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11041 res->vf_id, is_on);
11043 #ifdef RTE_NET_I40E
11044 if (ret == -ENOTSUP)
11045 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11046 res->vf_id, is_on);
11048 #ifdef RTE_NET_BNXT
11049 if (ret == -ENOTSUP)
11050 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11051 res->vf_id, is_on);
11058 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11061 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11064 fprintf(stderr, "function not implemented\n");
11067 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11071 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11072 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11074 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11076 (void *)&cmd_vf_vlan_anti_spoof_set,
11077 (void *)&cmd_vf_vlan_anti_spoof_vf,
11078 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11079 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11080 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11081 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11082 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11087 /* vf mac anti spoof configuration */
11089 /* Common result structure for vf mac anti spoof */
11090 struct cmd_vf_mac_anti_spoof_result {
11091 cmdline_fixed_string_t set;
11092 cmdline_fixed_string_t vf;
11093 cmdline_fixed_string_t mac;
11094 cmdline_fixed_string_t antispoof;
11097 cmdline_fixed_string_t on_off;
11100 /* Common CLI fields for vf mac anti spoof enable disable */
11101 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11102 TOKEN_STRING_INITIALIZER
11103 (struct cmd_vf_mac_anti_spoof_result,
11105 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11106 TOKEN_STRING_INITIALIZER
11107 (struct cmd_vf_mac_anti_spoof_result,
11109 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11110 TOKEN_STRING_INITIALIZER
11111 (struct cmd_vf_mac_anti_spoof_result,
11113 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11114 TOKEN_STRING_INITIALIZER
11115 (struct cmd_vf_mac_anti_spoof_result,
11116 antispoof, "antispoof");
11117 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11118 TOKEN_NUM_INITIALIZER
11119 (struct cmd_vf_mac_anti_spoof_result,
11120 port_id, RTE_UINT16);
11121 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11122 TOKEN_NUM_INITIALIZER
11123 (struct cmd_vf_mac_anti_spoof_result,
11124 vf_id, RTE_UINT32);
11125 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11126 TOKEN_STRING_INITIALIZER
11127 (struct cmd_vf_mac_anti_spoof_result,
11131 cmd_set_vf_mac_anti_spoof_parsed(
11132 void *parsed_result,
11133 __rte_unused struct cmdline *cl,
11134 __rte_unused void *data)
11136 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11137 int ret = -ENOTSUP;
11139 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11141 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11144 #ifdef RTE_NET_IXGBE
11145 if (ret == -ENOTSUP)
11146 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11147 res->vf_id, is_on);
11149 #ifdef RTE_NET_I40E
11150 if (ret == -ENOTSUP)
11151 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11152 res->vf_id, is_on);
11154 #ifdef RTE_NET_BNXT
11155 if (ret == -ENOTSUP)
11156 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11157 res->vf_id, is_on);
11164 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11165 res->vf_id, is_on);
11168 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11171 fprintf(stderr, "function not implemented\n");
11174 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11178 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11179 .f = cmd_set_vf_mac_anti_spoof_parsed,
11181 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11183 (void *)&cmd_vf_mac_anti_spoof_set,
11184 (void *)&cmd_vf_mac_anti_spoof_vf,
11185 (void *)&cmd_vf_mac_anti_spoof_mac,
11186 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11187 (void *)&cmd_vf_mac_anti_spoof_port_id,
11188 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11189 (void *)&cmd_vf_mac_anti_spoof_on_off,
11194 /* vf vlan strip queue configuration */
11196 /* Common result structure for vf mac anti spoof */
11197 struct cmd_vf_vlan_stripq_result {
11198 cmdline_fixed_string_t set;
11199 cmdline_fixed_string_t vf;
11200 cmdline_fixed_string_t vlan;
11201 cmdline_fixed_string_t stripq;
11204 cmdline_fixed_string_t on_off;
11207 /* Common CLI fields for vf vlan strip enable disable */
11208 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11209 TOKEN_STRING_INITIALIZER
11210 (struct cmd_vf_vlan_stripq_result,
11212 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11213 TOKEN_STRING_INITIALIZER
11214 (struct cmd_vf_vlan_stripq_result,
11216 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11217 TOKEN_STRING_INITIALIZER
11218 (struct cmd_vf_vlan_stripq_result,
11220 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11221 TOKEN_STRING_INITIALIZER
11222 (struct cmd_vf_vlan_stripq_result,
11224 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11225 TOKEN_NUM_INITIALIZER
11226 (struct cmd_vf_vlan_stripq_result,
11227 port_id, RTE_UINT16);
11228 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11229 TOKEN_NUM_INITIALIZER
11230 (struct cmd_vf_vlan_stripq_result,
11231 vf_id, RTE_UINT16);
11232 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11233 TOKEN_STRING_INITIALIZER
11234 (struct cmd_vf_vlan_stripq_result,
11238 cmd_set_vf_vlan_stripq_parsed(
11239 void *parsed_result,
11240 __rte_unused struct cmdline *cl,
11241 __rte_unused void *data)
11243 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11244 int ret = -ENOTSUP;
11246 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11248 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11251 #ifdef RTE_NET_IXGBE
11252 if (ret == -ENOTSUP)
11253 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11254 res->vf_id, is_on);
11256 #ifdef RTE_NET_I40E
11257 if (ret == -ENOTSUP)
11258 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11259 res->vf_id, is_on);
11261 #ifdef RTE_NET_BNXT
11262 if (ret == -ENOTSUP)
11263 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11264 res->vf_id, is_on);
11271 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11272 res->vf_id, is_on);
11275 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11278 fprintf(stderr, "function not implemented\n");
11281 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11285 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11286 .f = cmd_set_vf_vlan_stripq_parsed,
11288 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11290 (void *)&cmd_vf_vlan_stripq_set,
11291 (void *)&cmd_vf_vlan_stripq_vf,
11292 (void *)&cmd_vf_vlan_stripq_vlan,
11293 (void *)&cmd_vf_vlan_stripq_stripq,
11294 (void *)&cmd_vf_vlan_stripq_port_id,
11295 (void *)&cmd_vf_vlan_stripq_vf_id,
11296 (void *)&cmd_vf_vlan_stripq_on_off,
11301 /* vf vlan insert configuration */
11303 /* Common result structure for vf vlan insert */
11304 struct cmd_vf_vlan_insert_result {
11305 cmdline_fixed_string_t set;
11306 cmdline_fixed_string_t vf;
11307 cmdline_fixed_string_t vlan;
11308 cmdline_fixed_string_t insert;
11314 /* Common CLI fields for vf vlan insert enable disable */
11315 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11316 TOKEN_STRING_INITIALIZER
11317 (struct cmd_vf_vlan_insert_result,
11319 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11320 TOKEN_STRING_INITIALIZER
11321 (struct cmd_vf_vlan_insert_result,
11323 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11324 TOKEN_STRING_INITIALIZER
11325 (struct cmd_vf_vlan_insert_result,
11327 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11328 TOKEN_STRING_INITIALIZER
11329 (struct cmd_vf_vlan_insert_result,
11331 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11332 TOKEN_NUM_INITIALIZER
11333 (struct cmd_vf_vlan_insert_result,
11334 port_id, RTE_UINT16);
11335 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11336 TOKEN_NUM_INITIALIZER
11337 (struct cmd_vf_vlan_insert_result,
11338 vf_id, RTE_UINT16);
11339 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11340 TOKEN_NUM_INITIALIZER
11341 (struct cmd_vf_vlan_insert_result,
11342 vlan_id, RTE_UINT16);
11345 cmd_set_vf_vlan_insert_parsed(
11346 void *parsed_result,
11347 __rte_unused struct cmdline *cl,
11348 __rte_unused void *data)
11350 struct cmd_vf_vlan_insert_result *res = parsed_result;
11351 int ret = -ENOTSUP;
11353 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11356 #ifdef RTE_NET_IXGBE
11357 if (ret == -ENOTSUP)
11358 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11361 #ifdef RTE_NET_I40E
11362 if (ret == -ENOTSUP)
11363 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11366 #ifdef RTE_NET_BNXT
11367 if (ret == -ENOTSUP)
11368 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11376 fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
11377 res->vf_id, res->vlan_id);
11380 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11383 fprintf(stderr, "function not implemented\n");
11386 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11390 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11391 .f = cmd_set_vf_vlan_insert_parsed,
11393 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11395 (void *)&cmd_vf_vlan_insert_set,
11396 (void *)&cmd_vf_vlan_insert_vf,
11397 (void *)&cmd_vf_vlan_insert_vlan,
11398 (void *)&cmd_vf_vlan_insert_insert,
11399 (void *)&cmd_vf_vlan_insert_port_id,
11400 (void *)&cmd_vf_vlan_insert_vf_id,
11401 (void *)&cmd_vf_vlan_insert_vlan_id,
11406 /* tx loopback configuration */
11408 /* Common result structure for tx loopback */
11409 struct cmd_tx_loopback_result {
11410 cmdline_fixed_string_t set;
11411 cmdline_fixed_string_t tx;
11412 cmdline_fixed_string_t loopback;
11414 cmdline_fixed_string_t on_off;
11417 /* Common CLI fields for tx loopback enable disable */
11418 cmdline_parse_token_string_t cmd_tx_loopback_set =
11419 TOKEN_STRING_INITIALIZER
11420 (struct cmd_tx_loopback_result,
11422 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11423 TOKEN_STRING_INITIALIZER
11424 (struct cmd_tx_loopback_result,
11426 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11427 TOKEN_STRING_INITIALIZER
11428 (struct cmd_tx_loopback_result,
11429 loopback, "loopback");
11430 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11431 TOKEN_NUM_INITIALIZER
11432 (struct cmd_tx_loopback_result,
11433 port_id, RTE_UINT16);
11434 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11435 TOKEN_STRING_INITIALIZER
11436 (struct cmd_tx_loopback_result,
11440 cmd_set_tx_loopback_parsed(
11441 void *parsed_result,
11442 __rte_unused struct cmdline *cl,
11443 __rte_unused void *data)
11445 struct cmd_tx_loopback_result *res = parsed_result;
11446 int ret = -ENOTSUP;
11448 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11450 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11453 #ifdef RTE_NET_IXGBE
11454 if (ret == -ENOTSUP)
11455 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11457 #ifdef RTE_NET_I40E
11458 if (ret == -ENOTSUP)
11459 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11461 #ifdef RTE_NET_BNXT
11462 if (ret == -ENOTSUP)
11463 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11465 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11466 if (ret == -ENOTSUP)
11467 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11474 fprintf(stderr, "invalid is_on %d\n", is_on);
11477 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11480 fprintf(stderr, "function not implemented\n");
11483 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11487 cmdline_parse_inst_t cmd_set_tx_loopback = {
11488 .f = cmd_set_tx_loopback_parsed,
11490 .help_str = "set tx loopback <port_id> on|off",
11492 (void *)&cmd_tx_loopback_set,
11493 (void *)&cmd_tx_loopback_tx,
11494 (void *)&cmd_tx_loopback_loopback,
11495 (void *)&cmd_tx_loopback_port_id,
11496 (void *)&cmd_tx_loopback_on_off,
11501 /* all queues drop enable configuration */
11503 /* Common result structure for all queues drop enable */
11504 struct cmd_all_queues_drop_en_result {
11505 cmdline_fixed_string_t set;
11506 cmdline_fixed_string_t all;
11507 cmdline_fixed_string_t queues;
11508 cmdline_fixed_string_t drop;
11510 cmdline_fixed_string_t on_off;
11513 /* Common CLI fields for tx loopback enable disable */
11514 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11515 TOKEN_STRING_INITIALIZER
11516 (struct cmd_all_queues_drop_en_result,
11518 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11519 TOKEN_STRING_INITIALIZER
11520 (struct cmd_all_queues_drop_en_result,
11522 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11523 TOKEN_STRING_INITIALIZER
11524 (struct cmd_all_queues_drop_en_result,
11526 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11527 TOKEN_STRING_INITIALIZER
11528 (struct cmd_all_queues_drop_en_result,
11530 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11531 TOKEN_NUM_INITIALIZER
11532 (struct cmd_all_queues_drop_en_result,
11533 port_id, RTE_UINT16);
11534 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11535 TOKEN_STRING_INITIALIZER
11536 (struct cmd_all_queues_drop_en_result,
11540 cmd_set_all_queues_drop_en_parsed(
11541 void *parsed_result,
11542 __rte_unused struct cmdline *cl,
11543 __rte_unused void *data)
11545 struct cmd_all_queues_drop_en_result *res = parsed_result;
11546 int ret = -ENOTSUP;
11547 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11549 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11552 #ifdef RTE_NET_IXGBE
11553 if (ret == -ENOTSUP)
11554 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11556 #ifdef RTE_NET_BNXT
11557 if (ret == -ENOTSUP)
11558 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11564 fprintf(stderr, "invalid is_on %d\n", is_on);
11567 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11570 fprintf(stderr, "function not implemented\n");
11573 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11577 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11578 .f = cmd_set_all_queues_drop_en_parsed,
11580 .help_str = "set all queues drop <port_id> on|off",
11582 (void *)&cmd_all_queues_drop_en_set,
11583 (void *)&cmd_all_queues_drop_en_all,
11584 (void *)&cmd_all_queues_drop_en_queues,
11585 (void *)&cmd_all_queues_drop_en_drop,
11586 (void *)&cmd_all_queues_drop_en_port_id,
11587 (void *)&cmd_all_queues_drop_en_on_off,
11592 /* vf split drop enable configuration */
11594 /* Common result structure for vf split drop enable */
11595 struct cmd_vf_split_drop_en_result {
11596 cmdline_fixed_string_t set;
11597 cmdline_fixed_string_t vf;
11598 cmdline_fixed_string_t split;
11599 cmdline_fixed_string_t drop;
11602 cmdline_fixed_string_t on_off;
11605 /* Common CLI fields for vf split drop enable disable */
11606 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11607 TOKEN_STRING_INITIALIZER
11608 (struct cmd_vf_split_drop_en_result,
11610 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11611 TOKEN_STRING_INITIALIZER
11612 (struct cmd_vf_split_drop_en_result,
11614 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11615 TOKEN_STRING_INITIALIZER
11616 (struct cmd_vf_split_drop_en_result,
11618 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11619 TOKEN_STRING_INITIALIZER
11620 (struct cmd_vf_split_drop_en_result,
11622 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11623 TOKEN_NUM_INITIALIZER
11624 (struct cmd_vf_split_drop_en_result,
11625 port_id, RTE_UINT16);
11626 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11627 TOKEN_NUM_INITIALIZER
11628 (struct cmd_vf_split_drop_en_result,
11629 vf_id, RTE_UINT16);
11630 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11631 TOKEN_STRING_INITIALIZER
11632 (struct cmd_vf_split_drop_en_result,
11636 cmd_set_vf_split_drop_en_parsed(
11637 void *parsed_result,
11638 __rte_unused struct cmdline *cl,
11639 __rte_unused void *data)
11641 struct cmd_vf_split_drop_en_result *res = parsed_result;
11642 int ret = -ENOTSUP;
11643 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11645 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11648 #ifdef RTE_NET_IXGBE
11649 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11656 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11657 res->vf_id, is_on);
11660 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11663 fprintf(stderr, "not supported on port %d\n", res->port_id);
11666 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11670 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11671 .f = cmd_set_vf_split_drop_en_parsed,
11673 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11675 (void *)&cmd_vf_split_drop_en_set,
11676 (void *)&cmd_vf_split_drop_en_vf,
11677 (void *)&cmd_vf_split_drop_en_split,
11678 (void *)&cmd_vf_split_drop_en_drop,
11679 (void *)&cmd_vf_split_drop_en_port_id,
11680 (void *)&cmd_vf_split_drop_en_vf_id,
11681 (void *)&cmd_vf_split_drop_en_on_off,
11686 /* vf mac address configuration */
11688 /* Common result structure for vf mac address */
11689 struct cmd_set_vf_mac_addr_result {
11690 cmdline_fixed_string_t set;
11691 cmdline_fixed_string_t vf;
11692 cmdline_fixed_string_t mac;
11693 cmdline_fixed_string_t addr;
11696 struct rte_ether_addr mac_addr;
11700 /* Common CLI fields for vf split drop enable disable */
11701 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11702 TOKEN_STRING_INITIALIZER
11703 (struct cmd_set_vf_mac_addr_result,
11705 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11706 TOKEN_STRING_INITIALIZER
11707 (struct cmd_set_vf_mac_addr_result,
11709 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11710 TOKEN_STRING_INITIALIZER
11711 (struct cmd_set_vf_mac_addr_result,
11713 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11714 TOKEN_STRING_INITIALIZER
11715 (struct cmd_set_vf_mac_addr_result,
11717 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11718 TOKEN_NUM_INITIALIZER
11719 (struct cmd_set_vf_mac_addr_result,
11720 port_id, RTE_UINT16);
11721 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11722 TOKEN_NUM_INITIALIZER
11723 (struct cmd_set_vf_mac_addr_result,
11724 vf_id, RTE_UINT16);
11725 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11726 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11730 cmd_set_vf_mac_addr_parsed(
11731 void *parsed_result,
11732 __rte_unused struct cmdline *cl,
11733 __rte_unused void *data)
11735 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11736 int ret = -ENOTSUP;
11738 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11741 #ifdef RTE_NET_IXGBE
11742 if (ret == -ENOTSUP)
11743 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11746 #ifdef RTE_NET_I40E
11747 if (ret == -ENOTSUP)
11748 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11751 #ifdef RTE_NET_BNXT
11752 if (ret == -ENOTSUP)
11753 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11761 fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
11764 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11767 fprintf(stderr, "function not implemented\n");
11770 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11774 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11775 .f = cmd_set_vf_mac_addr_parsed,
11777 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11779 (void *)&cmd_set_vf_mac_addr_set,
11780 (void *)&cmd_set_vf_mac_addr_vf,
11781 (void *)&cmd_set_vf_mac_addr_mac,
11782 (void *)&cmd_set_vf_mac_addr_addr,
11783 (void *)&cmd_set_vf_mac_addr_port_id,
11784 (void *)&cmd_set_vf_mac_addr_vf_id,
11785 (void *)&cmd_set_vf_mac_addr_mac_addr,
11790 /* MACsec configuration */
11792 /* Common result structure for MACsec offload enable */
11793 struct cmd_macsec_offload_on_result {
11794 cmdline_fixed_string_t set;
11795 cmdline_fixed_string_t macsec;
11796 cmdline_fixed_string_t offload;
11798 cmdline_fixed_string_t on;
11799 cmdline_fixed_string_t encrypt;
11800 cmdline_fixed_string_t en_on_off;
11801 cmdline_fixed_string_t replay_protect;
11802 cmdline_fixed_string_t rp_on_off;
11805 /* Common CLI fields for MACsec offload disable */
11806 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11807 TOKEN_STRING_INITIALIZER
11808 (struct cmd_macsec_offload_on_result,
11810 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11811 TOKEN_STRING_INITIALIZER
11812 (struct cmd_macsec_offload_on_result,
11814 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11815 TOKEN_STRING_INITIALIZER
11816 (struct cmd_macsec_offload_on_result,
11817 offload, "offload");
11818 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11819 TOKEN_NUM_INITIALIZER
11820 (struct cmd_macsec_offload_on_result,
11821 port_id, RTE_UINT16);
11822 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11823 TOKEN_STRING_INITIALIZER
11824 (struct cmd_macsec_offload_on_result,
11826 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11827 TOKEN_STRING_INITIALIZER
11828 (struct cmd_macsec_offload_on_result,
11829 encrypt, "encrypt");
11830 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11831 TOKEN_STRING_INITIALIZER
11832 (struct cmd_macsec_offload_on_result,
11833 en_on_off, "on#off");
11834 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11835 TOKEN_STRING_INITIALIZER
11836 (struct cmd_macsec_offload_on_result,
11837 replay_protect, "replay-protect");
11838 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11839 TOKEN_STRING_INITIALIZER
11840 (struct cmd_macsec_offload_on_result,
11841 rp_on_off, "on#off");
11844 cmd_set_macsec_offload_on_parsed(
11845 void *parsed_result,
11846 __rte_unused struct cmdline *cl,
11847 __rte_unused void *data)
11849 struct cmd_macsec_offload_on_result *res = parsed_result;
11850 int ret = -ENOTSUP;
11851 portid_t port_id = res->port_id;
11852 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11853 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11854 struct rte_eth_dev_info dev_info;
11856 if (port_id_is_invalid(port_id, ENABLED_WARN))
11858 if (!port_is_stopped(port_id)) {
11859 fprintf(stderr, "Please stop port %d first\n", port_id);
11863 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11867 if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) {
11868 #ifdef RTE_NET_IXGBE
11869 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11877 ports[port_id].dev_conf.txmode.offloads |=
11878 RTE_ETH_TX_OFFLOAD_MACSEC_INSERT;
11879 cmd_reconfig_device_queue(port_id, 1, 1);
11882 fprintf(stderr, "invalid port_id %d\n", port_id);
11885 fprintf(stderr, "not supported on port %d\n", port_id);
11888 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11892 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11893 .f = cmd_set_macsec_offload_on_parsed,
11895 .help_str = "set macsec offload <port_id> on "
11896 "encrypt on|off replay-protect on|off",
11898 (void *)&cmd_macsec_offload_on_set,
11899 (void *)&cmd_macsec_offload_on_macsec,
11900 (void *)&cmd_macsec_offload_on_offload,
11901 (void *)&cmd_macsec_offload_on_port_id,
11902 (void *)&cmd_macsec_offload_on_on,
11903 (void *)&cmd_macsec_offload_on_encrypt,
11904 (void *)&cmd_macsec_offload_on_en_on_off,
11905 (void *)&cmd_macsec_offload_on_replay_protect,
11906 (void *)&cmd_macsec_offload_on_rp_on_off,
11911 /* Common result structure for MACsec offload disable */
11912 struct cmd_macsec_offload_off_result {
11913 cmdline_fixed_string_t set;
11914 cmdline_fixed_string_t macsec;
11915 cmdline_fixed_string_t offload;
11917 cmdline_fixed_string_t off;
11920 /* Common CLI fields for MACsec offload disable */
11921 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11922 TOKEN_STRING_INITIALIZER
11923 (struct cmd_macsec_offload_off_result,
11925 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11926 TOKEN_STRING_INITIALIZER
11927 (struct cmd_macsec_offload_off_result,
11929 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11930 TOKEN_STRING_INITIALIZER
11931 (struct cmd_macsec_offload_off_result,
11932 offload, "offload");
11933 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11934 TOKEN_NUM_INITIALIZER
11935 (struct cmd_macsec_offload_off_result,
11936 port_id, RTE_UINT16);
11937 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11938 TOKEN_STRING_INITIALIZER
11939 (struct cmd_macsec_offload_off_result,
11943 cmd_set_macsec_offload_off_parsed(
11944 void *parsed_result,
11945 __rte_unused struct cmdline *cl,
11946 __rte_unused void *data)
11948 struct cmd_macsec_offload_off_result *res = parsed_result;
11949 int ret = -ENOTSUP;
11950 struct rte_eth_dev_info dev_info;
11951 portid_t port_id = res->port_id;
11953 if (port_id_is_invalid(port_id, ENABLED_WARN))
11955 if (!port_is_stopped(port_id)) {
11956 fprintf(stderr, "Please stop port %d first\n", port_id);
11960 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11964 if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) {
11965 #ifdef RTE_NET_IXGBE
11966 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11971 ports[port_id].dev_conf.txmode.offloads &=
11972 ~RTE_ETH_TX_OFFLOAD_MACSEC_INSERT;
11973 cmd_reconfig_device_queue(port_id, 1, 1);
11976 fprintf(stderr, "invalid port_id %d\n", port_id);
11979 fprintf(stderr, "not supported on port %d\n", port_id);
11982 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11986 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11987 .f = cmd_set_macsec_offload_off_parsed,
11989 .help_str = "set macsec offload <port_id> off",
11991 (void *)&cmd_macsec_offload_off_set,
11992 (void *)&cmd_macsec_offload_off_macsec,
11993 (void *)&cmd_macsec_offload_off_offload,
11994 (void *)&cmd_macsec_offload_off_port_id,
11995 (void *)&cmd_macsec_offload_off_off,
12000 /* Common result structure for MACsec secure connection configure */
12001 struct cmd_macsec_sc_result {
12002 cmdline_fixed_string_t set;
12003 cmdline_fixed_string_t macsec;
12004 cmdline_fixed_string_t sc;
12005 cmdline_fixed_string_t tx_rx;
12007 struct rte_ether_addr mac;
12011 /* Common CLI fields for MACsec secure connection configure */
12012 cmdline_parse_token_string_t cmd_macsec_sc_set =
12013 TOKEN_STRING_INITIALIZER
12014 (struct cmd_macsec_sc_result,
12016 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
12017 TOKEN_STRING_INITIALIZER
12018 (struct cmd_macsec_sc_result,
12020 cmdline_parse_token_string_t cmd_macsec_sc_sc =
12021 TOKEN_STRING_INITIALIZER
12022 (struct cmd_macsec_sc_result,
12024 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
12025 TOKEN_STRING_INITIALIZER
12026 (struct cmd_macsec_sc_result,
12028 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
12029 TOKEN_NUM_INITIALIZER
12030 (struct cmd_macsec_sc_result,
12031 port_id, RTE_UINT16);
12032 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
12033 TOKEN_ETHERADDR_INITIALIZER
12034 (struct cmd_macsec_sc_result,
12036 cmdline_parse_token_num_t cmd_macsec_sc_pi =
12037 TOKEN_NUM_INITIALIZER
12038 (struct cmd_macsec_sc_result,
12042 cmd_set_macsec_sc_parsed(
12043 void *parsed_result,
12044 __rte_unused struct cmdline *cl,
12045 __rte_unused void *data)
12047 struct cmd_macsec_sc_result *res = parsed_result;
12048 int ret = -ENOTSUP;
12049 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12051 #ifdef RTE_NET_IXGBE
12053 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12054 res->mac.addr_bytes) :
12055 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12056 res->mac.addr_bytes, res->pi);
12058 RTE_SET_USED(is_tx);
12064 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12067 fprintf(stderr, "not supported on port %d\n", res->port_id);
12070 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12074 cmdline_parse_inst_t cmd_set_macsec_sc = {
12075 .f = cmd_set_macsec_sc_parsed,
12077 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12079 (void *)&cmd_macsec_sc_set,
12080 (void *)&cmd_macsec_sc_macsec,
12081 (void *)&cmd_macsec_sc_sc,
12082 (void *)&cmd_macsec_sc_tx_rx,
12083 (void *)&cmd_macsec_sc_port_id,
12084 (void *)&cmd_macsec_sc_mac,
12085 (void *)&cmd_macsec_sc_pi,
12090 /* Common result structure for MACsec secure connection configure */
12091 struct cmd_macsec_sa_result {
12092 cmdline_fixed_string_t set;
12093 cmdline_fixed_string_t macsec;
12094 cmdline_fixed_string_t sa;
12095 cmdline_fixed_string_t tx_rx;
12100 cmdline_fixed_string_t key;
12103 /* Common CLI fields for MACsec secure connection configure */
12104 cmdline_parse_token_string_t cmd_macsec_sa_set =
12105 TOKEN_STRING_INITIALIZER
12106 (struct cmd_macsec_sa_result,
12108 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12109 TOKEN_STRING_INITIALIZER
12110 (struct cmd_macsec_sa_result,
12112 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12113 TOKEN_STRING_INITIALIZER
12114 (struct cmd_macsec_sa_result,
12116 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12117 TOKEN_STRING_INITIALIZER
12118 (struct cmd_macsec_sa_result,
12120 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12121 TOKEN_NUM_INITIALIZER
12122 (struct cmd_macsec_sa_result,
12123 port_id, RTE_UINT16);
12124 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12125 TOKEN_NUM_INITIALIZER
12126 (struct cmd_macsec_sa_result,
12128 cmdline_parse_token_num_t cmd_macsec_sa_an =
12129 TOKEN_NUM_INITIALIZER
12130 (struct cmd_macsec_sa_result,
12132 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12133 TOKEN_NUM_INITIALIZER
12134 (struct cmd_macsec_sa_result,
12136 cmdline_parse_token_string_t cmd_macsec_sa_key =
12137 TOKEN_STRING_INITIALIZER
12138 (struct cmd_macsec_sa_result,
12142 cmd_set_macsec_sa_parsed(
12143 void *parsed_result,
12144 __rte_unused struct cmdline *cl,
12145 __rte_unused void *data)
12147 struct cmd_macsec_sa_result *res = parsed_result;
12148 int ret = -ENOTSUP;
12149 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12150 uint8_t key[16] = { 0 };
12156 key_len = strlen(res->key) / 2;
12160 for (i = 0; i < key_len; i++) {
12161 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12164 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12167 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12170 #ifdef RTE_NET_IXGBE
12172 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12173 res->idx, res->an, res->pn, key) :
12174 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12175 res->idx, res->an, res->pn, key);
12177 RTE_SET_USED(is_tx);
12184 fprintf(stderr, "invalid idx %d or an %d\n", res->idx, res->an);
12187 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12190 fprintf(stderr, "not supported on port %d\n", res->port_id);
12193 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12197 cmdline_parse_inst_t cmd_set_macsec_sa = {
12198 .f = cmd_set_macsec_sa_parsed,
12200 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12202 (void *)&cmd_macsec_sa_set,
12203 (void *)&cmd_macsec_sa_macsec,
12204 (void *)&cmd_macsec_sa_sa,
12205 (void *)&cmd_macsec_sa_tx_rx,
12206 (void *)&cmd_macsec_sa_port_id,
12207 (void *)&cmd_macsec_sa_idx,
12208 (void *)&cmd_macsec_sa_an,
12209 (void *)&cmd_macsec_sa_pn,
12210 (void *)&cmd_macsec_sa_key,
12215 /* VF unicast promiscuous mode configuration */
12217 /* Common result structure for VF unicast promiscuous mode */
12218 struct cmd_vf_promisc_result {
12219 cmdline_fixed_string_t set;
12220 cmdline_fixed_string_t vf;
12221 cmdline_fixed_string_t promisc;
12224 cmdline_fixed_string_t on_off;
12227 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12228 cmdline_parse_token_string_t cmd_vf_promisc_set =
12229 TOKEN_STRING_INITIALIZER
12230 (struct cmd_vf_promisc_result,
12232 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12233 TOKEN_STRING_INITIALIZER
12234 (struct cmd_vf_promisc_result,
12236 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12237 TOKEN_STRING_INITIALIZER
12238 (struct cmd_vf_promisc_result,
12239 promisc, "promisc");
12240 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12241 TOKEN_NUM_INITIALIZER
12242 (struct cmd_vf_promisc_result,
12243 port_id, RTE_UINT16);
12244 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12245 TOKEN_NUM_INITIALIZER
12246 (struct cmd_vf_promisc_result,
12247 vf_id, RTE_UINT32);
12248 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12249 TOKEN_STRING_INITIALIZER
12250 (struct cmd_vf_promisc_result,
12254 cmd_set_vf_promisc_parsed(
12255 void *parsed_result,
12256 __rte_unused struct cmdline *cl,
12257 __rte_unused void *data)
12259 struct cmd_vf_promisc_result *res = parsed_result;
12260 int ret = -ENOTSUP;
12262 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12264 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12267 #ifdef RTE_NET_I40E
12268 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12269 res->vf_id, is_on);
12276 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12279 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12282 fprintf(stderr, "function not implemented\n");
12285 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12289 cmdline_parse_inst_t cmd_set_vf_promisc = {
12290 .f = cmd_set_vf_promisc_parsed,
12292 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12293 "Set unicast promiscuous mode for a VF from the PF",
12295 (void *)&cmd_vf_promisc_set,
12296 (void *)&cmd_vf_promisc_vf,
12297 (void *)&cmd_vf_promisc_promisc,
12298 (void *)&cmd_vf_promisc_port_id,
12299 (void *)&cmd_vf_promisc_vf_id,
12300 (void *)&cmd_vf_promisc_on_off,
12305 /* VF multicast promiscuous mode configuration */
12307 /* Common result structure for VF multicast promiscuous mode */
12308 struct cmd_vf_allmulti_result {
12309 cmdline_fixed_string_t set;
12310 cmdline_fixed_string_t vf;
12311 cmdline_fixed_string_t allmulti;
12314 cmdline_fixed_string_t on_off;
12317 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12318 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12319 TOKEN_STRING_INITIALIZER
12320 (struct cmd_vf_allmulti_result,
12322 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12323 TOKEN_STRING_INITIALIZER
12324 (struct cmd_vf_allmulti_result,
12326 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12327 TOKEN_STRING_INITIALIZER
12328 (struct cmd_vf_allmulti_result,
12329 allmulti, "allmulti");
12330 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12331 TOKEN_NUM_INITIALIZER
12332 (struct cmd_vf_allmulti_result,
12333 port_id, RTE_UINT16);
12334 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12335 TOKEN_NUM_INITIALIZER
12336 (struct cmd_vf_allmulti_result,
12337 vf_id, RTE_UINT32);
12338 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12339 TOKEN_STRING_INITIALIZER
12340 (struct cmd_vf_allmulti_result,
12344 cmd_set_vf_allmulti_parsed(
12345 void *parsed_result,
12346 __rte_unused struct cmdline *cl,
12347 __rte_unused void *data)
12349 struct cmd_vf_allmulti_result *res = parsed_result;
12350 int ret = -ENOTSUP;
12352 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12354 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12357 #ifdef RTE_NET_I40E
12358 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12359 res->vf_id, is_on);
12366 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12369 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12372 fprintf(stderr, "function not implemented\n");
12375 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12379 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12380 .f = cmd_set_vf_allmulti_parsed,
12382 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12383 "Set multicast promiscuous mode for a VF from the PF",
12385 (void *)&cmd_vf_allmulti_set,
12386 (void *)&cmd_vf_allmulti_vf,
12387 (void *)&cmd_vf_allmulti_allmulti,
12388 (void *)&cmd_vf_allmulti_port_id,
12389 (void *)&cmd_vf_allmulti_vf_id,
12390 (void *)&cmd_vf_allmulti_on_off,
12395 /* vf broadcast mode configuration */
12397 /* Common result structure for vf broadcast */
12398 struct cmd_set_vf_broadcast_result {
12399 cmdline_fixed_string_t set;
12400 cmdline_fixed_string_t vf;
12401 cmdline_fixed_string_t broadcast;
12404 cmdline_fixed_string_t on_off;
12407 /* Common CLI fields for vf broadcast enable disable */
12408 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12409 TOKEN_STRING_INITIALIZER
12410 (struct cmd_set_vf_broadcast_result,
12412 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12413 TOKEN_STRING_INITIALIZER
12414 (struct cmd_set_vf_broadcast_result,
12416 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12417 TOKEN_STRING_INITIALIZER
12418 (struct cmd_set_vf_broadcast_result,
12419 broadcast, "broadcast");
12420 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12421 TOKEN_NUM_INITIALIZER
12422 (struct cmd_set_vf_broadcast_result,
12423 port_id, RTE_UINT16);
12424 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12425 TOKEN_NUM_INITIALIZER
12426 (struct cmd_set_vf_broadcast_result,
12427 vf_id, RTE_UINT16);
12428 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12429 TOKEN_STRING_INITIALIZER
12430 (struct cmd_set_vf_broadcast_result,
12434 cmd_set_vf_broadcast_parsed(
12435 void *parsed_result,
12436 __rte_unused struct cmdline *cl,
12437 __rte_unused void *data)
12439 struct cmd_set_vf_broadcast_result *res = parsed_result;
12440 int ret = -ENOTSUP;
12442 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12444 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12447 #ifdef RTE_NET_I40E
12448 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12449 res->vf_id, is_on);
12456 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12457 res->vf_id, is_on);
12460 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12463 fprintf(stderr, "function not implemented\n");
12466 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12470 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12471 .f = cmd_set_vf_broadcast_parsed,
12473 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12475 (void *)&cmd_set_vf_broadcast_set,
12476 (void *)&cmd_set_vf_broadcast_vf,
12477 (void *)&cmd_set_vf_broadcast_broadcast,
12478 (void *)&cmd_set_vf_broadcast_port_id,
12479 (void *)&cmd_set_vf_broadcast_vf_id,
12480 (void *)&cmd_set_vf_broadcast_on_off,
12485 /* vf vlan tag configuration */
12487 /* Common result structure for vf vlan tag */
12488 struct cmd_set_vf_vlan_tag_result {
12489 cmdline_fixed_string_t set;
12490 cmdline_fixed_string_t vf;
12491 cmdline_fixed_string_t vlan;
12492 cmdline_fixed_string_t tag;
12495 cmdline_fixed_string_t on_off;
12498 /* Common CLI fields for vf vlan tag enable disable */
12499 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12500 TOKEN_STRING_INITIALIZER
12501 (struct cmd_set_vf_vlan_tag_result,
12503 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12504 TOKEN_STRING_INITIALIZER
12505 (struct cmd_set_vf_vlan_tag_result,
12507 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12508 TOKEN_STRING_INITIALIZER
12509 (struct cmd_set_vf_vlan_tag_result,
12511 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12512 TOKEN_STRING_INITIALIZER
12513 (struct cmd_set_vf_vlan_tag_result,
12515 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12516 TOKEN_NUM_INITIALIZER
12517 (struct cmd_set_vf_vlan_tag_result,
12518 port_id, RTE_UINT16);
12519 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12520 TOKEN_NUM_INITIALIZER
12521 (struct cmd_set_vf_vlan_tag_result,
12522 vf_id, RTE_UINT16);
12523 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12524 TOKEN_STRING_INITIALIZER
12525 (struct cmd_set_vf_vlan_tag_result,
12529 cmd_set_vf_vlan_tag_parsed(
12530 void *parsed_result,
12531 __rte_unused struct cmdline *cl,
12532 __rte_unused void *data)
12534 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12535 int ret = -ENOTSUP;
12537 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12539 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12542 #ifdef RTE_NET_I40E
12543 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12544 res->vf_id, is_on);
12551 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12552 res->vf_id, is_on);
12555 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12558 fprintf(stderr, "function not implemented\n");
12561 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12565 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12566 .f = cmd_set_vf_vlan_tag_parsed,
12568 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12570 (void *)&cmd_set_vf_vlan_tag_set,
12571 (void *)&cmd_set_vf_vlan_tag_vf,
12572 (void *)&cmd_set_vf_vlan_tag_vlan,
12573 (void *)&cmd_set_vf_vlan_tag_tag,
12574 (void *)&cmd_set_vf_vlan_tag_port_id,
12575 (void *)&cmd_set_vf_vlan_tag_vf_id,
12576 (void *)&cmd_set_vf_vlan_tag_on_off,
12581 /* Common definition of VF and TC TX bandwidth configuration */
12582 struct cmd_vf_tc_bw_result {
12583 cmdline_fixed_string_t set;
12584 cmdline_fixed_string_t vf;
12585 cmdline_fixed_string_t tc;
12586 cmdline_fixed_string_t tx;
12587 cmdline_fixed_string_t min_bw;
12588 cmdline_fixed_string_t max_bw;
12589 cmdline_fixed_string_t strict_link_prio;
12594 cmdline_fixed_string_t bw_list;
12598 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12599 TOKEN_STRING_INITIALIZER
12600 (struct cmd_vf_tc_bw_result,
12602 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12603 TOKEN_STRING_INITIALIZER
12604 (struct cmd_vf_tc_bw_result,
12606 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12607 TOKEN_STRING_INITIALIZER
12608 (struct cmd_vf_tc_bw_result,
12610 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12611 TOKEN_STRING_INITIALIZER
12612 (struct cmd_vf_tc_bw_result,
12614 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12615 TOKEN_STRING_INITIALIZER
12616 (struct cmd_vf_tc_bw_result,
12617 strict_link_prio, "strict-link-priority");
12618 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12619 TOKEN_STRING_INITIALIZER
12620 (struct cmd_vf_tc_bw_result,
12621 min_bw, "min-bandwidth");
12622 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12623 TOKEN_STRING_INITIALIZER
12624 (struct cmd_vf_tc_bw_result,
12625 max_bw, "max-bandwidth");
12626 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12627 TOKEN_NUM_INITIALIZER
12628 (struct cmd_vf_tc_bw_result,
12629 port_id, RTE_UINT16);
12630 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12631 TOKEN_NUM_INITIALIZER
12632 (struct cmd_vf_tc_bw_result,
12633 vf_id, RTE_UINT16);
12634 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12635 TOKEN_NUM_INITIALIZER
12636 (struct cmd_vf_tc_bw_result,
12638 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12639 TOKEN_NUM_INITIALIZER
12640 (struct cmd_vf_tc_bw_result,
12642 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12643 TOKEN_STRING_INITIALIZER
12644 (struct cmd_vf_tc_bw_result,
12646 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12647 TOKEN_NUM_INITIALIZER
12648 (struct cmd_vf_tc_bw_result,
12649 tc_map, RTE_UINT8);
12651 /* VF max bandwidth setting */
12653 cmd_vf_max_bw_parsed(
12654 void *parsed_result,
12655 __rte_unused struct cmdline *cl,
12656 __rte_unused void *data)
12658 struct cmd_vf_tc_bw_result *res = parsed_result;
12659 int ret = -ENOTSUP;
12661 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12664 #ifdef RTE_NET_I40E
12665 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12666 res->vf_id, res->bw);
12673 fprintf(stderr, "invalid vf_id %d or bandwidth %d\n",
12674 res->vf_id, res->bw);
12677 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12680 fprintf(stderr, "function not implemented\n");
12683 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12687 cmdline_parse_inst_t cmd_vf_max_bw = {
12688 .f = cmd_vf_max_bw_parsed,
12690 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12692 (void *)&cmd_vf_tc_bw_set,
12693 (void *)&cmd_vf_tc_bw_vf,
12694 (void *)&cmd_vf_tc_bw_tx,
12695 (void *)&cmd_vf_tc_bw_max_bw,
12696 (void *)&cmd_vf_tc_bw_port_id,
12697 (void *)&cmd_vf_tc_bw_vf_id,
12698 (void *)&cmd_vf_tc_bw_bw,
12704 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12709 const char *p, *p0 = str;
12716 p = strchr(p0, '(');
12719 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12723 p0 = strchr(p, ')');
12726 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12730 if (size >= sizeof(s)) {
12732 "The string size exceeds the internal buffer size\n");
12735 snprintf(s, sizeof(s), "%.*s", size, p);
12736 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12738 fprintf(stderr, "Failed to get the bandwidth list.\n");
12742 for (i = 0; i < ret; i++)
12743 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12748 /* TC min bandwidth setting */
12750 cmd_vf_tc_min_bw_parsed(
12751 void *parsed_result,
12752 __rte_unused struct cmdline *cl,
12753 __rte_unused void *data)
12755 struct cmd_vf_tc_bw_result *res = parsed_result;
12758 int ret = -ENOTSUP;
12760 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12763 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12767 #ifdef RTE_NET_I40E
12768 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12776 fprintf(stderr, "invalid vf_id %d or bandwidth\n", res->vf_id);
12779 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12782 fprintf(stderr, "function not implemented\n");
12785 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12789 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12790 .f = cmd_vf_tc_min_bw_parsed,
12792 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12793 " <bw1, bw2, ...>",
12795 (void *)&cmd_vf_tc_bw_set,
12796 (void *)&cmd_vf_tc_bw_vf,
12797 (void *)&cmd_vf_tc_bw_tc,
12798 (void *)&cmd_vf_tc_bw_tx,
12799 (void *)&cmd_vf_tc_bw_min_bw,
12800 (void *)&cmd_vf_tc_bw_port_id,
12801 (void *)&cmd_vf_tc_bw_vf_id,
12802 (void *)&cmd_vf_tc_bw_bw_list,
12808 cmd_tc_min_bw_parsed(
12809 void *parsed_result,
12810 __rte_unused struct cmdline *cl,
12811 __rte_unused void *data)
12813 struct cmd_vf_tc_bw_result *res = parsed_result;
12814 struct rte_port *port;
12817 int ret = -ENOTSUP;
12819 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12822 port = &ports[res->port_id];
12823 /** Check if the port is not started **/
12824 if (port->port_status != RTE_PORT_STOPPED) {
12825 fprintf(stderr, "Please stop port %d first\n", res->port_id);
12829 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12833 #ifdef RTE_NET_IXGBE
12834 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12841 fprintf(stderr, "invalid bandwidth\n");
12844 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12847 fprintf(stderr, "function not implemented\n");
12850 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12854 cmdline_parse_inst_t cmd_tc_min_bw = {
12855 .f = cmd_tc_min_bw_parsed,
12857 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12859 (void *)&cmd_vf_tc_bw_set,
12860 (void *)&cmd_vf_tc_bw_tc,
12861 (void *)&cmd_vf_tc_bw_tx,
12862 (void *)&cmd_vf_tc_bw_min_bw,
12863 (void *)&cmd_vf_tc_bw_port_id,
12864 (void *)&cmd_vf_tc_bw_bw_list,
12869 /* TC max bandwidth setting */
12871 cmd_vf_tc_max_bw_parsed(
12872 void *parsed_result,
12873 __rte_unused struct cmdline *cl,
12874 __rte_unused void *data)
12876 struct cmd_vf_tc_bw_result *res = parsed_result;
12877 int ret = -ENOTSUP;
12879 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12882 #ifdef RTE_NET_I40E
12883 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12884 res->tc_no, res->bw);
12892 "invalid vf_id %d, tc_no %d or bandwidth %d\n",
12893 res->vf_id, res->tc_no, res->bw);
12896 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12899 fprintf(stderr, "function not implemented\n");
12902 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12906 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12907 .f = cmd_vf_tc_max_bw_parsed,
12909 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12912 (void *)&cmd_vf_tc_bw_set,
12913 (void *)&cmd_vf_tc_bw_vf,
12914 (void *)&cmd_vf_tc_bw_tc,
12915 (void *)&cmd_vf_tc_bw_tx,
12916 (void *)&cmd_vf_tc_bw_max_bw,
12917 (void *)&cmd_vf_tc_bw_port_id,
12918 (void *)&cmd_vf_tc_bw_vf_id,
12919 (void *)&cmd_vf_tc_bw_tc_no,
12920 (void *)&cmd_vf_tc_bw_bw,
12925 /** Set VXLAN encapsulation details */
12926 struct cmd_set_vxlan_result {
12927 cmdline_fixed_string_t set;
12928 cmdline_fixed_string_t vxlan;
12929 cmdline_fixed_string_t pos_token;
12930 cmdline_fixed_string_t ip_version;
12931 uint32_t vlan_present:1;
12935 cmdline_ipaddr_t ip_src;
12936 cmdline_ipaddr_t ip_dst;
12940 struct rte_ether_addr eth_src;
12941 struct rte_ether_addr eth_dst;
12944 cmdline_parse_token_string_t cmd_set_vxlan_set =
12945 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
12946 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
12947 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
12948 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
12949 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12951 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
12952 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12953 "vxlan-with-vlan");
12954 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
12955 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12957 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
12958 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
12960 cmdline_parse_token_string_t cmd_set_vxlan_vni =
12961 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12963 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
12964 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
12965 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
12966 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12968 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
12969 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
12970 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
12971 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12973 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
12974 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
12975 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
12976 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12978 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
12979 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
12980 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
12981 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12983 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
12984 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
12985 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
12986 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12988 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
12989 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
12990 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
12991 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12993 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
12994 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
12995 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
12996 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12998 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
12999 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
13000 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
13001 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13003 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
13004 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
13005 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
13006 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13008 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
13009 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
13011 static void cmd_set_vxlan_parsed(void *parsed_result,
13012 __rte_unused struct cmdline *cl,
13013 __rte_unused void *data)
13015 struct cmd_set_vxlan_result *res = parsed_result;
13020 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
13023 vxlan_encap_conf.select_tos_ttl = 0;
13024 if (strcmp(res->vxlan, "vxlan") == 0)
13025 vxlan_encap_conf.select_vlan = 0;
13026 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
13027 vxlan_encap_conf.select_vlan = 1;
13028 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
13029 vxlan_encap_conf.select_vlan = 0;
13030 vxlan_encap_conf.select_tos_ttl = 1;
13032 if (strcmp(res->ip_version, "ipv4") == 0)
13033 vxlan_encap_conf.select_ipv4 = 1;
13034 else if (strcmp(res->ip_version, "ipv6") == 0)
13035 vxlan_encap_conf.select_ipv4 = 0;
13038 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
13039 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13040 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13041 vxlan_encap_conf.ip_tos = res->tos;
13042 vxlan_encap_conf.ip_ttl = res->ttl;
13043 if (vxlan_encap_conf.select_ipv4) {
13044 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
13045 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
13047 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
13048 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
13050 if (vxlan_encap_conf.select_vlan)
13051 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13052 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
13053 RTE_ETHER_ADDR_LEN);
13054 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13055 RTE_ETHER_ADDR_LEN);
13058 cmdline_parse_inst_t cmd_set_vxlan = {
13059 .f = cmd_set_vxlan_parsed,
13061 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
13062 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
13063 " eth-src <eth-src> eth-dst <eth-dst>",
13065 (void *)&cmd_set_vxlan_set,
13066 (void *)&cmd_set_vxlan_vxlan,
13067 (void *)&cmd_set_vxlan_ip_version,
13068 (void *)&cmd_set_vxlan_ip_version_value,
13069 (void *)&cmd_set_vxlan_vni,
13070 (void *)&cmd_set_vxlan_vni_value,
13071 (void *)&cmd_set_vxlan_udp_src,
13072 (void *)&cmd_set_vxlan_udp_src_value,
13073 (void *)&cmd_set_vxlan_udp_dst,
13074 (void *)&cmd_set_vxlan_udp_dst_value,
13075 (void *)&cmd_set_vxlan_ip_src,
13076 (void *)&cmd_set_vxlan_ip_src_value,
13077 (void *)&cmd_set_vxlan_ip_dst,
13078 (void *)&cmd_set_vxlan_ip_dst_value,
13079 (void *)&cmd_set_vxlan_eth_src,
13080 (void *)&cmd_set_vxlan_eth_src_value,
13081 (void *)&cmd_set_vxlan_eth_dst,
13082 (void *)&cmd_set_vxlan_eth_dst_value,
13087 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
13088 .f = cmd_set_vxlan_parsed,
13090 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
13091 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
13092 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13093 " eth-dst <eth-dst>",
13095 (void *)&cmd_set_vxlan_set,
13096 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
13097 (void *)&cmd_set_vxlan_ip_version,
13098 (void *)&cmd_set_vxlan_ip_version_value,
13099 (void *)&cmd_set_vxlan_vni,
13100 (void *)&cmd_set_vxlan_vni_value,
13101 (void *)&cmd_set_vxlan_udp_src,
13102 (void *)&cmd_set_vxlan_udp_src_value,
13103 (void *)&cmd_set_vxlan_udp_dst,
13104 (void *)&cmd_set_vxlan_udp_dst_value,
13105 (void *)&cmd_set_vxlan_ip_tos,
13106 (void *)&cmd_set_vxlan_ip_tos_value,
13107 (void *)&cmd_set_vxlan_ip_ttl,
13108 (void *)&cmd_set_vxlan_ip_ttl_value,
13109 (void *)&cmd_set_vxlan_ip_src,
13110 (void *)&cmd_set_vxlan_ip_src_value,
13111 (void *)&cmd_set_vxlan_ip_dst,
13112 (void *)&cmd_set_vxlan_ip_dst_value,
13113 (void *)&cmd_set_vxlan_eth_src,
13114 (void *)&cmd_set_vxlan_eth_src_value,
13115 (void *)&cmd_set_vxlan_eth_dst,
13116 (void *)&cmd_set_vxlan_eth_dst_value,
13121 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
13122 .f = cmd_set_vxlan_parsed,
13124 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
13125 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
13126 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
13129 (void *)&cmd_set_vxlan_set,
13130 (void *)&cmd_set_vxlan_vxlan_with_vlan,
13131 (void *)&cmd_set_vxlan_ip_version,
13132 (void *)&cmd_set_vxlan_ip_version_value,
13133 (void *)&cmd_set_vxlan_vni,
13134 (void *)&cmd_set_vxlan_vni_value,
13135 (void *)&cmd_set_vxlan_udp_src,
13136 (void *)&cmd_set_vxlan_udp_src_value,
13137 (void *)&cmd_set_vxlan_udp_dst,
13138 (void *)&cmd_set_vxlan_udp_dst_value,
13139 (void *)&cmd_set_vxlan_ip_src,
13140 (void *)&cmd_set_vxlan_ip_src_value,
13141 (void *)&cmd_set_vxlan_ip_dst,
13142 (void *)&cmd_set_vxlan_ip_dst_value,
13143 (void *)&cmd_set_vxlan_vlan,
13144 (void *)&cmd_set_vxlan_vlan_value,
13145 (void *)&cmd_set_vxlan_eth_src,
13146 (void *)&cmd_set_vxlan_eth_src_value,
13147 (void *)&cmd_set_vxlan_eth_dst,
13148 (void *)&cmd_set_vxlan_eth_dst_value,
13153 /** Set NVGRE encapsulation details */
13154 struct cmd_set_nvgre_result {
13155 cmdline_fixed_string_t set;
13156 cmdline_fixed_string_t nvgre;
13157 cmdline_fixed_string_t pos_token;
13158 cmdline_fixed_string_t ip_version;
13160 cmdline_ipaddr_t ip_src;
13161 cmdline_ipaddr_t ip_dst;
13163 struct rte_ether_addr eth_src;
13164 struct rte_ether_addr eth_dst;
13167 cmdline_parse_token_string_t cmd_set_nvgre_set =
13168 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
13169 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
13170 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
13171 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
13172 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
13173 "nvgre-with-vlan");
13174 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
13175 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13177 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
13178 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
13180 cmdline_parse_token_string_t cmd_set_nvgre_tni =
13181 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13183 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
13184 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
13185 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
13186 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13188 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
13189 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
13190 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
13191 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13193 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
13194 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
13195 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
13196 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13198 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
13199 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
13200 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
13201 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13203 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
13204 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
13205 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
13206 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13208 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
13209 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
13211 static void cmd_set_nvgre_parsed(void *parsed_result,
13212 __rte_unused struct cmdline *cl,
13213 __rte_unused void *data)
13215 struct cmd_set_nvgre_result *res = parsed_result;
13217 uint32_t nvgre_tni;
13220 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
13223 if (strcmp(res->nvgre, "nvgre") == 0)
13224 nvgre_encap_conf.select_vlan = 0;
13225 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
13226 nvgre_encap_conf.select_vlan = 1;
13227 if (strcmp(res->ip_version, "ipv4") == 0)
13228 nvgre_encap_conf.select_ipv4 = 1;
13229 else if (strcmp(res->ip_version, "ipv6") == 0)
13230 nvgre_encap_conf.select_ipv4 = 0;
13233 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
13234 if (nvgre_encap_conf.select_ipv4) {
13235 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
13236 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
13238 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
13239 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
13241 if (nvgre_encap_conf.select_vlan)
13242 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13243 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
13244 RTE_ETHER_ADDR_LEN);
13245 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13246 RTE_ETHER_ADDR_LEN);
13249 cmdline_parse_inst_t cmd_set_nvgre = {
13250 .f = cmd_set_nvgre_parsed,
13252 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
13253 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13254 " eth-dst <eth-dst>",
13256 (void *)&cmd_set_nvgre_set,
13257 (void *)&cmd_set_nvgre_nvgre,
13258 (void *)&cmd_set_nvgre_ip_version,
13259 (void *)&cmd_set_nvgre_ip_version_value,
13260 (void *)&cmd_set_nvgre_tni,
13261 (void *)&cmd_set_nvgre_tni_value,
13262 (void *)&cmd_set_nvgre_ip_src,
13263 (void *)&cmd_set_nvgre_ip_src_value,
13264 (void *)&cmd_set_nvgre_ip_dst,
13265 (void *)&cmd_set_nvgre_ip_dst_value,
13266 (void *)&cmd_set_nvgre_eth_src,
13267 (void *)&cmd_set_nvgre_eth_src_value,
13268 (void *)&cmd_set_nvgre_eth_dst,
13269 (void *)&cmd_set_nvgre_eth_dst_value,
13274 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
13275 .f = cmd_set_nvgre_parsed,
13277 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
13278 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13279 " eth-src <eth-src> eth-dst <eth-dst>",
13281 (void *)&cmd_set_nvgre_set,
13282 (void *)&cmd_set_nvgre_nvgre_with_vlan,
13283 (void *)&cmd_set_nvgre_ip_version,
13284 (void *)&cmd_set_nvgre_ip_version_value,
13285 (void *)&cmd_set_nvgre_tni,
13286 (void *)&cmd_set_nvgre_tni_value,
13287 (void *)&cmd_set_nvgre_ip_src,
13288 (void *)&cmd_set_nvgre_ip_src_value,
13289 (void *)&cmd_set_nvgre_ip_dst,
13290 (void *)&cmd_set_nvgre_ip_dst_value,
13291 (void *)&cmd_set_nvgre_vlan,
13292 (void *)&cmd_set_nvgre_vlan_value,
13293 (void *)&cmd_set_nvgre_eth_src,
13294 (void *)&cmd_set_nvgre_eth_src_value,
13295 (void *)&cmd_set_nvgre_eth_dst,
13296 (void *)&cmd_set_nvgre_eth_dst_value,
13301 /** Set L2 encapsulation details */
13302 struct cmd_set_l2_encap_result {
13303 cmdline_fixed_string_t set;
13304 cmdline_fixed_string_t l2_encap;
13305 cmdline_fixed_string_t pos_token;
13306 cmdline_fixed_string_t ip_version;
13307 uint32_t vlan_present:1;
13309 struct rte_ether_addr eth_src;
13310 struct rte_ether_addr eth_dst;
13313 cmdline_parse_token_string_t cmd_set_l2_encap_set =
13314 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13315 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13316 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13317 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13318 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13319 "l2_encap-with-vlan");
13320 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13321 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13323 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13324 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13326 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13327 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13329 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13330 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13331 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13332 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13334 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13335 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13336 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13337 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13339 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13340 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13342 static void cmd_set_l2_encap_parsed(void *parsed_result,
13343 __rte_unused struct cmdline *cl,
13344 __rte_unused void *data)
13346 struct cmd_set_l2_encap_result *res = parsed_result;
13348 if (strcmp(res->l2_encap, "l2_encap") == 0)
13349 l2_encap_conf.select_vlan = 0;
13350 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13351 l2_encap_conf.select_vlan = 1;
13352 if (strcmp(res->ip_version, "ipv4") == 0)
13353 l2_encap_conf.select_ipv4 = 1;
13354 else if (strcmp(res->ip_version, "ipv6") == 0)
13355 l2_encap_conf.select_ipv4 = 0;
13358 if (l2_encap_conf.select_vlan)
13359 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13360 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13361 RTE_ETHER_ADDR_LEN);
13362 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13363 RTE_ETHER_ADDR_LEN);
13366 cmdline_parse_inst_t cmd_set_l2_encap = {
13367 .f = cmd_set_l2_encap_parsed,
13369 .help_str = "set l2_encap ip-version ipv4|ipv6"
13370 " eth-src <eth-src> eth-dst <eth-dst>",
13372 (void *)&cmd_set_l2_encap_set,
13373 (void *)&cmd_set_l2_encap_l2_encap,
13374 (void *)&cmd_set_l2_encap_ip_version,
13375 (void *)&cmd_set_l2_encap_ip_version_value,
13376 (void *)&cmd_set_l2_encap_eth_src,
13377 (void *)&cmd_set_l2_encap_eth_src_value,
13378 (void *)&cmd_set_l2_encap_eth_dst,
13379 (void *)&cmd_set_l2_encap_eth_dst_value,
13384 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13385 .f = cmd_set_l2_encap_parsed,
13387 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13388 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13390 (void *)&cmd_set_l2_encap_set,
13391 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13392 (void *)&cmd_set_l2_encap_ip_version,
13393 (void *)&cmd_set_l2_encap_ip_version_value,
13394 (void *)&cmd_set_l2_encap_vlan,
13395 (void *)&cmd_set_l2_encap_vlan_value,
13396 (void *)&cmd_set_l2_encap_eth_src,
13397 (void *)&cmd_set_l2_encap_eth_src_value,
13398 (void *)&cmd_set_l2_encap_eth_dst,
13399 (void *)&cmd_set_l2_encap_eth_dst_value,
13404 /** Set L2 decapsulation details */
13405 struct cmd_set_l2_decap_result {
13406 cmdline_fixed_string_t set;
13407 cmdline_fixed_string_t l2_decap;
13408 cmdline_fixed_string_t pos_token;
13409 uint32_t vlan_present:1;
13412 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13413 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13414 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13415 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13417 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13418 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13419 "l2_decap-with-vlan");
13421 static void cmd_set_l2_decap_parsed(void *parsed_result,
13422 __rte_unused struct cmdline *cl,
13423 __rte_unused void *data)
13425 struct cmd_set_l2_decap_result *res = parsed_result;
13427 if (strcmp(res->l2_decap, "l2_decap") == 0)
13428 l2_decap_conf.select_vlan = 0;
13429 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13430 l2_decap_conf.select_vlan = 1;
13433 cmdline_parse_inst_t cmd_set_l2_decap = {
13434 .f = cmd_set_l2_decap_parsed,
13436 .help_str = "set l2_decap",
13438 (void *)&cmd_set_l2_decap_set,
13439 (void *)&cmd_set_l2_decap_l2_decap,
13444 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13445 .f = cmd_set_l2_decap_parsed,
13447 .help_str = "set l2_decap-with-vlan",
13449 (void *)&cmd_set_l2_decap_set,
13450 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13455 /** Set MPLSoGRE encapsulation details */
13456 struct cmd_set_mplsogre_encap_result {
13457 cmdline_fixed_string_t set;
13458 cmdline_fixed_string_t mplsogre;
13459 cmdline_fixed_string_t pos_token;
13460 cmdline_fixed_string_t ip_version;
13461 uint32_t vlan_present:1;
13463 cmdline_ipaddr_t ip_src;
13464 cmdline_ipaddr_t ip_dst;
13466 struct rte_ether_addr eth_src;
13467 struct rte_ether_addr eth_dst;
13470 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13471 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13473 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13474 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13476 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13477 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13478 mplsogre, "mplsogre_encap-with-vlan");
13479 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13480 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13481 pos_token, "ip-version");
13482 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13483 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13484 ip_version, "ipv4#ipv6");
13485 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13486 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13487 pos_token, "label");
13488 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13489 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13491 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13492 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13493 pos_token, "ip-src");
13494 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13495 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13496 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13497 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13498 pos_token, "ip-dst");
13499 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13500 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13501 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13502 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13503 pos_token, "vlan-tci");
13504 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13505 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13507 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13508 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13509 pos_token, "eth-src");
13510 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13511 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13513 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13514 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13515 pos_token, "eth-dst");
13516 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13517 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13520 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13521 __rte_unused struct cmdline *cl,
13522 __rte_unused void *data)
13524 struct cmd_set_mplsogre_encap_result *res = parsed_result;
13526 uint32_t mplsogre_label;
13529 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13532 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13533 mplsogre_encap_conf.select_vlan = 0;
13534 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13535 mplsogre_encap_conf.select_vlan = 1;
13536 if (strcmp(res->ip_version, "ipv4") == 0)
13537 mplsogre_encap_conf.select_ipv4 = 1;
13538 else if (strcmp(res->ip_version, "ipv6") == 0)
13539 mplsogre_encap_conf.select_ipv4 = 0;
13542 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13543 if (mplsogre_encap_conf.select_ipv4) {
13544 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13545 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13547 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13548 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13550 if (mplsogre_encap_conf.select_vlan)
13551 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13552 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13553 RTE_ETHER_ADDR_LEN);
13554 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13555 RTE_ETHER_ADDR_LEN);
13558 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13559 .f = cmd_set_mplsogre_encap_parsed,
13561 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13562 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13563 " eth-dst <eth-dst>",
13565 (void *)&cmd_set_mplsogre_encap_set,
13566 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13567 (void *)&cmd_set_mplsogre_encap_ip_version,
13568 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13569 (void *)&cmd_set_mplsogre_encap_label,
13570 (void *)&cmd_set_mplsogre_encap_label_value,
13571 (void *)&cmd_set_mplsogre_encap_ip_src,
13572 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13573 (void *)&cmd_set_mplsogre_encap_ip_dst,
13574 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13575 (void *)&cmd_set_mplsogre_encap_eth_src,
13576 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13577 (void *)&cmd_set_mplsogre_encap_eth_dst,
13578 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13583 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13584 .f = cmd_set_mplsogre_encap_parsed,
13586 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13587 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
13588 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13590 (void *)&cmd_set_mplsogre_encap_set,
13591 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13592 (void *)&cmd_set_mplsogre_encap_ip_version,
13593 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13594 (void *)&cmd_set_mplsogre_encap_label,
13595 (void *)&cmd_set_mplsogre_encap_label_value,
13596 (void *)&cmd_set_mplsogre_encap_ip_src,
13597 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13598 (void *)&cmd_set_mplsogre_encap_ip_dst,
13599 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13600 (void *)&cmd_set_mplsogre_encap_vlan,
13601 (void *)&cmd_set_mplsogre_encap_vlan_value,
13602 (void *)&cmd_set_mplsogre_encap_eth_src,
13603 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13604 (void *)&cmd_set_mplsogre_encap_eth_dst,
13605 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13610 /** Set MPLSoGRE decapsulation details */
13611 struct cmd_set_mplsogre_decap_result {
13612 cmdline_fixed_string_t set;
13613 cmdline_fixed_string_t mplsogre;
13614 cmdline_fixed_string_t pos_token;
13615 cmdline_fixed_string_t ip_version;
13616 uint32_t vlan_present:1;
13619 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13620 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13622 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13623 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13625 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13626 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13627 mplsogre, "mplsogre_decap-with-vlan");
13628 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13629 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13630 pos_token, "ip-version");
13631 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13632 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13633 ip_version, "ipv4#ipv6");
13635 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13636 __rte_unused struct cmdline *cl,
13637 __rte_unused void *data)
13639 struct cmd_set_mplsogre_decap_result *res = parsed_result;
13641 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13642 mplsogre_decap_conf.select_vlan = 0;
13643 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13644 mplsogre_decap_conf.select_vlan = 1;
13645 if (strcmp(res->ip_version, "ipv4") == 0)
13646 mplsogre_decap_conf.select_ipv4 = 1;
13647 else if (strcmp(res->ip_version, "ipv6") == 0)
13648 mplsogre_decap_conf.select_ipv4 = 0;
13651 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13652 .f = cmd_set_mplsogre_decap_parsed,
13654 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13656 (void *)&cmd_set_mplsogre_decap_set,
13657 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13658 (void *)&cmd_set_mplsogre_decap_ip_version,
13659 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13664 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13665 .f = cmd_set_mplsogre_decap_parsed,
13667 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13669 (void *)&cmd_set_mplsogre_decap_set,
13670 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13671 (void *)&cmd_set_mplsogre_decap_ip_version,
13672 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13677 /** Set MPLSoUDP encapsulation details */
13678 struct cmd_set_mplsoudp_encap_result {
13679 cmdline_fixed_string_t set;
13680 cmdline_fixed_string_t mplsoudp;
13681 cmdline_fixed_string_t pos_token;
13682 cmdline_fixed_string_t ip_version;
13683 uint32_t vlan_present:1;
13687 cmdline_ipaddr_t ip_src;
13688 cmdline_ipaddr_t ip_dst;
13690 struct rte_ether_addr eth_src;
13691 struct rte_ether_addr eth_dst;
13694 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13695 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13697 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13698 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13700 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13701 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13702 mplsoudp, "mplsoudp_encap-with-vlan");
13703 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13704 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13705 pos_token, "ip-version");
13706 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13707 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13708 ip_version, "ipv4#ipv6");
13709 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13710 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13711 pos_token, "label");
13712 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13713 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13715 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13716 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13717 pos_token, "udp-src");
13718 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13719 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13721 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13722 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13723 pos_token, "udp-dst");
13724 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13725 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13727 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13728 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13729 pos_token, "ip-src");
13730 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13731 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13732 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13733 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13734 pos_token, "ip-dst");
13735 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13736 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13737 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13738 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13739 pos_token, "vlan-tci");
13740 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13741 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13743 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13744 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13745 pos_token, "eth-src");
13746 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13747 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13749 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13750 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13751 pos_token, "eth-dst");
13752 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13753 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13756 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13757 __rte_unused struct cmdline *cl,
13758 __rte_unused void *data)
13760 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13762 uint32_t mplsoudp_label;
13765 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13768 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13769 mplsoudp_encap_conf.select_vlan = 0;
13770 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13771 mplsoudp_encap_conf.select_vlan = 1;
13772 if (strcmp(res->ip_version, "ipv4") == 0)
13773 mplsoudp_encap_conf.select_ipv4 = 1;
13774 else if (strcmp(res->ip_version, "ipv6") == 0)
13775 mplsoudp_encap_conf.select_ipv4 = 0;
13778 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13779 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13780 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13781 if (mplsoudp_encap_conf.select_ipv4) {
13782 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13783 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13785 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13786 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13788 if (mplsoudp_encap_conf.select_vlan)
13789 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13790 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13791 RTE_ETHER_ADDR_LEN);
13792 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13793 RTE_ETHER_ADDR_LEN);
13796 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13797 .f = cmd_set_mplsoudp_encap_parsed,
13799 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13800 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13801 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13803 (void *)&cmd_set_mplsoudp_encap_set,
13804 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13805 (void *)&cmd_set_mplsoudp_encap_ip_version,
13806 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13807 (void *)&cmd_set_mplsoudp_encap_label,
13808 (void *)&cmd_set_mplsoudp_encap_label_value,
13809 (void *)&cmd_set_mplsoudp_encap_udp_src,
13810 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13811 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13812 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13813 (void *)&cmd_set_mplsoudp_encap_ip_src,
13814 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13815 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13816 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13817 (void *)&cmd_set_mplsoudp_encap_eth_src,
13818 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13819 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13820 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13825 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13826 .f = cmd_set_mplsoudp_encap_parsed,
13828 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13829 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
13830 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13831 " eth-src <eth-src> eth-dst <eth-dst>",
13833 (void *)&cmd_set_mplsoudp_encap_set,
13834 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13835 (void *)&cmd_set_mplsoudp_encap_ip_version,
13836 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13837 (void *)&cmd_set_mplsoudp_encap_label,
13838 (void *)&cmd_set_mplsoudp_encap_label_value,
13839 (void *)&cmd_set_mplsoudp_encap_udp_src,
13840 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13841 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13842 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13843 (void *)&cmd_set_mplsoudp_encap_ip_src,
13844 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13845 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13846 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13847 (void *)&cmd_set_mplsoudp_encap_vlan,
13848 (void *)&cmd_set_mplsoudp_encap_vlan_value,
13849 (void *)&cmd_set_mplsoudp_encap_eth_src,
13850 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13851 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13852 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13857 /** Set MPLSoUDP decapsulation details */
13858 struct cmd_set_mplsoudp_decap_result {
13859 cmdline_fixed_string_t set;
13860 cmdline_fixed_string_t mplsoudp;
13861 cmdline_fixed_string_t pos_token;
13862 cmdline_fixed_string_t ip_version;
13863 uint32_t vlan_present:1;
13866 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
13867 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
13869 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
13870 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
13872 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
13873 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13874 mplsoudp, "mplsoudp_decap-with-vlan");
13875 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
13876 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13877 pos_token, "ip-version");
13878 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
13879 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13880 ip_version, "ipv4#ipv6");
13882 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
13883 __rte_unused struct cmdline *cl,
13884 __rte_unused void *data)
13886 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
13888 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
13889 mplsoudp_decap_conf.select_vlan = 0;
13890 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
13891 mplsoudp_decap_conf.select_vlan = 1;
13892 if (strcmp(res->ip_version, "ipv4") == 0)
13893 mplsoudp_decap_conf.select_ipv4 = 1;
13894 else if (strcmp(res->ip_version, "ipv6") == 0)
13895 mplsoudp_decap_conf.select_ipv4 = 0;
13898 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
13899 .f = cmd_set_mplsoudp_decap_parsed,
13901 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
13903 (void *)&cmd_set_mplsoudp_decap_set,
13904 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
13905 (void *)&cmd_set_mplsoudp_decap_ip_version,
13906 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13911 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
13912 .f = cmd_set_mplsoudp_decap_parsed,
13914 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
13916 (void *)&cmd_set_mplsoudp_decap_set,
13917 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
13918 (void *)&cmd_set_mplsoudp_decap_ip_version,
13919 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13924 /** Set connection tracking object common details */
13925 struct cmd_set_conntrack_common_result {
13926 cmdline_fixed_string_t set;
13927 cmdline_fixed_string_t conntrack;
13928 cmdline_fixed_string_t common;
13929 cmdline_fixed_string_t peer;
13930 cmdline_fixed_string_t is_orig;
13931 cmdline_fixed_string_t enable;
13932 cmdline_fixed_string_t live;
13933 cmdline_fixed_string_t sack;
13934 cmdline_fixed_string_t cack;
13935 cmdline_fixed_string_t last_dir;
13936 cmdline_fixed_string_t liberal;
13937 cmdline_fixed_string_t state;
13938 cmdline_fixed_string_t max_ack_win;
13939 cmdline_fixed_string_t retrans;
13940 cmdline_fixed_string_t last_win;
13941 cmdline_fixed_string_t last_seq;
13942 cmdline_fixed_string_t last_ack;
13943 cmdline_fixed_string_t last_end;
13944 cmdline_fixed_string_t last_index;
13947 uint16_t peer_port;
13948 uint32_t is_original;
13963 cmdline_parse_token_string_t cmd_set_conntrack_set =
13964 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13966 cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
13967 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13968 conntrack, "conntrack");
13969 cmdline_parse_token_string_t cmd_set_conntrack_common_com =
13970 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13972 cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
13973 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13975 cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
13976 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13977 peer_port, RTE_UINT16);
13978 cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
13979 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13980 is_orig, "is_orig");
13981 cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
13982 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13983 is_original, RTE_UINT32);
13984 cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
13985 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13987 cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
13988 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13990 cmdline_parse_token_string_t cmd_set_conntrack_common_live =
13991 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13993 cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
13994 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13995 is_live, RTE_UINT32);
13996 cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
13997 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13999 cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
14000 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14001 s_ack, RTE_UINT32);
14002 cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
14003 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14005 cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
14006 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14007 c_ack, RTE_UINT32);
14008 cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
14009 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14010 last_dir, "last_dir");
14011 cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
14012 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14014 cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
14015 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14016 liberal, "liberal");
14017 cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
14018 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14020 cmdline_parse_token_string_t cmd_set_conntrack_common_state =
14021 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14023 cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
14024 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14026 cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
14027 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14028 max_ack_win, "max_ack_win");
14029 cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
14030 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14031 factor, RTE_UINT8);
14032 cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
14033 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14035 cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
14036 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14037 re_num, RTE_UINT8);
14038 cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
14039 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14040 last_win, "last_win");
14041 cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
14042 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14044 cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
14045 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14046 last_seq, "last_seq");
14047 cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
14048 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14050 cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
14051 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14052 last_ack, "last_ack");
14053 cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
14054 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14056 cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
14057 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14058 last_end, "last_end");
14059 cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
14060 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14062 cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
14063 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14064 last_index, "last_index");
14065 cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
14066 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14069 static void cmd_set_conntrack_common_parsed(void *parsed_result,
14070 __rte_unused struct cmdline *cl,
14071 __rte_unused void *data)
14073 struct cmd_set_conntrack_common_result *res = parsed_result;
14075 /* No need to swap to big endian. */
14076 conntrack_context.peer_port = res->peer_port;
14077 conntrack_context.is_original_dir = res->is_original;
14078 conntrack_context.enable = res->en;
14079 conntrack_context.live_connection = res->is_live;
14080 conntrack_context.selective_ack = res->s_ack;
14081 conntrack_context.challenge_ack_passed = res->c_ack;
14082 conntrack_context.last_direction = res->ld;
14083 conntrack_context.liberal_mode = res->lb;
14084 conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
14085 conntrack_context.max_ack_window = res->factor;
14086 conntrack_context.retransmission_limit = res->re_num;
14087 conntrack_context.last_window = res->lw;
14088 conntrack_context.last_index =
14089 (enum rte_flow_conntrack_tcp_last_index)res->li;
14090 conntrack_context.last_seq = res->ls;
14091 conntrack_context.last_ack = res->la;
14092 conntrack_context.last_end = res->le;
14095 cmdline_parse_inst_t cmd_set_conntrack_common = {
14096 .f = cmd_set_conntrack_common_parsed,
14098 .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
14099 " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
14100 " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
14101 " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
14102 " last_index <flag>",
14104 (void *)&cmd_set_conntrack_set,
14105 (void *)&cmd_set_conntrack_conntrack,
14106 (void *)&cmd_set_conntrack_common_com,
14107 (void *)&cmd_set_conntrack_common_peer,
14108 (void *)&cmd_set_conntrack_common_peer_value,
14109 (void *)&cmd_set_conntrack_common_is_orig,
14110 (void *)&cmd_set_conntrack_common_is_orig_value,
14111 (void *)&cmd_set_conntrack_common_enable,
14112 (void *)&cmd_set_conntrack_common_enable_value,
14113 (void *)&cmd_set_conntrack_common_live,
14114 (void *)&cmd_set_conntrack_common_live_value,
14115 (void *)&cmd_set_conntrack_common_sack,
14116 (void *)&cmd_set_conntrack_common_sack_value,
14117 (void *)&cmd_set_conntrack_common_cack,
14118 (void *)&cmd_set_conntrack_common_cack_value,
14119 (void *)&cmd_set_conntrack_common_last_dir,
14120 (void *)&cmd_set_conntrack_common_last_dir_value,
14121 (void *)&cmd_set_conntrack_common_liberal,
14122 (void *)&cmd_set_conntrack_common_liberal_value,
14123 (void *)&cmd_set_conntrack_common_state,
14124 (void *)&cmd_set_conntrack_common_state_value,
14125 (void *)&cmd_set_conntrack_common_max_ackwin,
14126 (void *)&cmd_set_conntrack_common_max_ackwin_value,
14127 (void *)&cmd_set_conntrack_common_retrans,
14128 (void *)&cmd_set_conntrack_common_retrans_value,
14129 (void *)&cmd_set_conntrack_common_last_win,
14130 (void *)&cmd_set_conntrack_common_last_win_value,
14131 (void *)&cmd_set_conntrack_common_last_seq,
14132 (void *)&cmd_set_conntrack_common_last_seq_value,
14133 (void *)&cmd_set_conntrack_common_last_ack,
14134 (void *)&cmd_set_conntrack_common_last_ack_value,
14135 (void *)&cmd_set_conntrack_common_last_end,
14136 (void *)&cmd_set_conntrack_common_last_end_value,
14137 (void *)&cmd_set_conntrack_common_last_index,
14138 (void *)&cmd_set_conntrack_common_last_index_value,
14143 /** Set connection tracking object both directions' details */
14144 struct cmd_set_conntrack_dir_result {
14145 cmdline_fixed_string_t set;
14146 cmdline_fixed_string_t conntrack;
14147 cmdline_fixed_string_t dir;
14148 cmdline_fixed_string_t scale;
14149 cmdline_fixed_string_t fin;
14150 cmdline_fixed_string_t ack_seen;
14151 cmdline_fixed_string_t unack;
14152 cmdline_fixed_string_t sent_end;
14153 cmdline_fixed_string_t reply_end;
14154 cmdline_fixed_string_t max_win;
14155 cmdline_fixed_string_t max_ack;
14166 cmdline_parse_token_string_t cmd_set_conntrack_dir_set =
14167 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14169 cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack =
14170 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14171 conntrack, "conntrack");
14172 cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
14173 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14175 cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
14176 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14178 cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
14179 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14180 factor, RTE_UINT32);
14181 cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
14182 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14184 cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
14185 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14187 cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
14188 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14189 ack_seen, "acked");
14190 cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
14191 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14193 cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
14194 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14195 unack, "unack_data");
14196 cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
14197 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14199 cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
14200 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14201 sent_end, "sent_end");
14202 cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
14203 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14205 cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
14206 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14207 reply_end, "reply_end");
14208 cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
14209 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14211 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
14212 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14213 max_win, "max_win");
14214 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
14215 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14217 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
14218 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14219 max_ack, "max_ack");
14220 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
14221 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14224 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
14225 __rte_unused struct cmdline *cl,
14226 __rte_unused void *data)
14228 struct cmd_set_conntrack_dir_result *res = parsed_result;
14229 struct rte_flow_tcp_dir_param *dir = NULL;
14231 if (strcmp(res->dir, "orig") == 0)
14232 dir = &conntrack_context.original_dir;
14233 else if (strcmp(res->dir, "rply") == 0)
14234 dir = &conntrack_context.reply_dir;
14237 dir->scale = res->factor;
14238 dir->close_initiated = res->f;
14239 dir->last_ack_seen = res->as;
14240 dir->data_unacked = res->un;
14241 dir->sent_end = res->se;
14242 dir->reply_end = res->re;
14243 dir->max_ack = res->ma;
14244 dir->max_win = res->mw;
14247 cmdline_parse_inst_t cmd_set_conntrack_dir = {
14248 .f = cmd_set_conntrack_dir_parsed,
14250 .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
14251 " acked <seen> unack_data <unack> sent_end <sent>"
14252 " reply_end <reply> max_win <win> max_ack <ack>",
14254 (void *)&cmd_set_conntrack_set,
14255 (void *)&cmd_set_conntrack_conntrack,
14256 (void *)&cmd_set_conntrack_dir_dir,
14257 (void *)&cmd_set_conntrack_dir_scale,
14258 (void *)&cmd_set_conntrack_dir_scale_value,
14259 (void *)&cmd_set_conntrack_dir_fin,
14260 (void *)&cmd_set_conntrack_dir_fin_value,
14261 (void *)&cmd_set_conntrack_dir_ack,
14262 (void *)&cmd_set_conntrack_dir_ack_value,
14263 (void *)&cmd_set_conntrack_dir_unack_data,
14264 (void *)&cmd_set_conntrack_dir_unack_data_value,
14265 (void *)&cmd_set_conntrack_dir_sent_end,
14266 (void *)&cmd_set_conntrack_dir_sent_end_value,
14267 (void *)&cmd_set_conntrack_dir_reply_end,
14268 (void *)&cmd_set_conntrack_dir_reply_end_value,
14269 (void *)&cmd_set_conntrack_dir_max_win,
14270 (void *)&cmd_set_conntrack_dir_max_win_value,
14271 (void *)&cmd_set_conntrack_dir_max_ack,
14272 (void *)&cmd_set_conntrack_dir_max_ack_value,
14277 /* Strict link priority scheduling mode setting */
14279 cmd_strict_link_prio_parsed(
14280 void *parsed_result,
14281 __rte_unused struct cmdline *cl,
14282 __rte_unused void *data)
14284 struct cmd_vf_tc_bw_result *res = parsed_result;
14285 int ret = -ENOTSUP;
14287 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14290 #ifdef RTE_NET_I40E
14291 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14298 fprintf(stderr, "invalid tc_bitmap 0x%x\n", res->tc_map);
14301 fprintf(stderr, "invalid port_id %d\n", res->port_id);
14304 fprintf(stderr, "function not implemented\n");
14307 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
14311 cmdline_parse_inst_t cmd_strict_link_prio = {
14312 .f = cmd_strict_link_prio_parsed,
14314 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14316 (void *)&cmd_vf_tc_bw_set,
14317 (void *)&cmd_vf_tc_bw_tx,
14318 (void *)&cmd_vf_tc_bw_strict_link_prio,
14319 (void *)&cmd_vf_tc_bw_port_id,
14320 (void *)&cmd_vf_tc_bw_tc_map,
14325 /* Load dynamic device personalization*/
14326 struct cmd_ddp_add_result {
14327 cmdline_fixed_string_t ddp;
14328 cmdline_fixed_string_t add;
14333 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14334 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14335 cmdline_parse_token_string_t cmd_ddp_add_add =
14336 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14337 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14338 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
14340 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14341 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14344 cmd_ddp_add_parsed(
14345 void *parsed_result,
14346 __rte_unused struct cmdline *cl,
14347 __rte_unused void *data)
14349 struct cmd_ddp_add_result *res = parsed_result;
14355 int ret = -ENOTSUP;
14357 if (!all_ports_stopped()) {
14358 fprintf(stderr, "Please stop all ports first\n");
14362 filepath = strdup(res->filepath);
14363 if (filepath == NULL) {
14364 fprintf(stderr, "Failed to allocate memory\n");
14367 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14369 buff = open_file(file_fld[0], &size);
14371 free((void *)filepath);
14375 #ifdef RTE_NET_I40E
14376 if (ret == -ENOTSUP)
14377 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14379 RTE_PMD_I40E_PKG_OP_WR_ADD);
14382 if (ret == -EEXIST)
14383 fprintf(stderr, "Profile has already existed.\n");
14385 fprintf(stderr, "Failed to load profile.\n");
14386 else if (file_num == 2)
14387 save_file(file_fld[1], buff, size);
14390 free((void *)filepath);
14393 cmdline_parse_inst_t cmd_ddp_add = {
14394 .f = cmd_ddp_add_parsed,
14396 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14398 (void *)&cmd_ddp_add_ddp,
14399 (void *)&cmd_ddp_add_add,
14400 (void *)&cmd_ddp_add_port_id,
14401 (void *)&cmd_ddp_add_filepath,
14406 /* Delete dynamic device personalization*/
14407 struct cmd_ddp_del_result {
14408 cmdline_fixed_string_t ddp;
14409 cmdline_fixed_string_t del;
14414 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14415 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14416 cmdline_parse_token_string_t cmd_ddp_del_del =
14417 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14418 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14419 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
14420 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14421 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14424 cmd_ddp_del_parsed(
14425 void *parsed_result,
14426 __rte_unused struct cmdline *cl,
14427 __rte_unused void *data)
14429 struct cmd_ddp_del_result *res = parsed_result;
14432 int ret = -ENOTSUP;
14434 if (!all_ports_stopped()) {
14435 fprintf(stderr, "Please stop all ports first\n");
14439 buff = open_file(res->filepath, &size);
14443 #ifdef RTE_NET_I40E
14444 if (ret == -ENOTSUP)
14445 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14447 RTE_PMD_I40E_PKG_OP_WR_DEL);
14450 if (ret == -EACCES)
14451 fprintf(stderr, "Profile does not exist.\n");
14453 fprintf(stderr, "Failed to delete profile.\n");
14458 cmdline_parse_inst_t cmd_ddp_del = {
14459 .f = cmd_ddp_del_parsed,
14461 .help_str = "ddp del <port_id> <backup_profile_path>",
14463 (void *)&cmd_ddp_del_ddp,
14464 (void *)&cmd_ddp_del_del,
14465 (void *)&cmd_ddp_del_port_id,
14466 (void *)&cmd_ddp_del_filepath,
14471 /* Get dynamic device personalization profile info */
14472 struct cmd_ddp_info_result {
14473 cmdline_fixed_string_t ddp;
14474 cmdline_fixed_string_t get;
14475 cmdline_fixed_string_t info;
14479 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14480 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14481 cmdline_parse_token_string_t cmd_ddp_info_get =
14482 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14483 cmdline_parse_token_string_t cmd_ddp_info_info =
14484 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14485 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14486 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14489 cmd_ddp_info_parsed(
14490 void *parsed_result,
14491 __rte_unused struct cmdline *cl,
14492 __rte_unused void *data)
14494 struct cmd_ddp_info_result *res = parsed_result;
14497 int ret = -ENOTSUP;
14498 #ifdef RTE_NET_I40E
14501 uint32_t buff_size = 0;
14502 struct rte_pmd_i40e_profile_info info;
14503 uint32_t dev_num = 0;
14504 struct rte_pmd_i40e_ddp_device_id *devs;
14505 uint32_t proto_num = 0;
14506 struct rte_pmd_i40e_proto_info *proto = NULL;
14507 uint32_t pctype_num = 0;
14508 struct rte_pmd_i40e_ptype_info *pctype;
14509 uint32_t ptype_num = 0;
14510 struct rte_pmd_i40e_ptype_info *ptype;
14515 pkg = open_file(res->filepath, &pkg_size);
14519 #ifdef RTE_NET_I40E
14520 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14521 (uint8_t *)&info, sizeof(info),
14522 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14524 printf("Global Track id: 0x%x\n", info.track_id);
14525 printf("Global Version: %d.%d.%d.%d\n",
14526 info.version.major,
14527 info.version.minor,
14528 info.version.update,
14529 info.version.draft);
14530 printf("Global Package name: %s\n\n", info.name);
14533 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14534 (uint8_t *)&info, sizeof(info),
14535 RTE_PMD_I40E_PKG_INFO_HEADER);
14537 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14538 printf("i40e Profile Version: %d.%d.%d.%d\n",
14539 info.version.major,
14540 info.version.minor,
14541 info.version.update,
14542 info.version.draft);
14543 printf("i40e Profile name: %s\n\n", info.name);
14546 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14547 (uint8_t *)&buff_size, sizeof(buff_size),
14548 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14549 if (!ret && buff_size) {
14550 buff = (uint8_t *)malloc(buff_size);
14552 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14554 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14556 printf("Package Notes:\n%s\n\n", buff);
14561 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14562 (uint8_t *)&dev_num, sizeof(dev_num),
14563 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14564 if (!ret && dev_num) {
14565 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14566 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14568 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14569 (uint8_t *)devs, buff_size,
14570 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14572 printf("List of supported devices:\n");
14573 for (i = 0; i < dev_num; i++) {
14574 printf(" %04X:%04X %04X:%04X\n",
14575 devs[i].vendor_dev_id >> 16,
14576 devs[i].vendor_dev_id & 0xFFFF,
14577 devs[i].sub_vendor_dev_id >> 16,
14578 devs[i].sub_vendor_dev_id & 0xFFFF);
14586 /* get information about protocols and packet types */
14587 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14588 (uint8_t *)&proto_num, sizeof(proto_num),
14589 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14590 if (ret || !proto_num)
14591 goto no_print_return;
14593 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14594 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14596 goto no_print_return;
14598 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14600 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14602 printf("List of used protocols:\n");
14603 for (i = 0; i < proto_num; i++)
14604 printf(" %2u: %s\n", proto[i].proto_id,
14608 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14609 (uint8_t *)&pctype_num, sizeof(pctype_num),
14610 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14611 if (ret || !pctype_num)
14612 goto no_print_pctypes;
14614 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14615 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14617 goto no_print_pctypes;
14619 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14621 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14624 goto no_print_pctypes;
14627 printf("List of defined packet classification types:\n");
14628 for (i = 0; i < pctype_num; i++) {
14629 printf(" %2u:", pctype[i].ptype_id);
14630 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14631 proto_id = pctype[i].protocols[j];
14632 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14633 for (n = 0; n < proto_num; n++) {
14634 if (proto[n].proto_id == proto_id) {
14635 printf(" %s", proto[n].name);
14648 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14650 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14651 if (ret || !ptype_num)
14652 goto no_print_return;
14654 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14655 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14657 goto no_print_return;
14659 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14661 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14664 goto no_print_return;
14666 printf("List of defined packet types:\n");
14667 for (i = 0; i < ptype_num; i++) {
14668 printf(" %2u:", ptype[i].ptype_id);
14669 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14670 proto_id = ptype[i].protocols[j];
14671 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14672 for (n = 0; n < proto_num; n++) {
14673 if (proto[n].proto_id == proto_id) {
14674 printf(" %s", proto[n].name);
14690 if (ret == -ENOTSUP)
14691 fprintf(stderr, "Function not supported in PMD driver\n");
14695 cmdline_parse_inst_t cmd_ddp_get_info = {
14696 .f = cmd_ddp_info_parsed,
14698 .help_str = "ddp get info <profile_path>",
14700 (void *)&cmd_ddp_info_ddp,
14701 (void *)&cmd_ddp_info_get,
14702 (void *)&cmd_ddp_info_info,
14703 (void *)&cmd_ddp_info_filepath,
14708 /* Get dynamic device personalization profile info list*/
14709 #define PROFILE_INFO_SIZE 48
14710 #define MAX_PROFILE_NUM 16
14712 struct cmd_ddp_get_list_result {
14713 cmdline_fixed_string_t ddp;
14714 cmdline_fixed_string_t get;
14715 cmdline_fixed_string_t list;
14719 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14720 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14721 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14722 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14723 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14724 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14725 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14726 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14730 cmd_ddp_get_list_parsed(
14731 __rte_unused void *parsed_result,
14732 __rte_unused struct cmdline *cl,
14733 __rte_unused void *data)
14735 #ifdef RTE_NET_I40E
14736 struct cmd_ddp_get_list_result *res = parsed_result;
14737 struct rte_pmd_i40e_profile_list *p_list;
14738 struct rte_pmd_i40e_profile_info *p_info;
14743 int ret = -ENOTSUP;
14745 #ifdef RTE_NET_I40E
14746 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14747 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14749 fprintf(stderr, "%s: Failed to malloc buffer\n", __func__);
14753 if (ret == -ENOTSUP)
14754 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14755 (uint8_t *)p_list, size);
14758 p_num = p_list->p_count;
14759 printf("Profile number is: %d\n\n", p_num);
14761 for (i = 0; i < p_num; i++) {
14762 p_info = &p_list->p_info[i];
14763 printf("Profile %d:\n", i);
14764 printf("Track id: 0x%x\n", p_info->track_id);
14765 printf("Version: %d.%d.%d.%d\n",
14766 p_info->version.major,
14767 p_info->version.minor,
14768 p_info->version.update,
14769 p_info->version.draft);
14770 printf("Profile name: %s\n\n", p_info->name);
14778 fprintf(stderr, "Failed to get ddp list\n");
14781 cmdline_parse_inst_t cmd_ddp_get_list = {
14782 .f = cmd_ddp_get_list_parsed,
14784 .help_str = "ddp get list <port_id>",
14786 (void *)&cmd_ddp_get_list_ddp,
14787 (void *)&cmd_ddp_get_list_get,
14788 (void *)&cmd_ddp_get_list_list,
14789 (void *)&cmd_ddp_get_list_port_id,
14794 /* Configure input set */
14795 struct cmd_cfg_input_set_result {
14796 cmdline_fixed_string_t port;
14797 cmdline_fixed_string_t cfg;
14799 cmdline_fixed_string_t pctype;
14801 cmdline_fixed_string_t inset_type;
14802 cmdline_fixed_string_t opt;
14803 cmdline_fixed_string_t field;
14808 cmd_cfg_input_set_parsed(
14809 __rte_unused void *parsed_result,
14810 __rte_unused struct cmdline *cl,
14811 __rte_unused void *data)
14813 #ifdef RTE_NET_I40E
14814 struct cmd_cfg_input_set_result *res = parsed_result;
14815 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14816 struct rte_pmd_i40e_inset inset;
14818 int ret = -ENOTSUP;
14820 if (!all_ports_stopped()) {
14821 fprintf(stderr, "Please stop all ports first\n");
14825 #ifdef RTE_NET_I40E
14826 if (!strcmp(res->inset_type, "hash_inset"))
14827 inset_type = INSET_HASH;
14828 else if (!strcmp(res->inset_type, "fdir_inset"))
14829 inset_type = INSET_FDIR;
14830 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14831 inset_type = INSET_FDIR_FLX;
14832 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14833 &inset, inset_type);
14835 fprintf(stderr, "Failed to get input set.\n");
14839 if (!strcmp(res->opt, "get")) {
14840 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14843 printf("Field index %d is enabled.\n", res->field_idx);
14845 printf("Field index %d is disabled.\n", res->field_idx);
14847 } else if (!strcmp(res->opt, "set"))
14848 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14850 else if (!strcmp(res->opt, "clear"))
14851 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14854 fprintf(stderr, "Failed to configure input set field.\n");
14858 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14859 &inset, inset_type);
14861 fprintf(stderr, "Failed to set input set.\n");
14866 if (ret == -ENOTSUP)
14867 fprintf(stderr, "Function not supported\n");
14870 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14871 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14873 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14874 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14876 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14877 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14878 port_id, RTE_UINT16);
14879 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14880 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14882 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14883 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14884 pctype_id, RTE_UINT8);
14885 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14886 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14888 "hash_inset#fdir_inset#fdir_flx_inset");
14889 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14890 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14891 opt, "get#set#clear");
14892 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14893 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14895 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14896 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14897 field_idx, RTE_UINT8);
14899 cmdline_parse_inst_t cmd_cfg_input_set = {
14900 .f = cmd_cfg_input_set_parsed,
14902 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14903 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
14905 (void *)&cmd_cfg_input_set_port,
14906 (void *)&cmd_cfg_input_set_cfg,
14907 (void *)&cmd_cfg_input_set_port_id,
14908 (void *)&cmd_cfg_input_set_pctype,
14909 (void *)&cmd_cfg_input_set_pctype_id,
14910 (void *)&cmd_cfg_input_set_inset_type,
14911 (void *)&cmd_cfg_input_set_opt,
14912 (void *)&cmd_cfg_input_set_field,
14913 (void *)&cmd_cfg_input_set_field_idx,
14918 /* Clear input set */
14919 struct cmd_clear_input_set_result {
14920 cmdline_fixed_string_t port;
14921 cmdline_fixed_string_t cfg;
14923 cmdline_fixed_string_t pctype;
14925 cmdline_fixed_string_t inset_type;
14926 cmdline_fixed_string_t clear;
14927 cmdline_fixed_string_t all;
14931 cmd_clear_input_set_parsed(
14932 __rte_unused void *parsed_result,
14933 __rte_unused struct cmdline *cl,
14934 __rte_unused void *data)
14936 #ifdef RTE_NET_I40E
14937 struct cmd_clear_input_set_result *res = parsed_result;
14938 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14939 struct rte_pmd_i40e_inset inset;
14941 int ret = -ENOTSUP;
14943 if (!all_ports_stopped()) {
14944 fprintf(stderr, "Please stop all ports first\n");
14948 #ifdef RTE_NET_I40E
14949 if (!strcmp(res->inset_type, "hash_inset"))
14950 inset_type = INSET_HASH;
14951 else if (!strcmp(res->inset_type, "fdir_inset"))
14952 inset_type = INSET_FDIR;
14953 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14954 inset_type = INSET_FDIR_FLX;
14956 memset(&inset, 0, sizeof(inset));
14958 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14959 &inset, inset_type);
14961 fprintf(stderr, "Failed to clear input set.\n");
14967 if (ret == -ENOTSUP)
14968 fprintf(stderr, "Function not supported\n");
14971 cmdline_parse_token_string_t cmd_clear_input_set_port =
14972 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14974 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
14975 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14977 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
14978 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14979 port_id, RTE_UINT16);
14980 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
14981 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14983 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
14984 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14985 pctype_id, RTE_UINT8);
14986 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
14987 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14989 "hash_inset#fdir_inset#fdir_flx_inset");
14990 cmdline_parse_token_string_t cmd_clear_input_set_clear =
14991 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14993 cmdline_parse_token_string_t cmd_clear_input_set_all =
14994 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14997 cmdline_parse_inst_t cmd_clear_input_set = {
14998 .f = cmd_clear_input_set_parsed,
15000 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15001 "fdir_inset|fdir_flx_inset clear all",
15003 (void *)&cmd_clear_input_set_port,
15004 (void *)&cmd_clear_input_set_cfg,
15005 (void *)&cmd_clear_input_set_port_id,
15006 (void *)&cmd_clear_input_set_pctype,
15007 (void *)&cmd_clear_input_set_pctype_id,
15008 (void *)&cmd_clear_input_set_inset_type,
15009 (void *)&cmd_clear_input_set_clear,
15010 (void *)&cmd_clear_input_set_all,
15015 /* show vf stats */
15017 /* Common result structure for show vf stats */
15018 struct cmd_show_vf_stats_result {
15019 cmdline_fixed_string_t show;
15020 cmdline_fixed_string_t vf;
15021 cmdline_fixed_string_t stats;
15026 /* Common CLI fields show vf stats*/
15027 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15028 TOKEN_STRING_INITIALIZER
15029 (struct cmd_show_vf_stats_result,
15031 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15032 TOKEN_STRING_INITIALIZER
15033 (struct cmd_show_vf_stats_result,
15035 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15036 TOKEN_STRING_INITIALIZER
15037 (struct cmd_show_vf_stats_result,
15039 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15040 TOKEN_NUM_INITIALIZER
15041 (struct cmd_show_vf_stats_result,
15042 port_id, RTE_UINT16);
15043 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15044 TOKEN_NUM_INITIALIZER
15045 (struct cmd_show_vf_stats_result,
15046 vf_id, RTE_UINT16);
15049 cmd_show_vf_stats_parsed(
15050 void *parsed_result,
15051 __rte_unused struct cmdline *cl,
15052 __rte_unused void *data)
15054 struct cmd_show_vf_stats_result *res = parsed_result;
15055 struct rte_eth_stats stats;
15056 int ret = -ENOTSUP;
15057 static const char *nic_stats_border = "########################";
15059 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15062 memset(&stats, 0, sizeof(stats));
15064 #ifdef RTE_NET_I40E
15065 if (ret == -ENOTSUP)
15066 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15070 #ifdef RTE_NET_BNXT
15071 if (ret == -ENOTSUP)
15072 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15081 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15084 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15087 fprintf(stderr, "function not implemented\n");
15090 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15093 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15094 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15096 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15098 stats.ipackets, stats.imissed, stats.ibytes);
15099 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15100 printf(" RX-nombuf: %-10"PRIu64"\n",
15102 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15104 stats.opackets, stats.oerrors, stats.obytes);
15106 printf(" %s############################%s\n",
15107 nic_stats_border, nic_stats_border);
15110 cmdline_parse_inst_t cmd_show_vf_stats = {
15111 .f = cmd_show_vf_stats_parsed,
15113 .help_str = "show vf stats <port_id> <vf_id>",
15115 (void *)&cmd_show_vf_stats_show,
15116 (void *)&cmd_show_vf_stats_vf,
15117 (void *)&cmd_show_vf_stats_stats,
15118 (void *)&cmd_show_vf_stats_port_id,
15119 (void *)&cmd_show_vf_stats_vf_id,
15124 /* clear vf stats */
15126 /* Common result structure for clear vf stats */
15127 struct cmd_clear_vf_stats_result {
15128 cmdline_fixed_string_t clear;
15129 cmdline_fixed_string_t vf;
15130 cmdline_fixed_string_t stats;
15135 /* Common CLI fields clear vf stats*/
15136 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15137 TOKEN_STRING_INITIALIZER
15138 (struct cmd_clear_vf_stats_result,
15140 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15141 TOKEN_STRING_INITIALIZER
15142 (struct cmd_clear_vf_stats_result,
15144 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15145 TOKEN_STRING_INITIALIZER
15146 (struct cmd_clear_vf_stats_result,
15148 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15149 TOKEN_NUM_INITIALIZER
15150 (struct cmd_clear_vf_stats_result,
15151 port_id, RTE_UINT16);
15152 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15153 TOKEN_NUM_INITIALIZER
15154 (struct cmd_clear_vf_stats_result,
15155 vf_id, RTE_UINT16);
15158 cmd_clear_vf_stats_parsed(
15159 void *parsed_result,
15160 __rte_unused struct cmdline *cl,
15161 __rte_unused void *data)
15163 struct cmd_clear_vf_stats_result *res = parsed_result;
15164 int ret = -ENOTSUP;
15166 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15169 #ifdef RTE_NET_I40E
15170 if (ret == -ENOTSUP)
15171 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15174 #ifdef RTE_NET_BNXT
15175 if (ret == -ENOTSUP)
15176 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15184 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15187 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15190 fprintf(stderr, "function not implemented\n");
15193 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15197 cmdline_parse_inst_t cmd_clear_vf_stats = {
15198 .f = cmd_clear_vf_stats_parsed,
15200 .help_str = "clear vf stats <port_id> <vf_id>",
15202 (void *)&cmd_clear_vf_stats_clear,
15203 (void *)&cmd_clear_vf_stats_vf,
15204 (void *)&cmd_clear_vf_stats_stats,
15205 (void *)&cmd_clear_vf_stats_port_id,
15206 (void *)&cmd_clear_vf_stats_vf_id,
15211 /* port config pctype mapping reset */
15213 /* Common result structure for port config pctype mapping reset */
15214 struct cmd_pctype_mapping_reset_result {
15215 cmdline_fixed_string_t port;
15216 cmdline_fixed_string_t config;
15218 cmdline_fixed_string_t pctype;
15219 cmdline_fixed_string_t mapping;
15220 cmdline_fixed_string_t reset;
15223 /* Common CLI fields for port config pctype mapping reset*/
15224 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15225 TOKEN_STRING_INITIALIZER
15226 (struct cmd_pctype_mapping_reset_result,
15228 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15229 TOKEN_STRING_INITIALIZER
15230 (struct cmd_pctype_mapping_reset_result,
15232 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15233 TOKEN_NUM_INITIALIZER
15234 (struct cmd_pctype_mapping_reset_result,
15235 port_id, RTE_UINT16);
15236 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15237 TOKEN_STRING_INITIALIZER
15238 (struct cmd_pctype_mapping_reset_result,
15240 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15241 TOKEN_STRING_INITIALIZER
15242 (struct cmd_pctype_mapping_reset_result,
15243 mapping, "mapping");
15244 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15245 TOKEN_STRING_INITIALIZER
15246 (struct cmd_pctype_mapping_reset_result,
15250 cmd_pctype_mapping_reset_parsed(
15251 void *parsed_result,
15252 __rte_unused struct cmdline *cl,
15253 __rte_unused void *data)
15255 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15256 int ret = -ENOTSUP;
15258 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15261 #ifdef RTE_NET_I40E
15262 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15269 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15272 fprintf(stderr, "function not implemented\n");
15275 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15279 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15280 .f = cmd_pctype_mapping_reset_parsed,
15282 .help_str = "port config <port_id> pctype mapping reset",
15284 (void *)&cmd_pctype_mapping_reset_port,
15285 (void *)&cmd_pctype_mapping_reset_config,
15286 (void *)&cmd_pctype_mapping_reset_port_id,
15287 (void *)&cmd_pctype_mapping_reset_pctype,
15288 (void *)&cmd_pctype_mapping_reset_mapping,
15289 (void *)&cmd_pctype_mapping_reset_reset,
15294 /* show port pctype mapping */
15296 /* Common result structure for show port pctype mapping */
15297 struct cmd_pctype_mapping_get_result {
15298 cmdline_fixed_string_t show;
15299 cmdline_fixed_string_t port;
15301 cmdline_fixed_string_t pctype;
15302 cmdline_fixed_string_t mapping;
15305 /* Common CLI fields for pctype mapping get */
15306 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15307 TOKEN_STRING_INITIALIZER
15308 (struct cmd_pctype_mapping_get_result,
15310 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15311 TOKEN_STRING_INITIALIZER
15312 (struct cmd_pctype_mapping_get_result,
15314 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15315 TOKEN_NUM_INITIALIZER
15316 (struct cmd_pctype_mapping_get_result,
15317 port_id, RTE_UINT16);
15318 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15319 TOKEN_STRING_INITIALIZER
15320 (struct cmd_pctype_mapping_get_result,
15322 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15323 TOKEN_STRING_INITIALIZER
15324 (struct cmd_pctype_mapping_get_result,
15325 mapping, "mapping");
15328 cmd_pctype_mapping_get_parsed(
15329 void *parsed_result,
15330 __rte_unused struct cmdline *cl,
15331 __rte_unused void *data)
15333 struct cmd_pctype_mapping_get_result *res = parsed_result;
15334 int ret = -ENOTSUP;
15335 #ifdef RTE_NET_I40E
15336 struct rte_pmd_i40e_flow_type_mapping
15337 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15338 int i, j, first_pctype;
15341 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15344 #ifdef RTE_NET_I40E
15345 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15352 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15355 fprintf(stderr, "function not implemented\n");
15358 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15362 #ifdef RTE_NET_I40E
15363 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15364 if (mapping[i].pctype != 0ULL) {
15367 printf("pctype: ");
15368 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15369 if (mapping[i].pctype & (1ULL << j)) {
15370 printf(first_pctype ?
15371 "%02d" : ",%02d", j);
15375 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15381 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15382 .f = cmd_pctype_mapping_get_parsed,
15384 .help_str = "show port <port_id> pctype mapping",
15386 (void *)&cmd_pctype_mapping_get_show,
15387 (void *)&cmd_pctype_mapping_get_port,
15388 (void *)&cmd_pctype_mapping_get_port_id,
15389 (void *)&cmd_pctype_mapping_get_pctype,
15390 (void *)&cmd_pctype_mapping_get_mapping,
15395 /* port config pctype mapping update */
15397 /* Common result structure for port config pctype mapping update */
15398 struct cmd_pctype_mapping_update_result {
15399 cmdline_fixed_string_t port;
15400 cmdline_fixed_string_t config;
15402 cmdline_fixed_string_t pctype;
15403 cmdline_fixed_string_t mapping;
15404 cmdline_fixed_string_t update;
15405 cmdline_fixed_string_t pctype_list;
15406 uint16_t flow_type;
15409 /* Common CLI fields for pctype mapping update*/
15410 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15411 TOKEN_STRING_INITIALIZER
15412 (struct cmd_pctype_mapping_update_result,
15414 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15415 TOKEN_STRING_INITIALIZER
15416 (struct cmd_pctype_mapping_update_result,
15418 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15419 TOKEN_NUM_INITIALIZER
15420 (struct cmd_pctype_mapping_update_result,
15421 port_id, RTE_UINT16);
15422 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15423 TOKEN_STRING_INITIALIZER
15424 (struct cmd_pctype_mapping_update_result,
15426 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15427 TOKEN_STRING_INITIALIZER
15428 (struct cmd_pctype_mapping_update_result,
15429 mapping, "mapping");
15430 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15431 TOKEN_STRING_INITIALIZER
15432 (struct cmd_pctype_mapping_update_result,
15434 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15435 TOKEN_STRING_INITIALIZER
15436 (struct cmd_pctype_mapping_update_result,
15437 pctype_list, NULL);
15438 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15439 TOKEN_NUM_INITIALIZER
15440 (struct cmd_pctype_mapping_update_result,
15441 flow_type, RTE_UINT16);
15444 cmd_pctype_mapping_update_parsed(
15445 void *parsed_result,
15446 __rte_unused struct cmdline *cl,
15447 __rte_unused void *data)
15449 struct cmd_pctype_mapping_update_result *res = parsed_result;
15450 int ret = -ENOTSUP;
15451 #ifdef RTE_NET_I40E
15452 struct rte_pmd_i40e_flow_type_mapping mapping;
15454 unsigned int nb_item;
15455 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15458 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15461 #ifdef RTE_NET_I40E
15462 nb_item = parse_item_list(res->pctype_list, "pctypes",
15463 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15464 mapping.flow_type = res->flow_type;
15465 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15466 mapping.pctype |= (1ULL << pctype_list[i]);
15467 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15477 fprintf(stderr, "invalid pctype or flow type\n");
15480 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15483 fprintf(stderr, "function not implemented\n");
15486 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15490 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15491 .f = cmd_pctype_mapping_update_parsed,
15493 .help_str = "port config <port_id> pctype mapping update"
15494 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15496 (void *)&cmd_pctype_mapping_update_port,
15497 (void *)&cmd_pctype_mapping_update_config,
15498 (void *)&cmd_pctype_mapping_update_port_id,
15499 (void *)&cmd_pctype_mapping_update_pctype,
15500 (void *)&cmd_pctype_mapping_update_mapping,
15501 (void *)&cmd_pctype_mapping_update_update,
15502 (void *)&cmd_pctype_mapping_update_pc_type,
15503 (void *)&cmd_pctype_mapping_update_flow_type,
15508 /* ptype mapping get */
15510 /* Common result structure for ptype mapping get */
15511 struct cmd_ptype_mapping_get_result {
15512 cmdline_fixed_string_t ptype;
15513 cmdline_fixed_string_t mapping;
15514 cmdline_fixed_string_t get;
15516 uint8_t valid_only;
15519 /* Common CLI fields for ptype mapping get */
15520 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15521 TOKEN_STRING_INITIALIZER
15522 (struct cmd_ptype_mapping_get_result,
15524 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15525 TOKEN_STRING_INITIALIZER
15526 (struct cmd_ptype_mapping_get_result,
15527 mapping, "mapping");
15528 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15529 TOKEN_STRING_INITIALIZER
15530 (struct cmd_ptype_mapping_get_result,
15532 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15533 TOKEN_NUM_INITIALIZER
15534 (struct cmd_ptype_mapping_get_result,
15535 port_id, RTE_UINT16);
15536 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15537 TOKEN_NUM_INITIALIZER
15538 (struct cmd_ptype_mapping_get_result,
15539 valid_only, RTE_UINT8);
15542 cmd_ptype_mapping_get_parsed(
15543 void *parsed_result,
15544 __rte_unused struct cmdline *cl,
15545 __rte_unused void *data)
15547 struct cmd_ptype_mapping_get_result *res = parsed_result;
15548 int ret = -ENOTSUP;
15549 #ifdef RTE_NET_I40E
15550 int max_ptype_num = 256;
15551 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15556 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15559 #ifdef RTE_NET_I40E
15560 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15571 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15574 fprintf(stderr, "function not implemented\n");
15577 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15580 #ifdef RTE_NET_I40E
15582 for (i = 0; i < count; i++)
15583 printf("%3d\t0x%08x\n",
15584 mapping[i].hw_ptype, mapping[i].sw_ptype);
15589 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15590 .f = cmd_ptype_mapping_get_parsed,
15592 .help_str = "ptype mapping get <port_id> <valid_only>",
15594 (void *)&cmd_ptype_mapping_get_ptype,
15595 (void *)&cmd_ptype_mapping_get_mapping,
15596 (void *)&cmd_ptype_mapping_get_get,
15597 (void *)&cmd_ptype_mapping_get_port_id,
15598 (void *)&cmd_ptype_mapping_get_valid_only,
15603 /* ptype mapping replace */
15605 /* Common result structure for ptype mapping replace */
15606 struct cmd_ptype_mapping_replace_result {
15607 cmdline_fixed_string_t ptype;
15608 cmdline_fixed_string_t mapping;
15609 cmdline_fixed_string_t replace;
15616 /* Common CLI fields for ptype mapping replace */
15617 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15618 TOKEN_STRING_INITIALIZER
15619 (struct cmd_ptype_mapping_replace_result,
15621 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15622 TOKEN_STRING_INITIALIZER
15623 (struct cmd_ptype_mapping_replace_result,
15624 mapping, "mapping");
15625 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15626 TOKEN_STRING_INITIALIZER
15627 (struct cmd_ptype_mapping_replace_result,
15628 replace, "replace");
15629 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15630 TOKEN_NUM_INITIALIZER
15631 (struct cmd_ptype_mapping_replace_result,
15632 port_id, RTE_UINT16);
15633 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15634 TOKEN_NUM_INITIALIZER
15635 (struct cmd_ptype_mapping_replace_result,
15636 target, RTE_UINT32);
15637 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15638 TOKEN_NUM_INITIALIZER
15639 (struct cmd_ptype_mapping_replace_result,
15641 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15642 TOKEN_NUM_INITIALIZER
15643 (struct cmd_ptype_mapping_replace_result,
15644 pkt_type, RTE_UINT32);
15647 cmd_ptype_mapping_replace_parsed(
15648 void *parsed_result,
15649 __rte_unused struct cmdline *cl,
15650 __rte_unused void *data)
15652 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15653 int ret = -ENOTSUP;
15655 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15658 #ifdef RTE_NET_I40E
15659 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15669 fprintf(stderr, "invalid ptype 0x%8x or 0x%8x\n",
15670 res->target, res->pkt_type);
15673 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15676 fprintf(stderr, "function not implemented\n");
15679 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15683 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15684 .f = cmd_ptype_mapping_replace_parsed,
15687 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15689 (void *)&cmd_ptype_mapping_replace_ptype,
15690 (void *)&cmd_ptype_mapping_replace_mapping,
15691 (void *)&cmd_ptype_mapping_replace_replace,
15692 (void *)&cmd_ptype_mapping_replace_port_id,
15693 (void *)&cmd_ptype_mapping_replace_target,
15694 (void *)&cmd_ptype_mapping_replace_mask,
15695 (void *)&cmd_ptype_mapping_replace_pkt_type,
15700 /* ptype mapping reset */
15702 /* Common result structure for ptype mapping reset */
15703 struct cmd_ptype_mapping_reset_result {
15704 cmdline_fixed_string_t ptype;
15705 cmdline_fixed_string_t mapping;
15706 cmdline_fixed_string_t reset;
15710 /* Common CLI fields for ptype mapping reset*/
15711 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15712 TOKEN_STRING_INITIALIZER
15713 (struct cmd_ptype_mapping_reset_result,
15715 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15716 TOKEN_STRING_INITIALIZER
15717 (struct cmd_ptype_mapping_reset_result,
15718 mapping, "mapping");
15719 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15720 TOKEN_STRING_INITIALIZER
15721 (struct cmd_ptype_mapping_reset_result,
15723 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15724 TOKEN_NUM_INITIALIZER
15725 (struct cmd_ptype_mapping_reset_result,
15726 port_id, RTE_UINT16);
15729 cmd_ptype_mapping_reset_parsed(
15730 void *parsed_result,
15731 __rte_unused struct cmdline *cl,
15732 __rte_unused void *data)
15734 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15735 int ret = -ENOTSUP;
15737 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15740 #ifdef RTE_NET_I40E
15741 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15748 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15751 fprintf(stderr, "function not implemented\n");
15754 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15758 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15759 .f = cmd_ptype_mapping_reset_parsed,
15761 .help_str = "ptype mapping reset <port_id>",
15763 (void *)&cmd_ptype_mapping_reset_ptype,
15764 (void *)&cmd_ptype_mapping_reset_mapping,
15765 (void *)&cmd_ptype_mapping_reset_reset,
15766 (void *)&cmd_ptype_mapping_reset_port_id,
15771 /* ptype mapping update */
15773 /* Common result structure for ptype mapping update */
15774 struct cmd_ptype_mapping_update_result {
15775 cmdline_fixed_string_t ptype;
15776 cmdline_fixed_string_t mapping;
15777 cmdline_fixed_string_t reset;
15783 /* Common CLI fields for ptype mapping update*/
15784 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15785 TOKEN_STRING_INITIALIZER
15786 (struct cmd_ptype_mapping_update_result,
15788 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15789 TOKEN_STRING_INITIALIZER
15790 (struct cmd_ptype_mapping_update_result,
15791 mapping, "mapping");
15792 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15793 TOKEN_STRING_INITIALIZER
15794 (struct cmd_ptype_mapping_update_result,
15796 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15797 TOKEN_NUM_INITIALIZER
15798 (struct cmd_ptype_mapping_update_result,
15799 port_id, RTE_UINT16);
15800 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15801 TOKEN_NUM_INITIALIZER
15802 (struct cmd_ptype_mapping_update_result,
15803 hw_ptype, RTE_UINT8);
15804 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15805 TOKEN_NUM_INITIALIZER
15806 (struct cmd_ptype_mapping_update_result,
15807 sw_ptype, RTE_UINT32);
15810 cmd_ptype_mapping_update_parsed(
15811 void *parsed_result,
15812 __rte_unused struct cmdline *cl,
15813 __rte_unused void *data)
15815 struct cmd_ptype_mapping_update_result *res = parsed_result;
15816 int ret = -ENOTSUP;
15817 #ifdef RTE_NET_I40E
15818 struct rte_pmd_i40e_ptype_mapping mapping;
15820 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15823 #ifdef RTE_NET_I40E
15824 mapping.hw_ptype = res->hw_ptype;
15825 mapping.sw_ptype = res->sw_ptype;
15826 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15836 fprintf(stderr, "invalid ptype 0x%8x\n", res->sw_ptype);
15839 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15842 fprintf(stderr, "function not implemented\n");
15845 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15849 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15850 .f = cmd_ptype_mapping_update_parsed,
15852 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15854 (void *)&cmd_ptype_mapping_update_ptype,
15855 (void *)&cmd_ptype_mapping_update_mapping,
15856 (void *)&cmd_ptype_mapping_update_update,
15857 (void *)&cmd_ptype_mapping_update_port_id,
15858 (void *)&cmd_ptype_mapping_update_hw_ptype,
15859 (void *)&cmd_ptype_mapping_update_sw_ptype,
15864 /* Common result structure for file commands */
15865 struct cmd_cmdfile_result {
15866 cmdline_fixed_string_t load;
15867 cmdline_fixed_string_t filename;
15870 /* Common CLI fields for file commands */
15871 cmdline_parse_token_string_t cmd_load_cmdfile =
15872 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15873 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15874 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15877 cmd_load_from_file_parsed(
15878 void *parsed_result,
15879 __rte_unused struct cmdline *cl,
15880 __rte_unused void *data)
15882 struct cmd_cmdfile_result *res = parsed_result;
15884 cmdline_read_from_file(res->filename);
15887 cmdline_parse_inst_t cmd_load_from_file = {
15888 .f = cmd_load_from_file_parsed,
15890 .help_str = "load <filename>",
15892 (void *)&cmd_load_cmdfile,
15893 (void *)&cmd_load_cmdfile_filename,
15898 /* Get Rx offloads capabilities */
15899 struct cmd_rx_offload_get_capa_result {
15900 cmdline_fixed_string_t show;
15901 cmdline_fixed_string_t port;
15903 cmdline_fixed_string_t rx_offload;
15904 cmdline_fixed_string_t capabilities;
15907 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
15908 TOKEN_STRING_INITIALIZER
15909 (struct cmd_rx_offload_get_capa_result,
15911 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
15912 TOKEN_STRING_INITIALIZER
15913 (struct cmd_rx_offload_get_capa_result,
15915 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
15916 TOKEN_NUM_INITIALIZER
15917 (struct cmd_rx_offload_get_capa_result,
15918 port_id, RTE_UINT16);
15919 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
15920 TOKEN_STRING_INITIALIZER
15921 (struct cmd_rx_offload_get_capa_result,
15922 rx_offload, "rx_offload");
15923 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
15924 TOKEN_STRING_INITIALIZER
15925 (struct cmd_rx_offload_get_capa_result,
15926 capabilities, "capabilities");
15929 print_rx_offloads(uint64_t offloads)
15931 uint64_t single_offload;
15939 begin = __builtin_ctzll(offloads);
15940 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15942 single_offload = 1ULL << begin;
15943 for (bit = begin; bit < end; bit++) {
15944 if (offloads & single_offload)
15946 rte_eth_dev_rx_offload_name(single_offload));
15947 single_offload <<= 1;
15952 cmd_rx_offload_get_capa_parsed(
15953 void *parsed_result,
15954 __rte_unused struct cmdline *cl,
15955 __rte_unused void *data)
15957 struct cmd_rx_offload_get_capa_result *res = parsed_result;
15958 struct rte_eth_dev_info dev_info;
15959 portid_t port_id = res->port_id;
15960 uint64_t queue_offloads;
15961 uint64_t port_offloads;
15964 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15968 queue_offloads = dev_info.rx_queue_offload_capa;
15969 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
15971 printf("Rx Offloading Capabilities of port %d :\n", port_id);
15972 printf(" Per Queue :");
15973 print_rx_offloads(queue_offloads);
15976 printf(" Per Port :");
15977 print_rx_offloads(port_offloads);
15981 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
15982 .f = cmd_rx_offload_get_capa_parsed,
15984 .help_str = "show port <port_id> rx_offload capabilities",
15986 (void *)&cmd_rx_offload_get_capa_show,
15987 (void *)&cmd_rx_offload_get_capa_port,
15988 (void *)&cmd_rx_offload_get_capa_port_id,
15989 (void *)&cmd_rx_offload_get_capa_rx_offload,
15990 (void *)&cmd_rx_offload_get_capa_capabilities,
15995 /* Get Rx offloads configuration */
15996 struct cmd_rx_offload_get_configuration_result {
15997 cmdline_fixed_string_t show;
15998 cmdline_fixed_string_t port;
16000 cmdline_fixed_string_t rx_offload;
16001 cmdline_fixed_string_t configuration;
16004 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
16005 TOKEN_STRING_INITIALIZER
16006 (struct cmd_rx_offload_get_configuration_result,
16008 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
16009 TOKEN_STRING_INITIALIZER
16010 (struct cmd_rx_offload_get_configuration_result,
16012 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
16013 TOKEN_NUM_INITIALIZER
16014 (struct cmd_rx_offload_get_configuration_result,
16015 port_id, RTE_UINT16);
16016 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
16017 TOKEN_STRING_INITIALIZER
16018 (struct cmd_rx_offload_get_configuration_result,
16019 rx_offload, "rx_offload");
16020 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
16021 TOKEN_STRING_INITIALIZER
16022 (struct cmd_rx_offload_get_configuration_result,
16023 configuration, "configuration");
16026 cmd_rx_offload_get_configuration_parsed(
16027 void *parsed_result,
16028 __rte_unused struct cmdline *cl,
16029 __rte_unused void *data)
16031 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
16032 struct rte_eth_dev_info dev_info;
16033 portid_t port_id = res->port_id;
16034 struct rte_port *port = &ports[port_id];
16035 struct rte_eth_conf dev_conf;
16036 uint64_t port_offloads;
16037 uint64_t queue_offloads;
16038 uint16_t nb_rx_queues;
16042 printf("Rx Offloading Configuration of port %d :\n", port_id);
16044 ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
16048 port_offloads = dev_conf.rxmode.offloads;
16050 print_rx_offloads(port_offloads);
16053 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16057 nb_rx_queues = dev_info.nb_rx_queues;
16058 for (q = 0; q < nb_rx_queues; q++) {
16059 queue_offloads = port->rx_conf[q].offloads;
16060 printf(" Queue[%2d] :", q);
16061 print_rx_offloads(queue_offloads);
16067 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
16068 .f = cmd_rx_offload_get_configuration_parsed,
16070 .help_str = "show port <port_id> rx_offload configuration",
16072 (void *)&cmd_rx_offload_get_configuration_show,
16073 (void *)&cmd_rx_offload_get_configuration_port,
16074 (void *)&cmd_rx_offload_get_configuration_port_id,
16075 (void *)&cmd_rx_offload_get_configuration_rx_offload,
16076 (void *)&cmd_rx_offload_get_configuration_configuration,
16081 /* Enable/Disable a per port offloading */
16082 struct cmd_config_per_port_rx_offload_result {
16083 cmdline_fixed_string_t port;
16084 cmdline_fixed_string_t config;
16086 cmdline_fixed_string_t rx_offload;
16087 cmdline_fixed_string_t offload;
16088 cmdline_fixed_string_t on_off;
16091 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
16092 TOKEN_STRING_INITIALIZER
16093 (struct cmd_config_per_port_rx_offload_result,
16095 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
16096 TOKEN_STRING_INITIALIZER
16097 (struct cmd_config_per_port_rx_offload_result,
16099 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
16100 TOKEN_NUM_INITIALIZER
16101 (struct cmd_config_per_port_rx_offload_result,
16102 port_id, RTE_UINT16);
16103 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
16104 TOKEN_STRING_INITIALIZER
16105 (struct cmd_config_per_port_rx_offload_result,
16106 rx_offload, "rx_offload");
16107 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
16108 TOKEN_STRING_INITIALIZER
16109 (struct cmd_config_per_port_rx_offload_result,
16110 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16111 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16112 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16113 "scatter#buffer_split#timestamp#security#"
16114 "keep_crc#rss_hash");
16115 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
16116 TOKEN_STRING_INITIALIZER
16117 (struct cmd_config_per_port_rx_offload_result,
16121 search_rx_offload(const char *name)
16123 uint64_t single_offload;
16124 const char *single_name;
16128 single_offload = 1;
16129 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16130 single_name = rte_eth_dev_rx_offload_name(single_offload);
16131 if (!strcasecmp(single_name, name)) {
16135 single_offload <<= 1;
16139 return single_offload;
16145 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16146 __rte_unused struct cmdline *cl,
16147 __rte_unused void *data)
16149 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16150 portid_t port_id = res->port_id;
16151 struct rte_eth_dev_info dev_info;
16152 struct rte_port *port = &ports[port_id];
16153 uint64_t single_offload;
16154 uint16_t nb_rx_queues;
16158 if (port->port_status != RTE_PORT_STOPPED) {
16160 "Error: Can't config offload when Port %d is not stopped\n",
16165 single_offload = search_rx_offload(res->offload);
16166 if (single_offload == 0) {
16167 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16171 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16175 nb_rx_queues = dev_info.nb_rx_queues;
16176 if (!strcmp(res->on_off, "on")) {
16177 port->dev_conf.rxmode.offloads |= single_offload;
16178 for (q = 0; q < nb_rx_queues; q++)
16179 port->rx_conf[q].offloads |= single_offload;
16181 port->dev_conf.rxmode.offloads &= ~single_offload;
16182 for (q = 0; q < nb_rx_queues; q++)
16183 port->rx_conf[q].offloads &= ~single_offload;
16186 cmd_reconfig_device_queue(port_id, 1, 1);
16189 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16190 .f = cmd_config_per_port_rx_offload_parsed,
16192 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16193 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16194 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16195 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16196 "keep_crc|rss_hash on|off",
16198 (void *)&cmd_config_per_port_rx_offload_result_port,
16199 (void *)&cmd_config_per_port_rx_offload_result_config,
16200 (void *)&cmd_config_per_port_rx_offload_result_port_id,
16201 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16202 (void *)&cmd_config_per_port_rx_offload_result_offload,
16203 (void *)&cmd_config_per_port_rx_offload_result_on_off,
16208 /* Enable/Disable a per queue offloading */
16209 struct cmd_config_per_queue_rx_offload_result {
16210 cmdline_fixed_string_t port;
16212 cmdline_fixed_string_t rxq;
16214 cmdline_fixed_string_t rx_offload;
16215 cmdline_fixed_string_t offload;
16216 cmdline_fixed_string_t on_off;
16219 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16220 TOKEN_STRING_INITIALIZER
16221 (struct cmd_config_per_queue_rx_offload_result,
16223 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16224 TOKEN_NUM_INITIALIZER
16225 (struct cmd_config_per_queue_rx_offload_result,
16226 port_id, RTE_UINT16);
16227 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16228 TOKEN_STRING_INITIALIZER
16229 (struct cmd_config_per_queue_rx_offload_result,
16231 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16232 TOKEN_NUM_INITIALIZER
16233 (struct cmd_config_per_queue_rx_offload_result,
16234 queue_id, RTE_UINT16);
16235 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16236 TOKEN_STRING_INITIALIZER
16237 (struct cmd_config_per_queue_rx_offload_result,
16238 rx_offload, "rx_offload");
16239 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16240 TOKEN_STRING_INITIALIZER
16241 (struct cmd_config_per_queue_rx_offload_result,
16242 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16243 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16244 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16245 "scatter#buffer_split#timestamp#security#keep_crc");
16246 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16247 TOKEN_STRING_INITIALIZER
16248 (struct cmd_config_per_queue_rx_offload_result,
16252 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16253 __rte_unused struct cmdline *cl,
16254 __rte_unused void *data)
16256 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16257 struct rte_eth_dev_info dev_info;
16258 portid_t port_id = res->port_id;
16259 uint16_t queue_id = res->queue_id;
16260 struct rte_port *port = &ports[port_id];
16261 uint64_t single_offload;
16264 if (port->port_status != RTE_PORT_STOPPED) {
16266 "Error: Can't config offload when Port %d is not stopped\n",
16271 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16275 if (queue_id >= dev_info.nb_rx_queues) {
16277 "Error: input queue_id should be 0 ... %d\n",
16278 dev_info.nb_rx_queues - 1);
16282 single_offload = search_rx_offload(res->offload);
16283 if (single_offload == 0) {
16284 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16288 if (!strcmp(res->on_off, "on"))
16289 port->rx_conf[queue_id].offloads |= single_offload;
16291 port->rx_conf[queue_id].offloads &= ~single_offload;
16293 cmd_reconfig_device_queue(port_id, 1, 1);
16296 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16297 .f = cmd_config_per_queue_rx_offload_parsed,
16299 .help_str = "port <port_id> rxq <queue_id> rx_offload "
16300 "vlan_strip|ipv4_cksum|"
16301 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16302 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16303 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16306 (void *)&cmd_config_per_queue_rx_offload_result_port,
16307 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
16308 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
16309 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16310 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16311 (void *)&cmd_config_per_queue_rx_offload_result_offload,
16312 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
16317 /* Get Tx offloads capabilities */
16318 struct cmd_tx_offload_get_capa_result {
16319 cmdline_fixed_string_t show;
16320 cmdline_fixed_string_t port;
16322 cmdline_fixed_string_t tx_offload;
16323 cmdline_fixed_string_t capabilities;
16326 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16327 TOKEN_STRING_INITIALIZER
16328 (struct cmd_tx_offload_get_capa_result,
16330 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16331 TOKEN_STRING_INITIALIZER
16332 (struct cmd_tx_offload_get_capa_result,
16334 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16335 TOKEN_NUM_INITIALIZER
16336 (struct cmd_tx_offload_get_capa_result,
16337 port_id, RTE_UINT16);
16338 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16339 TOKEN_STRING_INITIALIZER
16340 (struct cmd_tx_offload_get_capa_result,
16341 tx_offload, "tx_offload");
16342 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16343 TOKEN_STRING_INITIALIZER
16344 (struct cmd_tx_offload_get_capa_result,
16345 capabilities, "capabilities");
16348 print_tx_offloads(uint64_t offloads)
16350 uint64_t single_offload;
16358 begin = __builtin_ctzll(offloads);
16359 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16361 single_offload = 1ULL << begin;
16362 for (bit = begin; bit < end; bit++) {
16363 if (offloads & single_offload)
16365 rte_eth_dev_tx_offload_name(single_offload));
16366 single_offload <<= 1;
16371 cmd_tx_offload_get_capa_parsed(
16372 void *parsed_result,
16373 __rte_unused struct cmdline *cl,
16374 __rte_unused void *data)
16376 struct cmd_tx_offload_get_capa_result *res = parsed_result;
16377 struct rte_eth_dev_info dev_info;
16378 portid_t port_id = res->port_id;
16379 uint64_t queue_offloads;
16380 uint64_t port_offloads;
16383 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16387 queue_offloads = dev_info.tx_queue_offload_capa;
16388 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16390 printf("Tx Offloading Capabilities of port %d :\n", port_id);
16391 printf(" Per Queue :");
16392 print_tx_offloads(queue_offloads);
16395 printf(" Per Port :");
16396 print_tx_offloads(port_offloads);
16400 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16401 .f = cmd_tx_offload_get_capa_parsed,
16403 .help_str = "show port <port_id> tx_offload capabilities",
16405 (void *)&cmd_tx_offload_get_capa_show,
16406 (void *)&cmd_tx_offload_get_capa_port,
16407 (void *)&cmd_tx_offload_get_capa_port_id,
16408 (void *)&cmd_tx_offload_get_capa_tx_offload,
16409 (void *)&cmd_tx_offload_get_capa_capabilities,
16414 /* Get Tx offloads configuration */
16415 struct cmd_tx_offload_get_configuration_result {
16416 cmdline_fixed_string_t show;
16417 cmdline_fixed_string_t port;
16419 cmdline_fixed_string_t tx_offload;
16420 cmdline_fixed_string_t configuration;
16423 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16424 TOKEN_STRING_INITIALIZER
16425 (struct cmd_tx_offload_get_configuration_result,
16427 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16428 TOKEN_STRING_INITIALIZER
16429 (struct cmd_tx_offload_get_configuration_result,
16431 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16432 TOKEN_NUM_INITIALIZER
16433 (struct cmd_tx_offload_get_configuration_result,
16434 port_id, RTE_UINT16);
16435 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16436 TOKEN_STRING_INITIALIZER
16437 (struct cmd_tx_offload_get_configuration_result,
16438 tx_offload, "tx_offload");
16439 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16440 TOKEN_STRING_INITIALIZER
16441 (struct cmd_tx_offload_get_configuration_result,
16442 configuration, "configuration");
16445 cmd_tx_offload_get_configuration_parsed(
16446 void *parsed_result,
16447 __rte_unused struct cmdline *cl,
16448 __rte_unused void *data)
16450 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16451 struct rte_eth_dev_info dev_info;
16452 portid_t port_id = res->port_id;
16453 struct rte_port *port = &ports[port_id];
16454 struct rte_eth_conf dev_conf;
16455 uint64_t port_offloads;
16456 uint64_t queue_offloads;
16457 uint16_t nb_tx_queues;
16461 printf("Tx Offloading Configuration of port %d :\n", port_id);
16463 ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
16467 port_offloads = dev_conf.txmode.offloads;
16469 print_tx_offloads(port_offloads);
16472 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16476 nb_tx_queues = dev_info.nb_tx_queues;
16477 for (q = 0; q < nb_tx_queues; q++) {
16478 queue_offloads = port->tx_conf[q].offloads;
16479 printf(" Queue[%2d] :", q);
16480 print_tx_offloads(queue_offloads);
16486 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16487 .f = cmd_tx_offload_get_configuration_parsed,
16489 .help_str = "show port <port_id> tx_offload configuration",
16491 (void *)&cmd_tx_offload_get_configuration_show,
16492 (void *)&cmd_tx_offload_get_configuration_port,
16493 (void *)&cmd_tx_offload_get_configuration_port_id,
16494 (void *)&cmd_tx_offload_get_configuration_tx_offload,
16495 (void *)&cmd_tx_offload_get_configuration_configuration,
16500 /* Enable/Disable a per port offloading */
16501 struct cmd_config_per_port_tx_offload_result {
16502 cmdline_fixed_string_t port;
16503 cmdline_fixed_string_t config;
16505 cmdline_fixed_string_t tx_offload;
16506 cmdline_fixed_string_t offload;
16507 cmdline_fixed_string_t on_off;
16510 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16511 TOKEN_STRING_INITIALIZER
16512 (struct cmd_config_per_port_tx_offload_result,
16514 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16515 TOKEN_STRING_INITIALIZER
16516 (struct cmd_config_per_port_tx_offload_result,
16518 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16519 TOKEN_NUM_INITIALIZER
16520 (struct cmd_config_per_port_tx_offload_result,
16521 port_id, RTE_UINT16);
16522 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16523 TOKEN_STRING_INITIALIZER
16524 (struct cmd_config_per_port_tx_offload_result,
16525 tx_offload, "tx_offload");
16526 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16527 TOKEN_STRING_INITIALIZER
16528 (struct cmd_config_per_port_tx_offload_result,
16529 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16530 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16531 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16532 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16533 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16534 "send_on_timestamp");
16535 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16536 TOKEN_STRING_INITIALIZER
16537 (struct cmd_config_per_port_tx_offload_result,
16541 search_tx_offload(const char *name)
16543 uint64_t single_offload;
16544 const char *single_name;
16548 single_offload = 1;
16549 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16550 single_name = rte_eth_dev_tx_offload_name(single_offload);
16551 if (single_name == NULL)
16553 if (!strcasecmp(single_name, name)) {
16556 } else if (!strcasecmp(single_name, "UNKNOWN"))
16558 single_offload <<= 1;
16562 return single_offload;
16568 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16569 __rte_unused struct cmdline *cl,
16570 __rte_unused void *data)
16572 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16573 portid_t port_id = res->port_id;
16574 struct rte_eth_dev_info dev_info;
16575 struct rte_port *port = &ports[port_id];
16576 uint64_t single_offload;
16577 uint16_t nb_tx_queues;
16581 if (port->port_status != RTE_PORT_STOPPED) {
16583 "Error: Can't config offload when Port %d is not stopped\n",
16588 single_offload = search_tx_offload(res->offload);
16589 if (single_offload == 0) {
16590 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16594 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16598 nb_tx_queues = dev_info.nb_tx_queues;
16599 if (!strcmp(res->on_off, "on")) {
16600 port->dev_conf.txmode.offloads |= single_offload;
16601 for (q = 0; q < nb_tx_queues; q++)
16602 port->tx_conf[q].offloads |= single_offload;
16604 port->dev_conf.txmode.offloads &= ~single_offload;
16605 for (q = 0; q < nb_tx_queues; q++)
16606 port->tx_conf[q].offloads &= ~single_offload;
16609 cmd_reconfig_device_queue(port_id, 1, 1);
16612 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16613 .f = cmd_config_per_port_tx_offload_parsed,
16615 .help_str = "port config <port_id> tx_offload "
16616 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16617 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16618 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16619 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16620 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16621 "send_on_timestamp on|off",
16623 (void *)&cmd_config_per_port_tx_offload_result_port,
16624 (void *)&cmd_config_per_port_tx_offload_result_config,
16625 (void *)&cmd_config_per_port_tx_offload_result_port_id,
16626 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16627 (void *)&cmd_config_per_port_tx_offload_result_offload,
16628 (void *)&cmd_config_per_port_tx_offload_result_on_off,
16633 /* Enable/Disable a per queue offloading */
16634 struct cmd_config_per_queue_tx_offload_result {
16635 cmdline_fixed_string_t port;
16637 cmdline_fixed_string_t txq;
16639 cmdline_fixed_string_t tx_offload;
16640 cmdline_fixed_string_t offload;
16641 cmdline_fixed_string_t on_off;
16644 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16645 TOKEN_STRING_INITIALIZER
16646 (struct cmd_config_per_queue_tx_offload_result,
16648 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16649 TOKEN_NUM_INITIALIZER
16650 (struct cmd_config_per_queue_tx_offload_result,
16651 port_id, RTE_UINT16);
16652 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16653 TOKEN_STRING_INITIALIZER
16654 (struct cmd_config_per_queue_tx_offload_result,
16656 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16657 TOKEN_NUM_INITIALIZER
16658 (struct cmd_config_per_queue_tx_offload_result,
16659 queue_id, RTE_UINT16);
16660 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16661 TOKEN_STRING_INITIALIZER
16662 (struct cmd_config_per_queue_tx_offload_result,
16663 tx_offload, "tx_offload");
16664 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16665 TOKEN_STRING_INITIALIZER
16666 (struct cmd_config_per_queue_tx_offload_result,
16667 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16668 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16669 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16670 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16671 "mt_lockfree#multi_segs#mbuf_fast_free#security");
16672 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16673 TOKEN_STRING_INITIALIZER
16674 (struct cmd_config_per_queue_tx_offload_result,
16678 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16679 __rte_unused struct cmdline *cl,
16680 __rte_unused void *data)
16682 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16683 struct rte_eth_dev_info dev_info;
16684 portid_t port_id = res->port_id;
16685 uint16_t queue_id = res->queue_id;
16686 struct rte_port *port = &ports[port_id];
16687 uint64_t single_offload;
16690 if (port->port_status != RTE_PORT_STOPPED) {
16692 "Error: Can't config offload when Port %d is not stopped\n",
16697 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16701 if (queue_id >= dev_info.nb_tx_queues) {
16703 "Error: input queue_id should be 0 ... %d\n",
16704 dev_info.nb_tx_queues - 1);
16708 single_offload = search_tx_offload(res->offload);
16709 if (single_offload == 0) {
16710 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16714 if (!strcmp(res->on_off, "on"))
16715 port->tx_conf[queue_id].offloads |= single_offload;
16717 port->tx_conf[queue_id].offloads &= ~single_offload;
16719 cmd_reconfig_device_queue(port_id, 1, 1);
16722 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16723 .f = cmd_config_per_queue_tx_offload_parsed,
16725 .help_str = "port <port_id> txq <queue_id> tx_offload "
16726 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16727 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16728 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16729 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16730 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16733 (void *)&cmd_config_per_queue_tx_offload_result_port,
16734 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16735 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16736 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16737 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16738 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16739 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16744 /* *** configure tx_metadata for specific port *** */
16745 struct cmd_config_tx_metadata_specific_result {
16746 cmdline_fixed_string_t port;
16747 cmdline_fixed_string_t keyword;
16749 cmdline_fixed_string_t item;
16754 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16755 __rte_unused struct cmdline *cl,
16756 __rte_unused void *data)
16758 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16760 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16762 ports[res->port_id].tx_metadata = res->value;
16763 /* Add/remove callback to insert valid metadata in every Tx packet. */
16764 if (ports[res->port_id].tx_metadata)
16765 add_tx_md_callback(res->port_id);
16767 remove_tx_md_callback(res->port_id);
16768 rte_flow_dynf_metadata_register();
16771 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16772 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16774 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16775 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16776 keyword, "config");
16777 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16778 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16779 port_id, RTE_UINT16);
16780 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16781 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16782 item, "tx_metadata");
16783 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16784 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16785 value, RTE_UINT32);
16787 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16788 .f = cmd_config_tx_metadata_specific_parsed,
16790 .help_str = "port config <port_id> tx_metadata <value>",
16792 (void *)&cmd_config_tx_metadata_specific_port,
16793 (void *)&cmd_config_tx_metadata_specific_keyword,
16794 (void *)&cmd_config_tx_metadata_specific_id,
16795 (void *)&cmd_config_tx_metadata_specific_item,
16796 (void *)&cmd_config_tx_metadata_specific_value,
16801 /* *** set dynf *** */
16802 struct cmd_config_tx_dynf_specific_result {
16803 cmdline_fixed_string_t port;
16804 cmdline_fixed_string_t keyword;
16806 cmdline_fixed_string_t item;
16807 cmdline_fixed_string_t name;
16808 cmdline_fixed_string_t value;
16812 cmd_config_dynf_specific_parsed(void *parsed_result,
16813 __rte_unused struct cmdline *cl,
16814 __rte_unused void *data)
16816 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16817 struct rte_mbuf_dynflag desc_flag;
16819 uint64_t old_port_flags;
16821 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16823 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16825 if (strlcpy(desc_flag.name, res->name,
16826 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16827 fprintf(stderr, "Flag name too long\n");
16830 desc_flag.flags = 0;
16831 flag = rte_mbuf_dynflag_register(&desc_flag);
16833 fprintf(stderr, "Can't register flag\n");
16836 strcpy(dynf_names[flag], desc_flag.name);
16838 old_port_flags = ports[res->port_id].mbuf_dynf;
16839 if (!strcmp(res->value, "set")) {
16840 ports[res->port_id].mbuf_dynf |= 1UL << flag;
16841 if (old_port_flags == 0)
16842 add_tx_dynf_callback(res->port_id);
16844 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16845 if (ports[res->port_id].mbuf_dynf == 0)
16846 remove_tx_dynf_callback(res->port_id);
16850 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16851 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16853 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16854 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16855 keyword, "config");
16856 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
16857 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16858 port_id, RTE_UINT16);
16859 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
16860 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16862 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
16863 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16865 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
16866 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16867 value, "set#clear");
16869 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
16870 .f = cmd_config_dynf_specific_parsed,
16872 .help_str = "port config <port id> dynf <name> set|clear",
16874 (void *)&cmd_config_tx_dynf_specific_port,
16875 (void *)&cmd_config_tx_dynf_specific_keyword,
16876 (void *)&cmd_config_tx_dynf_specific_port_id,
16877 (void *)&cmd_config_tx_dynf_specific_item,
16878 (void *)&cmd_config_tx_dynf_specific_name,
16879 (void *)&cmd_config_tx_dynf_specific_value,
16884 /* *** display tx_metadata per port configuration *** */
16885 struct cmd_show_tx_metadata_result {
16886 cmdline_fixed_string_t cmd_show;
16887 cmdline_fixed_string_t cmd_port;
16888 cmdline_fixed_string_t cmd_keyword;
16893 cmd_show_tx_metadata_parsed(void *parsed_result,
16894 __rte_unused struct cmdline *cl,
16895 __rte_unused void *data)
16897 struct cmd_show_tx_metadata_result *res = parsed_result;
16899 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16900 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
16903 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
16904 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
16905 ports[res->cmd_pid].tx_metadata);
16909 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
16910 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16912 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
16913 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16915 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
16916 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
16917 cmd_pid, RTE_UINT16);
16918 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
16919 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16920 cmd_keyword, "tx_metadata");
16922 cmdline_parse_inst_t cmd_show_tx_metadata = {
16923 .f = cmd_show_tx_metadata_parsed,
16925 .help_str = "show port <port_id> tx_metadata",
16927 (void *)&cmd_show_tx_metadata_show,
16928 (void *)&cmd_show_tx_metadata_port,
16929 (void *)&cmd_show_tx_metadata_pid,
16930 (void *)&cmd_show_tx_metadata_keyword,
16935 /* *** show fec capability per port configuration *** */
16936 struct cmd_show_fec_capability_result {
16937 cmdline_fixed_string_t cmd_show;
16938 cmdline_fixed_string_t cmd_port;
16939 cmdline_fixed_string_t cmd_fec;
16940 cmdline_fixed_string_t cmd_keyword;
16945 cmd_show_fec_capability_parsed(void *parsed_result,
16946 __rte_unused struct cmdline *cl,
16947 __rte_unused void *data)
16949 struct cmd_show_fec_capability_result *res = parsed_result;
16950 struct rte_eth_fec_capa *speed_fec_capa;
16954 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16955 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
16959 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
16960 if (ret == -ENOTSUP) {
16961 fprintf(stderr, "Function not implemented\n");
16963 } else if (ret < 0) {
16964 fprintf(stderr, "Get FEC capability failed: %d\n", ret);
16968 num = (unsigned int)ret;
16969 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
16970 if (speed_fec_capa == NULL) {
16971 fprintf(stderr, "Failed to alloc FEC capability buffer\n");
16975 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
16977 fprintf(stderr, "Error getting FEC capability: %d\n", ret);
16981 show_fec_capability(num, speed_fec_capa);
16983 free(speed_fec_capa);
16986 cmdline_parse_token_string_t cmd_show_fec_capability_show =
16987 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16989 cmdline_parse_token_string_t cmd_show_fec_capability_port =
16990 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16992 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
16993 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
16994 cmd_pid, RTE_UINT16);
16995 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
16996 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16998 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
16999 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
17000 cmd_keyword, "capabilities");
17002 cmdline_parse_inst_t cmd_show_capability = {
17003 .f = cmd_show_fec_capability_parsed,
17005 .help_str = "show port <port_id> fec capabilities",
17007 (void *)&cmd_show_fec_capability_show,
17008 (void *)&cmd_show_fec_capability_port,
17009 (void *)&cmd_show_fec_capability_pid,
17010 (void *)&cmd_show_fec_capability_fec,
17011 (void *)&cmd_show_fec_capability_keyword,
17016 /* *** show fec mode per port configuration *** */
17017 struct cmd_show_fec_metadata_result {
17018 cmdline_fixed_string_t cmd_show;
17019 cmdline_fixed_string_t cmd_port;
17020 cmdline_fixed_string_t cmd_keyword;
17025 cmd_show_fec_mode_parsed(void *parsed_result,
17026 __rte_unused struct cmdline *cl,
17027 __rte_unused void *data)
17029 #define FEC_NAME_SIZE 16
17030 struct cmd_show_fec_metadata_result *res = parsed_result;
17032 char buf[FEC_NAME_SIZE];
17035 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17036 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
17039 ret = rte_eth_fec_get(res->cmd_pid, &mode);
17040 if (ret == -ENOTSUP) {
17041 fprintf(stderr, "Function not implemented\n");
17043 } else if (ret < 0) {
17044 fprintf(stderr, "Get FEC mode failed\n");
17049 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
17050 strlcpy(buf, "off", sizeof(buf));
17052 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
17053 strlcpy(buf, "auto", sizeof(buf));
17055 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
17056 strlcpy(buf, "baser", sizeof(buf));
17058 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
17059 strlcpy(buf, "rs", sizeof(buf));
17065 printf("%s\n", buf);
17068 cmdline_parse_token_string_t cmd_show_fec_mode_show =
17069 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17071 cmdline_parse_token_string_t cmd_show_fec_mode_port =
17072 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17074 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
17075 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
17076 cmd_pid, RTE_UINT16);
17077 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
17078 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17079 cmd_keyword, "fec_mode");
17081 cmdline_parse_inst_t cmd_show_fec_mode = {
17082 .f = cmd_show_fec_mode_parsed,
17084 .help_str = "show port <port_id> fec_mode",
17086 (void *)&cmd_show_fec_mode_show,
17087 (void *)&cmd_show_fec_mode_port,
17088 (void *)&cmd_show_fec_mode_pid,
17089 (void *)&cmd_show_fec_mode_keyword,
17094 /* *** set fec mode per port configuration *** */
17095 struct cmd_set_port_fec_mode {
17096 cmdline_fixed_string_t set;
17097 cmdline_fixed_string_t port;
17099 cmdline_fixed_string_t fec_mode;
17100 cmdline_fixed_string_t fec_value;
17103 /* Common CLI fields for set fec mode */
17104 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
17105 TOKEN_STRING_INITIALIZER
17106 (struct cmd_set_port_fec_mode,
17108 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
17109 TOKEN_STRING_INITIALIZER
17110 (struct cmd_set_port_fec_mode,
17112 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
17113 TOKEN_NUM_INITIALIZER
17114 (struct cmd_set_port_fec_mode,
17115 port_id, RTE_UINT16);
17116 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
17117 TOKEN_STRING_INITIALIZER
17118 (struct cmd_set_port_fec_mode,
17119 fec_mode, "fec_mode");
17120 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
17121 TOKEN_STRING_INITIALIZER
17122 (struct cmd_set_port_fec_mode,
17126 cmd_set_port_fec_mode_parsed(
17127 void *parsed_result,
17128 __rte_unused struct cmdline *cl,
17129 __rte_unused void *data)
17131 struct cmd_set_port_fec_mode *res = parsed_result;
17132 uint16_t port_id = res->port_id;
17136 ret = parse_fec_mode(res->fec_value, &fec_capa);
17138 fprintf(stderr, "Unknown fec mode: %s for port %d\n",
17139 res->fec_value, port_id);
17143 ret = rte_eth_fec_set(port_id, fec_capa);
17144 if (ret == -ENOTSUP) {
17145 fprintf(stderr, "Function not implemented\n");
17147 } else if (ret < 0) {
17148 fprintf(stderr, "Set FEC mode failed\n");
17153 cmdline_parse_inst_t cmd_set_fec_mode = {
17154 .f = cmd_set_port_fec_mode_parsed,
17156 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
17158 (void *)&cmd_set_port_fec_mode_set,
17159 (void *)&cmd_set_port_fec_mode_port,
17160 (void *)&cmd_set_port_fec_mode_port_id,
17161 (void *)&cmd_set_port_fec_mode_str,
17162 (void *)&cmd_set_port_fec_mode_value,
17167 /* show port supported ptypes */
17169 /* Common result structure for show port ptypes */
17170 struct cmd_show_port_supported_ptypes_result {
17171 cmdline_fixed_string_t show;
17172 cmdline_fixed_string_t port;
17174 cmdline_fixed_string_t ptypes;
17177 /* Common CLI fields for show port ptypes */
17178 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
17179 TOKEN_STRING_INITIALIZER
17180 (struct cmd_show_port_supported_ptypes_result,
17182 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
17183 TOKEN_STRING_INITIALIZER
17184 (struct cmd_show_port_supported_ptypes_result,
17186 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
17187 TOKEN_NUM_INITIALIZER
17188 (struct cmd_show_port_supported_ptypes_result,
17189 port_id, RTE_UINT16);
17190 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
17191 TOKEN_STRING_INITIALIZER
17192 (struct cmd_show_port_supported_ptypes_result,
17196 cmd_show_port_supported_ptypes_parsed(
17197 void *parsed_result,
17198 __rte_unused struct cmdline *cl,
17199 __rte_unused void *data)
17201 #define RSVD_PTYPE_MASK 0xf0000000
17202 #define MAX_PTYPES_PER_LAYER 16
17203 #define LTYPE_NAMESIZE 32
17204 #define PTYPE_NAMESIZE 256
17205 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
17206 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
17207 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
17208 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
17209 uint16_t port_id = res->port_id;
17212 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
17216 while (ptype_mask != RSVD_PTYPE_MASK) {
17218 switch (ptype_mask) {
17219 case RTE_PTYPE_L2_MASK:
17220 strlcpy(ltype, "L2", sizeof(ltype));
17222 case RTE_PTYPE_L3_MASK:
17223 strlcpy(ltype, "L3", sizeof(ltype));
17225 case RTE_PTYPE_L4_MASK:
17226 strlcpy(ltype, "L4", sizeof(ltype));
17228 case RTE_PTYPE_TUNNEL_MASK:
17229 strlcpy(ltype, "Tunnel", sizeof(ltype));
17231 case RTE_PTYPE_INNER_L2_MASK:
17232 strlcpy(ltype, "Inner L2", sizeof(ltype));
17234 case RTE_PTYPE_INNER_L3_MASK:
17235 strlcpy(ltype, "Inner L3", sizeof(ltype));
17237 case RTE_PTYPE_INNER_L4_MASK:
17238 strlcpy(ltype, "Inner L4", sizeof(ltype));
17244 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
17245 ptype_mask, ptypes,
17246 MAX_PTYPES_PER_LAYER);
17249 printf("Supported %s ptypes:\n", ltype);
17251 printf("%s ptypes unsupported\n", ltype);
17253 for (i = 0; i < ret; ++i) {
17254 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
17255 printf("%s\n", buf);
17262 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
17263 .f = cmd_show_port_supported_ptypes_parsed,
17265 .help_str = "show port <port_id> ptypes",
17267 (void *)&cmd_show_port_supported_ptypes_show,
17268 (void *)&cmd_show_port_supported_ptypes_port,
17269 (void *)&cmd_show_port_supported_ptypes_port_id,
17270 (void *)&cmd_show_port_supported_ptypes_ptypes,
17275 /* *** display rx/tx descriptor status *** */
17276 struct cmd_show_rx_tx_desc_status_result {
17277 cmdline_fixed_string_t cmd_show;
17278 cmdline_fixed_string_t cmd_port;
17279 cmdline_fixed_string_t cmd_keyword;
17280 cmdline_fixed_string_t cmd_desc;
17281 cmdline_fixed_string_t cmd_status;
17288 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
17289 __rte_unused struct cmdline *cl,
17290 __rte_unused void *data)
17292 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
17295 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17296 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17300 if (!strcmp(res->cmd_keyword, "rxq")) {
17301 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
17305 "Invalid input: queue id = %d, desc id = %d\n",
17306 res->cmd_qid, res->cmd_did);
17309 if (rc == RTE_ETH_RX_DESC_AVAIL)
17310 printf("Desc status = AVAILABLE\n");
17311 else if (rc == RTE_ETH_RX_DESC_DONE)
17312 printf("Desc status = DONE\n");
17314 printf("Desc status = UNAVAILABLE\n");
17315 } else if (!strcmp(res->cmd_keyword, "txq")) {
17316 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17320 "Invalid input: queue id = %d, desc id = %d\n",
17321 res->cmd_qid, res->cmd_did);
17324 if (rc == RTE_ETH_TX_DESC_FULL)
17325 printf("Desc status = FULL\n");
17326 else if (rc == RTE_ETH_TX_DESC_DONE)
17327 printf("Desc status = DONE\n");
17329 printf("Desc status = UNAVAILABLE\n");
17333 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17334 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17336 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17337 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17339 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17340 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17341 cmd_pid, RTE_UINT16);
17342 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17343 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17344 cmd_keyword, "rxq#txq");
17345 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17346 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17347 cmd_qid, RTE_UINT16);
17348 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17349 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17351 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17352 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17353 cmd_did, RTE_UINT16);
17354 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17355 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17356 cmd_status, "status");
17357 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17358 .f = cmd_show_rx_tx_desc_status_parsed,
17360 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17363 (void *)&cmd_show_rx_tx_desc_status_show,
17364 (void *)&cmd_show_rx_tx_desc_status_port,
17365 (void *)&cmd_show_rx_tx_desc_status_pid,
17366 (void *)&cmd_show_rx_tx_desc_status_keyword,
17367 (void *)&cmd_show_rx_tx_desc_status_qid,
17368 (void *)&cmd_show_rx_tx_desc_status_desc,
17369 (void *)&cmd_show_rx_tx_desc_status_did,
17370 (void *)&cmd_show_rx_tx_desc_status_status,
17375 /* *** display rx queue desc used count *** */
17376 struct cmd_show_rx_queue_desc_used_count_result {
17377 cmdline_fixed_string_t cmd_show;
17378 cmdline_fixed_string_t cmd_port;
17379 cmdline_fixed_string_t cmd_rxq;
17380 cmdline_fixed_string_t cmd_desc;
17381 cmdline_fixed_string_t cmd_used;
17382 cmdline_fixed_string_t cmd_count;
17388 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17389 __rte_unused struct cmdline *cl,
17390 __rte_unused void *data)
17392 struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17395 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17396 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17400 rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17402 fprintf(stderr, "Invalid queueid = %d\n", res->cmd_qid);
17405 printf("Used desc count = %d\n", rc);
17408 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17409 TOKEN_STRING_INITIALIZER
17410 (struct cmd_show_rx_queue_desc_used_count_result,
17412 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17413 TOKEN_STRING_INITIALIZER
17414 (struct cmd_show_rx_queue_desc_used_count_result,
17416 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17417 TOKEN_NUM_INITIALIZER
17418 (struct cmd_show_rx_queue_desc_used_count_result,
17419 cmd_pid, RTE_UINT16);
17420 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17421 TOKEN_STRING_INITIALIZER
17422 (struct cmd_show_rx_queue_desc_used_count_result,
17424 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17425 TOKEN_NUM_INITIALIZER
17426 (struct cmd_show_rx_queue_desc_used_count_result,
17427 cmd_qid, RTE_UINT16);
17428 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17429 TOKEN_STRING_INITIALIZER
17430 (struct cmd_show_rx_queue_desc_used_count_result,
17431 cmd_count, "desc");
17432 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17433 TOKEN_STRING_INITIALIZER
17434 (struct cmd_show_rx_queue_desc_used_count_result,
17435 cmd_count, "used");
17436 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17437 TOKEN_STRING_INITIALIZER
17438 (struct cmd_show_rx_queue_desc_used_count_result,
17439 cmd_count, "count");
17440 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17441 .f = cmd_show_rx_queue_desc_used_count_parsed,
17443 .help_str = "show port <port_id> rxq <queue_id> desc used count",
17445 (void *)&cmd_show_rx_queue_desc_used_count_show,
17446 (void *)&cmd_show_rx_queue_desc_used_count_port,
17447 (void *)&cmd_show_rx_queue_desc_used_count_pid,
17448 (void *)&cmd_show_rx_queue_desc_used_count_rxq,
17449 (void *)&cmd_show_rx_queue_desc_used_count_qid,
17450 (void *)&cmd_show_rx_queue_desc_used_count_desc,
17451 (void *)&cmd_show_rx_queue_desc_used_count_used,
17452 (void *)&cmd_show_rx_queue_desc_used_count_count,
17457 /* Common result structure for set port ptypes */
17458 struct cmd_set_port_ptypes_result {
17459 cmdline_fixed_string_t set;
17460 cmdline_fixed_string_t port;
17462 cmdline_fixed_string_t ptype_mask;
17466 /* Common CLI fields for set port ptypes */
17467 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17468 TOKEN_STRING_INITIALIZER
17469 (struct cmd_set_port_ptypes_result,
17471 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17472 TOKEN_STRING_INITIALIZER
17473 (struct cmd_set_port_ptypes_result,
17475 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17476 TOKEN_NUM_INITIALIZER
17477 (struct cmd_set_port_ptypes_result,
17478 port_id, RTE_UINT16);
17479 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17480 TOKEN_STRING_INITIALIZER
17481 (struct cmd_set_port_ptypes_result,
17482 ptype_mask, "ptype_mask");
17483 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17484 TOKEN_NUM_INITIALIZER
17485 (struct cmd_set_port_ptypes_result,
17489 cmd_set_port_ptypes_parsed(
17490 void *parsed_result,
17491 __rte_unused struct cmdline *cl,
17492 __rte_unused void *data)
17494 struct cmd_set_port_ptypes_result *res = parsed_result;
17495 #define PTYPE_NAMESIZE 256
17496 char ptype_name[PTYPE_NAMESIZE];
17497 uint16_t port_id = res->port_id;
17498 uint32_t ptype_mask = res->mask;
17501 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17504 fprintf(stderr, "Port %d doesn't support any ptypes.\n",
17509 uint32_t ptypes[ret];
17511 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17513 fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
17518 printf("Successfully set following ptypes for Port %d\n", port_id);
17519 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17520 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17521 printf("%s\n", ptype_name);
17524 clear_ptypes = false;
17527 cmdline_parse_inst_t cmd_set_port_ptypes = {
17528 .f = cmd_set_port_ptypes_parsed,
17530 .help_str = "set port <port_id> ptype_mask <mask>",
17532 (void *)&cmd_set_port_ptypes_set,
17533 (void *)&cmd_set_port_ptypes_port,
17534 (void *)&cmd_set_port_ptypes_port_id,
17535 (void *)&cmd_set_port_ptypes_mask_str,
17536 (void *)&cmd_set_port_ptypes_mask_u32,
17541 /* *** display mac addresses added to a port *** */
17542 struct cmd_showport_macs_result {
17543 cmdline_fixed_string_t cmd_show;
17544 cmdline_fixed_string_t cmd_port;
17545 cmdline_fixed_string_t cmd_keyword;
17550 cmd_showport_macs_parsed(void *parsed_result,
17551 __rte_unused struct cmdline *cl,
17552 __rte_unused void *data)
17554 struct cmd_showport_macs_result *res = parsed_result;
17556 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17559 if (!strcmp(res->cmd_keyword, "macs"))
17560 show_macs(res->cmd_pid);
17561 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17562 show_mcast_macs(res->cmd_pid);
17565 cmdline_parse_token_string_t cmd_showport_macs_show =
17566 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17568 cmdline_parse_token_string_t cmd_showport_macs_port =
17569 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17571 cmdline_parse_token_num_t cmd_showport_macs_pid =
17572 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17573 cmd_pid, RTE_UINT16);
17574 cmdline_parse_token_string_t cmd_showport_macs_keyword =
17575 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17576 cmd_keyword, "macs#mcast_macs");
17578 cmdline_parse_inst_t cmd_showport_macs = {
17579 .f = cmd_showport_macs_parsed,
17581 .help_str = "show port <port_id> macs|mcast_macs",
17583 (void *)&cmd_showport_macs_show,
17584 (void *)&cmd_showport_macs_port,
17585 (void *)&cmd_showport_macs_pid,
17586 (void *)&cmd_showport_macs_keyword,
17591 /* ******************************************************************************** */
17593 /* list of instructions */
17594 cmdline_parse_ctx_t main_ctx[] = {
17595 (cmdline_parse_inst_t *)&cmd_help_brief,
17596 (cmdline_parse_inst_t *)&cmd_help_long,
17597 (cmdline_parse_inst_t *)&cmd_quit,
17598 (cmdline_parse_inst_t *)&cmd_load_from_file,
17599 (cmdline_parse_inst_t *)&cmd_showport,
17600 (cmdline_parse_inst_t *)&cmd_showqueue,
17601 (cmdline_parse_inst_t *)&cmd_showeeprom,
17602 (cmdline_parse_inst_t *)&cmd_showportall,
17603 (cmdline_parse_inst_t *)&cmd_representor_info,
17604 (cmdline_parse_inst_t *)&cmd_showdevice,
17605 (cmdline_parse_inst_t *)&cmd_showcfg,
17606 (cmdline_parse_inst_t *)&cmd_showfwdall,
17607 (cmdline_parse_inst_t *)&cmd_start,
17608 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17609 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17610 (cmdline_parse_inst_t *)&cmd_set_link_up,
17611 (cmdline_parse_inst_t *)&cmd_set_link_down,
17612 (cmdline_parse_inst_t *)&cmd_reset,
17613 (cmdline_parse_inst_t *)&cmd_set_numbers,
17614 (cmdline_parse_inst_t *)&cmd_set_log,
17615 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
17616 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
17617 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17618 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17619 (cmdline_parse_inst_t *)&cmd_set_txtimes,
17620 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17621 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17622 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17623 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17624 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17625 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17626 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17627 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17628 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17629 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17630 (cmdline_parse_inst_t *)&cmd_set_link_check,
17631 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17632 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17633 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17634 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17635 #ifdef RTE_NET_BOND
17636 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17637 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17638 (cmdline_parse_inst_t *) &cmd_show_bonding_lacp_info,
17639 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17640 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17641 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17642 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17643 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17644 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17645 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17646 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17647 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17649 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17650 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17651 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17652 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17653 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17654 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17655 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17656 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17657 (cmdline_parse_inst_t *)&cmd_csum_set,
17658 (cmdline_parse_inst_t *)&cmd_csum_show,
17659 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17660 (cmdline_parse_inst_t *)&cmd_tso_set,
17661 (cmdline_parse_inst_t *)&cmd_tso_show,
17662 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17663 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17664 (cmdline_parse_inst_t *)&cmd_gro_enable,
17665 (cmdline_parse_inst_t *)&cmd_gro_flush,
17666 (cmdline_parse_inst_t *)&cmd_gro_show,
17667 (cmdline_parse_inst_t *)&cmd_gso_enable,
17668 (cmdline_parse_inst_t *)&cmd_gso_size,
17669 (cmdline_parse_inst_t *)&cmd_gso_show,
17670 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17671 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17672 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17673 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17674 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17675 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17676 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17677 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17678 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17679 (cmdline_parse_inst_t *)&cmd_link_flow_control_show,
17680 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17681 (cmdline_parse_inst_t *)&cmd_config_dcb,
17682 (cmdline_parse_inst_t *)&cmd_read_reg,
17683 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17684 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17685 (cmdline_parse_inst_t *)&cmd_write_reg,
17686 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17687 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17688 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17689 (cmdline_parse_inst_t *)&cmd_stop,
17690 (cmdline_parse_inst_t *)&cmd_mac_addr,
17691 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17692 (cmdline_parse_inst_t *)&cmd_set_qmap,
17693 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17694 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17695 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17696 (cmdline_parse_inst_t *)&cmd_operate_port,
17697 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17698 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17699 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17700 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
17701 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17702 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17703 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17704 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17705 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17706 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17707 (cmdline_parse_inst_t *)&cmd_config_mtu,
17708 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17709 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17710 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17711 (cmdline_parse_inst_t *)&cmd_config_rss,
17712 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17713 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17714 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17715 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17716 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17717 (cmdline_parse_inst_t *)&cmd_showport_reta,
17718 (cmdline_parse_inst_t *)&cmd_showport_macs,
17719 (cmdline_parse_inst_t *)&cmd_config_burst,
17720 (cmdline_parse_inst_t *)&cmd_config_thresh,
17721 (cmdline_parse_inst_t *)&cmd_config_threshold,
17722 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17723 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17724 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17725 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17726 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17727 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17728 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17729 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17730 (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
17731 (cmdline_parse_inst_t *)&cmd_dump,
17732 (cmdline_parse_inst_t *)&cmd_dump_one,
17733 #ifdef RTE_NET_I40E
17734 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17736 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17737 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17738 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17739 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17740 (cmdline_parse_inst_t *)&cmd_flow,
17741 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17742 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17743 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17744 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17745 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17746 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17747 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17748 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17749 (cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
17750 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17751 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17752 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17753 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17754 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17755 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17756 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17757 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17758 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17759 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17760 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17761 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17762 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17763 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17764 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17765 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17766 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17767 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17768 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17769 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17770 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17771 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17772 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17773 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17774 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17775 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17776 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17777 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17778 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
17779 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
17780 (cmdline_parse_inst_t *)&cmd_set_vxlan,
17781 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
17782 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17783 (cmdline_parse_inst_t *)&cmd_set_nvgre,
17784 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17785 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
17786 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
17787 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
17788 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
17789 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
17790 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
17791 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
17792 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
17793 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
17794 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
17795 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
17796 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
17797 (cmdline_parse_inst_t *)&cmd_set_conntrack_common,
17798 (cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
17799 (cmdline_parse_inst_t *)&cmd_ddp_add,
17800 (cmdline_parse_inst_t *)&cmd_ddp_del,
17801 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
17802 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
17803 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
17804 (cmdline_parse_inst_t *)&cmd_clear_input_set,
17805 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
17806 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17807 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
17808 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
17809 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17810 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17811 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17812 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17814 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17815 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17816 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17817 (cmdline_parse_inst_t *)&cmd_queue_region,
17818 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17819 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17820 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17821 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17822 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17823 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17824 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17825 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17826 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17827 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17828 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17829 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17830 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17831 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17832 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17833 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17834 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17835 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
17836 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17837 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17838 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17839 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17840 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17841 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17842 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
17843 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
17844 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
17845 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17846 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17847 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17848 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17849 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17850 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17851 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17852 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17853 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17855 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17856 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17858 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
17859 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
17860 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
17861 (cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
17862 (cmdline_parse_inst_t *)&cmd_set_raw,
17863 (cmdline_parse_inst_t *)&cmd_show_set_raw,
17864 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
17865 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
17866 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
17867 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
17868 (cmdline_parse_inst_t *)&cmd_show_capability,
17869 (cmdline_parse_inst_t *)&cmd_set_flex_is_pattern,
17870 (cmdline_parse_inst_t *)&cmd_set_flex_spec_pattern,
17874 /* read cmdline commands from file */
17876 cmdline_read_from_file(const char *filename)
17878 struct cmdline *cl;
17880 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17883 "Failed to create file based cmdline context: %s\n",
17888 cmdline_interact(cl);
17893 printf("Read CLI commands from %s\n", filename);
17896 /* prompt function, called from main on MAIN lcore */
17901 /* initialize non-constant commands */
17902 cmd_set_fwd_mode_init();
17903 cmd_set_fwd_retry_mode_init();
17905 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17906 if (testpmd_cl == NULL)
17909 ret = atexit(prompt_exit);
17911 fprintf(stderr, "Cannot set exit function for cmdline\n");
17913 cmdline_interact(testpmd_cl);
17915 cmdline_stdin_exit(testpmd_cl);
17921 if (testpmd_cl != NULL) {
17922 cmdline_quit(testpmd_cl);
17923 cmdline_stdin_exit(testpmd_cl);
17928 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17930 if (id == (portid_t)RTE_PORT_ALL) {
17933 RTE_ETH_FOREACH_DEV(pid) {
17934 /* check if need_reconfig has been set to 1 */
17935 if (ports[pid].need_reconfig == 0)
17936 ports[pid].need_reconfig = dev;
17937 /* check if need_reconfig_queues has been set to 1 */
17938 if (ports[pid].need_reconfig_queues == 0)
17939 ports[pid].need_reconfig_queues = queue;
17941 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17942 /* check if need_reconfig has been set to 1 */
17943 if (ports[id].need_reconfig == 0)
17944 ports[id].need_reconfig = dev;
17945 /* check if need_reconfig_queues has been set to 1 */
17946 if (ports[id].need_reconfig_queues == 0)
17947 ports[id].need_reconfig_queues = queue;