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 port_id (module_eeprom|eeprom)\n"
166 " Display the module EEPROM or EEPROM information for port_id.\n\n"
168 "show port X rss reta (size) (mask0,mask1,...)\n"
169 " Display the rss redirection table entry indicated"
170 " by masks on port X. size is used to indicate the"
171 " hardware supported reta size\n\n"
173 "show port (port_id) rss-hash [key]\n"
174 " Display the RSS hash functions and RSS hash key of port\n\n"
176 "clear port (info|stats|xstats|fdir) (port_id|all)\n"
177 " Clear information for port_id, or all.\n\n"
179 "show (rxq|txq) info (port_id) (queue_id)\n"
180 " Display information for configured RX/TX queue.\n\n"
182 "show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n"
183 " Display the given configuration.\n\n"
185 "read rxd (port_id) (queue_id) (rxd_id)\n"
186 " Display an RX descriptor of a port RX queue.\n\n"
188 "read txd (port_id) (queue_id) (txd_id)\n"
189 " Display a TX descriptor of a port TX queue.\n\n"
191 "ddp get list (port_id)\n"
192 " Get ddp profile info list\n\n"
194 "ddp get info (profile_path)\n"
195 " Get ddp profile information.\n\n"
197 "show vf stats (port_id) (vf_id)\n"
198 " Display a VF's statistics.\n\n"
200 "clear vf stats (port_id) (vf_id)\n"
201 " Reset a VF's statistics.\n\n"
203 "show port (port_id) pctype mapping\n"
204 " Get flow ptype to pctype mapping on a port\n\n"
206 "show port meter stats (port_id) (meter_id) (clear)\n"
207 " Get meter stats on a port\n\n"
209 "show fwd stats all\n"
210 " Display statistics for all fwd engines.\n\n"
212 "clear fwd stats all\n"
213 " Clear statistics for all fwd engines.\n\n"
215 "show port (port_id) rx_offload capabilities\n"
216 " List all per queue and per port Rx offloading"
217 " capabilities of a port\n\n"
219 "show port (port_id) rx_offload configuration\n"
220 " List port level and all queue level"
221 " Rx offloading configuration\n\n"
223 "show port (port_id) tx_offload capabilities\n"
224 " List all per queue and per port"
225 " Tx offloading capabilities of a port\n\n"
227 "show port (port_id) tx_offload configuration\n"
228 " List port level and all queue level"
229 " Tx offloading configuration\n\n"
231 "show port (port_id) tx_metadata\n"
232 " Show Tx metadata value set"
233 " for a specific port\n\n"
235 "show port (port_id) ptypes\n"
236 " Show port supported ptypes"
237 " for a specific port\n\n"
239 "show device info (<identifier>|all)"
240 " Show general information about devices probed.\n\n"
242 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
243 " Show status of rx|tx descriptor.\n\n"
245 "show port (port_id) rxq (queue_id) desc used count\n"
246 " Show current number of filled receive"
247 " packet descriptors.\n\n"
249 "show port (port_id) macs|mcast_macs"
250 " Display list of mac addresses added to port.\n\n"
252 "show port (port_id) fec capabilities"
253 " Show fec capabilities of a port.\n\n"
255 "show port (port_id) fec_mode"
256 " Show fec mode of a port.\n\n"
258 "show port (port_id) flow_ctrl"
259 " Show flow control info of a port.\n\n"
263 if (show_all || !strcmp(res->section, "config")) {
269 "Configuration changes only become active when"
270 " forwarding is started/restarted.\n\n"
273 " Reset forwarding to the default configuration.\n\n"
275 "set verbose (level)\n"
276 " Set the debug verbosity level X.\n\n"
278 "set log global|(type) (level)\n"
279 " Set the log level.\n\n"
282 " Set number of ports.\n\n"
285 " Set number of cores.\n\n"
287 "set coremask (mask)\n"
288 " Set the forwarding cores hexadecimal mask.\n\n"
290 "set portmask (mask)\n"
291 " Set the forwarding ports hexadecimal mask.\n\n"
294 " Set number of packets per burst.\n\n"
296 "set burst tx delay (microseconds) retry (num)\n"
297 " Set the transmit delay time and number of retries,"
298 " effective when retry is enabled.\n\n"
300 "set rxoffs (x[,y]*)\n"
301 " Set the offset of each packet segment on"
302 " receiving if split feature is engaged."
303 " Affects only the queues configured with split"
306 "set rxpkts (x[,y]*)\n"
307 " Set the length of each segment to scatter"
308 " packets on receiving if split feature is engaged."
309 " Affects only the queues configured with split"
312 "set txpkts (x[,y]*)\n"
313 " Set the length of each segment of TXONLY"
314 " and optionally CSUM packets.\n\n"
316 "set txsplit (off|on|rand)\n"
317 " Set the split policy for the TX packets."
318 " Right now only applicable for CSUM and TXONLY"
321 "set txtimes (x, y)\n"
322 " Set the scheduling on timestamps"
323 " timings for the TXONLY mode\n\n"
325 "set corelist (x[,y]*)\n"
326 " Set the list of forwarding cores.\n\n"
328 "set portlist (x[,y]*)\n"
329 " Set the list of forwarding ports.\n\n"
331 "set port setup on (iterator|event)\n"
332 " Select how attached port is retrieved for setup.\n\n"
334 "set tx loopback (port_id) (on|off)\n"
335 " Enable or disable tx loopback.\n\n"
337 "set all queues drop (port_id) (on|off)\n"
338 " Set drop enable bit for all queues.\n\n"
340 "set vf split drop (port_id) (vf_id) (on|off)\n"
341 " Set split drop enable bit for a VF from the PF.\n\n"
343 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
344 " Set MAC antispoof for a VF from the PF.\n\n"
346 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
347 " Enable MACsec offload.\n\n"
349 "set macsec offload (port_id) off\n"
350 " Disable MACsec offload.\n\n"
352 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
353 " Configure MACsec secure connection (SC).\n\n"
355 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
356 " Configure MACsec secure association (SA).\n\n"
358 "set vf broadcast (port_id) (vf_id) (on|off)\n"
359 " Set VF broadcast for a VF from the PF.\n\n"
361 "vlan set stripq (on|off) (port_id,queue_id)\n"
362 " Set the VLAN strip for a queue on a port.\n\n"
364 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
365 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
367 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
368 " Set VLAN insert for a VF from the PF.\n\n"
370 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
371 " Set VLAN antispoof for a VF from the PF.\n\n"
373 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
374 " Set VLAN tag for a VF from the PF.\n\n"
376 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
377 " Set a VF's max bandwidth(Mbps).\n\n"
379 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
380 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
382 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
383 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
385 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
386 " Set some TCs' strict link priority mode on a physical port.\n\n"
388 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
389 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
391 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
392 " Set the VLAN strip or filter or qinq strip or extend\n\n"
394 "vlan set (inner|outer) tpid (value) (port_id)\n"
395 " Set the VLAN TPID for Packet Filtering on"
398 "rx_vlan add (vlan_id|all) (port_id)\n"
399 " Add a vlan_id, or all identifiers, to the set"
400 " of VLAN identifiers filtered by port_id.\n\n"
402 "rx_vlan rm (vlan_id|all) (port_id)\n"
403 " Remove a vlan_id, or all identifiers, from the set"
404 " of VLAN identifiers filtered by port_id.\n\n"
406 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
407 " Add a vlan_id, to the set of VLAN identifiers"
408 "filtered for VF(s) from port_id.\n\n"
410 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
411 " Remove a vlan_id, to the set of VLAN identifiers"
412 "filtered for VF(s) from port_id.\n\n"
414 "rx_vxlan_port add (udp_port) (port_id)\n"
415 " Add an UDP port for VXLAN packet filter on a port\n\n"
417 "rx_vxlan_port rm (udp_port) (port_id)\n"
418 " Remove an UDP port for VXLAN packet filter on a port\n\n"
420 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
421 " Set hardware insertion of VLAN IDs (single or double VLAN "
422 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
424 "tx_vlan set pvid port_id vlan_id (on|off)\n"
425 " Set port based TX VLAN insertion.\n\n"
427 "tx_vlan reset (port_id)\n"
428 " Disable hardware insertion of a VLAN header in"
429 " packets sent on a port.\n\n"
431 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
432 " Select hardware or software calculation of the"
433 " checksum when transmitting a packet using the"
434 " csum forward engine.\n"
435 " ip|udp|tcp|sctp always concern the inner layer.\n"
436 " outer-ip concerns the outer IP layer in"
437 " outer-udp concerns the outer UDP layer in"
438 " case the packet is recognized as a tunnel packet by"
439 " the forward engine (vxlan, gre and ipip are supported)\n"
440 " Please check the NIC datasheet for HW limits.\n\n"
442 "csum parse-tunnel (on|off) (tx_port_id)\n"
443 " If disabled, treat tunnel packets as non-tunneled"
444 " packets (treat inner headers as payload). The port\n"
445 " argument is the port used for TX in csum forward"
448 "csum show (port_id)\n"
449 " Display tx checksum offload configuration\n\n"
451 "tso set (segsize) (portid)\n"
452 " Enable TCP Segmentation Offload in csum forward"
454 " Please check the NIC datasheet for HW limits.\n\n"
457 " Display the status of TCP Segmentation Offload.\n\n"
459 "set port (port_id) gro on|off\n"
460 " Enable or disable Generic Receive Offload in"
461 " csum forwarding engine.\n\n"
463 "show port (port_id) gro\n"
464 " Display GRO configuration.\n\n"
466 "set gro flush (cycles)\n"
467 " Set the cycle to flush GROed packets from"
468 " reassembly tables.\n\n"
470 "set port (port_id) gso (on|off)"
471 " Enable or disable Generic Segmentation Offload in"
472 " csum forwarding engine.\n\n"
474 "set gso segsz (length)\n"
475 " Set max packet length for output GSO segments,"
476 " including packet header and payload.\n\n"
478 "show port (port_id) gso\n"
479 " Show GSO configuration.\n\n"
482 " Set packet forwarding mode.\n\n"
484 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
485 " Add a MAC address on port_id.\n\n"
487 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
488 " Remove a MAC address from port_id.\n\n"
490 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
491 " Set the default MAC address for port_id.\n\n"
493 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
494 " Add a MAC address for a VF on the port.\n\n"
496 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
497 " Set the MAC address for a VF from the PF.\n\n"
499 "set eth-peer (port_id) (peer_addr)\n"
500 " set the peer address for certain port.\n\n"
502 "set port (port_id) uta (mac_address|all) (on|off)\n"
503 " Add/Remove a or all unicast hash filter(s)"
506 "set promisc (port_id|all) (on|off)\n"
507 " Set the promiscuous mode on port_id, or all.\n\n"
509 "set allmulti (port_id|all) (on|off)\n"
510 " Set the allmulti mode on port_id, or all.\n\n"
512 "set vf promisc (port_id) (vf_id) (on|off)\n"
513 " Set unicast promiscuous mode for a VF from the PF.\n\n"
515 "set vf allmulti (port_id) (vf_id) (on|off)\n"
516 " Set multicast promiscuous mode for a VF from the PF.\n\n"
518 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
519 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
520 " (on|off) autoneg (on|off) (port_id)\n"
521 "set flow_ctrl rx (on|off) (portid)\n"
522 "set flow_ctrl tx (on|off) (portid)\n"
523 "set flow_ctrl high_water (high_water) (portid)\n"
524 "set flow_ctrl low_water (low_water) (portid)\n"
525 "set flow_ctrl pause_time (pause_time) (portid)\n"
526 "set flow_ctrl send_xon (send_xon) (portid)\n"
527 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
528 "set flow_ctrl autoneg (on|off) (port_id)\n"
529 " Set the link flow control parameter on a port.\n\n"
531 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
532 " (low_water) (pause_time) (priority) (port_id)\n"
533 " Set the priority flow control parameter on a"
536 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
537 " Set statistics mapping (qmapping 0..15) for RX/TX"
539 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
540 " on port 0 to mapping 5.\n\n"
542 "set xstats-hide-zero on|off\n"
543 " Set the option to hide the zero values"
544 " for xstats display.\n"
546 "set record-core-cycles on|off\n"
547 " Set the option to enable measurement of CPU cycles.\n"
549 "set record-burst-stats on|off\n"
550 " Set the option to enable display of RX and TX bursts.\n"
552 "set port (port_id) vf (vf_id) rx|tx on|off\n"
553 " Enable/Disable a VF receive/tranmit from a port\n\n"
555 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
557 " AUPE:accepts untagged VLAN;"
558 "ROPE:accept unicast hash\n\n"
559 " BAM:accepts broadcast packets;"
560 "MPE:accepts all multicast packets\n\n"
561 " Enable/Disable a VF receive mode of a port\n\n"
563 "set port (port_id) queue (queue_id) rate (rate_num)\n"
564 " Set rate limit for a queue of a port\n\n"
566 "set port (port_id) vf (vf_id) rate (rate_num) "
567 "queue_mask (queue_mask_value)\n"
568 " Set rate limit for queues in VF of a port\n\n"
570 "set flush_rx (on|off)\n"
571 " Flush (default) or don't flush RX streams before"
572 " forwarding. Mainly used with PCAP drivers.\n\n"
574 "set bypass mode (normal|bypass|isolate) (port_id)\n"
575 " Set the bypass mode for the lowest port on bypass enabled"
578 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
579 "mode (normal|bypass|isolate) (port_id)\n"
580 " Set the event required to initiate specified bypass mode for"
581 " the lowest port on a bypass enabled NIC where:\n"
582 " timeout = enable bypass after watchdog timeout.\n"
583 " os_on = enable bypass when OS/board is powered on.\n"
584 " os_off = enable bypass when OS/board is powered off.\n"
585 " power_on = enable bypass when power supply is turned on.\n"
586 " power_off = enable bypass when power supply is turned off."
589 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
590 " Set the bypass watchdog timeout to 'n' seconds"
591 " where 0 = instant.\n\n"
593 "show bypass config (port_id)\n"
594 " Show the bypass configuration for a bypass enabled NIC"
595 " using the lowest port on the NIC.\n\n"
598 "create bonded device (mode) (socket)\n"
599 " Create a new bonded device with specific bonding mode and socket.\n\n"
601 "add bonding slave (slave_id) (port_id)\n"
602 " Add a slave device to a bonded device.\n\n"
604 "remove bonding slave (slave_id) (port_id)\n"
605 " Remove a slave device from a bonded device.\n\n"
607 "set bonding mode (value) (port_id)\n"
608 " Set the bonding mode on a bonded device.\n\n"
610 "set bonding primary (slave_id) (port_id)\n"
611 " Set the primary slave for a bonded device.\n\n"
613 "show bonding config (port_id)\n"
614 " Show the bonding config for port_id.\n\n"
616 "set bonding mac_addr (port_id) (address)\n"
617 " Set the MAC address of a bonded device.\n\n"
619 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
620 " Set Aggregation mode for IEEE802.3AD (mode 4)"
622 "set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
623 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
625 "set bonding mon_period (port_id) (value)\n"
626 " Set the bonding link status monitoring polling period in ms.\n\n"
628 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
629 " Enable/disable dedicated queues for LACP control traffic.\n\n"
632 "set link-up port (port_id)\n"
633 " Set link up for a port.\n\n"
635 "set link-down port (port_id)\n"
636 " Set link down for a port.\n\n"
638 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
639 " Load a profile package on a port\n\n"
641 "ddp del (port_id) (backup_profile_path)\n"
642 " Delete a profile package from a port\n\n"
644 "ptype mapping get (port_id) (valid_only)\n"
645 " Get ptype mapping on a port\n\n"
647 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
648 " Replace target with the pkt_type in ptype mapping\n\n"
650 "ptype mapping reset (port_id)\n"
651 " Reset ptype mapping on a port\n\n"
653 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
654 " Update a ptype mapping item on a port\n\n"
656 "set port (port_id) ptype_mask (ptype_mask)\n"
657 " set packet types classification for a specific port\n\n"
659 "set port (port_id) queue-region region_id (value) "
660 "queue_start_index (value) queue_num (value)\n"
661 " Set a queue region on a port\n\n"
663 "set port (port_id) queue-region region_id (value) "
665 " Set a flowtype region index on a port\n\n"
667 "set port (port_id) queue-region UP (value) region_id (value)\n"
668 " Set the mapping of User Priority to "
669 "queue region on a port\n\n"
671 "set port (port_id) queue-region flush (on|off)\n"
672 " flush all queue region related configuration\n\n"
674 "show port meter cap (port_id)\n"
675 " Show port meter capability information\n\n"
677 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
678 " meter profile add - srtcm rfc 2697\n\n"
680 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
681 " meter profile add - trtcm rfc 2698\n\n"
683 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
684 " meter profile add - trtcm rfc 4115\n\n"
686 "del port meter profile (port_id) (profile_id)\n"
687 " meter profile delete\n\n"
689 "create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
690 "(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
691 "(dscp_tbl_entry63)]\n"
694 "enable port meter (port_id) (mtr_id)\n"
697 "disable port meter (port_id) (mtr_id)\n"
700 "del port meter (port_id) (mtr_id)\n"
703 "add port meter policy (port_id) (policy_id) g_actions (actions)\n"
704 "y_actions (actions) r_actions (actions)\n"
705 " meter policy add\n\n"
707 "del port meter policy (port_id) (policy_id)\n"
708 " meter policy delete\n\n"
710 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
711 " meter update meter profile\n\n"
713 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
714 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
715 " update meter dscp table entries\n\n"
717 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
718 "(action0) [(action1) (action2)]\n"
719 " meter update policer action\n\n"
721 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
722 " meter update stats\n\n"
724 "show port (port_id) queue-region\n"
725 " show all queue region related configuration info\n\n"
727 "set port (port_id) fec_mode auto|off|rs|baser\n"
728 " set fec mode for a specific port\n\n"
730 , list_pkt_forwarding_modes()
734 if (show_all || !strcmp(res->section, "ports")) {
740 "----------------\n\n"
742 "port start (port_id|all)\n"
743 " Start all ports or port_id.\n\n"
745 "port stop (port_id|all)\n"
746 " Stop all ports or port_id.\n\n"
748 "port close (port_id|all)\n"
749 " Close all ports or port_id.\n\n"
751 "port reset (port_id|all)\n"
752 " Reset all ports or port_id.\n\n"
754 "port attach (ident)\n"
755 " Attach physical or virtual dev by pci address or virtual device name\n\n"
757 "port detach (port_id)\n"
758 " Detach physical or virtual dev by port_id\n\n"
760 "port config (port_id|all)"
761 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
762 " duplex (half|full|auto)\n"
763 " Set speed and duplex for all ports or port_id\n\n"
765 "port config (port_id|all) loopback (mode)\n"
766 " Set loopback mode for all ports or port_id\n\n"
768 "port config all (rxq|txq|rxd|txd) (value)\n"
769 " Set number for rxq/txq/rxd/txd.\n\n"
771 "port config all max-pkt-len (value)\n"
772 " Set the max packet length.\n\n"
774 "port config all max-lro-pkt-size (value)\n"
775 " Set the max LRO aggregated packet size.\n\n"
777 "port config all drop-en (on|off)\n"
778 " Enable or disable packet drop on all RX queues of all ports when no "
779 "receive buffers available.\n\n"
781 "port config all rss (all|default|ip|tcp|udp|sctp|"
782 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|none|level-default|"
783 "level-outer|level-inner|<flowtype_id>)\n"
784 " Set the RSS mode.\n\n"
786 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
787 " Set the RSS redirection table.\n\n"
789 "port config (port_id) dcb vt (on|off) (traffic_class)"
791 " Set the DCB mode.\n\n"
793 "port config all burst (value)\n"
794 " Set the number of packets per burst.\n\n"
796 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
798 " Set the ring prefetch/host/writeback threshold"
799 " for tx/rx queue.\n\n"
801 "port config all (txfreet|txrst|rxfreet) (value)\n"
802 " Set free threshold for rx/tx, or set"
803 " tx rs bit threshold.\n\n"
804 "port config mtu X value\n"
805 " Set the MTU of port X to a given value\n\n"
807 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
808 " Set a rx/tx queue's ring size configuration, the new"
809 " value will take effect after command that (re-)start the port"
810 " or command that setup the specific queue\n\n"
812 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
813 " Start/stop a rx/tx queue of port X. Only take effect"
814 " when port X is started\n\n"
816 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
817 " Switch on/off a deferred start of port X rx/tx queue. Only"
818 " take effect when port X is stopped.\n\n"
820 "port (port_id) (rxq|txq) (queue_id) setup\n"
821 " Setup a rx/tx queue of port X.\n\n"
823 "port config (port_id) pctype mapping reset\n"
824 " Reset flow type to pctype mapping on a port\n\n"
826 "port config (port_id) pctype mapping update"
827 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
828 " Update a flow type to pctype mapping item on a port\n\n"
830 "port config (port_id) pctype (pctype_id) hash_inset|"
831 "fdir_inset|fdir_flx_inset get|set|clear field\n"
833 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
835 "port config (port_id) pctype (pctype_id) hash_inset|"
836 "fdir_inset|fdir_flx_inset clear all"
837 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
839 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
840 " Add/remove UDP tunnel port for tunneling offload\n\n"
842 "port config <port_id> rx_offload vlan_strip|"
843 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
844 "outer_ipv4_cksum|macsec_strip|header_split|"
845 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
846 "buffer_split|timestamp|security|keep_crc on|off\n"
847 " Enable or disable a per port Rx offloading"
848 " on all Rx queues of a port\n\n"
850 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
851 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
852 "outer_ipv4_cksum|macsec_strip|header_split|"
853 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
854 "buffer_split|timestamp|security|keep_crc on|off\n"
855 " Enable or disable a per queue Rx offloading"
856 " only on a specific Rx queue\n\n"
858 "port config (port_id) tx_offload vlan_insert|"
859 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
860 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
861 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
862 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
864 " Enable or disable a per port Tx offloading"
865 " on all Tx queues of a port\n\n"
867 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
868 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
869 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
870 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
871 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
873 " Enable or disable a per queue Tx offloading"
874 " only on a specific Tx queue\n\n"
876 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
877 " Load an eBPF program as a callback"
878 " for particular RX/TX queue\n\n"
880 "bpf-unload rx|tx (port) (queue)\n"
881 " Unload previously loaded eBPF program"
882 " for particular RX/TX queue\n\n"
884 "port config (port_id) tx_metadata (value)\n"
885 " Set Tx metadata value per port. Testpmd will add this value"
886 " to any Tx packet sent from this port\n\n"
888 "port config (port_id) dynf (name) set|clear\n"
889 " Register a dynf and Set/clear this flag on Tx. "
890 "Testpmd will set this value to any Tx packet "
891 "sent from this port\n\n"
893 "port cleanup (port_id) txq (queue_id) (free_cnt)\n"
894 " Cleanup txq mbufs for a specific Tx queue\n\n"
898 if (show_all || !strcmp(res->section, "registers")) {
906 "read reg (port_id) (address)\n"
907 " Display value of a port register.\n\n"
909 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
910 " Display a port register bit field.\n\n"
912 "read regbit (port_id) (address) (bit_x)\n"
913 " Display a single port register bit.\n\n"
915 "write reg (port_id) (address) (value)\n"
916 " Set value of a port register.\n\n"
918 "write regfield (port_id) (address) (bit_x) (bit_y)"
920 " Set bit field of a port register.\n\n"
922 "write regbit (port_id) (address) (bit_x) (value)\n"
923 " Set single bit value of a port register.\n\n"
926 if (show_all || !strcmp(res->section, "filters")) {
935 "flow_director_filter (port_id) mode raw (add|del|update)"
936 " flow (flow_id) (drop|fwd) queue (queue_id)"
937 " fd_id (fd_id_value) packet (packet file name)\n"
938 " Add/Del a raw type flow director filter.\n\n"
941 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
942 " src_mask (ipv4_src) (ipv6_src) (src_port)"
943 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
944 " Set flow director IP mask.\n\n"
946 "flow_director_mask (port_id) mode MAC-VLAN"
947 " vlan (vlan_value)\n"
948 " Set flow director MAC-VLAN mask.\n\n"
950 "flow_director_mask (port_id) mode Tunnel"
951 " vlan (vlan_value) mac (mac_value)"
952 " tunnel-type (tunnel_type_value)"
953 " tunnel-id (tunnel_id_value)\n"
954 " Set flow director Tunnel mask.\n\n"
956 "flow_director_flex_payload (port_id)"
957 " (raw|l2|l3|l4) (config)\n"
958 " Configure flex payload selection.\n\n"
960 "flow validate {port_id}"
961 " [group {group_id}] [priority {level}]"
962 " [ingress] [egress]"
963 " pattern {item} [/ {item} [...]] / end"
964 " actions {action} [/ {action} [...]] / end\n"
965 " Check whether a flow rule can be created.\n\n"
967 "flow create {port_id}"
968 " [group {group_id}] [priority {level}]"
969 " [ingress] [egress]"
970 " pattern {item} [/ {item} [...]] / end"
971 " actions {action} [/ {action} [...]] / end\n"
972 " Create a flow rule.\n\n"
974 "flow destroy {port_id} rule {rule_id} [...]\n"
975 " Destroy specific flow rules.\n\n"
977 "flow flush {port_id}\n"
978 " Destroy all flow rules.\n\n"
980 "flow query {port_id} {rule_id} {action}\n"
981 " Query an existing flow rule.\n\n"
983 "flow list {port_id} [group {group_id}] [...]\n"
984 " List existing flow rules sorted by priority,"
985 " filtered by group identifiers.\n\n"
987 "flow isolate {port_id} {boolean}\n"
988 " Restrict ingress traffic to the defined"
991 "flow aged {port_id} [destroy]\n"
992 " List and destroy aged flows"
995 "flow indirect_action {port_id} create"
996 " [action_id {indirect_action_id}]"
997 " [ingress] [egress]"
998 " action {action} / end\n"
999 " Create indirect action.\n\n"
1001 "flow indirect_action {port_id} update"
1002 " {indirect_action_id} action {action} / end\n"
1003 " Update indirect action.\n\n"
1005 "flow indirect_action {port_id} destroy"
1006 " action_id {indirect_action_id} [...]\n"
1007 " Destroy specific indirect actions.\n\n"
1009 "flow indirect_action {port_id} query"
1010 " {indirect_action_id}\n"
1011 " Query an existing indirect action.\n\n"
1013 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1014 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1015 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1016 " Configure the VXLAN encapsulation for flows.\n\n"
1018 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1019 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1020 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1021 " eth-dst (eth-dst)\n"
1022 " Configure the VXLAN encapsulation for flows.\n\n"
1024 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1025 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1026 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1027 " eth-dst (eth-dst)\n"
1028 " Configure the VXLAN encapsulation for flows.\n\n"
1030 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1031 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1033 " Configure the NVGRE encapsulation for flows.\n\n"
1035 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1036 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1037 " eth-src (eth-src) eth-dst (eth-dst)\n"
1038 " Configure the NVGRE encapsulation for flows.\n\n"
1040 "set raw_encap {flow items}\n"
1041 " Configure the encapsulation with raw data.\n\n"
1043 "set raw_decap {flow items}\n"
1044 " Configure the decapsulation with raw data.\n\n"
1049 if (show_all || !strcmp(res->section, "traffic_management")) {
1053 "Traffic Management:\n"
1055 "show port tm cap (port_id)\n"
1056 " Display the port TM capability.\n\n"
1058 "show port tm level cap (port_id) (level_id)\n"
1059 " Display the port TM hierarchical level capability.\n\n"
1061 "show port tm node cap (port_id) (node_id)\n"
1062 " Display the port TM node capability.\n\n"
1064 "show port tm node type (port_id) (node_id)\n"
1065 " Display the port TM node type.\n\n"
1067 "show port tm node stats (port_id) (node_id) (clear)\n"
1068 " Display the port TM node stats.\n\n"
1070 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1071 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1072 " (packet_length_adjust) (packet_mode)\n"
1073 " Add port tm node private shaper profile.\n\n"
1075 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1076 " Delete port tm node private shaper profile.\n\n"
1078 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1079 " (shaper_profile_id)\n"
1080 " Add/update port tm node shared shaper.\n\n"
1082 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1083 " Delete port tm node shared shaper.\n\n"
1085 "set port tm node shaper profile (port_id) (node_id)"
1086 " (shaper_profile_id)\n"
1087 " Set port tm node shaper profile.\n\n"
1089 "add port tm node wred profile (port_id) (wred_profile_id)"
1090 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1091 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1092 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1093 " Add port tm node wred profile.\n\n"
1095 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1096 " Delete port tm node wred profile.\n\n"
1098 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1099 " (priority) (weight) (level_id) (shaper_profile_id)"
1100 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1101 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1102 " Add port tm nonleaf node.\n\n"
1104 "add port tm nonleaf node pktmode (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 with pkt mode enabled.\n\n"
1110 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1111 " (priority) (weight) (level_id) (shaper_profile_id)"
1112 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1113 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1114 " Add port tm leaf node.\n\n"
1116 "del port tm node (port_id) (node_id)\n"
1117 " Delete port tm node.\n\n"
1119 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1120 " (priority) (weight)\n"
1121 " Set port tm node parent.\n\n"
1123 "suspend port tm node (port_id) (node_id)"
1124 " Suspend tm node.\n\n"
1126 "resume port tm node (port_id) (node_id)"
1127 " Resume tm node.\n\n"
1129 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1130 " Commit tm hierarchy.\n\n"
1132 "set port tm mark ip_ecn (port) (green) (yellow)"
1134 " Enables/Disables the traffic management marking"
1135 " for IP ECN (Explicit Congestion Notification)"
1136 " packets on a given port\n\n"
1138 "set port tm mark ip_dscp (port) (green) (yellow)"
1140 " Enables/Disables the traffic management marking"
1141 " on the port for IP dscp packets\n\n"
1143 "set port tm mark vlan_dei (port) (green) (yellow)"
1145 " Enables/Disables the traffic management marking"
1146 " on the port for VLAN packets with DEI enabled\n\n"
1150 if (show_all || !strcmp(res->section, "devices")) {
1154 "Device Operations:\n"
1156 "device detach (identifier)\n"
1157 " Detach device by identifier.\n\n"
1163 cmdline_parse_token_string_t cmd_help_long_help =
1164 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1166 cmdline_parse_token_string_t cmd_help_long_section =
1167 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1168 "all#control#display#config#"
1169 "ports#registers#filters#traffic_management#devices");
1171 cmdline_parse_inst_t cmd_help_long = {
1172 .f = cmd_help_long_parsed,
1174 .help_str = "help all|control|display|config|ports|register|"
1175 "filters|traffic_management|devices: "
1178 (void *)&cmd_help_long_help,
1179 (void *)&cmd_help_long_section,
1185 /* *** start/stop/close all ports *** */
1186 struct cmd_operate_port_result {
1187 cmdline_fixed_string_t keyword;
1188 cmdline_fixed_string_t name;
1189 cmdline_fixed_string_t value;
1192 static void cmd_operate_port_parsed(void *parsed_result,
1193 __rte_unused struct cmdline *cl,
1194 __rte_unused void *data)
1196 struct cmd_operate_port_result *res = parsed_result;
1198 if (!strcmp(res->name, "start"))
1199 start_port(RTE_PORT_ALL);
1200 else if (!strcmp(res->name, "stop"))
1201 stop_port(RTE_PORT_ALL);
1202 else if (!strcmp(res->name, "close"))
1203 close_port(RTE_PORT_ALL);
1204 else if (!strcmp(res->name, "reset"))
1205 reset_port(RTE_PORT_ALL);
1207 fprintf(stderr, "Unknown parameter\n");
1210 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1211 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1213 cmdline_parse_token_string_t cmd_operate_port_all_port =
1214 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1215 "start#stop#close#reset");
1216 cmdline_parse_token_string_t cmd_operate_port_all_all =
1217 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1219 cmdline_parse_inst_t cmd_operate_port = {
1220 .f = cmd_operate_port_parsed,
1222 .help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports",
1224 (void *)&cmd_operate_port_all_cmd,
1225 (void *)&cmd_operate_port_all_port,
1226 (void *)&cmd_operate_port_all_all,
1231 /* *** start/stop/close specific port *** */
1232 struct cmd_operate_specific_port_result {
1233 cmdline_fixed_string_t keyword;
1234 cmdline_fixed_string_t name;
1238 static void cmd_operate_specific_port_parsed(void *parsed_result,
1239 __rte_unused struct cmdline *cl,
1240 __rte_unused void *data)
1242 struct cmd_operate_specific_port_result *res = parsed_result;
1244 if (!strcmp(res->name, "start"))
1245 start_port(res->value);
1246 else if (!strcmp(res->name, "stop"))
1247 stop_port(res->value);
1248 else if (!strcmp(res->name, "close"))
1249 close_port(res->value);
1250 else if (!strcmp(res->name, "reset"))
1251 reset_port(res->value);
1253 fprintf(stderr, "Unknown parameter\n");
1256 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1257 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1259 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1260 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1261 name, "start#stop#close#reset");
1262 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1263 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1266 cmdline_parse_inst_t cmd_operate_specific_port = {
1267 .f = cmd_operate_specific_port_parsed,
1269 .help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id",
1271 (void *)&cmd_operate_specific_port_cmd,
1272 (void *)&cmd_operate_specific_port_port,
1273 (void *)&cmd_operate_specific_port_id,
1278 /* *** enable port setup (after attach) via iterator or event *** */
1279 struct cmd_set_port_setup_on_result {
1280 cmdline_fixed_string_t set;
1281 cmdline_fixed_string_t port;
1282 cmdline_fixed_string_t setup;
1283 cmdline_fixed_string_t on;
1284 cmdline_fixed_string_t mode;
1287 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1288 __rte_unused struct cmdline *cl,
1289 __rte_unused void *data)
1291 struct cmd_set_port_setup_on_result *res = parsed_result;
1293 if (strcmp(res->mode, "event") == 0)
1294 setup_on_probe_event = true;
1295 else if (strcmp(res->mode, "iterator") == 0)
1296 setup_on_probe_event = false;
1298 fprintf(stderr, "Unknown mode\n");
1301 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1302 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1304 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1305 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1307 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1308 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1310 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1311 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1313 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1314 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1315 mode, "iterator#event");
1317 cmdline_parse_inst_t cmd_set_port_setup_on = {
1318 .f = cmd_set_port_setup_on_parsed,
1320 .help_str = "set port setup on iterator|event",
1322 (void *)&cmd_set_port_setup_on_set,
1323 (void *)&cmd_set_port_setup_on_port,
1324 (void *)&cmd_set_port_setup_on_setup,
1325 (void *)&cmd_set_port_setup_on_on,
1326 (void *)&cmd_set_port_setup_on_mode,
1331 /* *** attach a specified port *** */
1332 struct cmd_operate_attach_port_result {
1333 cmdline_fixed_string_t port;
1334 cmdline_fixed_string_t keyword;
1335 cmdline_multi_string_t identifier;
1338 static void cmd_operate_attach_port_parsed(void *parsed_result,
1339 __rte_unused struct cmdline *cl,
1340 __rte_unused void *data)
1342 struct cmd_operate_attach_port_result *res = parsed_result;
1344 if (!strcmp(res->keyword, "attach"))
1345 attach_port(res->identifier);
1347 fprintf(stderr, "Unknown parameter\n");
1350 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1351 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1353 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1354 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1356 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1357 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1358 identifier, TOKEN_STRING_MULTI);
1360 cmdline_parse_inst_t cmd_operate_attach_port = {
1361 .f = cmd_operate_attach_port_parsed,
1363 .help_str = "port attach <identifier>: "
1364 "(identifier: pci address or virtual dev name)",
1366 (void *)&cmd_operate_attach_port_port,
1367 (void *)&cmd_operate_attach_port_keyword,
1368 (void *)&cmd_operate_attach_port_identifier,
1373 /* *** detach a specified port *** */
1374 struct cmd_operate_detach_port_result {
1375 cmdline_fixed_string_t port;
1376 cmdline_fixed_string_t keyword;
1380 static void cmd_operate_detach_port_parsed(void *parsed_result,
1381 __rte_unused struct cmdline *cl,
1382 __rte_unused void *data)
1384 struct cmd_operate_detach_port_result *res = parsed_result;
1386 if (!strcmp(res->keyword, "detach")) {
1387 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1388 detach_port_device(res->port_id);
1390 fprintf(stderr, "Unknown parameter\n");
1394 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1395 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1397 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1398 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1400 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1401 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1402 port_id, RTE_UINT16);
1404 cmdline_parse_inst_t cmd_operate_detach_port = {
1405 .f = cmd_operate_detach_port_parsed,
1407 .help_str = "port detach <port_id>",
1409 (void *)&cmd_operate_detach_port_port,
1410 (void *)&cmd_operate_detach_port_keyword,
1411 (void *)&cmd_operate_detach_port_port_id,
1416 /* *** detach device by identifier *** */
1417 struct cmd_operate_detach_device_result {
1418 cmdline_fixed_string_t device;
1419 cmdline_fixed_string_t keyword;
1420 cmdline_fixed_string_t identifier;
1423 static void cmd_operate_detach_device_parsed(void *parsed_result,
1424 __rte_unused struct cmdline *cl,
1425 __rte_unused void *data)
1427 struct cmd_operate_detach_device_result *res = parsed_result;
1429 if (!strcmp(res->keyword, "detach"))
1430 detach_devargs(res->identifier);
1432 fprintf(stderr, "Unknown parameter\n");
1435 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1436 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1438 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1439 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1441 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1442 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1445 cmdline_parse_inst_t cmd_operate_detach_device = {
1446 .f = cmd_operate_detach_device_parsed,
1448 .help_str = "device detach <identifier>:"
1449 "(identifier: pci address or virtual dev name)",
1451 (void *)&cmd_operate_detach_device_device,
1452 (void *)&cmd_operate_detach_device_keyword,
1453 (void *)&cmd_operate_detach_device_identifier,
1457 /* *** configure speed for all ports *** */
1458 struct cmd_config_speed_all {
1459 cmdline_fixed_string_t port;
1460 cmdline_fixed_string_t keyword;
1461 cmdline_fixed_string_t all;
1462 cmdline_fixed_string_t item1;
1463 cmdline_fixed_string_t item2;
1464 cmdline_fixed_string_t value1;
1465 cmdline_fixed_string_t value2;
1469 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1474 if (!strcmp(duplexstr, "half")) {
1475 duplex = ETH_LINK_HALF_DUPLEX;
1476 } else if (!strcmp(duplexstr, "full")) {
1477 duplex = ETH_LINK_FULL_DUPLEX;
1478 } else if (!strcmp(duplexstr, "auto")) {
1479 duplex = ETH_LINK_FULL_DUPLEX;
1481 fprintf(stderr, "Unknown duplex parameter\n");
1485 if (!strcmp(speedstr, "10")) {
1486 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1487 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1488 } else if (!strcmp(speedstr, "100")) {
1489 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1490 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1492 if (duplex != ETH_LINK_FULL_DUPLEX) {
1493 fprintf(stderr, "Invalid speed/duplex parameters\n");
1496 if (!strcmp(speedstr, "1000")) {
1497 *speed = ETH_LINK_SPEED_1G;
1498 } else if (!strcmp(speedstr, "10000")) {
1499 *speed = ETH_LINK_SPEED_10G;
1500 } else if (!strcmp(speedstr, "25000")) {
1501 *speed = ETH_LINK_SPEED_25G;
1502 } else if (!strcmp(speedstr, "40000")) {
1503 *speed = ETH_LINK_SPEED_40G;
1504 } else if (!strcmp(speedstr, "50000")) {
1505 *speed = ETH_LINK_SPEED_50G;
1506 } else if (!strcmp(speedstr, "100000")) {
1507 *speed = ETH_LINK_SPEED_100G;
1508 } else if (!strcmp(speedstr, "200000")) {
1509 *speed = ETH_LINK_SPEED_200G;
1510 } else if (!strcmp(speedstr, "auto")) {
1511 *speed = ETH_LINK_SPEED_AUTONEG;
1513 fprintf(stderr, "Unknown speed parameter\n");
1518 if (*speed != ETH_LINK_SPEED_AUTONEG)
1519 *speed |= ETH_LINK_SPEED_FIXED;
1525 cmd_config_speed_all_parsed(void *parsed_result,
1526 __rte_unused struct cmdline *cl,
1527 __rte_unused void *data)
1529 struct cmd_config_speed_all *res = parsed_result;
1530 uint32_t link_speed;
1533 if (!all_ports_stopped()) {
1534 fprintf(stderr, "Please stop all ports first\n");
1538 if (parse_and_check_speed_duplex(res->value1, res->value2,
1542 RTE_ETH_FOREACH_DEV(pid) {
1543 ports[pid].dev_conf.link_speeds = link_speed;
1546 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1549 cmdline_parse_token_string_t cmd_config_speed_all_port =
1550 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1551 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1552 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1554 cmdline_parse_token_string_t cmd_config_speed_all_all =
1555 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1556 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1557 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1558 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1559 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1560 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1561 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1562 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1563 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1564 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1567 cmdline_parse_inst_t cmd_config_speed_all = {
1568 .f = cmd_config_speed_all_parsed,
1570 .help_str = "port config all speed "
1571 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1574 (void *)&cmd_config_speed_all_port,
1575 (void *)&cmd_config_speed_all_keyword,
1576 (void *)&cmd_config_speed_all_all,
1577 (void *)&cmd_config_speed_all_item1,
1578 (void *)&cmd_config_speed_all_value1,
1579 (void *)&cmd_config_speed_all_item2,
1580 (void *)&cmd_config_speed_all_value2,
1585 /* *** configure speed for specific port *** */
1586 struct cmd_config_speed_specific {
1587 cmdline_fixed_string_t port;
1588 cmdline_fixed_string_t keyword;
1590 cmdline_fixed_string_t item1;
1591 cmdline_fixed_string_t item2;
1592 cmdline_fixed_string_t value1;
1593 cmdline_fixed_string_t value2;
1597 cmd_config_speed_specific_parsed(void *parsed_result,
1598 __rte_unused struct cmdline *cl,
1599 __rte_unused void *data)
1601 struct cmd_config_speed_specific *res = parsed_result;
1602 uint32_t link_speed;
1604 if (port_id_is_invalid(res->id, ENABLED_WARN))
1607 if (!port_is_stopped(res->id)) {
1608 fprintf(stderr, "Please stop port %d first\n", res->id);
1612 if (parse_and_check_speed_duplex(res->value1, res->value2,
1616 ports[res->id].dev_conf.link_speeds = link_speed;
1618 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1622 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1623 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1625 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1626 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1628 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1629 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1630 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1631 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1633 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1634 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1635 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1636 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1637 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1639 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1640 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1643 cmdline_parse_inst_t cmd_config_speed_specific = {
1644 .f = cmd_config_speed_specific_parsed,
1646 .help_str = "port config <port_id> speed "
1647 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1650 (void *)&cmd_config_speed_specific_port,
1651 (void *)&cmd_config_speed_specific_keyword,
1652 (void *)&cmd_config_speed_specific_id,
1653 (void *)&cmd_config_speed_specific_item1,
1654 (void *)&cmd_config_speed_specific_value1,
1655 (void *)&cmd_config_speed_specific_item2,
1656 (void *)&cmd_config_speed_specific_value2,
1661 /* *** configure loopback for all ports *** */
1662 struct cmd_config_loopback_all {
1663 cmdline_fixed_string_t port;
1664 cmdline_fixed_string_t keyword;
1665 cmdline_fixed_string_t all;
1666 cmdline_fixed_string_t item;
1671 cmd_config_loopback_all_parsed(void *parsed_result,
1672 __rte_unused struct cmdline *cl,
1673 __rte_unused void *data)
1675 struct cmd_config_loopback_all *res = parsed_result;
1678 if (!all_ports_stopped()) {
1679 fprintf(stderr, "Please stop all ports first\n");
1683 RTE_ETH_FOREACH_DEV(pid) {
1684 ports[pid].dev_conf.lpbk_mode = res->mode;
1687 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1690 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1691 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1692 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1693 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1695 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1696 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1697 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1698 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1700 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1701 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1703 cmdline_parse_inst_t cmd_config_loopback_all = {
1704 .f = cmd_config_loopback_all_parsed,
1706 .help_str = "port config all loopback <mode>",
1708 (void *)&cmd_config_loopback_all_port,
1709 (void *)&cmd_config_loopback_all_keyword,
1710 (void *)&cmd_config_loopback_all_all,
1711 (void *)&cmd_config_loopback_all_item,
1712 (void *)&cmd_config_loopback_all_mode,
1717 /* *** configure loopback for specific port *** */
1718 struct cmd_config_loopback_specific {
1719 cmdline_fixed_string_t port;
1720 cmdline_fixed_string_t keyword;
1722 cmdline_fixed_string_t item;
1727 cmd_config_loopback_specific_parsed(void *parsed_result,
1728 __rte_unused struct cmdline *cl,
1729 __rte_unused void *data)
1731 struct cmd_config_loopback_specific *res = parsed_result;
1733 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1736 if (!port_is_stopped(res->port_id)) {
1737 fprintf(stderr, "Please stop port %u first\n", res->port_id);
1741 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1743 cmd_reconfig_device_queue(res->port_id, 1, 1);
1747 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1748 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1750 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1751 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1753 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1754 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1756 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1757 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1759 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1760 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1763 cmdline_parse_inst_t cmd_config_loopback_specific = {
1764 .f = cmd_config_loopback_specific_parsed,
1766 .help_str = "port config <port_id> loopback <mode>",
1768 (void *)&cmd_config_loopback_specific_port,
1769 (void *)&cmd_config_loopback_specific_keyword,
1770 (void *)&cmd_config_loopback_specific_id,
1771 (void *)&cmd_config_loopback_specific_item,
1772 (void *)&cmd_config_loopback_specific_mode,
1777 /* *** configure txq/rxq, txd/rxd *** */
1778 struct cmd_config_rx_tx {
1779 cmdline_fixed_string_t port;
1780 cmdline_fixed_string_t keyword;
1781 cmdline_fixed_string_t all;
1782 cmdline_fixed_string_t name;
1787 cmd_config_rx_tx_parsed(void *parsed_result,
1788 __rte_unused struct cmdline *cl,
1789 __rte_unused void *data)
1791 struct cmd_config_rx_tx *res = parsed_result;
1793 if (!all_ports_stopped()) {
1794 fprintf(stderr, "Please stop all ports first\n");
1797 if (!strcmp(res->name, "rxq")) {
1798 if (!res->value && !nb_txq) {
1799 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1802 if (check_nb_rxq(res->value) != 0)
1804 nb_rxq = res->value;
1806 else if (!strcmp(res->name, "txq")) {
1807 if (!res->value && !nb_rxq) {
1808 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1811 if (check_nb_txq(res->value) != 0)
1813 nb_txq = res->value;
1815 else if (!strcmp(res->name, "rxd")) {
1816 if (check_nb_rxd(res->value) != 0)
1818 nb_rxd = res->value;
1819 } else if (!strcmp(res->name, "txd")) {
1820 if (check_nb_txd(res->value) != 0)
1823 nb_txd = res->value;
1825 fprintf(stderr, "Unknown parameter\n");
1833 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1836 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1837 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1838 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1839 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1840 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1841 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1842 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1843 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1845 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1846 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
1848 cmdline_parse_inst_t cmd_config_rx_tx = {
1849 .f = cmd_config_rx_tx_parsed,
1851 .help_str = "port config all rxq|txq|rxd|txd <value>",
1853 (void *)&cmd_config_rx_tx_port,
1854 (void *)&cmd_config_rx_tx_keyword,
1855 (void *)&cmd_config_rx_tx_all,
1856 (void *)&cmd_config_rx_tx_name,
1857 (void *)&cmd_config_rx_tx_value,
1862 /* *** config max packet length *** */
1863 struct cmd_config_max_pkt_len_result {
1864 cmdline_fixed_string_t port;
1865 cmdline_fixed_string_t keyword;
1866 cmdline_fixed_string_t all;
1867 cmdline_fixed_string_t name;
1872 cmd_config_max_pkt_len_parsed(void *parsed_result,
1873 __rte_unused struct cmdline *cl,
1874 __rte_unused void *data)
1876 struct cmd_config_max_pkt_len_result *res = parsed_result;
1877 uint32_t max_rx_pkt_len_backup = 0;
1881 if (!all_ports_stopped()) {
1882 fprintf(stderr, "Please stop all ports first\n");
1886 RTE_ETH_FOREACH_DEV(pid) {
1887 struct rte_port *port = &ports[pid];
1889 if (!strcmp(res->name, "max-pkt-len")) {
1890 if (res->value < RTE_ETHER_MIN_LEN) {
1892 "max-pkt-len can not be less than %d\n",
1896 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1899 ret = eth_dev_info_get_print_err(pid, &port->dev_info);
1902 "rte_eth_dev_info_get() failed for port %u\n",
1907 max_rx_pkt_len_backup = port->dev_conf.rxmode.max_rx_pkt_len;
1909 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1910 if (update_jumbo_frame_offload(pid) != 0)
1911 port->dev_conf.rxmode.max_rx_pkt_len = max_rx_pkt_len_backup;
1913 fprintf(stderr, "Unknown parameter\n");
1920 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1923 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1924 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1926 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1927 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1929 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1930 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1932 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1933 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1935 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1936 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1939 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1940 .f = cmd_config_max_pkt_len_parsed,
1942 .help_str = "port config all max-pkt-len <value>",
1944 (void *)&cmd_config_max_pkt_len_port,
1945 (void *)&cmd_config_max_pkt_len_keyword,
1946 (void *)&cmd_config_max_pkt_len_all,
1947 (void *)&cmd_config_max_pkt_len_name,
1948 (void *)&cmd_config_max_pkt_len_value,
1953 /* *** config max LRO aggregated packet size *** */
1954 struct cmd_config_max_lro_pkt_size_result {
1955 cmdline_fixed_string_t port;
1956 cmdline_fixed_string_t keyword;
1957 cmdline_fixed_string_t all;
1958 cmdline_fixed_string_t name;
1963 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1964 __rte_unused struct cmdline *cl,
1965 __rte_unused void *data)
1967 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1970 if (!all_ports_stopped()) {
1971 fprintf(stderr, "Please stop all ports first\n");
1975 RTE_ETH_FOREACH_DEV(pid) {
1976 struct rte_port *port = &ports[pid];
1978 if (!strcmp(res->name, "max-lro-pkt-size")) {
1980 port->dev_conf.rxmode.max_lro_pkt_size)
1983 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
1985 fprintf(stderr, "Unknown parameter\n");
1992 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1995 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
1996 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1998 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
1999 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2001 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2002 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2004 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2005 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2006 name, "max-lro-pkt-size");
2007 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2008 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2011 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2012 .f = cmd_config_max_lro_pkt_size_parsed,
2014 .help_str = "port config all max-lro-pkt-size <value>",
2016 (void *)&cmd_config_max_lro_pkt_size_port,
2017 (void *)&cmd_config_max_lro_pkt_size_keyword,
2018 (void *)&cmd_config_max_lro_pkt_size_all,
2019 (void *)&cmd_config_max_lro_pkt_size_name,
2020 (void *)&cmd_config_max_lro_pkt_size_value,
2025 /* *** configure port MTU *** */
2026 struct cmd_config_mtu_result {
2027 cmdline_fixed_string_t port;
2028 cmdline_fixed_string_t keyword;
2029 cmdline_fixed_string_t mtu;
2035 cmd_config_mtu_parsed(void *parsed_result,
2036 __rte_unused struct cmdline *cl,
2037 __rte_unused void *data)
2039 struct cmd_config_mtu_result *res = parsed_result;
2041 if (res->value < RTE_ETHER_MIN_LEN) {
2042 fprintf(stderr, "mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2045 port_mtu_set(res->port_id, res->value);
2048 cmdline_parse_token_string_t cmd_config_mtu_port =
2049 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2051 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2052 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2054 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2055 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2057 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2058 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2060 cmdline_parse_token_num_t cmd_config_mtu_value =
2061 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2064 cmdline_parse_inst_t cmd_config_mtu = {
2065 .f = cmd_config_mtu_parsed,
2067 .help_str = "port config mtu <port_id> <value>",
2069 (void *)&cmd_config_mtu_port,
2070 (void *)&cmd_config_mtu_keyword,
2071 (void *)&cmd_config_mtu_mtu,
2072 (void *)&cmd_config_mtu_port_id,
2073 (void *)&cmd_config_mtu_value,
2078 /* *** configure rx mode *** */
2079 struct cmd_config_rx_mode_flag {
2080 cmdline_fixed_string_t port;
2081 cmdline_fixed_string_t keyword;
2082 cmdline_fixed_string_t all;
2083 cmdline_fixed_string_t name;
2084 cmdline_fixed_string_t value;
2088 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2089 __rte_unused struct cmdline *cl,
2090 __rte_unused void *data)
2092 struct cmd_config_rx_mode_flag *res = parsed_result;
2094 if (!all_ports_stopped()) {
2095 fprintf(stderr, "Please stop all ports first\n");
2099 if (!strcmp(res->name, "drop-en")) {
2100 if (!strcmp(res->value, "on"))
2102 else if (!strcmp(res->value, "off"))
2105 fprintf(stderr, "Unknown parameter\n");
2109 fprintf(stderr, "Unknown parameter\n");
2115 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2118 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2119 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2120 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2121 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2123 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2124 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2125 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2126 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2128 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2129 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2132 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2133 .f = cmd_config_rx_mode_flag_parsed,
2135 .help_str = "port config all drop-en on|off",
2137 (void *)&cmd_config_rx_mode_flag_port,
2138 (void *)&cmd_config_rx_mode_flag_keyword,
2139 (void *)&cmd_config_rx_mode_flag_all,
2140 (void *)&cmd_config_rx_mode_flag_name,
2141 (void *)&cmd_config_rx_mode_flag_value,
2146 /* *** configure rss *** */
2147 struct cmd_config_rss {
2148 cmdline_fixed_string_t port;
2149 cmdline_fixed_string_t keyword;
2150 cmdline_fixed_string_t all;
2151 cmdline_fixed_string_t name;
2152 cmdline_fixed_string_t value;
2156 cmd_config_rss_parsed(void *parsed_result,
2157 __rte_unused struct cmdline *cl,
2158 __rte_unused void *data)
2160 struct cmd_config_rss *res = parsed_result;
2161 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2162 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2163 int use_default = 0;
2164 int all_updated = 1;
2169 if (!strcmp(res->value, "all"))
2170 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2171 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2172 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2173 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU |
2175 else if (!strcmp(res->value, "eth"))
2176 rss_conf.rss_hf = ETH_RSS_ETH;
2177 else if (!strcmp(res->value, "vlan"))
2178 rss_conf.rss_hf = ETH_RSS_VLAN;
2179 else if (!strcmp(res->value, "ip"))
2180 rss_conf.rss_hf = ETH_RSS_IP;
2181 else if (!strcmp(res->value, "udp"))
2182 rss_conf.rss_hf = ETH_RSS_UDP;
2183 else if (!strcmp(res->value, "tcp"))
2184 rss_conf.rss_hf = ETH_RSS_TCP;
2185 else if (!strcmp(res->value, "sctp"))
2186 rss_conf.rss_hf = ETH_RSS_SCTP;
2187 else if (!strcmp(res->value, "ether"))
2188 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2189 else if (!strcmp(res->value, "port"))
2190 rss_conf.rss_hf = ETH_RSS_PORT;
2191 else if (!strcmp(res->value, "vxlan"))
2192 rss_conf.rss_hf = ETH_RSS_VXLAN;
2193 else if (!strcmp(res->value, "geneve"))
2194 rss_conf.rss_hf = ETH_RSS_GENEVE;
2195 else if (!strcmp(res->value, "nvgre"))
2196 rss_conf.rss_hf = ETH_RSS_NVGRE;
2197 else if (!strcmp(res->value, "l3-pre32"))
2198 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2199 else if (!strcmp(res->value, "l3-pre40"))
2200 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2201 else if (!strcmp(res->value, "l3-pre48"))
2202 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2203 else if (!strcmp(res->value, "l3-pre56"))
2204 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2205 else if (!strcmp(res->value, "l3-pre64"))
2206 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2207 else if (!strcmp(res->value, "l3-pre96"))
2208 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2209 else if (!strcmp(res->value, "l3-src-only"))
2210 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2211 else if (!strcmp(res->value, "l3-dst-only"))
2212 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2213 else if (!strcmp(res->value, "l4-src-only"))
2214 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2215 else if (!strcmp(res->value, "l4-dst-only"))
2216 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2217 else if (!strcmp(res->value, "l2-src-only"))
2218 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2219 else if (!strcmp(res->value, "l2-dst-only"))
2220 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2221 else if (!strcmp(res->value, "l2tpv3"))
2222 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2223 else if (!strcmp(res->value, "esp"))
2224 rss_conf.rss_hf = ETH_RSS_ESP;
2225 else if (!strcmp(res->value, "ah"))
2226 rss_conf.rss_hf = ETH_RSS_AH;
2227 else if (!strcmp(res->value, "pfcp"))
2228 rss_conf.rss_hf = ETH_RSS_PFCP;
2229 else if (!strcmp(res->value, "pppoe"))
2230 rss_conf.rss_hf = ETH_RSS_PPPOE;
2231 else if (!strcmp(res->value, "gtpu"))
2232 rss_conf.rss_hf = ETH_RSS_GTPU;
2233 else if (!strcmp(res->value, "ecpri"))
2234 rss_conf.rss_hf = ETH_RSS_ECPRI;
2235 else if (!strcmp(res->value, "mpls"))
2236 rss_conf.rss_hf = ETH_RSS_MPLS;
2237 else if (!strcmp(res->value, "ipv4-chksum"))
2238 rss_conf.rss_hf = ETH_RSS_IPV4_CHKSUM;
2239 else if (!strcmp(res->value, "none"))
2240 rss_conf.rss_hf = 0;
2241 else if (!strcmp(res->value, "level-default")) {
2242 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2243 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2244 } else if (!strcmp(res->value, "level-outer")) {
2245 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2246 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2247 } else if (!strcmp(res->value, "level-inner")) {
2248 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2249 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2250 } else if (!strcmp(res->value, "default"))
2252 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2253 atoi(res->value) < 64)
2254 rss_conf.rss_hf = 1ULL << atoi(res->value);
2256 fprintf(stderr, "Unknown parameter\n");
2259 rss_conf.rss_key = NULL;
2260 /* Update global configuration for RSS types. */
2261 RTE_ETH_FOREACH_DEV(i) {
2262 struct rte_eth_rss_conf local_rss_conf;
2264 ret = eth_dev_info_get_print_err(i, &dev_info);
2269 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2271 local_rss_conf = rss_conf;
2272 local_rss_conf.rss_hf = rss_conf.rss_hf &
2273 dev_info.flow_type_rss_offloads;
2274 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2275 printf("Port %u modified RSS hash function based on hardware support,"
2276 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2277 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2279 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2283 "Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n",
2284 i, -diag, strerror(-diag));
2287 if (all_updated && !use_default) {
2288 rss_hf = rss_conf.rss_hf;
2289 printf("rss_hf %#"PRIx64"\n", rss_hf);
2293 cmdline_parse_token_string_t cmd_config_rss_port =
2294 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2295 cmdline_parse_token_string_t cmd_config_rss_keyword =
2296 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2297 cmdline_parse_token_string_t cmd_config_rss_all =
2298 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2299 cmdline_parse_token_string_t cmd_config_rss_name =
2300 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2301 cmdline_parse_token_string_t cmd_config_rss_value =
2302 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2304 cmdline_parse_inst_t cmd_config_rss = {
2305 .f = cmd_config_rss_parsed,
2307 .help_str = "port config all rss "
2308 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2309 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none|level-default|"
2310 "level-outer|level-inner|ipv4-chksum|<flowtype_id>",
2312 (void *)&cmd_config_rss_port,
2313 (void *)&cmd_config_rss_keyword,
2314 (void *)&cmd_config_rss_all,
2315 (void *)&cmd_config_rss_name,
2316 (void *)&cmd_config_rss_value,
2321 /* *** configure rss hash key *** */
2322 struct cmd_config_rss_hash_key {
2323 cmdline_fixed_string_t port;
2324 cmdline_fixed_string_t config;
2326 cmdline_fixed_string_t rss_hash_key;
2327 cmdline_fixed_string_t rss_type;
2328 cmdline_fixed_string_t key;
2332 hexa_digit_to_value(char hexa_digit)
2334 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2335 return (uint8_t) (hexa_digit - '0');
2336 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2337 return (uint8_t) ((hexa_digit - 'a') + 10);
2338 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2339 return (uint8_t) ((hexa_digit - 'A') + 10);
2340 /* Invalid hexa digit */
2345 parse_and_check_key_hexa_digit(char *key, int idx)
2349 hexa_v = hexa_digit_to_value(key[idx]);
2352 "invalid key: character %c at position %d is not a valid hexa digit\n",
2358 cmd_config_rss_hash_key_parsed(void *parsed_result,
2359 __rte_unused struct cmdline *cl,
2360 __rte_unused void *data)
2362 struct cmd_config_rss_hash_key *res = parsed_result;
2363 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2367 struct rte_eth_dev_info dev_info;
2368 uint8_t hash_key_size;
2372 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2376 if (dev_info.hash_key_size > 0 &&
2377 dev_info.hash_key_size <= sizeof(hash_key))
2378 hash_key_size = dev_info.hash_key_size;
2381 "dev_info did not provide a valid hash key size\n");
2384 /* Check the length of the RSS hash key */
2385 key_len = strlen(res->key);
2386 if (key_len != (hash_key_size * 2)) {
2388 "key length: %d invalid - key must be a string of %d hexa-decimal numbers\n",
2389 (int)key_len, hash_key_size * 2);
2392 /* Translate RSS hash key into binary representation */
2393 for (i = 0; i < hash_key_size; i++) {
2394 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2397 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2400 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2402 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2406 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2407 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2408 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2409 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2411 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2412 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2414 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2415 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2416 rss_hash_key, "rss-hash-key");
2417 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2418 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2419 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2420 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2421 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2422 "ipv6-tcp-ex#ipv6-udp-ex#"
2423 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2424 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2425 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls");
2426 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2427 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2429 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2430 .f = cmd_config_rss_hash_key_parsed,
2432 .help_str = "port config <port_id> rss-hash-key "
2433 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2434 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2435 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2436 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2437 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2438 "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls "
2439 "<string of hex digits (variable length, NIC dependent)>",
2441 (void *)&cmd_config_rss_hash_key_port,
2442 (void *)&cmd_config_rss_hash_key_config,
2443 (void *)&cmd_config_rss_hash_key_port_id,
2444 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2445 (void *)&cmd_config_rss_hash_key_rss_type,
2446 (void *)&cmd_config_rss_hash_key_value,
2451 /* *** cleanup txq mbufs *** */
2452 struct cmd_cleanup_txq_mbufs_result {
2453 cmdline_fixed_string_t port;
2454 cmdline_fixed_string_t keyword;
2455 cmdline_fixed_string_t name;
2462 cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2463 __rte_unused struct cmdline *cl,
2464 __rte_unused void *data)
2466 struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2467 uint16_t port_id = res->port_id;
2468 uint16_t queue_id = res->queue_id;
2469 uint32_t free_cnt = res->free_cnt;
2470 struct rte_eth_txq_info qinfo;
2473 if (test_done == 0) {
2474 fprintf(stderr, "Please stop forwarding first\n");
2478 if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2479 fprintf(stderr, "Failed to get port %u Tx queue %u info\n",
2484 if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2485 fprintf(stderr, "Tx queue %u not started\n", queue_id);
2489 ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2492 "Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n",
2493 port_id, queue_id, strerror(-ret), ret);
2497 printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2498 port_id, queue_id, ret);
2501 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2502 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2504 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2505 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2507 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2508 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2510 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2511 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2513 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2514 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2516 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2517 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2520 cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2521 .f = cmd_cleanup_txq_mbufs_parsed,
2523 .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2525 (void *)&cmd_cleanup_txq_mbufs_port,
2526 (void *)&cmd_cleanup_txq_mbufs_cleanup,
2527 (void *)&cmd_cleanup_txq_mbufs_port_id,
2528 (void *)&cmd_cleanup_txq_mbufs_txq,
2529 (void *)&cmd_cleanup_txq_mbufs_queue_id,
2530 (void *)&cmd_cleanup_txq_mbufs_free_cnt,
2535 /* *** configure port rxq/txq ring size *** */
2536 struct cmd_config_rxtx_ring_size {
2537 cmdline_fixed_string_t port;
2538 cmdline_fixed_string_t config;
2540 cmdline_fixed_string_t rxtxq;
2542 cmdline_fixed_string_t rsize;
2547 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2548 __rte_unused struct cmdline *cl,
2549 __rte_unused void *data)
2551 struct cmd_config_rxtx_ring_size *res = parsed_result;
2552 struct rte_port *port;
2555 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2558 if (res->portid == (portid_t)RTE_PORT_ALL) {
2559 fprintf(stderr, "Invalid port id\n");
2563 port = &ports[res->portid];
2565 if (!strcmp(res->rxtxq, "rxq"))
2567 else if (!strcmp(res->rxtxq, "txq"))
2570 fprintf(stderr, "Unknown parameter\n");
2574 if (isrx && rx_queue_id_is_invalid(res->qid))
2576 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2579 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2581 "Invalid rx ring_size, must > rx_free_thresh: %d\n",
2587 port->nb_rx_desc[res->qid] = res->size;
2589 port->nb_tx_desc[res->qid] = res->size;
2591 cmd_reconfig_device_queue(res->portid, 0, 1);
2594 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2595 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2597 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2598 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2600 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2601 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2602 portid, RTE_UINT16);
2603 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2604 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2606 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2607 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2609 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2610 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2611 rsize, "ring_size");
2612 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2613 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2616 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2617 .f = cmd_config_rxtx_ring_size_parsed,
2619 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2621 (void *)&cmd_config_rxtx_ring_size_port,
2622 (void *)&cmd_config_rxtx_ring_size_config,
2623 (void *)&cmd_config_rxtx_ring_size_portid,
2624 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2625 (void *)&cmd_config_rxtx_ring_size_qid,
2626 (void *)&cmd_config_rxtx_ring_size_rsize,
2627 (void *)&cmd_config_rxtx_ring_size_size,
2632 /* *** configure port rxq/txq start/stop *** */
2633 struct cmd_config_rxtx_queue {
2634 cmdline_fixed_string_t port;
2636 cmdline_fixed_string_t rxtxq;
2638 cmdline_fixed_string_t opname;
2642 cmd_config_rxtx_queue_parsed(void *parsed_result,
2643 __rte_unused struct cmdline *cl,
2644 __rte_unused void *data)
2646 struct cmd_config_rxtx_queue *res = parsed_result;
2651 if (test_done == 0) {
2652 fprintf(stderr, "Please stop forwarding first\n");
2656 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2659 if (port_is_started(res->portid) != 1) {
2660 fprintf(stderr, "Please start port %u first\n", res->portid);
2664 if (!strcmp(res->rxtxq, "rxq"))
2666 else if (!strcmp(res->rxtxq, "txq"))
2669 fprintf(stderr, "Unknown parameter\n");
2673 if (isrx && rx_queue_id_is_invalid(res->qid))
2675 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2678 if (!strcmp(res->opname, "start"))
2680 else if (!strcmp(res->opname, "stop"))
2683 fprintf(stderr, "Unknown parameter\n");
2687 if (isstart && isrx)
2688 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2689 else if (!isstart && isrx)
2690 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2691 else if (isstart && !isrx)
2692 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2694 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2696 if (ret == -ENOTSUP)
2697 fprintf(stderr, "Function not supported in PMD driver\n");
2700 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2701 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2702 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2703 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2704 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2705 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2706 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2707 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2708 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2709 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2712 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2713 .f = cmd_config_rxtx_queue_parsed,
2715 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2717 (void *)&cmd_config_rxtx_queue_port,
2718 (void *)&cmd_config_rxtx_queue_portid,
2719 (void *)&cmd_config_rxtx_queue_rxtxq,
2720 (void *)&cmd_config_rxtx_queue_qid,
2721 (void *)&cmd_config_rxtx_queue_opname,
2726 /* *** configure port rxq/txq deferred start on/off *** */
2727 struct cmd_config_deferred_start_rxtx_queue {
2728 cmdline_fixed_string_t port;
2730 cmdline_fixed_string_t rxtxq;
2732 cmdline_fixed_string_t opname;
2733 cmdline_fixed_string_t state;
2737 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2738 __rte_unused struct cmdline *cl,
2739 __rte_unused void *data)
2741 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2742 struct rte_port *port;
2745 uint8_t needreconfig = 0;
2747 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2750 if (port_is_started(res->port_id) != 0) {
2751 fprintf(stderr, "Please stop port %u first\n", res->port_id);
2755 port = &ports[res->port_id];
2757 isrx = !strcmp(res->rxtxq, "rxq");
2759 if (isrx && rx_queue_id_is_invalid(res->qid))
2761 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2764 ison = !strcmp(res->state, "on");
2766 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2767 port->rx_conf[res->qid].rx_deferred_start = ison;
2769 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2770 port->tx_conf[res->qid].tx_deferred_start = ison;
2775 cmd_reconfig_device_queue(res->port_id, 0, 1);
2778 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2779 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2781 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2782 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2783 port_id, RTE_UINT16);
2784 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2785 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2787 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2788 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2790 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2791 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2792 opname, "deferred_start");
2793 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2794 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2797 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2798 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2800 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2802 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2803 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2804 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2805 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2806 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2807 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2812 /* *** configure port rxq/txq setup *** */
2813 struct cmd_setup_rxtx_queue {
2814 cmdline_fixed_string_t port;
2816 cmdline_fixed_string_t rxtxq;
2818 cmdline_fixed_string_t setup;
2821 /* Common CLI fields for queue setup */
2822 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2823 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2824 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2825 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2826 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2827 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2828 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2829 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2830 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2831 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2834 cmd_setup_rxtx_queue_parsed(
2835 void *parsed_result,
2836 __rte_unused struct cmdline *cl,
2837 __rte_unused void *data)
2839 struct cmd_setup_rxtx_queue *res = parsed_result;
2840 struct rte_port *port;
2841 struct rte_mempool *mp;
2842 unsigned int socket_id;
2846 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2849 if (res->portid == (portid_t)RTE_PORT_ALL) {
2850 fprintf(stderr, "Invalid port id\n");
2854 if (!strcmp(res->rxtxq, "rxq"))
2856 else if (!strcmp(res->rxtxq, "txq"))
2859 fprintf(stderr, "Unknown parameter\n");
2863 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2864 fprintf(stderr, "Invalid rx queue\n");
2866 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2867 fprintf(stderr, "Invalid tx queue\n");
2871 port = &ports[res->portid];
2873 socket_id = rxring_numa[res->portid];
2874 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2875 socket_id = port->socket_id;
2877 mp = mbuf_pool_find(socket_id, 0);
2880 "Failed to setup RX queue: No mempool allocation on the socket %d\n",
2881 rxring_numa[res->portid]);
2884 ret = rx_queue_setup(res->portid,
2886 port->nb_rx_desc[res->qid],
2888 &port->rx_conf[res->qid],
2891 fprintf(stderr, "Failed to setup RX queue\n");
2893 socket_id = txring_numa[res->portid];
2894 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2895 socket_id = port->socket_id;
2897 if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
2899 "Failed to setup TX queue: not enough descriptors\n");
2902 ret = rte_eth_tx_queue_setup(res->portid,
2904 port->nb_tx_desc[res->qid],
2906 &port->tx_conf[res->qid]);
2908 fprintf(stderr, "Failed to setup TX queue\n");
2912 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2913 .f = cmd_setup_rxtx_queue_parsed,
2915 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2917 (void *)&cmd_setup_rxtx_queue_port,
2918 (void *)&cmd_setup_rxtx_queue_portid,
2919 (void *)&cmd_setup_rxtx_queue_rxtxq,
2920 (void *)&cmd_setup_rxtx_queue_qid,
2921 (void *)&cmd_setup_rxtx_queue_setup,
2927 /* *** Configure RSS RETA *** */
2928 struct cmd_config_rss_reta {
2929 cmdline_fixed_string_t port;
2930 cmdline_fixed_string_t keyword;
2932 cmdline_fixed_string_t name;
2933 cmdline_fixed_string_t list_name;
2934 cmdline_fixed_string_t list_of_items;
2938 parse_reta_config(const char *str,
2939 struct rte_eth_rss_reta_entry64 *reta_conf,
2940 uint16_t nb_entries)
2944 uint16_t hash_index, idx, shift;
2947 const char *p, *p0 = str;
2954 unsigned long int_fld[_NUM_FLD];
2955 char *str_fld[_NUM_FLD];
2957 while ((p = strchr(p0,'(')) != NULL) {
2959 if((p0 = strchr(p,')')) == NULL)
2963 if(size >= sizeof(s))
2966 snprintf(s, sizeof(s), "%.*s", size, p);
2967 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2969 for (i = 0; i < _NUM_FLD; i++) {
2971 int_fld[i] = strtoul(str_fld[i], &end, 0);
2972 if (errno != 0 || end == str_fld[i] ||
2977 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2978 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2980 if (hash_index >= nb_entries) {
2981 fprintf(stderr, "Invalid RETA hash index=%d\n",
2986 idx = hash_index / RTE_RETA_GROUP_SIZE;
2987 shift = hash_index % RTE_RETA_GROUP_SIZE;
2988 reta_conf[idx].mask |= (1ULL << shift);
2989 reta_conf[idx].reta[shift] = nb_queue;
2996 cmd_set_rss_reta_parsed(void *parsed_result,
2997 __rte_unused struct cmdline *cl,
2998 __rte_unused void *data)
3001 struct rte_eth_dev_info dev_info;
3002 struct rte_eth_rss_reta_entry64 reta_conf[8];
3003 struct cmd_config_rss_reta *res = parsed_result;
3005 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3009 if (dev_info.reta_size == 0) {
3011 "Redirection table size is 0 which is invalid for RSS\n");
3014 printf("The reta size of port %d is %u\n",
3015 res->port_id, dev_info.reta_size);
3016 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
3018 "Currently do not support more than %u entries of redirection table\n",
3019 ETH_RSS_RETA_SIZE_512);
3023 memset(reta_conf, 0, sizeof(reta_conf));
3024 if (!strcmp(res->list_name, "reta")) {
3025 if (parse_reta_config(res->list_of_items, reta_conf,
3026 dev_info.reta_size)) {
3028 "Invalid RSS Redirection Table config entered\n");
3031 ret = rte_eth_dev_rss_reta_update(res->port_id,
3032 reta_conf, dev_info.reta_size);
3035 "Bad redirection table parameter, return code = %d\n",
3040 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3041 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3042 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3043 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3044 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3045 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3046 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3047 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3048 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3049 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3050 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3051 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3053 cmdline_parse_inst_t cmd_config_rss_reta = {
3054 .f = cmd_set_rss_reta_parsed,
3056 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3058 (void *)&cmd_config_rss_reta_port,
3059 (void *)&cmd_config_rss_reta_keyword,
3060 (void *)&cmd_config_rss_reta_port_id,
3061 (void *)&cmd_config_rss_reta_name,
3062 (void *)&cmd_config_rss_reta_list_name,
3063 (void *)&cmd_config_rss_reta_list_of_items,
3068 /* *** SHOW PORT RETA INFO *** */
3069 struct cmd_showport_reta {
3070 cmdline_fixed_string_t show;
3071 cmdline_fixed_string_t port;
3073 cmdline_fixed_string_t rss;
3074 cmdline_fixed_string_t reta;
3076 cmdline_fixed_string_t list_of_items;
3080 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3081 uint16_t nb_entries,
3085 const char *p, *p0 = str;
3090 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3091 RTE_RETA_GROUP_SIZE;
3094 p = strchr(p0, '(');
3098 p0 = strchr(p, ')');
3102 if (size >= sizeof(s)) {
3104 "The string size exceeds the internal buffer size\n");
3107 snprintf(s, sizeof(s), "%.*s", size, p);
3108 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3109 if (ret <= 0 || ret != num) {
3111 "The bits of masks do not match the number of reta entries: %u\n",
3115 for (i = 0; i < ret; i++)
3116 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3122 cmd_showport_reta_parsed(void *parsed_result,
3123 __rte_unused struct cmdline *cl,
3124 __rte_unused void *data)
3126 struct cmd_showport_reta *res = parsed_result;
3127 struct rte_eth_rss_reta_entry64 reta_conf[8];
3128 struct rte_eth_dev_info dev_info;
3129 uint16_t max_reta_size;
3132 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3136 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3137 if (res->size == 0 || res->size > max_reta_size) {
3138 fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n",
3139 res->size, max_reta_size);
3143 memset(reta_conf, 0, sizeof(reta_conf));
3144 if (showport_parse_reta_config(reta_conf, res->size,
3145 res->list_of_items) < 0) {
3146 fprintf(stderr, "Invalid string: %s for reta masks\n",
3147 res->list_of_items);
3150 port_rss_reta_info(res->port_id, reta_conf, res->size);
3153 cmdline_parse_token_string_t cmd_showport_reta_show =
3154 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3155 cmdline_parse_token_string_t cmd_showport_reta_port =
3156 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3157 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3158 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3159 cmdline_parse_token_string_t cmd_showport_reta_rss =
3160 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3161 cmdline_parse_token_string_t cmd_showport_reta_reta =
3162 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3163 cmdline_parse_token_num_t cmd_showport_reta_size =
3164 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3165 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3166 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3167 list_of_items, NULL);
3169 cmdline_parse_inst_t cmd_showport_reta = {
3170 .f = cmd_showport_reta_parsed,
3172 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3174 (void *)&cmd_showport_reta_show,
3175 (void *)&cmd_showport_reta_port,
3176 (void *)&cmd_showport_reta_port_id,
3177 (void *)&cmd_showport_reta_rss,
3178 (void *)&cmd_showport_reta_reta,
3179 (void *)&cmd_showport_reta_size,
3180 (void *)&cmd_showport_reta_list_of_items,
3185 /* *** Show RSS hash configuration *** */
3186 struct cmd_showport_rss_hash {
3187 cmdline_fixed_string_t show;
3188 cmdline_fixed_string_t port;
3190 cmdline_fixed_string_t rss_hash;
3191 cmdline_fixed_string_t rss_type;
3192 cmdline_fixed_string_t key; /* optional argument */
3195 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3196 __rte_unused struct cmdline *cl,
3199 struct cmd_showport_rss_hash *res = parsed_result;
3201 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3204 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3205 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3206 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3207 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3208 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3209 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3211 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3212 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3214 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3215 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3217 cmdline_parse_inst_t cmd_showport_rss_hash = {
3218 .f = cmd_showport_rss_hash_parsed,
3220 .help_str = "show port <port_id> rss-hash",
3222 (void *)&cmd_showport_rss_hash_show,
3223 (void *)&cmd_showport_rss_hash_port,
3224 (void *)&cmd_showport_rss_hash_port_id,
3225 (void *)&cmd_showport_rss_hash_rss_hash,
3230 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3231 .f = cmd_showport_rss_hash_parsed,
3233 .help_str = "show port <port_id> rss-hash key",
3235 (void *)&cmd_showport_rss_hash_show,
3236 (void *)&cmd_showport_rss_hash_port,
3237 (void *)&cmd_showport_rss_hash_port_id,
3238 (void *)&cmd_showport_rss_hash_rss_hash,
3239 (void *)&cmd_showport_rss_hash_rss_key,
3244 /* *** Configure DCB *** */
3245 struct cmd_config_dcb {
3246 cmdline_fixed_string_t port;
3247 cmdline_fixed_string_t config;
3249 cmdline_fixed_string_t dcb;
3250 cmdline_fixed_string_t vt;
3251 cmdline_fixed_string_t vt_en;
3253 cmdline_fixed_string_t pfc;
3254 cmdline_fixed_string_t pfc_en;
3258 cmd_config_dcb_parsed(void *parsed_result,
3259 __rte_unused struct cmdline *cl,
3260 __rte_unused void *data)
3262 struct cmd_config_dcb *res = parsed_result;
3263 struct rte_eth_dcb_info dcb_info;
3264 portid_t port_id = res->port_id;
3265 struct rte_port *port;
3269 port = &ports[port_id];
3270 /** Check if the port is not started **/
3271 if (port->port_status != RTE_PORT_STOPPED) {
3272 fprintf(stderr, "Please stop port %d first\n", port_id);
3276 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3278 "The invalid number of traffic class, only 4 or 8 allowed.\n");
3282 if (nb_fwd_lcores < res->num_tcs) {
3284 "nb_cores shouldn't be less than number of TCs.\n");
3288 /* Check whether the port supports the report of DCB info. */
3289 ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3290 if (ret == -ENOTSUP) {
3291 fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n");
3295 if (!strncmp(res->pfc_en, "on", 2))
3300 /* DCB in VT mode */
3301 if (!strncmp(res->vt_en, "on", 2))
3302 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3303 (enum rte_eth_nb_tcs)res->num_tcs,
3306 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3307 (enum rte_eth_nb_tcs)res->num_tcs,
3310 fprintf(stderr, "Cannot initialize network ports.\n");
3316 cmd_reconfig_device_queue(port_id, 1, 1);
3319 cmdline_parse_token_string_t cmd_config_dcb_port =
3320 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3321 cmdline_parse_token_string_t cmd_config_dcb_config =
3322 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3323 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3324 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3325 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3326 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3327 cmdline_parse_token_string_t cmd_config_dcb_vt =
3328 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3329 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3330 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3331 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3332 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3333 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3334 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3335 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3336 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3338 cmdline_parse_inst_t cmd_config_dcb = {
3339 .f = cmd_config_dcb_parsed,
3341 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3343 (void *)&cmd_config_dcb_port,
3344 (void *)&cmd_config_dcb_config,
3345 (void *)&cmd_config_dcb_port_id,
3346 (void *)&cmd_config_dcb_dcb,
3347 (void *)&cmd_config_dcb_vt,
3348 (void *)&cmd_config_dcb_vt_en,
3349 (void *)&cmd_config_dcb_num_tcs,
3350 (void *)&cmd_config_dcb_pfc,
3351 (void *)&cmd_config_dcb_pfc_en,
3356 /* *** configure number of packets per burst *** */
3357 struct cmd_config_burst {
3358 cmdline_fixed_string_t port;
3359 cmdline_fixed_string_t keyword;
3360 cmdline_fixed_string_t all;
3361 cmdline_fixed_string_t name;
3366 cmd_config_burst_parsed(void *parsed_result,
3367 __rte_unused struct cmdline *cl,
3368 __rte_unused void *data)
3370 struct cmd_config_burst *res = parsed_result;
3371 struct rte_eth_dev_info dev_info;
3372 uint16_t rec_nb_pkts;
3375 if (!all_ports_stopped()) {
3376 fprintf(stderr, "Please stop all ports first\n");
3380 if (!strcmp(res->name, "burst")) {
3381 if (res->value == 0) {
3382 /* If user gives a value of zero, query the PMD for
3383 * its recommended Rx burst size. Testpmd uses a single
3384 * size for all ports, so assume all ports are the same
3385 * NIC model and use the values from Port 0.
3387 ret = eth_dev_info_get_print_err(0, &dev_info);
3391 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3393 if (rec_nb_pkts == 0) {
3394 printf("PMD does not recommend a burst size.\n"
3395 "User provided value must be between"
3396 " 1 and %d\n", MAX_PKT_BURST);
3398 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3399 printf("PMD recommended burst size of %d"
3400 " exceeds maximum value of %d\n",
3401 rec_nb_pkts, MAX_PKT_BURST);
3404 printf("Using PMD-provided burst value of %d\n",
3406 nb_pkt_per_burst = rec_nb_pkts;
3407 } else if (res->value > MAX_PKT_BURST) {
3408 fprintf(stderr, "burst must be >= 1 && <= %d\n",
3412 nb_pkt_per_burst = res->value;
3414 fprintf(stderr, "Unknown parameter\n");
3420 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3423 cmdline_parse_token_string_t cmd_config_burst_port =
3424 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3425 cmdline_parse_token_string_t cmd_config_burst_keyword =
3426 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3427 cmdline_parse_token_string_t cmd_config_burst_all =
3428 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3429 cmdline_parse_token_string_t cmd_config_burst_name =
3430 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3431 cmdline_parse_token_num_t cmd_config_burst_value =
3432 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3434 cmdline_parse_inst_t cmd_config_burst = {
3435 .f = cmd_config_burst_parsed,
3437 .help_str = "port config all burst <value>",
3439 (void *)&cmd_config_burst_port,
3440 (void *)&cmd_config_burst_keyword,
3441 (void *)&cmd_config_burst_all,
3442 (void *)&cmd_config_burst_name,
3443 (void *)&cmd_config_burst_value,
3448 /* *** configure rx/tx queues *** */
3449 struct cmd_config_thresh {
3450 cmdline_fixed_string_t port;
3451 cmdline_fixed_string_t keyword;
3452 cmdline_fixed_string_t all;
3453 cmdline_fixed_string_t name;
3458 cmd_config_thresh_parsed(void *parsed_result,
3459 __rte_unused struct cmdline *cl,
3460 __rte_unused void *data)
3462 struct cmd_config_thresh *res = parsed_result;
3464 if (!all_ports_stopped()) {
3465 fprintf(stderr, "Please stop all ports first\n");
3469 if (!strcmp(res->name, "txpt"))
3470 tx_pthresh = res->value;
3471 else if(!strcmp(res->name, "txht"))
3472 tx_hthresh = res->value;
3473 else if(!strcmp(res->name, "txwt"))
3474 tx_wthresh = res->value;
3475 else if(!strcmp(res->name, "rxpt"))
3476 rx_pthresh = res->value;
3477 else if(!strcmp(res->name, "rxht"))
3478 rx_hthresh = res->value;
3479 else if(!strcmp(res->name, "rxwt"))
3480 rx_wthresh = res->value;
3482 fprintf(stderr, "Unknown parameter\n");
3488 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3491 cmdline_parse_token_string_t cmd_config_thresh_port =
3492 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3493 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3494 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3495 cmdline_parse_token_string_t cmd_config_thresh_all =
3496 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3497 cmdline_parse_token_string_t cmd_config_thresh_name =
3498 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3499 "txpt#txht#txwt#rxpt#rxht#rxwt");
3500 cmdline_parse_token_num_t cmd_config_thresh_value =
3501 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3503 cmdline_parse_inst_t cmd_config_thresh = {
3504 .f = cmd_config_thresh_parsed,
3506 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3508 (void *)&cmd_config_thresh_port,
3509 (void *)&cmd_config_thresh_keyword,
3510 (void *)&cmd_config_thresh_all,
3511 (void *)&cmd_config_thresh_name,
3512 (void *)&cmd_config_thresh_value,
3517 /* *** configure free/rs threshold *** */
3518 struct cmd_config_threshold {
3519 cmdline_fixed_string_t port;
3520 cmdline_fixed_string_t keyword;
3521 cmdline_fixed_string_t all;
3522 cmdline_fixed_string_t name;
3527 cmd_config_threshold_parsed(void *parsed_result,
3528 __rte_unused struct cmdline *cl,
3529 __rte_unused void *data)
3531 struct cmd_config_threshold *res = parsed_result;
3533 if (!all_ports_stopped()) {
3534 fprintf(stderr, "Please stop all ports first\n");
3538 if (!strcmp(res->name, "txfreet"))
3539 tx_free_thresh = res->value;
3540 else if (!strcmp(res->name, "txrst"))
3541 tx_rs_thresh = res->value;
3542 else if (!strcmp(res->name, "rxfreet"))
3543 rx_free_thresh = res->value;
3545 fprintf(stderr, "Unknown parameter\n");
3551 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3554 cmdline_parse_token_string_t cmd_config_threshold_port =
3555 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3556 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3557 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3559 cmdline_parse_token_string_t cmd_config_threshold_all =
3560 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3561 cmdline_parse_token_string_t cmd_config_threshold_name =
3562 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3563 "txfreet#txrst#rxfreet");
3564 cmdline_parse_token_num_t cmd_config_threshold_value =
3565 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3567 cmdline_parse_inst_t cmd_config_threshold = {
3568 .f = cmd_config_threshold_parsed,
3570 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3572 (void *)&cmd_config_threshold_port,
3573 (void *)&cmd_config_threshold_keyword,
3574 (void *)&cmd_config_threshold_all,
3575 (void *)&cmd_config_threshold_name,
3576 (void *)&cmd_config_threshold_value,
3582 struct cmd_stop_result {
3583 cmdline_fixed_string_t stop;
3586 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3587 __rte_unused struct cmdline *cl,
3588 __rte_unused void *data)
3590 stop_packet_forwarding();
3593 cmdline_parse_token_string_t cmd_stop_stop =
3594 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3596 cmdline_parse_inst_t cmd_stop = {
3597 .f = cmd_stop_parsed,
3599 .help_str = "stop: Stop packet forwarding",
3601 (void *)&cmd_stop_stop,
3606 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3609 parse_item_list(const char *str, const char *item_name, unsigned int max_items,
3610 unsigned int *parsed_items, int check_unique_values)
3612 unsigned int nb_item;
3620 * First parse all items in the list and store their value.
3625 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3627 if ((c >= '0') && (c <= '9')) {
3628 value = (unsigned int) (value * 10 + (c - '0'));
3633 fprintf(stderr, "character %c is not a decimal digit\n", c);
3637 fprintf(stderr, "No valid value before comma\n");
3640 if (nb_item < max_items) {
3641 parsed_items[nb_item] = value;
3647 if (nb_item >= max_items) {
3648 fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
3649 item_name, nb_item + 1, max_items);
3652 parsed_items[nb_item++] = value;
3653 if (! check_unique_values)
3657 * Then, check that all values in the list are differents.
3658 * No optimization here...
3660 for (i = 0; i < nb_item; i++) {
3661 for (j = i + 1; j < nb_item; j++) {
3662 if (parsed_items[j] == parsed_items[i]) {
3664 "duplicated %s %u at index %u and %u\n",
3665 item_name, parsed_items[i], i, j);
3673 struct cmd_set_list_result {
3674 cmdline_fixed_string_t cmd_keyword;
3675 cmdline_fixed_string_t list_name;
3676 cmdline_fixed_string_t list_of_items;
3679 static void cmd_set_list_parsed(void *parsed_result,
3680 __rte_unused struct cmdline *cl,
3681 __rte_unused void *data)
3683 struct cmd_set_list_result *res;
3685 unsigned int lcorelist[RTE_MAX_LCORE];
3686 unsigned int portlist[RTE_MAX_ETHPORTS];
3688 unsigned int nb_item;
3690 if (test_done == 0) {
3691 fprintf(stderr, "Please stop forwarding first\n");
3695 res = parsed_result;
3696 if (!strcmp(res->list_name, "corelist")) {
3697 nb_item = parse_item_list(res->list_of_items, "core",
3699 parsed_items.lcorelist, 1);
3701 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3706 if (!strcmp(res->list_name, "portlist")) {
3707 nb_item = parse_item_list(res->list_of_items, "port",
3709 parsed_items.portlist, 1);
3711 set_fwd_ports_list(parsed_items.portlist, nb_item);
3717 cmdline_parse_token_string_t cmd_set_list_keyword =
3718 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3720 cmdline_parse_token_string_t cmd_set_list_name =
3721 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3722 "corelist#portlist");
3723 cmdline_parse_token_string_t cmd_set_list_of_items =
3724 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3727 cmdline_parse_inst_t cmd_set_fwd_list = {
3728 .f = cmd_set_list_parsed,
3730 .help_str = "set corelist|portlist <list0[,list1]*>",
3732 (void *)&cmd_set_list_keyword,
3733 (void *)&cmd_set_list_name,
3734 (void *)&cmd_set_list_of_items,
3739 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3741 struct cmd_setmask_result {
3742 cmdline_fixed_string_t set;
3743 cmdline_fixed_string_t mask;
3747 static void cmd_set_mask_parsed(void *parsed_result,
3748 __rte_unused struct cmdline *cl,
3749 __rte_unused void *data)
3751 struct cmd_setmask_result *res = parsed_result;
3753 if (test_done == 0) {
3754 fprintf(stderr, "Please stop forwarding first\n");
3757 if (!strcmp(res->mask, "coremask")) {
3758 set_fwd_lcores_mask(res->hexavalue);
3760 } else if (!strcmp(res->mask, "portmask")) {
3761 set_fwd_ports_mask(res->hexavalue);
3766 cmdline_parse_token_string_t cmd_setmask_set =
3767 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3768 cmdline_parse_token_string_t cmd_setmask_mask =
3769 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3770 "coremask#portmask");
3771 cmdline_parse_token_num_t cmd_setmask_value =
3772 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3774 cmdline_parse_inst_t cmd_set_fwd_mask = {
3775 .f = cmd_set_mask_parsed,
3777 .help_str = "set coremask|portmask <hexadecimal value>",
3779 (void *)&cmd_setmask_set,
3780 (void *)&cmd_setmask_mask,
3781 (void *)&cmd_setmask_value,
3787 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3789 struct cmd_set_result {
3790 cmdline_fixed_string_t set;
3791 cmdline_fixed_string_t what;
3795 static void cmd_set_parsed(void *parsed_result,
3796 __rte_unused struct cmdline *cl,
3797 __rte_unused void *data)
3799 struct cmd_set_result *res = parsed_result;
3800 if (!strcmp(res->what, "nbport")) {
3801 set_fwd_ports_number(res->value);
3803 } else if (!strcmp(res->what, "nbcore")) {
3804 set_fwd_lcores_number(res->value);
3806 } else if (!strcmp(res->what, "burst"))
3807 set_nb_pkt_per_burst(res->value);
3808 else if (!strcmp(res->what, "verbose"))
3809 set_verbose_level(res->value);
3812 cmdline_parse_token_string_t cmd_set_set =
3813 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3814 cmdline_parse_token_string_t cmd_set_what =
3815 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3816 "nbport#nbcore#burst#verbose");
3817 cmdline_parse_token_num_t cmd_set_value =
3818 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3820 cmdline_parse_inst_t cmd_set_numbers = {
3821 .f = cmd_set_parsed,
3823 .help_str = "set nbport|nbcore|burst|verbose <value>",
3825 (void *)&cmd_set_set,
3826 (void *)&cmd_set_what,
3827 (void *)&cmd_set_value,
3832 /* *** SET LOG LEVEL CONFIGURATION *** */
3834 struct cmd_set_log_result {
3835 cmdline_fixed_string_t set;
3836 cmdline_fixed_string_t log;
3837 cmdline_fixed_string_t type;
3842 cmd_set_log_parsed(void *parsed_result,
3843 __rte_unused struct cmdline *cl,
3844 __rte_unused void *data)
3846 struct cmd_set_log_result *res;
3849 res = parsed_result;
3850 if (!strcmp(res->type, "global"))
3851 rte_log_set_global_level(res->level);
3853 ret = rte_log_set_level_regexp(res->type, res->level);
3855 fprintf(stderr, "Unable to set log level\n");
3859 cmdline_parse_token_string_t cmd_set_log_set =
3860 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3861 cmdline_parse_token_string_t cmd_set_log_log =
3862 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3863 cmdline_parse_token_string_t cmd_set_log_type =
3864 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3865 cmdline_parse_token_num_t cmd_set_log_level =
3866 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3868 cmdline_parse_inst_t cmd_set_log = {
3869 .f = cmd_set_log_parsed,
3871 .help_str = "set log global|<type> <level>",
3873 (void *)&cmd_set_log_set,
3874 (void *)&cmd_set_log_log,
3875 (void *)&cmd_set_log_type,
3876 (void *)&cmd_set_log_level,
3881 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3883 struct cmd_set_rxoffs_result {
3884 cmdline_fixed_string_t cmd_keyword;
3885 cmdline_fixed_string_t rxoffs;
3886 cmdline_fixed_string_t seg_offsets;
3890 cmd_set_rxoffs_parsed(void *parsed_result,
3891 __rte_unused struct cmdline *cl,
3892 __rte_unused void *data)
3894 struct cmd_set_rxoffs_result *res;
3895 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3896 unsigned int nb_segs;
3898 res = parsed_result;
3899 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3900 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3902 set_rx_pkt_offsets(seg_offsets, nb_segs);
3903 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3906 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3907 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3908 cmd_keyword, "set");
3909 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3910 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3912 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3913 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3916 cmdline_parse_inst_t cmd_set_rxoffs = {
3917 .f = cmd_set_rxoffs_parsed,
3919 .help_str = "set rxoffs <len0[,len1]*>",
3921 (void *)&cmd_set_rxoffs_keyword,
3922 (void *)&cmd_set_rxoffs_name,
3923 (void *)&cmd_set_rxoffs_offsets,
3928 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3930 struct cmd_set_rxpkts_result {
3931 cmdline_fixed_string_t cmd_keyword;
3932 cmdline_fixed_string_t rxpkts;
3933 cmdline_fixed_string_t seg_lengths;
3937 cmd_set_rxpkts_parsed(void *parsed_result,
3938 __rte_unused struct cmdline *cl,
3939 __rte_unused void *data)
3941 struct cmd_set_rxpkts_result *res;
3942 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3943 unsigned int nb_segs;
3945 res = parsed_result;
3946 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3947 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3949 set_rx_pkt_segments(seg_lengths, nb_segs);
3950 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3953 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3954 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3955 cmd_keyword, "set");
3956 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3957 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3959 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3960 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3963 cmdline_parse_inst_t cmd_set_rxpkts = {
3964 .f = cmd_set_rxpkts_parsed,
3966 .help_str = "set rxpkts <len0[,len1]*>",
3968 (void *)&cmd_set_rxpkts_keyword,
3969 (void *)&cmd_set_rxpkts_name,
3970 (void *)&cmd_set_rxpkts_lengths,
3975 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3977 struct cmd_set_txpkts_result {
3978 cmdline_fixed_string_t cmd_keyword;
3979 cmdline_fixed_string_t txpkts;
3980 cmdline_fixed_string_t seg_lengths;
3984 cmd_set_txpkts_parsed(void *parsed_result,
3985 __rte_unused struct cmdline *cl,
3986 __rte_unused void *data)
3988 struct cmd_set_txpkts_result *res;
3989 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3990 unsigned int nb_segs;
3992 res = parsed_result;
3993 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3994 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3996 set_tx_pkt_segments(seg_lengths, nb_segs);
3999 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4000 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4001 cmd_keyword, "set");
4002 cmdline_parse_token_string_t cmd_set_txpkts_name =
4003 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4005 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4006 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4009 cmdline_parse_inst_t cmd_set_txpkts = {
4010 .f = cmd_set_txpkts_parsed,
4012 .help_str = "set txpkts <len0[,len1]*>",
4014 (void *)&cmd_set_txpkts_keyword,
4015 (void *)&cmd_set_txpkts_name,
4016 (void *)&cmd_set_txpkts_lengths,
4021 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4023 struct cmd_set_txsplit_result {
4024 cmdline_fixed_string_t cmd_keyword;
4025 cmdline_fixed_string_t txsplit;
4026 cmdline_fixed_string_t mode;
4030 cmd_set_txsplit_parsed(void *parsed_result,
4031 __rte_unused struct cmdline *cl,
4032 __rte_unused void *data)
4034 struct cmd_set_txsplit_result *res;
4036 res = parsed_result;
4037 set_tx_pkt_split(res->mode);
4040 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4041 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4042 cmd_keyword, "set");
4043 cmdline_parse_token_string_t cmd_set_txsplit_name =
4044 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4045 txsplit, "txsplit");
4046 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4047 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4050 cmdline_parse_inst_t cmd_set_txsplit = {
4051 .f = cmd_set_txsplit_parsed,
4053 .help_str = "set txsplit on|off|rand",
4055 (void *)&cmd_set_txsplit_keyword,
4056 (void *)&cmd_set_txsplit_name,
4057 (void *)&cmd_set_txsplit_mode,
4062 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4064 struct cmd_set_txtimes_result {
4065 cmdline_fixed_string_t cmd_keyword;
4066 cmdline_fixed_string_t txtimes;
4067 cmdline_fixed_string_t tx_times;
4071 cmd_set_txtimes_parsed(void *parsed_result,
4072 __rte_unused struct cmdline *cl,
4073 __rte_unused void *data)
4075 struct cmd_set_txtimes_result *res;
4076 unsigned int tx_times[2] = {0, 0};
4077 unsigned int n_times;
4079 res = parsed_result;
4080 n_times = parse_item_list(res->tx_times, "tx times",
4083 set_tx_pkt_times(tx_times);
4086 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4087 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4088 cmd_keyword, "set");
4089 cmdline_parse_token_string_t cmd_set_txtimes_name =
4090 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4091 txtimes, "txtimes");
4092 cmdline_parse_token_string_t cmd_set_txtimes_value =
4093 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4096 cmdline_parse_inst_t cmd_set_txtimes = {
4097 .f = cmd_set_txtimes_parsed,
4099 .help_str = "set txtimes <inter_burst>,<intra_burst>",
4101 (void *)&cmd_set_txtimes_keyword,
4102 (void *)&cmd_set_txtimes_name,
4103 (void *)&cmd_set_txtimes_value,
4108 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4109 struct cmd_rx_vlan_filter_all_result {
4110 cmdline_fixed_string_t rx_vlan;
4111 cmdline_fixed_string_t what;
4112 cmdline_fixed_string_t all;
4117 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4118 __rte_unused struct cmdline *cl,
4119 __rte_unused void *data)
4121 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4123 if (!strcmp(res->what, "add"))
4124 rx_vlan_all_filter_set(res->port_id, 1);
4126 rx_vlan_all_filter_set(res->port_id, 0);
4129 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4130 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4131 rx_vlan, "rx_vlan");
4132 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4133 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4135 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4136 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4138 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4139 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4140 port_id, RTE_UINT16);
4142 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4143 .f = cmd_rx_vlan_filter_all_parsed,
4145 .help_str = "rx_vlan add|rm all <port_id>: "
4146 "Add/Remove all identifiers to/from the set of VLAN "
4147 "identifiers filtered by a port",
4149 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4150 (void *)&cmd_rx_vlan_filter_all_what,
4151 (void *)&cmd_rx_vlan_filter_all_all,
4152 (void *)&cmd_rx_vlan_filter_all_portid,
4157 /* *** VLAN OFFLOAD SET ON A PORT *** */
4158 struct cmd_vlan_offload_result {
4159 cmdline_fixed_string_t vlan;
4160 cmdline_fixed_string_t set;
4161 cmdline_fixed_string_t vlan_type;
4162 cmdline_fixed_string_t what;
4163 cmdline_fixed_string_t on;
4164 cmdline_fixed_string_t port_id;
4168 cmd_vlan_offload_parsed(void *parsed_result,
4169 __rte_unused struct cmdline *cl,
4170 __rte_unused void *data)
4173 struct cmd_vlan_offload_result *res = parsed_result;
4176 portid_t port_id = 0;
4180 len = strnlen(str, STR_TOKEN_SIZE);
4182 /* Get port_id first */
4190 tmp = strtoul(str, NULL, 0);
4191 /* If port_id greater that what portid_t can represent, return */
4192 if(tmp >= RTE_MAX_ETHPORTS)
4194 port_id = (portid_t)tmp;
4196 if (!strcmp(res->on, "on"))
4201 if (!strcmp(res->what, "strip"))
4202 rx_vlan_strip_set(port_id, on);
4203 else if(!strcmp(res->what, "stripq")){
4204 uint16_t queue_id = 0;
4206 /* No queue_id, return */
4208 fprintf(stderr, "must specify (port,queue_id)\n");
4211 tmp = strtoul(str + i + 1, NULL, 0);
4212 /* If queue_id greater that what 16-bits can represent, return */
4216 queue_id = (uint16_t)tmp;
4217 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4219 else if (!strcmp(res->what, "filter"))
4220 rx_vlan_filter_set(port_id, on);
4221 else if (!strcmp(res->what, "qinq_strip"))
4222 rx_vlan_qinq_strip_set(port_id, on);
4224 vlan_extend_set(port_id, on);
4229 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4230 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4232 cmdline_parse_token_string_t cmd_vlan_offload_set =
4233 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4235 cmdline_parse_token_string_t cmd_vlan_offload_what =
4236 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4237 what, "strip#filter#qinq_strip#extend#stripq");
4238 cmdline_parse_token_string_t cmd_vlan_offload_on =
4239 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4241 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4242 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4245 cmdline_parse_inst_t cmd_vlan_offload = {
4246 .f = cmd_vlan_offload_parsed,
4248 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4249 "<port_id[,queue_id]>: "
4250 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4252 (void *)&cmd_vlan_offload_vlan,
4253 (void *)&cmd_vlan_offload_set,
4254 (void *)&cmd_vlan_offload_what,
4255 (void *)&cmd_vlan_offload_on,
4256 (void *)&cmd_vlan_offload_portid,
4261 /* *** VLAN TPID SET ON A PORT *** */
4262 struct cmd_vlan_tpid_result {
4263 cmdline_fixed_string_t vlan;
4264 cmdline_fixed_string_t set;
4265 cmdline_fixed_string_t vlan_type;
4266 cmdline_fixed_string_t what;
4272 cmd_vlan_tpid_parsed(void *parsed_result,
4273 __rte_unused struct cmdline *cl,
4274 __rte_unused void *data)
4276 struct cmd_vlan_tpid_result *res = parsed_result;
4277 enum rte_vlan_type vlan_type;
4279 if (!strcmp(res->vlan_type, "inner"))
4280 vlan_type = ETH_VLAN_TYPE_INNER;
4281 else if (!strcmp(res->vlan_type, "outer"))
4282 vlan_type = ETH_VLAN_TYPE_OUTER;
4284 fprintf(stderr, "Unknown vlan type\n");
4287 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4290 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4291 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4293 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4294 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4296 cmdline_parse_token_string_t cmd_vlan_type =
4297 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4298 vlan_type, "inner#outer");
4299 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4300 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4302 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4303 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4305 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4306 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4307 port_id, RTE_UINT16);
4309 cmdline_parse_inst_t cmd_vlan_tpid = {
4310 .f = cmd_vlan_tpid_parsed,
4312 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4313 "Set the VLAN Ether type",
4315 (void *)&cmd_vlan_tpid_vlan,
4316 (void *)&cmd_vlan_tpid_set,
4317 (void *)&cmd_vlan_type,
4318 (void *)&cmd_vlan_tpid_what,
4319 (void *)&cmd_vlan_tpid_tpid,
4320 (void *)&cmd_vlan_tpid_portid,
4325 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4326 struct cmd_rx_vlan_filter_result {
4327 cmdline_fixed_string_t rx_vlan;
4328 cmdline_fixed_string_t what;
4334 cmd_rx_vlan_filter_parsed(void *parsed_result,
4335 __rte_unused struct cmdline *cl,
4336 __rte_unused void *data)
4338 struct cmd_rx_vlan_filter_result *res = parsed_result;
4340 if (!strcmp(res->what, "add"))
4341 rx_vft_set(res->port_id, res->vlan_id, 1);
4343 rx_vft_set(res->port_id, res->vlan_id, 0);
4346 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4347 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4348 rx_vlan, "rx_vlan");
4349 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4350 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4352 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4353 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4354 vlan_id, RTE_UINT16);
4355 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4356 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4357 port_id, RTE_UINT16);
4359 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4360 .f = cmd_rx_vlan_filter_parsed,
4362 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4363 "Add/Remove a VLAN identifier to/from the set of VLAN "
4364 "identifiers filtered by a port",
4366 (void *)&cmd_rx_vlan_filter_rx_vlan,
4367 (void *)&cmd_rx_vlan_filter_what,
4368 (void *)&cmd_rx_vlan_filter_vlanid,
4369 (void *)&cmd_rx_vlan_filter_portid,
4374 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4375 struct cmd_tx_vlan_set_result {
4376 cmdline_fixed_string_t tx_vlan;
4377 cmdline_fixed_string_t set;
4383 cmd_tx_vlan_set_parsed(void *parsed_result,
4384 __rte_unused struct cmdline *cl,
4385 __rte_unused void *data)
4387 struct cmd_tx_vlan_set_result *res = parsed_result;
4389 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4392 if (!port_is_stopped(res->port_id)) {
4393 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4397 tx_vlan_set(res->port_id, res->vlan_id);
4399 cmd_reconfig_device_queue(res->port_id, 1, 1);
4402 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4403 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4404 tx_vlan, "tx_vlan");
4405 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4406 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4408 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4409 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4410 port_id, RTE_UINT16);
4411 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4412 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4413 vlan_id, RTE_UINT16);
4415 cmdline_parse_inst_t cmd_tx_vlan_set = {
4416 .f = cmd_tx_vlan_set_parsed,
4418 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4419 "Enable hardware insertion of a single VLAN header "
4420 "with a given TAG Identifier in packets sent on a port",
4422 (void *)&cmd_tx_vlan_set_tx_vlan,
4423 (void *)&cmd_tx_vlan_set_set,
4424 (void *)&cmd_tx_vlan_set_portid,
4425 (void *)&cmd_tx_vlan_set_vlanid,
4430 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4431 struct cmd_tx_vlan_set_qinq_result {
4432 cmdline_fixed_string_t tx_vlan;
4433 cmdline_fixed_string_t set;
4436 uint16_t vlan_id_outer;
4440 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4441 __rte_unused struct cmdline *cl,
4442 __rte_unused void *data)
4444 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4446 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4449 if (!port_is_stopped(res->port_id)) {
4450 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4454 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4456 cmd_reconfig_device_queue(res->port_id, 1, 1);
4459 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4460 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4461 tx_vlan, "tx_vlan");
4462 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4463 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4465 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4466 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4467 port_id, RTE_UINT16);
4468 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4469 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4470 vlan_id, RTE_UINT16);
4471 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4472 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4473 vlan_id_outer, RTE_UINT16);
4475 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4476 .f = cmd_tx_vlan_set_qinq_parsed,
4478 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4479 "Enable hardware insertion of double VLAN header "
4480 "with given TAG Identifiers in packets sent on a port",
4482 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4483 (void *)&cmd_tx_vlan_set_qinq_set,
4484 (void *)&cmd_tx_vlan_set_qinq_portid,
4485 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4486 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4491 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4492 struct cmd_tx_vlan_set_pvid_result {
4493 cmdline_fixed_string_t tx_vlan;
4494 cmdline_fixed_string_t set;
4495 cmdline_fixed_string_t pvid;
4498 cmdline_fixed_string_t mode;
4502 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4503 __rte_unused struct cmdline *cl,
4504 __rte_unused void *data)
4506 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4508 if (strcmp(res->mode, "on") == 0)
4509 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4511 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4514 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4515 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4516 tx_vlan, "tx_vlan");
4517 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4518 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4520 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4521 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4523 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4524 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4525 port_id, RTE_UINT16);
4526 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4527 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4528 vlan_id, RTE_UINT16);
4529 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4530 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4533 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4534 .f = cmd_tx_vlan_set_pvid_parsed,
4536 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4538 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4539 (void *)&cmd_tx_vlan_set_pvid_set,
4540 (void *)&cmd_tx_vlan_set_pvid_pvid,
4541 (void *)&cmd_tx_vlan_set_pvid_port_id,
4542 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4543 (void *)&cmd_tx_vlan_set_pvid_mode,
4548 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4549 struct cmd_tx_vlan_reset_result {
4550 cmdline_fixed_string_t tx_vlan;
4551 cmdline_fixed_string_t reset;
4556 cmd_tx_vlan_reset_parsed(void *parsed_result,
4557 __rte_unused struct cmdline *cl,
4558 __rte_unused void *data)
4560 struct cmd_tx_vlan_reset_result *res = parsed_result;
4562 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4565 if (!port_is_stopped(res->port_id)) {
4566 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4570 tx_vlan_reset(res->port_id);
4572 cmd_reconfig_device_queue(res->port_id, 1, 1);
4575 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4576 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4577 tx_vlan, "tx_vlan");
4578 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4579 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4581 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4582 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4583 port_id, RTE_UINT16);
4585 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4586 .f = cmd_tx_vlan_reset_parsed,
4588 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4589 "VLAN header in packets sent on a port",
4591 (void *)&cmd_tx_vlan_reset_tx_vlan,
4592 (void *)&cmd_tx_vlan_reset_reset,
4593 (void *)&cmd_tx_vlan_reset_portid,
4599 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4600 struct cmd_csum_result {
4601 cmdline_fixed_string_t csum;
4602 cmdline_fixed_string_t mode;
4603 cmdline_fixed_string_t proto;
4604 cmdline_fixed_string_t hwsw;
4609 csum_show(int port_id)
4611 struct rte_eth_dev_info dev_info;
4612 uint64_t tx_offloads;
4615 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4616 printf("Parse tunnel is %s\n",
4617 (ports[port_id].parse_tunnel) ? "on" : "off");
4618 printf("IP checksum offload is %s\n",
4619 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4620 printf("UDP checksum offload is %s\n",
4621 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4622 printf("TCP checksum offload is %s\n",
4623 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4624 printf("SCTP checksum offload is %s\n",
4625 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4626 printf("Outer-Ip checksum offload is %s\n",
4627 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4628 printf("Outer-Udp checksum offload is %s\n",
4629 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4631 /* display warnings if configuration is not supported by the NIC */
4632 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4636 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4637 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4639 "Warning: hardware IP checksum enabled but not supported by port %d\n",
4642 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4643 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4645 "Warning: hardware UDP checksum enabled but not supported by port %d\n",
4648 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4649 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4651 "Warning: hardware TCP checksum enabled but not supported by port %d\n",
4654 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4655 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4657 "Warning: hardware SCTP checksum enabled but not supported by port %d\n",
4660 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4661 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4663 "Warning: hardware outer IP checksum enabled but not supported by port %d\n",
4666 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4667 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4670 "Warning: hardware outer UDP checksum enabled but not supported by port %d\n",
4676 cmd_config_queue_tx_offloads(struct rte_port *port)
4680 /* Apply queue tx offloads configuration */
4681 for (k = 0; k < port->dev_info.max_tx_queues; k++)
4682 port->tx_conf[k].offloads =
4683 port->dev_conf.txmode.offloads;
4687 cmd_csum_parsed(void *parsed_result,
4688 __rte_unused struct cmdline *cl,
4689 __rte_unused void *data)
4691 struct cmd_csum_result *res = parsed_result;
4693 uint64_t csum_offloads = 0;
4694 struct rte_eth_dev_info dev_info;
4697 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4698 fprintf(stderr, "invalid port %d\n", res->port_id);
4701 if (!port_is_stopped(res->port_id)) {
4702 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4706 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4710 if (!strcmp(res->mode, "set")) {
4712 if (!strcmp(res->hwsw, "hw"))
4715 if (!strcmp(res->proto, "ip")) {
4716 if (hw == 0 || (dev_info.tx_offload_capa &
4717 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4718 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4721 "IP checksum offload is not supported by port %u\n",
4724 } else if (!strcmp(res->proto, "udp")) {
4725 if (hw == 0 || (dev_info.tx_offload_capa &
4726 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4727 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4730 "UDP checksum offload is not supported by port %u\n",
4733 } else if (!strcmp(res->proto, "tcp")) {
4734 if (hw == 0 || (dev_info.tx_offload_capa &
4735 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4736 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4739 "TCP checksum offload is not supported by port %u\n",
4742 } else if (!strcmp(res->proto, "sctp")) {
4743 if (hw == 0 || (dev_info.tx_offload_capa &
4744 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4745 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4748 "SCTP checksum offload is not supported by port %u\n",
4751 } else if (!strcmp(res->proto, "outer-ip")) {
4752 if (hw == 0 || (dev_info.tx_offload_capa &
4753 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4755 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4758 "Outer IP checksum offload is not supported by port %u\n",
4761 } else if (!strcmp(res->proto, "outer-udp")) {
4762 if (hw == 0 || (dev_info.tx_offload_capa &
4763 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4765 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4768 "Outer UDP checksum offload is not supported by port %u\n",
4774 ports[res->port_id].dev_conf.txmode.offloads |=
4777 ports[res->port_id].dev_conf.txmode.offloads &=
4780 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4782 csum_show(res->port_id);
4784 cmd_reconfig_device_queue(res->port_id, 1, 1);
4787 cmdline_parse_token_string_t cmd_csum_csum =
4788 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4790 cmdline_parse_token_string_t cmd_csum_mode =
4791 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4793 cmdline_parse_token_string_t cmd_csum_proto =
4794 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4795 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4796 cmdline_parse_token_string_t cmd_csum_hwsw =
4797 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4799 cmdline_parse_token_num_t cmd_csum_portid =
4800 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4801 port_id, RTE_UINT16);
4803 cmdline_parse_inst_t cmd_csum_set = {
4804 .f = cmd_csum_parsed,
4806 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4807 "Enable/Disable hardware calculation of L3/L4 checksum when "
4808 "using csum forward engine",
4810 (void *)&cmd_csum_csum,
4811 (void *)&cmd_csum_mode,
4812 (void *)&cmd_csum_proto,
4813 (void *)&cmd_csum_hwsw,
4814 (void *)&cmd_csum_portid,
4819 cmdline_parse_token_string_t cmd_csum_mode_show =
4820 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4823 cmdline_parse_inst_t cmd_csum_show = {
4824 .f = cmd_csum_parsed,
4826 .help_str = "csum show <port_id>: Show checksum offload configuration",
4828 (void *)&cmd_csum_csum,
4829 (void *)&cmd_csum_mode_show,
4830 (void *)&cmd_csum_portid,
4835 /* Enable/disable tunnel parsing */
4836 struct cmd_csum_tunnel_result {
4837 cmdline_fixed_string_t csum;
4838 cmdline_fixed_string_t parse;
4839 cmdline_fixed_string_t onoff;
4844 cmd_csum_tunnel_parsed(void *parsed_result,
4845 __rte_unused struct cmdline *cl,
4846 __rte_unused void *data)
4848 struct cmd_csum_tunnel_result *res = parsed_result;
4850 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4853 if (!strcmp(res->onoff, "on"))
4854 ports[res->port_id].parse_tunnel = 1;
4856 ports[res->port_id].parse_tunnel = 0;
4858 csum_show(res->port_id);
4861 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4862 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4864 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4865 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4866 parse, "parse-tunnel");
4867 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4868 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4870 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4871 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4872 port_id, RTE_UINT16);
4874 cmdline_parse_inst_t cmd_csum_tunnel = {
4875 .f = cmd_csum_tunnel_parsed,
4877 .help_str = "csum parse-tunnel on|off <port_id>: "
4878 "Enable/Disable parsing of tunnels for csum engine",
4880 (void *)&cmd_csum_tunnel_csum,
4881 (void *)&cmd_csum_tunnel_parse,
4882 (void *)&cmd_csum_tunnel_onoff,
4883 (void *)&cmd_csum_tunnel_portid,
4888 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4889 struct cmd_tso_set_result {
4890 cmdline_fixed_string_t tso;
4891 cmdline_fixed_string_t mode;
4897 cmd_tso_set_parsed(void *parsed_result,
4898 __rte_unused struct cmdline *cl,
4899 __rte_unused void *data)
4901 struct cmd_tso_set_result *res = parsed_result;
4902 struct rte_eth_dev_info dev_info;
4905 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4907 if (!port_is_stopped(res->port_id)) {
4908 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4912 if (!strcmp(res->mode, "set"))
4913 ports[res->port_id].tso_segsz = res->tso_segsz;
4915 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4919 if ((ports[res->port_id].tso_segsz != 0) &&
4920 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4921 fprintf(stderr, "Error: TSO is not supported by port %d\n",
4926 if (ports[res->port_id].tso_segsz == 0) {
4927 ports[res->port_id].dev_conf.txmode.offloads &=
4928 ~DEV_TX_OFFLOAD_TCP_TSO;
4929 printf("TSO for non-tunneled packets is disabled\n");
4931 ports[res->port_id].dev_conf.txmode.offloads |=
4932 DEV_TX_OFFLOAD_TCP_TSO;
4933 printf("TSO segment size for non-tunneled packets is %d\n",
4934 ports[res->port_id].tso_segsz);
4936 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4938 /* display warnings if configuration is not supported by the NIC */
4939 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4943 if ((ports[res->port_id].tso_segsz != 0) &&
4944 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4946 "Warning: TSO enabled but not supported by port %d\n",
4950 cmd_reconfig_device_queue(res->port_id, 1, 1);
4953 cmdline_parse_token_string_t cmd_tso_set_tso =
4954 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4956 cmdline_parse_token_string_t cmd_tso_set_mode =
4957 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4959 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4960 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4961 tso_segsz, RTE_UINT16);
4962 cmdline_parse_token_num_t cmd_tso_set_portid =
4963 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4964 port_id, RTE_UINT16);
4966 cmdline_parse_inst_t cmd_tso_set = {
4967 .f = cmd_tso_set_parsed,
4969 .help_str = "tso set <tso_segsz> <port_id>: "
4970 "Set TSO segment size of non-tunneled packets for csum engine "
4973 (void *)&cmd_tso_set_tso,
4974 (void *)&cmd_tso_set_mode,
4975 (void *)&cmd_tso_set_tso_segsz,
4976 (void *)&cmd_tso_set_portid,
4981 cmdline_parse_token_string_t cmd_tso_show_mode =
4982 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4986 cmdline_parse_inst_t cmd_tso_show = {
4987 .f = cmd_tso_set_parsed,
4989 .help_str = "tso show <port_id>: "
4990 "Show TSO segment size of non-tunneled packets for csum engine",
4992 (void *)&cmd_tso_set_tso,
4993 (void *)&cmd_tso_show_mode,
4994 (void *)&cmd_tso_set_portid,
4999 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5000 struct cmd_tunnel_tso_set_result {
5001 cmdline_fixed_string_t tso;
5002 cmdline_fixed_string_t mode;
5007 static struct rte_eth_dev_info
5008 check_tunnel_tso_nic_support(portid_t port_id)
5010 struct rte_eth_dev_info dev_info;
5012 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
5015 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
5017 "Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n",
5019 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
5021 "Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n",
5023 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
5025 "Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n",
5027 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
5029 "Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n",
5031 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
5033 "Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n",
5035 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
5037 "Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n",
5043 cmd_tunnel_tso_set_parsed(void *parsed_result,
5044 __rte_unused struct cmdline *cl,
5045 __rte_unused void *data)
5047 struct cmd_tunnel_tso_set_result *res = parsed_result;
5048 struct rte_eth_dev_info dev_info;
5050 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5052 if (!port_is_stopped(res->port_id)) {
5053 fprintf(stderr, "Please stop port %d first\n", res->port_id);
5057 if (!strcmp(res->mode, "set"))
5058 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5060 dev_info = check_tunnel_tso_nic_support(res->port_id);
5061 if (ports[res->port_id].tunnel_tso_segsz == 0) {
5062 ports[res->port_id].dev_conf.txmode.offloads &=
5063 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5064 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5065 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5066 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5067 DEV_TX_OFFLOAD_IP_TNL_TSO |
5068 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5069 printf("TSO for tunneled packets is disabled\n");
5071 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5072 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5073 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5074 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5075 DEV_TX_OFFLOAD_IP_TNL_TSO |
5076 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5078 ports[res->port_id].dev_conf.txmode.offloads |=
5079 (tso_offloads & dev_info.tx_offload_capa);
5080 printf("TSO segment size for tunneled packets is %d\n",
5081 ports[res->port_id].tunnel_tso_segsz);
5083 /* Below conditions are needed to make it work:
5084 * (1) tunnel TSO is supported by the NIC;
5085 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5087 * (3) for tunneled pkts with outer L3 of IPv4,
5088 * "csum set outer-ip" must be set to hw, because after tso,
5089 * total_len of outer IP header is changed, and the checksum
5090 * of outer IP header calculated by sw should be wrong; that
5091 * is not necessary for IPv6 tunneled pkts because there's no
5092 * checksum in IP header anymore.
5095 if (!ports[res->port_id].parse_tunnel)
5097 "Warning: csum parse_tunnel must be set so that tunneled packets are recognized\n");
5098 if (!(ports[res->port_id].dev_conf.txmode.offloads &
5099 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5101 "Warning: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n");
5104 cmd_config_queue_tx_offloads(&ports[res->port_id]);
5105 cmd_reconfig_device_queue(res->port_id, 1, 1);
5108 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5109 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5111 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5112 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5114 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5115 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5116 tso_segsz, RTE_UINT16);
5117 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5118 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5119 port_id, RTE_UINT16);
5121 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5122 .f = cmd_tunnel_tso_set_parsed,
5124 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5125 "Set TSO segment size of tunneled packets for csum engine "
5128 (void *)&cmd_tunnel_tso_set_tso,
5129 (void *)&cmd_tunnel_tso_set_mode,
5130 (void *)&cmd_tunnel_tso_set_tso_segsz,
5131 (void *)&cmd_tunnel_tso_set_portid,
5136 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5137 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5141 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5142 .f = cmd_tunnel_tso_set_parsed,
5144 .help_str = "tunnel_tso show <port_id> "
5145 "Show TSO segment size of tunneled packets for csum engine",
5147 (void *)&cmd_tunnel_tso_set_tso,
5148 (void *)&cmd_tunnel_tso_show_mode,
5149 (void *)&cmd_tunnel_tso_set_portid,
5154 /* *** SET GRO FOR A PORT *** */
5155 struct cmd_gro_enable_result {
5156 cmdline_fixed_string_t cmd_set;
5157 cmdline_fixed_string_t cmd_port;
5158 cmdline_fixed_string_t cmd_keyword;
5159 cmdline_fixed_string_t cmd_onoff;
5164 cmd_gro_enable_parsed(void *parsed_result,
5165 __rte_unused struct cmdline *cl,
5166 __rte_unused void *data)
5168 struct cmd_gro_enable_result *res;
5170 res = parsed_result;
5171 if (!strcmp(res->cmd_keyword, "gro"))
5172 setup_gro(res->cmd_onoff, res->cmd_pid);
5175 cmdline_parse_token_string_t cmd_gro_enable_set =
5176 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5178 cmdline_parse_token_string_t cmd_gro_enable_port =
5179 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5180 cmd_keyword, "port");
5181 cmdline_parse_token_num_t cmd_gro_enable_pid =
5182 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5183 cmd_pid, RTE_UINT16);
5184 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5185 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5186 cmd_keyword, "gro");
5187 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5188 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5189 cmd_onoff, "on#off");
5191 cmdline_parse_inst_t cmd_gro_enable = {
5192 .f = cmd_gro_enable_parsed,
5194 .help_str = "set port <port_id> gro on|off",
5196 (void *)&cmd_gro_enable_set,
5197 (void *)&cmd_gro_enable_port,
5198 (void *)&cmd_gro_enable_pid,
5199 (void *)&cmd_gro_enable_keyword,
5200 (void *)&cmd_gro_enable_onoff,
5205 /* *** DISPLAY GRO CONFIGURATION *** */
5206 struct cmd_gro_show_result {
5207 cmdline_fixed_string_t cmd_show;
5208 cmdline_fixed_string_t cmd_port;
5209 cmdline_fixed_string_t cmd_keyword;
5214 cmd_gro_show_parsed(void *parsed_result,
5215 __rte_unused struct cmdline *cl,
5216 __rte_unused void *data)
5218 struct cmd_gro_show_result *res;
5220 res = parsed_result;
5221 if (!strcmp(res->cmd_keyword, "gro"))
5222 show_gro(res->cmd_pid);
5225 cmdline_parse_token_string_t cmd_gro_show_show =
5226 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5228 cmdline_parse_token_string_t cmd_gro_show_port =
5229 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5231 cmdline_parse_token_num_t cmd_gro_show_pid =
5232 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5233 cmd_pid, RTE_UINT16);
5234 cmdline_parse_token_string_t cmd_gro_show_keyword =
5235 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5236 cmd_keyword, "gro");
5238 cmdline_parse_inst_t cmd_gro_show = {
5239 .f = cmd_gro_show_parsed,
5241 .help_str = "show port <port_id> gro",
5243 (void *)&cmd_gro_show_show,
5244 (void *)&cmd_gro_show_port,
5245 (void *)&cmd_gro_show_pid,
5246 (void *)&cmd_gro_show_keyword,
5251 /* *** SET FLUSH CYCLES FOR GRO *** */
5252 struct cmd_gro_flush_result {
5253 cmdline_fixed_string_t cmd_set;
5254 cmdline_fixed_string_t cmd_keyword;
5255 cmdline_fixed_string_t cmd_flush;
5260 cmd_gro_flush_parsed(void *parsed_result,
5261 __rte_unused struct cmdline *cl,
5262 __rte_unused void *data)
5264 struct cmd_gro_flush_result *res;
5266 res = parsed_result;
5267 if ((!strcmp(res->cmd_keyword, "gro")) &&
5268 (!strcmp(res->cmd_flush, "flush")))
5269 setup_gro_flush_cycles(res->cmd_cycles);
5272 cmdline_parse_token_string_t cmd_gro_flush_set =
5273 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5275 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5276 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5277 cmd_keyword, "gro");
5278 cmdline_parse_token_string_t cmd_gro_flush_flush =
5279 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5280 cmd_flush, "flush");
5281 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5282 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5283 cmd_cycles, RTE_UINT8);
5285 cmdline_parse_inst_t cmd_gro_flush = {
5286 .f = cmd_gro_flush_parsed,
5288 .help_str = "set gro flush <cycles>",
5290 (void *)&cmd_gro_flush_set,
5291 (void *)&cmd_gro_flush_keyword,
5292 (void *)&cmd_gro_flush_flush,
5293 (void *)&cmd_gro_flush_cycles,
5298 /* *** ENABLE/DISABLE GSO *** */
5299 struct cmd_gso_enable_result {
5300 cmdline_fixed_string_t cmd_set;
5301 cmdline_fixed_string_t cmd_port;
5302 cmdline_fixed_string_t cmd_keyword;
5303 cmdline_fixed_string_t cmd_mode;
5308 cmd_gso_enable_parsed(void *parsed_result,
5309 __rte_unused struct cmdline *cl,
5310 __rte_unused void *data)
5312 struct cmd_gso_enable_result *res;
5314 res = parsed_result;
5315 if (!strcmp(res->cmd_keyword, "gso"))
5316 setup_gso(res->cmd_mode, res->cmd_pid);
5319 cmdline_parse_token_string_t cmd_gso_enable_set =
5320 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5322 cmdline_parse_token_string_t cmd_gso_enable_port =
5323 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5325 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5326 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5327 cmd_keyword, "gso");
5328 cmdline_parse_token_string_t cmd_gso_enable_mode =
5329 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5330 cmd_mode, "on#off");
5331 cmdline_parse_token_num_t cmd_gso_enable_pid =
5332 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5333 cmd_pid, RTE_UINT16);
5335 cmdline_parse_inst_t cmd_gso_enable = {
5336 .f = cmd_gso_enable_parsed,
5338 .help_str = "set port <port_id> gso on|off",
5340 (void *)&cmd_gso_enable_set,
5341 (void *)&cmd_gso_enable_port,
5342 (void *)&cmd_gso_enable_pid,
5343 (void *)&cmd_gso_enable_keyword,
5344 (void *)&cmd_gso_enable_mode,
5349 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5350 struct cmd_gso_size_result {
5351 cmdline_fixed_string_t cmd_set;
5352 cmdline_fixed_string_t cmd_keyword;
5353 cmdline_fixed_string_t cmd_segsz;
5358 cmd_gso_size_parsed(void *parsed_result,
5359 __rte_unused struct cmdline *cl,
5360 __rte_unused void *data)
5362 struct cmd_gso_size_result *res = parsed_result;
5364 if (test_done == 0) {
5366 "Before setting GSO segsz, please first stop forwarding\n");
5370 if (!strcmp(res->cmd_keyword, "gso") &&
5371 !strcmp(res->cmd_segsz, "segsz")) {
5372 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5374 "gso_size should be larger than %zu. Please input a legal value\n",
5375 RTE_GSO_SEG_SIZE_MIN);
5377 gso_max_segment_size = res->cmd_size;
5381 cmdline_parse_token_string_t cmd_gso_size_set =
5382 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5384 cmdline_parse_token_string_t cmd_gso_size_keyword =
5385 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5386 cmd_keyword, "gso");
5387 cmdline_parse_token_string_t cmd_gso_size_segsz =
5388 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5389 cmd_segsz, "segsz");
5390 cmdline_parse_token_num_t cmd_gso_size_size =
5391 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5392 cmd_size, RTE_UINT16);
5394 cmdline_parse_inst_t cmd_gso_size = {
5395 .f = cmd_gso_size_parsed,
5397 .help_str = "set gso segsz <length>",
5399 (void *)&cmd_gso_size_set,
5400 (void *)&cmd_gso_size_keyword,
5401 (void *)&cmd_gso_size_segsz,
5402 (void *)&cmd_gso_size_size,
5407 /* *** SHOW GSO CONFIGURATION *** */
5408 struct cmd_gso_show_result {
5409 cmdline_fixed_string_t cmd_show;
5410 cmdline_fixed_string_t cmd_port;
5411 cmdline_fixed_string_t cmd_keyword;
5416 cmd_gso_show_parsed(void *parsed_result,
5417 __rte_unused struct cmdline *cl,
5418 __rte_unused void *data)
5420 struct cmd_gso_show_result *res = parsed_result;
5422 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5423 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
5426 if (!strcmp(res->cmd_keyword, "gso")) {
5427 if (gso_ports[res->cmd_pid].enable) {
5428 printf("Max GSO'd packet size: %uB\n"
5429 "Supported GSO types: TCP/IPv4, "
5430 "UDP/IPv4, VxLAN with inner "
5431 "TCP/IPv4 packet, GRE with inner "
5432 "TCP/IPv4 packet\n",
5433 gso_max_segment_size);
5435 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5439 cmdline_parse_token_string_t cmd_gso_show_show =
5440 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5442 cmdline_parse_token_string_t cmd_gso_show_port =
5443 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5445 cmdline_parse_token_string_t cmd_gso_show_keyword =
5446 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5447 cmd_keyword, "gso");
5448 cmdline_parse_token_num_t cmd_gso_show_pid =
5449 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5450 cmd_pid, RTE_UINT16);
5452 cmdline_parse_inst_t cmd_gso_show = {
5453 .f = cmd_gso_show_parsed,
5455 .help_str = "show port <port_id> gso",
5457 (void *)&cmd_gso_show_show,
5458 (void *)&cmd_gso_show_port,
5459 (void *)&cmd_gso_show_pid,
5460 (void *)&cmd_gso_show_keyword,
5465 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5466 struct cmd_set_flush_rx {
5467 cmdline_fixed_string_t set;
5468 cmdline_fixed_string_t flush_rx;
5469 cmdline_fixed_string_t mode;
5473 cmd_set_flush_rx_parsed(void *parsed_result,
5474 __rte_unused struct cmdline *cl,
5475 __rte_unused void *data)
5477 struct cmd_set_flush_rx *res = parsed_result;
5479 if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) {
5480 printf("multi-process doesn't support to flush Rx queues.\n");
5484 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5487 cmdline_parse_token_string_t cmd_setflushrx_set =
5488 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5490 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5491 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5492 flush_rx, "flush_rx");
5493 cmdline_parse_token_string_t cmd_setflushrx_mode =
5494 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5498 cmdline_parse_inst_t cmd_set_flush_rx = {
5499 .f = cmd_set_flush_rx_parsed,
5500 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5503 (void *)&cmd_setflushrx_set,
5504 (void *)&cmd_setflushrx_flush_rx,
5505 (void *)&cmd_setflushrx_mode,
5510 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5511 struct cmd_set_link_check {
5512 cmdline_fixed_string_t set;
5513 cmdline_fixed_string_t link_check;
5514 cmdline_fixed_string_t mode;
5518 cmd_set_link_check_parsed(void *parsed_result,
5519 __rte_unused struct cmdline *cl,
5520 __rte_unused void *data)
5522 struct cmd_set_link_check *res = parsed_result;
5523 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5526 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5527 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5529 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5530 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5531 link_check, "link_check");
5532 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5533 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5537 cmdline_parse_inst_t cmd_set_link_check = {
5538 .f = cmd_set_link_check_parsed,
5539 .help_str = "set link_check on|off: Enable/Disable link status check "
5540 "when starting/stopping a port",
5543 (void *)&cmd_setlinkcheck_set,
5544 (void *)&cmd_setlinkcheck_link_check,
5545 (void *)&cmd_setlinkcheck_mode,
5550 /* *** SET NIC BYPASS MODE *** */
5551 struct cmd_set_bypass_mode_result {
5552 cmdline_fixed_string_t set;
5553 cmdline_fixed_string_t bypass;
5554 cmdline_fixed_string_t mode;
5555 cmdline_fixed_string_t value;
5560 cmd_set_bypass_mode_parsed(void *parsed_result,
5561 __rte_unused struct cmdline *cl,
5562 __rte_unused void *data)
5564 struct cmd_set_bypass_mode_result *res = parsed_result;
5565 portid_t port_id = res->port_id;
5566 int32_t rc = -EINVAL;
5568 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5569 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5571 if (!strcmp(res->value, "bypass"))
5572 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5573 else if (!strcmp(res->value, "isolate"))
5574 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5576 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5578 /* Set the bypass mode for the relevant port. */
5579 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5582 fprintf(stderr, "\t Failed to set bypass mode for port = %d.\n",
5586 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5587 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5589 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5590 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5592 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5593 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5595 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5596 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5597 value, "normal#bypass#isolate");
5598 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5599 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5600 port_id, RTE_UINT16);
5602 cmdline_parse_inst_t cmd_set_bypass_mode = {
5603 .f = cmd_set_bypass_mode_parsed,
5604 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5605 "Set the NIC bypass mode for port_id",
5608 (void *)&cmd_setbypass_mode_set,
5609 (void *)&cmd_setbypass_mode_bypass,
5610 (void *)&cmd_setbypass_mode_mode,
5611 (void *)&cmd_setbypass_mode_value,
5612 (void *)&cmd_setbypass_mode_port,
5617 /* *** SET NIC BYPASS EVENT *** */
5618 struct cmd_set_bypass_event_result {
5619 cmdline_fixed_string_t set;
5620 cmdline_fixed_string_t bypass;
5621 cmdline_fixed_string_t event;
5622 cmdline_fixed_string_t event_value;
5623 cmdline_fixed_string_t mode;
5624 cmdline_fixed_string_t mode_value;
5629 cmd_set_bypass_event_parsed(void *parsed_result,
5630 __rte_unused struct cmdline *cl,
5631 __rte_unused void *data)
5633 int32_t rc = -EINVAL;
5634 struct cmd_set_bypass_event_result *res = parsed_result;
5635 portid_t port_id = res->port_id;
5637 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5638 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5639 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5641 if (!strcmp(res->event_value, "timeout"))
5642 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5643 else if (!strcmp(res->event_value, "os_on"))
5644 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5645 else if (!strcmp(res->event_value, "os_off"))
5646 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5647 else if (!strcmp(res->event_value, "power_on"))
5648 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5649 else if (!strcmp(res->event_value, "power_off"))
5650 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5652 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5654 if (!strcmp(res->mode_value, "bypass"))
5655 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5656 else if (!strcmp(res->mode_value, "isolate"))
5657 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5659 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5661 /* Set the watchdog timeout. */
5662 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5665 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5666 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5671 "Failed to set timeout value %u for port %d, errto code: %d.\n",
5672 bypass_timeout, port_id, rc);
5676 /* Set the bypass event to transition to bypass mode. */
5677 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5682 fprintf(stderr, "\t Failed to set bypass event for port = %d.\n",
5686 cmdline_parse_token_string_t cmd_setbypass_event_set =
5687 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5689 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5690 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5692 cmdline_parse_token_string_t cmd_setbypass_event_event =
5693 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5695 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5696 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5697 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5698 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5699 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5701 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5702 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5703 mode_value, "normal#bypass#isolate");
5704 cmdline_parse_token_num_t cmd_setbypass_event_port =
5705 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5706 port_id, RTE_UINT16);
5708 cmdline_parse_inst_t cmd_set_bypass_event = {
5709 .f = cmd_set_bypass_event_parsed,
5710 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5711 "power_off mode normal|bypass|isolate <port_id>: "
5712 "Set the NIC bypass event mode for port_id",
5715 (void *)&cmd_setbypass_event_set,
5716 (void *)&cmd_setbypass_event_bypass,
5717 (void *)&cmd_setbypass_event_event,
5718 (void *)&cmd_setbypass_event_event_value,
5719 (void *)&cmd_setbypass_event_mode,
5720 (void *)&cmd_setbypass_event_mode_value,
5721 (void *)&cmd_setbypass_event_port,
5727 /* *** SET NIC BYPASS TIMEOUT *** */
5728 struct cmd_set_bypass_timeout_result {
5729 cmdline_fixed_string_t set;
5730 cmdline_fixed_string_t bypass;
5731 cmdline_fixed_string_t timeout;
5732 cmdline_fixed_string_t value;
5736 cmd_set_bypass_timeout_parsed(void *parsed_result,
5737 __rte_unused struct cmdline *cl,
5738 __rte_unused void *data)
5740 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5742 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5743 if (!strcmp(res->value, "1.5"))
5744 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5745 else if (!strcmp(res->value, "2"))
5746 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5747 else if (!strcmp(res->value, "3"))
5748 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5749 else if (!strcmp(res->value, "4"))
5750 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5751 else if (!strcmp(res->value, "8"))
5752 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5753 else if (!strcmp(res->value, "16"))
5754 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5755 else if (!strcmp(res->value, "32"))
5756 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5758 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5762 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5763 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5765 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5766 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5768 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5769 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5770 timeout, "timeout");
5771 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5772 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5773 value, "0#1.5#2#3#4#8#16#32");
5775 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5776 .f = cmd_set_bypass_timeout_parsed,
5777 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5778 "Set the NIC bypass watchdog timeout in seconds",
5781 (void *)&cmd_setbypass_timeout_set,
5782 (void *)&cmd_setbypass_timeout_bypass,
5783 (void *)&cmd_setbypass_timeout_timeout,
5784 (void *)&cmd_setbypass_timeout_value,
5789 /* *** SHOW NIC BYPASS MODE *** */
5790 struct cmd_show_bypass_config_result {
5791 cmdline_fixed_string_t show;
5792 cmdline_fixed_string_t bypass;
5793 cmdline_fixed_string_t config;
5798 cmd_show_bypass_config_parsed(void *parsed_result,
5799 __rte_unused struct cmdline *cl,
5800 __rte_unused void *data)
5802 struct cmd_show_bypass_config_result *res = parsed_result;
5803 portid_t port_id = res->port_id;
5805 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5806 uint32_t event_mode;
5807 uint32_t bypass_mode;
5808 uint32_t timeout = bypass_timeout;
5811 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5812 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5813 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5814 {"UNKNOWN", "normal", "bypass", "isolate"};
5815 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5823 /* Display the bypass mode.*/
5824 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5825 fprintf(stderr, "\tFailed to get bypass mode for port = %d\n",
5830 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5831 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5833 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5836 /* Display the bypass timeout.*/
5837 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5838 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5840 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5842 /* Display the bypass events and associated modes. */
5843 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5845 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5847 "\tFailed to get bypass mode for event = %s\n",
5850 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5851 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5853 printf("\tbypass event: %-16s = %s\n", events[i],
5860 "\tFailed to get bypass configuration for port = %d\n",
5864 cmdline_parse_token_string_t cmd_showbypass_config_show =
5865 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5867 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5868 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5870 cmdline_parse_token_string_t cmd_showbypass_config_config =
5871 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5873 cmdline_parse_token_num_t cmd_showbypass_config_port =
5874 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5875 port_id, RTE_UINT16);
5877 cmdline_parse_inst_t cmd_show_bypass_config = {
5878 .f = cmd_show_bypass_config_parsed,
5879 .help_str = "show bypass config <port_id>: "
5880 "Show the NIC bypass config for port_id",
5883 (void *)&cmd_showbypass_config_show,
5884 (void *)&cmd_showbypass_config_bypass,
5885 (void *)&cmd_showbypass_config_config,
5886 (void *)&cmd_showbypass_config_port,
5892 /* *** SET BONDING MODE *** */
5893 struct cmd_set_bonding_mode_result {
5894 cmdline_fixed_string_t set;
5895 cmdline_fixed_string_t bonding;
5896 cmdline_fixed_string_t mode;
5901 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5902 __rte_unused struct cmdline *cl,
5903 __rte_unused void *data)
5905 struct cmd_set_bonding_mode_result *res = parsed_result;
5906 portid_t port_id = res->port_id;
5908 /* Set the bonding mode for the relevant port. */
5909 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5910 fprintf(stderr, "\t Failed to set bonding mode for port = %d.\n",
5914 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5915 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5917 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5918 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5919 bonding, "bonding");
5920 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5921 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5923 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5924 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5926 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5927 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5928 port_id, RTE_UINT16);
5930 cmdline_parse_inst_t cmd_set_bonding_mode = {
5931 .f = cmd_set_bonding_mode_parsed,
5932 .help_str = "set bonding mode <mode_value> <port_id>: "
5933 "Set the bonding mode for port_id",
5936 (void *) &cmd_setbonding_mode_set,
5937 (void *) &cmd_setbonding_mode_bonding,
5938 (void *) &cmd_setbonding_mode_mode,
5939 (void *) &cmd_setbonding_mode_value,
5940 (void *) &cmd_setbonding_mode_port,
5945 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5946 struct cmd_set_bonding_lacp_dedicated_queues_result {
5947 cmdline_fixed_string_t set;
5948 cmdline_fixed_string_t bonding;
5949 cmdline_fixed_string_t lacp;
5950 cmdline_fixed_string_t dedicated_queues;
5952 cmdline_fixed_string_t mode;
5955 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5956 __rte_unused struct cmdline *cl,
5957 __rte_unused void *data)
5959 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5960 portid_t port_id = res->port_id;
5961 struct rte_port *port;
5963 port = &ports[port_id];
5965 /** Check if the port is not started **/
5966 if (port->port_status != RTE_PORT_STOPPED) {
5967 fprintf(stderr, "Please stop port %d first\n", port_id);
5971 if (!strcmp(res->mode, "enable")) {
5972 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5973 printf("Dedicate queues for LACP control packets"
5976 printf("Enabling dedicate queues for LACP control "
5977 "packets on port %d failed\n", port_id);
5978 } else if (!strcmp(res->mode, "disable")) {
5979 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5980 printf("Dedicated queues for LACP control packets "
5983 printf("Disabling dedicated queues for LACP control "
5984 "traffic on port %d failed\n", port_id);
5988 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5989 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5991 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5992 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5993 bonding, "bonding");
5994 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5995 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5997 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5998 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5999 dedicated_queues, "dedicated_queues");
6000 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
6001 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6002 port_id, RTE_UINT16);
6003 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
6004 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6005 mode, "enable#disable");
6007 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
6008 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
6009 .help_str = "set bonding lacp dedicated_queues <port_id> "
6011 "Enable/disable dedicated queues for LACP control traffic for port_id",
6014 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
6015 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
6016 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
6017 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
6018 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
6019 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
6024 /* *** SET BALANCE XMIT POLICY *** */
6025 struct cmd_set_bonding_balance_xmit_policy_result {
6026 cmdline_fixed_string_t set;
6027 cmdline_fixed_string_t bonding;
6028 cmdline_fixed_string_t balance_xmit_policy;
6030 cmdline_fixed_string_t policy;
6033 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
6034 __rte_unused struct cmdline *cl,
6035 __rte_unused void *data)
6037 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6038 portid_t port_id = res->port_id;
6041 if (!strcmp(res->policy, "l2")) {
6042 policy = BALANCE_XMIT_POLICY_LAYER2;
6043 } else if (!strcmp(res->policy, "l23")) {
6044 policy = BALANCE_XMIT_POLICY_LAYER23;
6045 } else if (!strcmp(res->policy, "l34")) {
6046 policy = BALANCE_XMIT_POLICY_LAYER34;
6048 fprintf(stderr, "\t Invalid xmit policy selection");
6052 /* Set the bonding mode for the relevant port. */
6053 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6055 "\t Failed to set bonding balance xmit policy for port = %d.\n",
6060 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6061 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6063 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6064 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6065 bonding, "bonding");
6066 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6067 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6068 balance_xmit_policy, "balance_xmit_policy");
6069 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6070 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6071 port_id, RTE_UINT16);
6072 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6073 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6074 policy, "l2#l23#l34");
6076 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6077 .f = cmd_set_bonding_balance_xmit_policy_parsed,
6078 .help_str = "set bonding balance_xmit_policy <port_id> "
6080 "Set the bonding balance_xmit_policy for port_id",
6083 (void *)&cmd_setbonding_balance_xmit_policy_set,
6084 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
6085 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6086 (void *)&cmd_setbonding_balance_xmit_policy_port,
6087 (void *)&cmd_setbonding_balance_xmit_policy_policy,
6092 /* *** SHOW NIC BONDING CONFIGURATION *** */
6093 struct cmd_show_bonding_config_result {
6094 cmdline_fixed_string_t show;
6095 cmdline_fixed_string_t bonding;
6096 cmdline_fixed_string_t config;
6100 static void cmd_show_bonding_config_parsed(void *parsed_result,
6101 __rte_unused struct cmdline *cl,
6102 __rte_unused void *data)
6104 struct cmd_show_bonding_config_result *res = parsed_result;
6105 int bonding_mode, agg_mode;
6106 portid_t slaves[RTE_MAX_ETHPORTS];
6107 int num_slaves, num_active_slaves;
6110 portid_t port_id = res->port_id;
6112 /* Display the bonding mode.*/
6113 bonding_mode = rte_eth_bond_mode_get(port_id);
6114 if (bonding_mode < 0) {
6115 fprintf(stderr, "\tFailed to get bonding mode for port = %d\n",
6119 printf("\tBonding mode: %d\n", bonding_mode);
6121 if (bonding_mode == BONDING_MODE_BALANCE) {
6122 int balance_xmit_policy;
6124 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6125 if (balance_xmit_policy < 0) {
6127 "\tFailed to get balance xmit policy for port = %d\n",
6131 printf("\tBalance Xmit Policy: ");
6133 switch (balance_xmit_policy) {
6134 case BALANCE_XMIT_POLICY_LAYER2:
6135 printf("BALANCE_XMIT_POLICY_LAYER2");
6137 case BALANCE_XMIT_POLICY_LAYER23:
6138 printf("BALANCE_XMIT_POLICY_LAYER23");
6140 case BALANCE_XMIT_POLICY_LAYER34:
6141 printf("BALANCE_XMIT_POLICY_LAYER34");
6148 if (bonding_mode == BONDING_MODE_8023AD) {
6149 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6150 printf("\tIEEE802.3AD Aggregator Mode: ");
6153 printf("bandwidth");
6165 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6167 if (num_slaves < 0) {
6168 fprintf(stderr, "\tFailed to get slave list for port = %d\n",
6172 if (num_slaves > 0) {
6173 printf("\tSlaves (%d): [", num_slaves);
6174 for (i = 0; i < num_slaves - 1; i++)
6175 printf("%d ", slaves[i]);
6177 printf("%d]\n", slaves[num_slaves - 1]);
6179 printf("\tSlaves: []\n");
6183 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6186 if (num_active_slaves < 0) {
6188 "\tFailed to get active slave list for port = %d\n",
6192 if (num_active_slaves > 0) {
6193 printf("\tActive Slaves (%d): [", num_active_slaves);
6194 for (i = 0; i < num_active_slaves - 1; i++)
6195 printf("%d ", slaves[i]);
6197 printf("%d]\n", slaves[num_active_slaves - 1]);
6200 printf("\tActive Slaves: []\n");
6204 primary_id = rte_eth_bond_primary_get(port_id);
6205 if (primary_id < 0) {
6206 fprintf(stderr, "\tFailed to get primary slave for port = %d\n",
6210 printf("\tPrimary: [%d]\n", primary_id);
6214 cmdline_parse_token_string_t cmd_showbonding_config_show =
6215 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6217 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6218 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6219 bonding, "bonding");
6220 cmdline_parse_token_string_t cmd_showbonding_config_config =
6221 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6223 cmdline_parse_token_num_t cmd_showbonding_config_port =
6224 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6225 port_id, RTE_UINT16);
6227 cmdline_parse_inst_t cmd_show_bonding_config = {
6228 .f = cmd_show_bonding_config_parsed,
6229 .help_str = "show bonding config <port_id>: "
6230 "Show the bonding config for port_id",
6233 (void *)&cmd_showbonding_config_show,
6234 (void *)&cmd_showbonding_config_bonding,
6235 (void *)&cmd_showbonding_config_config,
6236 (void *)&cmd_showbonding_config_port,
6241 /* *** SET BONDING PRIMARY *** */
6242 struct cmd_set_bonding_primary_result {
6243 cmdline_fixed_string_t set;
6244 cmdline_fixed_string_t bonding;
6245 cmdline_fixed_string_t primary;
6250 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6251 __rte_unused struct cmdline *cl,
6252 __rte_unused void *data)
6254 struct cmd_set_bonding_primary_result *res = parsed_result;
6255 portid_t master_port_id = res->port_id;
6256 portid_t slave_port_id = res->slave_id;
6258 /* Set the primary slave for a bonded device. */
6259 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6260 fprintf(stderr, "\t Failed to set primary slave for port = %d.\n",
6267 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6268 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6270 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6271 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6272 bonding, "bonding");
6273 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6274 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6275 primary, "primary");
6276 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6277 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6278 slave_id, RTE_UINT16);
6279 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6280 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6281 port_id, RTE_UINT16);
6283 cmdline_parse_inst_t cmd_set_bonding_primary = {
6284 .f = cmd_set_bonding_primary_parsed,
6285 .help_str = "set bonding primary <slave_id> <port_id>: "
6286 "Set the primary slave for port_id",
6289 (void *)&cmd_setbonding_primary_set,
6290 (void *)&cmd_setbonding_primary_bonding,
6291 (void *)&cmd_setbonding_primary_primary,
6292 (void *)&cmd_setbonding_primary_slave,
6293 (void *)&cmd_setbonding_primary_port,
6298 /* *** ADD SLAVE *** */
6299 struct cmd_add_bonding_slave_result {
6300 cmdline_fixed_string_t add;
6301 cmdline_fixed_string_t bonding;
6302 cmdline_fixed_string_t slave;
6307 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6308 __rte_unused struct cmdline *cl,
6309 __rte_unused void *data)
6311 struct cmd_add_bonding_slave_result *res = parsed_result;
6312 portid_t master_port_id = res->port_id;
6313 portid_t slave_port_id = res->slave_id;
6315 /* add the slave for a bonded device. */
6316 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6318 "\t Failed to add slave %d to master port = %d.\n",
6319 slave_port_id, master_port_id);
6323 set_port_slave_flag(slave_port_id);
6326 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6327 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6329 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6330 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6331 bonding, "bonding");
6332 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6333 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6335 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6336 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6337 slave_id, RTE_UINT16);
6338 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6339 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6340 port_id, RTE_UINT16);
6342 cmdline_parse_inst_t cmd_add_bonding_slave = {
6343 .f = cmd_add_bonding_slave_parsed,
6344 .help_str = "add bonding slave <slave_id> <port_id>: "
6345 "Add a slave device to a bonded device",
6348 (void *)&cmd_addbonding_slave_add,
6349 (void *)&cmd_addbonding_slave_bonding,
6350 (void *)&cmd_addbonding_slave_slave,
6351 (void *)&cmd_addbonding_slave_slaveid,
6352 (void *)&cmd_addbonding_slave_port,
6357 /* *** REMOVE SLAVE *** */
6358 struct cmd_remove_bonding_slave_result {
6359 cmdline_fixed_string_t remove;
6360 cmdline_fixed_string_t bonding;
6361 cmdline_fixed_string_t slave;
6366 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6367 __rte_unused struct cmdline *cl,
6368 __rte_unused void *data)
6370 struct cmd_remove_bonding_slave_result *res = parsed_result;
6371 portid_t master_port_id = res->port_id;
6372 portid_t slave_port_id = res->slave_id;
6374 /* remove the slave from a bonded device. */
6375 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6377 "\t Failed to remove slave %d from master port = %d.\n",
6378 slave_port_id, master_port_id);
6382 clear_port_slave_flag(slave_port_id);
6385 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6386 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6388 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6389 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6390 bonding, "bonding");
6391 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6392 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6394 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6395 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6396 slave_id, RTE_UINT16);
6397 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6398 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6399 port_id, RTE_UINT16);
6401 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6402 .f = cmd_remove_bonding_slave_parsed,
6403 .help_str = "remove bonding slave <slave_id> <port_id>: "
6404 "Remove a slave device from a bonded device",
6407 (void *)&cmd_removebonding_slave_remove,
6408 (void *)&cmd_removebonding_slave_bonding,
6409 (void *)&cmd_removebonding_slave_slave,
6410 (void *)&cmd_removebonding_slave_slaveid,
6411 (void *)&cmd_removebonding_slave_port,
6416 /* *** CREATE BONDED DEVICE *** */
6417 struct cmd_create_bonded_device_result {
6418 cmdline_fixed_string_t create;
6419 cmdline_fixed_string_t bonded;
6420 cmdline_fixed_string_t device;
6425 static int bond_dev_num = 0;
6427 static void cmd_create_bonded_device_parsed(void *parsed_result,
6428 __rte_unused struct cmdline *cl,
6429 __rte_unused void *data)
6431 struct cmd_create_bonded_device_result *res = parsed_result;
6432 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6436 if (test_done == 0) {
6437 fprintf(stderr, "Please stop forwarding first\n");
6441 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6444 /* Create a new bonded device. */
6445 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6447 fprintf(stderr, "\t Failed to create bonded device.\n");
6450 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6453 /* Update number of ports */
6454 nb_ports = rte_eth_dev_count_avail();
6455 reconfig(port_id, res->socket);
6456 ret = rte_eth_promiscuous_enable(port_id);
6459 "Failed to enable promiscuous mode for port %u: %s - ignore\n",
6460 port_id, rte_strerror(-ret));
6462 ports[port_id].need_setup = 0;
6463 ports[port_id].port_status = RTE_PORT_STOPPED;
6468 cmdline_parse_token_string_t cmd_createbonded_device_create =
6469 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6471 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6472 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6474 cmdline_parse_token_string_t cmd_createbonded_device_device =
6475 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6477 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6478 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6480 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6481 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6484 cmdline_parse_inst_t cmd_create_bonded_device = {
6485 .f = cmd_create_bonded_device_parsed,
6486 .help_str = "create bonded device <mode> <socket>: "
6487 "Create a new bonded device with specific bonding mode and socket",
6490 (void *)&cmd_createbonded_device_create,
6491 (void *)&cmd_createbonded_device_bonded,
6492 (void *)&cmd_createbonded_device_device,
6493 (void *)&cmd_createbonded_device_mode,
6494 (void *)&cmd_createbonded_device_socket,
6499 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6500 struct cmd_set_bond_mac_addr_result {
6501 cmdline_fixed_string_t set;
6502 cmdline_fixed_string_t bonding;
6503 cmdline_fixed_string_t mac_addr;
6505 struct rte_ether_addr address;
6508 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6509 __rte_unused struct cmdline *cl,
6510 __rte_unused void *data)
6512 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6515 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6518 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6520 /* check the return value and print it if is < 0 */
6522 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6526 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6527 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6528 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6529 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6531 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6532 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6534 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6535 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6536 port_num, RTE_UINT16);
6537 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6538 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6540 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6541 .f = cmd_set_bond_mac_addr_parsed,
6543 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6545 (void *)&cmd_set_bond_mac_addr_set,
6546 (void *)&cmd_set_bond_mac_addr_bonding,
6547 (void *)&cmd_set_bond_mac_addr_mac,
6548 (void *)&cmd_set_bond_mac_addr_portnum,
6549 (void *)&cmd_set_bond_mac_addr_addr,
6555 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6556 struct cmd_set_bond_mon_period_result {
6557 cmdline_fixed_string_t set;
6558 cmdline_fixed_string_t bonding;
6559 cmdline_fixed_string_t mon_period;
6564 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6565 __rte_unused struct cmdline *cl,
6566 __rte_unused void *data)
6568 struct cmd_set_bond_mon_period_result *res = parsed_result;
6571 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6573 /* check the return value and print it if is < 0 */
6575 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6579 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6580 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6582 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6583 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6584 bonding, "bonding");
6585 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6586 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6587 mon_period, "mon_period");
6588 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6589 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6590 port_num, RTE_UINT16);
6591 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6592 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6593 period_ms, RTE_UINT32);
6595 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6596 .f = cmd_set_bond_mon_period_parsed,
6598 .help_str = "set bonding mon_period <port_id> <period_ms>",
6600 (void *)&cmd_set_bond_mon_period_set,
6601 (void *)&cmd_set_bond_mon_period_bonding,
6602 (void *)&cmd_set_bond_mon_period_mon_period,
6603 (void *)&cmd_set_bond_mon_period_portnum,
6604 (void *)&cmd_set_bond_mon_period_period_ms,
6611 struct cmd_set_bonding_agg_mode_policy_result {
6612 cmdline_fixed_string_t set;
6613 cmdline_fixed_string_t bonding;
6614 cmdline_fixed_string_t agg_mode;
6616 cmdline_fixed_string_t policy;
6621 cmd_set_bonding_agg_mode(void *parsed_result,
6622 __rte_unused struct cmdline *cl,
6623 __rte_unused void *data)
6625 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6626 uint8_t policy = AGG_BANDWIDTH;
6628 if (!strcmp(res->policy, "bandwidth"))
6629 policy = AGG_BANDWIDTH;
6630 else if (!strcmp(res->policy, "stable"))
6631 policy = AGG_STABLE;
6632 else if (!strcmp(res->policy, "count"))
6635 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6639 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6640 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6642 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6643 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6644 bonding, "bonding");
6646 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6647 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6648 agg_mode, "agg_mode");
6650 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6651 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6652 port_num, RTE_UINT16);
6654 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6655 TOKEN_STRING_INITIALIZER(
6656 struct cmd_set_bonding_balance_xmit_policy_result,
6657 policy, "stable#bandwidth#count");
6659 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6660 .f = cmd_set_bonding_agg_mode,
6662 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6664 (void *)&cmd_set_bonding_agg_mode_set,
6665 (void *)&cmd_set_bonding_agg_mode_bonding,
6666 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6667 (void *)&cmd_set_bonding_agg_mode_portnum,
6668 (void *)&cmd_set_bonding_agg_mode_policy_string,
6674 #endif /* RTE_NET_BOND */
6676 /* *** SET FORWARDING MODE *** */
6677 struct cmd_set_fwd_mode_result {
6678 cmdline_fixed_string_t set;
6679 cmdline_fixed_string_t fwd;
6680 cmdline_fixed_string_t mode;
6683 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6684 __rte_unused struct cmdline *cl,
6685 __rte_unused void *data)
6687 struct cmd_set_fwd_mode_result *res = parsed_result;
6690 set_pkt_forwarding_mode(res->mode);
6693 cmdline_parse_token_string_t cmd_setfwd_set =
6694 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6695 cmdline_parse_token_string_t cmd_setfwd_fwd =
6696 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6697 cmdline_parse_token_string_t cmd_setfwd_mode =
6698 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6699 "" /* defined at init */);
6701 cmdline_parse_inst_t cmd_set_fwd_mode = {
6702 .f = cmd_set_fwd_mode_parsed,
6704 .help_str = NULL, /* defined at init */
6706 (void *)&cmd_setfwd_set,
6707 (void *)&cmd_setfwd_fwd,
6708 (void *)&cmd_setfwd_mode,
6713 static void cmd_set_fwd_mode_init(void)
6716 static char token[128];
6717 static char help[256];
6718 cmdline_parse_token_string_t *token_struct;
6720 modes = list_pkt_forwarding_modes();
6721 snprintf(help, sizeof(help), "set fwd %s: "
6722 "Set packet forwarding mode", modes);
6723 cmd_set_fwd_mode.help_str = help;
6725 /* string token separator is # */
6726 for (c = token; *modes != '\0'; modes++)
6731 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6732 token_struct->string_data.str = token;
6735 /* *** SET RETRY FORWARDING MODE *** */
6736 struct cmd_set_fwd_retry_mode_result {
6737 cmdline_fixed_string_t set;
6738 cmdline_fixed_string_t fwd;
6739 cmdline_fixed_string_t mode;
6740 cmdline_fixed_string_t retry;
6743 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6744 __rte_unused struct cmdline *cl,
6745 __rte_unused void *data)
6747 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6750 set_pkt_forwarding_mode(res->mode);
6753 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6754 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6756 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6757 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6759 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6760 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6762 "" /* defined at init */);
6763 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6764 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6767 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6768 .f = cmd_set_fwd_retry_mode_parsed,
6770 .help_str = NULL, /* defined at init */
6772 (void *)&cmd_setfwd_retry_set,
6773 (void *)&cmd_setfwd_retry_fwd,
6774 (void *)&cmd_setfwd_retry_mode,
6775 (void *)&cmd_setfwd_retry_retry,
6780 static void cmd_set_fwd_retry_mode_init(void)
6783 static char token[128];
6784 static char help[256];
6785 cmdline_parse_token_string_t *token_struct;
6787 modes = list_pkt_forwarding_retry_modes();
6788 snprintf(help, sizeof(help), "set fwd %s retry: "
6789 "Set packet forwarding mode with retry", modes);
6790 cmd_set_fwd_retry_mode.help_str = help;
6792 /* string token separator is # */
6793 for (c = token; *modes != '\0'; modes++)
6798 token_struct = (cmdline_parse_token_string_t *)
6799 cmd_set_fwd_retry_mode.tokens[2];
6800 token_struct->string_data.str = token;
6803 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6804 struct cmd_set_burst_tx_retry_result {
6805 cmdline_fixed_string_t set;
6806 cmdline_fixed_string_t burst;
6807 cmdline_fixed_string_t tx;
6808 cmdline_fixed_string_t delay;
6810 cmdline_fixed_string_t retry;
6814 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6815 __rte_unused struct cmdline *cl,
6816 __rte_unused void *data)
6818 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6820 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6821 && !strcmp(res->tx, "tx")) {
6822 if (!strcmp(res->delay, "delay"))
6823 burst_tx_delay_time = res->time;
6824 if (!strcmp(res->retry, "retry"))
6825 burst_tx_retry_num = res->retry_num;
6830 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6831 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6832 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6833 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6835 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6836 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6837 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6838 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6839 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6840 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
6842 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6843 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6844 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6845 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
6848 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6849 .f = cmd_set_burst_tx_retry_parsed,
6850 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6852 (void *)&cmd_set_burst_tx_retry_set,
6853 (void *)&cmd_set_burst_tx_retry_burst,
6854 (void *)&cmd_set_burst_tx_retry_tx,
6855 (void *)&cmd_set_burst_tx_retry_delay,
6856 (void *)&cmd_set_burst_tx_retry_time,
6857 (void *)&cmd_set_burst_tx_retry_retry,
6858 (void *)&cmd_set_burst_tx_retry_retry_num,
6863 /* *** SET PROMISC MODE *** */
6864 struct cmd_set_promisc_mode_result {
6865 cmdline_fixed_string_t set;
6866 cmdline_fixed_string_t promisc;
6867 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6868 uint16_t port_num; /* valid if "allports" argument == 0 */
6869 cmdline_fixed_string_t mode;
6872 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6873 __rte_unused struct cmdline *cl,
6876 struct cmd_set_promisc_mode_result *res = parsed_result;
6880 if (!strcmp(res->mode, "on"))
6887 RTE_ETH_FOREACH_DEV(i)
6888 eth_set_promisc_mode(i, enable);
6890 eth_set_promisc_mode(res->port_num, enable);
6894 cmdline_parse_token_string_t cmd_setpromisc_set =
6895 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6896 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6897 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6899 cmdline_parse_token_string_t cmd_setpromisc_portall =
6900 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6902 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6903 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6905 cmdline_parse_token_string_t cmd_setpromisc_mode =
6906 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6909 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6910 .f = cmd_set_promisc_mode_parsed,
6912 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6914 (void *)&cmd_setpromisc_set,
6915 (void *)&cmd_setpromisc_promisc,
6916 (void *)&cmd_setpromisc_portall,
6917 (void *)&cmd_setpromisc_mode,
6922 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6923 .f = cmd_set_promisc_mode_parsed,
6925 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6927 (void *)&cmd_setpromisc_set,
6928 (void *)&cmd_setpromisc_promisc,
6929 (void *)&cmd_setpromisc_portnum,
6930 (void *)&cmd_setpromisc_mode,
6935 /* *** SET ALLMULTI MODE *** */
6936 struct cmd_set_allmulti_mode_result {
6937 cmdline_fixed_string_t set;
6938 cmdline_fixed_string_t allmulti;
6939 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6940 uint16_t port_num; /* valid if "allports" argument == 0 */
6941 cmdline_fixed_string_t mode;
6944 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6945 __rte_unused struct cmdline *cl,
6948 struct cmd_set_allmulti_mode_result *res = parsed_result;
6952 if (!strcmp(res->mode, "on"))
6959 RTE_ETH_FOREACH_DEV(i) {
6960 eth_set_allmulticast_mode(i, enable);
6964 eth_set_allmulticast_mode(res->port_num, enable);
6968 cmdline_parse_token_string_t cmd_setallmulti_set =
6969 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6970 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6971 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6973 cmdline_parse_token_string_t cmd_setallmulti_portall =
6974 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6976 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6977 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6979 cmdline_parse_token_string_t cmd_setallmulti_mode =
6980 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6983 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6984 .f = cmd_set_allmulti_mode_parsed,
6986 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6988 (void *)&cmd_setallmulti_set,
6989 (void *)&cmd_setallmulti_allmulti,
6990 (void *)&cmd_setallmulti_portall,
6991 (void *)&cmd_setallmulti_mode,
6996 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6997 .f = cmd_set_allmulti_mode_parsed,
6999 .help_str = "set allmulti <port_id> on|off: "
7000 "Set allmulti mode on port_id",
7002 (void *)&cmd_setallmulti_set,
7003 (void *)&cmd_setallmulti_allmulti,
7004 (void *)&cmd_setallmulti_portnum,
7005 (void *)&cmd_setallmulti_mode,
7010 /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
7011 struct cmd_link_flow_ctrl_show {
7012 cmdline_fixed_string_t show;
7013 cmdline_fixed_string_t port;
7015 cmdline_fixed_string_t flow_ctrl;
7018 cmdline_parse_token_string_t cmd_lfc_show_show =
7019 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7021 cmdline_parse_token_string_t cmd_lfc_show_port =
7022 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7024 cmdline_parse_token_num_t cmd_lfc_show_portid =
7025 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
7026 port_id, RTE_UINT16);
7027 cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
7028 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7029 flow_ctrl, "flow_ctrl");
7032 cmd_link_flow_ctrl_show_parsed(void *parsed_result,
7033 __rte_unused struct cmdline *cl,
7034 __rte_unused void *data)
7036 struct cmd_link_flow_ctrl_show *res = parsed_result;
7037 static const char *info_border = "*********************";
7038 struct rte_eth_fc_conf fc_conf;
7039 bool rx_fc_en = false;
7040 bool tx_fc_en = false;
7043 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7046 "Failed to get current flow ctrl information: err = %d\n",
7051 if (fc_conf.mode == RTE_FC_RX_PAUSE || fc_conf.mode == RTE_FC_FULL)
7053 if (fc_conf.mode == RTE_FC_TX_PAUSE || fc_conf.mode == RTE_FC_FULL)
7056 printf("\n%s Flow control infos for port %-2d %s\n",
7057 info_border, res->port_id, info_border);
7058 printf("FC mode:\n");
7059 printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
7060 printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
7061 printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
7062 printf("Pause time: 0x%x\n", fc_conf.pause_time);
7063 printf("High waterline: 0x%x\n", fc_conf.high_water);
7064 printf("Low waterline: 0x%x\n", fc_conf.low_water);
7065 printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
7066 printf("Forward MAC control frames: %s\n",
7067 fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
7068 printf("\n%s************** End ***********%s\n",
7069 info_border, info_border);
7072 cmdline_parse_inst_t cmd_link_flow_control_show = {
7073 .f = cmd_link_flow_ctrl_show_parsed,
7075 .help_str = "show port <port_id> flow_ctrl",
7077 (void *)&cmd_lfc_show_show,
7078 (void *)&cmd_lfc_show_port,
7079 (void *)&cmd_lfc_show_portid,
7080 (void *)&cmd_lfc_show_flow_ctrl,
7085 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
7086 struct cmd_link_flow_ctrl_set_result {
7087 cmdline_fixed_string_t set;
7088 cmdline_fixed_string_t flow_ctrl;
7089 cmdline_fixed_string_t rx;
7090 cmdline_fixed_string_t rx_lfc_mode;
7091 cmdline_fixed_string_t tx;
7092 cmdline_fixed_string_t tx_lfc_mode;
7093 cmdline_fixed_string_t mac_ctrl_frame_fwd;
7094 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
7095 cmdline_fixed_string_t autoneg_str;
7096 cmdline_fixed_string_t autoneg;
7097 cmdline_fixed_string_t hw_str;
7098 uint32_t high_water;
7099 cmdline_fixed_string_t lw_str;
7101 cmdline_fixed_string_t pt_str;
7102 uint16_t pause_time;
7103 cmdline_fixed_string_t xon_str;
7108 cmdline_parse_token_string_t cmd_lfc_set_set =
7109 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7111 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
7112 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7113 flow_ctrl, "flow_ctrl");
7114 cmdline_parse_token_string_t cmd_lfc_set_rx =
7115 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7117 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
7118 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7119 rx_lfc_mode, "on#off");
7120 cmdline_parse_token_string_t cmd_lfc_set_tx =
7121 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7123 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7124 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7125 tx_lfc_mode, "on#off");
7126 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7127 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7128 hw_str, "high_water");
7129 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7130 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7131 high_water, RTE_UINT32);
7132 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7133 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7134 lw_str, "low_water");
7135 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7136 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7137 low_water, RTE_UINT32);
7138 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7139 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7140 pt_str, "pause_time");
7141 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7142 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7143 pause_time, RTE_UINT16);
7144 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7145 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7146 xon_str, "send_xon");
7147 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7148 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7149 send_xon, RTE_UINT16);
7150 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7151 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7152 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7153 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7154 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7155 mac_ctrl_frame_fwd_mode, "on#off");
7156 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7157 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7158 autoneg_str, "autoneg");
7159 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7160 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7162 cmdline_parse_token_num_t cmd_lfc_set_portid =
7163 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7164 port_id, RTE_UINT16);
7166 /* forward declaration */
7168 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7171 cmdline_parse_inst_t cmd_link_flow_control_set = {
7172 .f = cmd_link_flow_ctrl_set_parsed,
7174 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7175 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7176 "autoneg on|off <port_id>: Configure the Ethernet flow control",
7178 (void *)&cmd_lfc_set_set,
7179 (void *)&cmd_lfc_set_flow_ctrl,
7180 (void *)&cmd_lfc_set_rx,
7181 (void *)&cmd_lfc_set_rx_mode,
7182 (void *)&cmd_lfc_set_tx,
7183 (void *)&cmd_lfc_set_tx_mode,
7184 (void *)&cmd_lfc_set_high_water,
7185 (void *)&cmd_lfc_set_low_water,
7186 (void *)&cmd_lfc_set_pause_time,
7187 (void *)&cmd_lfc_set_send_xon,
7188 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7189 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7190 (void *)&cmd_lfc_set_autoneg_str,
7191 (void *)&cmd_lfc_set_autoneg,
7192 (void *)&cmd_lfc_set_portid,
7197 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7198 .f = cmd_link_flow_ctrl_set_parsed,
7199 .data = (void *)&cmd_link_flow_control_set_rx,
7200 .help_str = "set flow_ctrl rx on|off <port_id>: "
7201 "Change rx flow control parameter",
7203 (void *)&cmd_lfc_set_set,
7204 (void *)&cmd_lfc_set_flow_ctrl,
7205 (void *)&cmd_lfc_set_rx,
7206 (void *)&cmd_lfc_set_rx_mode,
7207 (void *)&cmd_lfc_set_portid,
7212 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7213 .f = cmd_link_flow_ctrl_set_parsed,
7214 .data = (void *)&cmd_link_flow_control_set_tx,
7215 .help_str = "set flow_ctrl tx on|off <port_id>: "
7216 "Change tx flow control parameter",
7218 (void *)&cmd_lfc_set_set,
7219 (void *)&cmd_lfc_set_flow_ctrl,
7220 (void *)&cmd_lfc_set_tx,
7221 (void *)&cmd_lfc_set_tx_mode,
7222 (void *)&cmd_lfc_set_portid,
7227 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7228 .f = cmd_link_flow_ctrl_set_parsed,
7229 .data = (void *)&cmd_link_flow_control_set_hw,
7230 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7231 "Change high water flow control parameter",
7233 (void *)&cmd_lfc_set_set,
7234 (void *)&cmd_lfc_set_flow_ctrl,
7235 (void *)&cmd_lfc_set_high_water_str,
7236 (void *)&cmd_lfc_set_high_water,
7237 (void *)&cmd_lfc_set_portid,
7242 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7243 .f = cmd_link_flow_ctrl_set_parsed,
7244 .data = (void *)&cmd_link_flow_control_set_lw,
7245 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7246 "Change low water flow control parameter",
7248 (void *)&cmd_lfc_set_set,
7249 (void *)&cmd_lfc_set_flow_ctrl,
7250 (void *)&cmd_lfc_set_low_water_str,
7251 (void *)&cmd_lfc_set_low_water,
7252 (void *)&cmd_lfc_set_portid,
7257 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7258 .f = cmd_link_flow_ctrl_set_parsed,
7259 .data = (void *)&cmd_link_flow_control_set_pt,
7260 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7261 "Change pause time flow control parameter",
7263 (void *)&cmd_lfc_set_set,
7264 (void *)&cmd_lfc_set_flow_ctrl,
7265 (void *)&cmd_lfc_set_pause_time_str,
7266 (void *)&cmd_lfc_set_pause_time,
7267 (void *)&cmd_lfc_set_portid,
7272 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7273 .f = cmd_link_flow_ctrl_set_parsed,
7274 .data = (void *)&cmd_link_flow_control_set_xon,
7275 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7276 "Change send_xon flow control parameter",
7278 (void *)&cmd_lfc_set_set,
7279 (void *)&cmd_lfc_set_flow_ctrl,
7280 (void *)&cmd_lfc_set_send_xon_str,
7281 (void *)&cmd_lfc_set_send_xon,
7282 (void *)&cmd_lfc_set_portid,
7287 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7288 .f = cmd_link_flow_ctrl_set_parsed,
7289 .data = (void *)&cmd_link_flow_control_set_macfwd,
7290 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7291 "Change mac ctrl fwd flow control parameter",
7293 (void *)&cmd_lfc_set_set,
7294 (void *)&cmd_lfc_set_flow_ctrl,
7295 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7296 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7297 (void *)&cmd_lfc_set_portid,
7302 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7303 .f = cmd_link_flow_ctrl_set_parsed,
7304 .data = (void *)&cmd_link_flow_control_set_autoneg,
7305 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7306 "Change autoneg flow control parameter",
7308 (void *)&cmd_lfc_set_set,
7309 (void *)&cmd_lfc_set_flow_ctrl,
7310 (void *)&cmd_lfc_set_autoneg_str,
7311 (void *)&cmd_lfc_set_autoneg,
7312 (void *)&cmd_lfc_set_portid,
7318 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7319 __rte_unused struct cmdline *cl,
7322 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7323 cmdline_parse_inst_t *cmd = data;
7324 struct rte_eth_fc_conf fc_conf;
7330 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7331 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7332 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7333 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7335 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7336 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7339 /* Partial command line, retrieve current configuration */
7341 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7344 "cannot get current flow ctrl parameters, return code = %d\n",
7349 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7350 (fc_conf.mode == RTE_FC_FULL))
7352 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7353 (fc_conf.mode == RTE_FC_FULL))
7357 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7358 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7360 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7361 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7363 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7365 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7366 fc_conf.high_water = res->high_water;
7368 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7369 fc_conf.low_water = res->low_water;
7371 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7372 fc_conf.pause_time = res->pause_time;
7374 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7375 fc_conf.send_xon = res->send_xon;
7377 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7378 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7379 fc_conf.mac_ctrl_frame_fwd = 1;
7381 fc_conf.mac_ctrl_frame_fwd = 0;
7384 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7385 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7387 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7390 "bad flow control parameter, return code = %d\n",
7394 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7395 struct cmd_priority_flow_ctrl_set_result {
7396 cmdline_fixed_string_t set;
7397 cmdline_fixed_string_t pfc_ctrl;
7398 cmdline_fixed_string_t rx;
7399 cmdline_fixed_string_t rx_pfc_mode;
7400 cmdline_fixed_string_t tx;
7401 cmdline_fixed_string_t tx_pfc_mode;
7402 uint32_t high_water;
7404 uint16_t pause_time;
7410 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7411 __rte_unused struct cmdline *cl,
7412 __rte_unused void *data)
7414 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7415 struct rte_eth_pfc_conf pfc_conf;
7416 int rx_fc_enable, tx_fc_enable;
7420 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7421 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7422 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7423 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7425 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7426 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7429 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7430 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7431 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7432 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7433 pfc_conf.fc.high_water = res->high_water;
7434 pfc_conf.fc.low_water = res->low_water;
7435 pfc_conf.fc.pause_time = res->pause_time;
7436 pfc_conf.priority = res->priority;
7438 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7441 "bad priority flow control parameter, return code = %d\n",
7445 cmdline_parse_token_string_t cmd_pfc_set_set =
7446 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7448 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7449 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7450 pfc_ctrl, "pfc_ctrl");
7451 cmdline_parse_token_string_t cmd_pfc_set_rx =
7452 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7454 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7455 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7456 rx_pfc_mode, "on#off");
7457 cmdline_parse_token_string_t cmd_pfc_set_tx =
7458 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7460 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7461 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7462 tx_pfc_mode, "on#off");
7463 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7464 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7465 high_water, RTE_UINT32);
7466 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7467 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7468 low_water, RTE_UINT32);
7469 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7470 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7471 pause_time, RTE_UINT16);
7472 cmdline_parse_token_num_t cmd_pfc_set_priority =
7473 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7474 priority, RTE_UINT8);
7475 cmdline_parse_token_num_t cmd_pfc_set_portid =
7476 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7477 port_id, RTE_UINT16);
7479 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7480 .f = cmd_priority_flow_ctrl_set_parsed,
7482 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7483 "<pause_time> <priority> <port_id>: "
7484 "Configure the Ethernet priority flow control",
7486 (void *)&cmd_pfc_set_set,
7487 (void *)&cmd_pfc_set_flow_ctrl,
7488 (void *)&cmd_pfc_set_rx,
7489 (void *)&cmd_pfc_set_rx_mode,
7490 (void *)&cmd_pfc_set_tx,
7491 (void *)&cmd_pfc_set_tx_mode,
7492 (void *)&cmd_pfc_set_high_water,
7493 (void *)&cmd_pfc_set_low_water,
7494 (void *)&cmd_pfc_set_pause_time,
7495 (void *)&cmd_pfc_set_priority,
7496 (void *)&cmd_pfc_set_portid,
7501 /* *** RESET CONFIGURATION *** */
7502 struct cmd_reset_result {
7503 cmdline_fixed_string_t reset;
7504 cmdline_fixed_string_t def;
7507 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7509 __rte_unused void *data)
7511 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7512 set_def_fwd_config();
7515 cmdline_parse_token_string_t cmd_reset_set =
7516 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7517 cmdline_parse_token_string_t cmd_reset_def =
7518 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7521 cmdline_parse_inst_t cmd_reset = {
7522 .f = cmd_reset_parsed,
7524 .help_str = "set default: Reset default forwarding configuration",
7526 (void *)&cmd_reset_set,
7527 (void *)&cmd_reset_def,
7532 /* *** START FORWARDING *** */
7533 struct cmd_start_result {
7534 cmdline_fixed_string_t start;
7537 cmdline_parse_token_string_t cmd_start_start =
7538 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7540 static void cmd_start_parsed(__rte_unused void *parsed_result,
7541 __rte_unused struct cmdline *cl,
7542 __rte_unused void *data)
7544 start_packet_forwarding(0);
7547 cmdline_parse_inst_t cmd_start = {
7548 .f = cmd_start_parsed,
7550 .help_str = "start: Start packet forwarding",
7552 (void *)&cmd_start_start,
7557 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7558 struct cmd_start_tx_first_result {
7559 cmdline_fixed_string_t start;
7560 cmdline_fixed_string_t tx_first;
7564 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7565 __rte_unused struct cmdline *cl,
7566 __rte_unused void *data)
7568 start_packet_forwarding(1);
7571 cmdline_parse_token_string_t cmd_start_tx_first_start =
7572 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7574 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7575 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7576 tx_first, "tx_first");
7578 cmdline_parse_inst_t cmd_start_tx_first = {
7579 .f = cmd_start_tx_first_parsed,
7581 .help_str = "start tx_first: Start packet forwarding, "
7582 "after sending 1 burst of packets",
7584 (void *)&cmd_start_tx_first_start,
7585 (void *)&cmd_start_tx_first_tx_first,
7590 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7591 struct cmd_start_tx_first_n_result {
7592 cmdline_fixed_string_t start;
7593 cmdline_fixed_string_t tx_first;
7598 cmd_start_tx_first_n_parsed(void *parsed_result,
7599 __rte_unused struct cmdline *cl,
7600 __rte_unused void *data)
7602 struct cmd_start_tx_first_n_result *res = parsed_result;
7604 start_packet_forwarding(res->tx_num);
7607 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7608 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7610 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7611 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7612 tx_first, "tx_first");
7613 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7614 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7615 tx_num, RTE_UINT32);
7617 cmdline_parse_inst_t cmd_start_tx_first_n = {
7618 .f = cmd_start_tx_first_n_parsed,
7620 .help_str = "start tx_first <num>: "
7621 "packet forwarding, after sending <num> bursts of packets",
7623 (void *)&cmd_start_tx_first_n_start,
7624 (void *)&cmd_start_tx_first_n_tx_first,
7625 (void *)&cmd_start_tx_first_n_tx_num,
7630 /* *** SET LINK UP *** */
7631 struct cmd_set_link_up_result {
7632 cmdline_fixed_string_t set;
7633 cmdline_fixed_string_t link_up;
7634 cmdline_fixed_string_t port;
7638 cmdline_parse_token_string_t cmd_set_link_up_set =
7639 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7640 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7641 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7643 cmdline_parse_token_string_t cmd_set_link_up_port =
7644 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7645 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7646 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7649 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7650 __rte_unused struct cmdline *cl,
7651 __rte_unused void *data)
7653 struct cmd_set_link_up_result *res = parsed_result;
7654 dev_set_link_up(res->port_id);
7657 cmdline_parse_inst_t cmd_set_link_up = {
7658 .f = cmd_set_link_up_parsed,
7660 .help_str = "set link-up port <port id>",
7662 (void *)&cmd_set_link_up_set,
7663 (void *)&cmd_set_link_up_link_up,
7664 (void *)&cmd_set_link_up_port,
7665 (void *)&cmd_set_link_up_port_id,
7670 /* *** SET LINK DOWN *** */
7671 struct cmd_set_link_down_result {
7672 cmdline_fixed_string_t set;
7673 cmdline_fixed_string_t link_down;
7674 cmdline_fixed_string_t port;
7678 cmdline_parse_token_string_t cmd_set_link_down_set =
7679 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7680 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7681 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7683 cmdline_parse_token_string_t cmd_set_link_down_port =
7684 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7685 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7686 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7689 static void cmd_set_link_down_parsed(
7690 __rte_unused void *parsed_result,
7691 __rte_unused struct cmdline *cl,
7692 __rte_unused void *data)
7694 struct cmd_set_link_down_result *res = parsed_result;
7695 dev_set_link_down(res->port_id);
7698 cmdline_parse_inst_t cmd_set_link_down = {
7699 .f = cmd_set_link_down_parsed,
7701 .help_str = "set link-down port <port id>",
7703 (void *)&cmd_set_link_down_set,
7704 (void *)&cmd_set_link_down_link_down,
7705 (void *)&cmd_set_link_down_port,
7706 (void *)&cmd_set_link_down_port_id,
7711 /* *** SHOW CFG *** */
7712 struct cmd_showcfg_result {
7713 cmdline_fixed_string_t show;
7714 cmdline_fixed_string_t cfg;
7715 cmdline_fixed_string_t what;
7718 static void cmd_showcfg_parsed(void *parsed_result,
7719 __rte_unused struct cmdline *cl,
7720 __rte_unused void *data)
7722 struct cmd_showcfg_result *res = parsed_result;
7723 if (!strcmp(res->what, "rxtx"))
7724 rxtx_config_display();
7725 else if (!strcmp(res->what, "cores"))
7726 fwd_lcores_config_display();
7727 else if (!strcmp(res->what, "fwd"))
7728 pkt_fwd_config_display(&cur_fwd_config);
7729 else if (!strcmp(res->what, "rxoffs"))
7730 show_rx_pkt_offsets();
7731 else if (!strcmp(res->what, "rxpkts"))
7732 show_rx_pkt_segments();
7733 else if (!strcmp(res->what, "txpkts"))
7734 show_tx_pkt_segments();
7735 else if (!strcmp(res->what, "txtimes"))
7736 show_tx_pkt_times();
7739 cmdline_parse_token_string_t cmd_showcfg_show =
7740 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7741 cmdline_parse_token_string_t cmd_showcfg_port =
7742 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7743 cmdline_parse_token_string_t cmd_showcfg_what =
7744 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7745 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7747 cmdline_parse_inst_t cmd_showcfg = {
7748 .f = cmd_showcfg_parsed,
7750 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7752 (void *)&cmd_showcfg_show,
7753 (void *)&cmd_showcfg_port,
7754 (void *)&cmd_showcfg_what,
7759 /* *** SHOW ALL PORT INFO *** */
7760 struct cmd_showportall_result {
7761 cmdline_fixed_string_t show;
7762 cmdline_fixed_string_t port;
7763 cmdline_fixed_string_t what;
7764 cmdline_fixed_string_t all;
7767 static void cmd_showportall_parsed(void *parsed_result,
7768 __rte_unused struct cmdline *cl,
7769 __rte_unused void *data)
7773 struct cmd_showportall_result *res = parsed_result;
7774 if (!strcmp(res->show, "clear")) {
7775 if (!strcmp(res->what, "stats"))
7776 RTE_ETH_FOREACH_DEV(i)
7778 else if (!strcmp(res->what, "xstats"))
7779 RTE_ETH_FOREACH_DEV(i)
7780 nic_xstats_clear(i);
7781 } else if (!strcmp(res->what, "info"))
7782 RTE_ETH_FOREACH_DEV(i)
7783 port_infos_display(i);
7784 else if (!strcmp(res->what, "summary")) {
7785 port_summary_header_display();
7786 RTE_ETH_FOREACH_DEV(i)
7787 port_summary_display(i);
7789 else if (!strcmp(res->what, "stats"))
7790 RTE_ETH_FOREACH_DEV(i)
7791 nic_stats_display(i);
7792 else if (!strcmp(res->what, "xstats"))
7793 RTE_ETH_FOREACH_DEV(i)
7794 nic_xstats_display(i);
7795 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7796 else if (!strcmp(res->what, "fdir"))
7797 RTE_ETH_FOREACH_DEV(i)
7800 else if (!strcmp(res->what, "dcb_tc"))
7801 RTE_ETH_FOREACH_DEV(i)
7802 port_dcb_info_display(i);
7805 cmdline_parse_token_string_t cmd_showportall_show =
7806 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7808 cmdline_parse_token_string_t cmd_showportall_port =
7809 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7810 cmdline_parse_token_string_t cmd_showportall_what =
7811 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7812 "info#summary#stats#xstats#fdir#dcb_tc");
7813 cmdline_parse_token_string_t cmd_showportall_all =
7814 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7815 cmdline_parse_inst_t cmd_showportall = {
7816 .f = cmd_showportall_parsed,
7818 .help_str = "show|clear port "
7819 "info|summary|stats|xstats|fdir|dcb_tc all",
7821 (void *)&cmd_showportall_show,
7822 (void *)&cmd_showportall_port,
7823 (void *)&cmd_showportall_what,
7824 (void *)&cmd_showportall_all,
7829 /* *** SHOW PORT INFO *** */
7830 struct cmd_showport_result {
7831 cmdline_fixed_string_t show;
7832 cmdline_fixed_string_t port;
7833 cmdline_fixed_string_t what;
7837 static void cmd_showport_parsed(void *parsed_result,
7838 __rte_unused struct cmdline *cl,
7839 __rte_unused void *data)
7841 struct cmd_showport_result *res = parsed_result;
7842 if (!strcmp(res->show, "clear")) {
7843 if (!strcmp(res->what, "stats"))
7844 nic_stats_clear(res->portnum);
7845 else if (!strcmp(res->what, "xstats"))
7846 nic_xstats_clear(res->portnum);
7847 } else if (!strcmp(res->what, "info"))
7848 port_infos_display(res->portnum);
7849 else if (!strcmp(res->what, "summary")) {
7850 port_summary_header_display();
7851 port_summary_display(res->portnum);
7853 else if (!strcmp(res->what, "stats"))
7854 nic_stats_display(res->portnum);
7855 else if (!strcmp(res->what, "xstats"))
7856 nic_xstats_display(res->portnum);
7857 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7858 else if (!strcmp(res->what, "fdir"))
7859 fdir_get_infos(res->portnum);
7861 else if (!strcmp(res->what, "dcb_tc"))
7862 port_dcb_info_display(res->portnum);
7865 cmdline_parse_token_string_t cmd_showport_show =
7866 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7868 cmdline_parse_token_string_t cmd_showport_port =
7869 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7870 cmdline_parse_token_string_t cmd_showport_what =
7871 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7872 "info#summary#stats#xstats#fdir#dcb_tc");
7873 cmdline_parse_token_num_t cmd_showport_portnum =
7874 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
7876 cmdline_parse_inst_t cmd_showport = {
7877 .f = cmd_showport_parsed,
7879 .help_str = "show|clear port "
7880 "info|summary|stats|xstats|fdir|dcb_tc "
7883 (void *)&cmd_showport_show,
7884 (void *)&cmd_showport_port,
7885 (void *)&cmd_showport_what,
7886 (void *)&cmd_showport_portnum,
7891 /* *** SHOW DEVICE INFO *** */
7892 struct cmd_showdevice_result {
7893 cmdline_fixed_string_t show;
7894 cmdline_fixed_string_t device;
7895 cmdline_fixed_string_t what;
7896 cmdline_fixed_string_t identifier;
7899 static void cmd_showdevice_parsed(void *parsed_result,
7900 __rte_unused struct cmdline *cl,
7901 __rte_unused void *data)
7903 struct cmd_showdevice_result *res = parsed_result;
7904 if (!strcmp(res->what, "info")) {
7905 if (!strcmp(res->identifier, "all"))
7906 device_infos_display(NULL);
7908 device_infos_display(res->identifier);
7912 cmdline_parse_token_string_t cmd_showdevice_show =
7913 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7915 cmdline_parse_token_string_t cmd_showdevice_device =
7916 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7917 cmdline_parse_token_string_t cmd_showdevice_what =
7918 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7920 cmdline_parse_token_string_t cmd_showdevice_identifier =
7921 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7924 cmdline_parse_inst_t cmd_showdevice = {
7925 .f = cmd_showdevice_parsed,
7927 .help_str = "show device info <identifier>|all",
7929 (void *)&cmd_showdevice_show,
7930 (void *)&cmd_showdevice_device,
7931 (void *)&cmd_showdevice_what,
7932 (void *)&cmd_showdevice_identifier,
7937 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7938 struct cmd_showeeprom_result {
7939 cmdline_fixed_string_t show;
7940 cmdline_fixed_string_t port;
7942 cmdline_fixed_string_t type;
7945 static void cmd_showeeprom_parsed(void *parsed_result,
7946 __rte_unused struct cmdline *cl,
7947 __rte_unused void *data)
7949 struct cmd_showeeprom_result *res = parsed_result;
7951 if (!strcmp(res->type, "eeprom"))
7952 port_eeprom_display(res->portnum);
7953 else if (!strcmp(res->type, "module_eeprom"))
7954 port_module_eeprom_display(res->portnum);
7956 fprintf(stderr, "Unknown argument\n");
7959 cmdline_parse_token_string_t cmd_showeeprom_show =
7960 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7961 cmdline_parse_token_string_t cmd_showeeprom_port =
7962 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7963 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7964 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7966 cmdline_parse_token_string_t cmd_showeeprom_type =
7967 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7969 cmdline_parse_inst_t cmd_showeeprom = {
7970 .f = cmd_showeeprom_parsed,
7972 .help_str = "show port <port_id> module_eeprom|eeprom",
7974 (void *)&cmd_showeeprom_show,
7975 (void *)&cmd_showeeprom_port,
7976 (void *)&cmd_showeeprom_portnum,
7977 (void *)&cmd_showeeprom_type,
7982 /* *** SHOW QUEUE INFO *** */
7983 struct cmd_showqueue_result {
7984 cmdline_fixed_string_t show;
7985 cmdline_fixed_string_t type;
7986 cmdline_fixed_string_t what;
7992 cmd_showqueue_parsed(void *parsed_result,
7993 __rte_unused struct cmdline *cl,
7994 __rte_unused void *data)
7996 struct cmd_showqueue_result *res = parsed_result;
7998 if (!strcmp(res->type, "rxq"))
7999 rx_queue_infos_display(res->portnum, res->queuenum);
8000 else if (!strcmp(res->type, "txq"))
8001 tx_queue_infos_display(res->portnum, res->queuenum);
8004 cmdline_parse_token_string_t cmd_showqueue_show =
8005 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
8006 cmdline_parse_token_string_t cmd_showqueue_type =
8007 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
8008 cmdline_parse_token_string_t cmd_showqueue_what =
8009 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
8010 cmdline_parse_token_num_t cmd_showqueue_portnum =
8011 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
8013 cmdline_parse_token_num_t cmd_showqueue_queuenum =
8014 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
8017 cmdline_parse_inst_t cmd_showqueue = {
8018 .f = cmd_showqueue_parsed,
8020 .help_str = "show rxq|txq info <port_id> <queue_id>",
8022 (void *)&cmd_showqueue_show,
8023 (void *)&cmd_showqueue_type,
8024 (void *)&cmd_showqueue_what,
8025 (void *)&cmd_showqueue_portnum,
8026 (void *)&cmd_showqueue_queuenum,
8031 /* show/clear fwd engine statistics */
8033 cmdline_fixed_string_t action;
8034 cmdline_fixed_string_t fwd;
8035 cmdline_fixed_string_t stats;
8036 cmdline_fixed_string_t all;
8039 cmdline_parse_token_string_t cmd_fwd_action =
8040 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
8041 cmdline_parse_token_string_t cmd_fwd_fwd =
8042 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
8043 cmdline_parse_token_string_t cmd_fwd_stats =
8044 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
8045 cmdline_parse_token_string_t cmd_fwd_all =
8046 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
8049 cmd_showfwdall_parsed(void *parsed_result,
8050 __rte_unused struct cmdline *cl,
8051 __rte_unused void *data)
8053 struct fwd_result *res = parsed_result;
8055 if (!strcmp(res->action, "show"))
8056 fwd_stats_display();
8061 static cmdline_parse_inst_t cmd_showfwdall = {
8062 .f = cmd_showfwdall_parsed,
8064 .help_str = "show|clear fwd stats all",
8066 (void *)&cmd_fwd_action,
8067 (void *)&cmd_fwd_fwd,
8068 (void *)&cmd_fwd_stats,
8069 (void *)&cmd_fwd_all,
8074 /* *** READ PORT REGISTER *** */
8075 struct cmd_read_reg_result {
8076 cmdline_fixed_string_t read;
8077 cmdline_fixed_string_t reg;
8083 cmd_read_reg_parsed(void *parsed_result,
8084 __rte_unused struct cmdline *cl,
8085 __rte_unused void *data)
8087 struct cmd_read_reg_result *res = parsed_result;
8088 port_reg_display(res->port_id, res->reg_off);
8091 cmdline_parse_token_string_t cmd_read_reg_read =
8092 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
8093 cmdline_parse_token_string_t cmd_read_reg_reg =
8094 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
8095 cmdline_parse_token_num_t cmd_read_reg_port_id =
8096 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
8097 cmdline_parse_token_num_t cmd_read_reg_reg_off =
8098 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
8100 cmdline_parse_inst_t cmd_read_reg = {
8101 .f = cmd_read_reg_parsed,
8103 .help_str = "read reg <port_id> <reg_off>",
8105 (void *)&cmd_read_reg_read,
8106 (void *)&cmd_read_reg_reg,
8107 (void *)&cmd_read_reg_port_id,
8108 (void *)&cmd_read_reg_reg_off,
8113 /* *** READ PORT REGISTER BIT FIELD *** */
8114 struct cmd_read_reg_bit_field_result {
8115 cmdline_fixed_string_t read;
8116 cmdline_fixed_string_t regfield;
8124 cmd_read_reg_bit_field_parsed(void *parsed_result,
8125 __rte_unused struct cmdline *cl,
8126 __rte_unused void *data)
8128 struct cmd_read_reg_bit_field_result *res = parsed_result;
8129 port_reg_bit_field_display(res->port_id, res->reg_off,
8130 res->bit1_pos, res->bit2_pos);
8133 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8134 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8136 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8137 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8138 regfield, "regfield");
8139 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8140 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8142 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8143 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8145 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8146 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8148 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8149 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8152 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8153 .f = cmd_read_reg_bit_field_parsed,
8155 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8156 "Read register bit field between bit_x and bit_y included",
8158 (void *)&cmd_read_reg_bit_field_read,
8159 (void *)&cmd_read_reg_bit_field_regfield,
8160 (void *)&cmd_read_reg_bit_field_port_id,
8161 (void *)&cmd_read_reg_bit_field_reg_off,
8162 (void *)&cmd_read_reg_bit_field_bit1_pos,
8163 (void *)&cmd_read_reg_bit_field_bit2_pos,
8168 /* *** READ PORT REGISTER BIT *** */
8169 struct cmd_read_reg_bit_result {
8170 cmdline_fixed_string_t read;
8171 cmdline_fixed_string_t regbit;
8178 cmd_read_reg_bit_parsed(void *parsed_result,
8179 __rte_unused struct cmdline *cl,
8180 __rte_unused void *data)
8182 struct cmd_read_reg_bit_result *res = parsed_result;
8183 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8186 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8187 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8188 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8189 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8191 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8192 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
8194 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8195 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
8197 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8198 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
8201 cmdline_parse_inst_t cmd_read_reg_bit = {
8202 .f = cmd_read_reg_bit_parsed,
8204 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8206 (void *)&cmd_read_reg_bit_read,
8207 (void *)&cmd_read_reg_bit_regbit,
8208 (void *)&cmd_read_reg_bit_port_id,
8209 (void *)&cmd_read_reg_bit_reg_off,
8210 (void *)&cmd_read_reg_bit_bit_pos,
8215 /* *** WRITE PORT REGISTER *** */
8216 struct cmd_write_reg_result {
8217 cmdline_fixed_string_t write;
8218 cmdline_fixed_string_t reg;
8225 cmd_write_reg_parsed(void *parsed_result,
8226 __rte_unused struct cmdline *cl,
8227 __rte_unused void *data)
8229 struct cmd_write_reg_result *res = parsed_result;
8230 port_reg_set(res->port_id, res->reg_off, res->value);
8233 cmdline_parse_token_string_t cmd_write_reg_write =
8234 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8235 cmdline_parse_token_string_t cmd_write_reg_reg =
8236 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8237 cmdline_parse_token_num_t cmd_write_reg_port_id =
8238 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8239 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8240 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8241 cmdline_parse_token_num_t cmd_write_reg_value =
8242 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8244 cmdline_parse_inst_t cmd_write_reg = {
8245 .f = cmd_write_reg_parsed,
8247 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8249 (void *)&cmd_write_reg_write,
8250 (void *)&cmd_write_reg_reg,
8251 (void *)&cmd_write_reg_port_id,
8252 (void *)&cmd_write_reg_reg_off,
8253 (void *)&cmd_write_reg_value,
8258 /* *** WRITE PORT REGISTER BIT FIELD *** */
8259 struct cmd_write_reg_bit_field_result {
8260 cmdline_fixed_string_t write;
8261 cmdline_fixed_string_t regfield;
8270 cmd_write_reg_bit_field_parsed(void *parsed_result,
8271 __rte_unused struct cmdline *cl,
8272 __rte_unused void *data)
8274 struct cmd_write_reg_bit_field_result *res = parsed_result;
8275 port_reg_bit_field_set(res->port_id, res->reg_off,
8276 res->bit1_pos, res->bit2_pos, res->value);
8279 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8280 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8282 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8283 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8284 regfield, "regfield");
8285 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8286 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8288 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8289 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8291 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8292 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8294 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8295 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8297 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8298 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8301 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8302 .f = cmd_write_reg_bit_field_parsed,
8304 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8306 "Set register bit field between bit_x and bit_y included",
8308 (void *)&cmd_write_reg_bit_field_write,
8309 (void *)&cmd_write_reg_bit_field_regfield,
8310 (void *)&cmd_write_reg_bit_field_port_id,
8311 (void *)&cmd_write_reg_bit_field_reg_off,
8312 (void *)&cmd_write_reg_bit_field_bit1_pos,
8313 (void *)&cmd_write_reg_bit_field_bit2_pos,
8314 (void *)&cmd_write_reg_bit_field_value,
8319 /* *** WRITE PORT REGISTER BIT *** */
8320 struct cmd_write_reg_bit_result {
8321 cmdline_fixed_string_t write;
8322 cmdline_fixed_string_t regbit;
8330 cmd_write_reg_bit_parsed(void *parsed_result,
8331 __rte_unused struct cmdline *cl,
8332 __rte_unused void *data)
8334 struct cmd_write_reg_bit_result *res = parsed_result;
8335 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8338 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8339 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8341 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8342 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8344 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8345 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8347 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8348 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8350 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8351 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8353 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8354 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8357 cmdline_parse_inst_t cmd_write_reg_bit = {
8358 .f = cmd_write_reg_bit_parsed,
8360 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8363 (void *)&cmd_write_reg_bit_write,
8364 (void *)&cmd_write_reg_bit_regbit,
8365 (void *)&cmd_write_reg_bit_port_id,
8366 (void *)&cmd_write_reg_bit_reg_off,
8367 (void *)&cmd_write_reg_bit_bit_pos,
8368 (void *)&cmd_write_reg_bit_value,
8373 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8374 struct cmd_read_rxd_txd_result {
8375 cmdline_fixed_string_t read;
8376 cmdline_fixed_string_t rxd_txd;
8383 cmd_read_rxd_txd_parsed(void *parsed_result,
8384 __rte_unused struct cmdline *cl,
8385 __rte_unused void *data)
8387 struct cmd_read_rxd_txd_result *res = parsed_result;
8389 if (!strcmp(res->rxd_txd, "rxd"))
8390 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8391 else if (!strcmp(res->rxd_txd, "txd"))
8392 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8395 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8396 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8397 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8398 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8400 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8401 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8403 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8404 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8406 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8407 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8410 cmdline_parse_inst_t cmd_read_rxd_txd = {
8411 .f = cmd_read_rxd_txd_parsed,
8413 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8415 (void *)&cmd_read_rxd_txd_read,
8416 (void *)&cmd_read_rxd_txd_rxd_txd,
8417 (void *)&cmd_read_rxd_txd_port_id,
8418 (void *)&cmd_read_rxd_txd_queue_id,
8419 (void *)&cmd_read_rxd_txd_desc_id,
8425 struct cmd_quit_result {
8426 cmdline_fixed_string_t quit;
8429 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8431 __rte_unused void *data)
8436 cmdline_parse_token_string_t cmd_quit_quit =
8437 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8439 cmdline_parse_inst_t cmd_quit = {
8440 .f = cmd_quit_parsed,
8442 .help_str = "quit: Exit application",
8444 (void *)&cmd_quit_quit,
8449 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8450 struct cmd_mac_addr_result {
8451 cmdline_fixed_string_t mac_addr_cmd;
8452 cmdline_fixed_string_t what;
8454 struct rte_ether_addr address;
8457 static void cmd_mac_addr_parsed(void *parsed_result,
8458 __rte_unused struct cmdline *cl,
8459 __rte_unused void *data)
8461 struct cmd_mac_addr_result *res = parsed_result;
8464 if (strcmp(res->what, "add") == 0)
8465 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8466 else if (strcmp(res->what, "set") == 0)
8467 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8470 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8472 /* check the return value and print it if is < 0 */
8474 fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
8478 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8479 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8481 cmdline_parse_token_string_t cmd_mac_addr_what =
8482 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8484 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8485 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8487 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8488 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8490 cmdline_parse_inst_t cmd_mac_addr = {
8491 .f = cmd_mac_addr_parsed,
8493 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8494 "Add/Remove/Set MAC address on port_id",
8496 (void *)&cmd_mac_addr_cmd,
8497 (void *)&cmd_mac_addr_what,
8498 (void *)&cmd_mac_addr_portnum,
8499 (void *)&cmd_mac_addr_addr,
8504 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8505 struct cmd_eth_peer_result {
8506 cmdline_fixed_string_t set;
8507 cmdline_fixed_string_t eth_peer;
8509 cmdline_fixed_string_t peer_addr;
8512 static void cmd_set_eth_peer_parsed(void *parsed_result,
8513 __rte_unused struct cmdline *cl,
8514 __rte_unused void *data)
8516 struct cmd_eth_peer_result *res = parsed_result;
8518 if (test_done == 0) {
8519 fprintf(stderr, "Please stop forwarding first\n");
8522 if (!strcmp(res->eth_peer, "eth-peer")) {
8523 set_fwd_eth_peer(res->port_id, res->peer_addr);
8527 cmdline_parse_token_string_t cmd_eth_peer_set =
8528 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8529 cmdline_parse_token_string_t cmd_eth_peer =
8530 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8531 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8532 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8534 cmdline_parse_token_string_t cmd_eth_peer_addr =
8535 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8537 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8538 .f = cmd_set_eth_peer_parsed,
8540 .help_str = "set eth-peer <port_id> <peer_mac>",
8542 (void *)&cmd_eth_peer_set,
8543 (void *)&cmd_eth_peer,
8544 (void *)&cmd_eth_peer_port_id,
8545 (void *)&cmd_eth_peer_addr,
8550 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8551 struct cmd_set_qmap_result {
8552 cmdline_fixed_string_t set;
8553 cmdline_fixed_string_t qmap;
8554 cmdline_fixed_string_t what;
8561 cmd_set_qmap_parsed(void *parsed_result,
8562 __rte_unused struct cmdline *cl,
8563 __rte_unused void *data)
8565 struct cmd_set_qmap_result *res = parsed_result;
8566 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8568 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8571 cmdline_parse_token_string_t cmd_setqmap_set =
8572 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8574 cmdline_parse_token_string_t cmd_setqmap_qmap =
8575 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8577 cmdline_parse_token_string_t cmd_setqmap_what =
8578 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8580 cmdline_parse_token_num_t cmd_setqmap_portid =
8581 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8582 port_id, RTE_UINT16);
8583 cmdline_parse_token_num_t cmd_setqmap_queueid =
8584 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8585 queue_id, RTE_UINT16);
8586 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8587 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8588 map_value, RTE_UINT8);
8590 cmdline_parse_inst_t cmd_set_qmap = {
8591 .f = cmd_set_qmap_parsed,
8593 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8594 "Set statistics mapping value on tx|rx queue_id of port_id",
8596 (void *)&cmd_setqmap_set,
8597 (void *)&cmd_setqmap_qmap,
8598 (void *)&cmd_setqmap_what,
8599 (void *)&cmd_setqmap_portid,
8600 (void *)&cmd_setqmap_queueid,
8601 (void *)&cmd_setqmap_mapvalue,
8606 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8607 struct cmd_set_xstats_hide_zero_result {
8608 cmdline_fixed_string_t keyword;
8609 cmdline_fixed_string_t name;
8610 cmdline_fixed_string_t on_off;
8614 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8615 __rte_unused struct cmdline *cl,
8616 __rte_unused void *data)
8618 struct cmd_set_xstats_hide_zero_result *res;
8619 uint16_t on_off = 0;
8621 res = parsed_result;
8622 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8623 set_xstats_hide_zero(on_off);
8626 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8627 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8629 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8630 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8631 name, "xstats-hide-zero");
8632 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8633 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8636 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8637 .f = cmd_set_xstats_hide_zero_parsed,
8639 .help_str = "set xstats-hide-zero on|off",
8641 (void *)&cmd_set_xstats_hide_zero_keyword,
8642 (void *)&cmd_set_xstats_hide_zero_name,
8643 (void *)&cmd_set_xstats_hide_zero_on_off,
8648 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8649 struct cmd_set_record_core_cycles_result {
8650 cmdline_fixed_string_t keyword;
8651 cmdline_fixed_string_t name;
8652 cmdline_fixed_string_t on_off;
8656 cmd_set_record_core_cycles_parsed(void *parsed_result,
8657 __rte_unused struct cmdline *cl,
8658 __rte_unused void *data)
8660 struct cmd_set_record_core_cycles_result *res;
8661 uint16_t on_off = 0;
8663 res = parsed_result;
8664 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8665 set_record_core_cycles(on_off);
8668 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8669 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8671 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8672 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8673 name, "record-core-cycles");
8674 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8675 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8678 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8679 .f = cmd_set_record_core_cycles_parsed,
8681 .help_str = "set record-core-cycles on|off",
8683 (void *)&cmd_set_record_core_cycles_keyword,
8684 (void *)&cmd_set_record_core_cycles_name,
8685 (void *)&cmd_set_record_core_cycles_on_off,
8690 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8691 struct cmd_set_record_burst_stats_result {
8692 cmdline_fixed_string_t keyword;
8693 cmdline_fixed_string_t name;
8694 cmdline_fixed_string_t on_off;
8698 cmd_set_record_burst_stats_parsed(void *parsed_result,
8699 __rte_unused struct cmdline *cl,
8700 __rte_unused void *data)
8702 struct cmd_set_record_burst_stats_result *res;
8703 uint16_t on_off = 0;
8705 res = parsed_result;
8706 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8707 set_record_burst_stats(on_off);
8710 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8711 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8713 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8714 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8715 name, "record-burst-stats");
8716 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8717 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8720 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8721 .f = cmd_set_record_burst_stats_parsed,
8723 .help_str = "set record-burst-stats on|off",
8725 (void *)&cmd_set_record_burst_stats_keyword,
8726 (void *)&cmd_set_record_burst_stats_name,
8727 (void *)&cmd_set_record_burst_stats_on_off,
8732 /* *** CONFIGURE UNICAST HASH TABLE *** */
8733 struct cmd_set_uc_hash_table {
8734 cmdline_fixed_string_t set;
8735 cmdline_fixed_string_t port;
8737 cmdline_fixed_string_t what;
8738 struct rte_ether_addr address;
8739 cmdline_fixed_string_t mode;
8743 cmd_set_uc_hash_parsed(void *parsed_result,
8744 __rte_unused struct cmdline *cl,
8745 __rte_unused void *data)
8748 struct cmd_set_uc_hash_table *res = parsed_result;
8750 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8752 if (strcmp(res->what, "uta") == 0)
8753 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8754 &res->address,(uint8_t)is_on);
8757 "bad unicast hash table parameter, return code = %d\n",
8762 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8763 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8765 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8766 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8768 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8769 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8770 port_id, RTE_UINT16);
8771 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8772 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8774 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8775 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8777 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8778 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8781 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8782 .f = cmd_set_uc_hash_parsed,
8784 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8786 (void *)&cmd_set_uc_hash_set,
8787 (void *)&cmd_set_uc_hash_port,
8788 (void *)&cmd_set_uc_hash_portid,
8789 (void *)&cmd_set_uc_hash_what,
8790 (void *)&cmd_set_uc_hash_mac,
8791 (void *)&cmd_set_uc_hash_mode,
8796 struct cmd_set_uc_all_hash_table {
8797 cmdline_fixed_string_t set;
8798 cmdline_fixed_string_t port;
8800 cmdline_fixed_string_t what;
8801 cmdline_fixed_string_t value;
8802 cmdline_fixed_string_t mode;
8806 cmd_set_uc_all_hash_parsed(void *parsed_result,
8807 __rte_unused struct cmdline *cl,
8808 __rte_unused void *data)
8811 struct cmd_set_uc_all_hash_table *res = parsed_result;
8813 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8815 if ((strcmp(res->what, "uta") == 0) &&
8816 (strcmp(res->value, "all") == 0))
8817 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8820 "bad unicast hash table parameter, return code = %d\n",
8824 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8825 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8827 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8828 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8830 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8831 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8832 port_id, RTE_UINT16);
8833 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8834 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8836 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8837 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8839 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8840 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8843 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8844 .f = cmd_set_uc_all_hash_parsed,
8846 .help_str = "set port <port_id> uta all on|off",
8848 (void *)&cmd_set_uc_all_hash_set,
8849 (void *)&cmd_set_uc_all_hash_port,
8850 (void *)&cmd_set_uc_all_hash_portid,
8851 (void *)&cmd_set_uc_all_hash_what,
8852 (void *)&cmd_set_uc_all_hash_value,
8853 (void *)&cmd_set_uc_all_hash_mode,
8858 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8859 struct cmd_set_vf_traffic {
8860 cmdline_fixed_string_t set;
8861 cmdline_fixed_string_t port;
8863 cmdline_fixed_string_t vf;
8865 cmdline_fixed_string_t what;
8866 cmdline_fixed_string_t mode;
8870 cmd_set_vf_traffic_parsed(void *parsed_result,
8871 __rte_unused struct cmdline *cl,
8872 __rte_unused void *data)
8874 struct cmd_set_vf_traffic *res = parsed_result;
8875 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8876 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8878 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8881 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8882 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8884 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8885 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8887 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8888 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8889 port_id, RTE_UINT16);
8890 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8891 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8893 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8894 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8896 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8897 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8899 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8900 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8903 cmdline_parse_inst_t cmd_set_vf_traffic = {
8904 .f = cmd_set_vf_traffic_parsed,
8906 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8908 (void *)&cmd_setvf_traffic_set,
8909 (void *)&cmd_setvf_traffic_port,
8910 (void *)&cmd_setvf_traffic_portid,
8911 (void *)&cmd_setvf_traffic_vf,
8912 (void *)&cmd_setvf_traffic_vfid,
8913 (void *)&cmd_setvf_traffic_what,
8914 (void *)&cmd_setvf_traffic_mode,
8919 /* *** CONFIGURE VF RECEIVE MODE *** */
8920 struct cmd_set_vf_rxmode {
8921 cmdline_fixed_string_t set;
8922 cmdline_fixed_string_t port;
8924 cmdline_fixed_string_t vf;
8926 cmdline_fixed_string_t what;
8927 cmdline_fixed_string_t mode;
8928 cmdline_fixed_string_t on;
8932 cmd_set_vf_rxmode_parsed(void *parsed_result,
8933 __rte_unused struct cmdline *cl,
8934 __rte_unused void *data)
8937 uint16_t vf_rxmode = 0;
8938 struct cmd_set_vf_rxmode *res = parsed_result;
8940 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8941 if (!strcmp(res->what,"rxmode")) {
8942 if (!strcmp(res->mode, "AUPE"))
8943 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8944 else if (!strcmp(res->mode, "ROPE"))
8945 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8946 else if (!strcmp(res->mode, "BAM"))
8947 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8948 else if (!strncmp(res->mode, "MPE",3))
8949 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8952 RTE_SET_USED(is_on);
8954 #ifdef RTE_NET_IXGBE
8955 if (ret == -ENOTSUP)
8956 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8957 vf_rxmode, (uint8_t)is_on);
8960 if (ret == -ENOTSUP)
8961 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8962 vf_rxmode, (uint8_t)is_on);
8966 "bad VF receive mode parameter, return code = %d\n",
8970 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8971 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8973 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8974 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8976 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8977 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8978 port_id, RTE_UINT16);
8979 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8980 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8982 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8983 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8985 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8986 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8988 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8989 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8990 mode, "AUPE#ROPE#BAM#MPE");
8991 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8992 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8995 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8996 .f = cmd_set_vf_rxmode_parsed,
8998 .help_str = "set port <port_id> vf <vf_id> rxmode "
8999 "AUPE|ROPE|BAM|MPE on|off",
9001 (void *)&cmd_set_vf_rxmode_set,
9002 (void *)&cmd_set_vf_rxmode_port,
9003 (void *)&cmd_set_vf_rxmode_portid,
9004 (void *)&cmd_set_vf_rxmode_vf,
9005 (void *)&cmd_set_vf_rxmode_vfid,
9006 (void *)&cmd_set_vf_rxmode_what,
9007 (void *)&cmd_set_vf_rxmode_mode,
9008 (void *)&cmd_set_vf_rxmode_on,
9013 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
9014 struct cmd_vf_mac_addr_result {
9015 cmdline_fixed_string_t mac_addr_cmd;
9016 cmdline_fixed_string_t what;
9017 cmdline_fixed_string_t port;
9019 cmdline_fixed_string_t vf;
9021 struct rte_ether_addr address;
9024 static void cmd_vf_mac_addr_parsed(void *parsed_result,
9025 __rte_unused struct cmdline *cl,
9026 __rte_unused void *data)
9028 struct cmd_vf_mac_addr_result *res = parsed_result;
9031 if (strcmp(res->what, "add") != 0)
9035 if (ret == -ENOTSUP)
9036 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
9040 if (ret == -ENOTSUP)
9041 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
9046 fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
9050 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
9051 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9052 mac_addr_cmd,"mac_addr");
9053 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
9054 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9056 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
9057 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9059 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
9060 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9061 port_num, RTE_UINT16);
9062 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
9063 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9065 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
9066 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9068 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
9069 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
9072 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
9073 .f = cmd_vf_mac_addr_parsed,
9075 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
9076 "Add MAC address filtering for a VF on port_id",
9078 (void *)&cmd_vf_mac_addr_cmd,
9079 (void *)&cmd_vf_mac_addr_what,
9080 (void *)&cmd_vf_mac_addr_port,
9081 (void *)&cmd_vf_mac_addr_portnum,
9082 (void *)&cmd_vf_mac_addr_vf,
9083 (void *)&cmd_vf_mac_addr_vfnum,
9084 (void *)&cmd_vf_mac_addr_addr,
9089 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
9090 struct cmd_vf_rx_vlan_filter {
9091 cmdline_fixed_string_t rx_vlan;
9092 cmdline_fixed_string_t what;
9094 cmdline_fixed_string_t port;
9096 cmdline_fixed_string_t vf;
9101 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
9102 __rte_unused struct cmdline *cl,
9103 __rte_unused void *data)
9105 struct cmd_vf_rx_vlan_filter *res = parsed_result;
9108 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9110 #ifdef RTE_NET_IXGBE
9111 if (ret == -ENOTSUP)
9112 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9113 res->vlan_id, res->vf_mask, is_add);
9116 if (ret == -ENOTSUP)
9117 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9118 res->vlan_id, res->vf_mask, is_add);
9121 if (ret == -ENOTSUP)
9122 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9123 res->vlan_id, res->vf_mask, is_add);
9130 fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
9131 res->vlan_id, res->vf_mask);
9134 fprintf(stderr, "invalid port_id %d\n", res->port_id);
9137 fprintf(stderr, "function not implemented or supported\n");
9140 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9144 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9145 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9146 rx_vlan, "rx_vlan");
9147 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9148 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9150 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9151 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9152 vlan_id, RTE_UINT16);
9153 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9154 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9156 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9157 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9158 port_id, RTE_UINT16);
9159 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9160 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9162 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9163 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9164 vf_mask, RTE_UINT64);
9166 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9167 .f = cmd_vf_rx_vlan_filter_parsed,
9169 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9170 "(vf_mask = hexadecimal VF mask)",
9172 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9173 (void *)&cmd_vf_rx_vlan_filter_what,
9174 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9175 (void *)&cmd_vf_rx_vlan_filter_port,
9176 (void *)&cmd_vf_rx_vlan_filter_portid,
9177 (void *)&cmd_vf_rx_vlan_filter_vf,
9178 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9183 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9184 struct cmd_queue_rate_limit_result {
9185 cmdline_fixed_string_t set;
9186 cmdline_fixed_string_t port;
9188 cmdline_fixed_string_t queue;
9190 cmdline_fixed_string_t rate;
9194 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9195 __rte_unused struct cmdline *cl,
9196 __rte_unused void *data)
9198 struct cmd_queue_rate_limit_result *res = parsed_result;
9201 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9202 && (strcmp(res->queue, "queue") == 0)
9203 && (strcmp(res->rate, "rate") == 0))
9204 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9207 fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
9212 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9213 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9215 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9216 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9218 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9219 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9220 port_num, RTE_UINT16);
9221 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9222 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9224 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9225 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9226 queue_num, RTE_UINT8);
9227 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9228 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9230 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9231 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9232 rate_num, RTE_UINT16);
9234 cmdline_parse_inst_t cmd_queue_rate_limit = {
9235 .f = cmd_queue_rate_limit_parsed,
9237 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9238 "Set rate limit for a queue on port_id",
9240 (void *)&cmd_queue_rate_limit_set,
9241 (void *)&cmd_queue_rate_limit_port,
9242 (void *)&cmd_queue_rate_limit_portnum,
9243 (void *)&cmd_queue_rate_limit_queue,
9244 (void *)&cmd_queue_rate_limit_queuenum,
9245 (void *)&cmd_queue_rate_limit_rate,
9246 (void *)&cmd_queue_rate_limit_ratenum,
9251 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9252 struct cmd_vf_rate_limit_result {
9253 cmdline_fixed_string_t set;
9254 cmdline_fixed_string_t port;
9256 cmdline_fixed_string_t vf;
9258 cmdline_fixed_string_t rate;
9260 cmdline_fixed_string_t q_msk;
9264 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9265 __rte_unused struct cmdline *cl,
9266 __rte_unused void *data)
9268 struct cmd_vf_rate_limit_result *res = parsed_result;
9271 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9272 && (strcmp(res->vf, "vf") == 0)
9273 && (strcmp(res->rate, "rate") == 0)
9274 && (strcmp(res->q_msk, "queue_mask") == 0))
9275 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9276 res->rate_num, res->q_msk_val);
9278 fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
9283 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9284 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9286 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9287 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9289 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9290 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9291 port_num, RTE_UINT16);
9292 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9293 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9295 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9296 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9298 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9299 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9301 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9302 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9303 rate_num, RTE_UINT16);
9304 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9305 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9306 q_msk, "queue_mask");
9307 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9308 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9309 q_msk_val, RTE_UINT64);
9311 cmdline_parse_inst_t cmd_vf_rate_limit = {
9312 .f = cmd_vf_rate_limit_parsed,
9314 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9315 "queue_mask <queue_mask_value>: "
9316 "Set rate limit for queues of VF on port_id",
9318 (void *)&cmd_vf_rate_limit_set,
9319 (void *)&cmd_vf_rate_limit_port,
9320 (void *)&cmd_vf_rate_limit_portnum,
9321 (void *)&cmd_vf_rate_limit_vf,
9322 (void *)&cmd_vf_rate_limit_vfnum,
9323 (void *)&cmd_vf_rate_limit_rate,
9324 (void *)&cmd_vf_rate_limit_ratenum,
9325 (void *)&cmd_vf_rate_limit_q_msk,
9326 (void *)&cmd_vf_rate_limit_q_msk_val,
9331 /* *** CONFIGURE TUNNEL UDP PORT *** */
9332 struct cmd_tunnel_udp_config {
9333 cmdline_fixed_string_t rx_vxlan_port;
9334 cmdline_fixed_string_t what;
9340 cmd_tunnel_udp_config_parsed(void *parsed_result,
9341 __rte_unused struct cmdline *cl,
9342 __rte_unused void *data)
9344 struct cmd_tunnel_udp_config *res = parsed_result;
9345 struct rte_eth_udp_tunnel tunnel_udp;
9348 tunnel_udp.udp_port = res->udp_port;
9349 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9351 if (!strcmp(res->what, "add"))
9352 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9355 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9359 fprintf(stderr, "udp tunneling add error: (%s)\n",
9363 cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9364 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9365 rx_vxlan_port, "rx_vxlan_port");
9366 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9367 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9369 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9370 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9371 udp_port, RTE_UINT16);
9372 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9373 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9374 port_id, RTE_UINT16);
9376 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9377 .f = cmd_tunnel_udp_config_parsed,
9379 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9380 "Add/Remove a tunneling UDP port filter",
9382 (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9383 (void *)&cmd_tunnel_udp_config_what,
9384 (void *)&cmd_tunnel_udp_config_udp_port,
9385 (void *)&cmd_tunnel_udp_config_port_id,
9390 struct cmd_config_tunnel_udp_port {
9391 cmdline_fixed_string_t port;
9392 cmdline_fixed_string_t config;
9394 cmdline_fixed_string_t udp_tunnel_port;
9395 cmdline_fixed_string_t action;
9396 cmdline_fixed_string_t tunnel_type;
9401 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9402 __rte_unused struct cmdline *cl,
9403 __rte_unused void *data)
9405 struct cmd_config_tunnel_udp_port *res = parsed_result;
9406 struct rte_eth_udp_tunnel tunnel_udp;
9409 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9412 tunnel_udp.udp_port = res->udp_port;
9414 if (!strcmp(res->tunnel_type, "vxlan")) {
9415 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9416 } else if (!strcmp(res->tunnel_type, "geneve")) {
9417 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9418 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9419 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9420 } else if (!strcmp(res->tunnel_type, "ecpri")) {
9421 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_ECPRI;
9423 fprintf(stderr, "Invalid tunnel type\n");
9427 if (!strcmp(res->action, "add"))
9428 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9431 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9435 fprintf(stderr, "udp tunneling port add error: (%s)\n",
9439 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9440 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9442 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9443 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9445 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9446 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9448 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9449 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9452 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9453 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9455 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9456 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9457 "vxlan#geneve#vxlan-gpe#ecpri");
9458 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9459 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9462 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9463 .f = cmd_cfg_tunnel_udp_port_parsed,
9465 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9466 "geneve|vxlan-gpe|ecpri <udp_port>",
9468 (void *)&cmd_config_tunnel_udp_port_port,
9469 (void *)&cmd_config_tunnel_udp_port_config,
9470 (void *)&cmd_config_tunnel_udp_port_port_id,
9471 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9472 (void *)&cmd_config_tunnel_udp_port_action,
9473 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9474 (void *)&cmd_config_tunnel_udp_port_value,
9479 /* ******************************************************************************** */
9481 struct cmd_dump_result {
9482 cmdline_fixed_string_t dump;
9486 dump_struct_sizes(void)
9488 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9489 DUMP_SIZE(struct rte_mbuf);
9490 DUMP_SIZE(struct rte_mempool);
9491 DUMP_SIZE(struct rte_ring);
9496 /* Dump the socket memory statistics on console */
9498 dump_socket_mem(FILE *f)
9500 struct rte_malloc_socket_stats socket_stats;
9505 unsigned int n_alloc = 0;
9506 unsigned int n_free = 0;
9507 static size_t last_allocs;
9508 static size_t last_total;
9511 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9512 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9513 !socket_stats.heap_totalsz_bytes)
9515 total += socket_stats.heap_totalsz_bytes;
9516 alloc += socket_stats.heap_allocsz_bytes;
9517 free += socket_stats.heap_freesz_bytes;
9518 n_alloc += socket_stats.alloc_count;
9519 n_free += socket_stats.free_count;
9521 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9523 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9524 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9525 (double)socket_stats.heap_allocsz_bytes * 100 /
9526 (double)socket_stats.heap_totalsz_bytes,
9527 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9528 socket_stats.alloc_count,
9529 socket_stats.free_count);
9532 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9533 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9534 total ? ((double)alloc * 100 / (double)total) : 0,
9535 (double)free / (1024 * 1024),
9538 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9539 ((double)total - (double)last_total) / (1024 * 1024),
9540 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9541 last_allocs = alloc;
9545 static void cmd_dump_parsed(void *parsed_result,
9546 __rte_unused struct cmdline *cl,
9547 __rte_unused void *data)
9549 struct cmd_dump_result *res = parsed_result;
9551 if (!strcmp(res->dump, "dump_physmem"))
9552 rte_dump_physmem_layout(stdout);
9553 else if (!strcmp(res->dump, "dump_socket_mem"))
9554 dump_socket_mem(stdout);
9555 else if (!strcmp(res->dump, "dump_memzone"))
9556 rte_memzone_dump(stdout);
9557 else if (!strcmp(res->dump, "dump_struct_sizes"))
9558 dump_struct_sizes();
9559 else if (!strcmp(res->dump, "dump_ring"))
9560 rte_ring_list_dump(stdout);
9561 else if (!strcmp(res->dump, "dump_mempool"))
9562 rte_mempool_list_dump(stdout);
9563 else if (!strcmp(res->dump, "dump_devargs"))
9564 rte_devargs_dump(stdout);
9565 else if (!strcmp(res->dump, "dump_log_types"))
9566 rte_log_dump(stdout);
9569 cmdline_parse_token_string_t cmd_dump_dump =
9570 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9574 "dump_struct_sizes#"
9580 cmdline_parse_inst_t cmd_dump = {
9581 .f = cmd_dump_parsed, /* function to call */
9582 .data = NULL, /* 2nd arg of func */
9583 .help_str = "Dump status",
9584 .tokens = { /* token list, NULL terminated */
9585 (void *)&cmd_dump_dump,
9590 /* ******************************************************************************** */
9592 struct cmd_dump_one_result {
9593 cmdline_fixed_string_t dump;
9594 cmdline_fixed_string_t name;
9597 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9598 __rte_unused void *data)
9600 struct cmd_dump_one_result *res = parsed_result;
9602 if (!strcmp(res->dump, "dump_ring")) {
9604 r = rte_ring_lookup(res->name);
9606 cmdline_printf(cl, "Cannot find ring\n");
9609 rte_ring_dump(stdout, r);
9610 } else if (!strcmp(res->dump, "dump_mempool")) {
9611 struct rte_mempool *mp;
9612 mp = rte_mempool_lookup(res->name);
9614 cmdline_printf(cl, "Cannot find mempool\n");
9617 rte_mempool_dump(stdout, mp);
9621 cmdline_parse_token_string_t cmd_dump_one_dump =
9622 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9623 "dump_ring#dump_mempool");
9625 cmdline_parse_token_string_t cmd_dump_one_name =
9626 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9628 cmdline_parse_inst_t cmd_dump_one = {
9629 .f = cmd_dump_one_parsed, /* function to call */
9630 .data = NULL, /* 2nd arg of func */
9631 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9632 .tokens = { /* token list, NULL terminated */
9633 (void *)&cmd_dump_one_dump,
9634 (void *)&cmd_dump_one_name,
9639 /* *** queue region set *** */
9640 struct cmd_queue_region_result {
9641 cmdline_fixed_string_t set;
9642 cmdline_fixed_string_t port;
9644 cmdline_fixed_string_t cmd;
9645 cmdline_fixed_string_t region;
9647 cmdline_fixed_string_t queue_start_index;
9649 cmdline_fixed_string_t queue_num;
9650 uint8_t queue_num_value;
9654 cmd_queue_region_parsed(void *parsed_result,
9655 __rte_unused struct cmdline *cl,
9656 __rte_unused void *data)
9658 struct cmd_queue_region_result *res = parsed_result;
9661 struct rte_pmd_i40e_queue_region_conf region_conf;
9662 enum rte_pmd_i40e_queue_region_op op_type;
9665 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9669 memset(®ion_conf, 0, sizeof(region_conf));
9670 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9671 region_conf.region_id = res->region_id;
9672 region_conf.queue_num = res->queue_num_value;
9673 region_conf.queue_start_index = res->queue_id;
9675 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9676 op_type, ®ion_conf);
9683 fprintf(stderr, "function not implemented or supported\n");
9686 fprintf(stderr, "queue region config error: (%s)\n",
9691 cmdline_parse_token_string_t cmd_queue_region_set =
9692 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9694 cmdline_parse_token_string_t cmd_queue_region_port =
9695 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9696 cmdline_parse_token_num_t cmd_queue_region_port_id =
9697 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9698 port_id, RTE_UINT16);
9699 cmdline_parse_token_string_t cmd_queue_region_cmd =
9700 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9701 cmd, "queue-region");
9702 cmdline_parse_token_string_t cmd_queue_region_id =
9703 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9704 region, "region_id");
9705 cmdline_parse_token_num_t cmd_queue_region_index =
9706 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9707 region_id, RTE_UINT8);
9708 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9709 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9710 queue_start_index, "queue_start_index");
9711 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9712 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9713 queue_id, RTE_UINT8);
9714 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9715 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9716 queue_num, "queue_num");
9717 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9718 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9719 queue_num_value, RTE_UINT8);
9721 cmdline_parse_inst_t cmd_queue_region = {
9722 .f = cmd_queue_region_parsed,
9724 .help_str = "set port <port_id> queue-region region_id <value> "
9725 "queue_start_index <value> queue_num <value>: Set a queue region",
9727 (void *)&cmd_queue_region_set,
9728 (void *)&cmd_queue_region_port,
9729 (void *)&cmd_queue_region_port_id,
9730 (void *)&cmd_queue_region_cmd,
9731 (void *)&cmd_queue_region_id,
9732 (void *)&cmd_queue_region_index,
9733 (void *)&cmd_queue_region_queue_start_index,
9734 (void *)&cmd_queue_region_queue_id,
9735 (void *)&cmd_queue_region_queue_num,
9736 (void *)&cmd_queue_region_queue_num_value,
9741 /* *** queue region and flowtype set *** */
9742 struct cmd_region_flowtype_result {
9743 cmdline_fixed_string_t set;
9744 cmdline_fixed_string_t port;
9746 cmdline_fixed_string_t cmd;
9747 cmdline_fixed_string_t region;
9749 cmdline_fixed_string_t flowtype;
9750 uint8_t flowtype_id;
9754 cmd_region_flowtype_parsed(void *parsed_result,
9755 __rte_unused struct cmdline *cl,
9756 __rte_unused void *data)
9758 struct cmd_region_flowtype_result *res = parsed_result;
9761 struct rte_pmd_i40e_queue_region_conf region_conf;
9762 enum rte_pmd_i40e_queue_region_op op_type;
9765 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9769 memset(®ion_conf, 0, sizeof(region_conf));
9771 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9772 region_conf.region_id = res->region_id;
9773 region_conf.hw_flowtype = res->flowtype_id;
9775 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9776 op_type, ®ion_conf);
9783 fprintf(stderr, "function not implemented or supported\n");
9786 fprintf(stderr, "region flowtype config error: (%s)\n",
9791 cmdline_parse_token_string_t cmd_region_flowtype_set =
9792 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9794 cmdline_parse_token_string_t cmd_region_flowtype_port =
9795 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9797 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9798 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9799 port_id, RTE_UINT16);
9800 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9801 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9802 cmd, "queue-region");
9803 cmdline_parse_token_string_t cmd_region_flowtype_index =
9804 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9805 region, "region_id");
9806 cmdline_parse_token_num_t cmd_region_flowtype_id =
9807 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9808 region_id, RTE_UINT8);
9809 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9810 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9811 flowtype, "flowtype");
9812 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9813 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9814 flowtype_id, RTE_UINT8);
9815 cmdline_parse_inst_t cmd_region_flowtype = {
9816 .f = cmd_region_flowtype_parsed,
9818 .help_str = "set port <port_id> queue-region region_id <value> "
9819 "flowtype <value>: Set a flowtype region index",
9821 (void *)&cmd_region_flowtype_set,
9822 (void *)&cmd_region_flowtype_port,
9823 (void *)&cmd_region_flowtype_port_index,
9824 (void *)&cmd_region_flowtype_cmd,
9825 (void *)&cmd_region_flowtype_index,
9826 (void *)&cmd_region_flowtype_id,
9827 (void *)&cmd_region_flowtype_flow_index,
9828 (void *)&cmd_region_flowtype_flow_id,
9833 /* *** User Priority (UP) to queue region (region_id) set *** */
9834 struct cmd_user_priority_region_result {
9835 cmdline_fixed_string_t set;
9836 cmdline_fixed_string_t port;
9838 cmdline_fixed_string_t cmd;
9839 cmdline_fixed_string_t user_priority;
9840 uint8_t user_priority_id;
9841 cmdline_fixed_string_t region;
9846 cmd_user_priority_region_parsed(void *parsed_result,
9847 __rte_unused struct cmdline *cl,
9848 __rte_unused void *data)
9850 struct cmd_user_priority_region_result *res = parsed_result;
9853 struct rte_pmd_i40e_queue_region_conf region_conf;
9854 enum rte_pmd_i40e_queue_region_op op_type;
9857 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9861 memset(®ion_conf, 0, sizeof(region_conf));
9862 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9863 region_conf.user_priority = res->user_priority_id;
9864 region_conf.region_id = res->region_id;
9866 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9867 op_type, ®ion_conf);
9874 fprintf(stderr, "function not implemented or supported\n");
9877 fprintf(stderr, "user_priority region config error: (%s)\n",
9882 cmdline_parse_token_string_t cmd_user_priority_region_set =
9883 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9885 cmdline_parse_token_string_t cmd_user_priority_region_port =
9886 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9888 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9889 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9890 port_id, RTE_UINT16);
9891 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9892 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9893 cmd, "queue-region");
9894 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9895 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9896 user_priority, "UP");
9897 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9898 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9899 user_priority_id, RTE_UINT8);
9900 cmdline_parse_token_string_t cmd_user_priority_region_region =
9901 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9902 region, "region_id");
9903 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9904 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9905 region_id, RTE_UINT8);
9907 cmdline_parse_inst_t cmd_user_priority_region = {
9908 .f = cmd_user_priority_region_parsed,
9910 .help_str = "set port <port_id> queue-region UP <value> "
9911 "region_id <value>: Set the mapping of User Priority (UP) "
9912 "to queue region (region_id) ",
9914 (void *)&cmd_user_priority_region_set,
9915 (void *)&cmd_user_priority_region_port,
9916 (void *)&cmd_user_priority_region_port_index,
9917 (void *)&cmd_user_priority_region_cmd,
9918 (void *)&cmd_user_priority_region_UP,
9919 (void *)&cmd_user_priority_region_UP_id,
9920 (void *)&cmd_user_priority_region_region,
9921 (void *)&cmd_user_priority_region_region_id,
9926 /* *** flush all queue region related configuration *** */
9927 struct cmd_flush_queue_region_result {
9928 cmdline_fixed_string_t set;
9929 cmdline_fixed_string_t port;
9931 cmdline_fixed_string_t cmd;
9932 cmdline_fixed_string_t flush;
9933 cmdline_fixed_string_t what;
9937 cmd_flush_queue_region_parsed(void *parsed_result,
9938 __rte_unused struct cmdline *cl,
9939 __rte_unused void *data)
9941 struct cmd_flush_queue_region_result *res = parsed_result;
9944 struct rte_pmd_i40e_queue_region_conf region_conf;
9945 enum rte_pmd_i40e_queue_region_op op_type;
9948 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9952 memset(®ion_conf, 0, sizeof(region_conf));
9954 if (strcmp(res->what, "on") == 0)
9955 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9957 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9959 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9960 op_type, ®ion_conf);
9967 fprintf(stderr, "function not implemented or supported\n");
9970 fprintf(stderr, "queue region config flush error: (%s)\n",
9975 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9976 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9978 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9979 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9981 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9982 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9983 port_id, RTE_UINT16);
9984 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9985 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9986 cmd, "queue-region");
9987 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9988 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9990 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9991 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9994 cmdline_parse_inst_t cmd_flush_queue_region = {
9995 .f = cmd_flush_queue_region_parsed,
9997 .help_str = "set port <port_id> queue-region flush on|off"
9998 ": flush all queue region related configuration",
10000 (void *)&cmd_flush_queue_region_set,
10001 (void *)&cmd_flush_queue_region_port,
10002 (void *)&cmd_flush_queue_region_port_index,
10003 (void *)&cmd_flush_queue_region_cmd,
10004 (void *)&cmd_flush_queue_region_flush,
10005 (void *)&cmd_flush_queue_region_what,
10010 /* *** get all queue region related configuration info *** */
10011 struct cmd_show_queue_region_info {
10012 cmdline_fixed_string_t show;
10013 cmdline_fixed_string_t port;
10015 cmdline_fixed_string_t cmd;
10019 cmd_show_queue_region_info_parsed(void *parsed_result,
10020 __rte_unused struct cmdline *cl,
10021 __rte_unused void *data)
10023 struct cmd_show_queue_region_info *res = parsed_result;
10024 int ret = -ENOTSUP;
10025 #ifdef RTE_NET_I40E
10026 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10027 enum rte_pmd_i40e_queue_region_op op_type;
10030 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10033 #ifdef RTE_NET_I40E
10034 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10036 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10038 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10039 op_type, &rte_pmd_regions);
10041 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10048 fprintf(stderr, "function not implemented or supported\n");
10051 fprintf(stderr, "queue region config info show error: (%s)\n",
10056 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10057 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10059 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10060 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10062 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10063 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10064 port_id, RTE_UINT16);
10065 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10066 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10067 cmd, "queue-region");
10069 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10070 .f = cmd_show_queue_region_info_parsed,
10072 .help_str = "show port <port_id> queue-region"
10073 ": show all queue region related configuration info",
10075 (void *)&cmd_show_queue_region_info_get,
10076 (void *)&cmd_show_queue_region_info_port,
10077 (void *)&cmd_show_queue_region_info_port_index,
10078 (void *)&cmd_show_queue_region_info_cmd,
10083 /* *** Filters Control *** */
10085 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10087 if ((ip_addr).family == AF_INET) \
10088 (ip) = (ip_addr).addr.ipv4.s_addr; \
10090 fprintf(stderr, "invalid parameter.\n"); \
10095 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10097 if ((ip_addr).family == AF_INET6) \
10098 rte_memcpy(&(ip), \
10099 &((ip_addr).addr.ipv6), \
10100 sizeof(struct in6_addr)); \
10102 fprintf(stderr, "invalid parameter.\n"); \
10107 #ifdef RTE_NET_I40E
10110 str2flowtype(char *string)
10113 static const struct {
10116 } flowtype_str[] = {
10117 {"raw", RTE_ETH_FLOW_RAW},
10118 {"ipv4", RTE_ETH_FLOW_IPV4},
10119 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10120 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10121 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10122 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10123 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10124 {"ipv6", RTE_ETH_FLOW_IPV6},
10125 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10126 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10127 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10128 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10129 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10130 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10133 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10134 if (!strcmp(flowtype_str[i].str, string))
10135 return flowtype_str[i].type;
10138 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10139 return (uint16_t)atoi(string);
10141 return RTE_ETH_FLOW_UNKNOWN;
10144 /* *** deal with flow director filter *** */
10145 struct cmd_flow_director_result {
10146 cmdline_fixed_string_t flow_director_filter;
10148 cmdline_fixed_string_t mode;
10149 cmdline_fixed_string_t mode_value;
10150 cmdline_fixed_string_t ops;
10151 cmdline_fixed_string_t flow;
10152 cmdline_fixed_string_t flow_type;
10153 cmdline_fixed_string_t drop;
10154 cmdline_fixed_string_t queue;
10156 cmdline_fixed_string_t fd_id;
10157 uint32_t fd_id_value;
10158 cmdline_fixed_string_t packet;
10163 cmd_flow_director_filter_parsed(void *parsed_result,
10164 __rte_unused struct cmdline *cl,
10165 __rte_unused void *data)
10167 struct cmd_flow_director_result *res = parsed_result;
10169 struct rte_pmd_i40e_flow_type_mapping
10170 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10171 struct rte_pmd_i40e_pkt_template_conf conf;
10172 uint16_t flow_type = str2flowtype(res->flow_type);
10173 uint16_t i, port = res->port_id;
10176 memset(&conf, 0, sizeof(conf));
10178 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10179 fprintf(stderr, "Invalid flow type specified.\n");
10182 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10186 if (mapping[flow_type].pctype == 0ULL) {
10187 fprintf(stderr, "Invalid flow type specified.\n");
10190 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10191 if (mapping[flow_type].pctype & (1ULL << i)) {
10192 conf.input.pctype = i;
10197 conf.input.packet = open_file(res->filepath,
10198 &conf.input.length);
10199 if (!conf.input.packet)
10201 if (!strcmp(res->drop, "drop"))
10202 conf.action.behavior =
10203 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10205 conf.action.behavior =
10206 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10207 conf.action.report_status =
10208 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10209 conf.action.rx_queue = res->queue_id;
10210 conf.soft_id = res->fd_id_value;
10211 add = strcmp(res->ops, "del") ? 1 : 0;
10212 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10216 fprintf(stderr, "flow director config error: (%s)\n",
10218 close_file(conf.input.packet);
10221 cmdline_parse_token_string_t cmd_flow_director_filter =
10222 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10223 flow_director_filter, "flow_director_filter");
10224 cmdline_parse_token_num_t cmd_flow_director_port_id =
10225 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10226 port_id, RTE_UINT16);
10227 cmdline_parse_token_string_t cmd_flow_director_ops =
10228 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10229 ops, "add#del#update");
10230 cmdline_parse_token_string_t cmd_flow_director_flow =
10231 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10233 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10234 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10236 cmdline_parse_token_string_t cmd_flow_director_drop =
10237 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10239 cmdline_parse_token_string_t cmd_flow_director_queue =
10240 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10242 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10243 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10244 queue_id, RTE_UINT16);
10245 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10246 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10248 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10249 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10250 fd_id_value, RTE_UINT32);
10252 cmdline_parse_token_string_t cmd_flow_director_mode =
10253 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10255 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10256 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10257 mode_value, "raw");
10258 cmdline_parse_token_string_t cmd_flow_director_packet =
10259 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10261 cmdline_parse_token_string_t cmd_flow_director_filepath =
10262 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10265 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10266 .f = cmd_flow_director_filter_parsed,
10268 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10269 "director entry on NIC",
10271 (void *)&cmd_flow_director_filter,
10272 (void *)&cmd_flow_director_port_id,
10273 (void *)&cmd_flow_director_mode,
10274 (void *)&cmd_flow_director_mode_raw,
10275 (void *)&cmd_flow_director_ops,
10276 (void *)&cmd_flow_director_flow,
10277 (void *)&cmd_flow_director_flow_type,
10278 (void *)&cmd_flow_director_drop,
10279 (void *)&cmd_flow_director_queue,
10280 (void *)&cmd_flow_director_queue_id,
10281 (void *)&cmd_flow_director_fd_id,
10282 (void *)&cmd_flow_director_fd_id_value,
10283 (void *)&cmd_flow_director_packet,
10284 (void *)&cmd_flow_director_filepath,
10289 #endif /* RTE_NET_I40E */
10291 /* *** deal with flow director mask *** */
10292 struct cmd_flow_director_mask_result {
10293 cmdline_fixed_string_t flow_director_mask;
10295 cmdline_fixed_string_t mode;
10296 cmdline_fixed_string_t mode_value;
10297 cmdline_fixed_string_t vlan;
10298 uint16_t vlan_mask;
10299 cmdline_fixed_string_t src_mask;
10300 cmdline_ipaddr_t ipv4_src;
10301 cmdline_ipaddr_t ipv6_src;
10303 cmdline_fixed_string_t dst_mask;
10304 cmdline_ipaddr_t ipv4_dst;
10305 cmdline_ipaddr_t ipv6_dst;
10307 cmdline_fixed_string_t mac;
10308 uint8_t mac_addr_byte_mask;
10309 cmdline_fixed_string_t tunnel_id;
10310 uint32_t tunnel_id_mask;
10311 cmdline_fixed_string_t tunnel_type;
10312 uint8_t tunnel_type_mask;
10316 cmd_flow_director_mask_parsed(void *parsed_result,
10317 __rte_unused struct cmdline *cl,
10318 __rte_unused void *data)
10320 struct cmd_flow_director_mask_result *res = parsed_result;
10321 struct rte_eth_fdir_masks *mask;
10322 struct rte_port *port;
10324 port = &ports[res->port_id];
10325 /** Check if the port is not started **/
10326 if (port->port_status != RTE_PORT_STOPPED) {
10327 fprintf(stderr, "Please stop port %d first\n", res->port_id);
10331 mask = &port->dev_conf.fdir_conf.mask;
10333 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10334 if (strcmp(res->mode_value, "MAC-VLAN")) {
10335 fprintf(stderr, "Please set mode to MAC-VLAN.\n");
10339 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10340 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10341 if (strcmp(res->mode_value, "Tunnel")) {
10342 fprintf(stderr, "Please set mode to Tunnel.\n");
10346 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10347 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10348 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10349 mask->tunnel_type_mask = res->tunnel_type_mask;
10351 if (strcmp(res->mode_value, "IP")) {
10352 fprintf(stderr, "Please set mode to IP.\n");
10356 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10357 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10358 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10359 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10360 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10361 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10362 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10365 cmd_reconfig_device_queue(res->port_id, 1, 1);
10368 cmdline_parse_token_string_t cmd_flow_director_mask =
10369 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10370 flow_director_mask, "flow_director_mask");
10371 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10372 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10373 port_id, RTE_UINT16);
10374 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10375 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10377 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10378 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10379 vlan_mask, RTE_UINT16);
10380 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10381 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10382 src_mask, "src_mask");
10383 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10384 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10386 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10387 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10389 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10390 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10391 port_src, RTE_UINT16);
10392 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10393 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10394 dst_mask, "dst_mask");
10395 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10396 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10398 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10399 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10401 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10402 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10403 port_dst, RTE_UINT16);
10405 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10406 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10408 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10409 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10411 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10412 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10413 mode_value, "MAC-VLAN");
10414 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10415 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10416 mode_value, "Tunnel");
10417 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10418 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10420 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10421 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10422 mac_addr_byte_mask, RTE_UINT8);
10423 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10424 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10425 tunnel_type, "tunnel-type");
10426 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10427 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10428 tunnel_type_mask, RTE_UINT8);
10429 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10430 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10431 tunnel_id, "tunnel-id");
10432 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10433 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10434 tunnel_id_mask, RTE_UINT32);
10436 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10437 .f = cmd_flow_director_mask_parsed,
10439 .help_str = "flow_director_mask ... : "
10440 "Set IP mode flow director's mask on NIC",
10442 (void *)&cmd_flow_director_mask,
10443 (void *)&cmd_flow_director_mask_port_id,
10444 (void *)&cmd_flow_director_mask_mode,
10445 (void *)&cmd_flow_director_mask_mode_ip,
10446 (void *)&cmd_flow_director_mask_vlan,
10447 (void *)&cmd_flow_director_mask_vlan_value,
10448 (void *)&cmd_flow_director_mask_src,
10449 (void *)&cmd_flow_director_mask_ipv4_src,
10450 (void *)&cmd_flow_director_mask_ipv6_src,
10451 (void *)&cmd_flow_director_mask_port_src,
10452 (void *)&cmd_flow_director_mask_dst,
10453 (void *)&cmd_flow_director_mask_ipv4_dst,
10454 (void *)&cmd_flow_director_mask_ipv6_dst,
10455 (void *)&cmd_flow_director_mask_port_dst,
10460 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10461 .f = cmd_flow_director_mask_parsed,
10463 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10464 "flow director's mask on NIC",
10466 (void *)&cmd_flow_director_mask,
10467 (void *)&cmd_flow_director_mask_port_id,
10468 (void *)&cmd_flow_director_mask_mode,
10469 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10470 (void *)&cmd_flow_director_mask_vlan,
10471 (void *)&cmd_flow_director_mask_vlan_value,
10476 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10477 .f = cmd_flow_director_mask_parsed,
10479 .help_str = "flow_director_mask ... : Set tunnel mode "
10480 "flow director's mask on NIC",
10482 (void *)&cmd_flow_director_mask,
10483 (void *)&cmd_flow_director_mask_port_id,
10484 (void *)&cmd_flow_director_mask_mode,
10485 (void *)&cmd_flow_director_mask_mode_tunnel,
10486 (void *)&cmd_flow_director_mask_vlan,
10487 (void *)&cmd_flow_director_mask_vlan_value,
10488 (void *)&cmd_flow_director_mask_mac,
10489 (void *)&cmd_flow_director_mask_mac_value,
10490 (void *)&cmd_flow_director_mask_tunnel_type,
10491 (void *)&cmd_flow_director_mask_tunnel_type_value,
10492 (void *)&cmd_flow_director_mask_tunnel_id,
10493 (void *)&cmd_flow_director_mask_tunnel_id_value,
10498 /* *** deal with flow director flexible payload configuration *** */
10499 struct cmd_flow_director_flexpayload_result {
10500 cmdline_fixed_string_t flow_director_flexpayload;
10502 cmdline_fixed_string_t payload_layer;
10503 cmdline_fixed_string_t payload_cfg;
10507 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10510 const char *p, *p0 = q_arg;
10512 unsigned long int_fld;
10513 char *str_fld[max_num];
10518 p = strchr(p0, '(');
10522 p0 = strchr(p, ')');
10527 if (size >= sizeof(s))
10530 snprintf(s, sizeof(s), "%.*s", size, p);
10531 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10532 if (ret < 0 || ret > max_num)
10534 for (i = 0; i < ret; i++) {
10536 int_fld = strtoul(str_fld[i], &end, 0);
10537 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10539 offsets[i] = (uint16_t)int_fld;
10545 cmd_flow_director_flxpld_parsed(void *parsed_result,
10546 __rte_unused struct cmdline *cl,
10547 __rte_unused void *data)
10549 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10550 struct rte_eth_flex_payload_cfg flex_cfg;
10551 struct rte_port *port;
10554 port = &ports[res->port_id];
10555 /** Check if the port is not started **/
10556 if (port->port_status != RTE_PORT_STOPPED) {
10557 fprintf(stderr, "Please stop port %d first\n", res->port_id);
10561 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10563 if (!strcmp(res->payload_layer, "raw"))
10564 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10565 else if (!strcmp(res->payload_layer, "l2"))
10566 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10567 else if (!strcmp(res->payload_layer, "l3"))
10568 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10569 else if (!strcmp(res->payload_layer, "l4"))
10570 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10572 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10573 RTE_ETH_FDIR_MAX_FLEXLEN);
10575 fprintf(stderr, "error: Cannot parse flex payload input.\n");
10579 fdir_set_flex_payload(res->port_id, &flex_cfg);
10580 cmd_reconfig_device_queue(res->port_id, 1, 1);
10583 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10584 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10585 flow_director_flexpayload,
10586 "flow_director_flex_payload");
10587 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10588 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10589 port_id, RTE_UINT16);
10590 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10591 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10592 payload_layer, "raw#l2#l3#l4");
10593 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10594 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10595 payload_cfg, NULL);
10597 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10598 .f = cmd_flow_director_flxpld_parsed,
10600 .help_str = "flow_director_flexpayload ... : "
10601 "Set flow director's flex payload on NIC",
10603 (void *)&cmd_flow_director_flexpayload,
10604 (void *)&cmd_flow_director_flexpayload_port_id,
10605 (void *)&cmd_flow_director_flexpayload_payload_layer,
10606 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10611 /* Generic flow interface command. */
10612 extern cmdline_parse_inst_t cmd_flow;
10614 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10615 struct cmd_mcast_addr_result {
10616 cmdline_fixed_string_t mcast_addr_cmd;
10617 cmdline_fixed_string_t what;
10619 struct rte_ether_addr mc_addr;
10622 static void cmd_mcast_addr_parsed(void *parsed_result,
10623 __rte_unused struct cmdline *cl,
10624 __rte_unused void *data)
10626 struct cmd_mcast_addr_result *res = parsed_result;
10628 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
10630 "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
10631 RTE_ETHER_ADDR_BYTES(&res->mc_addr));
10634 if (strcmp(res->what, "add") == 0)
10635 mcast_addr_add(res->port_num, &res->mc_addr);
10637 mcast_addr_remove(res->port_num, &res->mc_addr);
10640 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10641 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10642 mcast_addr_cmd, "mcast_addr");
10643 cmdline_parse_token_string_t cmd_mcast_addr_what =
10644 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10646 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10647 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
10649 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10650 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10652 cmdline_parse_inst_t cmd_mcast_addr = {
10653 .f = cmd_mcast_addr_parsed,
10655 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10656 "Add/Remove multicast MAC address on port_id",
10658 (void *)&cmd_mcast_addr_cmd,
10659 (void *)&cmd_mcast_addr_what,
10660 (void *)&cmd_mcast_addr_portnum,
10661 (void *)&cmd_mcast_addr_addr,
10666 /* vf vlan anti spoof configuration */
10668 /* Common result structure for vf vlan anti spoof */
10669 struct cmd_vf_vlan_anti_spoof_result {
10670 cmdline_fixed_string_t set;
10671 cmdline_fixed_string_t vf;
10672 cmdline_fixed_string_t vlan;
10673 cmdline_fixed_string_t antispoof;
10676 cmdline_fixed_string_t on_off;
10679 /* Common CLI fields for vf vlan anti spoof enable disable */
10680 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10681 TOKEN_STRING_INITIALIZER
10682 (struct cmd_vf_vlan_anti_spoof_result,
10684 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10685 TOKEN_STRING_INITIALIZER
10686 (struct cmd_vf_vlan_anti_spoof_result,
10688 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10689 TOKEN_STRING_INITIALIZER
10690 (struct cmd_vf_vlan_anti_spoof_result,
10692 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10693 TOKEN_STRING_INITIALIZER
10694 (struct cmd_vf_vlan_anti_spoof_result,
10695 antispoof, "antispoof");
10696 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10697 TOKEN_NUM_INITIALIZER
10698 (struct cmd_vf_vlan_anti_spoof_result,
10699 port_id, RTE_UINT16);
10700 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10701 TOKEN_NUM_INITIALIZER
10702 (struct cmd_vf_vlan_anti_spoof_result,
10703 vf_id, RTE_UINT32);
10704 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10705 TOKEN_STRING_INITIALIZER
10706 (struct cmd_vf_vlan_anti_spoof_result,
10710 cmd_set_vf_vlan_anti_spoof_parsed(
10711 void *parsed_result,
10712 __rte_unused struct cmdline *cl,
10713 __rte_unused void *data)
10715 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10716 int ret = -ENOTSUP;
10718 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10720 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10723 #ifdef RTE_NET_IXGBE
10724 if (ret == -ENOTSUP)
10725 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10726 res->vf_id, is_on);
10728 #ifdef RTE_NET_I40E
10729 if (ret == -ENOTSUP)
10730 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10731 res->vf_id, is_on);
10733 #ifdef RTE_NET_BNXT
10734 if (ret == -ENOTSUP)
10735 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
10736 res->vf_id, is_on);
10743 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
10746 fprintf(stderr, "invalid port_id %d\n", res->port_id);
10749 fprintf(stderr, "function not implemented\n");
10752 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10756 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10757 .f = cmd_set_vf_vlan_anti_spoof_parsed,
10759 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10761 (void *)&cmd_vf_vlan_anti_spoof_set,
10762 (void *)&cmd_vf_vlan_anti_spoof_vf,
10763 (void *)&cmd_vf_vlan_anti_spoof_vlan,
10764 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
10765 (void *)&cmd_vf_vlan_anti_spoof_port_id,
10766 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
10767 (void *)&cmd_vf_vlan_anti_spoof_on_off,
10772 /* vf mac anti spoof configuration */
10774 /* Common result structure for vf mac anti spoof */
10775 struct cmd_vf_mac_anti_spoof_result {
10776 cmdline_fixed_string_t set;
10777 cmdline_fixed_string_t vf;
10778 cmdline_fixed_string_t mac;
10779 cmdline_fixed_string_t antispoof;
10782 cmdline_fixed_string_t on_off;
10785 /* Common CLI fields for vf mac anti spoof enable disable */
10786 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
10787 TOKEN_STRING_INITIALIZER
10788 (struct cmd_vf_mac_anti_spoof_result,
10790 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
10791 TOKEN_STRING_INITIALIZER
10792 (struct cmd_vf_mac_anti_spoof_result,
10794 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
10795 TOKEN_STRING_INITIALIZER
10796 (struct cmd_vf_mac_anti_spoof_result,
10798 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
10799 TOKEN_STRING_INITIALIZER
10800 (struct cmd_vf_mac_anti_spoof_result,
10801 antispoof, "antispoof");
10802 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
10803 TOKEN_NUM_INITIALIZER
10804 (struct cmd_vf_mac_anti_spoof_result,
10805 port_id, RTE_UINT16);
10806 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
10807 TOKEN_NUM_INITIALIZER
10808 (struct cmd_vf_mac_anti_spoof_result,
10809 vf_id, RTE_UINT32);
10810 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
10811 TOKEN_STRING_INITIALIZER
10812 (struct cmd_vf_mac_anti_spoof_result,
10816 cmd_set_vf_mac_anti_spoof_parsed(
10817 void *parsed_result,
10818 __rte_unused struct cmdline *cl,
10819 __rte_unused void *data)
10821 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
10822 int ret = -ENOTSUP;
10824 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10826 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10829 #ifdef RTE_NET_IXGBE
10830 if (ret == -ENOTSUP)
10831 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
10832 res->vf_id, is_on);
10834 #ifdef RTE_NET_I40E
10835 if (ret == -ENOTSUP)
10836 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
10837 res->vf_id, is_on);
10839 #ifdef RTE_NET_BNXT
10840 if (ret == -ENOTSUP)
10841 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
10842 res->vf_id, is_on);
10849 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
10850 res->vf_id, is_on);
10853 fprintf(stderr, "invalid port_id %d\n", res->port_id);
10856 fprintf(stderr, "function not implemented\n");
10859 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10863 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
10864 .f = cmd_set_vf_mac_anti_spoof_parsed,
10866 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
10868 (void *)&cmd_vf_mac_anti_spoof_set,
10869 (void *)&cmd_vf_mac_anti_spoof_vf,
10870 (void *)&cmd_vf_mac_anti_spoof_mac,
10871 (void *)&cmd_vf_mac_anti_spoof_antispoof,
10872 (void *)&cmd_vf_mac_anti_spoof_port_id,
10873 (void *)&cmd_vf_mac_anti_spoof_vf_id,
10874 (void *)&cmd_vf_mac_anti_spoof_on_off,
10879 /* vf vlan strip queue configuration */
10881 /* Common result structure for vf mac anti spoof */
10882 struct cmd_vf_vlan_stripq_result {
10883 cmdline_fixed_string_t set;
10884 cmdline_fixed_string_t vf;
10885 cmdline_fixed_string_t vlan;
10886 cmdline_fixed_string_t stripq;
10889 cmdline_fixed_string_t on_off;
10892 /* Common CLI fields for vf vlan strip enable disable */
10893 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
10894 TOKEN_STRING_INITIALIZER
10895 (struct cmd_vf_vlan_stripq_result,
10897 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
10898 TOKEN_STRING_INITIALIZER
10899 (struct cmd_vf_vlan_stripq_result,
10901 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
10902 TOKEN_STRING_INITIALIZER
10903 (struct cmd_vf_vlan_stripq_result,
10905 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
10906 TOKEN_STRING_INITIALIZER
10907 (struct cmd_vf_vlan_stripq_result,
10909 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
10910 TOKEN_NUM_INITIALIZER
10911 (struct cmd_vf_vlan_stripq_result,
10912 port_id, RTE_UINT16);
10913 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
10914 TOKEN_NUM_INITIALIZER
10915 (struct cmd_vf_vlan_stripq_result,
10916 vf_id, RTE_UINT16);
10917 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
10918 TOKEN_STRING_INITIALIZER
10919 (struct cmd_vf_vlan_stripq_result,
10923 cmd_set_vf_vlan_stripq_parsed(
10924 void *parsed_result,
10925 __rte_unused struct cmdline *cl,
10926 __rte_unused void *data)
10928 struct cmd_vf_vlan_stripq_result *res = parsed_result;
10929 int ret = -ENOTSUP;
10931 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10933 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10936 #ifdef RTE_NET_IXGBE
10937 if (ret == -ENOTSUP)
10938 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
10939 res->vf_id, is_on);
10941 #ifdef RTE_NET_I40E
10942 if (ret == -ENOTSUP)
10943 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
10944 res->vf_id, is_on);
10946 #ifdef RTE_NET_BNXT
10947 if (ret == -ENOTSUP)
10948 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
10949 res->vf_id, is_on);
10956 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
10957 res->vf_id, is_on);
10960 fprintf(stderr, "invalid port_id %d\n", res->port_id);
10963 fprintf(stderr, "function not implemented\n");
10966 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10970 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
10971 .f = cmd_set_vf_vlan_stripq_parsed,
10973 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
10975 (void *)&cmd_vf_vlan_stripq_set,
10976 (void *)&cmd_vf_vlan_stripq_vf,
10977 (void *)&cmd_vf_vlan_stripq_vlan,
10978 (void *)&cmd_vf_vlan_stripq_stripq,
10979 (void *)&cmd_vf_vlan_stripq_port_id,
10980 (void *)&cmd_vf_vlan_stripq_vf_id,
10981 (void *)&cmd_vf_vlan_stripq_on_off,
10986 /* vf vlan insert configuration */
10988 /* Common result structure for vf vlan insert */
10989 struct cmd_vf_vlan_insert_result {
10990 cmdline_fixed_string_t set;
10991 cmdline_fixed_string_t vf;
10992 cmdline_fixed_string_t vlan;
10993 cmdline_fixed_string_t insert;
10999 /* Common CLI fields for vf vlan insert enable disable */
11000 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11001 TOKEN_STRING_INITIALIZER
11002 (struct cmd_vf_vlan_insert_result,
11004 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11005 TOKEN_STRING_INITIALIZER
11006 (struct cmd_vf_vlan_insert_result,
11008 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11009 TOKEN_STRING_INITIALIZER
11010 (struct cmd_vf_vlan_insert_result,
11012 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11013 TOKEN_STRING_INITIALIZER
11014 (struct cmd_vf_vlan_insert_result,
11016 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11017 TOKEN_NUM_INITIALIZER
11018 (struct cmd_vf_vlan_insert_result,
11019 port_id, RTE_UINT16);
11020 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11021 TOKEN_NUM_INITIALIZER
11022 (struct cmd_vf_vlan_insert_result,
11023 vf_id, RTE_UINT16);
11024 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11025 TOKEN_NUM_INITIALIZER
11026 (struct cmd_vf_vlan_insert_result,
11027 vlan_id, RTE_UINT16);
11030 cmd_set_vf_vlan_insert_parsed(
11031 void *parsed_result,
11032 __rte_unused struct cmdline *cl,
11033 __rte_unused void *data)
11035 struct cmd_vf_vlan_insert_result *res = parsed_result;
11036 int ret = -ENOTSUP;
11038 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11041 #ifdef RTE_NET_IXGBE
11042 if (ret == -ENOTSUP)
11043 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11046 #ifdef RTE_NET_I40E
11047 if (ret == -ENOTSUP)
11048 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11051 #ifdef RTE_NET_BNXT
11052 if (ret == -ENOTSUP)
11053 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11061 fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
11062 res->vf_id, res->vlan_id);
11065 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11068 fprintf(stderr, "function not implemented\n");
11071 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11075 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11076 .f = cmd_set_vf_vlan_insert_parsed,
11078 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11080 (void *)&cmd_vf_vlan_insert_set,
11081 (void *)&cmd_vf_vlan_insert_vf,
11082 (void *)&cmd_vf_vlan_insert_vlan,
11083 (void *)&cmd_vf_vlan_insert_insert,
11084 (void *)&cmd_vf_vlan_insert_port_id,
11085 (void *)&cmd_vf_vlan_insert_vf_id,
11086 (void *)&cmd_vf_vlan_insert_vlan_id,
11091 /* tx loopback configuration */
11093 /* Common result structure for tx loopback */
11094 struct cmd_tx_loopback_result {
11095 cmdline_fixed_string_t set;
11096 cmdline_fixed_string_t tx;
11097 cmdline_fixed_string_t loopback;
11099 cmdline_fixed_string_t on_off;
11102 /* Common CLI fields for tx loopback enable disable */
11103 cmdline_parse_token_string_t cmd_tx_loopback_set =
11104 TOKEN_STRING_INITIALIZER
11105 (struct cmd_tx_loopback_result,
11107 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11108 TOKEN_STRING_INITIALIZER
11109 (struct cmd_tx_loopback_result,
11111 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11112 TOKEN_STRING_INITIALIZER
11113 (struct cmd_tx_loopback_result,
11114 loopback, "loopback");
11115 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11116 TOKEN_NUM_INITIALIZER
11117 (struct cmd_tx_loopback_result,
11118 port_id, RTE_UINT16);
11119 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11120 TOKEN_STRING_INITIALIZER
11121 (struct cmd_tx_loopback_result,
11125 cmd_set_tx_loopback_parsed(
11126 void *parsed_result,
11127 __rte_unused struct cmdline *cl,
11128 __rte_unused void *data)
11130 struct cmd_tx_loopback_result *res = parsed_result;
11131 int ret = -ENOTSUP;
11133 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11135 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11138 #ifdef RTE_NET_IXGBE
11139 if (ret == -ENOTSUP)
11140 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11142 #ifdef RTE_NET_I40E
11143 if (ret == -ENOTSUP)
11144 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11146 #ifdef RTE_NET_BNXT
11147 if (ret == -ENOTSUP)
11148 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11150 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11151 if (ret == -ENOTSUP)
11152 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11159 fprintf(stderr, "invalid is_on %d\n", is_on);
11162 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11165 fprintf(stderr, "function not implemented\n");
11168 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11172 cmdline_parse_inst_t cmd_set_tx_loopback = {
11173 .f = cmd_set_tx_loopback_parsed,
11175 .help_str = "set tx loopback <port_id> on|off",
11177 (void *)&cmd_tx_loopback_set,
11178 (void *)&cmd_tx_loopback_tx,
11179 (void *)&cmd_tx_loopback_loopback,
11180 (void *)&cmd_tx_loopback_port_id,
11181 (void *)&cmd_tx_loopback_on_off,
11186 /* all queues drop enable configuration */
11188 /* Common result structure for all queues drop enable */
11189 struct cmd_all_queues_drop_en_result {
11190 cmdline_fixed_string_t set;
11191 cmdline_fixed_string_t all;
11192 cmdline_fixed_string_t queues;
11193 cmdline_fixed_string_t drop;
11195 cmdline_fixed_string_t on_off;
11198 /* Common CLI fields for tx loopback enable disable */
11199 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11200 TOKEN_STRING_INITIALIZER
11201 (struct cmd_all_queues_drop_en_result,
11203 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11204 TOKEN_STRING_INITIALIZER
11205 (struct cmd_all_queues_drop_en_result,
11207 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11208 TOKEN_STRING_INITIALIZER
11209 (struct cmd_all_queues_drop_en_result,
11211 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11212 TOKEN_STRING_INITIALIZER
11213 (struct cmd_all_queues_drop_en_result,
11215 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11216 TOKEN_NUM_INITIALIZER
11217 (struct cmd_all_queues_drop_en_result,
11218 port_id, RTE_UINT16);
11219 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11220 TOKEN_STRING_INITIALIZER
11221 (struct cmd_all_queues_drop_en_result,
11225 cmd_set_all_queues_drop_en_parsed(
11226 void *parsed_result,
11227 __rte_unused struct cmdline *cl,
11228 __rte_unused void *data)
11230 struct cmd_all_queues_drop_en_result *res = parsed_result;
11231 int ret = -ENOTSUP;
11232 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11234 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11237 #ifdef RTE_NET_IXGBE
11238 if (ret == -ENOTSUP)
11239 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11241 #ifdef RTE_NET_BNXT
11242 if (ret == -ENOTSUP)
11243 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11249 fprintf(stderr, "invalid is_on %d\n", is_on);
11252 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11255 fprintf(stderr, "function not implemented\n");
11258 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11262 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11263 .f = cmd_set_all_queues_drop_en_parsed,
11265 .help_str = "set all queues drop <port_id> on|off",
11267 (void *)&cmd_all_queues_drop_en_set,
11268 (void *)&cmd_all_queues_drop_en_all,
11269 (void *)&cmd_all_queues_drop_en_queues,
11270 (void *)&cmd_all_queues_drop_en_drop,
11271 (void *)&cmd_all_queues_drop_en_port_id,
11272 (void *)&cmd_all_queues_drop_en_on_off,
11277 /* vf split drop enable configuration */
11279 /* Common result structure for vf split drop enable */
11280 struct cmd_vf_split_drop_en_result {
11281 cmdline_fixed_string_t set;
11282 cmdline_fixed_string_t vf;
11283 cmdline_fixed_string_t split;
11284 cmdline_fixed_string_t drop;
11287 cmdline_fixed_string_t on_off;
11290 /* Common CLI fields for vf split drop enable disable */
11291 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11292 TOKEN_STRING_INITIALIZER
11293 (struct cmd_vf_split_drop_en_result,
11295 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11296 TOKEN_STRING_INITIALIZER
11297 (struct cmd_vf_split_drop_en_result,
11299 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11300 TOKEN_STRING_INITIALIZER
11301 (struct cmd_vf_split_drop_en_result,
11303 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11304 TOKEN_STRING_INITIALIZER
11305 (struct cmd_vf_split_drop_en_result,
11307 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11308 TOKEN_NUM_INITIALIZER
11309 (struct cmd_vf_split_drop_en_result,
11310 port_id, RTE_UINT16);
11311 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11312 TOKEN_NUM_INITIALIZER
11313 (struct cmd_vf_split_drop_en_result,
11314 vf_id, RTE_UINT16);
11315 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11316 TOKEN_STRING_INITIALIZER
11317 (struct cmd_vf_split_drop_en_result,
11321 cmd_set_vf_split_drop_en_parsed(
11322 void *parsed_result,
11323 __rte_unused struct cmdline *cl,
11324 __rte_unused void *data)
11326 struct cmd_vf_split_drop_en_result *res = parsed_result;
11327 int ret = -ENOTSUP;
11328 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11330 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11333 #ifdef RTE_NET_IXGBE
11334 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11341 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11342 res->vf_id, is_on);
11345 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11348 fprintf(stderr, "not supported on port %d\n", res->port_id);
11351 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11355 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11356 .f = cmd_set_vf_split_drop_en_parsed,
11358 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11360 (void *)&cmd_vf_split_drop_en_set,
11361 (void *)&cmd_vf_split_drop_en_vf,
11362 (void *)&cmd_vf_split_drop_en_split,
11363 (void *)&cmd_vf_split_drop_en_drop,
11364 (void *)&cmd_vf_split_drop_en_port_id,
11365 (void *)&cmd_vf_split_drop_en_vf_id,
11366 (void *)&cmd_vf_split_drop_en_on_off,
11371 /* vf mac address configuration */
11373 /* Common result structure for vf mac address */
11374 struct cmd_set_vf_mac_addr_result {
11375 cmdline_fixed_string_t set;
11376 cmdline_fixed_string_t vf;
11377 cmdline_fixed_string_t mac;
11378 cmdline_fixed_string_t addr;
11381 struct rte_ether_addr mac_addr;
11385 /* Common CLI fields for vf split drop enable disable */
11386 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11387 TOKEN_STRING_INITIALIZER
11388 (struct cmd_set_vf_mac_addr_result,
11390 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11391 TOKEN_STRING_INITIALIZER
11392 (struct cmd_set_vf_mac_addr_result,
11394 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11395 TOKEN_STRING_INITIALIZER
11396 (struct cmd_set_vf_mac_addr_result,
11398 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11399 TOKEN_STRING_INITIALIZER
11400 (struct cmd_set_vf_mac_addr_result,
11402 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11403 TOKEN_NUM_INITIALIZER
11404 (struct cmd_set_vf_mac_addr_result,
11405 port_id, RTE_UINT16);
11406 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11407 TOKEN_NUM_INITIALIZER
11408 (struct cmd_set_vf_mac_addr_result,
11409 vf_id, RTE_UINT16);
11410 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11411 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11415 cmd_set_vf_mac_addr_parsed(
11416 void *parsed_result,
11417 __rte_unused struct cmdline *cl,
11418 __rte_unused void *data)
11420 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11421 int ret = -ENOTSUP;
11423 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11426 #ifdef RTE_NET_IXGBE
11427 if (ret == -ENOTSUP)
11428 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11431 #ifdef RTE_NET_I40E
11432 if (ret == -ENOTSUP)
11433 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11436 #ifdef RTE_NET_BNXT
11437 if (ret == -ENOTSUP)
11438 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11446 fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
11449 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11452 fprintf(stderr, "function not implemented\n");
11455 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11459 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11460 .f = cmd_set_vf_mac_addr_parsed,
11462 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11464 (void *)&cmd_set_vf_mac_addr_set,
11465 (void *)&cmd_set_vf_mac_addr_vf,
11466 (void *)&cmd_set_vf_mac_addr_mac,
11467 (void *)&cmd_set_vf_mac_addr_addr,
11468 (void *)&cmd_set_vf_mac_addr_port_id,
11469 (void *)&cmd_set_vf_mac_addr_vf_id,
11470 (void *)&cmd_set_vf_mac_addr_mac_addr,
11475 /* MACsec configuration */
11477 /* Common result structure for MACsec offload enable */
11478 struct cmd_macsec_offload_on_result {
11479 cmdline_fixed_string_t set;
11480 cmdline_fixed_string_t macsec;
11481 cmdline_fixed_string_t offload;
11483 cmdline_fixed_string_t on;
11484 cmdline_fixed_string_t encrypt;
11485 cmdline_fixed_string_t en_on_off;
11486 cmdline_fixed_string_t replay_protect;
11487 cmdline_fixed_string_t rp_on_off;
11490 /* Common CLI fields for MACsec offload disable */
11491 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11492 TOKEN_STRING_INITIALIZER
11493 (struct cmd_macsec_offload_on_result,
11495 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11496 TOKEN_STRING_INITIALIZER
11497 (struct cmd_macsec_offload_on_result,
11499 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11500 TOKEN_STRING_INITIALIZER
11501 (struct cmd_macsec_offload_on_result,
11502 offload, "offload");
11503 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11504 TOKEN_NUM_INITIALIZER
11505 (struct cmd_macsec_offload_on_result,
11506 port_id, RTE_UINT16);
11507 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11508 TOKEN_STRING_INITIALIZER
11509 (struct cmd_macsec_offload_on_result,
11511 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11512 TOKEN_STRING_INITIALIZER
11513 (struct cmd_macsec_offload_on_result,
11514 encrypt, "encrypt");
11515 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11516 TOKEN_STRING_INITIALIZER
11517 (struct cmd_macsec_offload_on_result,
11518 en_on_off, "on#off");
11519 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11520 TOKEN_STRING_INITIALIZER
11521 (struct cmd_macsec_offload_on_result,
11522 replay_protect, "replay-protect");
11523 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11524 TOKEN_STRING_INITIALIZER
11525 (struct cmd_macsec_offload_on_result,
11526 rp_on_off, "on#off");
11529 cmd_set_macsec_offload_on_parsed(
11530 void *parsed_result,
11531 __rte_unused struct cmdline *cl,
11532 __rte_unused void *data)
11534 struct cmd_macsec_offload_on_result *res = parsed_result;
11535 int ret = -ENOTSUP;
11536 portid_t port_id = res->port_id;
11537 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11538 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11539 struct rte_eth_dev_info dev_info;
11541 if (port_id_is_invalid(port_id, ENABLED_WARN))
11543 if (!port_is_stopped(port_id)) {
11544 fprintf(stderr, "Please stop port %d first\n", port_id);
11548 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11552 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11553 #ifdef RTE_NET_IXGBE
11554 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11562 ports[port_id].dev_conf.txmode.offloads |=
11563 DEV_TX_OFFLOAD_MACSEC_INSERT;
11564 cmd_reconfig_device_queue(port_id, 1, 1);
11567 fprintf(stderr, "invalid port_id %d\n", port_id);
11570 fprintf(stderr, "not supported on port %d\n", port_id);
11573 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11577 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11578 .f = cmd_set_macsec_offload_on_parsed,
11580 .help_str = "set macsec offload <port_id> on "
11581 "encrypt on|off replay-protect on|off",
11583 (void *)&cmd_macsec_offload_on_set,
11584 (void *)&cmd_macsec_offload_on_macsec,
11585 (void *)&cmd_macsec_offload_on_offload,
11586 (void *)&cmd_macsec_offload_on_port_id,
11587 (void *)&cmd_macsec_offload_on_on,
11588 (void *)&cmd_macsec_offload_on_encrypt,
11589 (void *)&cmd_macsec_offload_on_en_on_off,
11590 (void *)&cmd_macsec_offload_on_replay_protect,
11591 (void *)&cmd_macsec_offload_on_rp_on_off,
11596 /* Common result structure for MACsec offload disable */
11597 struct cmd_macsec_offload_off_result {
11598 cmdline_fixed_string_t set;
11599 cmdline_fixed_string_t macsec;
11600 cmdline_fixed_string_t offload;
11602 cmdline_fixed_string_t off;
11605 /* Common CLI fields for MACsec offload disable */
11606 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11607 TOKEN_STRING_INITIALIZER
11608 (struct cmd_macsec_offload_off_result,
11610 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11611 TOKEN_STRING_INITIALIZER
11612 (struct cmd_macsec_offload_off_result,
11614 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11615 TOKEN_STRING_INITIALIZER
11616 (struct cmd_macsec_offload_off_result,
11617 offload, "offload");
11618 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11619 TOKEN_NUM_INITIALIZER
11620 (struct cmd_macsec_offload_off_result,
11621 port_id, RTE_UINT16);
11622 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11623 TOKEN_STRING_INITIALIZER
11624 (struct cmd_macsec_offload_off_result,
11628 cmd_set_macsec_offload_off_parsed(
11629 void *parsed_result,
11630 __rte_unused struct cmdline *cl,
11631 __rte_unused void *data)
11633 struct cmd_macsec_offload_off_result *res = parsed_result;
11634 int ret = -ENOTSUP;
11635 struct rte_eth_dev_info dev_info;
11636 portid_t port_id = res->port_id;
11638 if (port_id_is_invalid(port_id, ENABLED_WARN))
11640 if (!port_is_stopped(port_id)) {
11641 fprintf(stderr, "Please stop port %d first\n", port_id);
11645 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11649 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11650 #ifdef RTE_NET_IXGBE
11651 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11656 ports[port_id].dev_conf.txmode.offloads &=
11657 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
11658 cmd_reconfig_device_queue(port_id, 1, 1);
11661 fprintf(stderr, "invalid port_id %d\n", port_id);
11664 fprintf(stderr, "not supported on port %d\n", port_id);
11667 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11671 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11672 .f = cmd_set_macsec_offload_off_parsed,
11674 .help_str = "set macsec offload <port_id> off",
11676 (void *)&cmd_macsec_offload_off_set,
11677 (void *)&cmd_macsec_offload_off_macsec,
11678 (void *)&cmd_macsec_offload_off_offload,
11679 (void *)&cmd_macsec_offload_off_port_id,
11680 (void *)&cmd_macsec_offload_off_off,
11685 /* Common result structure for MACsec secure connection configure */
11686 struct cmd_macsec_sc_result {
11687 cmdline_fixed_string_t set;
11688 cmdline_fixed_string_t macsec;
11689 cmdline_fixed_string_t sc;
11690 cmdline_fixed_string_t tx_rx;
11692 struct rte_ether_addr mac;
11696 /* Common CLI fields for MACsec secure connection configure */
11697 cmdline_parse_token_string_t cmd_macsec_sc_set =
11698 TOKEN_STRING_INITIALIZER
11699 (struct cmd_macsec_sc_result,
11701 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11702 TOKEN_STRING_INITIALIZER
11703 (struct cmd_macsec_sc_result,
11705 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11706 TOKEN_STRING_INITIALIZER
11707 (struct cmd_macsec_sc_result,
11709 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11710 TOKEN_STRING_INITIALIZER
11711 (struct cmd_macsec_sc_result,
11713 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11714 TOKEN_NUM_INITIALIZER
11715 (struct cmd_macsec_sc_result,
11716 port_id, RTE_UINT16);
11717 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11718 TOKEN_ETHERADDR_INITIALIZER
11719 (struct cmd_macsec_sc_result,
11721 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11722 TOKEN_NUM_INITIALIZER
11723 (struct cmd_macsec_sc_result,
11727 cmd_set_macsec_sc_parsed(
11728 void *parsed_result,
11729 __rte_unused struct cmdline *cl,
11730 __rte_unused void *data)
11732 struct cmd_macsec_sc_result *res = parsed_result;
11733 int ret = -ENOTSUP;
11734 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11736 #ifdef RTE_NET_IXGBE
11738 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11739 res->mac.addr_bytes) :
11740 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11741 res->mac.addr_bytes, res->pi);
11743 RTE_SET_USED(is_tx);
11749 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11752 fprintf(stderr, "not supported on port %d\n", res->port_id);
11755 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11759 cmdline_parse_inst_t cmd_set_macsec_sc = {
11760 .f = cmd_set_macsec_sc_parsed,
11762 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11764 (void *)&cmd_macsec_sc_set,
11765 (void *)&cmd_macsec_sc_macsec,
11766 (void *)&cmd_macsec_sc_sc,
11767 (void *)&cmd_macsec_sc_tx_rx,
11768 (void *)&cmd_macsec_sc_port_id,
11769 (void *)&cmd_macsec_sc_mac,
11770 (void *)&cmd_macsec_sc_pi,
11775 /* Common result structure for MACsec secure connection configure */
11776 struct cmd_macsec_sa_result {
11777 cmdline_fixed_string_t set;
11778 cmdline_fixed_string_t macsec;
11779 cmdline_fixed_string_t sa;
11780 cmdline_fixed_string_t tx_rx;
11785 cmdline_fixed_string_t key;
11788 /* Common CLI fields for MACsec secure connection configure */
11789 cmdline_parse_token_string_t cmd_macsec_sa_set =
11790 TOKEN_STRING_INITIALIZER
11791 (struct cmd_macsec_sa_result,
11793 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11794 TOKEN_STRING_INITIALIZER
11795 (struct cmd_macsec_sa_result,
11797 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11798 TOKEN_STRING_INITIALIZER
11799 (struct cmd_macsec_sa_result,
11801 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11802 TOKEN_STRING_INITIALIZER
11803 (struct cmd_macsec_sa_result,
11805 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11806 TOKEN_NUM_INITIALIZER
11807 (struct cmd_macsec_sa_result,
11808 port_id, RTE_UINT16);
11809 cmdline_parse_token_num_t cmd_macsec_sa_idx =
11810 TOKEN_NUM_INITIALIZER
11811 (struct cmd_macsec_sa_result,
11813 cmdline_parse_token_num_t cmd_macsec_sa_an =
11814 TOKEN_NUM_INITIALIZER
11815 (struct cmd_macsec_sa_result,
11817 cmdline_parse_token_num_t cmd_macsec_sa_pn =
11818 TOKEN_NUM_INITIALIZER
11819 (struct cmd_macsec_sa_result,
11821 cmdline_parse_token_string_t cmd_macsec_sa_key =
11822 TOKEN_STRING_INITIALIZER
11823 (struct cmd_macsec_sa_result,
11827 cmd_set_macsec_sa_parsed(
11828 void *parsed_result,
11829 __rte_unused struct cmdline *cl,
11830 __rte_unused void *data)
11832 struct cmd_macsec_sa_result *res = parsed_result;
11833 int ret = -ENOTSUP;
11834 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11835 uint8_t key[16] = { 0 };
11841 key_len = strlen(res->key) / 2;
11845 for (i = 0; i < key_len; i++) {
11846 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
11849 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
11852 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
11855 #ifdef RTE_NET_IXGBE
11857 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
11858 res->idx, res->an, res->pn, key) :
11859 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
11860 res->idx, res->an, res->pn, key);
11862 RTE_SET_USED(is_tx);
11869 fprintf(stderr, "invalid idx %d or an %d\n", res->idx, res->an);
11872 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11875 fprintf(stderr, "not supported on port %d\n", res->port_id);
11878 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11882 cmdline_parse_inst_t cmd_set_macsec_sa = {
11883 .f = cmd_set_macsec_sa_parsed,
11885 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
11887 (void *)&cmd_macsec_sa_set,
11888 (void *)&cmd_macsec_sa_macsec,
11889 (void *)&cmd_macsec_sa_sa,
11890 (void *)&cmd_macsec_sa_tx_rx,
11891 (void *)&cmd_macsec_sa_port_id,
11892 (void *)&cmd_macsec_sa_idx,
11893 (void *)&cmd_macsec_sa_an,
11894 (void *)&cmd_macsec_sa_pn,
11895 (void *)&cmd_macsec_sa_key,
11900 /* VF unicast promiscuous mode configuration */
11902 /* Common result structure for VF unicast promiscuous mode */
11903 struct cmd_vf_promisc_result {
11904 cmdline_fixed_string_t set;
11905 cmdline_fixed_string_t vf;
11906 cmdline_fixed_string_t promisc;
11909 cmdline_fixed_string_t on_off;
11912 /* Common CLI fields for VF unicast promiscuous mode enable disable */
11913 cmdline_parse_token_string_t cmd_vf_promisc_set =
11914 TOKEN_STRING_INITIALIZER
11915 (struct cmd_vf_promisc_result,
11917 cmdline_parse_token_string_t cmd_vf_promisc_vf =
11918 TOKEN_STRING_INITIALIZER
11919 (struct cmd_vf_promisc_result,
11921 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
11922 TOKEN_STRING_INITIALIZER
11923 (struct cmd_vf_promisc_result,
11924 promisc, "promisc");
11925 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
11926 TOKEN_NUM_INITIALIZER
11927 (struct cmd_vf_promisc_result,
11928 port_id, RTE_UINT16);
11929 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
11930 TOKEN_NUM_INITIALIZER
11931 (struct cmd_vf_promisc_result,
11932 vf_id, RTE_UINT32);
11933 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
11934 TOKEN_STRING_INITIALIZER
11935 (struct cmd_vf_promisc_result,
11939 cmd_set_vf_promisc_parsed(
11940 void *parsed_result,
11941 __rte_unused struct cmdline *cl,
11942 __rte_unused void *data)
11944 struct cmd_vf_promisc_result *res = parsed_result;
11945 int ret = -ENOTSUP;
11947 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11949 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11952 #ifdef RTE_NET_I40E
11953 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
11954 res->vf_id, is_on);
11961 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11964 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11967 fprintf(stderr, "function not implemented\n");
11970 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11974 cmdline_parse_inst_t cmd_set_vf_promisc = {
11975 .f = cmd_set_vf_promisc_parsed,
11977 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
11978 "Set unicast promiscuous mode for a VF from the PF",
11980 (void *)&cmd_vf_promisc_set,
11981 (void *)&cmd_vf_promisc_vf,
11982 (void *)&cmd_vf_promisc_promisc,
11983 (void *)&cmd_vf_promisc_port_id,
11984 (void *)&cmd_vf_promisc_vf_id,
11985 (void *)&cmd_vf_promisc_on_off,
11990 /* VF multicast promiscuous mode configuration */
11992 /* Common result structure for VF multicast promiscuous mode */
11993 struct cmd_vf_allmulti_result {
11994 cmdline_fixed_string_t set;
11995 cmdline_fixed_string_t vf;
11996 cmdline_fixed_string_t allmulti;
11999 cmdline_fixed_string_t on_off;
12002 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12003 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12004 TOKEN_STRING_INITIALIZER
12005 (struct cmd_vf_allmulti_result,
12007 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12008 TOKEN_STRING_INITIALIZER
12009 (struct cmd_vf_allmulti_result,
12011 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12012 TOKEN_STRING_INITIALIZER
12013 (struct cmd_vf_allmulti_result,
12014 allmulti, "allmulti");
12015 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12016 TOKEN_NUM_INITIALIZER
12017 (struct cmd_vf_allmulti_result,
12018 port_id, RTE_UINT16);
12019 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12020 TOKEN_NUM_INITIALIZER
12021 (struct cmd_vf_allmulti_result,
12022 vf_id, RTE_UINT32);
12023 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12024 TOKEN_STRING_INITIALIZER
12025 (struct cmd_vf_allmulti_result,
12029 cmd_set_vf_allmulti_parsed(
12030 void *parsed_result,
12031 __rte_unused struct cmdline *cl,
12032 __rte_unused void *data)
12034 struct cmd_vf_allmulti_result *res = parsed_result;
12035 int ret = -ENOTSUP;
12037 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12039 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12042 #ifdef RTE_NET_I40E
12043 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12044 res->vf_id, is_on);
12051 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12054 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12057 fprintf(stderr, "function not implemented\n");
12060 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12064 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12065 .f = cmd_set_vf_allmulti_parsed,
12067 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12068 "Set multicast promiscuous mode for a VF from the PF",
12070 (void *)&cmd_vf_allmulti_set,
12071 (void *)&cmd_vf_allmulti_vf,
12072 (void *)&cmd_vf_allmulti_allmulti,
12073 (void *)&cmd_vf_allmulti_port_id,
12074 (void *)&cmd_vf_allmulti_vf_id,
12075 (void *)&cmd_vf_allmulti_on_off,
12080 /* vf broadcast mode configuration */
12082 /* Common result structure for vf broadcast */
12083 struct cmd_set_vf_broadcast_result {
12084 cmdline_fixed_string_t set;
12085 cmdline_fixed_string_t vf;
12086 cmdline_fixed_string_t broadcast;
12089 cmdline_fixed_string_t on_off;
12092 /* Common CLI fields for vf broadcast enable disable */
12093 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12094 TOKEN_STRING_INITIALIZER
12095 (struct cmd_set_vf_broadcast_result,
12097 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12098 TOKEN_STRING_INITIALIZER
12099 (struct cmd_set_vf_broadcast_result,
12101 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12102 TOKEN_STRING_INITIALIZER
12103 (struct cmd_set_vf_broadcast_result,
12104 broadcast, "broadcast");
12105 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12106 TOKEN_NUM_INITIALIZER
12107 (struct cmd_set_vf_broadcast_result,
12108 port_id, RTE_UINT16);
12109 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12110 TOKEN_NUM_INITIALIZER
12111 (struct cmd_set_vf_broadcast_result,
12112 vf_id, RTE_UINT16);
12113 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12114 TOKEN_STRING_INITIALIZER
12115 (struct cmd_set_vf_broadcast_result,
12119 cmd_set_vf_broadcast_parsed(
12120 void *parsed_result,
12121 __rte_unused struct cmdline *cl,
12122 __rte_unused void *data)
12124 struct cmd_set_vf_broadcast_result *res = parsed_result;
12125 int ret = -ENOTSUP;
12127 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12129 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12132 #ifdef RTE_NET_I40E
12133 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12134 res->vf_id, is_on);
12141 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12142 res->vf_id, is_on);
12145 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12148 fprintf(stderr, "function not implemented\n");
12151 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12155 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12156 .f = cmd_set_vf_broadcast_parsed,
12158 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12160 (void *)&cmd_set_vf_broadcast_set,
12161 (void *)&cmd_set_vf_broadcast_vf,
12162 (void *)&cmd_set_vf_broadcast_broadcast,
12163 (void *)&cmd_set_vf_broadcast_port_id,
12164 (void *)&cmd_set_vf_broadcast_vf_id,
12165 (void *)&cmd_set_vf_broadcast_on_off,
12170 /* vf vlan tag configuration */
12172 /* Common result structure for vf vlan tag */
12173 struct cmd_set_vf_vlan_tag_result {
12174 cmdline_fixed_string_t set;
12175 cmdline_fixed_string_t vf;
12176 cmdline_fixed_string_t vlan;
12177 cmdline_fixed_string_t tag;
12180 cmdline_fixed_string_t on_off;
12183 /* Common CLI fields for vf vlan tag enable disable */
12184 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12185 TOKEN_STRING_INITIALIZER
12186 (struct cmd_set_vf_vlan_tag_result,
12188 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12189 TOKEN_STRING_INITIALIZER
12190 (struct cmd_set_vf_vlan_tag_result,
12192 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12193 TOKEN_STRING_INITIALIZER
12194 (struct cmd_set_vf_vlan_tag_result,
12196 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12197 TOKEN_STRING_INITIALIZER
12198 (struct cmd_set_vf_vlan_tag_result,
12200 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12201 TOKEN_NUM_INITIALIZER
12202 (struct cmd_set_vf_vlan_tag_result,
12203 port_id, RTE_UINT16);
12204 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12205 TOKEN_NUM_INITIALIZER
12206 (struct cmd_set_vf_vlan_tag_result,
12207 vf_id, RTE_UINT16);
12208 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12209 TOKEN_STRING_INITIALIZER
12210 (struct cmd_set_vf_vlan_tag_result,
12214 cmd_set_vf_vlan_tag_parsed(
12215 void *parsed_result,
12216 __rte_unused struct cmdline *cl,
12217 __rte_unused void *data)
12219 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12220 int ret = -ENOTSUP;
12222 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12224 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12227 #ifdef RTE_NET_I40E
12228 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12229 res->vf_id, is_on);
12236 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12237 res->vf_id, is_on);
12240 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12243 fprintf(stderr, "function not implemented\n");
12246 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12250 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12251 .f = cmd_set_vf_vlan_tag_parsed,
12253 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12255 (void *)&cmd_set_vf_vlan_tag_set,
12256 (void *)&cmd_set_vf_vlan_tag_vf,
12257 (void *)&cmd_set_vf_vlan_tag_vlan,
12258 (void *)&cmd_set_vf_vlan_tag_tag,
12259 (void *)&cmd_set_vf_vlan_tag_port_id,
12260 (void *)&cmd_set_vf_vlan_tag_vf_id,
12261 (void *)&cmd_set_vf_vlan_tag_on_off,
12266 /* Common definition of VF and TC TX bandwidth configuration */
12267 struct cmd_vf_tc_bw_result {
12268 cmdline_fixed_string_t set;
12269 cmdline_fixed_string_t vf;
12270 cmdline_fixed_string_t tc;
12271 cmdline_fixed_string_t tx;
12272 cmdline_fixed_string_t min_bw;
12273 cmdline_fixed_string_t max_bw;
12274 cmdline_fixed_string_t strict_link_prio;
12279 cmdline_fixed_string_t bw_list;
12283 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12284 TOKEN_STRING_INITIALIZER
12285 (struct cmd_vf_tc_bw_result,
12287 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12288 TOKEN_STRING_INITIALIZER
12289 (struct cmd_vf_tc_bw_result,
12291 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12292 TOKEN_STRING_INITIALIZER
12293 (struct cmd_vf_tc_bw_result,
12295 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12296 TOKEN_STRING_INITIALIZER
12297 (struct cmd_vf_tc_bw_result,
12299 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12300 TOKEN_STRING_INITIALIZER
12301 (struct cmd_vf_tc_bw_result,
12302 strict_link_prio, "strict-link-priority");
12303 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12304 TOKEN_STRING_INITIALIZER
12305 (struct cmd_vf_tc_bw_result,
12306 min_bw, "min-bandwidth");
12307 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12308 TOKEN_STRING_INITIALIZER
12309 (struct cmd_vf_tc_bw_result,
12310 max_bw, "max-bandwidth");
12311 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12312 TOKEN_NUM_INITIALIZER
12313 (struct cmd_vf_tc_bw_result,
12314 port_id, RTE_UINT16);
12315 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12316 TOKEN_NUM_INITIALIZER
12317 (struct cmd_vf_tc_bw_result,
12318 vf_id, RTE_UINT16);
12319 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12320 TOKEN_NUM_INITIALIZER
12321 (struct cmd_vf_tc_bw_result,
12323 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12324 TOKEN_NUM_INITIALIZER
12325 (struct cmd_vf_tc_bw_result,
12327 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12328 TOKEN_STRING_INITIALIZER
12329 (struct cmd_vf_tc_bw_result,
12331 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12332 TOKEN_NUM_INITIALIZER
12333 (struct cmd_vf_tc_bw_result,
12334 tc_map, RTE_UINT8);
12336 /* VF max bandwidth setting */
12338 cmd_vf_max_bw_parsed(
12339 void *parsed_result,
12340 __rte_unused struct cmdline *cl,
12341 __rte_unused void *data)
12343 struct cmd_vf_tc_bw_result *res = parsed_result;
12344 int ret = -ENOTSUP;
12346 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12349 #ifdef RTE_NET_I40E
12350 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12351 res->vf_id, res->bw);
12358 fprintf(stderr, "invalid vf_id %d or bandwidth %d\n",
12359 res->vf_id, res->bw);
12362 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12365 fprintf(stderr, "function not implemented\n");
12368 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12372 cmdline_parse_inst_t cmd_vf_max_bw = {
12373 .f = cmd_vf_max_bw_parsed,
12375 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12377 (void *)&cmd_vf_tc_bw_set,
12378 (void *)&cmd_vf_tc_bw_vf,
12379 (void *)&cmd_vf_tc_bw_tx,
12380 (void *)&cmd_vf_tc_bw_max_bw,
12381 (void *)&cmd_vf_tc_bw_port_id,
12382 (void *)&cmd_vf_tc_bw_vf_id,
12383 (void *)&cmd_vf_tc_bw_bw,
12389 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12394 const char *p, *p0 = str;
12401 p = strchr(p0, '(');
12404 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12408 p0 = strchr(p, ')');
12411 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12415 if (size >= sizeof(s)) {
12417 "The string size exceeds the internal buffer size\n");
12420 snprintf(s, sizeof(s), "%.*s", size, p);
12421 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12423 fprintf(stderr, "Failed to get the bandwidth list.\n");
12427 for (i = 0; i < ret; i++)
12428 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12433 /* TC min bandwidth setting */
12435 cmd_vf_tc_min_bw_parsed(
12436 void *parsed_result,
12437 __rte_unused struct cmdline *cl,
12438 __rte_unused void *data)
12440 struct cmd_vf_tc_bw_result *res = parsed_result;
12443 int ret = -ENOTSUP;
12445 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12448 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12452 #ifdef RTE_NET_I40E
12453 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12461 fprintf(stderr, "invalid vf_id %d or bandwidth\n", res->vf_id);
12464 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12467 fprintf(stderr, "function not implemented\n");
12470 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12474 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12475 .f = cmd_vf_tc_min_bw_parsed,
12477 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12478 " <bw1, bw2, ...>",
12480 (void *)&cmd_vf_tc_bw_set,
12481 (void *)&cmd_vf_tc_bw_vf,
12482 (void *)&cmd_vf_tc_bw_tc,
12483 (void *)&cmd_vf_tc_bw_tx,
12484 (void *)&cmd_vf_tc_bw_min_bw,
12485 (void *)&cmd_vf_tc_bw_port_id,
12486 (void *)&cmd_vf_tc_bw_vf_id,
12487 (void *)&cmd_vf_tc_bw_bw_list,
12493 cmd_tc_min_bw_parsed(
12494 void *parsed_result,
12495 __rte_unused struct cmdline *cl,
12496 __rte_unused void *data)
12498 struct cmd_vf_tc_bw_result *res = parsed_result;
12499 struct rte_port *port;
12502 int ret = -ENOTSUP;
12504 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12507 port = &ports[res->port_id];
12508 /** Check if the port is not started **/
12509 if (port->port_status != RTE_PORT_STOPPED) {
12510 fprintf(stderr, "Please stop port %d first\n", res->port_id);
12514 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12518 #ifdef RTE_NET_IXGBE
12519 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12526 fprintf(stderr, "invalid bandwidth\n");
12529 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12532 fprintf(stderr, "function not implemented\n");
12535 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12539 cmdline_parse_inst_t cmd_tc_min_bw = {
12540 .f = cmd_tc_min_bw_parsed,
12542 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12544 (void *)&cmd_vf_tc_bw_set,
12545 (void *)&cmd_vf_tc_bw_tc,
12546 (void *)&cmd_vf_tc_bw_tx,
12547 (void *)&cmd_vf_tc_bw_min_bw,
12548 (void *)&cmd_vf_tc_bw_port_id,
12549 (void *)&cmd_vf_tc_bw_bw_list,
12554 /* TC max bandwidth setting */
12556 cmd_vf_tc_max_bw_parsed(
12557 void *parsed_result,
12558 __rte_unused struct cmdline *cl,
12559 __rte_unused void *data)
12561 struct cmd_vf_tc_bw_result *res = parsed_result;
12562 int ret = -ENOTSUP;
12564 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12567 #ifdef RTE_NET_I40E
12568 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12569 res->tc_no, res->bw);
12577 "invalid vf_id %d, tc_no %d or bandwidth %d\n",
12578 res->vf_id, res->tc_no, res->bw);
12581 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12584 fprintf(stderr, "function not implemented\n");
12587 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12591 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12592 .f = cmd_vf_tc_max_bw_parsed,
12594 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12597 (void *)&cmd_vf_tc_bw_set,
12598 (void *)&cmd_vf_tc_bw_vf,
12599 (void *)&cmd_vf_tc_bw_tc,
12600 (void *)&cmd_vf_tc_bw_tx,
12601 (void *)&cmd_vf_tc_bw_max_bw,
12602 (void *)&cmd_vf_tc_bw_port_id,
12603 (void *)&cmd_vf_tc_bw_vf_id,
12604 (void *)&cmd_vf_tc_bw_tc_no,
12605 (void *)&cmd_vf_tc_bw_bw,
12610 /** Set VXLAN encapsulation details */
12611 struct cmd_set_vxlan_result {
12612 cmdline_fixed_string_t set;
12613 cmdline_fixed_string_t vxlan;
12614 cmdline_fixed_string_t pos_token;
12615 cmdline_fixed_string_t ip_version;
12616 uint32_t vlan_present:1;
12620 cmdline_ipaddr_t ip_src;
12621 cmdline_ipaddr_t ip_dst;
12625 struct rte_ether_addr eth_src;
12626 struct rte_ether_addr eth_dst;
12629 cmdline_parse_token_string_t cmd_set_vxlan_set =
12630 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
12631 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
12632 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
12633 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
12634 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12636 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
12637 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12638 "vxlan-with-vlan");
12639 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
12640 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12642 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
12643 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
12645 cmdline_parse_token_string_t cmd_set_vxlan_vni =
12646 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12648 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
12649 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
12650 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
12651 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12653 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
12654 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
12655 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
12656 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12658 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
12659 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
12660 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
12661 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12663 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
12664 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
12665 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
12666 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12668 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
12669 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
12670 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
12671 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12673 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
12674 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
12675 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
12676 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12678 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
12679 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
12680 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
12681 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12683 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
12684 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
12685 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
12686 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12688 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
12689 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
12690 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
12691 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12693 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
12694 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
12696 static void cmd_set_vxlan_parsed(void *parsed_result,
12697 __rte_unused struct cmdline *cl,
12698 __rte_unused void *data)
12700 struct cmd_set_vxlan_result *res = parsed_result;
12705 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
12708 vxlan_encap_conf.select_tos_ttl = 0;
12709 if (strcmp(res->vxlan, "vxlan") == 0)
12710 vxlan_encap_conf.select_vlan = 0;
12711 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
12712 vxlan_encap_conf.select_vlan = 1;
12713 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
12714 vxlan_encap_conf.select_vlan = 0;
12715 vxlan_encap_conf.select_tos_ttl = 1;
12717 if (strcmp(res->ip_version, "ipv4") == 0)
12718 vxlan_encap_conf.select_ipv4 = 1;
12719 else if (strcmp(res->ip_version, "ipv6") == 0)
12720 vxlan_encap_conf.select_ipv4 = 0;
12723 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
12724 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
12725 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
12726 vxlan_encap_conf.ip_tos = res->tos;
12727 vxlan_encap_conf.ip_ttl = res->ttl;
12728 if (vxlan_encap_conf.select_ipv4) {
12729 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
12730 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
12732 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
12733 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
12735 if (vxlan_encap_conf.select_vlan)
12736 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
12737 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
12738 RTE_ETHER_ADDR_LEN);
12739 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
12740 RTE_ETHER_ADDR_LEN);
12743 cmdline_parse_inst_t cmd_set_vxlan = {
12744 .f = cmd_set_vxlan_parsed,
12746 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
12747 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
12748 " eth-src <eth-src> eth-dst <eth-dst>",
12750 (void *)&cmd_set_vxlan_set,
12751 (void *)&cmd_set_vxlan_vxlan,
12752 (void *)&cmd_set_vxlan_ip_version,
12753 (void *)&cmd_set_vxlan_ip_version_value,
12754 (void *)&cmd_set_vxlan_vni,
12755 (void *)&cmd_set_vxlan_vni_value,
12756 (void *)&cmd_set_vxlan_udp_src,
12757 (void *)&cmd_set_vxlan_udp_src_value,
12758 (void *)&cmd_set_vxlan_udp_dst,
12759 (void *)&cmd_set_vxlan_udp_dst_value,
12760 (void *)&cmd_set_vxlan_ip_src,
12761 (void *)&cmd_set_vxlan_ip_src_value,
12762 (void *)&cmd_set_vxlan_ip_dst,
12763 (void *)&cmd_set_vxlan_ip_dst_value,
12764 (void *)&cmd_set_vxlan_eth_src,
12765 (void *)&cmd_set_vxlan_eth_src_value,
12766 (void *)&cmd_set_vxlan_eth_dst,
12767 (void *)&cmd_set_vxlan_eth_dst_value,
12772 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
12773 .f = cmd_set_vxlan_parsed,
12775 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
12776 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
12777 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
12778 " eth-dst <eth-dst>",
12780 (void *)&cmd_set_vxlan_set,
12781 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
12782 (void *)&cmd_set_vxlan_ip_version,
12783 (void *)&cmd_set_vxlan_ip_version_value,
12784 (void *)&cmd_set_vxlan_vni,
12785 (void *)&cmd_set_vxlan_vni_value,
12786 (void *)&cmd_set_vxlan_udp_src,
12787 (void *)&cmd_set_vxlan_udp_src_value,
12788 (void *)&cmd_set_vxlan_udp_dst,
12789 (void *)&cmd_set_vxlan_udp_dst_value,
12790 (void *)&cmd_set_vxlan_ip_tos,
12791 (void *)&cmd_set_vxlan_ip_tos_value,
12792 (void *)&cmd_set_vxlan_ip_ttl,
12793 (void *)&cmd_set_vxlan_ip_ttl_value,
12794 (void *)&cmd_set_vxlan_ip_src,
12795 (void *)&cmd_set_vxlan_ip_src_value,
12796 (void *)&cmd_set_vxlan_ip_dst,
12797 (void *)&cmd_set_vxlan_ip_dst_value,
12798 (void *)&cmd_set_vxlan_eth_src,
12799 (void *)&cmd_set_vxlan_eth_src_value,
12800 (void *)&cmd_set_vxlan_eth_dst,
12801 (void *)&cmd_set_vxlan_eth_dst_value,
12806 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
12807 .f = cmd_set_vxlan_parsed,
12809 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
12810 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
12811 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
12814 (void *)&cmd_set_vxlan_set,
12815 (void *)&cmd_set_vxlan_vxlan_with_vlan,
12816 (void *)&cmd_set_vxlan_ip_version,
12817 (void *)&cmd_set_vxlan_ip_version_value,
12818 (void *)&cmd_set_vxlan_vni,
12819 (void *)&cmd_set_vxlan_vni_value,
12820 (void *)&cmd_set_vxlan_udp_src,
12821 (void *)&cmd_set_vxlan_udp_src_value,
12822 (void *)&cmd_set_vxlan_udp_dst,
12823 (void *)&cmd_set_vxlan_udp_dst_value,
12824 (void *)&cmd_set_vxlan_ip_src,
12825 (void *)&cmd_set_vxlan_ip_src_value,
12826 (void *)&cmd_set_vxlan_ip_dst,
12827 (void *)&cmd_set_vxlan_ip_dst_value,
12828 (void *)&cmd_set_vxlan_vlan,
12829 (void *)&cmd_set_vxlan_vlan_value,
12830 (void *)&cmd_set_vxlan_eth_src,
12831 (void *)&cmd_set_vxlan_eth_src_value,
12832 (void *)&cmd_set_vxlan_eth_dst,
12833 (void *)&cmd_set_vxlan_eth_dst_value,
12838 /** Set NVGRE encapsulation details */
12839 struct cmd_set_nvgre_result {
12840 cmdline_fixed_string_t set;
12841 cmdline_fixed_string_t nvgre;
12842 cmdline_fixed_string_t pos_token;
12843 cmdline_fixed_string_t ip_version;
12845 cmdline_ipaddr_t ip_src;
12846 cmdline_ipaddr_t ip_dst;
12848 struct rte_ether_addr eth_src;
12849 struct rte_ether_addr eth_dst;
12852 cmdline_parse_token_string_t cmd_set_nvgre_set =
12853 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
12854 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
12855 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
12856 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
12857 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
12858 "nvgre-with-vlan");
12859 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
12860 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12862 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
12863 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
12865 cmdline_parse_token_string_t cmd_set_nvgre_tni =
12866 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12868 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
12869 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
12870 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
12871 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12873 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
12874 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
12875 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
12876 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12878 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
12879 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
12880 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
12881 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12883 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
12884 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
12885 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
12886 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12888 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
12889 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
12890 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
12891 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12893 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
12894 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
12896 static void cmd_set_nvgre_parsed(void *parsed_result,
12897 __rte_unused struct cmdline *cl,
12898 __rte_unused void *data)
12900 struct cmd_set_nvgre_result *res = parsed_result;
12902 uint32_t nvgre_tni;
12905 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
12908 if (strcmp(res->nvgre, "nvgre") == 0)
12909 nvgre_encap_conf.select_vlan = 0;
12910 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
12911 nvgre_encap_conf.select_vlan = 1;
12912 if (strcmp(res->ip_version, "ipv4") == 0)
12913 nvgre_encap_conf.select_ipv4 = 1;
12914 else if (strcmp(res->ip_version, "ipv6") == 0)
12915 nvgre_encap_conf.select_ipv4 = 0;
12918 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
12919 if (nvgre_encap_conf.select_ipv4) {
12920 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
12921 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
12923 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
12924 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
12926 if (nvgre_encap_conf.select_vlan)
12927 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
12928 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
12929 RTE_ETHER_ADDR_LEN);
12930 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
12931 RTE_ETHER_ADDR_LEN);
12934 cmdline_parse_inst_t cmd_set_nvgre = {
12935 .f = cmd_set_nvgre_parsed,
12937 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
12938 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
12939 " eth-dst <eth-dst>",
12941 (void *)&cmd_set_nvgre_set,
12942 (void *)&cmd_set_nvgre_nvgre,
12943 (void *)&cmd_set_nvgre_ip_version,
12944 (void *)&cmd_set_nvgre_ip_version_value,
12945 (void *)&cmd_set_nvgre_tni,
12946 (void *)&cmd_set_nvgre_tni_value,
12947 (void *)&cmd_set_nvgre_ip_src,
12948 (void *)&cmd_set_nvgre_ip_src_value,
12949 (void *)&cmd_set_nvgre_ip_dst,
12950 (void *)&cmd_set_nvgre_ip_dst_value,
12951 (void *)&cmd_set_nvgre_eth_src,
12952 (void *)&cmd_set_nvgre_eth_src_value,
12953 (void *)&cmd_set_nvgre_eth_dst,
12954 (void *)&cmd_set_nvgre_eth_dst_value,
12959 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
12960 .f = cmd_set_nvgre_parsed,
12962 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
12963 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
12964 " eth-src <eth-src> eth-dst <eth-dst>",
12966 (void *)&cmd_set_nvgre_set,
12967 (void *)&cmd_set_nvgre_nvgre_with_vlan,
12968 (void *)&cmd_set_nvgre_ip_version,
12969 (void *)&cmd_set_nvgre_ip_version_value,
12970 (void *)&cmd_set_nvgre_tni,
12971 (void *)&cmd_set_nvgre_tni_value,
12972 (void *)&cmd_set_nvgre_ip_src,
12973 (void *)&cmd_set_nvgre_ip_src_value,
12974 (void *)&cmd_set_nvgre_ip_dst,
12975 (void *)&cmd_set_nvgre_ip_dst_value,
12976 (void *)&cmd_set_nvgre_vlan,
12977 (void *)&cmd_set_nvgre_vlan_value,
12978 (void *)&cmd_set_nvgre_eth_src,
12979 (void *)&cmd_set_nvgre_eth_src_value,
12980 (void *)&cmd_set_nvgre_eth_dst,
12981 (void *)&cmd_set_nvgre_eth_dst_value,
12986 /** Set L2 encapsulation details */
12987 struct cmd_set_l2_encap_result {
12988 cmdline_fixed_string_t set;
12989 cmdline_fixed_string_t l2_encap;
12990 cmdline_fixed_string_t pos_token;
12991 cmdline_fixed_string_t ip_version;
12992 uint32_t vlan_present:1;
12994 struct rte_ether_addr eth_src;
12995 struct rte_ether_addr eth_dst;
12998 cmdline_parse_token_string_t cmd_set_l2_encap_set =
12999 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13000 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13001 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13002 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13003 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13004 "l2_encap-with-vlan");
13005 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13006 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13008 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13009 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13011 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13012 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13014 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13015 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13016 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13017 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13019 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13020 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13021 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13022 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13024 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13025 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13027 static void cmd_set_l2_encap_parsed(void *parsed_result,
13028 __rte_unused struct cmdline *cl,
13029 __rte_unused void *data)
13031 struct cmd_set_l2_encap_result *res = parsed_result;
13033 if (strcmp(res->l2_encap, "l2_encap") == 0)
13034 l2_encap_conf.select_vlan = 0;
13035 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13036 l2_encap_conf.select_vlan = 1;
13037 if (strcmp(res->ip_version, "ipv4") == 0)
13038 l2_encap_conf.select_ipv4 = 1;
13039 else if (strcmp(res->ip_version, "ipv6") == 0)
13040 l2_encap_conf.select_ipv4 = 0;
13043 if (l2_encap_conf.select_vlan)
13044 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13045 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13046 RTE_ETHER_ADDR_LEN);
13047 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13048 RTE_ETHER_ADDR_LEN);
13051 cmdline_parse_inst_t cmd_set_l2_encap = {
13052 .f = cmd_set_l2_encap_parsed,
13054 .help_str = "set l2_encap ip-version ipv4|ipv6"
13055 " eth-src <eth-src> eth-dst <eth-dst>",
13057 (void *)&cmd_set_l2_encap_set,
13058 (void *)&cmd_set_l2_encap_l2_encap,
13059 (void *)&cmd_set_l2_encap_ip_version,
13060 (void *)&cmd_set_l2_encap_ip_version_value,
13061 (void *)&cmd_set_l2_encap_eth_src,
13062 (void *)&cmd_set_l2_encap_eth_src_value,
13063 (void *)&cmd_set_l2_encap_eth_dst,
13064 (void *)&cmd_set_l2_encap_eth_dst_value,
13069 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13070 .f = cmd_set_l2_encap_parsed,
13072 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13073 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13075 (void *)&cmd_set_l2_encap_set,
13076 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13077 (void *)&cmd_set_l2_encap_ip_version,
13078 (void *)&cmd_set_l2_encap_ip_version_value,
13079 (void *)&cmd_set_l2_encap_vlan,
13080 (void *)&cmd_set_l2_encap_vlan_value,
13081 (void *)&cmd_set_l2_encap_eth_src,
13082 (void *)&cmd_set_l2_encap_eth_src_value,
13083 (void *)&cmd_set_l2_encap_eth_dst,
13084 (void *)&cmd_set_l2_encap_eth_dst_value,
13089 /** Set L2 decapsulation details */
13090 struct cmd_set_l2_decap_result {
13091 cmdline_fixed_string_t set;
13092 cmdline_fixed_string_t l2_decap;
13093 cmdline_fixed_string_t pos_token;
13094 uint32_t vlan_present:1;
13097 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13098 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13099 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13100 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13102 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13103 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13104 "l2_decap-with-vlan");
13106 static void cmd_set_l2_decap_parsed(void *parsed_result,
13107 __rte_unused struct cmdline *cl,
13108 __rte_unused void *data)
13110 struct cmd_set_l2_decap_result *res = parsed_result;
13112 if (strcmp(res->l2_decap, "l2_decap") == 0)
13113 l2_decap_conf.select_vlan = 0;
13114 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13115 l2_decap_conf.select_vlan = 1;
13118 cmdline_parse_inst_t cmd_set_l2_decap = {
13119 .f = cmd_set_l2_decap_parsed,
13121 .help_str = "set l2_decap",
13123 (void *)&cmd_set_l2_decap_set,
13124 (void *)&cmd_set_l2_decap_l2_decap,
13129 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13130 .f = cmd_set_l2_decap_parsed,
13132 .help_str = "set l2_decap-with-vlan",
13134 (void *)&cmd_set_l2_decap_set,
13135 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13140 /** Set MPLSoGRE encapsulation details */
13141 struct cmd_set_mplsogre_encap_result {
13142 cmdline_fixed_string_t set;
13143 cmdline_fixed_string_t mplsogre;
13144 cmdline_fixed_string_t pos_token;
13145 cmdline_fixed_string_t ip_version;
13146 uint32_t vlan_present:1;
13148 cmdline_ipaddr_t ip_src;
13149 cmdline_ipaddr_t ip_dst;
13151 struct rte_ether_addr eth_src;
13152 struct rte_ether_addr eth_dst;
13155 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13156 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13158 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13159 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13161 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13162 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13163 mplsogre, "mplsogre_encap-with-vlan");
13164 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13165 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13166 pos_token, "ip-version");
13167 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13168 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13169 ip_version, "ipv4#ipv6");
13170 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13171 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13172 pos_token, "label");
13173 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13174 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13176 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13177 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13178 pos_token, "ip-src");
13179 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13180 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13181 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13182 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13183 pos_token, "ip-dst");
13184 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13185 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13186 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13187 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13188 pos_token, "vlan-tci");
13189 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13190 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13192 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13193 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13194 pos_token, "eth-src");
13195 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13196 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13198 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13199 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13200 pos_token, "eth-dst");
13201 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13202 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13205 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13206 __rte_unused struct cmdline *cl,
13207 __rte_unused void *data)
13209 struct cmd_set_mplsogre_encap_result *res = parsed_result;
13211 uint32_t mplsogre_label;
13214 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13217 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13218 mplsogre_encap_conf.select_vlan = 0;
13219 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13220 mplsogre_encap_conf.select_vlan = 1;
13221 if (strcmp(res->ip_version, "ipv4") == 0)
13222 mplsogre_encap_conf.select_ipv4 = 1;
13223 else if (strcmp(res->ip_version, "ipv6") == 0)
13224 mplsogre_encap_conf.select_ipv4 = 0;
13227 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13228 if (mplsogre_encap_conf.select_ipv4) {
13229 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13230 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13232 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13233 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13235 if (mplsogre_encap_conf.select_vlan)
13236 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13237 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13238 RTE_ETHER_ADDR_LEN);
13239 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13240 RTE_ETHER_ADDR_LEN);
13243 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13244 .f = cmd_set_mplsogre_encap_parsed,
13246 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13247 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13248 " eth-dst <eth-dst>",
13250 (void *)&cmd_set_mplsogre_encap_set,
13251 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13252 (void *)&cmd_set_mplsogre_encap_ip_version,
13253 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13254 (void *)&cmd_set_mplsogre_encap_label,
13255 (void *)&cmd_set_mplsogre_encap_label_value,
13256 (void *)&cmd_set_mplsogre_encap_ip_src,
13257 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13258 (void *)&cmd_set_mplsogre_encap_ip_dst,
13259 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13260 (void *)&cmd_set_mplsogre_encap_eth_src,
13261 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13262 (void *)&cmd_set_mplsogre_encap_eth_dst,
13263 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13268 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13269 .f = cmd_set_mplsogre_encap_parsed,
13271 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13272 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
13273 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13275 (void *)&cmd_set_mplsogre_encap_set,
13276 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13277 (void *)&cmd_set_mplsogre_encap_ip_version,
13278 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13279 (void *)&cmd_set_mplsogre_encap_label,
13280 (void *)&cmd_set_mplsogre_encap_label_value,
13281 (void *)&cmd_set_mplsogre_encap_ip_src,
13282 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13283 (void *)&cmd_set_mplsogre_encap_ip_dst,
13284 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13285 (void *)&cmd_set_mplsogre_encap_vlan,
13286 (void *)&cmd_set_mplsogre_encap_vlan_value,
13287 (void *)&cmd_set_mplsogre_encap_eth_src,
13288 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13289 (void *)&cmd_set_mplsogre_encap_eth_dst,
13290 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13295 /** Set MPLSoGRE decapsulation details */
13296 struct cmd_set_mplsogre_decap_result {
13297 cmdline_fixed_string_t set;
13298 cmdline_fixed_string_t mplsogre;
13299 cmdline_fixed_string_t pos_token;
13300 cmdline_fixed_string_t ip_version;
13301 uint32_t vlan_present:1;
13304 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13305 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13307 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13308 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13310 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13311 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13312 mplsogre, "mplsogre_decap-with-vlan");
13313 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13314 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13315 pos_token, "ip-version");
13316 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13317 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13318 ip_version, "ipv4#ipv6");
13320 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13321 __rte_unused struct cmdline *cl,
13322 __rte_unused void *data)
13324 struct cmd_set_mplsogre_decap_result *res = parsed_result;
13326 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13327 mplsogre_decap_conf.select_vlan = 0;
13328 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13329 mplsogre_decap_conf.select_vlan = 1;
13330 if (strcmp(res->ip_version, "ipv4") == 0)
13331 mplsogre_decap_conf.select_ipv4 = 1;
13332 else if (strcmp(res->ip_version, "ipv6") == 0)
13333 mplsogre_decap_conf.select_ipv4 = 0;
13336 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13337 .f = cmd_set_mplsogre_decap_parsed,
13339 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13341 (void *)&cmd_set_mplsogre_decap_set,
13342 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13343 (void *)&cmd_set_mplsogre_decap_ip_version,
13344 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13349 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13350 .f = cmd_set_mplsogre_decap_parsed,
13352 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13354 (void *)&cmd_set_mplsogre_decap_set,
13355 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13356 (void *)&cmd_set_mplsogre_decap_ip_version,
13357 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13362 /** Set MPLSoUDP encapsulation details */
13363 struct cmd_set_mplsoudp_encap_result {
13364 cmdline_fixed_string_t set;
13365 cmdline_fixed_string_t mplsoudp;
13366 cmdline_fixed_string_t pos_token;
13367 cmdline_fixed_string_t ip_version;
13368 uint32_t vlan_present:1;
13372 cmdline_ipaddr_t ip_src;
13373 cmdline_ipaddr_t ip_dst;
13375 struct rte_ether_addr eth_src;
13376 struct rte_ether_addr eth_dst;
13379 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13380 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13382 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13383 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13385 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13386 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13387 mplsoudp, "mplsoudp_encap-with-vlan");
13388 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13389 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13390 pos_token, "ip-version");
13391 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13392 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13393 ip_version, "ipv4#ipv6");
13394 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13395 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13396 pos_token, "label");
13397 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13398 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13400 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13401 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13402 pos_token, "udp-src");
13403 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13404 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13406 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13407 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13408 pos_token, "udp-dst");
13409 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13410 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13412 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13413 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13414 pos_token, "ip-src");
13415 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13416 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13417 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13418 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13419 pos_token, "ip-dst");
13420 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13421 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13422 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13423 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13424 pos_token, "vlan-tci");
13425 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13426 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13428 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13429 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13430 pos_token, "eth-src");
13431 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13432 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13434 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13435 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13436 pos_token, "eth-dst");
13437 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13438 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13441 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13442 __rte_unused struct cmdline *cl,
13443 __rte_unused void *data)
13445 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13447 uint32_t mplsoudp_label;
13450 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13453 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13454 mplsoudp_encap_conf.select_vlan = 0;
13455 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13456 mplsoudp_encap_conf.select_vlan = 1;
13457 if (strcmp(res->ip_version, "ipv4") == 0)
13458 mplsoudp_encap_conf.select_ipv4 = 1;
13459 else if (strcmp(res->ip_version, "ipv6") == 0)
13460 mplsoudp_encap_conf.select_ipv4 = 0;
13463 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13464 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13465 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13466 if (mplsoudp_encap_conf.select_ipv4) {
13467 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13468 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13470 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13471 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13473 if (mplsoudp_encap_conf.select_vlan)
13474 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13475 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13476 RTE_ETHER_ADDR_LEN);
13477 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13478 RTE_ETHER_ADDR_LEN);
13481 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13482 .f = cmd_set_mplsoudp_encap_parsed,
13484 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13485 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13486 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13488 (void *)&cmd_set_mplsoudp_encap_set,
13489 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13490 (void *)&cmd_set_mplsoudp_encap_ip_version,
13491 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13492 (void *)&cmd_set_mplsoudp_encap_label,
13493 (void *)&cmd_set_mplsoudp_encap_label_value,
13494 (void *)&cmd_set_mplsoudp_encap_udp_src,
13495 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13496 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13497 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13498 (void *)&cmd_set_mplsoudp_encap_ip_src,
13499 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13500 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13501 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13502 (void *)&cmd_set_mplsoudp_encap_eth_src,
13503 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13504 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13505 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13510 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13511 .f = cmd_set_mplsoudp_encap_parsed,
13513 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13514 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
13515 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13516 " eth-src <eth-src> eth-dst <eth-dst>",
13518 (void *)&cmd_set_mplsoudp_encap_set,
13519 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13520 (void *)&cmd_set_mplsoudp_encap_ip_version,
13521 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13522 (void *)&cmd_set_mplsoudp_encap_label,
13523 (void *)&cmd_set_mplsoudp_encap_label_value,
13524 (void *)&cmd_set_mplsoudp_encap_udp_src,
13525 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13526 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13527 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13528 (void *)&cmd_set_mplsoudp_encap_ip_src,
13529 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13530 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13531 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13532 (void *)&cmd_set_mplsoudp_encap_vlan,
13533 (void *)&cmd_set_mplsoudp_encap_vlan_value,
13534 (void *)&cmd_set_mplsoudp_encap_eth_src,
13535 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13536 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13537 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13542 /** Set MPLSoUDP decapsulation details */
13543 struct cmd_set_mplsoudp_decap_result {
13544 cmdline_fixed_string_t set;
13545 cmdline_fixed_string_t mplsoudp;
13546 cmdline_fixed_string_t pos_token;
13547 cmdline_fixed_string_t ip_version;
13548 uint32_t vlan_present:1;
13551 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
13552 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
13554 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
13555 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
13557 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
13558 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13559 mplsoudp, "mplsoudp_decap-with-vlan");
13560 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
13561 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13562 pos_token, "ip-version");
13563 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
13564 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13565 ip_version, "ipv4#ipv6");
13567 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
13568 __rte_unused struct cmdline *cl,
13569 __rte_unused void *data)
13571 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
13573 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
13574 mplsoudp_decap_conf.select_vlan = 0;
13575 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
13576 mplsoudp_decap_conf.select_vlan = 1;
13577 if (strcmp(res->ip_version, "ipv4") == 0)
13578 mplsoudp_decap_conf.select_ipv4 = 1;
13579 else if (strcmp(res->ip_version, "ipv6") == 0)
13580 mplsoudp_decap_conf.select_ipv4 = 0;
13583 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
13584 .f = cmd_set_mplsoudp_decap_parsed,
13586 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
13588 (void *)&cmd_set_mplsoudp_decap_set,
13589 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
13590 (void *)&cmd_set_mplsoudp_decap_ip_version,
13591 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13596 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
13597 .f = cmd_set_mplsoudp_decap_parsed,
13599 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
13601 (void *)&cmd_set_mplsoudp_decap_set,
13602 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
13603 (void *)&cmd_set_mplsoudp_decap_ip_version,
13604 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13609 /** Set connection tracking object common details */
13610 struct cmd_set_conntrack_common_result {
13611 cmdline_fixed_string_t set;
13612 cmdline_fixed_string_t conntrack;
13613 cmdline_fixed_string_t common;
13614 cmdline_fixed_string_t peer;
13615 cmdline_fixed_string_t is_orig;
13616 cmdline_fixed_string_t enable;
13617 cmdline_fixed_string_t live;
13618 cmdline_fixed_string_t sack;
13619 cmdline_fixed_string_t cack;
13620 cmdline_fixed_string_t last_dir;
13621 cmdline_fixed_string_t liberal;
13622 cmdline_fixed_string_t state;
13623 cmdline_fixed_string_t max_ack_win;
13624 cmdline_fixed_string_t retrans;
13625 cmdline_fixed_string_t last_win;
13626 cmdline_fixed_string_t last_seq;
13627 cmdline_fixed_string_t last_ack;
13628 cmdline_fixed_string_t last_end;
13629 cmdline_fixed_string_t last_index;
13632 uint16_t peer_port;
13633 uint32_t is_original;
13648 cmdline_parse_token_string_t cmd_set_conntrack_set =
13649 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13651 cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
13652 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13653 conntrack, "conntrack");
13654 cmdline_parse_token_string_t cmd_set_conntrack_common_com =
13655 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13657 cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
13658 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13660 cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
13661 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13662 peer_port, RTE_UINT16);
13663 cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
13664 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13665 is_orig, "is_orig");
13666 cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
13667 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13668 is_original, RTE_UINT32);
13669 cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
13670 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13672 cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
13673 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13675 cmdline_parse_token_string_t cmd_set_conntrack_common_live =
13676 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13678 cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
13679 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13680 is_live, RTE_UINT32);
13681 cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
13682 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13684 cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
13685 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13686 s_ack, RTE_UINT32);
13687 cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
13688 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13690 cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
13691 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13692 c_ack, RTE_UINT32);
13693 cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
13694 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13695 last_dir, "last_dir");
13696 cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
13697 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13699 cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
13700 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13701 liberal, "liberal");
13702 cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
13703 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13705 cmdline_parse_token_string_t cmd_set_conntrack_common_state =
13706 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13708 cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
13709 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13711 cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
13712 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13713 max_ack_win, "max_ack_win");
13714 cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
13715 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13716 factor, RTE_UINT8);
13717 cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
13718 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13720 cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
13721 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13722 re_num, RTE_UINT8);
13723 cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
13724 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13725 last_win, "last_win");
13726 cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
13727 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13729 cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
13730 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13731 last_seq, "last_seq");
13732 cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
13733 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13735 cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
13736 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13737 last_ack, "last_ack");
13738 cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
13739 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13741 cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
13742 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13743 last_end, "last_end");
13744 cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
13745 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13747 cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
13748 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13749 last_index, "last_index");
13750 cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
13751 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13754 static void cmd_set_conntrack_common_parsed(void *parsed_result,
13755 __rte_unused struct cmdline *cl,
13756 __rte_unused void *data)
13758 struct cmd_set_conntrack_common_result *res = parsed_result;
13760 /* No need to swap to big endian. */
13761 conntrack_context.peer_port = res->peer_port;
13762 conntrack_context.is_original_dir = res->is_original;
13763 conntrack_context.enable = res->en;
13764 conntrack_context.live_connection = res->is_live;
13765 conntrack_context.selective_ack = res->s_ack;
13766 conntrack_context.challenge_ack_passed = res->c_ack;
13767 conntrack_context.last_direction = res->ld;
13768 conntrack_context.liberal_mode = res->lb;
13769 conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
13770 conntrack_context.max_ack_window = res->factor;
13771 conntrack_context.retransmission_limit = res->re_num;
13772 conntrack_context.last_window = res->lw;
13773 conntrack_context.last_index =
13774 (enum rte_flow_conntrack_tcp_last_index)res->li;
13775 conntrack_context.last_seq = res->ls;
13776 conntrack_context.last_ack = res->la;
13777 conntrack_context.last_end = res->le;
13780 cmdline_parse_inst_t cmd_set_conntrack_common = {
13781 .f = cmd_set_conntrack_common_parsed,
13783 .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
13784 " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
13785 " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
13786 " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
13787 " last_index <flag>",
13789 (void *)&cmd_set_conntrack_set,
13790 (void *)&cmd_set_conntrack_conntrack,
13791 (void *)&cmd_set_conntrack_common_com,
13792 (void *)&cmd_set_conntrack_common_peer,
13793 (void *)&cmd_set_conntrack_common_peer_value,
13794 (void *)&cmd_set_conntrack_common_is_orig,
13795 (void *)&cmd_set_conntrack_common_is_orig_value,
13796 (void *)&cmd_set_conntrack_common_enable,
13797 (void *)&cmd_set_conntrack_common_enable_value,
13798 (void *)&cmd_set_conntrack_common_live,
13799 (void *)&cmd_set_conntrack_common_live_value,
13800 (void *)&cmd_set_conntrack_common_sack,
13801 (void *)&cmd_set_conntrack_common_sack_value,
13802 (void *)&cmd_set_conntrack_common_cack,
13803 (void *)&cmd_set_conntrack_common_cack_value,
13804 (void *)&cmd_set_conntrack_common_last_dir,
13805 (void *)&cmd_set_conntrack_common_last_dir_value,
13806 (void *)&cmd_set_conntrack_common_liberal,
13807 (void *)&cmd_set_conntrack_common_liberal_value,
13808 (void *)&cmd_set_conntrack_common_state,
13809 (void *)&cmd_set_conntrack_common_state_value,
13810 (void *)&cmd_set_conntrack_common_max_ackwin,
13811 (void *)&cmd_set_conntrack_common_max_ackwin_value,
13812 (void *)&cmd_set_conntrack_common_retrans,
13813 (void *)&cmd_set_conntrack_common_retrans_value,
13814 (void *)&cmd_set_conntrack_common_last_win,
13815 (void *)&cmd_set_conntrack_common_last_win_value,
13816 (void *)&cmd_set_conntrack_common_last_seq,
13817 (void *)&cmd_set_conntrack_common_last_seq_value,
13818 (void *)&cmd_set_conntrack_common_last_ack,
13819 (void *)&cmd_set_conntrack_common_last_ack_value,
13820 (void *)&cmd_set_conntrack_common_last_end,
13821 (void *)&cmd_set_conntrack_common_last_end_value,
13822 (void *)&cmd_set_conntrack_common_last_index,
13823 (void *)&cmd_set_conntrack_common_last_index_value,
13828 /** Set connection tracking object both directions' details */
13829 struct cmd_set_conntrack_dir_result {
13830 cmdline_fixed_string_t set;
13831 cmdline_fixed_string_t conntrack;
13832 cmdline_fixed_string_t dir;
13833 cmdline_fixed_string_t scale;
13834 cmdline_fixed_string_t fin;
13835 cmdline_fixed_string_t ack_seen;
13836 cmdline_fixed_string_t unack;
13837 cmdline_fixed_string_t sent_end;
13838 cmdline_fixed_string_t reply_end;
13839 cmdline_fixed_string_t max_win;
13840 cmdline_fixed_string_t max_ack;
13851 cmdline_parse_token_string_t cmd_set_conntrack_dir_set =
13852 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13854 cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack =
13855 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13856 conntrack, "conntrack");
13857 cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
13858 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13860 cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
13861 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13863 cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
13864 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13865 factor, RTE_UINT32);
13866 cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
13867 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13869 cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
13870 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13872 cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
13873 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13874 ack_seen, "acked");
13875 cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
13876 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13878 cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
13879 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13880 unack, "unack_data");
13881 cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
13882 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13884 cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
13885 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13886 sent_end, "sent_end");
13887 cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
13888 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13890 cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
13891 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13892 reply_end, "reply_end");
13893 cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
13894 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13896 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
13897 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13898 max_win, "max_win");
13899 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
13900 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13902 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
13903 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
13904 max_ack, "max_ack");
13905 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
13906 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
13909 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
13910 __rte_unused struct cmdline *cl,
13911 __rte_unused void *data)
13913 struct cmd_set_conntrack_dir_result *res = parsed_result;
13914 struct rte_flow_tcp_dir_param *dir = NULL;
13916 if (strcmp(res->dir, "orig") == 0)
13917 dir = &conntrack_context.original_dir;
13918 else if (strcmp(res->dir, "rply") == 0)
13919 dir = &conntrack_context.reply_dir;
13922 dir->scale = res->factor;
13923 dir->close_initiated = res->f;
13924 dir->last_ack_seen = res->as;
13925 dir->data_unacked = res->un;
13926 dir->sent_end = res->se;
13927 dir->reply_end = res->re;
13928 dir->max_ack = res->ma;
13929 dir->max_win = res->mw;
13932 cmdline_parse_inst_t cmd_set_conntrack_dir = {
13933 .f = cmd_set_conntrack_dir_parsed,
13935 .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
13936 " acked <seen> unack_data <unack> sent_end <sent>"
13937 " reply_end <reply> max_win <win> max_ack <ack>",
13939 (void *)&cmd_set_conntrack_set,
13940 (void *)&cmd_set_conntrack_conntrack,
13941 (void *)&cmd_set_conntrack_dir_dir,
13942 (void *)&cmd_set_conntrack_dir_scale,
13943 (void *)&cmd_set_conntrack_dir_scale_value,
13944 (void *)&cmd_set_conntrack_dir_fin,
13945 (void *)&cmd_set_conntrack_dir_fin_value,
13946 (void *)&cmd_set_conntrack_dir_ack,
13947 (void *)&cmd_set_conntrack_dir_ack_value,
13948 (void *)&cmd_set_conntrack_dir_unack_data,
13949 (void *)&cmd_set_conntrack_dir_unack_data_value,
13950 (void *)&cmd_set_conntrack_dir_sent_end,
13951 (void *)&cmd_set_conntrack_dir_sent_end_value,
13952 (void *)&cmd_set_conntrack_dir_reply_end,
13953 (void *)&cmd_set_conntrack_dir_reply_end_value,
13954 (void *)&cmd_set_conntrack_dir_max_win,
13955 (void *)&cmd_set_conntrack_dir_max_win_value,
13956 (void *)&cmd_set_conntrack_dir_max_ack,
13957 (void *)&cmd_set_conntrack_dir_max_ack_value,
13962 /* Strict link priority scheduling mode setting */
13964 cmd_strict_link_prio_parsed(
13965 void *parsed_result,
13966 __rte_unused struct cmdline *cl,
13967 __rte_unused void *data)
13969 struct cmd_vf_tc_bw_result *res = parsed_result;
13970 int ret = -ENOTSUP;
13972 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13975 #ifdef RTE_NET_I40E
13976 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
13983 fprintf(stderr, "invalid tc_bitmap 0x%x\n", res->tc_map);
13986 fprintf(stderr, "invalid port_id %d\n", res->port_id);
13989 fprintf(stderr, "function not implemented\n");
13992 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
13996 cmdline_parse_inst_t cmd_strict_link_prio = {
13997 .f = cmd_strict_link_prio_parsed,
13999 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14001 (void *)&cmd_vf_tc_bw_set,
14002 (void *)&cmd_vf_tc_bw_tx,
14003 (void *)&cmd_vf_tc_bw_strict_link_prio,
14004 (void *)&cmd_vf_tc_bw_port_id,
14005 (void *)&cmd_vf_tc_bw_tc_map,
14010 /* Load dynamic device personalization*/
14011 struct cmd_ddp_add_result {
14012 cmdline_fixed_string_t ddp;
14013 cmdline_fixed_string_t add;
14018 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14019 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14020 cmdline_parse_token_string_t cmd_ddp_add_add =
14021 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14022 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14023 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
14025 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14026 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14029 cmd_ddp_add_parsed(
14030 void *parsed_result,
14031 __rte_unused struct cmdline *cl,
14032 __rte_unused void *data)
14034 struct cmd_ddp_add_result *res = parsed_result;
14040 int ret = -ENOTSUP;
14042 if (!all_ports_stopped()) {
14043 fprintf(stderr, "Please stop all ports first\n");
14047 filepath = strdup(res->filepath);
14048 if (filepath == NULL) {
14049 fprintf(stderr, "Failed to allocate memory\n");
14052 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14054 buff = open_file(file_fld[0], &size);
14056 free((void *)filepath);
14060 #ifdef RTE_NET_I40E
14061 if (ret == -ENOTSUP)
14062 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14064 RTE_PMD_I40E_PKG_OP_WR_ADD);
14067 if (ret == -EEXIST)
14068 fprintf(stderr, "Profile has already existed.\n");
14070 fprintf(stderr, "Failed to load profile.\n");
14071 else if (file_num == 2)
14072 save_file(file_fld[1], buff, size);
14075 free((void *)filepath);
14078 cmdline_parse_inst_t cmd_ddp_add = {
14079 .f = cmd_ddp_add_parsed,
14081 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14083 (void *)&cmd_ddp_add_ddp,
14084 (void *)&cmd_ddp_add_add,
14085 (void *)&cmd_ddp_add_port_id,
14086 (void *)&cmd_ddp_add_filepath,
14091 /* Delete dynamic device personalization*/
14092 struct cmd_ddp_del_result {
14093 cmdline_fixed_string_t ddp;
14094 cmdline_fixed_string_t del;
14099 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14100 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14101 cmdline_parse_token_string_t cmd_ddp_del_del =
14102 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14103 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14104 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
14105 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14106 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14109 cmd_ddp_del_parsed(
14110 void *parsed_result,
14111 __rte_unused struct cmdline *cl,
14112 __rte_unused void *data)
14114 struct cmd_ddp_del_result *res = parsed_result;
14117 int ret = -ENOTSUP;
14119 if (!all_ports_stopped()) {
14120 fprintf(stderr, "Please stop all ports first\n");
14124 buff = open_file(res->filepath, &size);
14128 #ifdef RTE_NET_I40E
14129 if (ret == -ENOTSUP)
14130 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14132 RTE_PMD_I40E_PKG_OP_WR_DEL);
14135 if (ret == -EACCES)
14136 fprintf(stderr, "Profile does not exist.\n");
14138 fprintf(stderr, "Failed to delete profile.\n");
14143 cmdline_parse_inst_t cmd_ddp_del = {
14144 .f = cmd_ddp_del_parsed,
14146 .help_str = "ddp del <port_id> <backup_profile_path>",
14148 (void *)&cmd_ddp_del_ddp,
14149 (void *)&cmd_ddp_del_del,
14150 (void *)&cmd_ddp_del_port_id,
14151 (void *)&cmd_ddp_del_filepath,
14156 /* Get dynamic device personalization profile info */
14157 struct cmd_ddp_info_result {
14158 cmdline_fixed_string_t ddp;
14159 cmdline_fixed_string_t get;
14160 cmdline_fixed_string_t info;
14164 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14165 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14166 cmdline_parse_token_string_t cmd_ddp_info_get =
14167 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14168 cmdline_parse_token_string_t cmd_ddp_info_info =
14169 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14170 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14171 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14174 cmd_ddp_info_parsed(
14175 void *parsed_result,
14176 __rte_unused struct cmdline *cl,
14177 __rte_unused void *data)
14179 struct cmd_ddp_info_result *res = parsed_result;
14182 int ret = -ENOTSUP;
14183 #ifdef RTE_NET_I40E
14186 uint32_t buff_size = 0;
14187 struct rte_pmd_i40e_profile_info info;
14188 uint32_t dev_num = 0;
14189 struct rte_pmd_i40e_ddp_device_id *devs;
14190 uint32_t proto_num = 0;
14191 struct rte_pmd_i40e_proto_info *proto = NULL;
14192 uint32_t pctype_num = 0;
14193 struct rte_pmd_i40e_ptype_info *pctype;
14194 uint32_t ptype_num = 0;
14195 struct rte_pmd_i40e_ptype_info *ptype;
14200 pkg = open_file(res->filepath, &pkg_size);
14204 #ifdef RTE_NET_I40E
14205 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14206 (uint8_t *)&info, sizeof(info),
14207 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14209 printf("Global Track id: 0x%x\n", info.track_id);
14210 printf("Global Version: %d.%d.%d.%d\n",
14211 info.version.major,
14212 info.version.minor,
14213 info.version.update,
14214 info.version.draft);
14215 printf("Global Package name: %s\n\n", info.name);
14218 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14219 (uint8_t *)&info, sizeof(info),
14220 RTE_PMD_I40E_PKG_INFO_HEADER);
14222 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14223 printf("i40e Profile Version: %d.%d.%d.%d\n",
14224 info.version.major,
14225 info.version.minor,
14226 info.version.update,
14227 info.version.draft);
14228 printf("i40e Profile name: %s\n\n", info.name);
14231 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14232 (uint8_t *)&buff_size, sizeof(buff_size),
14233 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14234 if (!ret && buff_size) {
14235 buff = (uint8_t *)malloc(buff_size);
14237 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14239 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14241 printf("Package Notes:\n%s\n\n", buff);
14246 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14247 (uint8_t *)&dev_num, sizeof(dev_num),
14248 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14249 if (!ret && dev_num) {
14250 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14251 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14253 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14254 (uint8_t *)devs, buff_size,
14255 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14257 printf("List of supported devices:\n");
14258 for (i = 0; i < dev_num; i++) {
14259 printf(" %04X:%04X %04X:%04X\n",
14260 devs[i].vendor_dev_id >> 16,
14261 devs[i].vendor_dev_id & 0xFFFF,
14262 devs[i].sub_vendor_dev_id >> 16,
14263 devs[i].sub_vendor_dev_id & 0xFFFF);
14271 /* get information about protocols and packet types */
14272 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14273 (uint8_t *)&proto_num, sizeof(proto_num),
14274 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14275 if (ret || !proto_num)
14276 goto no_print_return;
14278 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14279 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14281 goto no_print_return;
14283 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14285 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14287 printf("List of used protocols:\n");
14288 for (i = 0; i < proto_num; i++)
14289 printf(" %2u: %s\n", proto[i].proto_id,
14293 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14294 (uint8_t *)&pctype_num, sizeof(pctype_num),
14295 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14296 if (ret || !pctype_num)
14297 goto no_print_pctypes;
14299 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14300 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14302 goto no_print_pctypes;
14304 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14306 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14309 goto no_print_pctypes;
14312 printf("List of defined packet classification types:\n");
14313 for (i = 0; i < pctype_num; i++) {
14314 printf(" %2u:", pctype[i].ptype_id);
14315 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14316 proto_id = pctype[i].protocols[j];
14317 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14318 for (n = 0; n < proto_num; n++) {
14319 if (proto[n].proto_id == proto_id) {
14320 printf(" %s", proto[n].name);
14333 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14335 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14336 if (ret || !ptype_num)
14337 goto no_print_return;
14339 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14340 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14342 goto no_print_return;
14344 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14346 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14349 goto no_print_return;
14351 printf("List of defined packet types:\n");
14352 for (i = 0; i < ptype_num; i++) {
14353 printf(" %2u:", ptype[i].ptype_id);
14354 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14355 proto_id = ptype[i].protocols[j];
14356 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14357 for (n = 0; n < proto_num; n++) {
14358 if (proto[n].proto_id == proto_id) {
14359 printf(" %s", proto[n].name);
14375 if (ret == -ENOTSUP)
14376 fprintf(stderr, "Function not supported in PMD driver\n");
14380 cmdline_parse_inst_t cmd_ddp_get_info = {
14381 .f = cmd_ddp_info_parsed,
14383 .help_str = "ddp get info <profile_path>",
14385 (void *)&cmd_ddp_info_ddp,
14386 (void *)&cmd_ddp_info_get,
14387 (void *)&cmd_ddp_info_info,
14388 (void *)&cmd_ddp_info_filepath,
14393 /* Get dynamic device personalization profile info list*/
14394 #define PROFILE_INFO_SIZE 48
14395 #define MAX_PROFILE_NUM 16
14397 struct cmd_ddp_get_list_result {
14398 cmdline_fixed_string_t ddp;
14399 cmdline_fixed_string_t get;
14400 cmdline_fixed_string_t list;
14404 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14405 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14406 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14407 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14408 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14409 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14410 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14411 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14415 cmd_ddp_get_list_parsed(
14416 __rte_unused void *parsed_result,
14417 __rte_unused struct cmdline *cl,
14418 __rte_unused void *data)
14420 #ifdef RTE_NET_I40E
14421 struct cmd_ddp_get_list_result *res = parsed_result;
14422 struct rte_pmd_i40e_profile_list *p_list;
14423 struct rte_pmd_i40e_profile_info *p_info;
14428 int ret = -ENOTSUP;
14430 #ifdef RTE_NET_I40E
14431 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14432 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14434 fprintf(stderr, "%s: Failed to malloc buffer\n", __func__);
14438 if (ret == -ENOTSUP)
14439 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14440 (uint8_t *)p_list, size);
14443 p_num = p_list->p_count;
14444 printf("Profile number is: %d\n\n", p_num);
14446 for (i = 0; i < p_num; i++) {
14447 p_info = &p_list->p_info[i];
14448 printf("Profile %d:\n", i);
14449 printf("Track id: 0x%x\n", p_info->track_id);
14450 printf("Version: %d.%d.%d.%d\n",
14451 p_info->version.major,
14452 p_info->version.minor,
14453 p_info->version.update,
14454 p_info->version.draft);
14455 printf("Profile name: %s\n\n", p_info->name);
14463 fprintf(stderr, "Failed to get ddp list\n");
14466 cmdline_parse_inst_t cmd_ddp_get_list = {
14467 .f = cmd_ddp_get_list_parsed,
14469 .help_str = "ddp get list <port_id>",
14471 (void *)&cmd_ddp_get_list_ddp,
14472 (void *)&cmd_ddp_get_list_get,
14473 (void *)&cmd_ddp_get_list_list,
14474 (void *)&cmd_ddp_get_list_port_id,
14479 /* Configure input set */
14480 struct cmd_cfg_input_set_result {
14481 cmdline_fixed_string_t port;
14482 cmdline_fixed_string_t cfg;
14484 cmdline_fixed_string_t pctype;
14486 cmdline_fixed_string_t inset_type;
14487 cmdline_fixed_string_t opt;
14488 cmdline_fixed_string_t field;
14493 cmd_cfg_input_set_parsed(
14494 __rte_unused void *parsed_result,
14495 __rte_unused struct cmdline *cl,
14496 __rte_unused void *data)
14498 #ifdef RTE_NET_I40E
14499 struct cmd_cfg_input_set_result *res = parsed_result;
14500 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14501 struct rte_pmd_i40e_inset inset;
14503 int ret = -ENOTSUP;
14505 if (!all_ports_stopped()) {
14506 fprintf(stderr, "Please stop all ports first\n");
14510 #ifdef RTE_NET_I40E
14511 if (!strcmp(res->inset_type, "hash_inset"))
14512 inset_type = INSET_HASH;
14513 else if (!strcmp(res->inset_type, "fdir_inset"))
14514 inset_type = INSET_FDIR;
14515 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14516 inset_type = INSET_FDIR_FLX;
14517 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14518 &inset, inset_type);
14520 fprintf(stderr, "Failed to get input set.\n");
14524 if (!strcmp(res->opt, "get")) {
14525 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14528 printf("Field index %d is enabled.\n", res->field_idx);
14530 printf("Field index %d is disabled.\n", res->field_idx);
14532 } else if (!strcmp(res->opt, "set"))
14533 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14535 else if (!strcmp(res->opt, "clear"))
14536 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14539 fprintf(stderr, "Failed to configure input set field.\n");
14543 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14544 &inset, inset_type);
14546 fprintf(stderr, "Failed to set input set.\n");
14551 if (ret == -ENOTSUP)
14552 fprintf(stderr, "Function not supported\n");
14555 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14556 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14558 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14559 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14561 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14562 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14563 port_id, RTE_UINT16);
14564 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14565 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14567 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14568 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14569 pctype_id, RTE_UINT8);
14570 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14571 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14573 "hash_inset#fdir_inset#fdir_flx_inset");
14574 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14575 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14576 opt, "get#set#clear");
14577 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14578 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14580 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14581 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14582 field_idx, RTE_UINT8);
14584 cmdline_parse_inst_t cmd_cfg_input_set = {
14585 .f = cmd_cfg_input_set_parsed,
14587 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14588 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
14590 (void *)&cmd_cfg_input_set_port,
14591 (void *)&cmd_cfg_input_set_cfg,
14592 (void *)&cmd_cfg_input_set_port_id,
14593 (void *)&cmd_cfg_input_set_pctype,
14594 (void *)&cmd_cfg_input_set_pctype_id,
14595 (void *)&cmd_cfg_input_set_inset_type,
14596 (void *)&cmd_cfg_input_set_opt,
14597 (void *)&cmd_cfg_input_set_field,
14598 (void *)&cmd_cfg_input_set_field_idx,
14603 /* Clear input set */
14604 struct cmd_clear_input_set_result {
14605 cmdline_fixed_string_t port;
14606 cmdline_fixed_string_t cfg;
14608 cmdline_fixed_string_t pctype;
14610 cmdline_fixed_string_t inset_type;
14611 cmdline_fixed_string_t clear;
14612 cmdline_fixed_string_t all;
14616 cmd_clear_input_set_parsed(
14617 __rte_unused void *parsed_result,
14618 __rte_unused struct cmdline *cl,
14619 __rte_unused void *data)
14621 #ifdef RTE_NET_I40E
14622 struct cmd_clear_input_set_result *res = parsed_result;
14623 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14624 struct rte_pmd_i40e_inset inset;
14626 int ret = -ENOTSUP;
14628 if (!all_ports_stopped()) {
14629 fprintf(stderr, "Please stop all ports first\n");
14633 #ifdef RTE_NET_I40E
14634 if (!strcmp(res->inset_type, "hash_inset"))
14635 inset_type = INSET_HASH;
14636 else if (!strcmp(res->inset_type, "fdir_inset"))
14637 inset_type = INSET_FDIR;
14638 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14639 inset_type = INSET_FDIR_FLX;
14641 memset(&inset, 0, sizeof(inset));
14643 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14644 &inset, inset_type);
14646 fprintf(stderr, "Failed to clear input set.\n");
14652 if (ret == -ENOTSUP)
14653 fprintf(stderr, "Function not supported\n");
14656 cmdline_parse_token_string_t cmd_clear_input_set_port =
14657 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14659 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
14660 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14662 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
14663 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14664 port_id, RTE_UINT16);
14665 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
14666 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14668 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
14669 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14670 pctype_id, RTE_UINT8);
14671 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
14672 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14674 "hash_inset#fdir_inset#fdir_flx_inset");
14675 cmdline_parse_token_string_t cmd_clear_input_set_clear =
14676 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14678 cmdline_parse_token_string_t cmd_clear_input_set_all =
14679 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14682 cmdline_parse_inst_t cmd_clear_input_set = {
14683 .f = cmd_clear_input_set_parsed,
14685 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14686 "fdir_inset|fdir_flx_inset clear all",
14688 (void *)&cmd_clear_input_set_port,
14689 (void *)&cmd_clear_input_set_cfg,
14690 (void *)&cmd_clear_input_set_port_id,
14691 (void *)&cmd_clear_input_set_pctype,
14692 (void *)&cmd_clear_input_set_pctype_id,
14693 (void *)&cmd_clear_input_set_inset_type,
14694 (void *)&cmd_clear_input_set_clear,
14695 (void *)&cmd_clear_input_set_all,
14700 /* show vf stats */
14702 /* Common result structure for show vf stats */
14703 struct cmd_show_vf_stats_result {
14704 cmdline_fixed_string_t show;
14705 cmdline_fixed_string_t vf;
14706 cmdline_fixed_string_t stats;
14711 /* Common CLI fields show vf stats*/
14712 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14713 TOKEN_STRING_INITIALIZER
14714 (struct cmd_show_vf_stats_result,
14716 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14717 TOKEN_STRING_INITIALIZER
14718 (struct cmd_show_vf_stats_result,
14720 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14721 TOKEN_STRING_INITIALIZER
14722 (struct cmd_show_vf_stats_result,
14724 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14725 TOKEN_NUM_INITIALIZER
14726 (struct cmd_show_vf_stats_result,
14727 port_id, RTE_UINT16);
14728 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14729 TOKEN_NUM_INITIALIZER
14730 (struct cmd_show_vf_stats_result,
14731 vf_id, RTE_UINT16);
14734 cmd_show_vf_stats_parsed(
14735 void *parsed_result,
14736 __rte_unused struct cmdline *cl,
14737 __rte_unused void *data)
14739 struct cmd_show_vf_stats_result *res = parsed_result;
14740 struct rte_eth_stats stats;
14741 int ret = -ENOTSUP;
14742 static const char *nic_stats_border = "########################";
14744 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14747 memset(&stats, 0, sizeof(stats));
14749 #ifdef RTE_NET_I40E
14750 if (ret == -ENOTSUP)
14751 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14755 #ifdef RTE_NET_BNXT
14756 if (ret == -ENOTSUP)
14757 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14766 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
14769 fprintf(stderr, "invalid port_id %d\n", res->port_id);
14772 fprintf(stderr, "function not implemented\n");
14775 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
14778 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14779 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14781 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14783 stats.ipackets, stats.imissed, stats.ibytes);
14784 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14785 printf(" RX-nombuf: %-10"PRIu64"\n",
14787 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14789 stats.opackets, stats.oerrors, stats.obytes);
14791 printf(" %s############################%s\n",
14792 nic_stats_border, nic_stats_border);
14795 cmdline_parse_inst_t cmd_show_vf_stats = {
14796 .f = cmd_show_vf_stats_parsed,
14798 .help_str = "show vf stats <port_id> <vf_id>",
14800 (void *)&cmd_show_vf_stats_show,
14801 (void *)&cmd_show_vf_stats_vf,
14802 (void *)&cmd_show_vf_stats_stats,
14803 (void *)&cmd_show_vf_stats_port_id,
14804 (void *)&cmd_show_vf_stats_vf_id,
14809 /* clear vf stats */
14811 /* Common result structure for clear vf stats */
14812 struct cmd_clear_vf_stats_result {
14813 cmdline_fixed_string_t clear;
14814 cmdline_fixed_string_t vf;
14815 cmdline_fixed_string_t stats;
14820 /* Common CLI fields clear vf stats*/
14821 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14822 TOKEN_STRING_INITIALIZER
14823 (struct cmd_clear_vf_stats_result,
14825 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
14826 TOKEN_STRING_INITIALIZER
14827 (struct cmd_clear_vf_stats_result,
14829 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
14830 TOKEN_STRING_INITIALIZER
14831 (struct cmd_clear_vf_stats_result,
14833 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
14834 TOKEN_NUM_INITIALIZER
14835 (struct cmd_clear_vf_stats_result,
14836 port_id, RTE_UINT16);
14837 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
14838 TOKEN_NUM_INITIALIZER
14839 (struct cmd_clear_vf_stats_result,
14840 vf_id, RTE_UINT16);
14843 cmd_clear_vf_stats_parsed(
14844 void *parsed_result,
14845 __rte_unused struct cmdline *cl,
14846 __rte_unused void *data)
14848 struct cmd_clear_vf_stats_result *res = parsed_result;
14849 int ret = -ENOTSUP;
14851 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14854 #ifdef RTE_NET_I40E
14855 if (ret == -ENOTSUP)
14856 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
14859 #ifdef RTE_NET_BNXT
14860 if (ret == -ENOTSUP)
14861 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
14869 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
14872 fprintf(stderr, "invalid port_id %d\n", res->port_id);
14875 fprintf(stderr, "function not implemented\n");
14878 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
14882 cmdline_parse_inst_t cmd_clear_vf_stats = {
14883 .f = cmd_clear_vf_stats_parsed,
14885 .help_str = "clear vf stats <port_id> <vf_id>",
14887 (void *)&cmd_clear_vf_stats_clear,
14888 (void *)&cmd_clear_vf_stats_vf,
14889 (void *)&cmd_clear_vf_stats_stats,
14890 (void *)&cmd_clear_vf_stats_port_id,
14891 (void *)&cmd_clear_vf_stats_vf_id,
14896 /* port config pctype mapping reset */
14898 /* Common result structure for port config pctype mapping reset */
14899 struct cmd_pctype_mapping_reset_result {
14900 cmdline_fixed_string_t port;
14901 cmdline_fixed_string_t config;
14903 cmdline_fixed_string_t pctype;
14904 cmdline_fixed_string_t mapping;
14905 cmdline_fixed_string_t reset;
14908 /* Common CLI fields for port config pctype mapping reset*/
14909 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
14910 TOKEN_STRING_INITIALIZER
14911 (struct cmd_pctype_mapping_reset_result,
14913 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
14914 TOKEN_STRING_INITIALIZER
14915 (struct cmd_pctype_mapping_reset_result,
14917 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
14918 TOKEN_NUM_INITIALIZER
14919 (struct cmd_pctype_mapping_reset_result,
14920 port_id, RTE_UINT16);
14921 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
14922 TOKEN_STRING_INITIALIZER
14923 (struct cmd_pctype_mapping_reset_result,
14925 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
14926 TOKEN_STRING_INITIALIZER
14927 (struct cmd_pctype_mapping_reset_result,
14928 mapping, "mapping");
14929 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
14930 TOKEN_STRING_INITIALIZER
14931 (struct cmd_pctype_mapping_reset_result,
14935 cmd_pctype_mapping_reset_parsed(
14936 void *parsed_result,
14937 __rte_unused struct cmdline *cl,
14938 __rte_unused void *data)
14940 struct cmd_pctype_mapping_reset_result *res = parsed_result;
14941 int ret = -ENOTSUP;
14943 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14946 #ifdef RTE_NET_I40E
14947 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
14954 fprintf(stderr, "invalid port_id %d\n", res->port_id);
14957 fprintf(stderr, "function not implemented\n");
14960 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
14964 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
14965 .f = cmd_pctype_mapping_reset_parsed,
14967 .help_str = "port config <port_id> pctype mapping reset",
14969 (void *)&cmd_pctype_mapping_reset_port,
14970 (void *)&cmd_pctype_mapping_reset_config,
14971 (void *)&cmd_pctype_mapping_reset_port_id,
14972 (void *)&cmd_pctype_mapping_reset_pctype,
14973 (void *)&cmd_pctype_mapping_reset_mapping,
14974 (void *)&cmd_pctype_mapping_reset_reset,
14979 /* show port pctype mapping */
14981 /* Common result structure for show port pctype mapping */
14982 struct cmd_pctype_mapping_get_result {
14983 cmdline_fixed_string_t show;
14984 cmdline_fixed_string_t port;
14986 cmdline_fixed_string_t pctype;
14987 cmdline_fixed_string_t mapping;
14990 /* Common CLI fields for pctype mapping get */
14991 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
14992 TOKEN_STRING_INITIALIZER
14993 (struct cmd_pctype_mapping_get_result,
14995 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
14996 TOKEN_STRING_INITIALIZER
14997 (struct cmd_pctype_mapping_get_result,
14999 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15000 TOKEN_NUM_INITIALIZER
15001 (struct cmd_pctype_mapping_get_result,
15002 port_id, RTE_UINT16);
15003 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15004 TOKEN_STRING_INITIALIZER
15005 (struct cmd_pctype_mapping_get_result,
15007 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15008 TOKEN_STRING_INITIALIZER
15009 (struct cmd_pctype_mapping_get_result,
15010 mapping, "mapping");
15013 cmd_pctype_mapping_get_parsed(
15014 void *parsed_result,
15015 __rte_unused struct cmdline *cl,
15016 __rte_unused void *data)
15018 struct cmd_pctype_mapping_get_result *res = parsed_result;
15019 int ret = -ENOTSUP;
15020 #ifdef RTE_NET_I40E
15021 struct rte_pmd_i40e_flow_type_mapping
15022 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15023 int i, j, first_pctype;
15026 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15029 #ifdef RTE_NET_I40E
15030 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15037 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15040 fprintf(stderr, "function not implemented\n");
15043 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15047 #ifdef RTE_NET_I40E
15048 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15049 if (mapping[i].pctype != 0ULL) {
15052 printf("pctype: ");
15053 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15054 if (mapping[i].pctype & (1ULL << j)) {
15055 printf(first_pctype ?
15056 "%02d" : ",%02d", j);
15060 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15066 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15067 .f = cmd_pctype_mapping_get_parsed,
15069 .help_str = "show port <port_id> pctype mapping",
15071 (void *)&cmd_pctype_mapping_get_show,
15072 (void *)&cmd_pctype_mapping_get_port,
15073 (void *)&cmd_pctype_mapping_get_port_id,
15074 (void *)&cmd_pctype_mapping_get_pctype,
15075 (void *)&cmd_pctype_mapping_get_mapping,
15080 /* port config pctype mapping update */
15082 /* Common result structure for port config pctype mapping update */
15083 struct cmd_pctype_mapping_update_result {
15084 cmdline_fixed_string_t port;
15085 cmdline_fixed_string_t config;
15087 cmdline_fixed_string_t pctype;
15088 cmdline_fixed_string_t mapping;
15089 cmdline_fixed_string_t update;
15090 cmdline_fixed_string_t pctype_list;
15091 uint16_t flow_type;
15094 /* Common CLI fields for pctype mapping update*/
15095 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15096 TOKEN_STRING_INITIALIZER
15097 (struct cmd_pctype_mapping_update_result,
15099 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15100 TOKEN_STRING_INITIALIZER
15101 (struct cmd_pctype_mapping_update_result,
15103 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15104 TOKEN_NUM_INITIALIZER
15105 (struct cmd_pctype_mapping_update_result,
15106 port_id, RTE_UINT16);
15107 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15108 TOKEN_STRING_INITIALIZER
15109 (struct cmd_pctype_mapping_update_result,
15111 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15112 TOKEN_STRING_INITIALIZER
15113 (struct cmd_pctype_mapping_update_result,
15114 mapping, "mapping");
15115 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15116 TOKEN_STRING_INITIALIZER
15117 (struct cmd_pctype_mapping_update_result,
15119 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15120 TOKEN_STRING_INITIALIZER
15121 (struct cmd_pctype_mapping_update_result,
15122 pctype_list, NULL);
15123 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15124 TOKEN_NUM_INITIALIZER
15125 (struct cmd_pctype_mapping_update_result,
15126 flow_type, RTE_UINT16);
15129 cmd_pctype_mapping_update_parsed(
15130 void *parsed_result,
15131 __rte_unused struct cmdline *cl,
15132 __rte_unused void *data)
15134 struct cmd_pctype_mapping_update_result *res = parsed_result;
15135 int ret = -ENOTSUP;
15136 #ifdef RTE_NET_I40E
15137 struct rte_pmd_i40e_flow_type_mapping mapping;
15139 unsigned int nb_item;
15140 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15143 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15146 #ifdef RTE_NET_I40E
15147 nb_item = parse_item_list(res->pctype_list, "pctypes",
15148 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15149 mapping.flow_type = res->flow_type;
15150 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15151 mapping.pctype |= (1ULL << pctype_list[i]);
15152 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15162 fprintf(stderr, "invalid pctype or flow type\n");
15165 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15168 fprintf(stderr, "function not implemented\n");
15171 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15175 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15176 .f = cmd_pctype_mapping_update_parsed,
15178 .help_str = "port config <port_id> pctype mapping update"
15179 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15181 (void *)&cmd_pctype_mapping_update_port,
15182 (void *)&cmd_pctype_mapping_update_config,
15183 (void *)&cmd_pctype_mapping_update_port_id,
15184 (void *)&cmd_pctype_mapping_update_pctype,
15185 (void *)&cmd_pctype_mapping_update_mapping,
15186 (void *)&cmd_pctype_mapping_update_update,
15187 (void *)&cmd_pctype_mapping_update_pc_type,
15188 (void *)&cmd_pctype_mapping_update_flow_type,
15193 /* ptype mapping get */
15195 /* Common result structure for ptype mapping get */
15196 struct cmd_ptype_mapping_get_result {
15197 cmdline_fixed_string_t ptype;
15198 cmdline_fixed_string_t mapping;
15199 cmdline_fixed_string_t get;
15201 uint8_t valid_only;
15204 /* Common CLI fields for ptype mapping get */
15205 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15206 TOKEN_STRING_INITIALIZER
15207 (struct cmd_ptype_mapping_get_result,
15209 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15210 TOKEN_STRING_INITIALIZER
15211 (struct cmd_ptype_mapping_get_result,
15212 mapping, "mapping");
15213 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15214 TOKEN_STRING_INITIALIZER
15215 (struct cmd_ptype_mapping_get_result,
15217 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15218 TOKEN_NUM_INITIALIZER
15219 (struct cmd_ptype_mapping_get_result,
15220 port_id, RTE_UINT16);
15221 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15222 TOKEN_NUM_INITIALIZER
15223 (struct cmd_ptype_mapping_get_result,
15224 valid_only, RTE_UINT8);
15227 cmd_ptype_mapping_get_parsed(
15228 void *parsed_result,
15229 __rte_unused struct cmdline *cl,
15230 __rte_unused void *data)
15232 struct cmd_ptype_mapping_get_result *res = parsed_result;
15233 int ret = -ENOTSUP;
15234 #ifdef RTE_NET_I40E
15235 int max_ptype_num = 256;
15236 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15241 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15244 #ifdef RTE_NET_I40E
15245 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15256 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15259 fprintf(stderr, "function not implemented\n");
15262 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15265 #ifdef RTE_NET_I40E
15267 for (i = 0; i < count; i++)
15268 printf("%3d\t0x%08x\n",
15269 mapping[i].hw_ptype, mapping[i].sw_ptype);
15274 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15275 .f = cmd_ptype_mapping_get_parsed,
15277 .help_str = "ptype mapping get <port_id> <valid_only>",
15279 (void *)&cmd_ptype_mapping_get_ptype,
15280 (void *)&cmd_ptype_mapping_get_mapping,
15281 (void *)&cmd_ptype_mapping_get_get,
15282 (void *)&cmd_ptype_mapping_get_port_id,
15283 (void *)&cmd_ptype_mapping_get_valid_only,
15288 /* ptype mapping replace */
15290 /* Common result structure for ptype mapping replace */
15291 struct cmd_ptype_mapping_replace_result {
15292 cmdline_fixed_string_t ptype;
15293 cmdline_fixed_string_t mapping;
15294 cmdline_fixed_string_t replace;
15301 /* Common CLI fields for ptype mapping replace */
15302 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15303 TOKEN_STRING_INITIALIZER
15304 (struct cmd_ptype_mapping_replace_result,
15306 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15307 TOKEN_STRING_INITIALIZER
15308 (struct cmd_ptype_mapping_replace_result,
15309 mapping, "mapping");
15310 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15311 TOKEN_STRING_INITIALIZER
15312 (struct cmd_ptype_mapping_replace_result,
15313 replace, "replace");
15314 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15315 TOKEN_NUM_INITIALIZER
15316 (struct cmd_ptype_mapping_replace_result,
15317 port_id, RTE_UINT16);
15318 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15319 TOKEN_NUM_INITIALIZER
15320 (struct cmd_ptype_mapping_replace_result,
15321 target, RTE_UINT32);
15322 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15323 TOKEN_NUM_INITIALIZER
15324 (struct cmd_ptype_mapping_replace_result,
15326 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15327 TOKEN_NUM_INITIALIZER
15328 (struct cmd_ptype_mapping_replace_result,
15329 pkt_type, RTE_UINT32);
15332 cmd_ptype_mapping_replace_parsed(
15333 void *parsed_result,
15334 __rte_unused struct cmdline *cl,
15335 __rte_unused void *data)
15337 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15338 int ret = -ENOTSUP;
15340 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15343 #ifdef RTE_NET_I40E
15344 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15354 fprintf(stderr, "invalid ptype 0x%8x or 0x%8x\n",
15355 res->target, res->pkt_type);
15358 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15361 fprintf(stderr, "function not implemented\n");
15364 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15368 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15369 .f = cmd_ptype_mapping_replace_parsed,
15372 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15374 (void *)&cmd_ptype_mapping_replace_ptype,
15375 (void *)&cmd_ptype_mapping_replace_mapping,
15376 (void *)&cmd_ptype_mapping_replace_replace,
15377 (void *)&cmd_ptype_mapping_replace_port_id,
15378 (void *)&cmd_ptype_mapping_replace_target,
15379 (void *)&cmd_ptype_mapping_replace_mask,
15380 (void *)&cmd_ptype_mapping_replace_pkt_type,
15385 /* ptype mapping reset */
15387 /* Common result structure for ptype mapping reset */
15388 struct cmd_ptype_mapping_reset_result {
15389 cmdline_fixed_string_t ptype;
15390 cmdline_fixed_string_t mapping;
15391 cmdline_fixed_string_t reset;
15395 /* Common CLI fields for ptype mapping reset*/
15396 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15397 TOKEN_STRING_INITIALIZER
15398 (struct cmd_ptype_mapping_reset_result,
15400 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15401 TOKEN_STRING_INITIALIZER
15402 (struct cmd_ptype_mapping_reset_result,
15403 mapping, "mapping");
15404 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15405 TOKEN_STRING_INITIALIZER
15406 (struct cmd_ptype_mapping_reset_result,
15408 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15409 TOKEN_NUM_INITIALIZER
15410 (struct cmd_ptype_mapping_reset_result,
15411 port_id, RTE_UINT16);
15414 cmd_ptype_mapping_reset_parsed(
15415 void *parsed_result,
15416 __rte_unused struct cmdline *cl,
15417 __rte_unused void *data)
15419 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15420 int ret = -ENOTSUP;
15422 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15425 #ifdef RTE_NET_I40E
15426 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15433 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15436 fprintf(stderr, "function not implemented\n");
15439 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15443 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15444 .f = cmd_ptype_mapping_reset_parsed,
15446 .help_str = "ptype mapping reset <port_id>",
15448 (void *)&cmd_ptype_mapping_reset_ptype,
15449 (void *)&cmd_ptype_mapping_reset_mapping,
15450 (void *)&cmd_ptype_mapping_reset_reset,
15451 (void *)&cmd_ptype_mapping_reset_port_id,
15456 /* ptype mapping update */
15458 /* Common result structure for ptype mapping update */
15459 struct cmd_ptype_mapping_update_result {
15460 cmdline_fixed_string_t ptype;
15461 cmdline_fixed_string_t mapping;
15462 cmdline_fixed_string_t reset;
15468 /* Common CLI fields for ptype mapping update*/
15469 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15470 TOKEN_STRING_INITIALIZER
15471 (struct cmd_ptype_mapping_update_result,
15473 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15474 TOKEN_STRING_INITIALIZER
15475 (struct cmd_ptype_mapping_update_result,
15476 mapping, "mapping");
15477 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15478 TOKEN_STRING_INITIALIZER
15479 (struct cmd_ptype_mapping_update_result,
15481 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15482 TOKEN_NUM_INITIALIZER
15483 (struct cmd_ptype_mapping_update_result,
15484 port_id, RTE_UINT16);
15485 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15486 TOKEN_NUM_INITIALIZER
15487 (struct cmd_ptype_mapping_update_result,
15488 hw_ptype, RTE_UINT8);
15489 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15490 TOKEN_NUM_INITIALIZER
15491 (struct cmd_ptype_mapping_update_result,
15492 sw_ptype, RTE_UINT32);
15495 cmd_ptype_mapping_update_parsed(
15496 void *parsed_result,
15497 __rte_unused struct cmdline *cl,
15498 __rte_unused void *data)
15500 struct cmd_ptype_mapping_update_result *res = parsed_result;
15501 int ret = -ENOTSUP;
15502 #ifdef RTE_NET_I40E
15503 struct rte_pmd_i40e_ptype_mapping mapping;
15505 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15508 #ifdef RTE_NET_I40E
15509 mapping.hw_ptype = res->hw_ptype;
15510 mapping.sw_ptype = res->sw_ptype;
15511 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15521 fprintf(stderr, "invalid ptype 0x%8x\n", res->sw_ptype);
15524 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15527 fprintf(stderr, "function not implemented\n");
15530 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15534 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15535 .f = cmd_ptype_mapping_update_parsed,
15537 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15539 (void *)&cmd_ptype_mapping_update_ptype,
15540 (void *)&cmd_ptype_mapping_update_mapping,
15541 (void *)&cmd_ptype_mapping_update_update,
15542 (void *)&cmd_ptype_mapping_update_port_id,
15543 (void *)&cmd_ptype_mapping_update_hw_ptype,
15544 (void *)&cmd_ptype_mapping_update_sw_ptype,
15549 /* Common result structure for file commands */
15550 struct cmd_cmdfile_result {
15551 cmdline_fixed_string_t load;
15552 cmdline_fixed_string_t filename;
15555 /* Common CLI fields for file commands */
15556 cmdline_parse_token_string_t cmd_load_cmdfile =
15557 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15558 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15559 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15562 cmd_load_from_file_parsed(
15563 void *parsed_result,
15564 __rte_unused struct cmdline *cl,
15565 __rte_unused void *data)
15567 struct cmd_cmdfile_result *res = parsed_result;
15569 cmdline_read_from_file(res->filename);
15572 cmdline_parse_inst_t cmd_load_from_file = {
15573 .f = cmd_load_from_file_parsed,
15575 .help_str = "load <filename>",
15577 (void *)&cmd_load_cmdfile,
15578 (void *)&cmd_load_cmdfile_filename,
15583 /* Get Rx offloads capabilities */
15584 struct cmd_rx_offload_get_capa_result {
15585 cmdline_fixed_string_t show;
15586 cmdline_fixed_string_t port;
15588 cmdline_fixed_string_t rx_offload;
15589 cmdline_fixed_string_t capabilities;
15592 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
15593 TOKEN_STRING_INITIALIZER
15594 (struct cmd_rx_offload_get_capa_result,
15596 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
15597 TOKEN_STRING_INITIALIZER
15598 (struct cmd_rx_offload_get_capa_result,
15600 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
15601 TOKEN_NUM_INITIALIZER
15602 (struct cmd_rx_offload_get_capa_result,
15603 port_id, RTE_UINT16);
15604 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
15605 TOKEN_STRING_INITIALIZER
15606 (struct cmd_rx_offload_get_capa_result,
15607 rx_offload, "rx_offload");
15608 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
15609 TOKEN_STRING_INITIALIZER
15610 (struct cmd_rx_offload_get_capa_result,
15611 capabilities, "capabilities");
15614 print_rx_offloads(uint64_t offloads)
15616 uint64_t single_offload;
15624 begin = __builtin_ctzll(offloads);
15625 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15627 single_offload = 1ULL << begin;
15628 for (bit = begin; bit < end; bit++) {
15629 if (offloads & single_offload)
15631 rte_eth_dev_rx_offload_name(single_offload));
15632 single_offload <<= 1;
15637 cmd_rx_offload_get_capa_parsed(
15638 void *parsed_result,
15639 __rte_unused struct cmdline *cl,
15640 __rte_unused void *data)
15642 struct cmd_rx_offload_get_capa_result *res = parsed_result;
15643 struct rte_eth_dev_info dev_info;
15644 portid_t port_id = res->port_id;
15645 uint64_t queue_offloads;
15646 uint64_t port_offloads;
15649 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15653 queue_offloads = dev_info.rx_queue_offload_capa;
15654 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
15656 printf("Rx Offloading Capabilities of port %d :\n", port_id);
15657 printf(" Per Queue :");
15658 print_rx_offloads(queue_offloads);
15661 printf(" Per Port :");
15662 print_rx_offloads(port_offloads);
15666 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
15667 .f = cmd_rx_offload_get_capa_parsed,
15669 .help_str = "show port <port_id> rx_offload capabilities",
15671 (void *)&cmd_rx_offload_get_capa_show,
15672 (void *)&cmd_rx_offload_get_capa_port,
15673 (void *)&cmd_rx_offload_get_capa_port_id,
15674 (void *)&cmd_rx_offload_get_capa_rx_offload,
15675 (void *)&cmd_rx_offload_get_capa_capabilities,
15680 /* Get Rx offloads configuration */
15681 struct cmd_rx_offload_get_configuration_result {
15682 cmdline_fixed_string_t show;
15683 cmdline_fixed_string_t port;
15685 cmdline_fixed_string_t rx_offload;
15686 cmdline_fixed_string_t configuration;
15689 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
15690 TOKEN_STRING_INITIALIZER
15691 (struct cmd_rx_offload_get_configuration_result,
15693 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
15694 TOKEN_STRING_INITIALIZER
15695 (struct cmd_rx_offload_get_configuration_result,
15697 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
15698 TOKEN_NUM_INITIALIZER
15699 (struct cmd_rx_offload_get_configuration_result,
15700 port_id, RTE_UINT16);
15701 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
15702 TOKEN_STRING_INITIALIZER
15703 (struct cmd_rx_offload_get_configuration_result,
15704 rx_offload, "rx_offload");
15705 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
15706 TOKEN_STRING_INITIALIZER
15707 (struct cmd_rx_offload_get_configuration_result,
15708 configuration, "configuration");
15711 cmd_rx_offload_get_configuration_parsed(
15712 void *parsed_result,
15713 __rte_unused struct cmdline *cl,
15714 __rte_unused void *data)
15716 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
15717 struct rte_eth_dev_info dev_info;
15718 portid_t port_id = res->port_id;
15719 struct rte_port *port = &ports[port_id];
15720 uint64_t port_offloads;
15721 uint64_t queue_offloads;
15722 uint16_t nb_rx_queues;
15726 printf("Rx Offloading Configuration of port %d :\n", port_id);
15728 port_offloads = port->dev_conf.rxmode.offloads;
15730 print_rx_offloads(port_offloads);
15733 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15737 nb_rx_queues = dev_info.nb_rx_queues;
15738 for (q = 0; q < nb_rx_queues; q++) {
15739 queue_offloads = port->rx_conf[q].offloads;
15740 printf(" Queue[%2d] :", q);
15741 print_rx_offloads(queue_offloads);
15747 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
15748 .f = cmd_rx_offload_get_configuration_parsed,
15750 .help_str = "show port <port_id> rx_offload configuration",
15752 (void *)&cmd_rx_offload_get_configuration_show,
15753 (void *)&cmd_rx_offload_get_configuration_port,
15754 (void *)&cmd_rx_offload_get_configuration_port_id,
15755 (void *)&cmd_rx_offload_get_configuration_rx_offload,
15756 (void *)&cmd_rx_offload_get_configuration_configuration,
15761 /* Enable/Disable a per port offloading */
15762 struct cmd_config_per_port_rx_offload_result {
15763 cmdline_fixed_string_t port;
15764 cmdline_fixed_string_t config;
15766 cmdline_fixed_string_t rx_offload;
15767 cmdline_fixed_string_t offload;
15768 cmdline_fixed_string_t on_off;
15771 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
15772 TOKEN_STRING_INITIALIZER
15773 (struct cmd_config_per_port_rx_offload_result,
15775 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
15776 TOKEN_STRING_INITIALIZER
15777 (struct cmd_config_per_port_rx_offload_result,
15779 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
15780 TOKEN_NUM_INITIALIZER
15781 (struct cmd_config_per_port_rx_offload_result,
15782 port_id, RTE_UINT16);
15783 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
15784 TOKEN_STRING_INITIALIZER
15785 (struct cmd_config_per_port_rx_offload_result,
15786 rx_offload, "rx_offload");
15787 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
15788 TOKEN_STRING_INITIALIZER
15789 (struct cmd_config_per_port_rx_offload_result,
15790 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
15791 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
15792 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
15793 "scatter#buffer_split#timestamp#security#"
15794 "keep_crc#rss_hash");
15795 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
15796 TOKEN_STRING_INITIALIZER
15797 (struct cmd_config_per_port_rx_offload_result,
15801 search_rx_offload(const char *name)
15803 uint64_t single_offload;
15804 const char *single_name;
15808 single_offload = 1;
15809 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
15810 single_name = rte_eth_dev_rx_offload_name(single_offload);
15811 if (!strcasecmp(single_name, name)) {
15815 single_offload <<= 1;
15819 return single_offload;
15825 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
15826 __rte_unused struct cmdline *cl,
15827 __rte_unused void *data)
15829 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
15830 portid_t port_id = res->port_id;
15831 struct rte_eth_dev_info dev_info;
15832 struct rte_port *port = &ports[port_id];
15833 uint64_t single_offload;
15834 uint16_t nb_rx_queues;
15838 if (port->port_status != RTE_PORT_STOPPED) {
15840 "Error: Can't config offload when Port %d is not stopped\n",
15845 single_offload = search_rx_offload(res->offload);
15846 if (single_offload == 0) {
15847 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
15851 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15855 nb_rx_queues = dev_info.nb_rx_queues;
15856 if (!strcmp(res->on_off, "on")) {
15857 port->dev_conf.rxmode.offloads |= single_offload;
15858 for (q = 0; q < nb_rx_queues; q++)
15859 port->rx_conf[q].offloads |= single_offload;
15861 port->dev_conf.rxmode.offloads &= ~single_offload;
15862 for (q = 0; q < nb_rx_queues; q++)
15863 port->rx_conf[q].offloads &= ~single_offload;
15866 cmd_reconfig_device_queue(port_id, 1, 1);
15869 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
15870 .f = cmd_config_per_port_rx_offload_parsed,
15872 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
15873 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
15874 "macsec_strip|header_split|vlan_filter|vlan_extend|"
15875 "jumbo_frame|scatter|buffer_split|timestamp|security|"
15876 "keep_crc|rss_hash on|off",
15878 (void *)&cmd_config_per_port_rx_offload_result_port,
15879 (void *)&cmd_config_per_port_rx_offload_result_config,
15880 (void *)&cmd_config_per_port_rx_offload_result_port_id,
15881 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
15882 (void *)&cmd_config_per_port_rx_offload_result_offload,
15883 (void *)&cmd_config_per_port_rx_offload_result_on_off,
15888 /* Enable/Disable a per queue offloading */
15889 struct cmd_config_per_queue_rx_offload_result {
15890 cmdline_fixed_string_t port;
15892 cmdline_fixed_string_t rxq;
15894 cmdline_fixed_string_t rx_offload;
15895 cmdline_fixed_string_t offload;
15896 cmdline_fixed_string_t on_off;
15899 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
15900 TOKEN_STRING_INITIALIZER
15901 (struct cmd_config_per_queue_rx_offload_result,
15903 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
15904 TOKEN_NUM_INITIALIZER
15905 (struct cmd_config_per_queue_rx_offload_result,
15906 port_id, RTE_UINT16);
15907 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
15908 TOKEN_STRING_INITIALIZER
15909 (struct cmd_config_per_queue_rx_offload_result,
15911 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
15912 TOKEN_NUM_INITIALIZER
15913 (struct cmd_config_per_queue_rx_offload_result,
15914 queue_id, RTE_UINT16);
15915 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
15916 TOKEN_STRING_INITIALIZER
15917 (struct cmd_config_per_queue_rx_offload_result,
15918 rx_offload, "rx_offload");
15919 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
15920 TOKEN_STRING_INITIALIZER
15921 (struct cmd_config_per_queue_rx_offload_result,
15922 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
15923 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
15924 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
15925 "scatter#buffer_split#timestamp#security#keep_crc");
15926 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
15927 TOKEN_STRING_INITIALIZER
15928 (struct cmd_config_per_queue_rx_offload_result,
15932 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
15933 __rte_unused struct cmdline *cl,
15934 __rte_unused void *data)
15936 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
15937 struct rte_eth_dev_info dev_info;
15938 portid_t port_id = res->port_id;
15939 uint16_t queue_id = res->queue_id;
15940 struct rte_port *port = &ports[port_id];
15941 uint64_t single_offload;
15944 if (port->port_status != RTE_PORT_STOPPED) {
15946 "Error: Can't config offload when Port %d is not stopped\n",
15951 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15955 if (queue_id >= dev_info.nb_rx_queues) {
15957 "Error: input queue_id should be 0 ... %d\n",
15958 dev_info.nb_rx_queues - 1);
15962 single_offload = search_rx_offload(res->offload);
15963 if (single_offload == 0) {
15964 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
15968 if (!strcmp(res->on_off, "on"))
15969 port->rx_conf[queue_id].offloads |= single_offload;
15971 port->rx_conf[queue_id].offloads &= ~single_offload;
15973 cmd_reconfig_device_queue(port_id, 1, 1);
15976 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
15977 .f = cmd_config_per_queue_rx_offload_parsed,
15979 .help_str = "port <port_id> rxq <queue_id> rx_offload "
15980 "vlan_strip|ipv4_cksum|"
15981 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
15982 "macsec_strip|header_split|vlan_filter|vlan_extend|"
15983 "jumbo_frame|scatter|buffer_split|timestamp|security|"
15986 (void *)&cmd_config_per_queue_rx_offload_result_port,
15987 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
15988 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
15989 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
15990 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
15991 (void *)&cmd_config_per_queue_rx_offload_result_offload,
15992 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
15997 /* Get Tx offloads capabilities */
15998 struct cmd_tx_offload_get_capa_result {
15999 cmdline_fixed_string_t show;
16000 cmdline_fixed_string_t port;
16002 cmdline_fixed_string_t tx_offload;
16003 cmdline_fixed_string_t capabilities;
16006 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16007 TOKEN_STRING_INITIALIZER
16008 (struct cmd_tx_offload_get_capa_result,
16010 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16011 TOKEN_STRING_INITIALIZER
16012 (struct cmd_tx_offload_get_capa_result,
16014 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16015 TOKEN_NUM_INITIALIZER
16016 (struct cmd_tx_offload_get_capa_result,
16017 port_id, RTE_UINT16);
16018 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16019 TOKEN_STRING_INITIALIZER
16020 (struct cmd_tx_offload_get_capa_result,
16021 tx_offload, "tx_offload");
16022 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16023 TOKEN_STRING_INITIALIZER
16024 (struct cmd_tx_offload_get_capa_result,
16025 capabilities, "capabilities");
16028 print_tx_offloads(uint64_t offloads)
16030 uint64_t single_offload;
16038 begin = __builtin_ctzll(offloads);
16039 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16041 single_offload = 1ULL << begin;
16042 for (bit = begin; bit < end; bit++) {
16043 if (offloads & single_offload)
16045 rte_eth_dev_tx_offload_name(single_offload));
16046 single_offload <<= 1;
16051 cmd_tx_offload_get_capa_parsed(
16052 void *parsed_result,
16053 __rte_unused struct cmdline *cl,
16054 __rte_unused void *data)
16056 struct cmd_tx_offload_get_capa_result *res = parsed_result;
16057 struct rte_eth_dev_info dev_info;
16058 portid_t port_id = res->port_id;
16059 uint64_t queue_offloads;
16060 uint64_t port_offloads;
16063 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16067 queue_offloads = dev_info.tx_queue_offload_capa;
16068 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16070 printf("Tx Offloading Capabilities of port %d :\n", port_id);
16071 printf(" Per Queue :");
16072 print_tx_offloads(queue_offloads);
16075 printf(" Per Port :");
16076 print_tx_offloads(port_offloads);
16080 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16081 .f = cmd_tx_offload_get_capa_parsed,
16083 .help_str = "show port <port_id> tx_offload capabilities",
16085 (void *)&cmd_tx_offload_get_capa_show,
16086 (void *)&cmd_tx_offload_get_capa_port,
16087 (void *)&cmd_tx_offload_get_capa_port_id,
16088 (void *)&cmd_tx_offload_get_capa_tx_offload,
16089 (void *)&cmd_tx_offload_get_capa_capabilities,
16094 /* Get Tx offloads configuration */
16095 struct cmd_tx_offload_get_configuration_result {
16096 cmdline_fixed_string_t show;
16097 cmdline_fixed_string_t port;
16099 cmdline_fixed_string_t tx_offload;
16100 cmdline_fixed_string_t configuration;
16103 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16104 TOKEN_STRING_INITIALIZER
16105 (struct cmd_tx_offload_get_configuration_result,
16107 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16108 TOKEN_STRING_INITIALIZER
16109 (struct cmd_tx_offload_get_configuration_result,
16111 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16112 TOKEN_NUM_INITIALIZER
16113 (struct cmd_tx_offload_get_configuration_result,
16114 port_id, RTE_UINT16);
16115 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16116 TOKEN_STRING_INITIALIZER
16117 (struct cmd_tx_offload_get_configuration_result,
16118 tx_offload, "tx_offload");
16119 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16120 TOKEN_STRING_INITIALIZER
16121 (struct cmd_tx_offload_get_configuration_result,
16122 configuration, "configuration");
16125 cmd_tx_offload_get_configuration_parsed(
16126 void *parsed_result,
16127 __rte_unused struct cmdline *cl,
16128 __rte_unused void *data)
16130 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16131 struct rte_eth_dev_info dev_info;
16132 portid_t port_id = res->port_id;
16133 struct rte_port *port = &ports[port_id];
16134 uint64_t port_offloads;
16135 uint64_t queue_offloads;
16136 uint16_t nb_tx_queues;
16140 printf("Tx Offloading Configuration of port %d :\n", port_id);
16142 port_offloads = port->dev_conf.txmode.offloads;
16144 print_tx_offloads(port_offloads);
16147 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16151 nb_tx_queues = dev_info.nb_tx_queues;
16152 for (q = 0; q < nb_tx_queues; q++) {
16153 queue_offloads = port->tx_conf[q].offloads;
16154 printf(" Queue[%2d] :", q);
16155 print_tx_offloads(queue_offloads);
16161 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16162 .f = cmd_tx_offload_get_configuration_parsed,
16164 .help_str = "show port <port_id> tx_offload configuration",
16166 (void *)&cmd_tx_offload_get_configuration_show,
16167 (void *)&cmd_tx_offload_get_configuration_port,
16168 (void *)&cmd_tx_offload_get_configuration_port_id,
16169 (void *)&cmd_tx_offload_get_configuration_tx_offload,
16170 (void *)&cmd_tx_offload_get_configuration_configuration,
16175 /* Enable/Disable a per port offloading */
16176 struct cmd_config_per_port_tx_offload_result {
16177 cmdline_fixed_string_t port;
16178 cmdline_fixed_string_t config;
16180 cmdline_fixed_string_t tx_offload;
16181 cmdline_fixed_string_t offload;
16182 cmdline_fixed_string_t on_off;
16185 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16186 TOKEN_STRING_INITIALIZER
16187 (struct cmd_config_per_port_tx_offload_result,
16189 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16190 TOKEN_STRING_INITIALIZER
16191 (struct cmd_config_per_port_tx_offload_result,
16193 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16194 TOKEN_NUM_INITIALIZER
16195 (struct cmd_config_per_port_tx_offload_result,
16196 port_id, RTE_UINT16);
16197 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16198 TOKEN_STRING_INITIALIZER
16199 (struct cmd_config_per_port_tx_offload_result,
16200 tx_offload, "tx_offload");
16201 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16202 TOKEN_STRING_INITIALIZER
16203 (struct cmd_config_per_port_tx_offload_result,
16204 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16205 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16206 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16207 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16208 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16209 "send_on_timestamp");
16210 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16211 TOKEN_STRING_INITIALIZER
16212 (struct cmd_config_per_port_tx_offload_result,
16216 search_tx_offload(const char *name)
16218 uint64_t single_offload;
16219 const char *single_name;
16223 single_offload = 1;
16224 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16225 single_name = rte_eth_dev_tx_offload_name(single_offload);
16226 if (single_name == NULL)
16228 if (!strcasecmp(single_name, name)) {
16231 } else if (!strcasecmp(single_name, "UNKNOWN"))
16233 single_offload <<= 1;
16237 return single_offload;
16243 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16244 __rte_unused struct cmdline *cl,
16245 __rte_unused void *data)
16247 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16248 portid_t port_id = res->port_id;
16249 struct rte_eth_dev_info dev_info;
16250 struct rte_port *port = &ports[port_id];
16251 uint64_t single_offload;
16252 uint16_t nb_tx_queues;
16256 if (port->port_status != RTE_PORT_STOPPED) {
16258 "Error: Can't config offload when Port %d is not stopped\n",
16263 single_offload = search_tx_offload(res->offload);
16264 if (single_offload == 0) {
16265 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16269 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16273 nb_tx_queues = dev_info.nb_tx_queues;
16274 if (!strcmp(res->on_off, "on")) {
16275 port->dev_conf.txmode.offloads |= single_offload;
16276 for (q = 0; q < nb_tx_queues; q++)
16277 port->tx_conf[q].offloads |= single_offload;
16279 port->dev_conf.txmode.offloads &= ~single_offload;
16280 for (q = 0; q < nb_tx_queues; q++)
16281 port->tx_conf[q].offloads &= ~single_offload;
16284 cmd_reconfig_device_queue(port_id, 1, 1);
16287 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16288 .f = cmd_config_per_port_tx_offload_parsed,
16290 .help_str = "port config <port_id> tx_offload "
16291 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16292 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16293 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16294 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16295 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16296 "send_on_timestamp on|off",
16298 (void *)&cmd_config_per_port_tx_offload_result_port,
16299 (void *)&cmd_config_per_port_tx_offload_result_config,
16300 (void *)&cmd_config_per_port_tx_offload_result_port_id,
16301 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16302 (void *)&cmd_config_per_port_tx_offload_result_offload,
16303 (void *)&cmd_config_per_port_tx_offload_result_on_off,
16308 /* Enable/Disable a per queue offloading */
16309 struct cmd_config_per_queue_tx_offload_result {
16310 cmdline_fixed_string_t port;
16312 cmdline_fixed_string_t txq;
16314 cmdline_fixed_string_t tx_offload;
16315 cmdline_fixed_string_t offload;
16316 cmdline_fixed_string_t on_off;
16319 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16320 TOKEN_STRING_INITIALIZER
16321 (struct cmd_config_per_queue_tx_offload_result,
16323 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16324 TOKEN_NUM_INITIALIZER
16325 (struct cmd_config_per_queue_tx_offload_result,
16326 port_id, RTE_UINT16);
16327 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16328 TOKEN_STRING_INITIALIZER
16329 (struct cmd_config_per_queue_tx_offload_result,
16331 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16332 TOKEN_NUM_INITIALIZER
16333 (struct cmd_config_per_queue_tx_offload_result,
16334 queue_id, RTE_UINT16);
16335 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16336 TOKEN_STRING_INITIALIZER
16337 (struct cmd_config_per_queue_tx_offload_result,
16338 tx_offload, "tx_offload");
16339 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16340 TOKEN_STRING_INITIALIZER
16341 (struct cmd_config_per_queue_tx_offload_result,
16342 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16343 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16344 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16345 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16346 "mt_lockfree#multi_segs#mbuf_fast_free#security");
16347 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16348 TOKEN_STRING_INITIALIZER
16349 (struct cmd_config_per_queue_tx_offload_result,
16353 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16354 __rte_unused struct cmdline *cl,
16355 __rte_unused void *data)
16357 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16358 struct rte_eth_dev_info dev_info;
16359 portid_t port_id = res->port_id;
16360 uint16_t queue_id = res->queue_id;
16361 struct rte_port *port = &ports[port_id];
16362 uint64_t single_offload;
16365 if (port->port_status != RTE_PORT_STOPPED) {
16367 "Error: Can't config offload when Port %d is not stopped\n",
16372 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16376 if (queue_id >= dev_info.nb_tx_queues) {
16378 "Error: input queue_id should be 0 ... %d\n",
16379 dev_info.nb_tx_queues - 1);
16383 single_offload = search_tx_offload(res->offload);
16384 if (single_offload == 0) {
16385 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16389 if (!strcmp(res->on_off, "on"))
16390 port->tx_conf[queue_id].offloads |= single_offload;
16392 port->tx_conf[queue_id].offloads &= ~single_offload;
16394 cmd_reconfig_device_queue(port_id, 1, 1);
16397 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16398 .f = cmd_config_per_queue_tx_offload_parsed,
16400 .help_str = "port <port_id> txq <queue_id> tx_offload "
16401 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16402 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16403 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16404 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16405 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16408 (void *)&cmd_config_per_queue_tx_offload_result_port,
16409 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16410 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16411 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16412 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16413 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16414 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16419 /* *** configure tx_metadata for specific port *** */
16420 struct cmd_config_tx_metadata_specific_result {
16421 cmdline_fixed_string_t port;
16422 cmdline_fixed_string_t keyword;
16424 cmdline_fixed_string_t item;
16429 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16430 __rte_unused struct cmdline *cl,
16431 __rte_unused void *data)
16433 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16435 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16437 ports[res->port_id].tx_metadata = res->value;
16438 /* Add/remove callback to insert valid metadata in every Tx packet. */
16439 if (ports[res->port_id].tx_metadata)
16440 add_tx_md_callback(res->port_id);
16442 remove_tx_md_callback(res->port_id);
16443 rte_flow_dynf_metadata_register();
16446 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16447 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16449 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16450 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16451 keyword, "config");
16452 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16453 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16454 port_id, RTE_UINT16);
16455 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16456 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16457 item, "tx_metadata");
16458 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16459 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16460 value, RTE_UINT32);
16462 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16463 .f = cmd_config_tx_metadata_specific_parsed,
16465 .help_str = "port config <port_id> tx_metadata <value>",
16467 (void *)&cmd_config_tx_metadata_specific_port,
16468 (void *)&cmd_config_tx_metadata_specific_keyword,
16469 (void *)&cmd_config_tx_metadata_specific_id,
16470 (void *)&cmd_config_tx_metadata_specific_item,
16471 (void *)&cmd_config_tx_metadata_specific_value,
16476 /* *** set dynf *** */
16477 struct cmd_config_tx_dynf_specific_result {
16478 cmdline_fixed_string_t port;
16479 cmdline_fixed_string_t keyword;
16481 cmdline_fixed_string_t item;
16482 cmdline_fixed_string_t name;
16483 cmdline_fixed_string_t value;
16487 cmd_config_dynf_specific_parsed(void *parsed_result,
16488 __rte_unused struct cmdline *cl,
16489 __rte_unused void *data)
16491 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16492 struct rte_mbuf_dynflag desc_flag;
16494 uint64_t old_port_flags;
16496 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16498 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16500 if (strlcpy(desc_flag.name, res->name,
16501 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16502 fprintf(stderr, "Flag name too long\n");
16505 desc_flag.flags = 0;
16506 flag = rte_mbuf_dynflag_register(&desc_flag);
16508 fprintf(stderr, "Can't register flag\n");
16511 strcpy(dynf_names[flag], desc_flag.name);
16513 old_port_flags = ports[res->port_id].mbuf_dynf;
16514 if (!strcmp(res->value, "set")) {
16515 ports[res->port_id].mbuf_dynf |= 1UL << flag;
16516 if (old_port_flags == 0)
16517 add_tx_dynf_callback(res->port_id);
16519 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16520 if (ports[res->port_id].mbuf_dynf == 0)
16521 remove_tx_dynf_callback(res->port_id);
16525 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16526 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16528 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16529 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16530 keyword, "config");
16531 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
16532 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16533 port_id, RTE_UINT16);
16534 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
16535 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16537 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
16538 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16540 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
16541 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16542 value, "set#clear");
16544 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
16545 .f = cmd_config_dynf_specific_parsed,
16547 .help_str = "port config <port id> dynf <name> set|clear",
16549 (void *)&cmd_config_tx_dynf_specific_port,
16550 (void *)&cmd_config_tx_dynf_specific_keyword,
16551 (void *)&cmd_config_tx_dynf_specific_port_id,
16552 (void *)&cmd_config_tx_dynf_specific_item,
16553 (void *)&cmd_config_tx_dynf_specific_name,
16554 (void *)&cmd_config_tx_dynf_specific_value,
16559 /* *** display tx_metadata per port configuration *** */
16560 struct cmd_show_tx_metadata_result {
16561 cmdline_fixed_string_t cmd_show;
16562 cmdline_fixed_string_t cmd_port;
16563 cmdline_fixed_string_t cmd_keyword;
16568 cmd_show_tx_metadata_parsed(void *parsed_result,
16569 __rte_unused struct cmdline *cl,
16570 __rte_unused void *data)
16572 struct cmd_show_tx_metadata_result *res = parsed_result;
16574 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16575 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
16578 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
16579 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
16580 ports[res->cmd_pid].tx_metadata);
16584 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
16585 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16587 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
16588 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16590 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
16591 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
16592 cmd_pid, RTE_UINT16);
16593 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
16594 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16595 cmd_keyword, "tx_metadata");
16597 cmdline_parse_inst_t cmd_show_tx_metadata = {
16598 .f = cmd_show_tx_metadata_parsed,
16600 .help_str = "show port <port_id> tx_metadata",
16602 (void *)&cmd_show_tx_metadata_show,
16603 (void *)&cmd_show_tx_metadata_port,
16604 (void *)&cmd_show_tx_metadata_pid,
16605 (void *)&cmd_show_tx_metadata_keyword,
16610 /* *** show fec capability per port configuration *** */
16611 struct cmd_show_fec_capability_result {
16612 cmdline_fixed_string_t cmd_show;
16613 cmdline_fixed_string_t cmd_port;
16614 cmdline_fixed_string_t cmd_fec;
16615 cmdline_fixed_string_t cmd_keyword;
16620 cmd_show_fec_capability_parsed(void *parsed_result,
16621 __rte_unused struct cmdline *cl,
16622 __rte_unused void *data)
16624 struct cmd_show_fec_capability_result *res = parsed_result;
16625 struct rte_eth_fec_capa *speed_fec_capa;
16629 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16630 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
16634 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
16635 if (ret == -ENOTSUP) {
16636 fprintf(stderr, "Function not implemented\n");
16638 } else if (ret < 0) {
16639 fprintf(stderr, "Get FEC capability failed: %d\n", ret);
16643 num = (unsigned int)ret;
16644 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
16645 if (speed_fec_capa == NULL) {
16646 fprintf(stderr, "Failed to alloc FEC capability buffer\n");
16650 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
16652 fprintf(stderr, "Error getting FEC capability: %d\n", ret);
16656 show_fec_capability(num, speed_fec_capa);
16658 free(speed_fec_capa);
16661 cmdline_parse_token_string_t cmd_show_fec_capability_show =
16662 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16664 cmdline_parse_token_string_t cmd_show_fec_capability_port =
16665 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16667 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
16668 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
16669 cmd_pid, RTE_UINT16);
16670 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
16671 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16673 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
16674 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16675 cmd_keyword, "capabilities");
16677 cmdline_parse_inst_t cmd_show_capability = {
16678 .f = cmd_show_fec_capability_parsed,
16680 .help_str = "show port <port_id> fec capabilities",
16682 (void *)&cmd_show_fec_capability_show,
16683 (void *)&cmd_show_fec_capability_port,
16684 (void *)&cmd_show_fec_capability_pid,
16685 (void *)&cmd_show_fec_capability_fec,
16686 (void *)&cmd_show_fec_capability_keyword,
16691 /* *** show fec mode per port configuration *** */
16692 struct cmd_show_fec_metadata_result {
16693 cmdline_fixed_string_t cmd_show;
16694 cmdline_fixed_string_t cmd_port;
16695 cmdline_fixed_string_t cmd_keyword;
16700 cmd_show_fec_mode_parsed(void *parsed_result,
16701 __rte_unused struct cmdline *cl,
16702 __rte_unused void *data)
16704 #define FEC_NAME_SIZE 16
16705 struct cmd_show_fec_metadata_result *res = parsed_result;
16707 char buf[FEC_NAME_SIZE];
16710 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16711 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
16714 ret = rte_eth_fec_get(res->cmd_pid, &mode);
16715 if (ret == -ENOTSUP) {
16716 fprintf(stderr, "Function not implemented\n");
16718 } else if (ret < 0) {
16719 fprintf(stderr, "Get FEC mode failed\n");
16724 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
16725 strlcpy(buf, "off", sizeof(buf));
16727 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
16728 strlcpy(buf, "auto", sizeof(buf));
16730 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
16731 strlcpy(buf, "baser", sizeof(buf));
16733 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
16734 strlcpy(buf, "rs", sizeof(buf));
16740 printf("%s\n", buf);
16743 cmdline_parse_token_string_t cmd_show_fec_mode_show =
16744 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16746 cmdline_parse_token_string_t cmd_show_fec_mode_port =
16747 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16749 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
16750 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
16751 cmd_pid, RTE_UINT16);
16752 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
16753 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16754 cmd_keyword, "fec_mode");
16756 cmdline_parse_inst_t cmd_show_fec_mode = {
16757 .f = cmd_show_fec_mode_parsed,
16759 .help_str = "show port <port_id> fec_mode",
16761 (void *)&cmd_show_fec_mode_show,
16762 (void *)&cmd_show_fec_mode_port,
16763 (void *)&cmd_show_fec_mode_pid,
16764 (void *)&cmd_show_fec_mode_keyword,
16769 /* *** set fec mode per port configuration *** */
16770 struct cmd_set_port_fec_mode {
16771 cmdline_fixed_string_t set;
16772 cmdline_fixed_string_t port;
16774 cmdline_fixed_string_t fec_mode;
16775 cmdline_fixed_string_t fec_value;
16778 /* Common CLI fields for set fec mode */
16779 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
16780 TOKEN_STRING_INITIALIZER
16781 (struct cmd_set_port_fec_mode,
16783 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
16784 TOKEN_STRING_INITIALIZER
16785 (struct cmd_set_port_fec_mode,
16787 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
16788 TOKEN_NUM_INITIALIZER
16789 (struct cmd_set_port_fec_mode,
16790 port_id, RTE_UINT16);
16791 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
16792 TOKEN_STRING_INITIALIZER
16793 (struct cmd_set_port_fec_mode,
16794 fec_mode, "fec_mode");
16795 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
16796 TOKEN_STRING_INITIALIZER
16797 (struct cmd_set_port_fec_mode,
16801 cmd_set_port_fec_mode_parsed(
16802 void *parsed_result,
16803 __rte_unused struct cmdline *cl,
16804 __rte_unused void *data)
16806 struct cmd_set_port_fec_mode *res = parsed_result;
16807 uint16_t port_id = res->port_id;
16811 ret = parse_fec_mode(res->fec_value, &fec_capa);
16813 fprintf(stderr, "Unknown fec mode: %s for port %d\n",
16814 res->fec_value, port_id);
16818 ret = rte_eth_fec_set(port_id, fec_capa);
16819 if (ret == -ENOTSUP) {
16820 fprintf(stderr, "Function not implemented\n");
16822 } else if (ret < 0) {
16823 fprintf(stderr, "Set FEC mode failed\n");
16828 cmdline_parse_inst_t cmd_set_fec_mode = {
16829 .f = cmd_set_port_fec_mode_parsed,
16831 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
16833 (void *)&cmd_set_port_fec_mode_set,
16834 (void *)&cmd_set_port_fec_mode_port,
16835 (void *)&cmd_set_port_fec_mode_port_id,
16836 (void *)&cmd_set_port_fec_mode_str,
16837 (void *)&cmd_set_port_fec_mode_value,
16842 /* show port supported ptypes */
16844 /* Common result structure for show port ptypes */
16845 struct cmd_show_port_supported_ptypes_result {
16846 cmdline_fixed_string_t show;
16847 cmdline_fixed_string_t port;
16849 cmdline_fixed_string_t ptypes;
16852 /* Common CLI fields for show port ptypes */
16853 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
16854 TOKEN_STRING_INITIALIZER
16855 (struct cmd_show_port_supported_ptypes_result,
16857 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
16858 TOKEN_STRING_INITIALIZER
16859 (struct cmd_show_port_supported_ptypes_result,
16861 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
16862 TOKEN_NUM_INITIALIZER
16863 (struct cmd_show_port_supported_ptypes_result,
16864 port_id, RTE_UINT16);
16865 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
16866 TOKEN_STRING_INITIALIZER
16867 (struct cmd_show_port_supported_ptypes_result,
16871 cmd_show_port_supported_ptypes_parsed(
16872 void *parsed_result,
16873 __rte_unused struct cmdline *cl,
16874 __rte_unused void *data)
16876 #define RSVD_PTYPE_MASK 0xf0000000
16877 #define MAX_PTYPES_PER_LAYER 16
16878 #define LTYPE_NAMESIZE 32
16879 #define PTYPE_NAMESIZE 256
16880 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
16881 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
16882 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
16883 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
16884 uint16_t port_id = res->port_id;
16887 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
16891 while (ptype_mask != RSVD_PTYPE_MASK) {
16893 switch (ptype_mask) {
16894 case RTE_PTYPE_L2_MASK:
16895 strlcpy(ltype, "L2", sizeof(ltype));
16897 case RTE_PTYPE_L3_MASK:
16898 strlcpy(ltype, "L3", sizeof(ltype));
16900 case RTE_PTYPE_L4_MASK:
16901 strlcpy(ltype, "L4", sizeof(ltype));
16903 case RTE_PTYPE_TUNNEL_MASK:
16904 strlcpy(ltype, "Tunnel", sizeof(ltype));
16906 case RTE_PTYPE_INNER_L2_MASK:
16907 strlcpy(ltype, "Inner L2", sizeof(ltype));
16909 case RTE_PTYPE_INNER_L3_MASK:
16910 strlcpy(ltype, "Inner L3", sizeof(ltype));
16912 case RTE_PTYPE_INNER_L4_MASK:
16913 strlcpy(ltype, "Inner L4", sizeof(ltype));
16919 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
16920 ptype_mask, ptypes,
16921 MAX_PTYPES_PER_LAYER);
16924 printf("Supported %s ptypes:\n", ltype);
16926 printf("%s ptypes unsupported\n", ltype);
16928 for (i = 0; i < ret; ++i) {
16929 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
16930 printf("%s\n", buf);
16937 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
16938 .f = cmd_show_port_supported_ptypes_parsed,
16940 .help_str = "show port <port_id> ptypes",
16942 (void *)&cmd_show_port_supported_ptypes_show,
16943 (void *)&cmd_show_port_supported_ptypes_port,
16944 (void *)&cmd_show_port_supported_ptypes_port_id,
16945 (void *)&cmd_show_port_supported_ptypes_ptypes,
16950 /* *** display rx/tx descriptor status *** */
16951 struct cmd_show_rx_tx_desc_status_result {
16952 cmdline_fixed_string_t cmd_show;
16953 cmdline_fixed_string_t cmd_port;
16954 cmdline_fixed_string_t cmd_keyword;
16955 cmdline_fixed_string_t cmd_desc;
16956 cmdline_fixed_string_t cmd_status;
16963 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
16964 __rte_unused struct cmdline *cl,
16965 __rte_unused void *data)
16967 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
16970 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16971 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
16975 if (!strcmp(res->cmd_keyword, "rxq")) {
16976 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
16980 "Invalid input: queue id = %d, desc id = %d\n",
16981 res->cmd_qid, res->cmd_did);
16984 if (rc == RTE_ETH_RX_DESC_AVAIL)
16985 printf("Desc status = AVAILABLE\n");
16986 else if (rc == RTE_ETH_RX_DESC_DONE)
16987 printf("Desc status = DONE\n");
16989 printf("Desc status = UNAVAILABLE\n");
16990 } else if (!strcmp(res->cmd_keyword, "txq")) {
16991 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
16995 "Invalid input: queue id = %d, desc id = %d\n",
16996 res->cmd_qid, res->cmd_did);
16999 if (rc == RTE_ETH_TX_DESC_FULL)
17000 printf("Desc status = FULL\n");
17001 else if (rc == RTE_ETH_TX_DESC_DONE)
17002 printf("Desc status = DONE\n");
17004 printf("Desc status = UNAVAILABLE\n");
17008 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17009 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17011 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17012 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17014 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17015 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17016 cmd_pid, RTE_UINT16);
17017 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17018 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17019 cmd_keyword, "rxq#txq");
17020 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17021 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17022 cmd_qid, RTE_UINT16);
17023 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17024 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17026 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17027 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17028 cmd_did, RTE_UINT16);
17029 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17030 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17031 cmd_status, "status");
17032 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17033 .f = cmd_show_rx_tx_desc_status_parsed,
17035 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17038 (void *)&cmd_show_rx_tx_desc_status_show,
17039 (void *)&cmd_show_rx_tx_desc_status_port,
17040 (void *)&cmd_show_rx_tx_desc_status_pid,
17041 (void *)&cmd_show_rx_tx_desc_status_keyword,
17042 (void *)&cmd_show_rx_tx_desc_status_qid,
17043 (void *)&cmd_show_rx_tx_desc_status_desc,
17044 (void *)&cmd_show_rx_tx_desc_status_did,
17045 (void *)&cmd_show_rx_tx_desc_status_status,
17050 /* *** display rx queue desc used count *** */
17051 struct cmd_show_rx_queue_desc_used_count_result {
17052 cmdline_fixed_string_t cmd_show;
17053 cmdline_fixed_string_t cmd_port;
17054 cmdline_fixed_string_t cmd_rxq;
17055 cmdline_fixed_string_t cmd_desc;
17056 cmdline_fixed_string_t cmd_used;
17057 cmdline_fixed_string_t cmd_count;
17063 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17064 __rte_unused struct cmdline *cl,
17065 __rte_unused void *data)
17067 struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17070 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17071 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17075 rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17077 fprintf(stderr, "Invalid queueid = %d\n", res->cmd_qid);
17080 printf("Used desc count = %d\n", rc);
17083 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17084 TOKEN_STRING_INITIALIZER
17085 (struct cmd_show_rx_queue_desc_used_count_result,
17087 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17088 TOKEN_STRING_INITIALIZER
17089 (struct cmd_show_rx_queue_desc_used_count_result,
17091 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17092 TOKEN_NUM_INITIALIZER
17093 (struct cmd_show_rx_queue_desc_used_count_result,
17094 cmd_pid, RTE_UINT16);
17095 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17096 TOKEN_STRING_INITIALIZER
17097 (struct cmd_show_rx_queue_desc_used_count_result,
17099 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17100 TOKEN_NUM_INITIALIZER
17101 (struct cmd_show_rx_queue_desc_used_count_result,
17102 cmd_qid, RTE_UINT16);
17103 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17104 TOKEN_STRING_INITIALIZER
17105 (struct cmd_show_rx_queue_desc_used_count_result,
17106 cmd_count, "desc");
17107 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17108 TOKEN_STRING_INITIALIZER
17109 (struct cmd_show_rx_queue_desc_used_count_result,
17110 cmd_count, "used");
17111 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17112 TOKEN_STRING_INITIALIZER
17113 (struct cmd_show_rx_queue_desc_used_count_result,
17114 cmd_count, "count");
17115 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17116 .f = cmd_show_rx_queue_desc_used_count_parsed,
17118 .help_str = "show port <port_id> rxq <queue_id> desc used count",
17120 (void *)&cmd_show_rx_queue_desc_used_count_show,
17121 (void *)&cmd_show_rx_queue_desc_used_count_port,
17122 (void *)&cmd_show_rx_queue_desc_used_count_pid,
17123 (void *)&cmd_show_rx_queue_desc_used_count_rxq,
17124 (void *)&cmd_show_rx_queue_desc_used_count_qid,
17125 (void *)&cmd_show_rx_queue_desc_used_count_desc,
17126 (void *)&cmd_show_rx_queue_desc_used_count_used,
17127 (void *)&cmd_show_rx_queue_desc_used_count_count,
17132 /* Common result structure for set port ptypes */
17133 struct cmd_set_port_ptypes_result {
17134 cmdline_fixed_string_t set;
17135 cmdline_fixed_string_t port;
17137 cmdline_fixed_string_t ptype_mask;
17141 /* Common CLI fields for set port ptypes */
17142 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17143 TOKEN_STRING_INITIALIZER
17144 (struct cmd_set_port_ptypes_result,
17146 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17147 TOKEN_STRING_INITIALIZER
17148 (struct cmd_set_port_ptypes_result,
17150 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17151 TOKEN_NUM_INITIALIZER
17152 (struct cmd_set_port_ptypes_result,
17153 port_id, RTE_UINT16);
17154 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17155 TOKEN_STRING_INITIALIZER
17156 (struct cmd_set_port_ptypes_result,
17157 ptype_mask, "ptype_mask");
17158 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17159 TOKEN_NUM_INITIALIZER
17160 (struct cmd_set_port_ptypes_result,
17164 cmd_set_port_ptypes_parsed(
17165 void *parsed_result,
17166 __rte_unused struct cmdline *cl,
17167 __rte_unused void *data)
17169 struct cmd_set_port_ptypes_result *res = parsed_result;
17170 #define PTYPE_NAMESIZE 256
17171 char ptype_name[PTYPE_NAMESIZE];
17172 uint16_t port_id = res->port_id;
17173 uint32_t ptype_mask = res->mask;
17176 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17179 fprintf(stderr, "Port %d doesn't support any ptypes.\n",
17184 uint32_t ptypes[ret];
17186 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17188 fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
17193 printf("Successfully set following ptypes for Port %d\n", port_id);
17194 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17195 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17196 printf("%s\n", ptype_name);
17199 clear_ptypes = false;
17202 cmdline_parse_inst_t cmd_set_port_ptypes = {
17203 .f = cmd_set_port_ptypes_parsed,
17205 .help_str = "set port <port_id> ptype_mask <mask>",
17207 (void *)&cmd_set_port_ptypes_set,
17208 (void *)&cmd_set_port_ptypes_port,
17209 (void *)&cmd_set_port_ptypes_port_id,
17210 (void *)&cmd_set_port_ptypes_mask_str,
17211 (void *)&cmd_set_port_ptypes_mask_u32,
17216 /* *** display mac addresses added to a port *** */
17217 struct cmd_showport_macs_result {
17218 cmdline_fixed_string_t cmd_show;
17219 cmdline_fixed_string_t cmd_port;
17220 cmdline_fixed_string_t cmd_keyword;
17225 cmd_showport_macs_parsed(void *parsed_result,
17226 __rte_unused struct cmdline *cl,
17227 __rte_unused void *data)
17229 struct cmd_showport_macs_result *res = parsed_result;
17231 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17234 if (!strcmp(res->cmd_keyword, "macs"))
17235 show_macs(res->cmd_pid);
17236 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17237 show_mcast_macs(res->cmd_pid);
17240 cmdline_parse_token_string_t cmd_showport_macs_show =
17241 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17243 cmdline_parse_token_string_t cmd_showport_macs_port =
17244 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17246 cmdline_parse_token_num_t cmd_showport_macs_pid =
17247 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17248 cmd_pid, RTE_UINT16);
17249 cmdline_parse_token_string_t cmd_showport_macs_keyword =
17250 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17251 cmd_keyword, "macs#mcast_macs");
17253 cmdline_parse_inst_t cmd_showport_macs = {
17254 .f = cmd_showport_macs_parsed,
17256 .help_str = "show port <port_id> macs|mcast_macs",
17258 (void *)&cmd_showport_macs_show,
17259 (void *)&cmd_showport_macs_port,
17260 (void *)&cmd_showport_macs_pid,
17261 (void *)&cmd_showport_macs_keyword,
17266 /* ******************************************************************************** */
17268 /* list of instructions */
17269 cmdline_parse_ctx_t main_ctx[] = {
17270 (cmdline_parse_inst_t *)&cmd_help_brief,
17271 (cmdline_parse_inst_t *)&cmd_help_long,
17272 (cmdline_parse_inst_t *)&cmd_quit,
17273 (cmdline_parse_inst_t *)&cmd_load_from_file,
17274 (cmdline_parse_inst_t *)&cmd_showport,
17275 (cmdline_parse_inst_t *)&cmd_showqueue,
17276 (cmdline_parse_inst_t *)&cmd_showeeprom,
17277 (cmdline_parse_inst_t *)&cmd_showportall,
17278 (cmdline_parse_inst_t *)&cmd_showdevice,
17279 (cmdline_parse_inst_t *)&cmd_showcfg,
17280 (cmdline_parse_inst_t *)&cmd_showfwdall,
17281 (cmdline_parse_inst_t *)&cmd_start,
17282 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17283 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17284 (cmdline_parse_inst_t *)&cmd_set_link_up,
17285 (cmdline_parse_inst_t *)&cmd_set_link_down,
17286 (cmdline_parse_inst_t *)&cmd_reset,
17287 (cmdline_parse_inst_t *)&cmd_set_numbers,
17288 (cmdline_parse_inst_t *)&cmd_set_log,
17289 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
17290 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
17291 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17292 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17293 (cmdline_parse_inst_t *)&cmd_set_txtimes,
17294 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17295 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17296 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17297 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17298 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17299 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17300 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17301 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17302 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17303 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17304 (cmdline_parse_inst_t *)&cmd_set_link_check,
17305 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17306 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17307 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17308 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17309 #ifdef RTE_NET_BOND
17310 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17311 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17312 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17313 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17314 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17315 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17316 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17317 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17318 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17319 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17320 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17322 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17323 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17324 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17325 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17326 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17327 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17328 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17329 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17330 (cmdline_parse_inst_t *)&cmd_csum_set,
17331 (cmdline_parse_inst_t *)&cmd_csum_show,
17332 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17333 (cmdline_parse_inst_t *)&cmd_tso_set,
17334 (cmdline_parse_inst_t *)&cmd_tso_show,
17335 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17336 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17337 (cmdline_parse_inst_t *)&cmd_gro_enable,
17338 (cmdline_parse_inst_t *)&cmd_gro_flush,
17339 (cmdline_parse_inst_t *)&cmd_gro_show,
17340 (cmdline_parse_inst_t *)&cmd_gso_enable,
17341 (cmdline_parse_inst_t *)&cmd_gso_size,
17342 (cmdline_parse_inst_t *)&cmd_gso_show,
17343 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17344 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17345 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17346 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17347 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17348 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17349 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17350 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17351 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17352 (cmdline_parse_inst_t *)&cmd_link_flow_control_show,
17353 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17354 (cmdline_parse_inst_t *)&cmd_config_dcb,
17355 (cmdline_parse_inst_t *)&cmd_read_reg,
17356 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17357 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17358 (cmdline_parse_inst_t *)&cmd_write_reg,
17359 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17360 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17361 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17362 (cmdline_parse_inst_t *)&cmd_stop,
17363 (cmdline_parse_inst_t *)&cmd_mac_addr,
17364 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17365 (cmdline_parse_inst_t *)&cmd_set_qmap,
17366 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17367 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17368 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17369 (cmdline_parse_inst_t *)&cmd_operate_port,
17370 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17371 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17372 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17373 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
17374 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17375 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17376 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17377 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17378 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17379 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17380 (cmdline_parse_inst_t *)&cmd_config_mtu,
17381 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17382 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17383 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17384 (cmdline_parse_inst_t *)&cmd_config_rss,
17385 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17386 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17387 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17388 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17389 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17390 (cmdline_parse_inst_t *)&cmd_showport_reta,
17391 (cmdline_parse_inst_t *)&cmd_showport_macs,
17392 (cmdline_parse_inst_t *)&cmd_config_burst,
17393 (cmdline_parse_inst_t *)&cmd_config_thresh,
17394 (cmdline_parse_inst_t *)&cmd_config_threshold,
17395 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17396 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17397 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17398 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17399 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17400 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17401 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17402 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17403 (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
17404 (cmdline_parse_inst_t *)&cmd_dump,
17405 (cmdline_parse_inst_t *)&cmd_dump_one,
17406 #ifdef RTE_NET_I40E
17407 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17409 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17410 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17411 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17412 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17413 (cmdline_parse_inst_t *)&cmd_flow,
17414 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17415 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17416 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17417 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17418 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17419 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17420 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17421 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17422 (cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
17423 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17424 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17425 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17426 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17427 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17428 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17429 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17430 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17431 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17432 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17433 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17434 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17435 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17436 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17437 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17438 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17439 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17440 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17441 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17442 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17443 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17444 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17445 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17446 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17447 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17448 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17449 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17450 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17451 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
17452 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
17453 (cmdline_parse_inst_t *)&cmd_set_vxlan,
17454 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
17455 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17456 (cmdline_parse_inst_t *)&cmd_set_nvgre,
17457 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17458 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
17459 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
17460 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
17461 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
17462 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
17463 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
17464 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
17465 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
17466 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
17467 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
17468 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
17469 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
17470 (cmdline_parse_inst_t *)&cmd_set_conntrack_common,
17471 (cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
17472 (cmdline_parse_inst_t *)&cmd_ddp_add,
17473 (cmdline_parse_inst_t *)&cmd_ddp_del,
17474 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
17475 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
17476 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
17477 (cmdline_parse_inst_t *)&cmd_clear_input_set,
17478 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
17479 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17480 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
17481 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
17482 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17483 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17484 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17485 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17487 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17488 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17489 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17490 (cmdline_parse_inst_t *)&cmd_queue_region,
17491 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17492 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17493 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17494 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17495 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17496 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17497 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17498 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17499 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17500 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17501 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17502 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17503 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17504 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17505 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17506 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17507 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17508 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
17509 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17510 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17511 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17512 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17513 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17514 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17515 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
17516 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
17517 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
17518 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17519 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17520 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17521 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17522 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17523 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17524 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17525 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17526 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17528 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17529 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17531 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
17532 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
17533 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
17534 (cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
17535 (cmdline_parse_inst_t *)&cmd_set_raw,
17536 (cmdline_parse_inst_t *)&cmd_show_set_raw,
17537 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
17538 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
17539 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
17540 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
17541 (cmdline_parse_inst_t *)&cmd_show_capability,
17545 /* read cmdline commands from file */
17547 cmdline_read_from_file(const char *filename)
17549 struct cmdline *cl;
17551 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17554 "Failed to create file based cmdline context: %s\n",
17559 cmdline_interact(cl);
17564 printf("Read CLI commands from %s\n", filename);
17567 /* prompt function, called from main on MAIN lcore */
17572 /* initialize non-constant commands */
17573 cmd_set_fwd_mode_init();
17574 cmd_set_fwd_retry_mode_init();
17576 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17577 if (testpmd_cl == NULL)
17580 ret = atexit(prompt_exit);
17582 fprintf(stderr, "Cannot set exit function for cmdline\n");
17584 cmdline_interact(testpmd_cl);
17586 cmdline_stdin_exit(testpmd_cl);
17592 if (testpmd_cl != NULL) {
17593 cmdline_quit(testpmd_cl);
17594 cmdline_stdin_exit(testpmd_cl);
17599 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17601 if (id == (portid_t)RTE_PORT_ALL) {
17604 RTE_ETH_FOREACH_DEV(pid) {
17605 /* check if need_reconfig has been set to 1 */
17606 if (ports[pid].need_reconfig == 0)
17607 ports[pid].need_reconfig = dev;
17608 /* check if need_reconfig_queues has been set to 1 */
17609 if (ports[pid].need_reconfig_queues == 0)
17610 ports[pid].need_reconfig_queues = queue;
17612 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17613 /* check if need_reconfig has been set to 1 */
17614 if (ports[id].need_reconfig == 0)
17615 ports[id].need_reconfig = dev;
17616 /* check if need_reconfig_queues has been set to 1 */
17617 if (ports[id].need_reconfig_queues == 0)
17618 ports[id].need_reconfig_queues = queue;