1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
14 #include <sys/socket.h>
15 #include <netinet/in.h>
17 #include <sys/queue.h>
19 #include <rte_common.h>
20 #include <rte_byteorder.h>
22 #include <rte_debug.h>
23 #include <rte_cycles.h>
24 #include <rte_memory.h>
25 #include <rte_memzone.h>
26 #include <rte_malloc.h>
27 #include <rte_launch.h>
29 #include <rte_per_lcore.h>
30 #include <rte_lcore.h>
31 #include <rte_atomic.h>
32 #include <rte_branch_prediction.h>
34 #include <rte_mempool.h>
35 #include <rte_interrupts.h>
37 #include <rte_ether.h>
38 #include <rte_ethdev.h>
39 #include <rte_string_fns.h>
40 #include <rte_devargs.h>
43 #include <rte_mbuf_dyn.h>
45 #include <cmdline_rdline.h>
46 #include <cmdline_parse.h>
47 #include <cmdline_parse_num.h>
48 #include <cmdline_parse_string.h>
49 #include <cmdline_parse_ipaddr.h>
50 #include <cmdline_parse_etheraddr.h>
51 #include <cmdline_socket.h>
54 #include <rte_eth_bond.h>
55 #include <rte_eth_bond_8023ad.h>
57 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
58 #include <rte_pmd_dpaa.h>
61 #include <rte_pmd_ixgbe.h>
64 #include <rte_pmd_i40e.h>
67 #include <rte_pmd_bnxt.h>
70 #include "cmdline_mtr.h"
71 #include "cmdline_tm.h"
74 static struct cmdline *testpmd_cl;
76 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
78 /* *** Help command with introduction. *** */
79 struct cmd_help_brief_result {
80 cmdline_fixed_string_t help;
83 static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
85 __rte_unused void *data)
90 "Help is available for the following sections:\n\n"
91 " help control : Start and stop forwarding.\n"
92 " help display : Displaying port, stats and config "
94 " help config : Configuration information.\n"
95 " help ports : Configuring ports.\n"
96 " help registers : Reading and setting port registers.\n"
97 " help filters : Filters configuration help.\n"
98 " help traffic_management : Traffic Management commands.\n"
99 " help devices : Device related cmds.\n"
100 " help all : All of the above sections.\n\n"
105 cmdline_parse_token_string_t cmd_help_brief_help =
106 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
108 cmdline_parse_inst_t cmd_help_brief = {
109 .f = cmd_help_brief_parsed,
111 .help_str = "help: Show help",
113 (void *)&cmd_help_brief_help,
118 /* *** Help command with help sections. *** */
119 struct cmd_help_long_result {
120 cmdline_fixed_string_t help;
121 cmdline_fixed_string_t section;
124 static void cmd_help_long_parsed(void *parsed_result,
126 __rte_unused void *data)
129 struct cmd_help_long_result *res = parsed_result;
131 if (!strcmp(res->section, "all"))
134 if (show_all || !strcmp(res->section, "control")) {
139 "Control forwarding:\n"
140 "-------------------\n\n"
143 " Start packet forwarding with current configuration.\n\n"
146 " Start packet forwarding with current config"
147 " after sending one burst of packets.\n\n"
150 " Stop packet forwarding, and display accumulated"
154 " Quit to prompt.\n\n"
158 if (show_all || !strcmp(res->section, "display")) {
166 "show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
167 " Display information for port_id, or all.\n\n"
169 "show port port_id (module_eeprom|eeprom)\n"
170 " Display the module EEPROM or EEPROM information for port_id.\n\n"
172 "show port X rss reta (size) (mask0,mask1,...)\n"
173 " Display the rss redirection table entry indicated"
174 " by masks on port X. size is used to indicate the"
175 " hardware supported reta size\n\n"
177 "show port (port_id) rss-hash [key]\n"
178 " Display the RSS hash functions and RSS hash key of port\n\n"
180 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
181 " Clear information for port_id, or all.\n\n"
183 "show (rxq|txq) info (port_id) (queue_id)\n"
184 " Display information for configured RX/TX queue.\n\n"
186 "show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n"
187 " Display the given configuration.\n\n"
189 "read rxd (port_id) (queue_id) (rxd_id)\n"
190 " Display an RX descriptor of a port RX queue.\n\n"
192 "read txd (port_id) (queue_id) (txd_id)\n"
193 " Display a TX descriptor of a port TX queue.\n\n"
195 "ddp get list (port_id)\n"
196 " Get ddp profile info list\n\n"
198 "ddp get info (profile_path)\n"
199 " Get ddp profile information.\n\n"
201 "show vf stats (port_id) (vf_id)\n"
202 " Display a VF's statistics.\n\n"
204 "clear vf stats (port_id) (vf_id)\n"
205 " Reset a VF's statistics.\n\n"
207 "show port (port_id) pctype mapping\n"
208 " Get flow ptype to pctype mapping on a port\n\n"
210 "show port meter stats (port_id) (meter_id) (clear)\n"
211 " Get meter stats on a port\n\n"
213 "show fwd stats all\n"
214 " Display statistics for all fwd engines.\n\n"
216 "clear fwd stats all\n"
217 " Clear statistics for all fwd engines.\n\n"
219 "show port (port_id) rx_offload capabilities\n"
220 " List all per queue and per port Rx offloading"
221 " capabilities of a port\n\n"
223 "show port (port_id) rx_offload configuration\n"
224 " List port level and all queue level"
225 " Rx offloading configuration\n\n"
227 "show port (port_id) tx_offload capabilities\n"
228 " List all per queue and per port"
229 " Tx offloading capabilities of a port\n\n"
231 "show port (port_id) tx_offload configuration\n"
232 " List port level and all queue level"
233 " Tx offloading configuration\n\n"
235 "show port (port_id) tx_metadata\n"
236 " Show Tx metadata value set"
237 " for a specific port\n\n"
239 "show port (port_id) ptypes\n"
240 " Show port supported ptypes"
241 " for a specific port\n\n"
243 "show device info (<identifier>|all)"
244 " Show general information about devices probed.\n\n"
246 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
247 " Show status of rx|tx descriptor.\n\n"
249 "show port (port_id) 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"
260 if (show_all || !strcmp(res->section, "config")) {
266 "Configuration changes only become active when"
267 " forwarding is started/restarted.\n\n"
270 " Reset forwarding to the default configuration.\n\n"
272 "set verbose (level)\n"
273 " Set the debug verbosity level X.\n\n"
275 "set log global|(type) (level)\n"
276 " Set the log level.\n\n"
279 " Set number of ports.\n\n"
282 " Set number of cores.\n\n"
284 "set coremask (mask)\n"
285 " Set the forwarding cores hexadecimal mask.\n\n"
287 "set portmask (mask)\n"
288 " Set the forwarding ports hexadecimal mask.\n\n"
291 " Set number of packets per burst.\n\n"
293 "set burst tx delay (microseconds) retry (num)\n"
294 " Set the transmit delay time and number of retries,"
295 " effective when retry is enabled.\n\n"
297 "set rxoffs (x[,y]*)\n"
298 " Set the offset of each packet segment on"
299 " receiving if split feature is engaged."
300 " Affects only the queues configured with split"
303 "set rxpkts (x[,y]*)\n"
304 " Set the length of each segment to scatter"
305 " packets on receiving if split feature is engaged."
306 " Affects only the queues configured with split"
309 "set txpkts (x[,y]*)\n"
310 " Set the length of each segment of TXONLY"
311 " and optionally CSUM packets.\n\n"
313 "set txsplit (off|on|rand)\n"
314 " Set the split policy for the TX packets."
315 " Right now only applicable for CSUM and TXONLY"
318 "set txtimes (x, y)\n"
319 " Set the scheduling on timestamps"
320 " timings for the TXONLY mode\n\n"
322 "set corelist (x[,y]*)\n"
323 " Set the list of forwarding cores.\n\n"
325 "set portlist (x[,y]*)\n"
326 " Set the list of forwarding ports.\n\n"
328 "set port setup on (iterator|event)\n"
329 " Select how attached port is retrieved for setup.\n\n"
331 "set tx loopback (port_id) (on|off)\n"
332 " Enable or disable tx loopback.\n\n"
334 "set all queues drop (port_id) (on|off)\n"
335 " Set drop enable bit for all queues.\n\n"
337 "set vf split drop (port_id) (vf_id) (on|off)\n"
338 " Set split drop enable bit for a VF from the PF.\n\n"
340 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
341 " Set MAC antispoof for a VF from the PF.\n\n"
343 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
344 " Enable MACsec offload.\n\n"
346 "set macsec offload (port_id) off\n"
347 " Disable MACsec offload.\n\n"
349 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
350 " Configure MACsec secure connection (SC).\n\n"
352 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
353 " Configure MACsec secure association (SA).\n\n"
355 "set vf broadcast (port_id) (vf_id) (on|off)\n"
356 " Set VF broadcast for a VF from the PF.\n\n"
358 "vlan set stripq (on|off) (port_id,queue_id)\n"
359 " Set the VLAN strip for a queue on a port.\n\n"
361 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
362 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
364 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
365 " Set VLAN insert for a VF from the PF.\n\n"
367 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
368 " Set VLAN antispoof for a VF from the PF.\n\n"
370 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
371 " Set VLAN tag for a VF from the PF.\n\n"
373 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
374 " Set a VF's max bandwidth(Mbps).\n\n"
376 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
377 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
379 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
380 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
382 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
383 " Set some TCs' strict link priority mode on a physical port.\n\n"
385 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
386 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
388 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
389 " Set the VLAN strip or filter or qinq strip or extend\n\n"
391 "vlan set (inner|outer) tpid (value) (port_id)\n"
392 " Set the VLAN TPID for Packet Filtering on"
395 "rx_vlan add (vlan_id|all) (port_id)\n"
396 " Add a vlan_id, or all identifiers, to the set"
397 " of VLAN identifiers filtered by port_id.\n\n"
399 "rx_vlan rm (vlan_id|all) (port_id)\n"
400 " Remove a vlan_id, or all identifiers, from the set"
401 " of VLAN identifiers filtered by port_id.\n\n"
403 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
404 " Add a vlan_id, to the set of VLAN identifiers"
405 "filtered for VF(s) from port_id.\n\n"
407 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
408 " Remove a vlan_id, to the set of VLAN identifiers"
409 "filtered for VF(s) from port_id.\n\n"
411 "rx_vxlan_port add (udp_port) (port_id)\n"
412 " Add an UDP port for VXLAN packet filter on a port\n\n"
414 "rx_vxlan_port rm (udp_port) (port_id)\n"
415 " Remove an UDP port for VXLAN packet filter on a port\n\n"
417 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
418 " Set hardware insertion of VLAN IDs (single or double VLAN "
419 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
421 "tx_vlan set pvid port_id vlan_id (on|off)\n"
422 " Set port based TX VLAN insertion.\n\n"
424 "tx_vlan reset (port_id)\n"
425 " Disable hardware insertion of a VLAN header in"
426 " packets sent on a port.\n\n"
428 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
429 " Select hardware or software calculation of the"
430 " checksum when transmitting a packet using the"
431 " csum forward engine.\n"
432 " ip|udp|tcp|sctp always concern the inner layer.\n"
433 " outer-ip concerns the outer IP layer in"
434 " outer-udp concerns the outer UDP layer in"
435 " case the packet is recognized as a tunnel packet by"
436 " the forward engine (vxlan, gre and ipip are supported)\n"
437 " Please check the NIC datasheet for HW limits.\n\n"
439 "csum parse-tunnel (on|off) (tx_port_id)\n"
440 " If disabled, treat tunnel packets as non-tunneled"
441 " packets (treat inner headers as payload). The port\n"
442 " argument is the port used for TX in csum forward"
445 "csum show (port_id)\n"
446 " Display tx checksum offload configuration\n\n"
448 "tso set (segsize) (portid)\n"
449 " Enable TCP Segmentation Offload in csum forward"
451 " Please check the NIC datasheet for HW limits.\n\n"
454 " Display the status of TCP Segmentation Offload.\n\n"
456 "set port (port_id) gro on|off\n"
457 " Enable or disable Generic Receive Offload in"
458 " csum forwarding engine.\n\n"
460 "show port (port_id) gro\n"
461 " Display GRO configuration.\n\n"
463 "set gro flush (cycles)\n"
464 " Set the cycle to flush GROed packets from"
465 " reassembly tables.\n\n"
467 "set port (port_id) gso (on|off)"
468 " Enable or disable Generic Segmentation Offload in"
469 " csum forwarding engine.\n\n"
471 "set gso segsz (length)\n"
472 " Set max packet length for output GSO segments,"
473 " including packet header and payload.\n\n"
475 "show port (port_id) gso\n"
476 " Show GSO configuration.\n\n"
479 " Set packet forwarding mode.\n\n"
481 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
482 " Add a MAC address on port_id.\n\n"
484 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
485 " Remove a MAC address from port_id.\n\n"
487 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
488 " Set the default MAC address for port_id.\n\n"
490 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
491 " Add a MAC address for a VF on the port.\n\n"
493 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
494 " Set the MAC address for a VF from the PF.\n\n"
496 "set eth-peer (port_id) (peer_addr)\n"
497 " set the peer address for certain port.\n\n"
499 "set port (port_id) uta (mac_address|all) (on|off)\n"
500 " Add/Remove a or all unicast hash filter(s)"
503 "set promisc (port_id|all) (on|off)\n"
504 " Set the promiscuous mode on port_id, or all.\n\n"
506 "set allmulti (port_id|all) (on|off)\n"
507 " Set the allmulti mode on port_id, or all.\n\n"
509 "set vf promisc (port_id) (vf_id) (on|off)\n"
510 " Set unicast promiscuous mode for a VF from the PF.\n\n"
512 "set vf allmulti (port_id) (vf_id) (on|off)\n"
513 " Set multicast promiscuous mode for a VF from the PF.\n\n"
515 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
516 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
517 " (on|off) autoneg (on|off) (port_id)\n"
518 "set flow_ctrl rx (on|off) (portid)\n"
519 "set flow_ctrl tx (on|off) (portid)\n"
520 "set flow_ctrl high_water (high_water) (portid)\n"
521 "set flow_ctrl low_water (low_water) (portid)\n"
522 "set flow_ctrl pause_time (pause_time) (portid)\n"
523 "set flow_ctrl send_xon (send_xon) (portid)\n"
524 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
525 "set flow_ctrl autoneg (on|off) (port_id)\n"
526 " Set the link flow control parameter on a port.\n\n"
528 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
529 " (low_water) (pause_time) (priority) (port_id)\n"
530 " Set the priority flow control parameter on a"
533 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
534 " Set statistics mapping (qmapping 0..15) for RX/TX"
536 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
537 " on port 0 to mapping 5.\n\n"
539 "set xstats-hide-zero on|off\n"
540 " Set the option to hide the zero values"
541 " for xstats display.\n"
543 "set record-core-cycles on|off\n"
544 " Set the option to enable measurement of CPU cycles.\n"
546 "set record-burst-stats on|off\n"
547 " Set the option to enable display of RX and TX bursts.\n"
549 "set port (port_id) vf (vf_id) rx|tx on|off\n"
550 " Enable/Disable a VF receive/tranmit from a port\n\n"
552 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
554 " AUPE:accepts untagged VLAN;"
555 "ROPE:accept unicast hash\n\n"
556 " BAM:accepts broadcast packets;"
557 "MPE:accepts all multicast packets\n\n"
558 " Enable/Disable a VF receive mode of a port\n\n"
560 "set port (port_id) queue (queue_id) rate (rate_num)\n"
561 " Set rate limit for a queue of a port\n\n"
563 "set port (port_id) vf (vf_id) rate (rate_num) "
564 "queue_mask (queue_mask_value)\n"
565 " Set rate limit for queues in VF of a port\n\n"
567 "set port (port_id) mirror-rule (rule_id)"
568 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
569 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
570 " Set pool or vlan type mirror rule on a port.\n"
571 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
572 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
575 "set port (port_id) mirror-rule (rule_id)"
576 " (uplink-mirror|downlink-mirror) dst-pool"
577 " (pool_id) (on|off)\n"
578 " Set uplink or downlink type mirror rule on a port.\n"
579 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
580 " 0 on' enable mirror income traffic to pool 0.\n\n"
582 "reset port (port_id) mirror-rule (rule_id)\n"
583 " Reset a mirror rule.\n\n"
585 "set flush_rx (on|off)\n"
586 " Flush (default) or don't flush RX streams before"
587 " forwarding. Mainly used with PCAP drivers.\n\n"
589 "set bypass mode (normal|bypass|isolate) (port_id)\n"
590 " Set the bypass mode for the lowest port on bypass enabled"
593 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
594 "mode (normal|bypass|isolate) (port_id)\n"
595 " Set the event required to initiate specified bypass mode for"
596 " the lowest port on a bypass enabled NIC where:\n"
597 " timeout = enable bypass after watchdog timeout.\n"
598 " os_on = enable bypass when OS/board is powered on.\n"
599 " os_off = enable bypass when OS/board is powered off.\n"
600 " power_on = enable bypass when power supply is turned on.\n"
601 " power_off = enable bypass when power supply is turned off."
604 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
605 " Set the bypass watchdog timeout to 'n' seconds"
606 " where 0 = instant.\n\n"
608 "show bypass config (port_id)\n"
609 " Show the bypass configuration for a bypass enabled NIC"
610 " using the lowest port on the NIC.\n\n"
613 "create bonded device (mode) (socket)\n"
614 " Create a new bonded device with specific bonding mode and socket.\n\n"
616 "add bonding slave (slave_id) (port_id)\n"
617 " Add a slave device to a bonded device.\n\n"
619 "remove bonding slave (slave_id) (port_id)\n"
620 " Remove a slave device from a bonded device.\n\n"
622 "set bonding mode (value) (port_id)\n"
623 " Set the bonding mode on a bonded device.\n\n"
625 "set bonding primary (slave_id) (port_id)\n"
626 " Set the primary slave for a bonded device.\n\n"
628 "show bonding config (port_id)\n"
629 " Show the bonding config for port_id.\n\n"
631 "set bonding mac_addr (port_id) (address)\n"
632 " Set the MAC address of a bonded device.\n\n"
634 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
635 " Set Aggregation mode for IEEE802.3AD (mode 4)"
637 "set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
638 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
640 "set bonding mon_period (port_id) (value)\n"
641 " Set the bonding link status monitoring polling period in ms.\n\n"
643 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
644 " Enable/disable dedicated queues for LACP control traffic.\n\n"
647 "set link-up port (port_id)\n"
648 " Set link up for a port.\n\n"
650 "set link-down port (port_id)\n"
651 " Set link down for a port.\n\n"
653 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
654 " Load a profile package on a port\n\n"
656 "ddp del (port_id) (backup_profile_path)\n"
657 " Delete a profile package from a port\n\n"
659 "ptype mapping get (port_id) (valid_only)\n"
660 " Get ptype mapping on a port\n\n"
662 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
663 " Replace target with the pkt_type in ptype mapping\n\n"
665 "ptype mapping reset (port_id)\n"
666 " Reset ptype mapping on a port\n\n"
668 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
669 " Update a ptype mapping item on a port\n\n"
671 "set port (port_id) ptype_mask (ptype_mask)\n"
672 " set packet types classification for a specific port\n\n"
674 "set port (port_id) queue-region region_id (value) "
675 "queue_start_index (value) queue_num (value)\n"
676 " Set a queue region on a port\n\n"
678 "set port (port_id) queue-region region_id (value) "
680 " Set a flowtype region index on a port\n\n"
682 "set port (port_id) queue-region UP (value) region_id (value)\n"
683 " Set the mapping of User Priority to "
684 "queue region on a port\n\n"
686 "set port (port_id) queue-region flush (on|off)\n"
687 " flush all queue region related configuration\n\n"
689 "show port meter cap (port_id)\n"
690 " Show port meter capability information\n\n"
692 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
693 " meter profile add - srtcm rfc 2697\n\n"
695 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
696 " meter profile add - trtcm rfc 2698\n\n"
698 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
699 " meter profile add - trtcm rfc 4115\n\n"
701 "del port meter profile (port_id) (profile_id)\n"
702 " meter profile delete\n\n"
704 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
705 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
706 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
707 "(dscp_tbl_entry63)]\n"
710 "enable port meter (port_id) (mtr_id)\n"
713 "disable port meter (port_id) (mtr_id)\n"
716 "del port meter (port_id) (mtr_id)\n"
719 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
720 " meter update meter profile\n\n"
722 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
723 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
724 " update meter dscp table entries\n\n"
726 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
727 "(action0) [(action1) (action2)]\n"
728 " meter update policer action\n\n"
730 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
731 " meter update stats\n\n"
733 "show port (port_id) queue-region\n"
734 " show all queue region related configuration info\n\n"
736 "set port (port_id) fec_mode auto|off|rs|baser\n"
737 " set fec mode for a specific port\n\n"
739 , list_pkt_forwarding_modes()
743 if (show_all || !strcmp(res->section, "ports")) {
749 "----------------\n\n"
751 "port start (port_id|all)\n"
752 " Start all ports or port_id.\n\n"
754 "port stop (port_id|all)\n"
755 " Stop all ports or port_id.\n\n"
757 "port close (port_id|all)\n"
758 " Close all ports or port_id.\n\n"
760 "port reset (port_id|all)\n"
761 " Reset all ports or port_id.\n\n"
763 "port attach (ident)\n"
764 " Attach physical or virtual dev by pci address or virtual device name\n\n"
766 "port detach (port_id)\n"
767 " Detach physical or virtual dev by port_id\n\n"
769 "port config (port_id|all)"
770 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
771 " duplex (half|full|auto)\n"
772 " Set speed and duplex for all ports or port_id\n\n"
774 "port config (port_id|all) loopback (mode)\n"
775 " Set loopback mode for all ports or port_id\n\n"
777 "port config all (rxq|txq|rxd|txd) (value)\n"
778 " Set number for rxq/txq/rxd/txd.\n\n"
780 "port config all max-pkt-len (value)\n"
781 " Set the max packet length.\n\n"
783 "port config all max-lro-pkt-size (value)\n"
784 " Set the max LRO aggregated packet size.\n\n"
786 "port config all drop-en (on|off)\n"
787 " Enable or disable packet drop on all RX queues of all ports when no "
788 "receive buffers available.\n\n"
790 "port config all rss (all|default|ip|tcp|udp|sctp|"
791 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|level-default|"
792 "level-outer|level-inner|<flowtype_id>)\n"
793 " Set the RSS mode.\n\n"
795 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
796 " Set the RSS redirection table.\n\n"
798 "port config (port_id) dcb vt (on|off) (traffic_class)"
800 " Set the DCB mode.\n\n"
802 "port config all burst (value)\n"
803 " Set the number of packets per burst.\n\n"
805 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
807 " Set the ring prefetch/host/writeback threshold"
808 " for tx/rx queue.\n\n"
810 "port config all (txfreet|txrst|rxfreet) (value)\n"
811 " Set free threshold for rx/tx, or set"
812 " tx rs bit threshold.\n\n"
813 "port config mtu X value\n"
814 " Set the MTU of port X to a given value\n\n"
816 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
817 " Set a rx/tx queue's ring size configuration, the new"
818 " value will take effect after command that (re-)start the port"
819 " or command that setup the specific queue\n\n"
821 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
822 " Start/stop a rx/tx queue of port X. Only take effect"
823 " when port X is started\n\n"
825 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
826 " Switch on/off a deferred start of port X rx/tx queue. Only"
827 " take effect when port X is stopped.\n\n"
829 "port (port_id) (rxq|txq) (queue_id) setup\n"
830 " Setup a rx/tx queue of port X.\n\n"
832 "port config (port_id) pctype mapping reset\n"
833 " Reset flow type to pctype mapping on a port\n\n"
835 "port config (port_id) pctype mapping update"
836 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
837 " Update a flow type to pctype mapping item on a port\n\n"
839 "port config (port_id) pctype (pctype_id) hash_inset|"
840 "fdir_inset|fdir_flx_inset get|set|clear field\n"
842 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
844 "port config (port_id) pctype (pctype_id) hash_inset|"
845 "fdir_inset|fdir_flx_inset clear all"
846 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
848 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
849 " Add/remove UDP tunnel port for tunneling offload\n\n"
851 "port config <port_id> rx_offload vlan_strip|"
852 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
853 "outer_ipv4_cksum|macsec_strip|header_split|"
854 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
855 "buffer_split|timestamp|security|keep_crc on|off\n"
856 " Enable or disable a per port Rx offloading"
857 " on all Rx queues of a port\n\n"
859 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
860 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
861 "outer_ipv4_cksum|macsec_strip|header_split|"
862 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
863 "buffer_split|timestamp|security|keep_crc on|off\n"
864 " Enable or disable a per queue Rx offloading"
865 " only on a specific Rx queue\n\n"
867 "port config (port_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|"
871 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
873 " Enable or disable a per port Tx offloading"
874 " on all Tx queues of a port\n\n"
876 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
877 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
878 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
879 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
880 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
882 " Enable or disable a per queue Tx offloading"
883 " only on a specific Tx queue\n\n"
885 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
886 " Load an eBPF program as a callback"
887 " for particular RX/TX queue\n\n"
889 "bpf-unload rx|tx (port) (queue)\n"
890 " Unload previously loaded eBPF program"
891 " for particular RX/TX queue\n\n"
893 "port config (port_id) tx_metadata (value)\n"
894 " Set Tx metadata value per port. Testpmd will add this value"
895 " to any Tx packet sent from this port\n\n"
897 "port config (port_id) dynf (name) set|clear\n"
898 " Register a dynf and Set/clear this flag on Tx. "
899 "Testpmd will set this value to any Tx packet "
900 "sent from this port\n\n"
904 if (show_all || !strcmp(res->section, "registers")) {
912 "read reg (port_id) (address)\n"
913 " Display value of a port register.\n\n"
915 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
916 " Display a port register bit field.\n\n"
918 "read regbit (port_id) (address) (bit_x)\n"
919 " Display a single port register bit.\n\n"
921 "write reg (port_id) (address) (value)\n"
922 " Set value of a port register.\n\n"
924 "write regfield (port_id) (address) (bit_x) (bit_y)"
926 " Set bit field of a port register.\n\n"
928 "write regbit (port_id) (address) (bit_x) (value)\n"
929 " Set single bit value of a port register.\n\n"
932 if (show_all || !strcmp(res->section, "filters")) {
941 "flow_director_filter (port_id) mode raw (add|del|update)"
942 " flow (flow_id) (drop|fwd) queue (queue_id)"
943 " fd_id (fd_id_value) packet (packet file name)\n"
944 " Add/Del a raw type flow director filter.\n\n"
947 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
948 " src_mask (ipv4_src) (ipv6_src) (src_port)"
949 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
950 " Set flow director IP mask.\n\n"
952 "flow_director_mask (port_id) mode MAC-VLAN"
953 " vlan (vlan_value)\n"
954 " Set flow director MAC-VLAN mask.\n\n"
956 "flow_director_mask (port_id) mode Tunnel"
957 " vlan (vlan_value) mac (mac_value)"
958 " tunnel-type (tunnel_type_value)"
959 " tunnel-id (tunnel_id_value)\n"
960 " Set flow director Tunnel mask.\n\n"
962 "flow_director_flex_payload (port_id)"
963 " (raw|l2|l3|l4) (config)\n"
964 " Configure flex payload selection.\n\n"
966 "flow validate {port_id}"
967 " [group {group_id}] [priority {level}]"
968 " [ingress] [egress]"
969 " pattern {item} [/ {item} [...]] / end"
970 " actions {action} [/ {action} [...]] / end\n"
971 " Check whether a flow rule can be created.\n\n"
973 "flow create {port_id}"
974 " [group {group_id}] [priority {level}]"
975 " [ingress] [egress]"
976 " pattern {item} [/ {item} [...]] / end"
977 " actions {action} [/ {action} [...]] / end\n"
978 " Create a flow rule.\n\n"
980 "flow destroy {port_id} rule {rule_id} [...]\n"
981 " Destroy specific flow rules.\n\n"
983 "flow flush {port_id}\n"
984 " Destroy all flow rules.\n\n"
986 "flow query {port_id} {rule_id} {action}\n"
987 " Query an existing flow rule.\n\n"
989 "flow list {port_id} [group {group_id}] [...]\n"
990 " List existing flow rules sorted by priority,"
991 " filtered by group identifiers.\n\n"
993 "flow isolate {port_id} {boolean}\n"
994 " Restrict ingress traffic to the defined"
997 "flow aged {port_id} [destroy]\n"
998 " List and destroy aged flows"
1001 "flow shared_action {port_id} create"
1002 " [action_id {shared_action_id}]"
1003 " [ingress] [egress]"
1004 " action {action} / end\n"
1005 " Create shared action.\n\n"
1007 "flow shared_action {port_id} update"
1008 " {shared_action_id} action {action} / end\n"
1009 " Update shared action.\n\n"
1011 "flow shared_action {port_id} destroy"
1012 " action_id {shared_action_id} [...]\n"
1013 " Destroy specific shared actions.\n\n"
1015 "flow shared_action {port_id} query"
1016 " {shared_action_id}\n"
1017 " Query an existing shared action.\n\n"
1019 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1020 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1021 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1022 " Configure the VXLAN encapsulation for flows.\n\n"
1024 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1025 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1026 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1027 " eth-dst (eth-dst)\n"
1028 " Configure the VXLAN encapsulation for flows.\n\n"
1030 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1031 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1032 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1033 " eth-dst (eth-dst)\n"
1034 " Configure the VXLAN encapsulation for flows.\n\n"
1036 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1037 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1039 " Configure the NVGRE encapsulation for flows.\n\n"
1041 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1042 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1043 " eth-src (eth-src) eth-dst (eth-dst)\n"
1044 " Configure the NVGRE encapsulation for flows.\n\n"
1046 "set raw_encap {flow items}\n"
1047 " Configure the encapsulation with raw data.\n\n"
1049 "set raw_decap {flow items}\n"
1050 " Configure the decapsulation with raw data.\n\n"
1055 if (show_all || !strcmp(res->section, "traffic_management")) {
1059 "Traffic Management:\n"
1061 "show port tm cap (port_id)\n"
1062 " Display the port TM capability.\n\n"
1064 "show port tm level cap (port_id) (level_id)\n"
1065 " Display the port TM hierarchical level capability.\n\n"
1067 "show port tm node cap (port_id) (node_id)\n"
1068 " Display the port TM node capability.\n\n"
1070 "show port tm node type (port_id) (node_id)\n"
1071 " Display the port TM node type.\n\n"
1073 "show port tm node stats (port_id) (node_id) (clear)\n"
1074 " Display the port TM node stats.\n\n"
1076 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1077 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1078 " (packet_length_adjust) (packet_mode)\n"
1079 " Add port tm node private shaper profile.\n\n"
1081 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1082 " Delete port tm node private shaper profile.\n\n"
1084 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1085 " (shaper_profile_id)\n"
1086 " Add/update port tm node shared shaper.\n\n"
1088 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1089 " Delete port tm node shared shaper.\n\n"
1091 "set port tm node shaper profile (port_id) (node_id)"
1092 " (shaper_profile_id)\n"
1093 " Set port tm node shaper profile.\n\n"
1095 "add port tm node wred profile (port_id) (wred_profile_id)"
1096 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1097 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1098 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1099 " Add port tm node wred profile.\n\n"
1101 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1102 " Delete port tm node wred profile.\n\n"
1104 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1105 " (priority) (weight) (level_id) (shaper_profile_id)"
1106 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1107 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1108 " Add port tm nonleaf node.\n\n"
1110 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1111 " (priority) (weight) (level_id) (shaper_profile_id)"
1112 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1113 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1114 " Add port tm nonleaf node with pkt mode enabled.\n\n"
1116 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1117 " (priority) (weight) (level_id) (shaper_profile_id)"
1118 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1119 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1120 " Add port tm leaf node.\n\n"
1122 "del port tm node (port_id) (node_id)\n"
1123 " Delete port tm node.\n\n"
1125 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1126 " (priority) (weight)\n"
1127 " Set port tm node parent.\n\n"
1129 "suspend port tm node (port_id) (node_id)"
1130 " Suspend tm node.\n\n"
1132 "resume port tm node (port_id) (node_id)"
1133 " Resume tm node.\n\n"
1135 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1136 " Commit tm hierarchy.\n\n"
1138 "set port tm mark ip_ecn (port) (green) (yellow)"
1140 " Enables/Disables the traffic management marking"
1141 " for IP ECN (Explicit Congestion Notification)"
1142 " packets on a given port\n\n"
1144 "set port tm mark ip_dscp (port) (green) (yellow)"
1146 " Enables/Disables the traffic management marking"
1147 " on the port for IP dscp packets\n\n"
1149 "set port tm mark vlan_dei (port) (green) (yellow)"
1151 " Enables/Disables the traffic management marking"
1152 " on the port for VLAN packets with DEI enabled\n\n"
1156 if (show_all || !strcmp(res->section, "devices")) {
1160 "Device Operations:\n"
1162 "device detach (identifier)\n"
1163 " Detach device by identifier.\n\n"
1169 cmdline_parse_token_string_t cmd_help_long_help =
1170 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1172 cmdline_parse_token_string_t cmd_help_long_section =
1173 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1174 "all#control#display#config#"
1175 "ports#registers#filters#traffic_management#devices");
1177 cmdline_parse_inst_t cmd_help_long = {
1178 .f = cmd_help_long_parsed,
1180 .help_str = "help all|control|display|config|ports|register|"
1181 "filters|traffic_management|devices: "
1184 (void *)&cmd_help_long_help,
1185 (void *)&cmd_help_long_section,
1191 /* *** start/stop/close all ports *** */
1192 struct cmd_operate_port_result {
1193 cmdline_fixed_string_t keyword;
1194 cmdline_fixed_string_t name;
1195 cmdline_fixed_string_t value;
1198 static void cmd_operate_port_parsed(void *parsed_result,
1199 __rte_unused struct cmdline *cl,
1200 __rte_unused void *data)
1202 struct cmd_operate_port_result *res = parsed_result;
1204 if (!strcmp(res->name, "start"))
1205 start_port(RTE_PORT_ALL);
1206 else if (!strcmp(res->name, "stop"))
1207 stop_port(RTE_PORT_ALL);
1208 else if (!strcmp(res->name, "close"))
1209 close_port(RTE_PORT_ALL);
1210 else if (!strcmp(res->name, "reset"))
1211 reset_port(RTE_PORT_ALL);
1213 printf("Unknown parameter\n");
1216 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1217 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1219 cmdline_parse_token_string_t cmd_operate_port_all_port =
1220 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1221 "start#stop#close#reset");
1222 cmdline_parse_token_string_t cmd_operate_port_all_all =
1223 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1225 cmdline_parse_inst_t cmd_operate_port = {
1226 .f = cmd_operate_port_parsed,
1228 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1230 (void *)&cmd_operate_port_all_cmd,
1231 (void *)&cmd_operate_port_all_port,
1232 (void *)&cmd_operate_port_all_all,
1237 /* *** start/stop/close specific port *** */
1238 struct cmd_operate_specific_port_result {
1239 cmdline_fixed_string_t keyword;
1240 cmdline_fixed_string_t name;
1244 static void cmd_operate_specific_port_parsed(void *parsed_result,
1245 __rte_unused struct cmdline *cl,
1246 __rte_unused void *data)
1248 struct cmd_operate_specific_port_result *res = parsed_result;
1250 if (!strcmp(res->name, "start"))
1251 start_port(res->value);
1252 else if (!strcmp(res->name, "stop"))
1253 stop_port(res->value);
1254 else if (!strcmp(res->name, "close"))
1255 close_port(res->value);
1256 else if (!strcmp(res->name, "reset"))
1257 reset_port(res->value);
1259 printf("Unknown parameter\n");
1262 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1263 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1265 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1266 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1267 name, "start#stop#close#reset");
1268 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1269 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1272 cmdline_parse_inst_t cmd_operate_specific_port = {
1273 .f = cmd_operate_specific_port_parsed,
1275 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1277 (void *)&cmd_operate_specific_port_cmd,
1278 (void *)&cmd_operate_specific_port_port,
1279 (void *)&cmd_operate_specific_port_id,
1284 /* *** enable port setup (after attach) via iterator or event *** */
1285 struct cmd_set_port_setup_on_result {
1286 cmdline_fixed_string_t set;
1287 cmdline_fixed_string_t port;
1288 cmdline_fixed_string_t setup;
1289 cmdline_fixed_string_t on;
1290 cmdline_fixed_string_t mode;
1293 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1294 __rte_unused struct cmdline *cl,
1295 __rte_unused void *data)
1297 struct cmd_set_port_setup_on_result *res = parsed_result;
1299 if (strcmp(res->mode, "event") == 0)
1300 setup_on_probe_event = true;
1301 else if (strcmp(res->mode, "iterator") == 0)
1302 setup_on_probe_event = false;
1304 printf("Unknown mode\n");
1307 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1308 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1310 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1311 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1313 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1314 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1316 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1317 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1319 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1320 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1321 mode, "iterator#event");
1323 cmdline_parse_inst_t cmd_set_port_setup_on = {
1324 .f = cmd_set_port_setup_on_parsed,
1326 .help_str = "set port setup on iterator|event",
1328 (void *)&cmd_set_port_setup_on_set,
1329 (void *)&cmd_set_port_setup_on_port,
1330 (void *)&cmd_set_port_setup_on_setup,
1331 (void *)&cmd_set_port_setup_on_on,
1332 (void *)&cmd_set_port_setup_on_mode,
1337 /* *** attach a specified port *** */
1338 struct cmd_operate_attach_port_result {
1339 cmdline_fixed_string_t port;
1340 cmdline_fixed_string_t keyword;
1341 cmdline_multi_string_t identifier;
1344 static void cmd_operate_attach_port_parsed(void *parsed_result,
1345 __rte_unused struct cmdline *cl,
1346 __rte_unused void *data)
1348 struct cmd_operate_attach_port_result *res = parsed_result;
1350 if (!strcmp(res->keyword, "attach"))
1351 attach_port(res->identifier);
1353 printf("Unknown parameter\n");
1356 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1357 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1359 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1360 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1362 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1363 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1364 identifier, TOKEN_STRING_MULTI);
1366 cmdline_parse_inst_t cmd_operate_attach_port = {
1367 .f = cmd_operate_attach_port_parsed,
1369 .help_str = "port attach <identifier>: "
1370 "(identifier: pci address or virtual dev name)",
1372 (void *)&cmd_operate_attach_port_port,
1373 (void *)&cmd_operate_attach_port_keyword,
1374 (void *)&cmd_operate_attach_port_identifier,
1379 /* *** detach a specified port *** */
1380 struct cmd_operate_detach_port_result {
1381 cmdline_fixed_string_t port;
1382 cmdline_fixed_string_t keyword;
1386 static void cmd_operate_detach_port_parsed(void *parsed_result,
1387 __rte_unused struct cmdline *cl,
1388 __rte_unused void *data)
1390 struct cmd_operate_detach_port_result *res = parsed_result;
1392 if (!strcmp(res->keyword, "detach")) {
1393 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1394 detach_port_device(res->port_id);
1396 printf("Unknown parameter\n");
1400 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1401 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1403 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1404 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1406 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1407 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1410 cmdline_parse_inst_t cmd_operate_detach_port = {
1411 .f = cmd_operate_detach_port_parsed,
1413 .help_str = "port detach <port_id>",
1415 (void *)&cmd_operate_detach_port_port,
1416 (void *)&cmd_operate_detach_port_keyword,
1417 (void *)&cmd_operate_detach_port_port_id,
1422 /* *** detach device by identifier *** */
1423 struct cmd_operate_detach_device_result {
1424 cmdline_fixed_string_t device;
1425 cmdline_fixed_string_t keyword;
1426 cmdline_fixed_string_t identifier;
1429 static void cmd_operate_detach_device_parsed(void *parsed_result,
1430 __rte_unused struct cmdline *cl,
1431 __rte_unused void *data)
1433 struct cmd_operate_detach_device_result *res = parsed_result;
1435 if (!strcmp(res->keyword, "detach"))
1436 detach_devargs(res->identifier);
1438 printf("Unknown parameter\n");
1441 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1442 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1444 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1445 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1447 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1448 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1451 cmdline_parse_inst_t cmd_operate_detach_device = {
1452 .f = cmd_operate_detach_device_parsed,
1454 .help_str = "device detach <identifier>:"
1455 "(identifier: pci address or virtual dev name)",
1457 (void *)&cmd_operate_detach_device_device,
1458 (void *)&cmd_operate_detach_device_keyword,
1459 (void *)&cmd_operate_detach_device_identifier,
1463 /* *** configure speed for all ports *** */
1464 struct cmd_config_speed_all {
1465 cmdline_fixed_string_t port;
1466 cmdline_fixed_string_t keyword;
1467 cmdline_fixed_string_t all;
1468 cmdline_fixed_string_t item1;
1469 cmdline_fixed_string_t item2;
1470 cmdline_fixed_string_t value1;
1471 cmdline_fixed_string_t value2;
1475 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1480 if (!strcmp(duplexstr, "half")) {
1481 duplex = ETH_LINK_HALF_DUPLEX;
1482 } else if (!strcmp(duplexstr, "full")) {
1483 duplex = ETH_LINK_FULL_DUPLEX;
1484 } else if (!strcmp(duplexstr, "auto")) {
1485 duplex = ETH_LINK_FULL_DUPLEX;
1487 printf("Unknown duplex parameter\n");
1491 if (!strcmp(speedstr, "10")) {
1492 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1493 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1494 } else if (!strcmp(speedstr, "100")) {
1495 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1496 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1498 if (duplex != ETH_LINK_FULL_DUPLEX) {
1499 printf("Invalid speed/duplex parameters\n");
1502 if (!strcmp(speedstr, "1000")) {
1503 *speed = ETH_LINK_SPEED_1G;
1504 } else if (!strcmp(speedstr, "10000")) {
1505 *speed = ETH_LINK_SPEED_10G;
1506 } else if (!strcmp(speedstr, "25000")) {
1507 *speed = ETH_LINK_SPEED_25G;
1508 } else if (!strcmp(speedstr, "40000")) {
1509 *speed = ETH_LINK_SPEED_40G;
1510 } else if (!strcmp(speedstr, "50000")) {
1511 *speed = ETH_LINK_SPEED_50G;
1512 } else if (!strcmp(speedstr, "100000")) {
1513 *speed = ETH_LINK_SPEED_100G;
1514 } else if (!strcmp(speedstr, "200000")) {
1515 *speed = ETH_LINK_SPEED_200G;
1516 } else if (!strcmp(speedstr, "auto")) {
1517 *speed = ETH_LINK_SPEED_AUTONEG;
1519 printf("Unknown speed parameter\n");
1528 cmd_config_speed_all_parsed(void *parsed_result,
1529 __rte_unused struct cmdline *cl,
1530 __rte_unused void *data)
1532 struct cmd_config_speed_all *res = parsed_result;
1533 uint32_t link_speed;
1536 if (!all_ports_stopped()) {
1537 printf("Please stop all ports first\n");
1541 if (parse_and_check_speed_duplex(res->value1, res->value2,
1545 RTE_ETH_FOREACH_DEV(pid) {
1546 ports[pid].dev_conf.link_speeds = link_speed;
1549 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1552 cmdline_parse_token_string_t cmd_config_speed_all_port =
1553 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1554 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1555 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1557 cmdline_parse_token_string_t cmd_config_speed_all_all =
1558 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1559 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1560 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1561 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1562 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1563 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1564 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1565 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1566 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1567 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1570 cmdline_parse_inst_t cmd_config_speed_all = {
1571 .f = cmd_config_speed_all_parsed,
1573 .help_str = "port config all speed "
1574 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1577 (void *)&cmd_config_speed_all_port,
1578 (void *)&cmd_config_speed_all_keyword,
1579 (void *)&cmd_config_speed_all_all,
1580 (void *)&cmd_config_speed_all_item1,
1581 (void *)&cmd_config_speed_all_value1,
1582 (void *)&cmd_config_speed_all_item2,
1583 (void *)&cmd_config_speed_all_value2,
1588 /* *** configure speed for specific port *** */
1589 struct cmd_config_speed_specific {
1590 cmdline_fixed_string_t port;
1591 cmdline_fixed_string_t keyword;
1593 cmdline_fixed_string_t item1;
1594 cmdline_fixed_string_t item2;
1595 cmdline_fixed_string_t value1;
1596 cmdline_fixed_string_t value2;
1600 cmd_config_speed_specific_parsed(void *parsed_result,
1601 __rte_unused struct cmdline *cl,
1602 __rte_unused void *data)
1604 struct cmd_config_speed_specific *res = parsed_result;
1605 uint32_t link_speed;
1607 if (!all_ports_stopped()) {
1608 printf("Please stop all ports first\n");
1612 if (port_id_is_invalid(res->id, ENABLED_WARN))
1615 if (parse_and_check_speed_duplex(res->value1, res->value2,
1619 ports[res->id].dev_conf.link_speeds = link_speed;
1621 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1625 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1626 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1628 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1629 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1631 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1632 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1633 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1634 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1636 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1637 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1638 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1639 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1640 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1642 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1643 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1646 cmdline_parse_inst_t cmd_config_speed_specific = {
1647 .f = cmd_config_speed_specific_parsed,
1649 .help_str = "port config <port_id> speed "
1650 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1653 (void *)&cmd_config_speed_specific_port,
1654 (void *)&cmd_config_speed_specific_keyword,
1655 (void *)&cmd_config_speed_specific_id,
1656 (void *)&cmd_config_speed_specific_item1,
1657 (void *)&cmd_config_speed_specific_value1,
1658 (void *)&cmd_config_speed_specific_item2,
1659 (void *)&cmd_config_speed_specific_value2,
1664 /* *** configure loopback for all ports *** */
1665 struct cmd_config_loopback_all {
1666 cmdline_fixed_string_t port;
1667 cmdline_fixed_string_t keyword;
1668 cmdline_fixed_string_t all;
1669 cmdline_fixed_string_t item;
1674 cmd_config_loopback_all_parsed(void *parsed_result,
1675 __rte_unused struct cmdline *cl,
1676 __rte_unused void *data)
1678 struct cmd_config_loopback_all *res = parsed_result;
1681 if (!all_ports_stopped()) {
1682 printf("Please stop all ports first\n");
1686 RTE_ETH_FOREACH_DEV(pid) {
1687 ports[pid].dev_conf.lpbk_mode = res->mode;
1690 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1693 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1694 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1695 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1696 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1698 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1699 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1700 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1701 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1703 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1704 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1706 cmdline_parse_inst_t cmd_config_loopback_all = {
1707 .f = cmd_config_loopback_all_parsed,
1709 .help_str = "port config all loopback <mode>",
1711 (void *)&cmd_config_loopback_all_port,
1712 (void *)&cmd_config_loopback_all_keyword,
1713 (void *)&cmd_config_loopback_all_all,
1714 (void *)&cmd_config_loopback_all_item,
1715 (void *)&cmd_config_loopback_all_mode,
1720 /* *** configure loopback for specific port *** */
1721 struct cmd_config_loopback_specific {
1722 cmdline_fixed_string_t port;
1723 cmdline_fixed_string_t keyword;
1725 cmdline_fixed_string_t item;
1730 cmd_config_loopback_specific_parsed(void *parsed_result,
1731 __rte_unused struct cmdline *cl,
1732 __rte_unused void *data)
1734 struct cmd_config_loopback_specific *res = parsed_result;
1736 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1739 if (!port_is_stopped(res->port_id)) {
1740 printf("Please stop port %u first\n", res->port_id);
1744 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1746 cmd_reconfig_device_queue(res->port_id, 1, 1);
1750 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1751 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1753 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1754 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1756 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1757 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1759 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1760 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1762 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1763 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1766 cmdline_parse_inst_t cmd_config_loopback_specific = {
1767 .f = cmd_config_loopback_specific_parsed,
1769 .help_str = "port config <port_id> loopback <mode>",
1771 (void *)&cmd_config_loopback_specific_port,
1772 (void *)&cmd_config_loopback_specific_keyword,
1773 (void *)&cmd_config_loopback_specific_id,
1774 (void *)&cmd_config_loopback_specific_item,
1775 (void *)&cmd_config_loopback_specific_mode,
1780 /* *** configure txq/rxq, txd/rxd *** */
1781 struct cmd_config_rx_tx {
1782 cmdline_fixed_string_t port;
1783 cmdline_fixed_string_t keyword;
1784 cmdline_fixed_string_t all;
1785 cmdline_fixed_string_t name;
1790 cmd_config_rx_tx_parsed(void *parsed_result,
1791 __rte_unused struct cmdline *cl,
1792 __rte_unused void *data)
1794 struct cmd_config_rx_tx *res = parsed_result;
1796 if (!all_ports_stopped()) {
1797 printf("Please stop all ports first\n");
1800 if (!strcmp(res->name, "rxq")) {
1801 if (!res->value && !nb_txq) {
1802 printf("Warning: Either rx or tx queues should be non zero\n");
1805 if (check_nb_rxq(res->value) != 0)
1807 nb_rxq = res->value;
1809 else if (!strcmp(res->name, "txq")) {
1810 if (!res->value && !nb_rxq) {
1811 printf("Warning: Either rx or tx queues should be non zero\n");
1814 if (check_nb_txq(res->value) != 0)
1816 nb_txq = res->value;
1818 else if (!strcmp(res->name, "rxd")) {
1819 if (check_nb_rxd(res->value) != 0)
1821 nb_rxd = res->value;
1822 } else if (!strcmp(res->name, "txd")) {
1823 if (check_nb_txd(res->value) != 0)
1826 nb_txd = res->value;
1828 printf("Unknown parameter\n");
1836 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1839 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1840 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1841 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1842 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1843 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1844 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1845 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1846 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1848 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1849 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1851 cmdline_parse_inst_t cmd_config_rx_tx = {
1852 .f = cmd_config_rx_tx_parsed,
1854 .help_str = "port config all rxq|txq|rxd|txd <value>",
1856 (void *)&cmd_config_rx_tx_port,
1857 (void *)&cmd_config_rx_tx_keyword,
1858 (void *)&cmd_config_rx_tx_all,
1859 (void *)&cmd_config_rx_tx_name,
1860 (void *)&cmd_config_rx_tx_value,
1865 /* *** config max packet length *** */
1866 struct cmd_config_max_pkt_len_result {
1867 cmdline_fixed_string_t port;
1868 cmdline_fixed_string_t keyword;
1869 cmdline_fixed_string_t all;
1870 cmdline_fixed_string_t name;
1875 cmd_config_max_pkt_len_parsed(void *parsed_result,
1876 __rte_unused struct cmdline *cl,
1877 __rte_unused void *data)
1879 struct cmd_config_max_pkt_len_result *res = parsed_result;
1882 if (!all_ports_stopped()) {
1883 printf("Please stop all ports first\n");
1887 RTE_ETH_FOREACH_DEV(pid) {
1888 struct rte_port *port = &ports[pid];
1889 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1891 if (!strcmp(res->name, "max-pkt-len")) {
1892 if (res->value < RTE_ETHER_MIN_LEN) {
1893 printf("max-pkt-len can not be less than %d\n",
1897 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1900 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1901 if (res->value > RTE_ETHER_MAX_LEN)
1902 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1904 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1905 port->dev_conf.rxmode.offloads = rx_offloads;
1907 printf("Unknown parameter\n");
1914 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1917 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1918 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1920 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1921 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1923 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1924 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1926 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1927 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1929 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1930 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1933 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1934 .f = cmd_config_max_pkt_len_parsed,
1936 .help_str = "port config all max-pkt-len <value>",
1938 (void *)&cmd_config_max_pkt_len_port,
1939 (void *)&cmd_config_max_pkt_len_keyword,
1940 (void *)&cmd_config_max_pkt_len_all,
1941 (void *)&cmd_config_max_pkt_len_name,
1942 (void *)&cmd_config_max_pkt_len_value,
1947 /* *** config max LRO aggregated packet size *** */
1948 struct cmd_config_max_lro_pkt_size_result {
1949 cmdline_fixed_string_t port;
1950 cmdline_fixed_string_t keyword;
1951 cmdline_fixed_string_t all;
1952 cmdline_fixed_string_t name;
1957 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1958 __rte_unused struct cmdline *cl,
1959 __rte_unused void *data)
1961 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1964 if (!all_ports_stopped()) {
1965 printf("Please stop all ports first\n");
1969 RTE_ETH_FOREACH_DEV(pid) {
1970 struct rte_port *port = &ports[pid];
1972 if (!strcmp(res->name, "max-lro-pkt-size")) {
1974 port->dev_conf.rxmode.max_lro_pkt_size)
1977 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
1979 printf("Unknown parameter\n");
1986 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1989 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
1990 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1992 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
1993 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1995 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
1996 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1998 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
1999 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2000 name, "max-lro-pkt-size");
2001 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2002 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2005 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2006 .f = cmd_config_max_lro_pkt_size_parsed,
2008 .help_str = "port config all max-lro-pkt-size <value>",
2010 (void *)&cmd_config_max_lro_pkt_size_port,
2011 (void *)&cmd_config_max_lro_pkt_size_keyword,
2012 (void *)&cmd_config_max_lro_pkt_size_all,
2013 (void *)&cmd_config_max_lro_pkt_size_name,
2014 (void *)&cmd_config_max_lro_pkt_size_value,
2019 /* *** configure port MTU *** */
2020 struct cmd_config_mtu_result {
2021 cmdline_fixed_string_t port;
2022 cmdline_fixed_string_t keyword;
2023 cmdline_fixed_string_t mtu;
2029 cmd_config_mtu_parsed(void *parsed_result,
2030 __rte_unused struct cmdline *cl,
2031 __rte_unused void *data)
2033 struct cmd_config_mtu_result *res = parsed_result;
2035 if (res->value < RTE_ETHER_MIN_LEN) {
2036 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2039 port_mtu_set(res->port_id, res->value);
2042 cmdline_parse_token_string_t cmd_config_mtu_port =
2043 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2045 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2046 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2048 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2049 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2051 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2052 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2053 cmdline_parse_token_num_t cmd_config_mtu_value =
2054 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2056 cmdline_parse_inst_t cmd_config_mtu = {
2057 .f = cmd_config_mtu_parsed,
2059 .help_str = "port config mtu <port_id> <value>",
2061 (void *)&cmd_config_mtu_port,
2062 (void *)&cmd_config_mtu_keyword,
2063 (void *)&cmd_config_mtu_mtu,
2064 (void *)&cmd_config_mtu_port_id,
2065 (void *)&cmd_config_mtu_value,
2070 /* *** configure rx mode *** */
2071 struct cmd_config_rx_mode_flag {
2072 cmdline_fixed_string_t port;
2073 cmdline_fixed_string_t keyword;
2074 cmdline_fixed_string_t all;
2075 cmdline_fixed_string_t name;
2076 cmdline_fixed_string_t value;
2080 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2081 __rte_unused struct cmdline *cl,
2082 __rte_unused void *data)
2084 struct cmd_config_rx_mode_flag *res = parsed_result;
2086 if (!all_ports_stopped()) {
2087 printf("Please stop all ports first\n");
2091 if (!strcmp(res->name, "drop-en")) {
2092 if (!strcmp(res->value, "on"))
2094 else if (!strcmp(res->value, "off"))
2097 printf("Unknown parameter\n");
2101 printf("Unknown parameter\n");
2107 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2110 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2111 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2112 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2113 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2115 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2116 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2117 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2118 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2120 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2121 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2124 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2125 .f = cmd_config_rx_mode_flag_parsed,
2127 .help_str = "port config all drop-en on|off",
2129 (void *)&cmd_config_rx_mode_flag_port,
2130 (void *)&cmd_config_rx_mode_flag_keyword,
2131 (void *)&cmd_config_rx_mode_flag_all,
2132 (void *)&cmd_config_rx_mode_flag_name,
2133 (void *)&cmd_config_rx_mode_flag_value,
2138 /* *** configure rss *** */
2139 struct cmd_config_rss {
2140 cmdline_fixed_string_t port;
2141 cmdline_fixed_string_t keyword;
2142 cmdline_fixed_string_t all;
2143 cmdline_fixed_string_t name;
2144 cmdline_fixed_string_t value;
2148 cmd_config_rss_parsed(void *parsed_result,
2149 __rte_unused struct cmdline *cl,
2150 __rte_unused void *data)
2152 struct cmd_config_rss *res = parsed_result;
2153 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2154 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2155 int use_default = 0;
2156 int all_updated = 1;
2161 if (!strcmp(res->value, "all"))
2162 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2163 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2164 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2165 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU;
2166 else if (!strcmp(res->value, "eth"))
2167 rss_conf.rss_hf = ETH_RSS_ETH;
2168 else if (!strcmp(res->value, "vlan"))
2169 rss_conf.rss_hf = ETH_RSS_VLAN;
2170 else if (!strcmp(res->value, "ip"))
2171 rss_conf.rss_hf = ETH_RSS_IP;
2172 else if (!strcmp(res->value, "udp"))
2173 rss_conf.rss_hf = ETH_RSS_UDP;
2174 else if (!strcmp(res->value, "tcp"))
2175 rss_conf.rss_hf = ETH_RSS_TCP;
2176 else if (!strcmp(res->value, "sctp"))
2177 rss_conf.rss_hf = ETH_RSS_SCTP;
2178 else if (!strcmp(res->value, "ether"))
2179 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2180 else if (!strcmp(res->value, "port"))
2181 rss_conf.rss_hf = ETH_RSS_PORT;
2182 else if (!strcmp(res->value, "vxlan"))
2183 rss_conf.rss_hf = ETH_RSS_VXLAN;
2184 else if (!strcmp(res->value, "geneve"))
2185 rss_conf.rss_hf = ETH_RSS_GENEVE;
2186 else if (!strcmp(res->value, "nvgre"))
2187 rss_conf.rss_hf = ETH_RSS_NVGRE;
2188 else if (!strcmp(res->value, "l3-pre32"))
2189 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2190 else if (!strcmp(res->value, "l3-pre40"))
2191 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2192 else if (!strcmp(res->value, "l3-pre48"))
2193 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2194 else if (!strcmp(res->value, "l3-pre56"))
2195 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2196 else if (!strcmp(res->value, "l3-pre64"))
2197 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2198 else if (!strcmp(res->value, "l3-pre96"))
2199 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2200 else if (!strcmp(res->value, "l3-src-only"))
2201 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2202 else if (!strcmp(res->value, "l3-dst-only"))
2203 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2204 else if (!strcmp(res->value, "l4-src-only"))
2205 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2206 else if (!strcmp(res->value, "l4-dst-only"))
2207 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2208 else if (!strcmp(res->value, "l2-src-only"))
2209 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2210 else if (!strcmp(res->value, "l2-dst-only"))
2211 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2212 else if (!strcmp(res->value, "l2tpv3"))
2213 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2214 else if (!strcmp(res->value, "esp"))
2215 rss_conf.rss_hf = ETH_RSS_ESP;
2216 else if (!strcmp(res->value, "ah"))
2217 rss_conf.rss_hf = ETH_RSS_AH;
2218 else if (!strcmp(res->value, "pfcp"))
2219 rss_conf.rss_hf = ETH_RSS_PFCP;
2220 else if (!strcmp(res->value, "pppoe"))
2221 rss_conf.rss_hf = ETH_RSS_PPPOE;
2222 else if (!strcmp(res->value, "gtpu"))
2223 rss_conf.rss_hf = ETH_RSS_GTPU;
2224 else if (!strcmp(res->value, "none"))
2225 rss_conf.rss_hf = 0;
2226 else if (!strcmp(res->value, "level-default")) {
2227 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2228 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2229 } else if (!strcmp(res->value, "level-outer")) {
2230 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2231 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2232 } else if (!strcmp(res->value, "level-inner")) {
2233 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2234 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2235 } else if (!strcmp(res->value, "default"))
2237 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2238 atoi(res->value) < 64)
2239 rss_conf.rss_hf = 1ULL << atoi(res->value);
2241 printf("Unknown parameter\n");
2244 rss_conf.rss_key = NULL;
2245 /* Update global configuration for RSS types. */
2246 RTE_ETH_FOREACH_DEV(i) {
2247 struct rte_eth_rss_conf local_rss_conf;
2249 ret = eth_dev_info_get_print_err(i, &dev_info);
2254 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2256 local_rss_conf = rss_conf;
2257 local_rss_conf.rss_hf = rss_conf.rss_hf &
2258 dev_info.flow_type_rss_offloads;
2259 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2260 printf("Port %u modified RSS hash function based on hardware support,"
2261 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2262 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2264 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2267 printf("Configuration of RSS hash at ethernet port %d "
2268 "failed with error (%d): %s.\n",
2269 i, -diag, strerror(-diag));
2272 if (all_updated && !use_default) {
2273 rss_hf = rss_conf.rss_hf;
2274 printf("rss_hf %#"PRIx64"\n", rss_hf);
2278 cmdline_parse_token_string_t cmd_config_rss_port =
2279 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2280 cmdline_parse_token_string_t cmd_config_rss_keyword =
2281 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2282 cmdline_parse_token_string_t cmd_config_rss_all =
2283 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2284 cmdline_parse_token_string_t cmd_config_rss_name =
2285 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2286 cmdline_parse_token_string_t cmd_config_rss_value =
2287 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2289 cmdline_parse_inst_t cmd_config_rss = {
2290 .f = cmd_config_rss_parsed,
2292 .help_str = "port config all rss "
2293 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2294 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|none|level-default|"
2295 "level-outer|level-inner|<flowtype_id>",
2297 (void *)&cmd_config_rss_port,
2298 (void *)&cmd_config_rss_keyword,
2299 (void *)&cmd_config_rss_all,
2300 (void *)&cmd_config_rss_name,
2301 (void *)&cmd_config_rss_value,
2306 /* *** configure rss hash key *** */
2307 struct cmd_config_rss_hash_key {
2308 cmdline_fixed_string_t port;
2309 cmdline_fixed_string_t config;
2311 cmdline_fixed_string_t rss_hash_key;
2312 cmdline_fixed_string_t rss_type;
2313 cmdline_fixed_string_t key;
2317 hexa_digit_to_value(char hexa_digit)
2319 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2320 return (uint8_t) (hexa_digit - '0');
2321 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2322 return (uint8_t) ((hexa_digit - 'a') + 10);
2323 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2324 return (uint8_t) ((hexa_digit - 'A') + 10);
2325 /* Invalid hexa digit */
2330 parse_and_check_key_hexa_digit(char *key, int idx)
2334 hexa_v = hexa_digit_to_value(key[idx]);
2336 printf("invalid key: character %c at position %d is not a "
2337 "valid hexa digit\n", key[idx], idx);
2342 cmd_config_rss_hash_key_parsed(void *parsed_result,
2343 __rte_unused struct cmdline *cl,
2344 __rte_unused void *data)
2346 struct cmd_config_rss_hash_key *res = parsed_result;
2347 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2351 struct rte_eth_dev_info dev_info;
2352 uint8_t hash_key_size;
2356 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2360 if (dev_info.hash_key_size > 0 &&
2361 dev_info.hash_key_size <= sizeof(hash_key))
2362 hash_key_size = dev_info.hash_key_size;
2364 printf("dev_info did not provide a valid hash key size\n");
2367 /* Check the length of the RSS hash key */
2368 key_len = strlen(res->key);
2369 if (key_len != (hash_key_size * 2)) {
2370 printf("key length: %d invalid - key must be a string of %d"
2371 " hexa-decimal numbers\n",
2372 (int) key_len, hash_key_size * 2);
2375 /* Translate RSS hash key into binary representation */
2376 for (i = 0; i < hash_key_size; i++) {
2377 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2380 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2383 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2385 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2389 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2390 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2391 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2392 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2394 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2395 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2396 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2397 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2398 rss_hash_key, "rss-hash-key");
2399 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2400 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2401 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2402 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2403 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2404 "ipv6-tcp-ex#ipv6-udp-ex#"
2405 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2406 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2407 "l2tpv3#esp#ah#pfcp#pppoe#gtpu");
2408 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2409 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2411 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2412 .f = cmd_config_rss_hash_key_parsed,
2414 .help_str = "port config <port_id> rss-hash-key "
2415 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2416 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2417 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2418 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2419 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2420 "l2tpv3|esp|ah|pfcp|pppoe|gtpu "
2421 "<string of hex digits (variable length, NIC dependent)>",
2423 (void *)&cmd_config_rss_hash_key_port,
2424 (void *)&cmd_config_rss_hash_key_config,
2425 (void *)&cmd_config_rss_hash_key_port_id,
2426 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2427 (void *)&cmd_config_rss_hash_key_rss_type,
2428 (void *)&cmd_config_rss_hash_key_value,
2433 /* *** configure port rxq/txq ring size *** */
2434 struct cmd_config_rxtx_ring_size {
2435 cmdline_fixed_string_t port;
2436 cmdline_fixed_string_t config;
2438 cmdline_fixed_string_t rxtxq;
2440 cmdline_fixed_string_t rsize;
2445 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2446 __rte_unused struct cmdline *cl,
2447 __rte_unused void *data)
2449 struct cmd_config_rxtx_ring_size *res = parsed_result;
2450 struct rte_port *port;
2453 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2456 if (res->portid == (portid_t)RTE_PORT_ALL) {
2457 printf("Invalid port id\n");
2461 port = &ports[res->portid];
2463 if (!strcmp(res->rxtxq, "rxq"))
2465 else if (!strcmp(res->rxtxq, "txq"))
2468 printf("Unknown parameter\n");
2472 if (isrx && rx_queue_id_is_invalid(res->qid))
2474 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2477 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2478 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2484 port->nb_rx_desc[res->qid] = res->size;
2486 port->nb_tx_desc[res->qid] = res->size;
2488 cmd_reconfig_device_queue(res->portid, 0, 1);
2491 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2492 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2494 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2495 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2497 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2498 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2500 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2501 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2503 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2504 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2506 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2507 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2508 rsize, "ring_size");
2509 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2510 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2513 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2514 .f = cmd_config_rxtx_ring_size_parsed,
2516 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2518 (void *)&cmd_config_rxtx_ring_size_port,
2519 (void *)&cmd_config_rxtx_ring_size_config,
2520 (void *)&cmd_config_rxtx_ring_size_portid,
2521 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2522 (void *)&cmd_config_rxtx_ring_size_qid,
2523 (void *)&cmd_config_rxtx_ring_size_rsize,
2524 (void *)&cmd_config_rxtx_ring_size_size,
2529 /* *** configure port rxq/txq start/stop *** */
2530 struct cmd_config_rxtx_queue {
2531 cmdline_fixed_string_t port;
2533 cmdline_fixed_string_t rxtxq;
2535 cmdline_fixed_string_t opname;
2539 cmd_config_rxtx_queue_parsed(void *parsed_result,
2540 __rte_unused struct cmdline *cl,
2541 __rte_unused void *data)
2543 struct cmd_config_rxtx_queue *res = parsed_result;
2548 if (test_done == 0) {
2549 printf("Please stop forwarding first\n");
2553 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2556 if (port_is_started(res->portid) != 1) {
2557 printf("Please start port %u first\n", res->portid);
2561 if (!strcmp(res->rxtxq, "rxq"))
2563 else if (!strcmp(res->rxtxq, "txq"))
2566 printf("Unknown parameter\n");
2570 if (isrx && rx_queue_id_is_invalid(res->qid))
2572 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2575 if (!strcmp(res->opname, "start"))
2577 else if (!strcmp(res->opname, "stop"))
2580 printf("Unknown parameter\n");
2584 if (isstart && isrx)
2585 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2586 else if (!isstart && isrx)
2587 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2588 else if (isstart && !isrx)
2589 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2591 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2593 if (ret == -ENOTSUP)
2594 printf("Function not supported in PMD driver\n");
2597 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2598 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2599 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2600 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2601 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2602 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2603 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2604 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2605 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2606 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2609 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2610 .f = cmd_config_rxtx_queue_parsed,
2612 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2614 (void *)&cmd_config_rxtx_queue_port,
2615 (void *)&cmd_config_rxtx_queue_portid,
2616 (void *)&cmd_config_rxtx_queue_rxtxq,
2617 (void *)&cmd_config_rxtx_queue_qid,
2618 (void *)&cmd_config_rxtx_queue_opname,
2623 /* *** configure port rxq/txq deferred start on/off *** */
2624 struct cmd_config_deferred_start_rxtx_queue {
2625 cmdline_fixed_string_t port;
2627 cmdline_fixed_string_t rxtxq;
2629 cmdline_fixed_string_t opname;
2630 cmdline_fixed_string_t state;
2634 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2635 __rte_unused struct cmdline *cl,
2636 __rte_unused void *data)
2638 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2639 struct rte_port *port;
2642 uint8_t needreconfig = 0;
2644 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2647 if (port_is_started(res->port_id) != 0) {
2648 printf("Please stop port %u first\n", res->port_id);
2652 port = &ports[res->port_id];
2654 isrx = !strcmp(res->rxtxq, "rxq");
2656 if (isrx && rx_queue_id_is_invalid(res->qid))
2658 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2661 ison = !strcmp(res->state, "on");
2663 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2664 port->rx_conf[res->qid].rx_deferred_start = ison;
2666 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2667 port->tx_conf[res->qid].tx_deferred_start = ison;
2672 cmd_reconfig_device_queue(res->port_id, 0, 1);
2675 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2676 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2678 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2679 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2681 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2682 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2684 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2685 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2687 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2688 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2689 opname, "deferred_start");
2690 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2691 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2694 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2695 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2697 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2699 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2700 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2701 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2702 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2703 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2704 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2709 /* *** configure port rxq/txq setup *** */
2710 struct cmd_setup_rxtx_queue {
2711 cmdline_fixed_string_t port;
2713 cmdline_fixed_string_t rxtxq;
2715 cmdline_fixed_string_t setup;
2718 /* Common CLI fields for queue setup */
2719 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2720 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2721 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2722 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2723 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2724 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2725 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2726 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2727 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2728 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2731 cmd_setup_rxtx_queue_parsed(
2732 void *parsed_result,
2733 __rte_unused struct cmdline *cl,
2734 __rte_unused void *data)
2736 struct cmd_setup_rxtx_queue *res = parsed_result;
2737 struct rte_port *port;
2738 struct rte_mempool *mp;
2739 unsigned int socket_id;
2743 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2746 if (res->portid == (portid_t)RTE_PORT_ALL) {
2747 printf("Invalid port id\n");
2751 if (!strcmp(res->rxtxq, "rxq"))
2753 else if (!strcmp(res->rxtxq, "txq"))
2756 printf("Unknown parameter\n");
2760 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2761 printf("Invalid rx queue\n");
2763 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2764 printf("Invalid tx queue\n");
2768 port = &ports[res->portid];
2770 socket_id = rxring_numa[res->portid];
2771 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2772 socket_id = port->socket_id;
2774 mp = mbuf_pool_find(socket_id, 0);
2776 printf("Failed to setup RX queue: "
2777 "No mempool allocation"
2778 " on the socket %d\n",
2779 rxring_numa[res->portid]);
2782 ret = rx_queue_setup(res->portid,
2784 port->nb_rx_desc[res->qid],
2786 &port->rx_conf[res->qid],
2789 printf("Failed to setup RX queue\n");
2791 socket_id = txring_numa[res->portid];
2792 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2793 socket_id = port->socket_id;
2795 ret = rte_eth_tx_queue_setup(res->portid,
2797 port->nb_tx_desc[res->qid],
2799 &port->tx_conf[res->qid]);
2801 printf("Failed to setup TX queue\n");
2805 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2806 .f = cmd_setup_rxtx_queue_parsed,
2808 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2810 (void *)&cmd_setup_rxtx_queue_port,
2811 (void *)&cmd_setup_rxtx_queue_portid,
2812 (void *)&cmd_setup_rxtx_queue_rxtxq,
2813 (void *)&cmd_setup_rxtx_queue_qid,
2814 (void *)&cmd_setup_rxtx_queue_setup,
2820 /* *** Configure RSS RETA *** */
2821 struct cmd_config_rss_reta {
2822 cmdline_fixed_string_t port;
2823 cmdline_fixed_string_t keyword;
2825 cmdline_fixed_string_t name;
2826 cmdline_fixed_string_t list_name;
2827 cmdline_fixed_string_t list_of_items;
2831 parse_reta_config(const char *str,
2832 struct rte_eth_rss_reta_entry64 *reta_conf,
2833 uint16_t nb_entries)
2837 uint16_t hash_index, idx, shift;
2840 const char *p, *p0 = str;
2847 unsigned long int_fld[_NUM_FLD];
2848 char *str_fld[_NUM_FLD];
2850 while ((p = strchr(p0,'(')) != NULL) {
2852 if((p0 = strchr(p,')')) == NULL)
2856 if(size >= sizeof(s))
2859 snprintf(s, sizeof(s), "%.*s", size, p);
2860 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2862 for (i = 0; i < _NUM_FLD; i++) {
2864 int_fld[i] = strtoul(str_fld[i], &end, 0);
2865 if (errno != 0 || end == str_fld[i] ||
2870 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2871 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2873 if (hash_index >= nb_entries) {
2874 printf("Invalid RETA hash index=%d\n", hash_index);
2878 idx = hash_index / RTE_RETA_GROUP_SIZE;
2879 shift = hash_index % RTE_RETA_GROUP_SIZE;
2880 reta_conf[idx].mask |= (1ULL << shift);
2881 reta_conf[idx].reta[shift] = nb_queue;
2888 cmd_set_rss_reta_parsed(void *parsed_result,
2889 __rte_unused struct cmdline *cl,
2890 __rte_unused void *data)
2893 struct rte_eth_dev_info dev_info;
2894 struct rte_eth_rss_reta_entry64 reta_conf[8];
2895 struct cmd_config_rss_reta *res = parsed_result;
2897 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2901 if (dev_info.reta_size == 0) {
2902 printf("Redirection table size is 0 which is "
2903 "invalid for RSS\n");
2906 printf("The reta size of port %d is %u\n",
2907 res->port_id, dev_info.reta_size);
2908 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2909 printf("Currently do not support more than %u entries of "
2910 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2914 memset(reta_conf, 0, sizeof(reta_conf));
2915 if (!strcmp(res->list_name, "reta")) {
2916 if (parse_reta_config(res->list_of_items, reta_conf,
2917 dev_info.reta_size)) {
2918 printf("Invalid RSS Redirection Table "
2919 "config entered\n");
2922 ret = rte_eth_dev_rss_reta_update(res->port_id,
2923 reta_conf, dev_info.reta_size);
2925 printf("Bad redirection table parameter, "
2926 "return code = %d \n", ret);
2930 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2931 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2932 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2933 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2934 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2935 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2936 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2937 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2938 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2939 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2940 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2941 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2943 cmdline_parse_inst_t cmd_config_rss_reta = {
2944 .f = cmd_set_rss_reta_parsed,
2946 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2948 (void *)&cmd_config_rss_reta_port,
2949 (void *)&cmd_config_rss_reta_keyword,
2950 (void *)&cmd_config_rss_reta_port_id,
2951 (void *)&cmd_config_rss_reta_name,
2952 (void *)&cmd_config_rss_reta_list_name,
2953 (void *)&cmd_config_rss_reta_list_of_items,
2958 /* *** SHOW PORT RETA INFO *** */
2959 struct cmd_showport_reta {
2960 cmdline_fixed_string_t show;
2961 cmdline_fixed_string_t port;
2963 cmdline_fixed_string_t rss;
2964 cmdline_fixed_string_t reta;
2966 cmdline_fixed_string_t list_of_items;
2970 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2971 uint16_t nb_entries,
2975 const char *p, *p0 = str;
2980 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2981 RTE_RETA_GROUP_SIZE;
2984 p = strchr(p0, '(');
2988 p0 = strchr(p, ')');
2992 if (size >= sizeof(s)) {
2993 printf("The string size exceeds the internal buffer size\n");
2996 snprintf(s, sizeof(s), "%.*s", size, p);
2997 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2998 if (ret <= 0 || ret != num) {
2999 printf("The bits of masks do not match the number of "
3000 "reta entries: %u\n", num);
3003 for (i = 0; i < ret; i++)
3004 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3010 cmd_showport_reta_parsed(void *parsed_result,
3011 __rte_unused struct cmdline *cl,
3012 __rte_unused void *data)
3014 struct cmd_showport_reta *res = parsed_result;
3015 struct rte_eth_rss_reta_entry64 reta_conf[8];
3016 struct rte_eth_dev_info dev_info;
3017 uint16_t max_reta_size;
3020 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3024 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3025 if (res->size == 0 || res->size > max_reta_size) {
3026 printf("Invalid redirection table size: %u (1-%u)\n",
3027 res->size, max_reta_size);
3031 memset(reta_conf, 0, sizeof(reta_conf));
3032 if (showport_parse_reta_config(reta_conf, res->size,
3033 res->list_of_items) < 0) {
3034 printf("Invalid string: %s for reta masks\n",
3035 res->list_of_items);
3038 port_rss_reta_info(res->port_id, reta_conf, res->size);
3041 cmdline_parse_token_string_t cmd_showport_reta_show =
3042 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3043 cmdline_parse_token_string_t cmd_showport_reta_port =
3044 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3045 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3046 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3047 cmdline_parse_token_string_t cmd_showport_reta_rss =
3048 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3049 cmdline_parse_token_string_t cmd_showport_reta_reta =
3050 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3051 cmdline_parse_token_num_t cmd_showport_reta_size =
3052 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3053 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3054 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3055 list_of_items, NULL);
3057 cmdline_parse_inst_t cmd_showport_reta = {
3058 .f = cmd_showport_reta_parsed,
3060 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3062 (void *)&cmd_showport_reta_show,
3063 (void *)&cmd_showport_reta_port,
3064 (void *)&cmd_showport_reta_port_id,
3065 (void *)&cmd_showport_reta_rss,
3066 (void *)&cmd_showport_reta_reta,
3067 (void *)&cmd_showport_reta_size,
3068 (void *)&cmd_showport_reta_list_of_items,
3073 /* *** Show RSS hash configuration *** */
3074 struct cmd_showport_rss_hash {
3075 cmdline_fixed_string_t show;
3076 cmdline_fixed_string_t port;
3078 cmdline_fixed_string_t rss_hash;
3079 cmdline_fixed_string_t rss_type;
3080 cmdline_fixed_string_t key; /* optional argument */
3083 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3084 __rte_unused struct cmdline *cl,
3087 struct cmd_showport_rss_hash *res = parsed_result;
3089 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3092 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3093 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3094 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3095 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3096 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3097 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3098 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3099 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3101 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3102 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3104 cmdline_parse_inst_t cmd_showport_rss_hash = {
3105 .f = cmd_showport_rss_hash_parsed,
3107 .help_str = "show port <port_id> rss-hash",
3109 (void *)&cmd_showport_rss_hash_show,
3110 (void *)&cmd_showport_rss_hash_port,
3111 (void *)&cmd_showport_rss_hash_port_id,
3112 (void *)&cmd_showport_rss_hash_rss_hash,
3117 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3118 .f = cmd_showport_rss_hash_parsed,
3120 .help_str = "show port <port_id> rss-hash key",
3122 (void *)&cmd_showport_rss_hash_show,
3123 (void *)&cmd_showport_rss_hash_port,
3124 (void *)&cmd_showport_rss_hash_port_id,
3125 (void *)&cmd_showport_rss_hash_rss_hash,
3126 (void *)&cmd_showport_rss_hash_rss_key,
3131 /* *** Configure DCB *** */
3132 struct cmd_config_dcb {
3133 cmdline_fixed_string_t port;
3134 cmdline_fixed_string_t config;
3136 cmdline_fixed_string_t dcb;
3137 cmdline_fixed_string_t vt;
3138 cmdline_fixed_string_t vt_en;
3140 cmdline_fixed_string_t pfc;
3141 cmdline_fixed_string_t pfc_en;
3145 cmd_config_dcb_parsed(void *parsed_result,
3146 __rte_unused struct cmdline *cl,
3147 __rte_unused void *data)
3149 struct cmd_config_dcb *res = parsed_result;
3150 portid_t port_id = res->port_id;
3151 struct rte_port *port;
3155 port = &ports[port_id];
3156 /** Check if the port is not started **/
3157 if (port->port_status != RTE_PORT_STOPPED) {
3158 printf("Please stop port %d first\n", port_id);
3162 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3163 printf("The invalid number of traffic class,"
3164 " only 4 or 8 allowed.\n");
3168 if (nb_fwd_lcores < res->num_tcs) {
3169 printf("nb_cores shouldn't be less than number of TCs.\n");
3172 if (!strncmp(res->pfc_en, "on", 2))
3177 /* DCB in VT mode */
3178 if (!strncmp(res->vt_en, "on", 2))
3179 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3180 (enum rte_eth_nb_tcs)res->num_tcs,
3183 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3184 (enum rte_eth_nb_tcs)res->num_tcs,
3189 printf("Cannot initialize network ports.\n");
3193 cmd_reconfig_device_queue(port_id, 1, 1);
3196 cmdline_parse_token_string_t cmd_config_dcb_port =
3197 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3198 cmdline_parse_token_string_t cmd_config_dcb_config =
3199 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3200 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3201 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3202 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3203 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3204 cmdline_parse_token_string_t cmd_config_dcb_vt =
3205 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3206 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3207 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3208 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3209 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3210 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3211 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3212 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3213 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3215 cmdline_parse_inst_t cmd_config_dcb = {
3216 .f = cmd_config_dcb_parsed,
3218 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3220 (void *)&cmd_config_dcb_port,
3221 (void *)&cmd_config_dcb_config,
3222 (void *)&cmd_config_dcb_port_id,
3223 (void *)&cmd_config_dcb_dcb,
3224 (void *)&cmd_config_dcb_vt,
3225 (void *)&cmd_config_dcb_vt_en,
3226 (void *)&cmd_config_dcb_num_tcs,
3227 (void *)&cmd_config_dcb_pfc,
3228 (void *)&cmd_config_dcb_pfc_en,
3233 /* *** configure number of packets per burst *** */
3234 struct cmd_config_burst {
3235 cmdline_fixed_string_t port;
3236 cmdline_fixed_string_t keyword;
3237 cmdline_fixed_string_t all;
3238 cmdline_fixed_string_t name;
3243 cmd_config_burst_parsed(void *parsed_result,
3244 __rte_unused struct cmdline *cl,
3245 __rte_unused void *data)
3247 struct cmd_config_burst *res = parsed_result;
3248 struct rte_eth_dev_info dev_info;
3249 uint16_t rec_nb_pkts;
3252 if (!all_ports_stopped()) {
3253 printf("Please stop all ports first\n");
3257 if (!strcmp(res->name, "burst")) {
3258 if (res->value == 0) {
3259 /* If user gives a value of zero, query the PMD for
3260 * its recommended Rx burst size. Testpmd uses a single
3261 * size for all ports, so assume all ports are the same
3262 * NIC model and use the values from Port 0.
3264 ret = eth_dev_info_get_print_err(0, &dev_info);
3268 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3270 if (rec_nb_pkts == 0) {
3271 printf("PMD does not recommend a burst size.\n"
3272 "User provided value must be between"
3273 " 1 and %d\n", MAX_PKT_BURST);
3275 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3276 printf("PMD recommended burst size of %d"
3277 " exceeds maximum value of %d\n",
3278 rec_nb_pkts, MAX_PKT_BURST);
3281 printf("Using PMD-provided burst value of %d\n",
3283 nb_pkt_per_burst = rec_nb_pkts;
3284 } else if (res->value > MAX_PKT_BURST) {
3285 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3288 nb_pkt_per_burst = res->value;
3290 printf("Unknown parameter\n");
3296 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3299 cmdline_parse_token_string_t cmd_config_burst_port =
3300 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3301 cmdline_parse_token_string_t cmd_config_burst_keyword =
3302 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3303 cmdline_parse_token_string_t cmd_config_burst_all =
3304 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3305 cmdline_parse_token_string_t cmd_config_burst_name =
3306 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3307 cmdline_parse_token_num_t cmd_config_burst_value =
3308 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3310 cmdline_parse_inst_t cmd_config_burst = {
3311 .f = cmd_config_burst_parsed,
3313 .help_str = "port config all burst <value>",
3315 (void *)&cmd_config_burst_port,
3316 (void *)&cmd_config_burst_keyword,
3317 (void *)&cmd_config_burst_all,
3318 (void *)&cmd_config_burst_name,
3319 (void *)&cmd_config_burst_value,
3324 /* *** configure rx/tx queues *** */
3325 struct cmd_config_thresh {
3326 cmdline_fixed_string_t port;
3327 cmdline_fixed_string_t keyword;
3328 cmdline_fixed_string_t all;
3329 cmdline_fixed_string_t name;
3334 cmd_config_thresh_parsed(void *parsed_result,
3335 __rte_unused struct cmdline *cl,
3336 __rte_unused void *data)
3338 struct cmd_config_thresh *res = parsed_result;
3340 if (!all_ports_stopped()) {
3341 printf("Please stop all ports first\n");
3345 if (!strcmp(res->name, "txpt"))
3346 tx_pthresh = res->value;
3347 else if(!strcmp(res->name, "txht"))
3348 tx_hthresh = res->value;
3349 else if(!strcmp(res->name, "txwt"))
3350 tx_wthresh = res->value;
3351 else if(!strcmp(res->name, "rxpt"))
3352 rx_pthresh = res->value;
3353 else if(!strcmp(res->name, "rxht"))
3354 rx_hthresh = res->value;
3355 else if(!strcmp(res->name, "rxwt"))
3356 rx_wthresh = res->value;
3358 printf("Unknown parameter\n");
3364 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3367 cmdline_parse_token_string_t cmd_config_thresh_port =
3368 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3369 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3370 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3371 cmdline_parse_token_string_t cmd_config_thresh_all =
3372 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3373 cmdline_parse_token_string_t cmd_config_thresh_name =
3374 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3375 "txpt#txht#txwt#rxpt#rxht#rxwt");
3376 cmdline_parse_token_num_t cmd_config_thresh_value =
3377 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3379 cmdline_parse_inst_t cmd_config_thresh = {
3380 .f = cmd_config_thresh_parsed,
3382 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3384 (void *)&cmd_config_thresh_port,
3385 (void *)&cmd_config_thresh_keyword,
3386 (void *)&cmd_config_thresh_all,
3387 (void *)&cmd_config_thresh_name,
3388 (void *)&cmd_config_thresh_value,
3393 /* *** configure free/rs threshold *** */
3394 struct cmd_config_threshold {
3395 cmdline_fixed_string_t port;
3396 cmdline_fixed_string_t keyword;
3397 cmdline_fixed_string_t all;
3398 cmdline_fixed_string_t name;
3403 cmd_config_threshold_parsed(void *parsed_result,
3404 __rte_unused struct cmdline *cl,
3405 __rte_unused void *data)
3407 struct cmd_config_threshold *res = parsed_result;
3409 if (!all_ports_stopped()) {
3410 printf("Please stop all ports first\n");
3414 if (!strcmp(res->name, "txfreet"))
3415 tx_free_thresh = res->value;
3416 else if (!strcmp(res->name, "txrst"))
3417 tx_rs_thresh = res->value;
3418 else if (!strcmp(res->name, "rxfreet"))
3419 rx_free_thresh = res->value;
3421 printf("Unknown parameter\n");
3427 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3430 cmdline_parse_token_string_t cmd_config_threshold_port =
3431 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3432 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3433 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3435 cmdline_parse_token_string_t cmd_config_threshold_all =
3436 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3437 cmdline_parse_token_string_t cmd_config_threshold_name =
3438 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3439 "txfreet#txrst#rxfreet");
3440 cmdline_parse_token_num_t cmd_config_threshold_value =
3441 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3443 cmdline_parse_inst_t cmd_config_threshold = {
3444 .f = cmd_config_threshold_parsed,
3446 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3448 (void *)&cmd_config_threshold_port,
3449 (void *)&cmd_config_threshold_keyword,
3450 (void *)&cmd_config_threshold_all,
3451 (void *)&cmd_config_threshold_name,
3452 (void *)&cmd_config_threshold_value,
3458 struct cmd_stop_result {
3459 cmdline_fixed_string_t stop;
3462 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3463 __rte_unused struct cmdline *cl,
3464 __rte_unused void *data)
3466 stop_packet_forwarding();
3469 cmdline_parse_token_string_t cmd_stop_stop =
3470 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3472 cmdline_parse_inst_t cmd_stop = {
3473 .f = cmd_stop_parsed,
3475 .help_str = "stop: Stop packet forwarding",
3477 (void *)&cmd_stop_stop,
3482 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3485 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3486 unsigned int *parsed_items, int check_unique_values)
3488 unsigned int nb_item;
3496 * First parse all items in the list and store their value.
3501 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3503 if ((c >= '0') && (c <= '9')) {
3504 value = (unsigned int) (value * 10 + (c - '0'));
3509 printf("character %c is not a decimal digit\n", c);
3513 printf("No valid value before comma\n");
3516 if (nb_item < max_items) {
3517 parsed_items[nb_item] = value;
3523 if (nb_item >= max_items) {
3524 printf("Number of %s = %u > %u (maximum items)\n",
3525 item_name, nb_item + 1, max_items);
3528 parsed_items[nb_item++] = value;
3529 if (! check_unique_values)
3533 * Then, check that all values in the list are differents.
3534 * No optimization here...
3536 for (i = 0; i < nb_item; i++) {
3537 for (j = i + 1; j < nb_item; j++) {
3538 if (parsed_items[j] == parsed_items[i]) {
3539 printf("duplicated %s %u at index %u and %u\n",
3540 item_name, parsed_items[i], i, j);
3548 struct cmd_set_list_result {
3549 cmdline_fixed_string_t cmd_keyword;
3550 cmdline_fixed_string_t list_name;
3551 cmdline_fixed_string_t list_of_items;
3554 static void cmd_set_list_parsed(void *parsed_result,
3555 __rte_unused struct cmdline *cl,
3556 __rte_unused void *data)
3558 struct cmd_set_list_result *res;
3560 unsigned int lcorelist[RTE_MAX_LCORE];
3561 unsigned int portlist[RTE_MAX_ETHPORTS];
3563 unsigned int nb_item;
3565 if (test_done == 0) {
3566 printf("Please stop forwarding first\n");
3570 res = parsed_result;
3571 if (!strcmp(res->list_name, "corelist")) {
3572 nb_item = parse_item_list(res->list_of_items, "core",
3574 parsed_items.lcorelist, 1);
3576 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3581 if (!strcmp(res->list_name, "portlist")) {
3582 nb_item = parse_item_list(res->list_of_items, "port",
3584 parsed_items.portlist, 1);
3586 set_fwd_ports_list(parsed_items.portlist, nb_item);
3592 cmdline_parse_token_string_t cmd_set_list_keyword =
3593 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3595 cmdline_parse_token_string_t cmd_set_list_name =
3596 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3597 "corelist#portlist");
3598 cmdline_parse_token_string_t cmd_set_list_of_items =
3599 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3602 cmdline_parse_inst_t cmd_set_fwd_list = {
3603 .f = cmd_set_list_parsed,
3605 .help_str = "set corelist|portlist <list0[,list1]*>",
3607 (void *)&cmd_set_list_keyword,
3608 (void *)&cmd_set_list_name,
3609 (void *)&cmd_set_list_of_items,
3614 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3616 struct cmd_setmask_result {
3617 cmdline_fixed_string_t set;
3618 cmdline_fixed_string_t mask;
3622 static void cmd_set_mask_parsed(void *parsed_result,
3623 __rte_unused struct cmdline *cl,
3624 __rte_unused void *data)
3626 struct cmd_setmask_result *res = parsed_result;
3628 if (test_done == 0) {
3629 printf("Please stop forwarding first\n");
3632 if (!strcmp(res->mask, "coremask")) {
3633 set_fwd_lcores_mask(res->hexavalue);
3635 } else if (!strcmp(res->mask, "portmask")) {
3636 set_fwd_ports_mask(res->hexavalue);
3641 cmdline_parse_token_string_t cmd_setmask_set =
3642 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3643 cmdline_parse_token_string_t cmd_setmask_mask =
3644 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3645 "coremask#portmask");
3646 cmdline_parse_token_num_t cmd_setmask_value =
3647 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3649 cmdline_parse_inst_t cmd_set_fwd_mask = {
3650 .f = cmd_set_mask_parsed,
3652 .help_str = "set coremask|portmask <hexadecimal value>",
3654 (void *)&cmd_setmask_set,
3655 (void *)&cmd_setmask_mask,
3656 (void *)&cmd_setmask_value,
3662 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3664 struct cmd_set_result {
3665 cmdline_fixed_string_t set;
3666 cmdline_fixed_string_t what;
3670 static void cmd_set_parsed(void *parsed_result,
3671 __rte_unused struct cmdline *cl,
3672 __rte_unused void *data)
3674 struct cmd_set_result *res = parsed_result;
3675 if (!strcmp(res->what, "nbport")) {
3676 set_fwd_ports_number(res->value);
3678 } else if (!strcmp(res->what, "nbcore")) {
3679 set_fwd_lcores_number(res->value);
3681 } else if (!strcmp(res->what, "burst"))
3682 set_nb_pkt_per_burst(res->value);
3683 else if (!strcmp(res->what, "verbose"))
3684 set_verbose_level(res->value);
3687 cmdline_parse_token_string_t cmd_set_set =
3688 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3689 cmdline_parse_token_string_t cmd_set_what =
3690 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3691 "nbport#nbcore#burst#verbose");
3692 cmdline_parse_token_num_t cmd_set_value =
3693 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3695 cmdline_parse_inst_t cmd_set_numbers = {
3696 .f = cmd_set_parsed,
3698 .help_str = "set nbport|nbcore|burst|verbose <value>",
3700 (void *)&cmd_set_set,
3701 (void *)&cmd_set_what,
3702 (void *)&cmd_set_value,
3707 /* *** SET LOG LEVEL CONFIGURATION *** */
3709 struct cmd_set_log_result {
3710 cmdline_fixed_string_t set;
3711 cmdline_fixed_string_t log;
3712 cmdline_fixed_string_t type;
3717 cmd_set_log_parsed(void *parsed_result,
3718 __rte_unused struct cmdline *cl,
3719 __rte_unused void *data)
3721 struct cmd_set_log_result *res;
3724 res = parsed_result;
3725 if (!strcmp(res->type, "global"))
3726 rte_log_set_global_level(res->level);
3728 ret = rte_log_set_level_regexp(res->type, res->level);
3730 printf("Unable to set log level\n");
3734 cmdline_parse_token_string_t cmd_set_log_set =
3735 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3736 cmdline_parse_token_string_t cmd_set_log_log =
3737 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3738 cmdline_parse_token_string_t cmd_set_log_type =
3739 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3740 cmdline_parse_token_num_t cmd_set_log_level =
3741 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3743 cmdline_parse_inst_t cmd_set_log = {
3744 .f = cmd_set_log_parsed,
3746 .help_str = "set log global|<type> <level>",
3748 (void *)&cmd_set_log_set,
3749 (void *)&cmd_set_log_log,
3750 (void *)&cmd_set_log_type,
3751 (void *)&cmd_set_log_level,
3756 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3758 struct cmd_set_rxoffs_result {
3759 cmdline_fixed_string_t cmd_keyword;
3760 cmdline_fixed_string_t rxoffs;
3761 cmdline_fixed_string_t seg_offsets;
3765 cmd_set_rxoffs_parsed(void *parsed_result,
3766 __rte_unused struct cmdline *cl,
3767 __rte_unused void *data)
3769 struct cmd_set_rxoffs_result *res;
3770 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3771 unsigned int nb_segs;
3773 res = parsed_result;
3774 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3775 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3777 set_rx_pkt_offsets(seg_offsets, nb_segs);
3780 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3781 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3782 cmd_keyword, "set");
3783 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3784 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3786 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3787 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3790 cmdline_parse_inst_t cmd_set_rxoffs = {
3791 .f = cmd_set_rxoffs_parsed,
3793 .help_str = "set rxoffs <len0[,len1]*>",
3795 (void *)&cmd_set_rxoffs_keyword,
3796 (void *)&cmd_set_rxoffs_name,
3797 (void *)&cmd_set_rxoffs_offsets,
3802 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3804 struct cmd_set_rxpkts_result {
3805 cmdline_fixed_string_t cmd_keyword;
3806 cmdline_fixed_string_t rxpkts;
3807 cmdline_fixed_string_t seg_lengths;
3811 cmd_set_rxpkts_parsed(void *parsed_result,
3812 __rte_unused struct cmdline *cl,
3813 __rte_unused void *data)
3815 struct cmd_set_rxpkts_result *res;
3816 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3817 unsigned int nb_segs;
3819 res = parsed_result;
3820 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3821 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3823 set_rx_pkt_segments(seg_lengths, nb_segs);
3826 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3827 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3828 cmd_keyword, "set");
3829 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3830 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3832 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3833 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3836 cmdline_parse_inst_t cmd_set_rxpkts = {
3837 .f = cmd_set_rxpkts_parsed,
3839 .help_str = "set rxpkts <len0[,len1]*>",
3841 (void *)&cmd_set_rxpkts_keyword,
3842 (void *)&cmd_set_rxpkts_name,
3843 (void *)&cmd_set_rxpkts_lengths,
3848 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3850 struct cmd_set_txpkts_result {
3851 cmdline_fixed_string_t cmd_keyword;
3852 cmdline_fixed_string_t txpkts;
3853 cmdline_fixed_string_t seg_lengths;
3857 cmd_set_txpkts_parsed(void *parsed_result,
3858 __rte_unused struct cmdline *cl,
3859 __rte_unused void *data)
3861 struct cmd_set_txpkts_result *res;
3862 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3863 unsigned int nb_segs;
3865 res = parsed_result;
3866 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3867 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3869 set_tx_pkt_segments(seg_lengths, nb_segs);
3872 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3873 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3874 cmd_keyword, "set");
3875 cmdline_parse_token_string_t cmd_set_txpkts_name =
3876 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3878 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3879 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3882 cmdline_parse_inst_t cmd_set_txpkts = {
3883 .f = cmd_set_txpkts_parsed,
3885 .help_str = "set txpkts <len0[,len1]*>",
3887 (void *)&cmd_set_txpkts_keyword,
3888 (void *)&cmd_set_txpkts_name,
3889 (void *)&cmd_set_txpkts_lengths,
3894 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3896 struct cmd_set_txsplit_result {
3897 cmdline_fixed_string_t cmd_keyword;
3898 cmdline_fixed_string_t txsplit;
3899 cmdline_fixed_string_t mode;
3903 cmd_set_txsplit_parsed(void *parsed_result,
3904 __rte_unused struct cmdline *cl,
3905 __rte_unused void *data)
3907 struct cmd_set_txsplit_result *res;
3909 res = parsed_result;
3910 set_tx_pkt_split(res->mode);
3913 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3914 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3915 cmd_keyword, "set");
3916 cmdline_parse_token_string_t cmd_set_txsplit_name =
3917 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3918 txsplit, "txsplit");
3919 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3920 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3923 cmdline_parse_inst_t cmd_set_txsplit = {
3924 .f = cmd_set_txsplit_parsed,
3926 .help_str = "set txsplit on|off|rand",
3928 (void *)&cmd_set_txsplit_keyword,
3929 (void *)&cmd_set_txsplit_name,
3930 (void *)&cmd_set_txsplit_mode,
3935 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
3937 struct cmd_set_txtimes_result {
3938 cmdline_fixed_string_t cmd_keyword;
3939 cmdline_fixed_string_t txtimes;
3940 cmdline_fixed_string_t tx_times;
3944 cmd_set_txtimes_parsed(void *parsed_result,
3945 __rte_unused struct cmdline *cl,
3946 __rte_unused void *data)
3948 struct cmd_set_txtimes_result *res;
3949 unsigned int tx_times[2] = {0, 0};
3950 unsigned int n_times;
3952 res = parsed_result;
3953 n_times = parse_item_list(res->tx_times, "tx times",
3956 set_tx_pkt_times(tx_times);
3959 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
3960 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3961 cmd_keyword, "set");
3962 cmdline_parse_token_string_t cmd_set_txtimes_name =
3963 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3964 txtimes, "txtimes");
3965 cmdline_parse_token_string_t cmd_set_txtimes_value =
3966 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3969 cmdline_parse_inst_t cmd_set_txtimes = {
3970 .f = cmd_set_txtimes_parsed,
3972 .help_str = "set txtimes <inter_burst>,<intra_burst>",
3974 (void *)&cmd_set_txtimes_keyword,
3975 (void *)&cmd_set_txtimes_name,
3976 (void *)&cmd_set_txtimes_value,
3981 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3982 struct cmd_rx_vlan_filter_all_result {
3983 cmdline_fixed_string_t rx_vlan;
3984 cmdline_fixed_string_t what;
3985 cmdline_fixed_string_t all;
3990 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3991 __rte_unused struct cmdline *cl,
3992 __rte_unused void *data)
3994 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3996 if (!strcmp(res->what, "add"))
3997 rx_vlan_all_filter_set(res->port_id, 1);
3999 rx_vlan_all_filter_set(res->port_id, 0);
4002 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4003 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4004 rx_vlan, "rx_vlan");
4005 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4006 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4008 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4009 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4011 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4012 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4015 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4016 .f = cmd_rx_vlan_filter_all_parsed,
4018 .help_str = "rx_vlan add|rm all <port_id>: "
4019 "Add/Remove all identifiers to/from the set of VLAN "
4020 "identifiers filtered by a port",
4022 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4023 (void *)&cmd_rx_vlan_filter_all_what,
4024 (void *)&cmd_rx_vlan_filter_all_all,
4025 (void *)&cmd_rx_vlan_filter_all_portid,
4030 /* *** VLAN OFFLOAD SET ON A PORT *** */
4031 struct cmd_vlan_offload_result {
4032 cmdline_fixed_string_t vlan;
4033 cmdline_fixed_string_t set;
4034 cmdline_fixed_string_t vlan_type;
4035 cmdline_fixed_string_t what;
4036 cmdline_fixed_string_t on;
4037 cmdline_fixed_string_t port_id;
4041 cmd_vlan_offload_parsed(void *parsed_result,
4042 __rte_unused struct cmdline *cl,
4043 __rte_unused void *data)
4046 struct cmd_vlan_offload_result *res = parsed_result;
4049 portid_t port_id = 0;
4053 len = strnlen(str, STR_TOKEN_SIZE);
4055 /* Get port_id first */
4063 tmp = strtoul(str, NULL, 0);
4064 /* If port_id greater that what portid_t can represent, return */
4065 if(tmp >= RTE_MAX_ETHPORTS)
4067 port_id = (portid_t)tmp;
4069 if (!strcmp(res->on, "on"))
4074 if (!strcmp(res->what, "strip"))
4075 rx_vlan_strip_set(port_id, on);
4076 else if(!strcmp(res->what, "stripq")){
4077 uint16_t queue_id = 0;
4079 /* No queue_id, return */
4081 printf("must specify (port,queue_id)\n");
4084 tmp = strtoul(str + i + 1, NULL, 0);
4085 /* If queue_id greater that what 16-bits can represent, return */
4089 queue_id = (uint16_t)tmp;
4090 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4092 else if (!strcmp(res->what, "filter"))
4093 rx_vlan_filter_set(port_id, on);
4094 else if (!strcmp(res->what, "qinq_strip"))
4095 rx_vlan_qinq_strip_set(port_id, on);
4097 vlan_extend_set(port_id, on);
4102 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4103 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4105 cmdline_parse_token_string_t cmd_vlan_offload_set =
4106 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4108 cmdline_parse_token_string_t cmd_vlan_offload_what =
4109 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4110 what, "strip#filter#qinq_strip#extend#stripq");
4111 cmdline_parse_token_string_t cmd_vlan_offload_on =
4112 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4114 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4115 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4118 cmdline_parse_inst_t cmd_vlan_offload = {
4119 .f = cmd_vlan_offload_parsed,
4121 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4122 "<port_id[,queue_id]>: "
4123 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4125 (void *)&cmd_vlan_offload_vlan,
4126 (void *)&cmd_vlan_offload_set,
4127 (void *)&cmd_vlan_offload_what,
4128 (void *)&cmd_vlan_offload_on,
4129 (void *)&cmd_vlan_offload_portid,
4134 /* *** VLAN TPID SET ON A PORT *** */
4135 struct cmd_vlan_tpid_result {
4136 cmdline_fixed_string_t vlan;
4137 cmdline_fixed_string_t set;
4138 cmdline_fixed_string_t vlan_type;
4139 cmdline_fixed_string_t what;
4145 cmd_vlan_tpid_parsed(void *parsed_result,
4146 __rte_unused struct cmdline *cl,
4147 __rte_unused void *data)
4149 struct cmd_vlan_tpid_result *res = parsed_result;
4150 enum rte_vlan_type vlan_type;
4152 if (!strcmp(res->vlan_type, "inner"))
4153 vlan_type = ETH_VLAN_TYPE_INNER;
4154 else if (!strcmp(res->vlan_type, "outer"))
4155 vlan_type = ETH_VLAN_TYPE_OUTER;
4157 printf("Unknown vlan type\n");
4160 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4163 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4164 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4166 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4167 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4169 cmdline_parse_token_string_t cmd_vlan_type =
4170 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4171 vlan_type, "inner#outer");
4172 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4173 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4175 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4176 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4178 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4179 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4182 cmdline_parse_inst_t cmd_vlan_tpid = {
4183 .f = cmd_vlan_tpid_parsed,
4185 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4186 "Set the VLAN Ether type",
4188 (void *)&cmd_vlan_tpid_vlan,
4189 (void *)&cmd_vlan_tpid_set,
4190 (void *)&cmd_vlan_type,
4191 (void *)&cmd_vlan_tpid_what,
4192 (void *)&cmd_vlan_tpid_tpid,
4193 (void *)&cmd_vlan_tpid_portid,
4198 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4199 struct cmd_rx_vlan_filter_result {
4200 cmdline_fixed_string_t rx_vlan;
4201 cmdline_fixed_string_t what;
4207 cmd_rx_vlan_filter_parsed(void *parsed_result,
4208 __rte_unused struct cmdline *cl,
4209 __rte_unused void *data)
4211 struct cmd_rx_vlan_filter_result *res = parsed_result;
4213 if (!strcmp(res->what, "add"))
4214 rx_vft_set(res->port_id, res->vlan_id, 1);
4216 rx_vft_set(res->port_id, res->vlan_id, 0);
4219 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4220 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4221 rx_vlan, "rx_vlan");
4222 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4223 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4225 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4226 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4228 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4229 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4232 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4233 .f = cmd_rx_vlan_filter_parsed,
4235 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4236 "Add/Remove a VLAN identifier to/from the set of VLAN "
4237 "identifiers filtered by a port",
4239 (void *)&cmd_rx_vlan_filter_rx_vlan,
4240 (void *)&cmd_rx_vlan_filter_what,
4241 (void *)&cmd_rx_vlan_filter_vlanid,
4242 (void *)&cmd_rx_vlan_filter_portid,
4247 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4248 struct cmd_tx_vlan_set_result {
4249 cmdline_fixed_string_t tx_vlan;
4250 cmdline_fixed_string_t set;
4256 cmd_tx_vlan_set_parsed(void *parsed_result,
4257 __rte_unused struct cmdline *cl,
4258 __rte_unused void *data)
4260 struct cmd_tx_vlan_set_result *res = parsed_result;
4262 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4265 if (!port_is_stopped(res->port_id)) {
4266 printf("Please stop port %d first\n", res->port_id);
4270 tx_vlan_set(res->port_id, res->vlan_id);
4272 cmd_reconfig_device_queue(res->port_id, 1, 1);
4275 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4276 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4277 tx_vlan, "tx_vlan");
4278 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4279 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4281 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4282 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4284 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4285 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4288 cmdline_parse_inst_t cmd_tx_vlan_set = {
4289 .f = cmd_tx_vlan_set_parsed,
4291 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4292 "Enable hardware insertion of a single VLAN header "
4293 "with a given TAG Identifier in packets sent on a port",
4295 (void *)&cmd_tx_vlan_set_tx_vlan,
4296 (void *)&cmd_tx_vlan_set_set,
4297 (void *)&cmd_tx_vlan_set_portid,
4298 (void *)&cmd_tx_vlan_set_vlanid,
4303 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4304 struct cmd_tx_vlan_set_qinq_result {
4305 cmdline_fixed_string_t tx_vlan;
4306 cmdline_fixed_string_t set;
4309 uint16_t vlan_id_outer;
4313 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4314 __rte_unused struct cmdline *cl,
4315 __rte_unused void *data)
4317 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4319 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4322 if (!port_is_stopped(res->port_id)) {
4323 printf("Please stop port %d first\n", res->port_id);
4327 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4329 cmd_reconfig_device_queue(res->port_id, 1, 1);
4332 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4333 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4334 tx_vlan, "tx_vlan");
4335 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4336 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4338 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4339 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4341 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4342 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4344 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4345 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4346 vlan_id_outer, UINT16);
4348 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4349 .f = cmd_tx_vlan_set_qinq_parsed,
4351 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4352 "Enable hardware insertion of double VLAN header "
4353 "with given TAG Identifiers in packets sent on a port",
4355 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4356 (void *)&cmd_tx_vlan_set_qinq_set,
4357 (void *)&cmd_tx_vlan_set_qinq_portid,
4358 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4359 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4364 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4365 struct cmd_tx_vlan_set_pvid_result {
4366 cmdline_fixed_string_t tx_vlan;
4367 cmdline_fixed_string_t set;
4368 cmdline_fixed_string_t pvid;
4371 cmdline_fixed_string_t mode;
4375 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4376 __rte_unused struct cmdline *cl,
4377 __rte_unused void *data)
4379 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4381 if (strcmp(res->mode, "on") == 0)
4382 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4384 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4387 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4388 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4389 tx_vlan, "tx_vlan");
4390 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4391 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4393 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4394 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4396 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4397 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4399 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4400 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4402 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4403 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4406 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4407 .f = cmd_tx_vlan_set_pvid_parsed,
4409 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4411 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4412 (void *)&cmd_tx_vlan_set_pvid_set,
4413 (void *)&cmd_tx_vlan_set_pvid_pvid,
4414 (void *)&cmd_tx_vlan_set_pvid_port_id,
4415 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4416 (void *)&cmd_tx_vlan_set_pvid_mode,
4421 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4422 struct cmd_tx_vlan_reset_result {
4423 cmdline_fixed_string_t tx_vlan;
4424 cmdline_fixed_string_t reset;
4429 cmd_tx_vlan_reset_parsed(void *parsed_result,
4430 __rte_unused struct cmdline *cl,
4431 __rte_unused void *data)
4433 struct cmd_tx_vlan_reset_result *res = parsed_result;
4435 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4438 if (!port_is_stopped(res->port_id)) {
4439 printf("Please stop port %d first\n", res->port_id);
4443 tx_vlan_reset(res->port_id);
4445 cmd_reconfig_device_queue(res->port_id, 1, 1);
4448 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4449 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4450 tx_vlan, "tx_vlan");
4451 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4452 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4454 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4455 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4458 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4459 .f = cmd_tx_vlan_reset_parsed,
4461 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4462 "VLAN header in packets sent on a port",
4464 (void *)&cmd_tx_vlan_reset_tx_vlan,
4465 (void *)&cmd_tx_vlan_reset_reset,
4466 (void *)&cmd_tx_vlan_reset_portid,
4472 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4473 struct cmd_csum_result {
4474 cmdline_fixed_string_t csum;
4475 cmdline_fixed_string_t mode;
4476 cmdline_fixed_string_t proto;
4477 cmdline_fixed_string_t hwsw;
4482 csum_show(int port_id)
4484 struct rte_eth_dev_info dev_info;
4485 uint64_t tx_offloads;
4488 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4489 printf("Parse tunnel is %s\n",
4490 (ports[port_id].parse_tunnel) ? "on" : "off");
4491 printf("IP checksum offload is %s\n",
4492 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4493 printf("UDP checksum offload is %s\n",
4494 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4495 printf("TCP checksum offload is %s\n",
4496 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4497 printf("SCTP checksum offload is %s\n",
4498 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4499 printf("Outer-Ip checksum offload is %s\n",
4500 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4501 printf("Outer-Udp checksum offload is %s\n",
4502 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4504 /* display warnings if configuration is not supported by the NIC */
4505 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4509 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4510 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4511 printf("Warning: hardware IP checksum enabled but not "
4512 "supported by port %d\n", port_id);
4514 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4515 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4516 printf("Warning: hardware UDP checksum enabled but not "
4517 "supported by port %d\n", port_id);
4519 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4520 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4521 printf("Warning: hardware TCP checksum enabled but not "
4522 "supported by port %d\n", port_id);
4524 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4525 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4526 printf("Warning: hardware SCTP checksum enabled but not "
4527 "supported by port %d\n", port_id);
4529 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4530 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4531 printf("Warning: hardware outer IP checksum enabled but not "
4532 "supported by port %d\n", port_id);
4534 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4535 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4537 printf("Warning: hardware outer UDP checksum enabled but not "
4538 "supported by port %d\n", port_id);
4543 cmd_config_queue_tx_offloads(struct rte_port *port)
4547 /* Apply queue tx offloads configuration */
4548 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4549 port->tx_conf[k].offloads =
4550 port->dev_conf.txmode.offloads;
4554 cmd_csum_parsed(void *parsed_result,
4555 __rte_unused struct cmdline *cl,
4556 __rte_unused void *data)
4558 struct cmd_csum_result *res = parsed_result;
4560 uint64_t csum_offloads = 0;
4561 struct rte_eth_dev_info dev_info;
4564 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4565 printf("invalid port %d\n", res->port_id);
4568 if (!port_is_stopped(res->port_id)) {
4569 printf("Please stop port %d first\n", res->port_id);
4573 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4577 if (!strcmp(res->mode, "set")) {
4579 if (!strcmp(res->hwsw, "hw"))
4582 if (!strcmp(res->proto, "ip")) {
4583 if (hw == 0 || (dev_info.tx_offload_capa &
4584 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4585 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4587 printf("IP checksum offload is not supported "
4588 "by port %u\n", res->port_id);
4590 } else if (!strcmp(res->proto, "udp")) {
4591 if (hw == 0 || (dev_info.tx_offload_capa &
4592 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4593 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4595 printf("UDP checksum offload is not supported "
4596 "by port %u\n", res->port_id);
4598 } else if (!strcmp(res->proto, "tcp")) {
4599 if (hw == 0 || (dev_info.tx_offload_capa &
4600 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4601 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4603 printf("TCP checksum offload is not supported "
4604 "by port %u\n", res->port_id);
4606 } else if (!strcmp(res->proto, "sctp")) {
4607 if (hw == 0 || (dev_info.tx_offload_capa &
4608 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4609 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4611 printf("SCTP checksum offload is not supported "
4612 "by port %u\n", res->port_id);
4614 } else if (!strcmp(res->proto, "outer-ip")) {
4615 if (hw == 0 || (dev_info.tx_offload_capa &
4616 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4618 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4620 printf("Outer IP checksum offload is not "
4621 "supported by port %u\n", res->port_id);
4623 } else if (!strcmp(res->proto, "outer-udp")) {
4624 if (hw == 0 || (dev_info.tx_offload_capa &
4625 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4627 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4629 printf("Outer UDP checksum offload is not "
4630 "supported by port %u\n", res->port_id);
4635 ports[res->port_id].dev_conf.txmode.offloads |=
4638 ports[res->port_id].dev_conf.txmode.offloads &=
4641 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4643 csum_show(res->port_id);
4645 cmd_reconfig_device_queue(res->port_id, 1, 1);
4648 cmdline_parse_token_string_t cmd_csum_csum =
4649 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4651 cmdline_parse_token_string_t cmd_csum_mode =
4652 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4654 cmdline_parse_token_string_t cmd_csum_proto =
4655 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4656 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4657 cmdline_parse_token_string_t cmd_csum_hwsw =
4658 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4660 cmdline_parse_token_num_t cmd_csum_portid =
4661 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4664 cmdline_parse_inst_t cmd_csum_set = {
4665 .f = cmd_csum_parsed,
4667 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4668 "Enable/Disable hardware calculation of L3/L4 checksum when "
4669 "using csum forward engine",
4671 (void *)&cmd_csum_csum,
4672 (void *)&cmd_csum_mode,
4673 (void *)&cmd_csum_proto,
4674 (void *)&cmd_csum_hwsw,
4675 (void *)&cmd_csum_portid,
4680 cmdline_parse_token_string_t cmd_csum_mode_show =
4681 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4684 cmdline_parse_inst_t cmd_csum_show = {
4685 .f = cmd_csum_parsed,
4687 .help_str = "csum show <port_id>: Show checksum offload configuration",
4689 (void *)&cmd_csum_csum,
4690 (void *)&cmd_csum_mode_show,
4691 (void *)&cmd_csum_portid,
4696 /* Enable/disable tunnel parsing */
4697 struct cmd_csum_tunnel_result {
4698 cmdline_fixed_string_t csum;
4699 cmdline_fixed_string_t parse;
4700 cmdline_fixed_string_t onoff;
4705 cmd_csum_tunnel_parsed(void *parsed_result,
4706 __rte_unused struct cmdline *cl,
4707 __rte_unused void *data)
4709 struct cmd_csum_tunnel_result *res = parsed_result;
4711 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4714 if (!strcmp(res->onoff, "on"))
4715 ports[res->port_id].parse_tunnel = 1;
4717 ports[res->port_id].parse_tunnel = 0;
4719 csum_show(res->port_id);
4722 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4723 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4725 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4726 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4727 parse, "parse-tunnel");
4728 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4729 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4731 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4732 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4735 cmdline_parse_inst_t cmd_csum_tunnel = {
4736 .f = cmd_csum_tunnel_parsed,
4738 .help_str = "csum parse-tunnel on|off <port_id>: "
4739 "Enable/Disable parsing of tunnels for csum engine",
4741 (void *)&cmd_csum_tunnel_csum,
4742 (void *)&cmd_csum_tunnel_parse,
4743 (void *)&cmd_csum_tunnel_onoff,
4744 (void *)&cmd_csum_tunnel_portid,
4749 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4750 struct cmd_tso_set_result {
4751 cmdline_fixed_string_t tso;
4752 cmdline_fixed_string_t mode;
4758 cmd_tso_set_parsed(void *parsed_result,
4759 __rte_unused struct cmdline *cl,
4760 __rte_unused void *data)
4762 struct cmd_tso_set_result *res = parsed_result;
4763 struct rte_eth_dev_info dev_info;
4766 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4768 if (!port_is_stopped(res->port_id)) {
4769 printf("Please stop port %d first\n", res->port_id);
4773 if (!strcmp(res->mode, "set"))
4774 ports[res->port_id].tso_segsz = res->tso_segsz;
4776 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4780 if ((ports[res->port_id].tso_segsz != 0) &&
4781 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4782 printf("Error: TSO is not supported by port %d\n",
4787 if (ports[res->port_id].tso_segsz == 0) {
4788 ports[res->port_id].dev_conf.txmode.offloads &=
4789 ~DEV_TX_OFFLOAD_TCP_TSO;
4790 printf("TSO for non-tunneled packets is disabled\n");
4792 ports[res->port_id].dev_conf.txmode.offloads |=
4793 DEV_TX_OFFLOAD_TCP_TSO;
4794 printf("TSO segment size for non-tunneled packets is %d\n",
4795 ports[res->port_id].tso_segsz);
4797 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4799 /* display warnings if configuration is not supported by the NIC */
4800 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4804 if ((ports[res->port_id].tso_segsz != 0) &&
4805 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4806 printf("Warning: TSO enabled but not "
4807 "supported by port %d\n", res->port_id);
4810 cmd_reconfig_device_queue(res->port_id, 1, 1);
4813 cmdline_parse_token_string_t cmd_tso_set_tso =
4814 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4816 cmdline_parse_token_string_t cmd_tso_set_mode =
4817 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4819 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4820 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4822 cmdline_parse_token_num_t cmd_tso_set_portid =
4823 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4826 cmdline_parse_inst_t cmd_tso_set = {
4827 .f = cmd_tso_set_parsed,
4829 .help_str = "tso set <tso_segsz> <port_id>: "
4830 "Set TSO segment size of non-tunneled packets for csum engine "
4833 (void *)&cmd_tso_set_tso,
4834 (void *)&cmd_tso_set_mode,
4835 (void *)&cmd_tso_set_tso_segsz,
4836 (void *)&cmd_tso_set_portid,
4841 cmdline_parse_token_string_t cmd_tso_show_mode =
4842 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4846 cmdline_parse_inst_t cmd_tso_show = {
4847 .f = cmd_tso_set_parsed,
4849 .help_str = "tso show <port_id>: "
4850 "Show TSO segment size of non-tunneled packets for csum engine",
4852 (void *)&cmd_tso_set_tso,
4853 (void *)&cmd_tso_show_mode,
4854 (void *)&cmd_tso_set_portid,
4859 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4860 struct cmd_tunnel_tso_set_result {
4861 cmdline_fixed_string_t tso;
4862 cmdline_fixed_string_t mode;
4867 static struct rte_eth_dev_info
4868 check_tunnel_tso_nic_support(portid_t port_id)
4870 struct rte_eth_dev_info dev_info;
4872 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4875 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4876 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4877 "not enabled for port %d\n", port_id);
4878 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4879 printf("Warning: GRE TUNNEL TSO not supported therefore "
4880 "not enabled for port %d\n", port_id);
4881 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4882 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4883 "not enabled for port %d\n", port_id);
4884 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4885 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4886 "not enabled for port %d\n", port_id);
4887 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4888 printf("Warning: IP TUNNEL TSO not supported therefore "
4889 "not enabled for port %d\n", port_id);
4890 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4891 printf("Warning: UDP TUNNEL TSO not supported therefore "
4892 "not enabled for port %d\n", port_id);
4897 cmd_tunnel_tso_set_parsed(void *parsed_result,
4898 __rte_unused struct cmdline *cl,
4899 __rte_unused void *data)
4901 struct cmd_tunnel_tso_set_result *res = parsed_result;
4902 struct rte_eth_dev_info dev_info;
4904 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4906 if (!port_is_stopped(res->port_id)) {
4907 printf("Please stop port %d first\n", res->port_id);
4911 if (!strcmp(res->mode, "set"))
4912 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4914 dev_info = check_tunnel_tso_nic_support(res->port_id);
4915 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4916 ports[res->port_id].dev_conf.txmode.offloads &=
4917 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4918 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4919 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4920 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4921 DEV_TX_OFFLOAD_IP_TNL_TSO |
4922 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4923 printf("TSO for tunneled packets is disabled\n");
4925 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4926 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4927 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4928 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4929 DEV_TX_OFFLOAD_IP_TNL_TSO |
4930 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4932 ports[res->port_id].dev_conf.txmode.offloads |=
4933 (tso_offloads & dev_info.tx_offload_capa);
4934 printf("TSO segment size for tunneled packets is %d\n",
4935 ports[res->port_id].tunnel_tso_segsz);
4937 /* Below conditions are needed to make it work:
4938 * (1) tunnel TSO is supported by the NIC;
4939 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4941 * (3) for tunneled pkts with outer L3 of IPv4,
4942 * "csum set outer-ip" must be set to hw, because after tso,
4943 * total_len of outer IP header is changed, and the checksum
4944 * of outer IP header calculated by sw should be wrong; that
4945 * is not necessary for IPv6 tunneled pkts because there's no
4946 * checksum in IP header anymore.
4949 if (!ports[res->port_id].parse_tunnel)
4950 printf("Warning: csum parse_tunnel must be set "
4951 "so that tunneled packets are recognized\n");
4952 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4953 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4954 printf("Warning: csum set outer-ip must be set to hw "
4955 "if outer L3 is IPv4; not necessary for IPv6\n");
4958 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4959 cmd_reconfig_device_queue(res->port_id, 1, 1);
4962 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4963 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4965 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4966 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4968 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4969 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4971 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4972 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4975 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4976 .f = cmd_tunnel_tso_set_parsed,
4978 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4979 "Set TSO segment size of tunneled packets for csum engine "
4982 (void *)&cmd_tunnel_tso_set_tso,
4983 (void *)&cmd_tunnel_tso_set_mode,
4984 (void *)&cmd_tunnel_tso_set_tso_segsz,
4985 (void *)&cmd_tunnel_tso_set_portid,
4990 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4991 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4995 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4996 .f = cmd_tunnel_tso_set_parsed,
4998 .help_str = "tunnel_tso show <port_id> "
4999 "Show TSO segment size of tunneled packets for csum engine",
5001 (void *)&cmd_tunnel_tso_set_tso,
5002 (void *)&cmd_tunnel_tso_show_mode,
5003 (void *)&cmd_tunnel_tso_set_portid,
5008 /* *** SET GRO FOR A PORT *** */
5009 struct cmd_gro_enable_result {
5010 cmdline_fixed_string_t cmd_set;
5011 cmdline_fixed_string_t cmd_port;
5012 cmdline_fixed_string_t cmd_keyword;
5013 cmdline_fixed_string_t cmd_onoff;
5018 cmd_gro_enable_parsed(void *parsed_result,
5019 __rte_unused struct cmdline *cl,
5020 __rte_unused void *data)
5022 struct cmd_gro_enable_result *res;
5024 res = parsed_result;
5025 if (!strcmp(res->cmd_keyword, "gro"))
5026 setup_gro(res->cmd_onoff, res->cmd_pid);
5029 cmdline_parse_token_string_t cmd_gro_enable_set =
5030 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5032 cmdline_parse_token_string_t cmd_gro_enable_port =
5033 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5034 cmd_keyword, "port");
5035 cmdline_parse_token_num_t cmd_gro_enable_pid =
5036 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5038 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5039 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5040 cmd_keyword, "gro");
5041 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5042 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5043 cmd_onoff, "on#off");
5045 cmdline_parse_inst_t cmd_gro_enable = {
5046 .f = cmd_gro_enable_parsed,
5048 .help_str = "set port <port_id> gro on|off",
5050 (void *)&cmd_gro_enable_set,
5051 (void *)&cmd_gro_enable_port,
5052 (void *)&cmd_gro_enable_pid,
5053 (void *)&cmd_gro_enable_keyword,
5054 (void *)&cmd_gro_enable_onoff,
5059 /* *** DISPLAY GRO CONFIGURATION *** */
5060 struct cmd_gro_show_result {
5061 cmdline_fixed_string_t cmd_show;
5062 cmdline_fixed_string_t cmd_port;
5063 cmdline_fixed_string_t cmd_keyword;
5068 cmd_gro_show_parsed(void *parsed_result,
5069 __rte_unused struct cmdline *cl,
5070 __rte_unused void *data)
5072 struct cmd_gro_show_result *res;
5074 res = parsed_result;
5075 if (!strcmp(res->cmd_keyword, "gro"))
5076 show_gro(res->cmd_pid);
5079 cmdline_parse_token_string_t cmd_gro_show_show =
5080 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5082 cmdline_parse_token_string_t cmd_gro_show_port =
5083 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5085 cmdline_parse_token_num_t cmd_gro_show_pid =
5086 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5088 cmdline_parse_token_string_t cmd_gro_show_keyword =
5089 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5090 cmd_keyword, "gro");
5092 cmdline_parse_inst_t cmd_gro_show = {
5093 .f = cmd_gro_show_parsed,
5095 .help_str = "show port <port_id> gro",
5097 (void *)&cmd_gro_show_show,
5098 (void *)&cmd_gro_show_port,
5099 (void *)&cmd_gro_show_pid,
5100 (void *)&cmd_gro_show_keyword,
5105 /* *** SET FLUSH CYCLES FOR GRO *** */
5106 struct cmd_gro_flush_result {
5107 cmdline_fixed_string_t cmd_set;
5108 cmdline_fixed_string_t cmd_keyword;
5109 cmdline_fixed_string_t cmd_flush;
5114 cmd_gro_flush_parsed(void *parsed_result,
5115 __rte_unused struct cmdline *cl,
5116 __rte_unused void *data)
5118 struct cmd_gro_flush_result *res;
5120 res = parsed_result;
5121 if ((!strcmp(res->cmd_keyword, "gro")) &&
5122 (!strcmp(res->cmd_flush, "flush")))
5123 setup_gro_flush_cycles(res->cmd_cycles);
5126 cmdline_parse_token_string_t cmd_gro_flush_set =
5127 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5129 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5130 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5131 cmd_keyword, "gro");
5132 cmdline_parse_token_string_t cmd_gro_flush_flush =
5133 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5134 cmd_flush, "flush");
5135 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5136 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5139 cmdline_parse_inst_t cmd_gro_flush = {
5140 .f = cmd_gro_flush_parsed,
5142 .help_str = "set gro flush <cycles>",
5144 (void *)&cmd_gro_flush_set,
5145 (void *)&cmd_gro_flush_keyword,
5146 (void *)&cmd_gro_flush_flush,
5147 (void *)&cmd_gro_flush_cycles,
5152 /* *** ENABLE/DISABLE GSO *** */
5153 struct cmd_gso_enable_result {
5154 cmdline_fixed_string_t cmd_set;
5155 cmdline_fixed_string_t cmd_port;
5156 cmdline_fixed_string_t cmd_keyword;
5157 cmdline_fixed_string_t cmd_mode;
5162 cmd_gso_enable_parsed(void *parsed_result,
5163 __rte_unused struct cmdline *cl,
5164 __rte_unused void *data)
5166 struct cmd_gso_enable_result *res;
5168 res = parsed_result;
5169 if (!strcmp(res->cmd_keyword, "gso"))
5170 setup_gso(res->cmd_mode, res->cmd_pid);
5173 cmdline_parse_token_string_t cmd_gso_enable_set =
5174 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5176 cmdline_parse_token_string_t cmd_gso_enable_port =
5177 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5179 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5180 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5181 cmd_keyword, "gso");
5182 cmdline_parse_token_string_t cmd_gso_enable_mode =
5183 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5184 cmd_mode, "on#off");
5185 cmdline_parse_token_num_t cmd_gso_enable_pid =
5186 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5189 cmdline_parse_inst_t cmd_gso_enable = {
5190 .f = cmd_gso_enable_parsed,
5192 .help_str = "set port <port_id> gso on|off",
5194 (void *)&cmd_gso_enable_set,
5195 (void *)&cmd_gso_enable_port,
5196 (void *)&cmd_gso_enable_pid,
5197 (void *)&cmd_gso_enable_keyword,
5198 (void *)&cmd_gso_enable_mode,
5203 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5204 struct cmd_gso_size_result {
5205 cmdline_fixed_string_t cmd_set;
5206 cmdline_fixed_string_t cmd_keyword;
5207 cmdline_fixed_string_t cmd_segsz;
5212 cmd_gso_size_parsed(void *parsed_result,
5213 __rte_unused struct cmdline *cl,
5214 __rte_unused void *data)
5216 struct cmd_gso_size_result *res = parsed_result;
5218 if (test_done == 0) {
5219 printf("Before setting GSO segsz, please first"
5220 " stop forwarding\n");
5224 if (!strcmp(res->cmd_keyword, "gso") &&
5225 !strcmp(res->cmd_segsz, "segsz")) {
5226 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5227 printf("gso_size should be larger than %zu."
5228 " Please input a legal value\n",
5229 RTE_GSO_SEG_SIZE_MIN);
5231 gso_max_segment_size = res->cmd_size;
5235 cmdline_parse_token_string_t cmd_gso_size_set =
5236 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5238 cmdline_parse_token_string_t cmd_gso_size_keyword =
5239 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5240 cmd_keyword, "gso");
5241 cmdline_parse_token_string_t cmd_gso_size_segsz =
5242 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5243 cmd_segsz, "segsz");
5244 cmdline_parse_token_num_t cmd_gso_size_size =
5245 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5248 cmdline_parse_inst_t cmd_gso_size = {
5249 .f = cmd_gso_size_parsed,
5251 .help_str = "set gso segsz <length>",
5253 (void *)&cmd_gso_size_set,
5254 (void *)&cmd_gso_size_keyword,
5255 (void *)&cmd_gso_size_segsz,
5256 (void *)&cmd_gso_size_size,
5261 /* *** SHOW GSO CONFIGURATION *** */
5262 struct cmd_gso_show_result {
5263 cmdline_fixed_string_t cmd_show;
5264 cmdline_fixed_string_t cmd_port;
5265 cmdline_fixed_string_t cmd_keyword;
5270 cmd_gso_show_parsed(void *parsed_result,
5271 __rte_unused struct cmdline *cl,
5272 __rte_unused void *data)
5274 struct cmd_gso_show_result *res = parsed_result;
5276 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5277 printf("invalid port id %u\n", res->cmd_pid);
5280 if (!strcmp(res->cmd_keyword, "gso")) {
5281 if (gso_ports[res->cmd_pid].enable) {
5282 printf("Max GSO'd packet size: %uB\n"
5283 "Supported GSO types: TCP/IPv4, "
5284 "UDP/IPv4, VxLAN with inner "
5285 "TCP/IPv4 packet, GRE with inner "
5286 "TCP/IPv4 packet\n",
5287 gso_max_segment_size);
5289 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5293 cmdline_parse_token_string_t cmd_gso_show_show =
5294 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5296 cmdline_parse_token_string_t cmd_gso_show_port =
5297 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5299 cmdline_parse_token_string_t cmd_gso_show_keyword =
5300 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5301 cmd_keyword, "gso");
5302 cmdline_parse_token_num_t cmd_gso_show_pid =
5303 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5306 cmdline_parse_inst_t cmd_gso_show = {
5307 .f = cmd_gso_show_parsed,
5309 .help_str = "show port <port_id> gso",
5311 (void *)&cmd_gso_show_show,
5312 (void *)&cmd_gso_show_port,
5313 (void *)&cmd_gso_show_pid,
5314 (void *)&cmd_gso_show_keyword,
5319 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5320 struct cmd_set_flush_rx {
5321 cmdline_fixed_string_t set;
5322 cmdline_fixed_string_t flush_rx;
5323 cmdline_fixed_string_t mode;
5327 cmd_set_flush_rx_parsed(void *parsed_result,
5328 __rte_unused struct cmdline *cl,
5329 __rte_unused void *data)
5331 struct cmd_set_flush_rx *res = parsed_result;
5332 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5335 cmdline_parse_token_string_t cmd_setflushrx_set =
5336 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5338 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5339 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5340 flush_rx, "flush_rx");
5341 cmdline_parse_token_string_t cmd_setflushrx_mode =
5342 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5346 cmdline_parse_inst_t cmd_set_flush_rx = {
5347 .f = cmd_set_flush_rx_parsed,
5348 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5351 (void *)&cmd_setflushrx_set,
5352 (void *)&cmd_setflushrx_flush_rx,
5353 (void *)&cmd_setflushrx_mode,
5358 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5359 struct cmd_set_link_check {
5360 cmdline_fixed_string_t set;
5361 cmdline_fixed_string_t link_check;
5362 cmdline_fixed_string_t mode;
5366 cmd_set_link_check_parsed(void *parsed_result,
5367 __rte_unused struct cmdline *cl,
5368 __rte_unused void *data)
5370 struct cmd_set_link_check *res = parsed_result;
5371 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5374 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5375 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5377 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5378 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5379 link_check, "link_check");
5380 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5381 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5385 cmdline_parse_inst_t cmd_set_link_check = {
5386 .f = cmd_set_link_check_parsed,
5387 .help_str = "set link_check on|off: Enable/Disable link status check "
5388 "when starting/stopping a port",
5391 (void *)&cmd_setlinkcheck_set,
5392 (void *)&cmd_setlinkcheck_link_check,
5393 (void *)&cmd_setlinkcheck_mode,
5398 /* *** SET NIC BYPASS MODE *** */
5399 struct cmd_set_bypass_mode_result {
5400 cmdline_fixed_string_t set;
5401 cmdline_fixed_string_t bypass;
5402 cmdline_fixed_string_t mode;
5403 cmdline_fixed_string_t value;
5408 cmd_set_bypass_mode_parsed(void *parsed_result,
5409 __rte_unused struct cmdline *cl,
5410 __rte_unused void *data)
5412 struct cmd_set_bypass_mode_result *res = parsed_result;
5413 portid_t port_id = res->port_id;
5414 int32_t rc = -EINVAL;
5416 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5417 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5419 if (!strcmp(res->value, "bypass"))
5420 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5421 else if (!strcmp(res->value, "isolate"))
5422 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5424 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5426 /* Set the bypass mode for the relevant port. */
5427 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5430 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5433 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5434 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5436 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5437 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5439 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5440 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5442 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5443 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5444 value, "normal#bypass#isolate");
5445 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5446 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5449 cmdline_parse_inst_t cmd_set_bypass_mode = {
5450 .f = cmd_set_bypass_mode_parsed,
5451 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5452 "Set the NIC bypass mode for port_id",
5455 (void *)&cmd_setbypass_mode_set,
5456 (void *)&cmd_setbypass_mode_bypass,
5457 (void *)&cmd_setbypass_mode_mode,
5458 (void *)&cmd_setbypass_mode_value,
5459 (void *)&cmd_setbypass_mode_port,
5464 /* *** SET NIC BYPASS EVENT *** */
5465 struct cmd_set_bypass_event_result {
5466 cmdline_fixed_string_t set;
5467 cmdline_fixed_string_t bypass;
5468 cmdline_fixed_string_t event;
5469 cmdline_fixed_string_t event_value;
5470 cmdline_fixed_string_t mode;
5471 cmdline_fixed_string_t mode_value;
5476 cmd_set_bypass_event_parsed(void *parsed_result,
5477 __rte_unused struct cmdline *cl,
5478 __rte_unused void *data)
5480 int32_t rc = -EINVAL;
5481 struct cmd_set_bypass_event_result *res = parsed_result;
5482 portid_t port_id = res->port_id;
5484 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5485 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5486 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5488 if (!strcmp(res->event_value, "timeout"))
5489 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5490 else if (!strcmp(res->event_value, "os_on"))
5491 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5492 else if (!strcmp(res->event_value, "os_off"))
5493 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5494 else if (!strcmp(res->event_value, "power_on"))
5495 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5496 else if (!strcmp(res->event_value, "power_off"))
5497 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5499 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5501 if (!strcmp(res->mode_value, "bypass"))
5502 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5503 else if (!strcmp(res->mode_value, "isolate"))
5504 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5506 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5508 /* Set the watchdog timeout. */
5509 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5512 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5513 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5517 printf("Failed to set timeout value %u "
5518 "for port %d, errto code: %d.\n",
5519 bypass_timeout, port_id, rc);
5523 /* Set the bypass event to transition to bypass mode. */
5524 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5529 printf("\t Failed to set bypass event for port = %d.\n",
5533 cmdline_parse_token_string_t cmd_setbypass_event_set =
5534 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5536 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5537 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5539 cmdline_parse_token_string_t cmd_setbypass_event_event =
5540 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5542 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5543 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5544 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5545 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5546 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5548 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5549 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5550 mode_value, "normal#bypass#isolate");
5551 cmdline_parse_token_num_t cmd_setbypass_event_port =
5552 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5555 cmdline_parse_inst_t cmd_set_bypass_event = {
5556 .f = cmd_set_bypass_event_parsed,
5557 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5558 "power_off mode normal|bypass|isolate <port_id>: "
5559 "Set the NIC bypass event mode for port_id",
5562 (void *)&cmd_setbypass_event_set,
5563 (void *)&cmd_setbypass_event_bypass,
5564 (void *)&cmd_setbypass_event_event,
5565 (void *)&cmd_setbypass_event_event_value,
5566 (void *)&cmd_setbypass_event_mode,
5567 (void *)&cmd_setbypass_event_mode_value,
5568 (void *)&cmd_setbypass_event_port,
5574 /* *** SET NIC BYPASS TIMEOUT *** */
5575 struct cmd_set_bypass_timeout_result {
5576 cmdline_fixed_string_t set;
5577 cmdline_fixed_string_t bypass;
5578 cmdline_fixed_string_t timeout;
5579 cmdline_fixed_string_t value;
5583 cmd_set_bypass_timeout_parsed(void *parsed_result,
5584 __rte_unused struct cmdline *cl,
5585 __rte_unused void *data)
5587 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5589 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5590 if (!strcmp(res->value, "1.5"))
5591 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5592 else if (!strcmp(res->value, "2"))
5593 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5594 else if (!strcmp(res->value, "3"))
5595 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5596 else if (!strcmp(res->value, "4"))
5597 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5598 else if (!strcmp(res->value, "8"))
5599 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5600 else if (!strcmp(res->value, "16"))
5601 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5602 else if (!strcmp(res->value, "32"))
5603 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5605 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5609 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5610 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5612 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5613 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5615 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5616 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5617 timeout, "timeout");
5618 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5619 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5620 value, "0#1.5#2#3#4#8#16#32");
5622 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5623 .f = cmd_set_bypass_timeout_parsed,
5624 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5625 "Set the NIC bypass watchdog timeout in seconds",
5628 (void *)&cmd_setbypass_timeout_set,
5629 (void *)&cmd_setbypass_timeout_bypass,
5630 (void *)&cmd_setbypass_timeout_timeout,
5631 (void *)&cmd_setbypass_timeout_value,
5636 /* *** SHOW NIC BYPASS MODE *** */
5637 struct cmd_show_bypass_config_result {
5638 cmdline_fixed_string_t show;
5639 cmdline_fixed_string_t bypass;
5640 cmdline_fixed_string_t config;
5645 cmd_show_bypass_config_parsed(void *parsed_result,
5646 __rte_unused struct cmdline *cl,
5647 __rte_unused void *data)
5649 struct cmd_show_bypass_config_result *res = parsed_result;
5650 portid_t port_id = res->port_id;
5652 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5653 uint32_t event_mode;
5654 uint32_t bypass_mode;
5655 uint32_t timeout = bypass_timeout;
5658 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5659 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5660 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5661 {"UNKNOWN", "normal", "bypass", "isolate"};
5662 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5670 /* Display the bypass mode.*/
5671 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5672 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5676 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5677 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5679 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5682 /* Display the bypass timeout.*/
5683 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5684 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5686 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5688 /* Display the bypass events and associated modes. */
5689 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5691 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5692 printf("\tFailed to get bypass mode for event = %s\n",
5695 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5696 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5698 printf("\tbypass event: %-16s = %s\n", events[i],
5704 printf("\tFailed to get bypass configuration for port = %d\n",
5708 cmdline_parse_token_string_t cmd_showbypass_config_show =
5709 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5711 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5712 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5714 cmdline_parse_token_string_t cmd_showbypass_config_config =
5715 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5717 cmdline_parse_token_num_t cmd_showbypass_config_port =
5718 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5721 cmdline_parse_inst_t cmd_show_bypass_config = {
5722 .f = cmd_show_bypass_config_parsed,
5723 .help_str = "show bypass config <port_id>: "
5724 "Show the NIC bypass config for port_id",
5727 (void *)&cmd_showbypass_config_show,
5728 (void *)&cmd_showbypass_config_bypass,
5729 (void *)&cmd_showbypass_config_config,
5730 (void *)&cmd_showbypass_config_port,
5736 /* *** SET BONDING MODE *** */
5737 struct cmd_set_bonding_mode_result {
5738 cmdline_fixed_string_t set;
5739 cmdline_fixed_string_t bonding;
5740 cmdline_fixed_string_t mode;
5745 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5746 __rte_unused struct cmdline *cl,
5747 __rte_unused void *data)
5749 struct cmd_set_bonding_mode_result *res = parsed_result;
5750 portid_t port_id = res->port_id;
5752 /* Set the bonding mode for the relevant port. */
5753 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5754 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5757 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5758 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5760 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5761 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5762 bonding, "bonding");
5763 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5764 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5766 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5767 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5769 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5770 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5773 cmdline_parse_inst_t cmd_set_bonding_mode = {
5774 .f = cmd_set_bonding_mode_parsed,
5775 .help_str = "set bonding mode <mode_value> <port_id>: "
5776 "Set the bonding mode for port_id",
5779 (void *) &cmd_setbonding_mode_set,
5780 (void *) &cmd_setbonding_mode_bonding,
5781 (void *) &cmd_setbonding_mode_mode,
5782 (void *) &cmd_setbonding_mode_value,
5783 (void *) &cmd_setbonding_mode_port,
5788 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5789 struct cmd_set_bonding_lacp_dedicated_queues_result {
5790 cmdline_fixed_string_t set;
5791 cmdline_fixed_string_t bonding;
5792 cmdline_fixed_string_t lacp;
5793 cmdline_fixed_string_t dedicated_queues;
5795 cmdline_fixed_string_t mode;
5798 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5799 __rte_unused struct cmdline *cl,
5800 __rte_unused void *data)
5802 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5803 portid_t port_id = res->port_id;
5804 struct rte_port *port;
5806 port = &ports[port_id];
5808 /** Check if the port is not started **/
5809 if (port->port_status != RTE_PORT_STOPPED) {
5810 printf("Please stop port %d first\n", port_id);
5814 if (!strcmp(res->mode, "enable")) {
5815 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5816 printf("Dedicate queues for LACP control packets"
5819 printf("Enabling dedicate queues for LACP control "
5820 "packets on port %d failed\n", port_id);
5821 } else if (!strcmp(res->mode, "disable")) {
5822 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5823 printf("Dedicated queues for LACP control packets "
5826 printf("Disabling dedicated queues for LACP control "
5827 "traffic on port %d failed\n", port_id);
5831 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5832 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5834 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5835 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5836 bonding, "bonding");
5837 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5838 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5840 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5841 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5842 dedicated_queues, "dedicated_queues");
5843 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5844 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5846 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5847 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5848 mode, "enable#disable");
5850 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5851 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5852 .help_str = "set bonding lacp dedicated_queues <port_id> "
5854 "Enable/disable dedicated queues for LACP control traffic for port_id",
5857 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5858 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5859 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5860 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5861 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5862 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5867 /* *** SET BALANCE XMIT POLICY *** */
5868 struct cmd_set_bonding_balance_xmit_policy_result {
5869 cmdline_fixed_string_t set;
5870 cmdline_fixed_string_t bonding;
5871 cmdline_fixed_string_t balance_xmit_policy;
5873 cmdline_fixed_string_t policy;
5876 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5877 __rte_unused struct cmdline *cl,
5878 __rte_unused void *data)
5880 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5881 portid_t port_id = res->port_id;
5884 if (!strcmp(res->policy, "l2")) {
5885 policy = BALANCE_XMIT_POLICY_LAYER2;
5886 } else if (!strcmp(res->policy, "l23")) {
5887 policy = BALANCE_XMIT_POLICY_LAYER23;
5888 } else if (!strcmp(res->policy, "l34")) {
5889 policy = BALANCE_XMIT_POLICY_LAYER34;
5891 printf("\t Invalid xmit policy selection");
5895 /* Set the bonding mode for the relevant port. */
5896 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5897 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5902 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5903 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5905 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5906 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5907 bonding, "bonding");
5908 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5909 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5910 balance_xmit_policy, "balance_xmit_policy");
5911 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5912 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5914 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5915 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5916 policy, "l2#l23#l34");
5918 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5919 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5920 .help_str = "set bonding balance_xmit_policy <port_id> "
5922 "Set the bonding balance_xmit_policy for port_id",
5925 (void *)&cmd_setbonding_balance_xmit_policy_set,
5926 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5927 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5928 (void *)&cmd_setbonding_balance_xmit_policy_port,
5929 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5934 /* *** SHOW NIC BONDING CONFIGURATION *** */
5935 struct cmd_show_bonding_config_result {
5936 cmdline_fixed_string_t show;
5937 cmdline_fixed_string_t bonding;
5938 cmdline_fixed_string_t config;
5942 static void cmd_show_bonding_config_parsed(void *parsed_result,
5943 __rte_unused struct cmdline *cl,
5944 __rte_unused void *data)
5946 struct cmd_show_bonding_config_result *res = parsed_result;
5947 int bonding_mode, agg_mode;
5948 portid_t slaves[RTE_MAX_ETHPORTS];
5949 int num_slaves, num_active_slaves;
5952 portid_t port_id = res->port_id;
5954 /* Display the bonding mode.*/
5955 bonding_mode = rte_eth_bond_mode_get(port_id);
5956 if (bonding_mode < 0) {
5957 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5960 printf("\tBonding mode: %d\n", bonding_mode);
5962 if (bonding_mode == BONDING_MODE_BALANCE) {
5963 int balance_xmit_policy;
5965 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5966 if (balance_xmit_policy < 0) {
5967 printf("\tFailed to get balance xmit policy for port = %d\n",
5971 printf("\tBalance Xmit Policy: ");
5973 switch (balance_xmit_policy) {
5974 case BALANCE_XMIT_POLICY_LAYER2:
5975 printf("BALANCE_XMIT_POLICY_LAYER2");
5977 case BALANCE_XMIT_POLICY_LAYER23:
5978 printf("BALANCE_XMIT_POLICY_LAYER23");
5980 case BALANCE_XMIT_POLICY_LAYER34:
5981 printf("BALANCE_XMIT_POLICY_LAYER34");
5988 if (bonding_mode == BONDING_MODE_8023AD) {
5989 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5990 printf("\tIEEE802.3AD Aggregator Mode: ");
5993 printf("bandwidth");
6005 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6007 if (num_slaves < 0) {
6008 printf("\tFailed to get slave list for port = %d\n", port_id);
6011 if (num_slaves > 0) {
6012 printf("\tSlaves (%d): [", num_slaves);
6013 for (i = 0; i < num_slaves - 1; i++)
6014 printf("%d ", slaves[i]);
6016 printf("%d]\n", slaves[num_slaves - 1]);
6018 printf("\tSlaves: []\n");
6022 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6025 if (num_active_slaves < 0) {
6026 printf("\tFailed to get active slave list for port = %d\n", port_id);
6029 if (num_active_slaves > 0) {
6030 printf("\tActive Slaves (%d): [", num_active_slaves);
6031 for (i = 0; i < num_active_slaves - 1; i++)
6032 printf("%d ", slaves[i]);
6034 printf("%d]\n", slaves[num_active_slaves - 1]);
6037 printf("\tActive Slaves: []\n");
6041 primary_id = rte_eth_bond_primary_get(port_id);
6042 if (primary_id < 0) {
6043 printf("\tFailed to get primary slave for port = %d\n", port_id);
6046 printf("\tPrimary: [%d]\n", primary_id);
6050 cmdline_parse_token_string_t cmd_showbonding_config_show =
6051 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6053 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6054 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6055 bonding, "bonding");
6056 cmdline_parse_token_string_t cmd_showbonding_config_config =
6057 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6059 cmdline_parse_token_num_t cmd_showbonding_config_port =
6060 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6063 cmdline_parse_inst_t cmd_show_bonding_config = {
6064 .f = cmd_show_bonding_config_parsed,
6065 .help_str = "show bonding config <port_id>: "
6066 "Show the bonding config for port_id",
6069 (void *)&cmd_showbonding_config_show,
6070 (void *)&cmd_showbonding_config_bonding,
6071 (void *)&cmd_showbonding_config_config,
6072 (void *)&cmd_showbonding_config_port,
6077 /* *** SET BONDING PRIMARY *** */
6078 struct cmd_set_bonding_primary_result {
6079 cmdline_fixed_string_t set;
6080 cmdline_fixed_string_t bonding;
6081 cmdline_fixed_string_t primary;
6086 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6087 __rte_unused struct cmdline *cl,
6088 __rte_unused void *data)
6090 struct cmd_set_bonding_primary_result *res = parsed_result;
6091 portid_t master_port_id = res->port_id;
6092 portid_t slave_port_id = res->slave_id;
6094 /* Set the primary slave for a bonded device. */
6095 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6096 printf("\t Failed to set primary slave for port = %d.\n",
6103 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6104 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6106 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6107 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6108 bonding, "bonding");
6109 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6110 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6111 primary, "primary");
6112 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6113 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6115 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6116 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6119 cmdline_parse_inst_t cmd_set_bonding_primary = {
6120 .f = cmd_set_bonding_primary_parsed,
6121 .help_str = "set bonding primary <slave_id> <port_id>: "
6122 "Set the primary slave for port_id",
6125 (void *)&cmd_setbonding_primary_set,
6126 (void *)&cmd_setbonding_primary_bonding,
6127 (void *)&cmd_setbonding_primary_primary,
6128 (void *)&cmd_setbonding_primary_slave,
6129 (void *)&cmd_setbonding_primary_port,
6134 /* *** ADD SLAVE *** */
6135 struct cmd_add_bonding_slave_result {
6136 cmdline_fixed_string_t add;
6137 cmdline_fixed_string_t bonding;
6138 cmdline_fixed_string_t slave;
6143 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6144 __rte_unused struct cmdline *cl,
6145 __rte_unused void *data)
6147 struct cmd_add_bonding_slave_result *res = parsed_result;
6148 portid_t master_port_id = res->port_id;
6149 portid_t slave_port_id = res->slave_id;
6151 /* add the slave for a bonded device. */
6152 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6153 printf("\t Failed to add slave %d to master port = %d.\n",
6154 slave_port_id, master_port_id);
6158 set_port_slave_flag(slave_port_id);
6161 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6162 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6164 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6165 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6166 bonding, "bonding");
6167 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6168 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6170 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6171 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6173 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6174 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6177 cmdline_parse_inst_t cmd_add_bonding_slave = {
6178 .f = cmd_add_bonding_slave_parsed,
6179 .help_str = "add bonding slave <slave_id> <port_id>: "
6180 "Add a slave device to a bonded device",
6183 (void *)&cmd_addbonding_slave_add,
6184 (void *)&cmd_addbonding_slave_bonding,
6185 (void *)&cmd_addbonding_slave_slave,
6186 (void *)&cmd_addbonding_slave_slaveid,
6187 (void *)&cmd_addbonding_slave_port,
6192 /* *** REMOVE SLAVE *** */
6193 struct cmd_remove_bonding_slave_result {
6194 cmdline_fixed_string_t remove;
6195 cmdline_fixed_string_t bonding;
6196 cmdline_fixed_string_t slave;
6201 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6202 __rte_unused struct cmdline *cl,
6203 __rte_unused void *data)
6205 struct cmd_remove_bonding_slave_result *res = parsed_result;
6206 portid_t master_port_id = res->port_id;
6207 portid_t slave_port_id = res->slave_id;
6209 /* remove the slave from a bonded device. */
6210 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6211 printf("\t Failed to remove slave %d from master port = %d.\n",
6212 slave_port_id, master_port_id);
6216 clear_port_slave_flag(slave_port_id);
6219 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6220 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6222 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6223 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6224 bonding, "bonding");
6225 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6226 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6228 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6229 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6231 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6232 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6235 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6236 .f = cmd_remove_bonding_slave_parsed,
6237 .help_str = "remove bonding slave <slave_id> <port_id>: "
6238 "Remove a slave device from a bonded device",
6241 (void *)&cmd_removebonding_slave_remove,
6242 (void *)&cmd_removebonding_slave_bonding,
6243 (void *)&cmd_removebonding_slave_slave,
6244 (void *)&cmd_removebonding_slave_slaveid,
6245 (void *)&cmd_removebonding_slave_port,
6250 /* *** CREATE BONDED DEVICE *** */
6251 struct cmd_create_bonded_device_result {
6252 cmdline_fixed_string_t create;
6253 cmdline_fixed_string_t bonded;
6254 cmdline_fixed_string_t device;
6259 static int bond_dev_num = 0;
6261 static void cmd_create_bonded_device_parsed(void *parsed_result,
6262 __rte_unused struct cmdline *cl,
6263 __rte_unused void *data)
6265 struct cmd_create_bonded_device_result *res = parsed_result;
6266 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6270 if (test_done == 0) {
6271 printf("Please stop forwarding first\n");
6275 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6278 /* Create a new bonded device. */
6279 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6281 printf("\t Failed to create bonded device.\n");
6284 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6287 /* Update number of ports */
6288 nb_ports = rte_eth_dev_count_avail();
6289 reconfig(port_id, res->socket);
6290 ret = rte_eth_promiscuous_enable(port_id);
6292 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6293 port_id, rte_strerror(-ret));
6295 ports[port_id].need_setup = 0;
6296 ports[port_id].port_status = RTE_PORT_STOPPED;
6301 cmdline_parse_token_string_t cmd_createbonded_device_create =
6302 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6304 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6305 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6307 cmdline_parse_token_string_t cmd_createbonded_device_device =
6308 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6310 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6311 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6313 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6314 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6317 cmdline_parse_inst_t cmd_create_bonded_device = {
6318 .f = cmd_create_bonded_device_parsed,
6319 .help_str = "create bonded device <mode> <socket>: "
6320 "Create a new bonded device with specific bonding mode and socket",
6323 (void *)&cmd_createbonded_device_create,
6324 (void *)&cmd_createbonded_device_bonded,
6325 (void *)&cmd_createbonded_device_device,
6326 (void *)&cmd_createbonded_device_mode,
6327 (void *)&cmd_createbonded_device_socket,
6332 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6333 struct cmd_set_bond_mac_addr_result {
6334 cmdline_fixed_string_t set;
6335 cmdline_fixed_string_t bonding;
6336 cmdline_fixed_string_t mac_addr;
6338 struct rte_ether_addr address;
6341 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6342 __rte_unused struct cmdline *cl,
6343 __rte_unused void *data)
6345 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6348 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6351 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6353 /* check the return value and print it if is < 0 */
6355 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6358 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6359 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6360 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6361 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6363 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6364 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6366 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6367 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6369 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6370 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6372 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6373 .f = cmd_set_bond_mac_addr_parsed,
6375 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6377 (void *)&cmd_set_bond_mac_addr_set,
6378 (void *)&cmd_set_bond_mac_addr_bonding,
6379 (void *)&cmd_set_bond_mac_addr_mac,
6380 (void *)&cmd_set_bond_mac_addr_portnum,
6381 (void *)&cmd_set_bond_mac_addr_addr,
6387 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6388 struct cmd_set_bond_mon_period_result {
6389 cmdline_fixed_string_t set;
6390 cmdline_fixed_string_t bonding;
6391 cmdline_fixed_string_t mon_period;
6396 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6397 __rte_unused struct cmdline *cl,
6398 __rte_unused void *data)
6400 struct cmd_set_bond_mon_period_result *res = parsed_result;
6403 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6405 /* check the return value and print it if is < 0 */
6407 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6410 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6411 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6413 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6414 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6415 bonding, "bonding");
6416 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6417 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6418 mon_period, "mon_period");
6419 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6420 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6422 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6423 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6426 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6427 .f = cmd_set_bond_mon_period_parsed,
6429 .help_str = "set bonding mon_period <port_id> <period_ms>",
6431 (void *)&cmd_set_bond_mon_period_set,
6432 (void *)&cmd_set_bond_mon_period_bonding,
6433 (void *)&cmd_set_bond_mon_period_mon_period,
6434 (void *)&cmd_set_bond_mon_period_portnum,
6435 (void *)&cmd_set_bond_mon_period_period_ms,
6442 struct cmd_set_bonding_agg_mode_policy_result {
6443 cmdline_fixed_string_t set;
6444 cmdline_fixed_string_t bonding;
6445 cmdline_fixed_string_t agg_mode;
6447 cmdline_fixed_string_t policy;
6452 cmd_set_bonding_agg_mode(void *parsed_result,
6453 __rte_unused struct cmdline *cl,
6454 __rte_unused void *data)
6456 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6457 uint8_t policy = AGG_BANDWIDTH;
6459 if (!strcmp(res->policy, "bandwidth"))
6460 policy = AGG_BANDWIDTH;
6461 else if (!strcmp(res->policy, "stable"))
6462 policy = AGG_STABLE;
6463 else if (!strcmp(res->policy, "count"))
6466 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6470 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6471 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6473 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6474 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6475 bonding, "bonding");
6477 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6478 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6479 agg_mode, "agg_mode");
6481 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6482 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6485 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6486 TOKEN_STRING_INITIALIZER(
6487 struct cmd_set_bonding_balance_xmit_policy_result,
6488 policy, "stable#bandwidth#count");
6490 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6491 .f = cmd_set_bonding_agg_mode,
6493 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6495 (void *)&cmd_set_bonding_agg_mode_set,
6496 (void *)&cmd_set_bonding_agg_mode_bonding,
6497 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6498 (void *)&cmd_set_bonding_agg_mode_portnum,
6499 (void *)&cmd_set_bonding_agg_mode_policy_string,
6505 #endif /* RTE_NET_BOND */
6507 /* *** SET FORWARDING MODE *** */
6508 struct cmd_set_fwd_mode_result {
6509 cmdline_fixed_string_t set;
6510 cmdline_fixed_string_t fwd;
6511 cmdline_fixed_string_t mode;
6514 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6515 __rte_unused struct cmdline *cl,
6516 __rte_unused void *data)
6518 struct cmd_set_fwd_mode_result *res = parsed_result;
6521 set_pkt_forwarding_mode(res->mode);
6524 cmdline_parse_token_string_t cmd_setfwd_set =
6525 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6526 cmdline_parse_token_string_t cmd_setfwd_fwd =
6527 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6528 cmdline_parse_token_string_t cmd_setfwd_mode =
6529 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6530 "" /* defined at init */);
6532 cmdline_parse_inst_t cmd_set_fwd_mode = {
6533 .f = cmd_set_fwd_mode_parsed,
6535 .help_str = NULL, /* defined at init */
6537 (void *)&cmd_setfwd_set,
6538 (void *)&cmd_setfwd_fwd,
6539 (void *)&cmd_setfwd_mode,
6544 static void cmd_set_fwd_mode_init(void)
6547 static char token[128];
6548 static char help[256];
6549 cmdline_parse_token_string_t *token_struct;
6551 modes = list_pkt_forwarding_modes();
6552 snprintf(help, sizeof(help), "set fwd %s: "
6553 "Set packet forwarding mode", modes);
6554 cmd_set_fwd_mode.help_str = help;
6556 /* string token separator is # */
6557 for (c = token; *modes != '\0'; modes++)
6562 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6563 token_struct->string_data.str = token;
6566 /* *** SET RETRY FORWARDING MODE *** */
6567 struct cmd_set_fwd_retry_mode_result {
6568 cmdline_fixed_string_t set;
6569 cmdline_fixed_string_t fwd;
6570 cmdline_fixed_string_t mode;
6571 cmdline_fixed_string_t retry;
6574 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6575 __rte_unused struct cmdline *cl,
6576 __rte_unused void *data)
6578 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6581 set_pkt_forwarding_mode(res->mode);
6584 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6585 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6587 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6588 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6590 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6591 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6593 "" /* defined at init */);
6594 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6595 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6598 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6599 .f = cmd_set_fwd_retry_mode_parsed,
6601 .help_str = NULL, /* defined at init */
6603 (void *)&cmd_setfwd_retry_set,
6604 (void *)&cmd_setfwd_retry_fwd,
6605 (void *)&cmd_setfwd_retry_mode,
6606 (void *)&cmd_setfwd_retry_retry,
6611 static void cmd_set_fwd_retry_mode_init(void)
6614 static char token[128];
6615 static char help[256];
6616 cmdline_parse_token_string_t *token_struct;
6618 modes = list_pkt_forwarding_retry_modes();
6619 snprintf(help, sizeof(help), "set fwd %s retry: "
6620 "Set packet forwarding mode with retry", modes);
6621 cmd_set_fwd_retry_mode.help_str = help;
6623 /* string token separator is # */
6624 for (c = token; *modes != '\0'; modes++)
6629 token_struct = (cmdline_parse_token_string_t *)
6630 cmd_set_fwd_retry_mode.tokens[2];
6631 token_struct->string_data.str = token;
6634 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6635 struct cmd_set_burst_tx_retry_result {
6636 cmdline_fixed_string_t set;
6637 cmdline_fixed_string_t burst;
6638 cmdline_fixed_string_t tx;
6639 cmdline_fixed_string_t delay;
6641 cmdline_fixed_string_t retry;
6645 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6646 __rte_unused struct cmdline *cl,
6647 __rte_unused void *data)
6649 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6651 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6652 && !strcmp(res->tx, "tx")) {
6653 if (!strcmp(res->delay, "delay"))
6654 burst_tx_delay_time = res->time;
6655 if (!strcmp(res->retry, "retry"))
6656 burst_tx_retry_num = res->retry_num;
6661 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6662 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6663 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6664 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6666 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6667 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6668 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6669 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6670 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6671 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6672 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6673 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6674 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6675 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6677 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6678 .f = cmd_set_burst_tx_retry_parsed,
6679 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6681 (void *)&cmd_set_burst_tx_retry_set,
6682 (void *)&cmd_set_burst_tx_retry_burst,
6683 (void *)&cmd_set_burst_tx_retry_tx,
6684 (void *)&cmd_set_burst_tx_retry_delay,
6685 (void *)&cmd_set_burst_tx_retry_time,
6686 (void *)&cmd_set_burst_tx_retry_retry,
6687 (void *)&cmd_set_burst_tx_retry_retry_num,
6692 /* *** SET PROMISC MODE *** */
6693 struct cmd_set_promisc_mode_result {
6694 cmdline_fixed_string_t set;
6695 cmdline_fixed_string_t promisc;
6696 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6697 uint16_t port_num; /* valid if "allports" argument == 0 */
6698 cmdline_fixed_string_t mode;
6701 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6702 __rte_unused struct cmdline *cl,
6705 struct cmd_set_promisc_mode_result *res = parsed_result;
6709 if (!strcmp(res->mode, "on"))
6716 RTE_ETH_FOREACH_DEV(i)
6717 eth_set_promisc_mode(i, enable);
6719 eth_set_promisc_mode(res->port_num, enable);
6723 cmdline_parse_token_string_t cmd_setpromisc_set =
6724 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6725 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6726 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6728 cmdline_parse_token_string_t cmd_setpromisc_portall =
6729 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6731 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6732 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6734 cmdline_parse_token_string_t cmd_setpromisc_mode =
6735 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6738 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6739 .f = cmd_set_promisc_mode_parsed,
6741 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6743 (void *)&cmd_setpromisc_set,
6744 (void *)&cmd_setpromisc_promisc,
6745 (void *)&cmd_setpromisc_portall,
6746 (void *)&cmd_setpromisc_mode,
6751 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6752 .f = cmd_set_promisc_mode_parsed,
6754 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6756 (void *)&cmd_setpromisc_set,
6757 (void *)&cmd_setpromisc_promisc,
6758 (void *)&cmd_setpromisc_portnum,
6759 (void *)&cmd_setpromisc_mode,
6764 /* *** SET ALLMULTI MODE *** */
6765 struct cmd_set_allmulti_mode_result {
6766 cmdline_fixed_string_t set;
6767 cmdline_fixed_string_t allmulti;
6768 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6769 uint16_t port_num; /* valid if "allports" argument == 0 */
6770 cmdline_fixed_string_t mode;
6773 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6774 __rte_unused struct cmdline *cl,
6777 struct cmd_set_allmulti_mode_result *res = parsed_result;
6781 if (!strcmp(res->mode, "on"))
6788 RTE_ETH_FOREACH_DEV(i) {
6789 eth_set_allmulticast_mode(i, enable);
6793 eth_set_allmulticast_mode(res->port_num, enable);
6797 cmdline_parse_token_string_t cmd_setallmulti_set =
6798 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6799 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6800 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6802 cmdline_parse_token_string_t cmd_setallmulti_portall =
6803 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6805 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6806 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6808 cmdline_parse_token_string_t cmd_setallmulti_mode =
6809 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6812 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6813 .f = cmd_set_allmulti_mode_parsed,
6815 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6817 (void *)&cmd_setallmulti_set,
6818 (void *)&cmd_setallmulti_allmulti,
6819 (void *)&cmd_setallmulti_portall,
6820 (void *)&cmd_setallmulti_mode,
6825 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6826 .f = cmd_set_allmulti_mode_parsed,
6828 .help_str = "set allmulti <port_id> on|off: "
6829 "Set allmulti mode on port_id",
6831 (void *)&cmd_setallmulti_set,
6832 (void *)&cmd_setallmulti_allmulti,
6833 (void *)&cmd_setallmulti_portnum,
6834 (void *)&cmd_setallmulti_mode,
6839 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6840 struct cmd_link_flow_ctrl_set_result {
6841 cmdline_fixed_string_t set;
6842 cmdline_fixed_string_t flow_ctrl;
6843 cmdline_fixed_string_t rx;
6844 cmdline_fixed_string_t rx_lfc_mode;
6845 cmdline_fixed_string_t tx;
6846 cmdline_fixed_string_t tx_lfc_mode;
6847 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6848 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6849 cmdline_fixed_string_t autoneg_str;
6850 cmdline_fixed_string_t autoneg;
6851 cmdline_fixed_string_t hw_str;
6852 uint32_t high_water;
6853 cmdline_fixed_string_t lw_str;
6855 cmdline_fixed_string_t pt_str;
6856 uint16_t pause_time;
6857 cmdline_fixed_string_t xon_str;
6862 cmdline_parse_token_string_t cmd_lfc_set_set =
6863 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6865 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6866 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6867 flow_ctrl, "flow_ctrl");
6868 cmdline_parse_token_string_t cmd_lfc_set_rx =
6869 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6871 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6872 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6873 rx_lfc_mode, "on#off");
6874 cmdline_parse_token_string_t cmd_lfc_set_tx =
6875 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6877 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6878 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6879 tx_lfc_mode, "on#off");
6880 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6881 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6882 hw_str, "high_water");
6883 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6884 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6885 high_water, UINT32);
6886 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6887 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6888 lw_str, "low_water");
6889 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6890 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6892 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6893 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6894 pt_str, "pause_time");
6895 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6896 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6897 pause_time, UINT16);
6898 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6899 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6900 xon_str, "send_xon");
6901 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6902 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6904 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6905 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6906 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6907 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6908 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6909 mac_ctrl_frame_fwd_mode, "on#off");
6910 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6911 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6912 autoneg_str, "autoneg");
6913 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6914 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6916 cmdline_parse_token_num_t cmd_lfc_set_portid =
6917 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6920 /* forward declaration */
6922 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6925 cmdline_parse_inst_t cmd_link_flow_control_set = {
6926 .f = cmd_link_flow_ctrl_set_parsed,
6928 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6929 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6930 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6932 (void *)&cmd_lfc_set_set,
6933 (void *)&cmd_lfc_set_flow_ctrl,
6934 (void *)&cmd_lfc_set_rx,
6935 (void *)&cmd_lfc_set_rx_mode,
6936 (void *)&cmd_lfc_set_tx,
6937 (void *)&cmd_lfc_set_tx_mode,
6938 (void *)&cmd_lfc_set_high_water,
6939 (void *)&cmd_lfc_set_low_water,
6940 (void *)&cmd_lfc_set_pause_time,
6941 (void *)&cmd_lfc_set_send_xon,
6942 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6943 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6944 (void *)&cmd_lfc_set_autoneg_str,
6945 (void *)&cmd_lfc_set_autoneg,
6946 (void *)&cmd_lfc_set_portid,
6951 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6952 .f = cmd_link_flow_ctrl_set_parsed,
6953 .data = (void *)&cmd_link_flow_control_set_rx,
6954 .help_str = "set flow_ctrl rx on|off <port_id>: "
6955 "Change rx flow control parameter",
6957 (void *)&cmd_lfc_set_set,
6958 (void *)&cmd_lfc_set_flow_ctrl,
6959 (void *)&cmd_lfc_set_rx,
6960 (void *)&cmd_lfc_set_rx_mode,
6961 (void *)&cmd_lfc_set_portid,
6966 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6967 .f = cmd_link_flow_ctrl_set_parsed,
6968 .data = (void *)&cmd_link_flow_control_set_tx,
6969 .help_str = "set flow_ctrl tx on|off <port_id>: "
6970 "Change tx flow control parameter",
6972 (void *)&cmd_lfc_set_set,
6973 (void *)&cmd_lfc_set_flow_ctrl,
6974 (void *)&cmd_lfc_set_tx,
6975 (void *)&cmd_lfc_set_tx_mode,
6976 (void *)&cmd_lfc_set_portid,
6981 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6982 .f = cmd_link_flow_ctrl_set_parsed,
6983 .data = (void *)&cmd_link_flow_control_set_hw,
6984 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6985 "Change high water flow control parameter",
6987 (void *)&cmd_lfc_set_set,
6988 (void *)&cmd_lfc_set_flow_ctrl,
6989 (void *)&cmd_lfc_set_high_water_str,
6990 (void *)&cmd_lfc_set_high_water,
6991 (void *)&cmd_lfc_set_portid,
6996 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6997 .f = cmd_link_flow_ctrl_set_parsed,
6998 .data = (void *)&cmd_link_flow_control_set_lw,
6999 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7000 "Change low water flow control parameter",
7002 (void *)&cmd_lfc_set_set,
7003 (void *)&cmd_lfc_set_flow_ctrl,
7004 (void *)&cmd_lfc_set_low_water_str,
7005 (void *)&cmd_lfc_set_low_water,
7006 (void *)&cmd_lfc_set_portid,
7011 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7012 .f = cmd_link_flow_ctrl_set_parsed,
7013 .data = (void *)&cmd_link_flow_control_set_pt,
7014 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7015 "Change pause time flow control parameter",
7017 (void *)&cmd_lfc_set_set,
7018 (void *)&cmd_lfc_set_flow_ctrl,
7019 (void *)&cmd_lfc_set_pause_time_str,
7020 (void *)&cmd_lfc_set_pause_time,
7021 (void *)&cmd_lfc_set_portid,
7026 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7027 .f = cmd_link_flow_ctrl_set_parsed,
7028 .data = (void *)&cmd_link_flow_control_set_xon,
7029 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7030 "Change send_xon flow control parameter",
7032 (void *)&cmd_lfc_set_set,
7033 (void *)&cmd_lfc_set_flow_ctrl,
7034 (void *)&cmd_lfc_set_send_xon_str,
7035 (void *)&cmd_lfc_set_send_xon,
7036 (void *)&cmd_lfc_set_portid,
7041 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7042 .f = cmd_link_flow_ctrl_set_parsed,
7043 .data = (void *)&cmd_link_flow_control_set_macfwd,
7044 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7045 "Change mac ctrl fwd flow control parameter",
7047 (void *)&cmd_lfc_set_set,
7048 (void *)&cmd_lfc_set_flow_ctrl,
7049 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7050 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7051 (void *)&cmd_lfc_set_portid,
7056 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7057 .f = cmd_link_flow_ctrl_set_parsed,
7058 .data = (void *)&cmd_link_flow_control_set_autoneg,
7059 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7060 "Change autoneg flow control parameter",
7062 (void *)&cmd_lfc_set_set,
7063 (void *)&cmd_lfc_set_flow_ctrl,
7064 (void *)&cmd_lfc_set_autoneg_str,
7065 (void *)&cmd_lfc_set_autoneg,
7066 (void *)&cmd_lfc_set_portid,
7072 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7073 __rte_unused struct cmdline *cl,
7076 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7077 cmdline_parse_inst_t *cmd = data;
7078 struct rte_eth_fc_conf fc_conf;
7084 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7085 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7086 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7087 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7089 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7090 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7093 /* Partial command line, retrieve current configuration */
7095 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7097 printf("cannot get current flow ctrl parameters, return"
7098 "code = %d\n", ret);
7102 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7103 (fc_conf.mode == RTE_FC_FULL))
7105 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7106 (fc_conf.mode == RTE_FC_FULL))
7110 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7111 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7113 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7114 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7116 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7118 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7119 fc_conf.high_water = res->high_water;
7121 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7122 fc_conf.low_water = res->low_water;
7124 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7125 fc_conf.pause_time = res->pause_time;
7127 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7128 fc_conf.send_xon = res->send_xon;
7130 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7131 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7132 fc_conf.mac_ctrl_frame_fwd = 1;
7134 fc_conf.mac_ctrl_frame_fwd = 0;
7137 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7138 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7140 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7142 printf("bad flow contrl parameter, return code = %d \n", ret);
7145 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7146 struct cmd_priority_flow_ctrl_set_result {
7147 cmdline_fixed_string_t set;
7148 cmdline_fixed_string_t pfc_ctrl;
7149 cmdline_fixed_string_t rx;
7150 cmdline_fixed_string_t rx_pfc_mode;
7151 cmdline_fixed_string_t tx;
7152 cmdline_fixed_string_t tx_pfc_mode;
7153 uint32_t high_water;
7155 uint16_t pause_time;
7161 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7162 __rte_unused struct cmdline *cl,
7163 __rte_unused void *data)
7165 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7166 struct rte_eth_pfc_conf pfc_conf;
7167 int rx_fc_enable, tx_fc_enable;
7171 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7172 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7173 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7174 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7176 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7177 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7180 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7181 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7182 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7183 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7184 pfc_conf.fc.high_water = res->high_water;
7185 pfc_conf.fc.low_water = res->low_water;
7186 pfc_conf.fc.pause_time = res->pause_time;
7187 pfc_conf.priority = res->priority;
7189 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7191 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7194 cmdline_parse_token_string_t cmd_pfc_set_set =
7195 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7197 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7198 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7199 pfc_ctrl, "pfc_ctrl");
7200 cmdline_parse_token_string_t cmd_pfc_set_rx =
7201 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7203 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7204 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7205 rx_pfc_mode, "on#off");
7206 cmdline_parse_token_string_t cmd_pfc_set_tx =
7207 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7209 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7210 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7211 tx_pfc_mode, "on#off");
7212 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7213 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7214 high_water, UINT32);
7215 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7216 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7218 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7219 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7220 pause_time, UINT16);
7221 cmdline_parse_token_num_t cmd_pfc_set_priority =
7222 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7224 cmdline_parse_token_num_t cmd_pfc_set_portid =
7225 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7228 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7229 .f = cmd_priority_flow_ctrl_set_parsed,
7231 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7232 "<pause_time> <priority> <port_id>: "
7233 "Configure the Ethernet priority flow control",
7235 (void *)&cmd_pfc_set_set,
7236 (void *)&cmd_pfc_set_flow_ctrl,
7237 (void *)&cmd_pfc_set_rx,
7238 (void *)&cmd_pfc_set_rx_mode,
7239 (void *)&cmd_pfc_set_tx,
7240 (void *)&cmd_pfc_set_tx_mode,
7241 (void *)&cmd_pfc_set_high_water,
7242 (void *)&cmd_pfc_set_low_water,
7243 (void *)&cmd_pfc_set_pause_time,
7244 (void *)&cmd_pfc_set_priority,
7245 (void *)&cmd_pfc_set_portid,
7250 /* *** RESET CONFIGURATION *** */
7251 struct cmd_reset_result {
7252 cmdline_fixed_string_t reset;
7253 cmdline_fixed_string_t def;
7256 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7258 __rte_unused void *data)
7260 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7261 set_def_fwd_config();
7264 cmdline_parse_token_string_t cmd_reset_set =
7265 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7266 cmdline_parse_token_string_t cmd_reset_def =
7267 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7270 cmdline_parse_inst_t cmd_reset = {
7271 .f = cmd_reset_parsed,
7273 .help_str = "set default: Reset default forwarding configuration",
7275 (void *)&cmd_reset_set,
7276 (void *)&cmd_reset_def,
7281 /* *** START FORWARDING *** */
7282 struct cmd_start_result {
7283 cmdline_fixed_string_t start;
7286 cmdline_parse_token_string_t cmd_start_start =
7287 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7289 static void cmd_start_parsed(__rte_unused void *parsed_result,
7290 __rte_unused struct cmdline *cl,
7291 __rte_unused void *data)
7293 start_packet_forwarding(0);
7296 cmdline_parse_inst_t cmd_start = {
7297 .f = cmd_start_parsed,
7299 .help_str = "start: Start packet forwarding",
7301 (void *)&cmd_start_start,
7306 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7307 struct cmd_start_tx_first_result {
7308 cmdline_fixed_string_t start;
7309 cmdline_fixed_string_t tx_first;
7313 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7314 __rte_unused struct cmdline *cl,
7315 __rte_unused void *data)
7317 start_packet_forwarding(1);
7320 cmdline_parse_token_string_t cmd_start_tx_first_start =
7321 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7323 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7324 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7325 tx_first, "tx_first");
7327 cmdline_parse_inst_t cmd_start_tx_first = {
7328 .f = cmd_start_tx_first_parsed,
7330 .help_str = "start tx_first: Start packet forwarding, "
7331 "after sending 1 burst of packets",
7333 (void *)&cmd_start_tx_first_start,
7334 (void *)&cmd_start_tx_first_tx_first,
7339 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7340 struct cmd_start_tx_first_n_result {
7341 cmdline_fixed_string_t start;
7342 cmdline_fixed_string_t tx_first;
7347 cmd_start_tx_first_n_parsed(void *parsed_result,
7348 __rte_unused struct cmdline *cl,
7349 __rte_unused void *data)
7351 struct cmd_start_tx_first_n_result *res = parsed_result;
7353 start_packet_forwarding(res->tx_num);
7356 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7357 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7359 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7360 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7361 tx_first, "tx_first");
7362 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7363 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7366 cmdline_parse_inst_t cmd_start_tx_first_n = {
7367 .f = cmd_start_tx_first_n_parsed,
7369 .help_str = "start tx_first <num>: "
7370 "packet forwarding, after sending <num> bursts of packets",
7372 (void *)&cmd_start_tx_first_n_start,
7373 (void *)&cmd_start_tx_first_n_tx_first,
7374 (void *)&cmd_start_tx_first_n_tx_num,
7379 /* *** SET LINK UP *** */
7380 struct cmd_set_link_up_result {
7381 cmdline_fixed_string_t set;
7382 cmdline_fixed_string_t link_up;
7383 cmdline_fixed_string_t port;
7387 cmdline_parse_token_string_t cmd_set_link_up_set =
7388 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7389 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7390 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7392 cmdline_parse_token_string_t cmd_set_link_up_port =
7393 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7394 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7395 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7397 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7398 __rte_unused struct cmdline *cl,
7399 __rte_unused void *data)
7401 struct cmd_set_link_up_result *res = parsed_result;
7402 dev_set_link_up(res->port_id);
7405 cmdline_parse_inst_t cmd_set_link_up = {
7406 .f = cmd_set_link_up_parsed,
7408 .help_str = "set link-up port <port id>",
7410 (void *)&cmd_set_link_up_set,
7411 (void *)&cmd_set_link_up_link_up,
7412 (void *)&cmd_set_link_up_port,
7413 (void *)&cmd_set_link_up_port_id,
7418 /* *** SET LINK DOWN *** */
7419 struct cmd_set_link_down_result {
7420 cmdline_fixed_string_t set;
7421 cmdline_fixed_string_t link_down;
7422 cmdline_fixed_string_t port;
7426 cmdline_parse_token_string_t cmd_set_link_down_set =
7427 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7428 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7429 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7431 cmdline_parse_token_string_t cmd_set_link_down_port =
7432 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7433 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7434 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7436 static void cmd_set_link_down_parsed(
7437 __rte_unused void *parsed_result,
7438 __rte_unused struct cmdline *cl,
7439 __rte_unused void *data)
7441 struct cmd_set_link_down_result *res = parsed_result;
7442 dev_set_link_down(res->port_id);
7445 cmdline_parse_inst_t cmd_set_link_down = {
7446 .f = cmd_set_link_down_parsed,
7448 .help_str = "set link-down port <port id>",
7450 (void *)&cmd_set_link_down_set,
7451 (void *)&cmd_set_link_down_link_down,
7452 (void *)&cmd_set_link_down_port,
7453 (void *)&cmd_set_link_down_port_id,
7458 /* *** SHOW CFG *** */
7459 struct cmd_showcfg_result {
7460 cmdline_fixed_string_t show;
7461 cmdline_fixed_string_t cfg;
7462 cmdline_fixed_string_t what;
7465 static void cmd_showcfg_parsed(void *parsed_result,
7466 __rte_unused struct cmdline *cl,
7467 __rte_unused void *data)
7469 struct cmd_showcfg_result *res = parsed_result;
7470 if (!strcmp(res->what, "rxtx"))
7471 rxtx_config_display();
7472 else if (!strcmp(res->what, "cores"))
7473 fwd_lcores_config_display();
7474 else if (!strcmp(res->what, "fwd"))
7475 pkt_fwd_config_display(&cur_fwd_config);
7476 else if (!strcmp(res->what, "rxoffs"))
7477 show_rx_pkt_offsets();
7478 else if (!strcmp(res->what, "rxpkts"))
7479 show_rx_pkt_segments();
7480 else if (!strcmp(res->what, "txpkts"))
7481 show_tx_pkt_segments();
7482 else if (!strcmp(res->what, "txtimes"))
7483 show_tx_pkt_times();
7486 cmdline_parse_token_string_t cmd_showcfg_show =
7487 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7488 cmdline_parse_token_string_t cmd_showcfg_port =
7489 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7490 cmdline_parse_token_string_t cmd_showcfg_what =
7491 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7492 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7494 cmdline_parse_inst_t cmd_showcfg = {
7495 .f = cmd_showcfg_parsed,
7497 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7499 (void *)&cmd_showcfg_show,
7500 (void *)&cmd_showcfg_port,
7501 (void *)&cmd_showcfg_what,
7506 /* *** SHOW ALL PORT INFO *** */
7507 struct cmd_showportall_result {
7508 cmdline_fixed_string_t show;
7509 cmdline_fixed_string_t port;
7510 cmdline_fixed_string_t what;
7511 cmdline_fixed_string_t all;
7514 static void cmd_showportall_parsed(void *parsed_result,
7515 __rte_unused struct cmdline *cl,
7516 __rte_unused void *data)
7520 struct cmd_showportall_result *res = parsed_result;
7521 if (!strcmp(res->show, "clear")) {
7522 if (!strcmp(res->what, "stats"))
7523 RTE_ETH_FOREACH_DEV(i)
7525 else if (!strcmp(res->what, "xstats"))
7526 RTE_ETH_FOREACH_DEV(i)
7527 nic_xstats_clear(i);
7528 } else if (!strcmp(res->what, "info"))
7529 RTE_ETH_FOREACH_DEV(i)
7530 port_infos_display(i);
7531 else if (!strcmp(res->what, "summary")) {
7532 port_summary_header_display();
7533 RTE_ETH_FOREACH_DEV(i)
7534 port_summary_display(i);
7536 else if (!strcmp(res->what, "stats"))
7537 RTE_ETH_FOREACH_DEV(i)
7538 nic_stats_display(i);
7539 else if (!strcmp(res->what, "xstats"))
7540 RTE_ETH_FOREACH_DEV(i)
7541 nic_xstats_display(i);
7542 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7543 else if (!strcmp(res->what, "fdir"))
7544 RTE_ETH_FOREACH_DEV(i)
7547 else if (!strcmp(res->what, "stat_qmap"))
7548 RTE_ETH_FOREACH_DEV(i)
7549 nic_stats_mapping_display(i);
7550 else if (!strcmp(res->what, "dcb_tc"))
7551 RTE_ETH_FOREACH_DEV(i)
7552 port_dcb_info_display(i);
7553 else if (!strcmp(res->what, "cap"))
7554 RTE_ETH_FOREACH_DEV(i)
7555 port_offload_cap_display(i);
7558 cmdline_parse_token_string_t cmd_showportall_show =
7559 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7561 cmdline_parse_token_string_t cmd_showportall_port =
7562 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7563 cmdline_parse_token_string_t cmd_showportall_what =
7564 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7565 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7566 cmdline_parse_token_string_t cmd_showportall_all =
7567 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7568 cmdline_parse_inst_t cmd_showportall = {
7569 .f = cmd_showportall_parsed,
7571 .help_str = "show|clear port "
7572 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7574 (void *)&cmd_showportall_show,
7575 (void *)&cmd_showportall_port,
7576 (void *)&cmd_showportall_what,
7577 (void *)&cmd_showportall_all,
7582 /* *** SHOW PORT INFO *** */
7583 struct cmd_showport_result {
7584 cmdline_fixed_string_t show;
7585 cmdline_fixed_string_t port;
7586 cmdline_fixed_string_t what;
7590 static void cmd_showport_parsed(void *parsed_result,
7591 __rte_unused struct cmdline *cl,
7592 __rte_unused void *data)
7594 struct cmd_showport_result *res = parsed_result;
7595 if (!strcmp(res->show, "clear")) {
7596 if (!strcmp(res->what, "stats"))
7597 nic_stats_clear(res->portnum);
7598 else if (!strcmp(res->what, "xstats"))
7599 nic_xstats_clear(res->portnum);
7600 } else if (!strcmp(res->what, "info"))
7601 port_infos_display(res->portnum);
7602 else if (!strcmp(res->what, "summary")) {
7603 port_summary_header_display();
7604 port_summary_display(res->portnum);
7606 else if (!strcmp(res->what, "stats"))
7607 nic_stats_display(res->portnum);
7608 else if (!strcmp(res->what, "xstats"))
7609 nic_xstats_display(res->portnum);
7610 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7611 else if (!strcmp(res->what, "fdir"))
7612 fdir_get_infos(res->portnum);
7614 else if (!strcmp(res->what, "stat_qmap"))
7615 nic_stats_mapping_display(res->portnum);
7616 else if (!strcmp(res->what, "dcb_tc"))
7617 port_dcb_info_display(res->portnum);
7618 else if (!strcmp(res->what, "cap"))
7619 port_offload_cap_display(res->portnum);
7622 cmdline_parse_token_string_t cmd_showport_show =
7623 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7625 cmdline_parse_token_string_t cmd_showport_port =
7626 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7627 cmdline_parse_token_string_t cmd_showport_what =
7628 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7629 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7630 cmdline_parse_token_num_t cmd_showport_portnum =
7631 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7633 cmdline_parse_inst_t cmd_showport = {
7634 .f = cmd_showport_parsed,
7636 .help_str = "show|clear port "
7637 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7640 (void *)&cmd_showport_show,
7641 (void *)&cmd_showport_port,
7642 (void *)&cmd_showport_what,
7643 (void *)&cmd_showport_portnum,
7648 /* *** SHOW DEVICE INFO *** */
7649 struct cmd_showdevice_result {
7650 cmdline_fixed_string_t show;
7651 cmdline_fixed_string_t device;
7652 cmdline_fixed_string_t what;
7653 cmdline_fixed_string_t identifier;
7656 static void cmd_showdevice_parsed(void *parsed_result,
7657 __rte_unused struct cmdline *cl,
7658 __rte_unused void *data)
7660 struct cmd_showdevice_result *res = parsed_result;
7661 if (!strcmp(res->what, "info")) {
7662 if (!strcmp(res->identifier, "all"))
7663 device_infos_display(NULL);
7665 device_infos_display(res->identifier);
7669 cmdline_parse_token_string_t cmd_showdevice_show =
7670 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7672 cmdline_parse_token_string_t cmd_showdevice_device =
7673 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7674 cmdline_parse_token_string_t cmd_showdevice_what =
7675 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7677 cmdline_parse_token_string_t cmd_showdevice_identifier =
7678 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7681 cmdline_parse_inst_t cmd_showdevice = {
7682 .f = cmd_showdevice_parsed,
7684 .help_str = "show device info <identifier>|all",
7686 (void *)&cmd_showdevice_show,
7687 (void *)&cmd_showdevice_device,
7688 (void *)&cmd_showdevice_what,
7689 (void *)&cmd_showdevice_identifier,
7694 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7695 struct cmd_showeeprom_result {
7696 cmdline_fixed_string_t show;
7697 cmdline_fixed_string_t port;
7699 cmdline_fixed_string_t type;
7702 static void cmd_showeeprom_parsed(void *parsed_result,
7703 __rte_unused struct cmdline *cl,
7704 __rte_unused void *data)
7706 struct cmd_showeeprom_result *res = parsed_result;
7708 if (!strcmp(res->type, "eeprom"))
7709 port_eeprom_display(res->portnum);
7710 else if (!strcmp(res->type, "module_eeprom"))
7711 port_module_eeprom_display(res->portnum);
7713 printf("Unknown argument\n");
7716 cmdline_parse_token_string_t cmd_showeeprom_show =
7717 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7718 cmdline_parse_token_string_t cmd_showeeprom_port =
7719 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7720 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7721 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum, UINT16);
7722 cmdline_parse_token_string_t cmd_showeeprom_type =
7723 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7725 cmdline_parse_inst_t cmd_showeeprom = {
7726 .f = cmd_showeeprom_parsed,
7728 .help_str = "show port <port_id> module_eeprom|eeprom",
7730 (void *)&cmd_showeeprom_show,
7731 (void *)&cmd_showeeprom_port,
7732 (void *)&cmd_showeeprom_portnum,
7733 (void *)&cmd_showeeprom_type,
7738 /* *** SHOW QUEUE INFO *** */
7739 struct cmd_showqueue_result {
7740 cmdline_fixed_string_t show;
7741 cmdline_fixed_string_t type;
7742 cmdline_fixed_string_t what;
7748 cmd_showqueue_parsed(void *parsed_result,
7749 __rte_unused struct cmdline *cl,
7750 __rte_unused void *data)
7752 struct cmd_showqueue_result *res = parsed_result;
7754 if (!strcmp(res->type, "rxq"))
7755 rx_queue_infos_display(res->portnum, res->queuenum);
7756 else if (!strcmp(res->type, "txq"))
7757 tx_queue_infos_display(res->portnum, res->queuenum);
7760 cmdline_parse_token_string_t cmd_showqueue_show =
7761 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7762 cmdline_parse_token_string_t cmd_showqueue_type =
7763 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7764 cmdline_parse_token_string_t cmd_showqueue_what =
7765 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7766 cmdline_parse_token_num_t cmd_showqueue_portnum =
7767 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7768 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7769 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7771 cmdline_parse_inst_t cmd_showqueue = {
7772 .f = cmd_showqueue_parsed,
7774 .help_str = "show rxq|txq info <port_id> <queue_id>",
7776 (void *)&cmd_showqueue_show,
7777 (void *)&cmd_showqueue_type,
7778 (void *)&cmd_showqueue_what,
7779 (void *)&cmd_showqueue_portnum,
7780 (void *)&cmd_showqueue_queuenum,
7785 /* show/clear fwd engine statistics */
7787 cmdline_fixed_string_t action;
7788 cmdline_fixed_string_t fwd;
7789 cmdline_fixed_string_t stats;
7790 cmdline_fixed_string_t all;
7793 cmdline_parse_token_string_t cmd_fwd_action =
7794 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7795 cmdline_parse_token_string_t cmd_fwd_fwd =
7796 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7797 cmdline_parse_token_string_t cmd_fwd_stats =
7798 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7799 cmdline_parse_token_string_t cmd_fwd_all =
7800 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7803 cmd_showfwdall_parsed(void *parsed_result,
7804 __rte_unused struct cmdline *cl,
7805 __rte_unused void *data)
7807 struct fwd_result *res = parsed_result;
7809 if (!strcmp(res->action, "show"))
7810 fwd_stats_display();
7815 static cmdline_parse_inst_t cmd_showfwdall = {
7816 .f = cmd_showfwdall_parsed,
7818 .help_str = "show|clear fwd stats all",
7820 (void *)&cmd_fwd_action,
7821 (void *)&cmd_fwd_fwd,
7822 (void *)&cmd_fwd_stats,
7823 (void *)&cmd_fwd_all,
7828 /* *** READ PORT REGISTER *** */
7829 struct cmd_read_reg_result {
7830 cmdline_fixed_string_t read;
7831 cmdline_fixed_string_t reg;
7837 cmd_read_reg_parsed(void *parsed_result,
7838 __rte_unused struct cmdline *cl,
7839 __rte_unused void *data)
7841 struct cmd_read_reg_result *res = parsed_result;
7842 port_reg_display(res->port_id, res->reg_off);
7845 cmdline_parse_token_string_t cmd_read_reg_read =
7846 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7847 cmdline_parse_token_string_t cmd_read_reg_reg =
7848 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7849 cmdline_parse_token_num_t cmd_read_reg_port_id =
7850 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7851 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7852 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7854 cmdline_parse_inst_t cmd_read_reg = {
7855 .f = cmd_read_reg_parsed,
7857 .help_str = "read reg <port_id> <reg_off>",
7859 (void *)&cmd_read_reg_read,
7860 (void *)&cmd_read_reg_reg,
7861 (void *)&cmd_read_reg_port_id,
7862 (void *)&cmd_read_reg_reg_off,
7867 /* *** READ PORT REGISTER BIT FIELD *** */
7868 struct cmd_read_reg_bit_field_result {
7869 cmdline_fixed_string_t read;
7870 cmdline_fixed_string_t regfield;
7878 cmd_read_reg_bit_field_parsed(void *parsed_result,
7879 __rte_unused struct cmdline *cl,
7880 __rte_unused void *data)
7882 struct cmd_read_reg_bit_field_result *res = parsed_result;
7883 port_reg_bit_field_display(res->port_id, res->reg_off,
7884 res->bit1_pos, res->bit2_pos);
7887 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7888 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7890 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7891 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7892 regfield, "regfield");
7893 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7894 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7896 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7897 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7899 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7900 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7902 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7903 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7906 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7907 .f = cmd_read_reg_bit_field_parsed,
7909 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7910 "Read register bit field between bit_x and bit_y included",
7912 (void *)&cmd_read_reg_bit_field_read,
7913 (void *)&cmd_read_reg_bit_field_regfield,
7914 (void *)&cmd_read_reg_bit_field_port_id,
7915 (void *)&cmd_read_reg_bit_field_reg_off,
7916 (void *)&cmd_read_reg_bit_field_bit1_pos,
7917 (void *)&cmd_read_reg_bit_field_bit2_pos,
7922 /* *** READ PORT REGISTER BIT *** */
7923 struct cmd_read_reg_bit_result {
7924 cmdline_fixed_string_t read;
7925 cmdline_fixed_string_t regbit;
7932 cmd_read_reg_bit_parsed(void *parsed_result,
7933 __rte_unused struct cmdline *cl,
7934 __rte_unused void *data)
7936 struct cmd_read_reg_bit_result *res = parsed_result;
7937 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7940 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7941 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7942 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7943 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7945 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7946 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7947 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7948 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7949 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7950 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7952 cmdline_parse_inst_t cmd_read_reg_bit = {
7953 .f = cmd_read_reg_bit_parsed,
7955 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7957 (void *)&cmd_read_reg_bit_read,
7958 (void *)&cmd_read_reg_bit_regbit,
7959 (void *)&cmd_read_reg_bit_port_id,
7960 (void *)&cmd_read_reg_bit_reg_off,
7961 (void *)&cmd_read_reg_bit_bit_pos,
7966 /* *** WRITE PORT REGISTER *** */
7967 struct cmd_write_reg_result {
7968 cmdline_fixed_string_t write;
7969 cmdline_fixed_string_t reg;
7976 cmd_write_reg_parsed(void *parsed_result,
7977 __rte_unused struct cmdline *cl,
7978 __rte_unused void *data)
7980 struct cmd_write_reg_result *res = parsed_result;
7981 port_reg_set(res->port_id, res->reg_off, res->value);
7984 cmdline_parse_token_string_t cmd_write_reg_write =
7985 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7986 cmdline_parse_token_string_t cmd_write_reg_reg =
7987 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7988 cmdline_parse_token_num_t cmd_write_reg_port_id =
7989 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7990 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7991 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7992 cmdline_parse_token_num_t cmd_write_reg_value =
7993 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7995 cmdline_parse_inst_t cmd_write_reg = {
7996 .f = cmd_write_reg_parsed,
7998 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8000 (void *)&cmd_write_reg_write,
8001 (void *)&cmd_write_reg_reg,
8002 (void *)&cmd_write_reg_port_id,
8003 (void *)&cmd_write_reg_reg_off,
8004 (void *)&cmd_write_reg_value,
8009 /* *** WRITE PORT REGISTER BIT FIELD *** */
8010 struct cmd_write_reg_bit_field_result {
8011 cmdline_fixed_string_t write;
8012 cmdline_fixed_string_t regfield;
8021 cmd_write_reg_bit_field_parsed(void *parsed_result,
8022 __rte_unused struct cmdline *cl,
8023 __rte_unused void *data)
8025 struct cmd_write_reg_bit_field_result *res = parsed_result;
8026 port_reg_bit_field_set(res->port_id, res->reg_off,
8027 res->bit1_pos, res->bit2_pos, res->value);
8030 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8031 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8033 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8034 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8035 regfield, "regfield");
8036 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8037 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8039 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8040 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8042 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8043 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8045 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8046 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8048 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8049 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8052 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8053 .f = cmd_write_reg_bit_field_parsed,
8055 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8057 "Set register bit field between bit_x and bit_y included",
8059 (void *)&cmd_write_reg_bit_field_write,
8060 (void *)&cmd_write_reg_bit_field_regfield,
8061 (void *)&cmd_write_reg_bit_field_port_id,
8062 (void *)&cmd_write_reg_bit_field_reg_off,
8063 (void *)&cmd_write_reg_bit_field_bit1_pos,
8064 (void *)&cmd_write_reg_bit_field_bit2_pos,
8065 (void *)&cmd_write_reg_bit_field_value,
8070 /* *** WRITE PORT REGISTER BIT *** */
8071 struct cmd_write_reg_bit_result {
8072 cmdline_fixed_string_t write;
8073 cmdline_fixed_string_t regbit;
8081 cmd_write_reg_bit_parsed(void *parsed_result,
8082 __rte_unused struct cmdline *cl,
8083 __rte_unused void *data)
8085 struct cmd_write_reg_bit_result *res = parsed_result;
8086 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8089 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8090 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8092 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8093 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8095 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8096 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
8097 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8098 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
8099 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8100 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
8101 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8102 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
8104 cmdline_parse_inst_t cmd_write_reg_bit = {
8105 .f = cmd_write_reg_bit_parsed,
8107 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8110 (void *)&cmd_write_reg_bit_write,
8111 (void *)&cmd_write_reg_bit_regbit,
8112 (void *)&cmd_write_reg_bit_port_id,
8113 (void *)&cmd_write_reg_bit_reg_off,
8114 (void *)&cmd_write_reg_bit_bit_pos,
8115 (void *)&cmd_write_reg_bit_value,
8120 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8121 struct cmd_read_rxd_txd_result {
8122 cmdline_fixed_string_t read;
8123 cmdline_fixed_string_t rxd_txd;
8130 cmd_read_rxd_txd_parsed(void *parsed_result,
8131 __rte_unused struct cmdline *cl,
8132 __rte_unused void *data)
8134 struct cmd_read_rxd_txd_result *res = parsed_result;
8136 if (!strcmp(res->rxd_txd, "rxd"))
8137 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8138 else if (!strcmp(res->rxd_txd, "txd"))
8139 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8142 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8143 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8144 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8145 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8147 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8148 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
8149 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8150 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8151 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8152 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8154 cmdline_parse_inst_t cmd_read_rxd_txd = {
8155 .f = cmd_read_rxd_txd_parsed,
8157 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8159 (void *)&cmd_read_rxd_txd_read,
8160 (void *)&cmd_read_rxd_txd_rxd_txd,
8161 (void *)&cmd_read_rxd_txd_port_id,
8162 (void *)&cmd_read_rxd_txd_queue_id,
8163 (void *)&cmd_read_rxd_txd_desc_id,
8169 struct cmd_quit_result {
8170 cmdline_fixed_string_t quit;
8173 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8175 __rte_unused void *data)
8180 cmdline_parse_token_string_t cmd_quit_quit =
8181 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8183 cmdline_parse_inst_t cmd_quit = {
8184 .f = cmd_quit_parsed,
8186 .help_str = "quit: Exit application",
8188 (void *)&cmd_quit_quit,
8193 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8194 struct cmd_mac_addr_result {
8195 cmdline_fixed_string_t mac_addr_cmd;
8196 cmdline_fixed_string_t what;
8198 struct rte_ether_addr address;
8201 static void cmd_mac_addr_parsed(void *parsed_result,
8202 __rte_unused struct cmdline *cl,
8203 __rte_unused void *data)
8205 struct cmd_mac_addr_result *res = parsed_result;
8208 if (strcmp(res->what, "add") == 0)
8209 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8210 else if (strcmp(res->what, "set") == 0)
8211 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8214 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8216 /* check the return value and print it if is < 0 */
8218 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8222 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8223 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8225 cmdline_parse_token_string_t cmd_mac_addr_what =
8226 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8228 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8229 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8231 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8232 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8234 cmdline_parse_inst_t cmd_mac_addr = {
8235 .f = cmd_mac_addr_parsed,
8237 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8238 "Add/Remove/Set MAC address on port_id",
8240 (void *)&cmd_mac_addr_cmd,
8241 (void *)&cmd_mac_addr_what,
8242 (void *)&cmd_mac_addr_portnum,
8243 (void *)&cmd_mac_addr_addr,
8248 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8249 struct cmd_eth_peer_result {
8250 cmdline_fixed_string_t set;
8251 cmdline_fixed_string_t eth_peer;
8253 cmdline_fixed_string_t peer_addr;
8256 static void cmd_set_eth_peer_parsed(void *parsed_result,
8257 __rte_unused struct cmdline *cl,
8258 __rte_unused void *data)
8260 struct cmd_eth_peer_result *res = parsed_result;
8262 if (test_done == 0) {
8263 printf("Please stop forwarding first\n");
8266 if (!strcmp(res->eth_peer, "eth-peer")) {
8267 set_fwd_eth_peer(res->port_id, res->peer_addr);
8271 cmdline_parse_token_string_t cmd_eth_peer_set =
8272 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8273 cmdline_parse_token_string_t cmd_eth_peer =
8274 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8275 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8276 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8277 cmdline_parse_token_string_t cmd_eth_peer_addr =
8278 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8280 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8281 .f = cmd_set_eth_peer_parsed,
8283 .help_str = "set eth-peer <port_id> <peer_mac>",
8285 (void *)&cmd_eth_peer_set,
8286 (void *)&cmd_eth_peer,
8287 (void *)&cmd_eth_peer_port_id,
8288 (void *)&cmd_eth_peer_addr,
8293 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8294 struct cmd_set_qmap_result {
8295 cmdline_fixed_string_t set;
8296 cmdline_fixed_string_t qmap;
8297 cmdline_fixed_string_t what;
8304 cmd_set_qmap_parsed(void *parsed_result,
8305 __rte_unused struct cmdline *cl,
8306 __rte_unused void *data)
8308 struct cmd_set_qmap_result *res = parsed_result;
8309 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8311 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8314 cmdline_parse_token_string_t cmd_setqmap_set =
8315 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8317 cmdline_parse_token_string_t cmd_setqmap_qmap =
8318 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8320 cmdline_parse_token_string_t cmd_setqmap_what =
8321 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8323 cmdline_parse_token_num_t cmd_setqmap_portid =
8324 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8326 cmdline_parse_token_num_t cmd_setqmap_queueid =
8327 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8329 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8330 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8333 cmdline_parse_inst_t cmd_set_qmap = {
8334 .f = cmd_set_qmap_parsed,
8336 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8337 "Set statistics mapping value on tx|rx queue_id of port_id",
8339 (void *)&cmd_setqmap_set,
8340 (void *)&cmd_setqmap_qmap,
8341 (void *)&cmd_setqmap_what,
8342 (void *)&cmd_setqmap_portid,
8343 (void *)&cmd_setqmap_queueid,
8344 (void *)&cmd_setqmap_mapvalue,
8349 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8350 struct cmd_set_xstats_hide_zero_result {
8351 cmdline_fixed_string_t keyword;
8352 cmdline_fixed_string_t name;
8353 cmdline_fixed_string_t on_off;
8357 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8358 __rte_unused struct cmdline *cl,
8359 __rte_unused void *data)
8361 struct cmd_set_xstats_hide_zero_result *res;
8362 uint16_t on_off = 0;
8364 res = parsed_result;
8365 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8366 set_xstats_hide_zero(on_off);
8369 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8370 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8372 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8373 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8374 name, "xstats-hide-zero");
8375 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8376 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8379 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8380 .f = cmd_set_xstats_hide_zero_parsed,
8382 .help_str = "set xstats-hide-zero on|off",
8384 (void *)&cmd_set_xstats_hide_zero_keyword,
8385 (void *)&cmd_set_xstats_hide_zero_name,
8386 (void *)&cmd_set_xstats_hide_zero_on_off,
8391 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8392 struct cmd_set_record_core_cycles_result {
8393 cmdline_fixed_string_t keyword;
8394 cmdline_fixed_string_t name;
8395 cmdline_fixed_string_t on_off;
8399 cmd_set_record_core_cycles_parsed(void *parsed_result,
8400 __rte_unused struct cmdline *cl,
8401 __rte_unused void *data)
8403 struct cmd_set_record_core_cycles_result *res;
8404 uint16_t on_off = 0;
8406 res = parsed_result;
8407 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8408 set_record_core_cycles(on_off);
8411 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8412 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8414 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8415 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8416 name, "record-core-cycles");
8417 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8418 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8421 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8422 .f = cmd_set_record_core_cycles_parsed,
8424 .help_str = "set record-core-cycles on|off",
8426 (void *)&cmd_set_record_core_cycles_keyword,
8427 (void *)&cmd_set_record_core_cycles_name,
8428 (void *)&cmd_set_record_core_cycles_on_off,
8433 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8434 struct cmd_set_record_burst_stats_result {
8435 cmdline_fixed_string_t keyword;
8436 cmdline_fixed_string_t name;
8437 cmdline_fixed_string_t on_off;
8441 cmd_set_record_burst_stats_parsed(void *parsed_result,
8442 __rte_unused struct cmdline *cl,
8443 __rte_unused void *data)
8445 struct cmd_set_record_burst_stats_result *res;
8446 uint16_t on_off = 0;
8448 res = parsed_result;
8449 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8450 set_record_burst_stats(on_off);
8453 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8454 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8456 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8457 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8458 name, "record-burst-stats");
8459 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8460 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8463 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8464 .f = cmd_set_record_burst_stats_parsed,
8466 .help_str = "set record-burst-stats on|off",
8468 (void *)&cmd_set_record_burst_stats_keyword,
8469 (void *)&cmd_set_record_burst_stats_name,
8470 (void *)&cmd_set_record_burst_stats_on_off,
8475 /* *** CONFIGURE UNICAST HASH TABLE *** */
8476 struct cmd_set_uc_hash_table {
8477 cmdline_fixed_string_t set;
8478 cmdline_fixed_string_t port;
8480 cmdline_fixed_string_t what;
8481 struct rte_ether_addr address;
8482 cmdline_fixed_string_t mode;
8486 cmd_set_uc_hash_parsed(void *parsed_result,
8487 __rte_unused struct cmdline *cl,
8488 __rte_unused void *data)
8491 struct cmd_set_uc_hash_table *res = parsed_result;
8493 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8495 if (strcmp(res->what, "uta") == 0)
8496 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8497 &res->address,(uint8_t)is_on);
8499 printf("bad unicast hash table parameter, return code = %d \n", ret);
8503 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8504 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8506 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8507 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8509 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8510 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8512 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8513 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8515 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8516 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8518 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8519 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8522 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8523 .f = cmd_set_uc_hash_parsed,
8525 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8527 (void *)&cmd_set_uc_hash_set,
8528 (void *)&cmd_set_uc_hash_port,
8529 (void *)&cmd_set_uc_hash_portid,
8530 (void *)&cmd_set_uc_hash_what,
8531 (void *)&cmd_set_uc_hash_mac,
8532 (void *)&cmd_set_uc_hash_mode,
8537 struct cmd_set_uc_all_hash_table {
8538 cmdline_fixed_string_t set;
8539 cmdline_fixed_string_t port;
8541 cmdline_fixed_string_t what;
8542 cmdline_fixed_string_t value;
8543 cmdline_fixed_string_t mode;
8547 cmd_set_uc_all_hash_parsed(void *parsed_result,
8548 __rte_unused struct cmdline *cl,
8549 __rte_unused void *data)
8552 struct cmd_set_uc_all_hash_table *res = parsed_result;
8554 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8556 if ((strcmp(res->what, "uta") == 0) &&
8557 (strcmp(res->value, "all") == 0))
8558 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8560 printf("bad unicast hash table parameter,"
8561 "return code = %d \n", ret);
8564 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8565 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8567 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8568 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8570 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8571 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8573 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8574 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8576 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8577 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8579 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8580 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8583 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8584 .f = cmd_set_uc_all_hash_parsed,
8586 .help_str = "set port <port_id> uta all on|off",
8588 (void *)&cmd_set_uc_all_hash_set,
8589 (void *)&cmd_set_uc_all_hash_port,
8590 (void *)&cmd_set_uc_all_hash_portid,
8591 (void *)&cmd_set_uc_all_hash_what,
8592 (void *)&cmd_set_uc_all_hash_value,
8593 (void *)&cmd_set_uc_all_hash_mode,
8598 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8599 struct cmd_set_vf_traffic {
8600 cmdline_fixed_string_t set;
8601 cmdline_fixed_string_t port;
8603 cmdline_fixed_string_t vf;
8605 cmdline_fixed_string_t what;
8606 cmdline_fixed_string_t mode;
8610 cmd_set_vf_traffic_parsed(void *parsed_result,
8611 __rte_unused struct cmdline *cl,
8612 __rte_unused void *data)
8614 struct cmd_set_vf_traffic *res = parsed_result;
8615 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8616 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8618 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8621 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8622 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8624 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8625 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8627 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8628 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8630 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8631 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8633 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8634 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8636 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8637 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8639 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8640 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8643 cmdline_parse_inst_t cmd_set_vf_traffic = {
8644 .f = cmd_set_vf_traffic_parsed,
8646 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8648 (void *)&cmd_setvf_traffic_set,
8649 (void *)&cmd_setvf_traffic_port,
8650 (void *)&cmd_setvf_traffic_portid,
8651 (void *)&cmd_setvf_traffic_vf,
8652 (void *)&cmd_setvf_traffic_vfid,
8653 (void *)&cmd_setvf_traffic_what,
8654 (void *)&cmd_setvf_traffic_mode,
8659 /* *** CONFIGURE VF RECEIVE MODE *** */
8660 struct cmd_set_vf_rxmode {
8661 cmdline_fixed_string_t set;
8662 cmdline_fixed_string_t port;
8664 cmdline_fixed_string_t vf;
8666 cmdline_fixed_string_t what;
8667 cmdline_fixed_string_t mode;
8668 cmdline_fixed_string_t on;
8672 cmd_set_vf_rxmode_parsed(void *parsed_result,
8673 __rte_unused struct cmdline *cl,
8674 __rte_unused void *data)
8677 uint16_t vf_rxmode = 0;
8678 struct cmd_set_vf_rxmode *res = parsed_result;
8680 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8681 if (!strcmp(res->what,"rxmode")) {
8682 if (!strcmp(res->mode, "AUPE"))
8683 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8684 else if (!strcmp(res->mode, "ROPE"))
8685 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8686 else if (!strcmp(res->mode, "BAM"))
8687 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8688 else if (!strncmp(res->mode, "MPE",3))
8689 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8692 RTE_SET_USED(is_on);
8694 #ifdef RTE_NET_IXGBE
8695 if (ret == -ENOTSUP)
8696 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8697 vf_rxmode, (uint8_t)is_on);
8700 if (ret == -ENOTSUP)
8701 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8702 vf_rxmode, (uint8_t)is_on);
8705 printf("bad VF receive mode parameter, return code = %d \n",
8709 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8710 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8712 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8713 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8715 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8716 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8718 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8719 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8721 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8722 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8724 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8725 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8727 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8728 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8729 mode, "AUPE#ROPE#BAM#MPE");
8730 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8731 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8734 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8735 .f = cmd_set_vf_rxmode_parsed,
8737 .help_str = "set port <port_id> vf <vf_id> rxmode "
8738 "AUPE|ROPE|BAM|MPE on|off",
8740 (void *)&cmd_set_vf_rxmode_set,
8741 (void *)&cmd_set_vf_rxmode_port,
8742 (void *)&cmd_set_vf_rxmode_portid,
8743 (void *)&cmd_set_vf_rxmode_vf,
8744 (void *)&cmd_set_vf_rxmode_vfid,
8745 (void *)&cmd_set_vf_rxmode_what,
8746 (void *)&cmd_set_vf_rxmode_mode,
8747 (void *)&cmd_set_vf_rxmode_on,
8752 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8753 struct cmd_vf_mac_addr_result {
8754 cmdline_fixed_string_t mac_addr_cmd;
8755 cmdline_fixed_string_t what;
8756 cmdline_fixed_string_t port;
8758 cmdline_fixed_string_t vf;
8760 struct rte_ether_addr address;
8763 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8764 __rte_unused struct cmdline *cl,
8765 __rte_unused void *data)
8767 struct cmd_vf_mac_addr_result *res = parsed_result;
8770 if (strcmp(res->what, "add") != 0)
8774 if (ret == -ENOTSUP)
8775 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8779 if (ret == -ENOTSUP)
8780 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8785 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8789 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8790 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8791 mac_addr_cmd,"mac_addr");
8792 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8793 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8795 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8796 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8798 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8799 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8801 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8802 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8804 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8805 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8807 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8808 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8811 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8812 .f = cmd_vf_mac_addr_parsed,
8814 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8815 "Add MAC address filtering for a VF on port_id",
8817 (void *)&cmd_vf_mac_addr_cmd,
8818 (void *)&cmd_vf_mac_addr_what,
8819 (void *)&cmd_vf_mac_addr_port,
8820 (void *)&cmd_vf_mac_addr_portnum,
8821 (void *)&cmd_vf_mac_addr_vf,
8822 (void *)&cmd_vf_mac_addr_vfnum,
8823 (void *)&cmd_vf_mac_addr_addr,
8828 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8829 struct cmd_vf_rx_vlan_filter {
8830 cmdline_fixed_string_t rx_vlan;
8831 cmdline_fixed_string_t what;
8833 cmdline_fixed_string_t port;
8835 cmdline_fixed_string_t vf;
8840 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8841 __rte_unused struct cmdline *cl,
8842 __rte_unused void *data)
8844 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8847 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8849 #ifdef RTE_NET_IXGBE
8850 if (ret == -ENOTSUP)
8851 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8852 res->vlan_id, res->vf_mask, is_add);
8855 if (ret == -ENOTSUP)
8856 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8857 res->vlan_id, res->vf_mask, is_add);
8860 if (ret == -ENOTSUP)
8861 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8862 res->vlan_id, res->vf_mask, is_add);
8869 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8870 res->vlan_id, res->vf_mask);
8873 printf("invalid port_id %d\n", res->port_id);
8876 printf("function not implemented or supported\n");
8879 printf("programming error: (%s)\n", strerror(-ret));
8883 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8884 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8885 rx_vlan, "rx_vlan");
8886 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8887 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8889 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8890 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8892 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8893 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8895 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8896 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8898 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8899 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8901 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8902 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8905 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8906 .f = cmd_vf_rx_vlan_filter_parsed,
8908 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8909 "(vf_mask = hexadecimal VF mask)",
8911 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8912 (void *)&cmd_vf_rx_vlan_filter_what,
8913 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8914 (void *)&cmd_vf_rx_vlan_filter_port,
8915 (void *)&cmd_vf_rx_vlan_filter_portid,
8916 (void *)&cmd_vf_rx_vlan_filter_vf,
8917 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8922 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8923 struct cmd_queue_rate_limit_result {
8924 cmdline_fixed_string_t set;
8925 cmdline_fixed_string_t port;
8927 cmdline_fixed_string_t queue;
8929 cmdline_fixed_string_t rate;
8933 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8934 __rte_unused struct cmdline *cl,
8935 __rte_unused void *data)
8937 struct cmd_queue_rate_limit_result *res = parsed_result;
8940 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8941 && (strcmp(res->queue, "queue") == 0)
8942 && (strcmp(res->rate, "rate") == 0))
8943 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8946 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8950 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8951 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8953 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8954 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8956 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8957 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8959 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8960 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8962 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8963 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8965 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8966 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8968 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8969 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8972 cmdline_parse_inst_t cmd_queue_rate_limit = {
8973 .f = cmd_queue_rate_limit_parsed,
8975 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8976 "Set rate limit for a queue on port_id",
8978 (void *)&cmd_queue_rate_limit_set,
8979 (void *)&cmd_queue_rate_limit_port,
8980 (void *)&cmd_queue_rate_limit_portnum,
8981 (void *)&cmd_queue_rate_limit_queue,
8982 (void *)&cmd_queue_rate_limit_queuenum,
8983 (void *)&cmd_queue_rate_limit_rate,
8984 (void *)&cmd_queue_rate_limit_ratenum,
8989 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8990 struct cmd_vf_rate_limit_result {
8991 cmdline_fixed_string_t set;
8992 cmdline_fixed_string_t port;
8994 cmdline_fixed_string_t vf;
8996 cmdline_fixed_string_t rate;
8998 cmdline_fixed_string_t q_msk;
9002 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9003 __rte_unused struct cmdline *cl,
9004 __rte_unused void *data)
9006 struct cmd_vf_rate_limit_result *res = parsed_result;
9009 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9010 && (strcmp(res->vf, "vf") == 0)
9011 && (strcmp(res->rate, "rate") == 0)
9012 && (strcmp(res->q_msk, "queue_mask") == 0))
9013 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9014 res->rate_num, res->q_msk_val);
9016 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9020 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9021 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9023 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9024 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9026 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9027 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9029 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9030 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9032 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9033 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9035 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9036 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9038 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9039 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9041 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9042 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9043 q_msk, "queue_mask");
9044 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9045 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9048 cmdline_parse_inst_t cmd_vf_rate_limit = {
9049 .f = cmd_vf_rate_limit_parsed,
9051 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9052 "queue_mask <queue_mask_value>: "
9053 "Set rate limit for queues of VF on port_id",
9055 (void *)&cmd_vf_rate_limit_set,
9056 (void *)&cmd_vf_rate_limit_port,
9057 (void *)&cmd_vf_rate_limit_portnum,
9058 (void *)&cmd_vf_rate_limit_vf,
9059 (void *)&cmd_vf_rate_limit_vfnum,
9060 (void *)&cmd_vf_rate_limit_rate,
9061 (void *)&cmd_vf_rate_limit_ratenum,
9062 (void *)&cmd_vf_rate_limit_q_msk,
9063 (void *)&cmd_vf_rate_limit_q_msk_val,
9068 /* *** CONFIGURE TUNNEL UDP PORT *** */
9069 struct cmd_tunnel_udp_config {
9070 cmdline_fixed_string_t cmd;
9071 cmdline_fixed_string_t what;
9077 cmd_tunnel_udp_config_parsed(void *parsed_result,
9078 __rte_unused struct cmdline *cl,
9079 __rte_unused void *data)
9081 struct cmd_tunnel_udp_config *res = parsed_result;
9082 struct rte_eth_udp_tunnel tunnel_udp;
9085 tunnel_udp.udp_port = res->udp_port;
9087 if (!strcmp(res->cmd, "rx_vxlan_port"))
9088 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9090 if (!strcmp(res->what, "add"))
9091 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9094 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9098 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9101 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9102 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9103 cmd, "rx_vxlan_port");
9104 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9105 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9107 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9108 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9110 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9111 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9114 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9115 .f = cmd_tunnel_udp_config_parsed,
9117 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9118 "Add/Remove a tunneling UDP port filter",
9120 (void *)&cmd_tunnel_udp_config_cmd,
9121 (void *)&cmd_tunnel_udp_config_what,
9122 (void *)&cmd_tunnel_udp_config_udp_port,
9123 (void *)&cmd_tunnel_udp_config_port_id,
9128 struct cmd_config_tunnel_udp_port {
9129 cmdline_fixed_string_t port;
9130 cmdline_fixed_string_t config;
9132 cmdline_fixed_string_t udp_tunnel_port;
9133 cmdline_fixed_string_t action;
9134 cmdline_fixed_string_t tunnel_type;
9139 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9140 __rte_unused struct cmdline *cl,
9141 __rte_unused void *data)
9143 struct cmd_config_tunnel_udp_port *res = parsed_result;
9144 struct rte_eth_udp_tunnel tunnel_udp;
9147 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9150 tunnel_udp.udp_port = res->udp_port;
9152 if (!strcmp(res->tunnel_type, "vxlan")) {
9153 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9154 } else if (!strcmp(res->tunnel_type, "geneve")) {
9155 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9156 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9157 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9159 printf("Invalid tunnel type\n");
9163 if (!strcmp(res->action, "add"))
9164 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9167 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9171 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9174 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9175 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9177 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9178 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9180 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9181 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9183 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9184 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9187 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9188 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9190 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9191 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9192 "vxlan#geneve#vxlan-gpe");
9193 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9194 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9197 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9198 .f = cmd_cfg_tunnel_udp_port_parsed,
9200 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9202 (void *)&cmd_config_tunnel_udp_port_port,
9203 (void *)&cmd_config_tunnel_udp_port_config,
9204 (void *)&cmd_config_tunnel_udp_port_port_id,
9205 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9206 (void *)&cmd_config_tunnel_udp_port_action,
9207 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9208 (void *)&cmd_config_tunnel_udp_port_value,
9213 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9214 struct cmd_set_mirror_mask_result {
9215 cmdline_fixed_string_t set;
9216 cmdline_fixed_string_t port;
9218 cmdline_fixed_string_t mirror;
9220 cmdline_fixed_string_t what;
9221 cmdline_fixed_string_t value;
9222 cmdline_fixed_string_t dstpool;
9224 cmdline_fixed_string_t on;
9227 cmdline_parse_token_string_t cmd_mirror_mask_set =
9228 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9230 cmdline_parse_token_string_t cmd_mirror_mask_port =
9231 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9233 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9234 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9236 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9237 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9238 mirror, "mirror-rule");
9239 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9240 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9242 cmdline_parse_token_string_t cmd_mirror_mask_what =
9243 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9244 what, "pool-mirror-up#pool-mirror-down"
9246 cmdline_parse_token_string_t cmd_mirror_mask_value =
9247 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9249 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9250 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9251 dstpool, "dst-pool");
9252 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9253 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9255 cmdline_parse_token_string_t cmd_mirror_mask_on =
9256 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9260 cmd_set_mirror_mask_parsed(void *parsed_result,
9261 __rte_unused struct cmdline *cl,
9262 __rte_unused void *data)
9265 struct cmd_set_mirror_mask_result *res = parsed_result;
9266 struct rte_eth_mirror_conf mr_conf;
9268 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9270 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9272 mr_conf.dst_pool = res->dstpool_id;
9274 if (!strcmp(res->what, "pool-mirror-up")) {
9275 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9276 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9277 } else if (!strcmp(res->what, "pool-mirror-down")) {
9278 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9279 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9280 } else if (!strcmp(res->what, "vlan-mirror")) {
9281 mr_conf.rule_type = ETH_MIRROR_VLAN;
9282 nb_item = parse_item_list(res->value, "vlan",
9283 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9287 for (i = 0; i < nb_item; i++) {
9288 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9289 printf("Invalid vlan_id: must be < 4096\n");
9293 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9294 mr_conf.vlan.vlan_mask |= 1ULL << i;
9298 if (!strcmp(res->on, "on"))
9299 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9302 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9305 printf("mirror rule add error: (%s)\n", strerror(-ret));
9308 cmdline_parse_inst_t cmd_set_mirror_mask = {
9309 .f = cmd_set_mirror_mask_parsed,
9311 .help_str = "set port <port_id> mirror-rule <rule_id> "
9312 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9313 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9315 (void *)&cmd_mirror_mask_set,
9316 (void *)&cmd_mirror_mask_port,
9317 (void *)&cmd_mirror_mask_portid,
9318 (void *)&cmd_mirror_mask_mirror,
9319 (void *)&cmd_mirror_mask_ruleid,
9320 (void *)&cmd_mirror_mask_what,
9321 (void *)&cmd_mirror_mask_value,
9322 (void *)&cmd_mirror_mask_dstpool,
9323 (void *)&cmd_mirror_mask_poolid,
9324 (void *)&cmd_mirror_mask_on,
9329 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9330 struct cmd_set_mirror_link_result {
9331 cmdline_fixed_string_t set;
9332 cmdline_fixed_string_t port;
9334 cmdline_fixed_string_t mirror;
9336 cmdline_fixed_string_t what;
9337 cmdline_fixed_string_t dstpool;
9339 cmdline_fixed_string_t on;
9342 cmdline_parse_token_string_t cmd_mirror_link_set =
9343 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9345 cmdline_parse_token_string_t cmd_mirror_link_port =
9346 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9348 cmdline_parse_token_num_t cmd_mirror_link_portid =
9349 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9351 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9352 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9353 mirror, "mirror-rule");
9354 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9355 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9357 cmdline_parse_token_string_t cmd_mirror_link_what =
9358 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9359 what, "uplink-mirror#downlink-mirror");
9360 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9361 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9362 dstpool, "dst-pool");
9363 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9364 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9366 cmdline_parse_token_string_t cmd_mirror_link_on =
9367 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9371 cmd_set_mirror_link_parsed(void *parsed_result,
9372 __rte_unused struct cmdline *cl,
9373 __rte_unused void *data)
9376 struct cmd_set_mirror_link_result *res = parsed_result;
9377 struct rte_eth_mirror_conf mr_conf;
9379 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9380 if (!strcmp(res->what, "uplink-mirror"))
9381 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9383 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9385 mr_conf.dst_pool = res->dstpool_id;
9387 if (!strcmp(res->on, "on"))
9388 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9391 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9394 /* check the return value and print it if is < 0 */
9396 printf("mirror rule add error: (%s)\n", strerror(-ret));
9400 cmdline_parse_inst_t cmd_set_mirror_link = {
9401 .f = cmd_set_mirror_link_parsed,
9403 .help_str = "set port <port_id> mirror-rule <rule_id> "
9404 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9406 (void *)&cmd_mirror_link_set,
9407 (void *)&cmd_mirror_link_port,
9408 (void *)&cmd_mirror_link_portid,
9409 (void *)&cmd_mirror_link_mirror,
9410 (void *)&cmd_mirror_link_ruleid,
9411 (void *)&cmd_mirror_link_what,
9412 (void *)&cmd_mirror_link_dstpool,
9413 (void *)&cmd_mirror_link_poolid,
9414 (void *)&cmd_mirror_link_on,
9419 /* *** RESET VM MIRROR RULE *** */
9420 struct cmd_rm_mirror_rule_result {
9421 cmdline_fixed_string_t reset;
9422 cmdline_fixed_string_t port;
9424 cmdline_fixed_string_t mirror;
9428 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9429 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9431 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9432 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9434 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9435 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9437 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9438 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9439 mirror, "mirror-rule");
9440 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9441 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9445 cmd_reset_mirror_rule_parsed(void *parsed_result,
9446 __rte_unused struct cmdline *cl,
9447 __rte_unused void *data)
9450 struct cmd_set_mirror_link_result *res = parsed_result;
9452 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9454 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9457 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9458 .f = cmd_reset_mirror_rule_parsed,
9460 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9462 (void *)&cmd_rm_mirror_rule_reset,
9463 (void *)&cmd_rm_mirror_rule_port,
9464 (void *)&cmd_rm_mirror_rule_portid,
9465 (void *)&cmd_rm_mirror_rule_mirror,
9466 (void *)&cmd_rm_mirror_rule_ruleid,
9471 /* ******************************************************************************** */
9473 struct cmd_dump_result {
9474 cmdline_fixed_string_t dump;
9478 dump_struct_sizes(void)
9480 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9481 DUMP_SIZE(struct rte_mbuf);
9482 DUMP_SIZE(struct rte_mempool);
9483 DUMP_SIZE(struct rte_ring);
9488 /* Dump the socket memory statistics on console */
9490 dump_socket_mem(FILE *f)
9492 struct rte_malloc_socket_stats socket_stats;
9497 unsigned int n_alloc = 0;
9498 unsigned int n_free = 0;
9499 static size_t last_allocs;
9500 static size_t last_total;
9503 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9504 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9505 !socket_stats.heap_totalsz_bytes)
9507 total += socket_stats.heap_totalsz_bytes;
9508 alloc += socket_stats.heap_allocsz_bytes;
9509 free += socket_stats.heap_freesz_bytes;
9510 n_alloc += socket_stats.alloc_count;
9511 n_free += socket_stats.free_count;
9513 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9515 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9516 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9517 (double)socket_stats.heap_allocsz_bytes * 100 /
9518 (double)socket_stats.heap_totalsz_bytes,
9519 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9520 socket_stats.alloc_count,
9521 socket_stats.free_count);
9524 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9525 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9526 (double)alloc * 100 / (double)total,
9527 (double)free / (1024 * 1024),
9530 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9531 ((double)total - (double)last_total) / (1024 * 1024),
9532 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9533 last_allocs = alloc;
9537 static void cmd_dump_parsed(void *parsed_result,
9538 __rte_unused struct cmdline *cl,
9539 __rte_unused void *data)
9541 struct cmd_dump_result *res = parsed_result;
9543 if (!strcmp(res->dump, "dump_physmem"))
9544 rte_dump_physmem_layout(stdout);
9545 else if (!strcmp(res->dump, "dump_socket_mem"))
9546 dump_socket_mem(stdout);
9547 else if (!strcmp(res->dump, "dump_memzone"))
9548 rte_memzone_dump(stdout);
9549 else if (!strcmp(res->dump, "dump_struct_sizes"))
9550 dump_struct_sizes();
9551 else if (!strcmp(res->dump, "dump_ring"))
9552 rte_ring_list_dump(stdout);
9553 else if (!strcmp(res->dump, "dump_mempool"))
9554 rte_mempool_list_dump(stdout);
9555 else if (!strcmp(res->dump, "dump_devargs"))
9556 rte_devargs_dump(stdout);
9557 else if (!strcmp(res->dump, "dump_log_types"))
9558 rte_log_dump(stdout);
9561 cmdline_parse_token_string_t cmd_dump_dump =
9562 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9566 "dump_struct_sizes#"
9572 cmdline_parse_inst_t cmd_dump = {
9573 .f = cmd_dump_parsed, /* function to call */
9574 .data = NULL, /* 2nd arg of func */
9575 .help_str = "Dump status",
9576 .tokens = { /* token list, NULL terminated */
9577 (void *)&cmd_dump_dump,
9582 /* ******************************************************************************** */
9584 struct cmd_dump_one_result {
9585 cmdline_fixed_string_t dump;
9586 cmdline_fixed_string_t name;
9589 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9590 __rte_unused void *data)
9592 struct cmd_dump_one_result *res = parsed_result;
9594 if (!strcmp(res->dump, "dump_ring")) {
9596 r = rte_ring_lookup(res->name);
9598 cmdline_printf(cl, "Cannot find ring\n");
9601 rte_ring_dump(stdout, r);
9602 } else if (!strcmp(res->dump, "dump_mempool")) {
9603 struct rte_mempool *mp;
9604 mp = rte_mempool_lookup(res->name);
9606 cmdline_printf(cl, "Cannot find mempool\n");
9609 rte_mempool_dump(stdout, mp);
9613 cmdline_parse_token_string_t cmd_dump_one_dump =
9614 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9615 "dump_ring#dump_mempool");
9617 cmdline_parse_token_string_t cmd_dump_one_name =
9618 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9620 cmdline_parse_inst_t cmd_dump_one = {
9621 .f = cmd_dump_one_parsed, /* function to call */
9622 .data = NULL, /* 2nd arg of func */
9623 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9624 .tokens = { /* token list, NULL terminated */
9625 (void *)&cmd_dump_one_dump,
9626 (void *)&cmd_dump_one_name,
9631 /* *** queue region set *** */
9632 struct cmd_queue_region_result {
9633 cmdline_fixed_string_t set;
9634 cmdline_fixed_string_t port;
9636 cmdline_fixed_string_t cmd;
9637 cmdline_fixed_string_t region;
9639 cmdline_fixed_string_t queue_start_index;
9641 cmdline_fixed_string_t queue_num;
9642 uint8_t queue_num_value;
9646 cmd_queue_region_parsed(void *parsed_result,
9647 __rte_unused struct cmdline *cl,
9648 __rte_unused void *data)
9650 struct cmd_queue_region_result *res = parsed_result;
9653 struct rte_pmd_i40e_queue_region_conf region_conf;
9654 enum rte_pmd_i40e_queue_region_op op_type;
9657 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9661 memset(®ion_conf, 0, sizeof(region_conf));
9662 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9663 region_conf.region_id = res->region_id;
9664 region_conf.queue_num = res->queue_num_value;
9665 region_conf.queue_start_index = res->queue_id;
9667 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9668 op_type, ®ion_conf);
9675 printf("function not implemented or supported\n");
9678 printf("queue region config error: (%s)\n", strerror(-ret));
9682 cmdline_parse_token_string_t cmd_queue_region_set =
9683 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9685 cmdline_parse_token_string_t cmd_queue_region_port =
9686 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9687 cmdline_parse_token_num_t cmd_queue_region_port_id =
9688 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9690 cmdline_parse_token_string_t cmd_queue_region_cmd =
9691 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9692 cmd, "queue-region");
9693 cmdline_parse_token_string_t cmd_queue_region_id =
9694 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9695 region, "region_id");
9696 cmdline_parse_token_num_t cmd_queue_region_index =
9697 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9699 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9700 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9701 queue_start_index, "queue_start_index");
9702 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9703 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9705 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9706 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9707 queue_num, "queue_num");
9708 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9709 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9710 queue_num_value, UINT8);
9712 cmdline_parse_inst_t cmd_queue_region = {
9713 .f = cmd_queue_region_parsed,
9715 .help_str = "set port <port_id> queue-region region_id <value> "
9716 "queue_start_index <value> queue_num <value>: Set a queue region",
9718 (void *)&cmd_queue_region_set,
9719 (void *)&cmd_queue_region_port,
9720 (void *)&cmd_queue_region_port_id,
9721 (void *)&cmd_queue_region_cmd,
9722 (void *)&cmd_queue_region_id,
9723 (void *)&cmd_queue_region_index,
9724 (void *)&cmd_queue_region_queue_start_index,
9725 (void *)&cmd_queue_region_queue_id,
9726 (void *)&cmd_queue_region_queue_num,
9727 (void *)&cmd_queue_region_queue_num_value,
9732 /* *** queue region and flowtype set *** */
9733 struct cmd_region_flowtype_result {
9734 cmdline_fixed_string_t set;
9735 cmdline_fixed_string_t port;
9737 cmdline_fixed_string_t cmd;
9738 cmdline_fixed_string_t region;
9740 cmdline_fixed_string_t flowtype;
9741 uint8_t flowtype_id;
9745 cmd_region_flowtype_parsed(void *parsed_result,
9746 __rte_unused struct cmdline *cl,
9747 __rte_unused void *data)
9749 struct cmd_region_flowtype_result *res = parsed_result;
9752 struct rte_pmd_i40e_queue_region_conf region_conf;
9753 enum rte_pmd_i40e_queue_region_op op_type;
9756 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9760 memset(®ion_conf, 0, sizeof(region_conf));
9762 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9763 region_conf.region_id = res->region_id;
9764 region_conf.hw_flowtype = res->flowtype_id;
9766 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9767 op_type, ®ion_conf);
9774 printf("function not implemented or supported\n");
9777 printf("region flowtype config error: (%s)\n", strerror(-ret));
9781 cmdline_parse_token_string_t cmd_region_flowtype_set =
9782 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9784 cmdline_parse_token_string_t cmd_region_flowtype_port =
9785 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9787 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9788 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9790 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9791 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9792 cmd, "queue-region");
9793 cmdline_parse_token_string_t cmd_region_flowtype_index =
9794 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9795 region, "region_id");
9796 cmdline_parse_token_num_t cmd_region_flowtype_id =
9797 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9799 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9800 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9801 flowtype, "flowtype");
9802 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9803 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9804 flowtype_id, UINT8);
9805 cmdline_parse_inst_t cmd_region_flowtype = {
9806 .f = cmd_region_flowtype_parsed,
9808 .help_str = "set port <port_id> queue-region region_id <value> "
9809 "flowtype <value>: Set a flowtype region index",
9811 (void *)&cmd_region_flowtype_set,
9812 (void *)&cmd_region_flowtype_port,
9813 (void *)&cmd_region_flowtype_port_index,
9814 (void *)&cmd_region_flowtype_cmd,
9815 (void *)&cmd_region_flowtype_index,
9816 (void *)&cmd_region_flowtype_id,
9817 (void *)&cmd_region_flowtype_flow_index,
9818 (void *)&cmd_region_flowtype_flow_id,
9823 /* *** User Priority (UP) to queue region (region_id) set *** */
9824 struct cmd_user_priority_region_result {
9825 cmdline_fixed_string_t set;
9826 cmdline_fixed_string_t port;
9828 cmdline_fixed_string_t cmd;
9829 cmdline_fixed_string_t user_priority;
9830 uint8_t user_priority_id;
9831 cmdline_fixed_string_t region;
9836 cmd_user_priority_region_parsed(void *parsed_result,
9837 __rte_unused struct cmdline *cl,
9838 __rte_unused void *data)
9840 struct cmd_user_priority_region_result *res = parsed_result;
9843 struct rte_pmd_i40e_queue_region_conf region_conf;
9844 enum rte_pmd_i40e_queue_region_op op_type;
9847 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9851 memset(®ion_conf, 0, sizeof(region_conf));
9852 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9853 region_conf.user_priority = res->user_priority_id;
9854 region_conf.region_id = res->region_id;
9856 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9857 op_type, ®ion_conf);
9864 printf("function not implemented or supported\n");
9867 printf("user_priority region config error: (%s)\n",
9872 cmdline_parse_token_string_t cmd_user_priority_region_set =
9873 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9875 cmdline_parse_token_string_t cmd_user_priority_region_port =
9876 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9878 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9879 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9881 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9882 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9883 cmd, "queue-region");
9884 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9885 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9886 user_priority, "UP");
9887 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9888 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9889 user_priority_id, UINT8);
9890 cmdline_parse_token_string_t cmd_user_priority_region_region =
9891 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9892 region, "region_id");
9893 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9894 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9897 cmdline_parse_inst_t cmd_user_priority_region = {
9898 .f = cmd_user_priority_region_parsed,
9900 .help_str = "set port <port_id> queue-region UP <value> "
9901 "region_id <value>: Set the mapping of User Priority (UP) "
9902 "to queue region (region_id) ",
9904 (void *)&cmd_user_priority_region_set,
9905 (void *)&cmd_user_priority_region_port,
9906 (void *)&cmd_user_priority_region_port_index,
9907 (void *)&cmd_user_priority_region_cmd,
9908 (void *)&cmd_user_priority_region_UP,
9909 (void *)&cmd_user_priority_region_UP_id,
9910 (void *)&cmd_user_priority_region_region,
9911 (void *)&cmd_user_priority_region_region_id,
9916 /* *** flush all queue region related configuration *** */
9917 struct cmd_flush_queue_region_result {
9918 cmdline_fixed_string_t set;
9919 cmdline_fixed_string_t port;
9921 cmdline_fixed_string_t cmd;
9922 cmdline_fixed_string_t flush;
9923 cmdline_fixed_string_t what;
9927 cmd_flush_queue_region_parsed(void *parsed_result,
9928 __rte_unused struct cmdline *cl,
9929 __rte_unused void *data)
9931 struct cmd_flush_queue_region_result *res = parsed_result;
9934 struct rte_pmd_i40e_queue_region_conf region_conf;
9935 enum rte_pmd_i40e_queue_region_op op_type;
9938 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9942 memset(®ion_conf, 0, sizeof(region_conf));
9944 if (strcmp(res->what, "on") == 0)
9945 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9947 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9949 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9950 op_type, ®ion_conf);
9957 printf("function not implemented or supported\n");
9960 printf("queue region config flush error: (%s)\n",
9965 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9966 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9968 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9969 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9971 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9972 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9974 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9975 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9976 cmd, "queue-region");
9977 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9978 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9980 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9981 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9984 cmdline_parse_inst_t cmd_flush_queue_region = {
9985 .f = cmd_flush_queue_region_parsed,
9987 .help_str = "set port <port_id> queue-region flush on|off"
9988 ": flush all queue region related configuration",
9990 (void *)&cmd_flush_queue_region_set,
9991 (void *)&cmd_flush_queue_region_port,
9992 (void *)&cmd_flush_queue_region_port_index,
9993 (void *)&cmd_flush_queue_region_cmd,
9994 (void *)&cmd_flush_queue_region_flush,
9995 (void *)&cmd_flush_queue_region_what,
10000 /* *** get all queue region related configuration info *** */
10001 struct cmd_show_queue_region_info {
10002 cmdline_fixed_string_t show;
10003 cmdline_fixed_string_t port;
10005 cmdline_fixed_string_t cmd;
10009 cmd_show_queue_region_info_parsed(void *parsed_result,
10010 __rte_unused struct cmdline *cl,
10011 __rte_unused void *data)
10013 struct cmd_show_queue_region_info *res = parsed_result;
10014 int ret = -ENOTSUP;
10015 #ifdef RTE_NET_I40E
10016 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10017 enum rte_pmd_i40e_queue_region_op op_type;
10020 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10023 #ifdef RTE_NET_I40E
10024 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10026 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10028 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10029 op_type, &rte_pmd_regions);
10031 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10038 printf("function not implemented or supported\n");
10041 printf("queue region config info show error: (%s)\n",
10046 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10047 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10049 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10050 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10052 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10053 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10055 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10056 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10057 cmd, "queue-region");
10059 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10060 .f = cmd_show_queue_region_info_parsed,
10062 .help_str = "show port <port_id> queue-region"
10063 ": show all queue region related configuration info",
10065 (void *)&cmd_show_queue_region_info_get,
10066 (void *)&cmd_show_queue_region_info_port,
10067 (void *)&cmd_show_queue_region_info_port_index,
10068 (void *)&cmd_show_queue_region_info_cmd,
10073 /* *** Filters Control *** */
10076 str2flowtype(char *string)
10079 static const struct {
10082 } flowtype_str[] = {
10083 {"raw", RTE_ETH_FLOW_RAW},
10084 {"ipv4", RTE_ETH_FLOW_IPV4},
10085 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10086 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10087 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10088 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10089 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10090 {"ipv6", RTE_ETH_FLOW_IPV6},
10091 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10092 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10093 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10094 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10095 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10096 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10099 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10100 if (!strcmp(flowtype_str[i].str, string))
10101 return flowtype_str[i].type;
10104 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10105 return (uint16_t)atoi(string);
10107 return RTE_ETH_FLOW_UNKNOWN;
10110 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10112 if ((ip_addr).family == AF_INET) \
10113 (ip) = (ip_addr).addr.ipv4.s_addr; \
10115 printf("invalid parameter.\n"); \
10120 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10122 if ((ip_addr).family == AF_INET6) \
10123 rte_memcpy(&(ip), \
10124 &((ip_addr).addr.ipv6), \
10125 sizeof(struct in6_addr)); \
10127 printf("invalid parameter.\n"); \
10132 #ifdef RTE_NET_I40E
10134 /* *** deal with flow director filter *** */
10135 struct cmd_flow_director_result {
10136 cmdline_fixed_string_t flow_director_filter;
10138 cmdline_fixed_string_t mode;
10139 cmdline_fixed_string_t mode_value;
10140 cmdline_fixed_string_t ops;
10141 cmdline_fixed_string_t flow;
10142 cmdline_fixed_string_t flow_type;
10143 cmdline_fixed_string_t drop;
10144 cmdline_fixed_string_t queue;
10146 cmdline_fixed_string_t fd_id;
10147 uint32_t fd_id_value;
10148 cmdline_fixed_string_t packet;
10153 cmd_flow_director_filter_parsed(void *parsed_result,
10154 __rte_unused struct cmdline *cl,
10155 __rte_unused void *data)
10157 struct cmd_flow_director_result *res = parsed_result;
10159 struct rte_pmd_i40e_flow_type_mapping
10160 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10161 struct rte_pmd_i40e_pkt_template_conf conf;
10162 uint16_t flow_type = str2flowtype(res->flow_type);
10163 uint16_t i, port = res->port_id;
10166 memset(&conf, 0, sizeof(conf));
10168 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10169 printf("Invalid flow type specified.\n");
10172 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10176 if (mapping[flow_type].pctype == 0ULL) {
10177 printf("Invalid flow type specified.\n");
10180 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10181 if (mapping[flow_type].pctype & (1ULL << i)) {
10182 conf.input.pctype = i;
10187 conf.input.packet = open_file(res->filepath,
10188 &conf.input.length);
10189 if (!conf.input.packet)
10191 if (!strcmp(res->drop, "drop"))
10192 conf.action.behavior =
10193 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10195 conf.action.behavior =
10196 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10197 conf.action.report_status =
10198 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10199 conf.action.rx_queue = res->queue_id;
10200 conf.soft_id = res->fd_id_value;
10201 add = strcmp(res->ops, "del") ? 1 : 0;
10202 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10206 printf("flow director config error: (%s)\n",
10208 close_file(conf.input.packet);
10211 cmdline_parse_token_string_t cmd_flow_director_filter =
10212 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10213 flow_director_filter, "flow_director_filter");
10214 cmdline_parse_token_num_t cmd_flow_director_port_id =
10215 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10217 cmdline_parse_token_string_t cmd_flow_director_ops =
10218 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10219 ops, "add#del#update");
10220 cmdline_parse_token_string_t cmd_flow_director_flow =
10221 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10223 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10224 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10226 cmdline_parse_token_string_t cmd_flow_director_drop =
10227 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10229 cmdline_parse_token_string_t cmd_flow_director_queue =
10230 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10232 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10233 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10235 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10236 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10238 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10239 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10240 fd_id_value, UINT32);
10242 cmdline_parse_token_string_t cmd_flow_director_mode =
10243 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10245 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10246 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10247 mode_value, "raw");
10248 cmdline_parse_token_string_t cmd_flow_director_packet =
10249 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10251 cmdline_parse_token_string_t cmd_flow_director_filepath =
10252 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10255 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10256 .f = cmd_flow_director_filter_parsed,
10258 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10259 "director entry on NIC",
10261 (void *)&cmd_flow_director_filter,
10262 (void *)&cmd_flow_director_port_id,
10263 (void *)&cmd_flow_director_mode,
10264 (void *)&cmd_flow_director_mode_raw,
10265 (void *)&cmd_flow_director_ops,
10266 (void *)&cmd_flow_director_flow,
10267 (void *)&cmd_flow_director_flow_type,
10268 (void *)&cmd_flow_director_drop,
10269 (void *)&cmd_flow_director_queue,
10270 (void *)&cmd_flow_director_queue_id,
10271 (void *)&cmd_flow_director_fd_id,
10272 (void *)&cmd_flow_director_fd_id_value,
10273 (void *)&cmd_flow_director_packet,
10274 (void *)&cmd_flow_director_filepath,
10279 #endif /* RTE_NET_I40E */
10281 /* *** deal with flow director mask *** */
10282 struct cmd_flow_director_mask_result {
10283 cmdline_fixed_string_t flow_director_mask;
10285 cmdline_fixed_string_t mode;
10286 cmdline_fixed_string_t mode_value;
10287 cmdline_fixed_string_t vlan;
10288 uint16_t vlan_mask;
10289 cmdline_fixed_string_t src_mask;
10290 cmdline_ipaddr_t ipv4_src;
10291 cmdline_ipaddr_t ipv6_src;
10293 cmdline_fixed_string_t dst_mask;
10294 cmdline_ipaddr_t ipv4_dst;
10295 cmdline_ipaddr_t ipv6_dst;
10297 cmdline_fixed_string_t mac;
10298 uint8_t mac_addr_byte_mask;
10299 cmdline_fixed_string_t tunnel_id;
10300 uint32_t tunnel_id_mask;
10301 cmdline_fixed_string_t tunnel_type;
10302 uint8_t tunnel_type_mask;
10306 cmd_flow_director_mask_parsed(void *parsed_result,
10307 __rte_unused struct cmdline *cl,
10308 __rte_unused void *data)
10310 struct cmd_flow_director_mask_result *res = parsed_result;
10311 struct rte_eth_fdir_masks *mask;
10312 struct rte_port *port;
10314 port = &ports[res->port_id];
10315 /** Check if the port is not started **/
10316 if (port->port_status != RTE_PORT_STOPPED) {
10317 printf("Please stop port %d first\n", res->port_id);
10321 mask = &port->dev_conf.fdir_conf.mask;
10323 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10324 if (strcmp(res->mode_value, "MAC-VLAN")) {
10325 printf("Please set mode to MAC-VLAN.\n");
10329 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10330 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10331 if (strcmp(res->mode_value, "Tunnel")) {
10332 printf("Please set mode to Tunnel.\n");
10336 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10337 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10338 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10339 mask->tunnel_type_mask = res->tunnel_type_mask;
10341 if (strcmp(res->mode_value, "IP")) {
10342 printf("Please set mode to IP.\n");
10346 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10347 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10348 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10349 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10350 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10351 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10352 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10355 cmd_reconfig_device_queue(res->port_id, 1, 1);
10358 cmdline_parse_token_string_t cmd_flow_director_mask =
10359 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10360 flow_director_mask, "flow_director_mask");
10361 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10362 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10364 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10365 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10367 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10368 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10369 vlan_mask, UINT16);
10370 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10371 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10372 src_mask, "src_mask");
10373 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10374 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10376 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10377 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10379 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10380 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10382 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10383 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10384 dst_mask, "dst_mask");
10385 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10386 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10388 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10389 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10391 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10392 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10395 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10396 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10398 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10399 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10401 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10402 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10403 mode_value, "MAC-VLAN");
10404 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10405 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10406 mode_value, "Tunnel");
10407 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10408 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10410 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10411 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10412 mac_addr_byte_mask, UINT8);
10413 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10414 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10415 tunnel_type, "tunnel-type");
10416 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10417 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10418 tunnel_type_mask, UINT8);
10419 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10420 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10421 tunnel_id, "tunnel-id");
10422 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10423 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10424 tunnel_id_mask, UINT32);
10426 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10427 .f = cmd_flow_director_mask_parsed,
10429 .help_str = "flow_director_mask ... : "
10430 "Set IP mode flow director's mask on NIC",
10432 (void *)&cmd_flow_director_mask,
10433 (void *)&cmd_flow_director_mask_port_id,
10434 (void *)&cmd_flow_director_mask_mode,
10435 (void *)&cmd_flow_director_mask_mode_ip,
10436 (void *)&cmd_flow_director_mask_vlan,
10437 (void *)&cmd_flow_director_mask_vlan_value,
10438 (void *)&cmd_flow_director_mask_src,
10439 (void *)&cmd_flow_director_mask_ipv4_src,
10440 (void *)&cmd_flow_director_mask_ipv6_src,
10441 (void *)&cmd_flow_director_mask_port_src,
10442 (void *)&cmd_flow_director_mask_dst,
10443 (void *)&cmd_flow_director_mask_ipv4_dst,
10444 (void *)&cmd_flow_director_mask_ipv6_dst,
10445 (void *)&cmd_flow_director_mask_port_dst,
10450 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10451 .f = cmd_flow_director_mask_parsed,
10453 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10454 "flow director's mask on NIC",
10456 (void *)&cmd_flow_director_mask,
10457 (void *)&cmd_flow_director_mask_port_id,
10458 (void *)&cmd_flow_director_mask_mode,
10459 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10460 (void *)&cmd_flow_director_mask_vlan,
10461 (void *)&cmd_flow_director_mask_vlan_value,
10466 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10467 .f = cmd_flow_director_mask_parsed,
10469 .help_str = "flow_director_mask ... : Set tunnel mode "
10470 "flow director's mask on NIC",
10472 (void *)&cmd_flow_director_mask,
10473 (void *)&cmd_flow_director_mask_port_id,
10474 (void *)&cmd_flow_director_mask_mode,
10475 (void *)&cmd_flow_director_mask_mode_tunnel,
10476 (void *)&cmd_flow_director_mask_vlan,
10477 (void *)&cmd_flow_director_mask_vlan_value,
10478 (void *)&cmd_flow_director_mask_mac,
10479 (void *)&cmd_flow_director_mask_mac_value,
10480 (void *)&cmd_flow_director_mask_tunnel_type,
10481 (void *)&cmd_flow_director_mask_tunnel_type_value,
10482 (void *)&cmd_flow_director_mask_tunnel_id,
10483 (void *)&cmd_flow_director_mask_tunnel_id_value,
10488 /* *** deal with flow director flexible payload configuration *** */
10489 struct cmd_flow_director_flexpayload_result {
10490 cmdline_fixed_string_t flow_director_flexpayload;
10492 cmdline_fixed_string_t payload_layer;
10493 cmdline_fixed_string_t payload_cfg;
10497 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10500 const char *p, *p0 = q_arg;
10502 unsigned long int_fld;
10503 char *str_fld[max_num];
10508 p = strchr(p0, '(');
10512 p0 = strchr(p, ')');
10517 if (size >= sizeof(s))
10520 snprintf(s, sizeof(s), "%.*s", size, p);
10521 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10522 if (ret < 0 || ret > max_num)
10524 for (i = 0; i < ret; i++) {
10526 int_fld = strtoul(str_fld[i], &end, 0);
10527 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10529 offsets[i] = (uint16_t)int_fld;
10535 cmd_flow_director_flxpld_parsed(void *parsed_result,
10536 __rte_unused struct cmdline *cl,
10537 __rte_unused void *data)
10539 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10540 struct rte_eth_flex_payload_cfg flex_cfg;
10541 struct rte_port *port;
10544 port = &ports[res->port_id];
10545 /** Check if the port is not started **/
10546 if (port->port_status != RTE_PORT_STOPPED) {
10547 printf("Please stop port %d first\n", res->port_id);
10551 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10553 if (!strcmp(res->payload_layer, "raw"))
10554 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10555 else if (!strcmp(res->payload_layer, "l2"))
10556 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10557 else if (!strcmp(res->payload_layer, "l3"))
10558 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10559 else if (!strcmp(res->payload_layer, "l4"))
10560 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10562 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10563 RTE_ETH_FDIR_MAX_FLEXLEN);
10565 printf("error: Cannot parse flex payload input.\n");
10569 fdir_set_flex_payload(res->port_id, &flex_cfg);
10570 cmd_reconfig_device_queue(res->port_id, 1, 1);
10573 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10574 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10575 flow_director_flexpayload,
10576 "flow_director_flex_payload");
10577 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10578 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10580 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10581 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10582 payload_layer, "raw#l2#l3#l4");
10583 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10584 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10585 payload_cfg, NULL);
10587 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10588 .f = cmd_flow_director_flxpld_parsed,
10590 .help_str = "flow_director_flexpayload ... : "
10591 "Set flow director's flex payload on NIC",
10593 (void *)&cmd_flow_director_flexpayload,
10594 (void *)&cmd_flow_director_flexpayload_port_id,
10595 (void *)&cmd_flow_director_flexpayload_payload_layer,
10596 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10601 /* Generic flow interface command. */
10602 extern cmdline_parse_inst_t cmd_flow;
10604 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10605 struct cmd_mcast_addr_result {
10606 cmdline_fixed_string_t mcast_addr_cmd;
10607 cmdline_fixed_string_t what;
10609 struct rte_ether_addr mc_addr;
10612 static void cmd_mcast_addr_parsed(void *parsed_result,
10613 __rte_unused struct cmdline *cl,
10614 __rte_unused void *data)
10616 struct cmd_mcast_addr_result *res = parsed_result;
10618 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
10619 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10620 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10621 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10622 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10625 if (strcmp(res->what, "add") == 0)
10626 mcast_addr_add(res->port_num, &res->mc_addr);
10628 mcast_addr_remove(res->port_num, &res->mc_addr);
10631 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10632 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10633 mcast_addr_cmd, "mcast_addr");
10634 cmdline_parse_token_string_t cmd_mcast_addr_what =
10635 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10637 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10638 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
10639 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10640 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10642 cmdline_parse_inst_t cmd_mcast_addr = {
10643 .f = cmd_mcast_addr_parsed,
10645 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10646 "Add/Remove multicast MAC address on port_id",
10648 (void *)&cmd_mcast_addr_cmd,
10649 (void *)&cmd_mcast_addr_what,
10650 (void *)&cmd_mcast_addr_portnum,
10651 (void *)&cmd_mcast_addr_addr,
10656 /* vf vlan anti spoof configuration */
10658 /* Common result structure for vf vlan anti spoof */
10659 struct cmd_vf_vlan_anti_spoof_result {
10660 cmdline_fixed_string_t set;
10661 cmdline_fixed_string_t vf;
10662 cmdline_fixed_string_t vlan;
10663 cmdline_fixed_string_t antispoof;
10666 cmdline_fixed_string_t on_off;
10669 /* Common CLI fields for vf vlan anti spoof enable disable */
10670 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10671 TOKEN_STRING_INITIALIZER
10672 (struct cmd_vf_vlan_anti_spoof_result,
10674 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10675 TOKEN_STRING_INITIALIZER
10676 (struct cmd_vf_vlan_anti_spoof_result,
10678 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10679 TOKEN_STRING_INITIALIZER
10680 (struct cmd_vf_vlan_anti_spoof_result,
10682 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10683 TOKEN_STRING_INITIALIZER
10684 (struct cmd_vf_vlan_anti_spoof_result,
10685 antispoof, "antispoof");
10686 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10687 TOKEN_NUM_INITIALIZER
10688 (struct cmd_vf_vlan_anti_spoof_result,
10690 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10691 TOKEN_NUM_INITIALIZER
10692 (struct cmd_vf_vlan_anti_spoof_result,
10694 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10695 TOKEN_STRING_INITIALIZER
10696 (struct cmd_vf_vlan_anti_spoof_result,
10700 cmd_set_vf_vlan_anti_spoof_parsed(
10701 void *parsed_result,
10702 __rte_unused struct cmdline *cl,
10703 __rte_unused void *data)
10705 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10706 int ret = -ENOTSUP;
10708 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10710 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10713 #ifdef RTE_NET_IXGBE
10714 if (ret == -ENOTSUP)
10715 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10716 res->vf_id, is_on);
10718 #ifdef RTE_NET_I40E
10719 if (ret == -ENOTSUP)
10720 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10721 res->vf_id, is_on);
10723 #ifdef RTE_NET_BNXT
10724 if (ret == -ENOTSUP)
10725 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
10726 res->vf_id, is_on);
10733 printf("invalid vf_id %d\n", res->vf_id);
10736 printf("invalid port_id %d\n", res->port_id);
10739 printf("function not implemented\n");
10742 printf("programming error: (%s)\n", strerror(-ret));
10746 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10747 .f = cmd_set_vf_vlan_anti_spoof_parsed,
10749 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10751 (void *)&cmd_vf_vlan_anti_spoof_set,
10752 (void *)&cmd_vf_vlan_anti_spoof_vf,
10753 (void *)&cmd_vf_vlan_anti_spoof_vlan,
10754 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
10755 (void *)&cmd_vf_vlan_anti_spoof_port_id,
10756 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
10757 (void *)&cmd_vf_vlan_anti_spoof_on_off,
10762 /* vf mac anti spoof configuration */
10764 /* Common result structure for vf mac anti spoof */
10765 struct cmd_vf_mac_anti_spoof_result {
10766 cmdline_fixed_string_t set;
10767 cmdline_fixed_string_t vf;
10768 cmdline_fixed_string_t mac;
10769 cmdline_fixed_string_t antispoof;
10772 cmdline_fixed_string_t on_off;
10775 /* Common CLI fields for vf mac anti spoof enable disable */
10776 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
10777 TOKEN_STRING_INITIALIZER
10778 (struct cmd_vf_mac_anti_spoof_result,
10780 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
10781 TOKEN_STRING_INITIALIZER
10782 (struct cmd_vf_mac_anti_spoof_result,
10784 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
10785 TOKEN_STRING_INITIALIZER
10786 (struct cmd_vf_mac_anti_spoof_result,
10788 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
10789 TOKEN_STRING_INITIALIZER
10790 (struct cmd_vf_mac_anti_spoof_result,
10791 antispoof, "antispoof");
10792 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
10793 TOKEN_NUM_INITIALIZER
10794 (struct cmd_vf_mac_anti_spoof_result,
10796 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
10797 TOKEN_NUM_INITIALIZER
10798 (struct cmd_vf_mac_anti_spoof_result,
10800 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
10801 TOKEN_STRING_INITIALIZER
10802 (struct cmd_vf_mac_anti_spoof_result,
10806 cmd_set_vf_mac_anti_spoof_parsed(
10807 void *parsed_result,
10808 __rte_unused struct cmdline *cl,
10809 __rte_unused void *data)
10811 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
10812 int ret = -ENOTSUP;
10814 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10816 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10819 #ifdef RTE_NET_IXGBE
10820 if (ret == -ENOTSUP)
10821 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
10822 res->vf_id, is_on);
10824 #ifdef RTE_NET_I40E
10825 if (ret == -ENOTSUP)
10826 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
10827 res->vf_id, is_on);
10829 #ifdef RTE_NET_BNXT
10830 if (ret == -ENOTSUP)
10831 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
10832 res->vf_id, is_on);
10839 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
10842 printf("invalid port_id %d\n", res->port_id);
10845 printf("function not implemented\n");
10848 printf("programming error: (%s)\n", strerror(-ret));
10852 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
10853 .f = cmd_set_vf_mac_anti_spoof_parsed,
10855 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
10857 (void *)&cmd_vf_mac_anti_spoof_set,
10858 (void *)&cmd_vf_mac_anti_spoof_vf,
10859 (void *)&cmd_vf_mac_anti_spoof_mac,
10860 (void *)&cmd_vf_mac_anti_spoof_antispoof,
10861 (void *)&cmd_vf_mac_anti_spoof_port_id,
10862 (void *)&cmd_vf_mac_anti_spoof_vf_id,
10863 (void *)&cmd_vf_mac_anti_spoof_on_off,
10868 /* vf vlan strip queue configuration */
10870 /* Common result structure for vf mac anti spoof */
10871 struct cmd_vf_vlan_stripq_result {
10872 cmdline_fixed_string_t set;
10873 cmdline_fixed_string_t vf;
10874 cmdline_fixed_string_t vlan;
10875 cmdline_fixed_string_t stripq;
10878 cmdline_fixed_string_t on_off;
10881 /* Common CLI fields for vf vlan strip enable disable */
10882 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
10883 TOKEN_STRING_INITIALIZER
10884 (struct cmd_vf_vlan_stripq_result,
10886 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
10887 TOKEN_STRING_INITIALIZER
10888 (struct cmd_vf_vlan_stripq_result,
10890 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
10891 TOKEN_STRING_INITIALIZER
10892 (struct cmd_vf_vlan_stripq_result,
10894 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
10895 TOKEN_STRING_INITIALIZER
10896 (struct cmd_vf_vlan_stripq_result,
10898 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
10899 TOKEN_NUM_INITIALIZER
10900 (struct cmd_vf_vlan_stripq_result,
10902 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
10903 TOKEN_NUM_INITIALIZER
10904 (struct cmd_vf_vlan_stripq_result,
10906 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
10907 TOKEN_STRING_INITIALIZER
10908 (struct cmd_vf_vlan_stripq_result,
10912 cmd_set_vf_vlan_stripq_parsed(
10913 void *parsed_result,
10914 __rte_unused struct cmdline *cl,
10915 __rte_unused void *data)
10917 struct cmd_vf_vlan_stripq_result *res = parsed_result;
10918 int ret = -ENOTSUP;
10920 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10922 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10925 #ifdef RTE_NET_IXGBE
10926 if (ret == -ENOTSUP)
10927 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
10928 res->vf_id, is_on);
10930 #ifdef RTE_NET_I40E
10931 if (ret == -ENOTSUP)
10932 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
10933 res->vf_id, is_on);
10935 #ifdef RTE_NET_BNXT
10936 if (ret == -ENOTSUP)
10937 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
10938 res->vf_id, is_on);
10945 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
10948 printf("invalid port_id %d\n", res->port_id);
10951 printf("function not implemented\n");
10954 printf("programming error: (%s)\n", strerror(-ret));
10958 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
10959 .f = cmd_set_vf_vlan_stripq_parsed,
10961 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
10963 (void *)&cmd_vf_vlan_stripq_set,
10964 (void *)&cmd_vf_vlan_stripq_vf,
10965 (void *)&cmd_vf_vlan_stripq_vlan,
10966 (void *)&cmd_vf_vlan_stripq_stripq,
10967 (void *)&cmd_vf_vlan_stripq_port_id,
10968 (void *)&cmd_vf_vlan_stripq_vf_id,
10969 (void *)&cmd_vf_vlan_stripq_on_off,
10974 /* vf vlan insert configuration */
10976 /* Common result structure for vf vlan insert */
10977 struct cmd_vf_vlan_insert_result {
10978 cmdline_fixed_string_t set;
10979 cmdline_fixed_string_t vf;
10980 cmdline_fixed_string_t vlan;
10981 cmdline_fixed_string_t insert;
10987 /* Common CLI fields for vf vlan insert enable disable */
10988 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
10989 TOKEN_STRING_INITIALIZER
10990 (struct cmd_vf_vlan_insert_result,
10992 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
10993 TOKEN_STRING_INITIALIZER
10994 (struct cmd_vf_vlan_insert_result,
10996 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
10997 TOKEN_STRING_INITIALIZER
10998 (struct cmd_vf_vlan_insert_result,
11000 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11001 TOKEN_STRING_INITIALIZER
11002 (struct cmd_vf_vlan_insert_result,
11004 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11005 TOKEN_NUM_INITIALIZER
11006 (struct cmd_vf_vlan_insert_result,
11008 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11009 TOKEN_NUM_INITIALIZER
11010 (struct cmd_vf_vlan_insert_result,
11012 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11013 TOKEN_NUM_INITIALIZER
11014 (struct cmd_vf_vlan_insert_result,
11018 cmd_set_vf_vlan_insert_parsed(
11019 void *parsed_result,
11020 __rte_unused struct cmdline *cl,
11021 __rte_unused void *data)
11023 struct cmd_vf_vlan_insert_result *res = parsed_result;
11024 int ret = -ENOTSUP;
11026 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11029 #ifdef RTE_NET_IXGBE
11030 if (ret == -ENOTSUP)
11031 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11034 #ifdef RTE_NET_I40E
11035 if (ret == -ENOTSUP)
11036 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11039 #ifdef RTE_NET_BNXT
11040 if (ret == -ENOTSUP)
11041 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11049 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11052 printf("invalid port_id %d\n", res->port_id);
11055 printf("function not implemented\n");
11058 printf("programming error: (%s)\n", strerror(-ret));
11062 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11063 .f = cmd_set_vf_vlan_insert_parsed,
11065 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11067 (void *)&cmd_vf_vlan_insert_set,
11068 (void *)&cmd_vf_vlan_insert_vf,
11069 (void *)&cmd_vf_vlan_insert_vlan,
11070 (void *)&cmd_vf_vlan_insert_insert,
11071 (void *)&cmd_vf_vlan_insert_port_id,
11072 (void *)&cmd_vf_vlan_insert_vf_id,
11073 (void *)&cmd_vf_vlan_insert_vlan_id,
11078 /* tx loopback configuration */
11080 /* Common result structure for tx loopback */
11081 struct cmd_tx_loopback_result {
11082 cmdline_fixed_string_t set;
11083 cmdline_fixed_string_t tx;
11084 cmdline_fixed_string_t loopback;
11086 cmdline_fixed_string_t on_off;
11089 /* Common CLI fields for tx loopback enable disable */
11090 cmdline_parse_token_string_t cmd_tx_loopback_set =
11091 TOKEN_STRING_INITIALIZER
11092 (struct cmd_tx_loopback_result,
11094 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11095 TOKEN_STRING_INITIALIZER
11096 (struct cmd_tx_loopback_result,
11098 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11099 TOKEN_STRING_INITIALIZER
11100 (struct cmd_tx_loopback_result,
11101 loopback, "loopback");
11102 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11103 TOKEN_NUM_INITIALIZER
11104 (struct cmd_tx_loopback_result,
11106 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11107 TOKEN_STRING_INITIALIZER
11108 (struct cmd_tx_loopback_result,
11112 cmd_set_tx_loopback_parsed(
11113 void *parsed_result,
11114 __rte_unused struct cmdline *cl,
11115 __rte_unused void *data)
11117 struct cmd_tx_loopback_result *res = parsed_result;
11118 int ret = -ENOTSUP;
11120 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11122 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11125 #ifdef RTE_NET_IXGBE
11126 if (ret == -ENOTSUP)
11127 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11129 #ifdef RTE_NET_I40E
11130 if (ret == -ENOTSUP)
11131 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11133 #ifdef RTE_NET_BNXT
11134 if (ret == -ENOTSUP)
11135 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11137 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11138 if (ret == -ENOTSUP)
11139 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11146 printf("invalid is_on %d\n", is_on);
11149 printf("invalid port_id %d\n", res->port_id);
11152 printf("function not implemented\n");
11155 printf("programming error: (%s)\n", strerror(-ret));
11159 cmdline_parse_inst_t cmd_set_tx_loopback = {
11160 .f = cmd_set_tx_loopback_parsed,
11162 .help_str = "set tx loopback <port_id> on|off",
11164 (void *)&cmd_tx_loopback_set,
11165 (void *)&cmd_tx_loopback_tx,
11166 (void *)&cmd_tx_loopback_loopback,
11167 (void *)&cmd_tx_loopback_port_id,
11168 (void *)&cmd_tx_loopback_on_off,
11173 /* all queues drop enable configuration */
11175 /* Common result structure for all queues drop enable */
11176 struct cmd_all_queues_drop_en_result {
11177 cmdline_fixed_string_t set;
11178 cmdline_fixed_string_t all;
11179 cmdline_fixed_string_t queues;
11180 cmdline_fixed_string_t drop;
11182 cmdline_fixed_string_t on_off;
11185 /* Common CLI fields for tx loopback enable disable */
11186 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11187 TOKEN_STRING_INITIALIZER
11188 (struct cmd_all_queues_drop_en_result,
11190 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11191 TOKEN_STRING_INITIALIZER
11192 (struct cmd_all_queues_drop_en_result,
11194 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11195 TOKEN_STRING_INITIALIZER
11196 (struct cmd_all_queues_drop_en_result,
11198 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11199 TOKEN_STRING_INITIALIZER
11200 (struct cmd_all_queues_drop_en_result,
11202 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11203 TOKEN_NUM_INITIALIZER
11204 (struct cmd_all_queues_drop_en_result,
11206 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11207 TOKEN_STRING_INITIALIZER
11208 (struct cmd_all_queues_drop_en_result,
11212 cmd_set_all_queues_drop_en_parsed(
11213 void *parsed_result,
11214 __rte_unused struct cmdline *cl,
11215 __rte_unused void *data)
11217 struct cmd_all_queues_drop_en_result *res = parsed_result;
11218 int ret = -ENOTSUP;
11219 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11221 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11224 #ifdef RTE_NET_IXGBE
11225 if (ret == -ENOTSUP)
11226 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11228 #ifdef RTE_NET_BNXT
11229 if (ret == -ENOTSUP)
11230 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11236 printf("invalid is_on %d\n", is_on);
11239 printf("invalid port_id %d\n", res->port_id);
11242 printf("function not implemented\n");
11245 printf("programming error: (%s)\n", strerror(-ret));
11249 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11250 .f = cmd_set_all_queues_drop_en_parsed,
11252 .help_str = "set all queues drop <port_id> on|off",
11254 (void *)&cmd_all_queues_drop_en_set,
11255 (void *)&cmd_all_queues_drop_en_all,
11256 (void *)&cmd_all_queues_drop_en_queues,
11257 (void *)&cmd_all_queues_drop_en_drop,
11258 (void *)&cmd_all_queues_drop_en_port_id,
11259 (void *)&cmd_all_queues_drop_en_on_off,
11264 /* vf split drop enable configuration */
11266 /* Common result structure for vf split drop enable */
11267 struct cmd_vf_split_drop_en_result {
11268 cmdline_fixed_string_t set;
11269 cmdline_fixed_string_t vf;
11270 cmdline_fixed_string_t split;
11271 cmdline_fixed_string_t drop;
11274 cmdline_fixed_string_t on_off;
11277 /* Common CLI fields for vf split drop enable disable */
11278 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11279 TOKEN_STRING_INITIALIZER
11280 (struct cmd_vf_split_drop_en_result,
11282 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11283 TOKEN_STRING_INITIALIZER
11284 (struct cmd_vf_split_drop_en_result,
11286 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11287 TOKEN_STRING_INITIALIZER
11288 (struct cmd_vf_split_drop_en_result,
11290 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11291 TOKEN_STRING_INITIALIZER
11292 (struct cmd_vf_split_drop_en_result,
11294 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11295 TOKEN_NUM_INITIALIZER
11296 (struct cmd_vf_split_drop_en_result,
11298 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11299 TOKEN_NUM_INITIALIZER
11300 (struct cmd_vf_split_drop_en_result,
11302 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11303 TOKEN_STRING_INITIALIZER
11304 (struct cmd_vf_split_drop_en_result,
11308 cmd_set_vf_split_drop_en_parsed(
11309 void *parsed_result,
11310 __rte_unused struct cmdline *cl,
11311 __rte_unused void *data)
11313 struct cmd_vf_split_drop_en_result *res = parsed_result;
11314 int ret = -ENOTSUP;
11315 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11317 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11320 #ifdef RTE_NET_IXGBE
11321 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11328 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11331 printf("invalid port_id %d\n", res->port_id);
11334 printf("not supported on port %d\n", res->port_id);
11337 printf("programming error: (%s)\n", strerror(-ret));
11341 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11342 .f = cmd_set_vf_split_drop_en_parsed,
11344 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11346 (void *)&cmd_vf_split_drop_en_set,
11347 (void *)&cmd_vf_split_drop_en_vf,
11348 (void *)&cmd_vf_split_drop_en_split,
11349 (void *)&cmd_vf_split_drop_en_drop,
11350 (void *)&cmd_vf_split_drop_en_port_id,
11351 (void *)&cmd_vf_split_drop_en_vf_id,
11352 (void *)&cmd_vf_split_drop_en_on_off,
11357 /* vf mac address configuration */
11359 /* Common result structure for vf mac address */
11360 struct cmd_set_vf_mac_addr_result {
11361 cmdline_fixed_string_t set;
11362 cmdline_fixed_string_t vf;
11363 cmdline_fixed_string_t mac;
11364 cmdline_fixed_string_t addr;
11367 struct rte_ether_addr mac_addr;
11371 /* Common CLI fields for vf split drop enable disable */
11372 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11373 TOKEN_STRING_INITIALIZER
11374 (struct cmd_set_vf_mac_addr_result,
11376 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11377 TOKEN_STRING_INITIALIZER
11378 (struct cmd_set_vf_mac_addr_result,
11380 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11381 TOKEN_STRING_INITIALIZER
11382 (struct cmd_set_vf_mac_addr_result,
11384 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11385 TOKEN_STRING_INITIALIZER
11386 (struct cmd_set_vf_mac_addr_result,
11388 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11389 TOKEN_NUM_INITIALIZER
11390 (struct cmd_set_vf_mac_addr_result,
11392 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11393 TOKEN_NUM_INITIALIZER
11394 (struct cmd_set_vf_mac_addr_result,
11396 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11397 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11401 cmd_set_vf_mac_addr_parsed(
11402 void *parsed_result,
11403 __rte_unused struct cmdline *cl,
11404 __rte_unused void *data)
11406 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11407 int ret = -ENOTSUP;
11409 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11412 #ifdef RTE_NET_IXGBE
11413 if (ret == -ENOTSUP)
11414 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11417 #ifdef RTE_NET_I40E
11418 if (ret == -ENOTSUP)
11419 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11422 #ifdef RTE_NET_BNXT
11423 if (ret == -ENOTSUP)
11424 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11432 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11435 printf("invalid port_id %d\n", res->port_id);
11438 printf("function not implemented\n");
11441 printf("programming error: (%s)\n", strerror(-ret));
11445 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11446 .f = cmd_set_vf_mac_addr_parsed,
11448 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11450 (void *)&cmd_set_vf_mac_addr_set,
11451 (void *)&cmd_set_vf_mac_addr_vf,
11452 (void *)&cmd_set_vf_mac_addr_mac,
11453 (void *)&cmd_set_vf_mac_addr_addr,
11454 (void *)&cmd_set_vf_mac_addr_port_id,
11455 (void *)&cmd_set_vf_mac_addr_vf_id,
11456 (void *)&cmd_set_vf_mac_addr_mac_addr,
11461 /* MACsec configuration */
11463 /* Common result structure for MACsec offload enable */
11464 struct cmd_macsec_offload_on_result {
11465 cmdline_fixed_string_t set;
11466 cmdline_fixed_string_t macsec;
11467 cmdline_fixed_string_t offload;
11469 cmdline_fixed_string_t on;
11470 cmdline_fixed_string_t encrypt;
11471 cmdline_fixed_string_t en_on_off;
11472 cmdline_fixed_string_t replay_protect;
11473 cmdline_fixed_string_t rp_on_off;
11476 /* Common CLI fields for MACsec offload disable */
11477 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11478 TOKEN_STRING_INITIALIZER
11479 (struct cmd_macsec_offload_on_result,
11481 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11482 TOKEN_STRING_INITIALIZER
11483 (struct cmd_macsec_offload_on_result,
11485 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11486 TOKEN_STRING_INITIALIZER
11487 (struct cmd_macsec_offload_on_result,
11488 offload, "offload");
11489 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11490 TOKEN_NUM_INITIALIZER
11491 (struct cmd_macsec_offload_on_result,
11493 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11494 TOKEN_STRING_INITIALIZER
11495 (struct cmd_macsec_offload_on_result,
11497 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11498 TOKEN_STRING_INITIALIZER
11499 (struct cmd_macsec_offload_on_result,
11500 encrypt, "encrypt");
11501 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11502 TOKEN_STRING_INITIALIZER
11503 (struct cmd_macsec_offload_on_result,
11504 en_on_off, "on#off");
11505 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11506 TOKEN_STRING_INITIALIZER
11507 (struct cmd_macsec_offload_on_result,
11508 replay_protect, "replay-protect");
11509 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11510 TOKEN_STRING_INITIALIZER
11511 (struct cmd_macsec_offload_on_result,
11512 rp_on_off, "on#off");
11515 cmd_set_macsec_offload_on_parsed(
11516 void *parsed_result,
11517 __rte_unused struct cmdline *cl,
11518 __rte_unused void *data)
11520 struct cmd_macsec_offload_on_result *res = parsed_result;
11521 int ret = -ENOTSUP;
11522 portid_t port_id = res->port_id;
11523 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11524 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11525 struct rte_eth_dev_info dev_info;
11527 if (port_id_is_invalid(port_id, ENABLED_WARN))
11529 if (!port_is_stopped(port_id)) {
11530 printf("Please stop port %d first\n", port_id);
11534 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11538 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11539 #ifdef RTE_NET_IXGBE
11540 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11548 ports[port_id].dev_conf.txmode.offloads |=
11549 DEV_TX_OFFLOAD_MACSEC_INSERT;
11550 cmd_reconfig_device_queue(port_id, 1, 1);
11553 printf("invalid port_id %d\n", port_id);
11556 printf("not supported on port %d\n", port_id);
11559 printf("programming error: (%s)\n", strerror(-ret));
11563 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11564 .f = cmd_set_macsec_offload_on_parsed,
11566 .help_str = "set macsec offload <port_id> on "
11567 "encrypt on|off replay-protect on|off",
11569 (void *)&cmd_macsec_offload_on_set,
11570 (void *)&cmd_macsec_offload_on_macsec,
11571 (void *)&cmd_macsec_offload_on_offload,
11572 (void *)&cmd_macsec_offload_on_port_id,
11573 (void *)&cmd_macsec_offload_on_on,
11574 (void *)&cmd_macsec_offload_on_encrypt,
11575 (void *)&cmd_macsec_offload_on_en_on_off,
11576 (void *)&cmd_macsec_offload_on_replay_protect,
11577 (void *)&cmd_macsec_offload_on_rp_on_off,
11582 /* Common result structure for MACsec offload disable */
11583 struct cmd_macsec_offload_off_result {
11584 cmdline_fixed_string_t set;
11585 cmdline_fixed_string_t macsec;
11586 cmdline_fixed_string_t offload;
11588 cmdline_fixed_string_t off;
11591 /* Common CLI fields for MACsec offload disable */
11592 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11593 TOKEN_STRING_INITIALIZER
11594 (struct cmd_macsec_offload_off_result,
11596 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11597 TOKEN_STRING_INITIALIZER
11598 (struct cmd_macsec_offload_off_result,
11600 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11601 TOKEN_STRING_INITIALIZER
11602 (struct cmd_macsec_offload_off_result,
11603 offload, "offload");
11604 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11605 TOKEN_NUM_INITIALIZER
11606 (struct cmd_macsec_offload_off_result,
11608 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11609 TOKEN_STRING_INITIALIZER
11610 (struct cmd_macsec_offload_off_result,
11614 cmd_set_macsec_offload_off_parsed(
11615 void *parsed_result,
11616 __rte_unused struct cmdline *cl,
11617 __rte_unused void *data)
11619 struct cmd_macsec_offload_off_result *res = parsed_result;
11620 int ret = -ENOTSUP;
11621 struct rte_eth_dev_info dev_info;
11622 portid_t port_id = res->port_id;
11624 if (port_id_is_invalid(port_id, ENABLED_WARN))
11626 if (!port_is_stopped(port_id)) {
11627 printf("Please stop port %d first\n", port_id);
11631 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11635 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11636 #ifdef RTE_NET_IXGBE
11637 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11642 ports[port_id].dev_conf.txmode.offloads &=
11643 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
11644 cmd_reconfig_device_queue(port_id, 1, 1);
11647 printf("invalid port_id %d\n", port_id);
11650 printf("not supported on port %d\n", port_id);
11653 printf("programming error: (%s)\n", strerror(-ret));
11657 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11658 .f = cmd_set_macsec_offload_off_parsed,
11660 .help_str = "set macsec offload <port_id> off",
11662 (void *)&cmd_macsec_offload_off_set,
11663 (void *)&cmd_macsec_offload_off_macsec,
11664 (void *)&cmd_macsec_offload_off_offload,
11665 (void *)&cmd_macsec_offload_off_port_id,
11666 (void *)&cmd_macsec_offload_off_off,
11671 /* Common result structure for MACsec secure connection configure */
11672 struct cmd_macsec_sc_result {
11673 cmdline_fixed_string_t set;
11674 cmdline_fixed_string_t macsec;
11675 cmdline_fixed_string_t sc;
11676 cmdline_fixed_string_t tx_rx;
11678 struct rte_ether_addr mac;
11682 /* Common CLI fields for MACsec secure connection configure */
11683 cmdline_parse_token_string_t cmd_macsec_sc_set =
11684 TOKEN_STRING_INITIALIZER
11685 (struct cmd_macsec_sc_result,
11687 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11688 TOKEN_STRING_INITIALIZER
11689 (struct cmd_macsec_sc_result,
11691 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11692 TOKEN_STRING_INITIALIZER
11693 (struct cmd_macsec_sc_result,
11695 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11696 TOKEN_STRING_INITIALIZER
11697 (struct cmd_macsec_sc_result,
11699 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11700 TOKEN_NUM_INITIALIZER
11701 (struct cmd_macsec_sc_result,
11703 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11704 TOKEN_ETHERADDR_INITIALIZER
11705 (struct cmd_macsec_sc_result,
11707 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11708 TOKEN_NUM_INITIALIZER
11709 (struct cmd_macsec_sc_result,
11713 cmd_set_macsec_sc_parsed(
11714 void *parsed_result,
11715 __rte_unused struct cmdline *cl,
11716 __rte_unused void *data)
11718 struct cmd_macsec_sc_result *res = parsed_result;
11719 int ret = -ENOTSUP;
11720 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11722 #ifdef RTE_NET_IXGBE
11724 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11725 res->mac.addr_bytes) :
11726 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11727 res->mac.addr_bytes, res->pi);
11729 RTE_SET_USED(is_tx);
11735 printf("invalid port_id %d\n", res->port_id);
11738 printf("not supported on port %d\n", res->port_id);
11741 printf("programming error: (%s)\n", strerror(-ret));
11745 cmdline_parse_inst_t cmd_set_macsec_sc = {
11746 .f = cmd_set_macsec_sc_parsed,
11748 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11750 (void *)&cmd_macsec_sc_set,
11751 (void *)&cmd_macsec_sc_macsec,
11752 (void *)&cmd_macsec_sc_sc,
11753 (void *)&cmd_macsec_sc_tx_rx,
11754 (void *)&cmd_macsec_sc_port_id,
11755 (void *)&cmd_macsec_sc_mac,
11756 (void *)&cmd_macsec_sc_pi,
11761 /* Common result structure for MACsec secure connection configure */
11762 struct cmd_macsec_sa_result {
11763 cmdline_fixed_string_t set;
11764 cmdline_fixed_string_t macsec;
11765 cmdline_fixed_string_t sa;
11766 cmdline_fixed_string_t tx_rx;
11771 cmdline_fixed_string_t key;
11774 /* Common CLI fields for MACsec secure connection configure */
11775 cmdline_parse_token_string_t cmd_macsec_sa_set =
11776 TOKEN_STRING_INITIALIZER
11777 (struct cmd_macsec_sa_result,
11779 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11780 TOKEN_STRING_INITIALIZER
11781 (struct cmd_macsec_sa_result,
11783 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11784 TOKEN_STRING_INITIALIZER
11785 (struct cmd_macsec_sa_result,
11787 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11788 TOKEN_STRING_INITIALIZER
11789 (struct cmd_macsec_sa_result,
11791 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11792 TOKEN_NUM_INITIALIZER
11793 (struct cmd_macsec_sa_result,
11795 cmdline_parse_token_num_t cmd_macsec_sa_idx =
11796 TOKEN_NUM_INITIALIZER
11797 (struct cmd_macsec_sa_result,
11799 cmdline_parse_token_num_t cmd_macsec_sa_an =
11800 TOKEN_NUM_INITIALIZER
11801 (struct cmd_macsec_sa_result,
11803 cmdline_parse_token_num_t cmd_macsec_sa_pn =
11804 TOKEN_NUM_INITIALIZER
11805 (struct cmd_macsec_sa_result,
11807 cmdline_parse_token_string_t cmd_macsec_sa_key =
11808 TOKEN_STRING_INITIALIZER
11809 (struct cmd_macsec_sa_result,
11813 cmd_set_macsec_sa_parsed(
11814 void *parsed_result,
11815 __rte_unused struct cmdline *cl,
11816 __rte_unused void *data)
11818 struct cmd_macsec_sa_result *res = parsed_result;
11819 int ret = -ENOTSUP;
11820 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11821 uint8_t key[16] = { 0 };
11827 key_len = strlen(res->key) / 2;
11831 for (i = 0; i < key_len; i++) {
11832 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
11835 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
11838 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
11841 #ifdef RTE_NET_IXGBE
11843 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
11844 res->idx, res->an, res->pn, key) :
11845 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
11846 res->idx, res->an, res->pn, key);
11848 RTE_SET_USED(is_tx);
11855 printf("invalid idx %d or an %d\n", res->idx, res->an);
11858 printf("invalid port_id %d\n", res->port_id);
11861 printf("not supported on port %d\n", res->port_id);
11864 printf("programming error: (%s)\n", strerror(-ret));
11868 cmdline_parse_inst_t cmd_set_macsec_sa = {
11869 .f = cmd_set_macsec_sa_parsed,
11871 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
11873 (void *)&cmd_macsec_sa_set,
11874 (void *)&cmd_macsec_sa_macsec,
11875 (void *)&cmd_macsec_sa_sa,
11876 (void *)&cmd_macsec_sa_tx_rx,
11877 (void *)&cmd_macsec_sa_port_id,
11878 (void *)&cmd_macsec_sa_idx,
11879 (void *)&cmd_macsec_sa_an,
11880 (void *)&cmd_macsec_sa_pn,
11881 (void *)&cmd_macsec_sa_key,
11886 /* VF unicast promiscuous mode configuration */
11888 /* Common result structure for VF unicast promiscuous mode */
11889 struct cmd_vf_promisc_result {
11890 cmdline_fixed_string_t set;
11891 cmdline_fixed_string_t vf;
11892 cmdline_fixed_string_t promisc;
11895 cmdline_fixed_string_t on_off;
11898 /* Common CLI fields for VF unicast promiscuous mode enable disable */
11899 cmdline_parse_token_string_t cmd_vf_promisc_set =
11900 TOKEN_STRING_INITIALIZER
11901 (struct cmd_vf_promisc_result,
11903 cmdline_parse_token_string_t cmd_vf_promisc_vf =
11904 TOKEN_STRING_INITIALIZER
11905 (struct cmd_vf_promisc_result,
11907 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
11908 TOKEN_STRING_INITIALIZER
11909 (struct cmd_vf_promisc_result,
11910 promisc, "promisc");
11911 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
11912 TOKEN_NUM_INITIALIZER
11913 (struct cmd_vf_promisc_result,
11915 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
11916 TOKEN_NUM_INITIALIZER
11917 (struct cmd_vf_promisc_result,
11919 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
11920 TOKEN_STRING_INITIALIZER
11921 (struct cmd_vf_promisc_result,
11925 cmd_set_vf_promisc_parsed(
11926 void *parsed_result,
11927 __rte_unused struct cmdline *cl,
11928 __rte_unused void *data)
11930 struct cmd_vf_promisc_result *res = parsed_result;
11931 int ret = -ENOTSUP;
11933 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11935 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11938 #ifdef RTE_NET_I40E
11939 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
11940 res->vf_id, is_on);
11947 printf("invalid vf_id %d\n", res->vf_id);
11950 printf("invalid port_id %d\n", res->port_id);
11953 printf("function not implemented\n");
11956 printf("programming error: (%s)\n", strerror(-ret));
11960 cmdline_parse_inst_t cmd_set_vf_promisc = {
11961 .f = cmd_set_vf_promisc_parsed,
11963 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
11964 "Set unicast promiscuous mode for a VF from the PF",
11966 (void *)&cmd_vf_promisc_set,
11967 (void *)&cmd_vf_promisc_vf,
11968 (void *)&cmd_vf_promisc_promisc,
11969 (void *)&cmd_vf_promisc_port_id,
11970 (void *)&cmd_vf_promisc_vf_id,
11971 (void *)&cmd_vf_promisc_on_off,
11976 /* VF multicast promiscuous mode configuration */
11978 /* Common result structure for VF multicast promiscuous mode */
11979 struct cmd_vf_allmulti_result {
11980 cmdline_fixed_string_t set;
11981 cmdline_fixed_string_t vf;
11982 cmdline_fixed_string_t allmulti;
11985 cmdline_fixed_string_t on_off;
11988 /* Common CLI fields for VF multicast promiscuous mode enable disable */
11989 cmdline_parse_token_string_t cmd_vf_allmulti_set =
11990 TOKEN_STRING_INITIALIZER
11991 (struct cmd_vf_allmulti_result,
11993 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
11994 TOKEN_STRING_INITIALIZER
11995 (struct cmd_vf_allmulti_result,
11997 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
11998 TOKEN_STRING_INITIALIZER
11999 (struct cmd_vf_allmulti_result,
12000 allmulti, "allmulti");
12001 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12002 TOKEN_NUM_INITIALIZER
12003 (struct cmd_vf_allmulti_result,
12005 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12006 TOKEN_NUM_INITIALIZER
12007 (struct cmd_vf_allmulti_result,
12009 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12010 TOKEN_STRING_INITIALIZER
12011 (struct cmd_vf_allmulti_result,
12015 cmd_set_vf_allmulti_parsed(
12016 void *parsed_result,
12017 __rte_unused struct cmdline *cl,
12018 __rte_unused void *data)
12020 struct cmd_vf_allmulti_result *res = parsed_result;
12021 int ret = -ENOTSUP;
12023 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12025 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12028 #ifdef RTE_NET_I40E
12029 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12030 res->vf_id, is_on);
12037 printf("invalid vf_id %d\n", res->vf_id);
12040 printf("invalid port_id %d\n", res->port_id);
12043 printf("function not implemented\n");
12046 printf("programming error: (%s)\n", strerror(-ret));
12050 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12051 .f = cmd_set_vf_allmulti_parsed,
12053 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12054 "Set multicast promiscuous mode for a VF from the PF",
12056 (void *)&cmd_vf_allmulti_set,
12057 (void *)&cmd_vf_allmulti_vf,
12058 (void *)&cmd_vf_allmulti_allmulti,
12059 (void *)&cmd_vf_allmulti_port_id,
12060 (void *)&cmd_vf_allmulti_vf_id,
12061 (void *)&cmd_vf_allmulti_on_off,
12066 /* vf broadcast mode configuration */
12068 /* Common result structure for vf broadcast */
12069 struct cmd_set_vf_broadcast_result {
12070 cmdline_fixed_string_t set;
12071 cmdline_fixed_string_t vf;
12072 cmdline_fixed_string_t broadcast;
12075 cmdline_fixed_string_t on_off;
12078 /* Common CLI fields for vf broadcast enable disable */
12079 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12080 TOKEN_STRING_INITIALIZER
12081 (struct cmd_set_vf_broadcast_result,
12083 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12084 TOKEN_STRING_INITIALIZER
12085 (struct cmd_set_vf_broadcast_result,
12087 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12088 TOKEN_STRING_INITIALIZER
12089 (struct cmd_set_vf_broadcast_result,
12090 broadcast, "broadcast");
12091 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12092 TOKEN_NUM_INITIALIZER
12093 (struct cmd_set_vf_broadcast_result,
12095 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12096 TOKEN_NUM_INITIALIZER
12097 (struct cmd_set_vf_broadcast_result,
12099 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12100 TOKEN_STRING_INITIALIZER
12101 (struct cmd_set_vf_broadcast_result,
12105 cmd_set_vf_broadcast_parsed(
12106 void *parsed_result,
12107 __rte_unused struct cmdline *cl,
12108 __rte_unused void *data)
12110 struct cmd_set_vf_broadcast_result *res = parsed_result;
12111 int ret = -ENOTSUP;
12113 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12115 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12118 #ifdef RTE_NET_I40E
12119 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12120 res->vf_id, is_on);
12127 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12130 printf("invalid port_id %d\n", res->port_id);
12133 printf("function not implemented\n");
12136 printf("programming error: (%s)\n", strerror(-ret));
12140 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12141 .f = cmd_set_vf_broadcast_parsed,
12143 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12145 (void *)&cmd_set_vf_broadcast_set,
12146 (void *)&cmd_set_vf_broadcast_vf,
12147 (void *)&cmd_set_vf_broadcast_broadcast,
12148 (void *)&cmd_set_vf_broadcast_port_id,
12149 (void *)&cmd_set_vf_broadcast_vf_id,
12150 (void *)&cmd_set_vf_broadcast_on_off,
12155 /* vf vlan tag configuration */
12157 /* Common result structure for vf vlan tag */
12158 struct cmd_set_vf_vlan_tag_result {
12159 cmdline_fixed_string_t set;
12160 cmdline_fixed_string_t vf;
12161 cmdline_fixed_string_t vlan;
12162 cmdline_fixed_string_t tag;
12165 cmdline_fixed_string_t on_off;
12168 /* Common CLI fields for vf vlan tag enable disable */
12169 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12170 TOKEN_STRING_INITIALIZER
12171 (struct cmd_set_vf_vlan_tag_result,
12173 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12174 TOKEN_STRING_INITIALIZER
12175 (struct cmd_set_vf_vlan_tag_result,
12177 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12178 TOKEN_STRING_INITIALIZER
12179 (struct cmd_set_vf_vlan_tag_result,
12181 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12182 TOKEN_STRING_INITIALIZER
12183 (struct cmd_set_vf_vlan_tag_result,
12185 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12186 TOKEN_NUM_INITIALIZER
12187 (struct cmd_set_vf_vlan_tag_result,
12189 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12190 TOKEN_NUM_INITIALIZER
12191 (struct cmd_set_vf_vlan_tag_result,
12193 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12194 TOKEN_STRING_INITIALIZER
12195 (struct cmd_set_vf_vlan_tag_result,
12199 cmd_set_vf_vlan_tag_parsed(
12200 void *parsed_result,
12201 __rte_unused struct cmdline *cl,
12202 __rte_unused void *data)
12204 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12205 int ret = -ENOTSUP;
12207 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12209 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12212 #ifdef RTE_NET_I40E
12213 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12214 res->vf_id, is_on);
12221 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12224 printf("invalid port_id %d\n", res->port_id);
12227 printf("function not implemented\n");
12230 printf("programming error: (%s)\n", strerror(-ret));
12234 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12235 .f = cmd_set_vf_vlan_tag_parsed,
12237 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12239 (void *)&cmd_set_vf_vlan_tag_set,
12240 (void *)&cmd_set_vf_vlan_tag_vf,
12241 (void *)&cmd_set_vf_vlan_tag_vlan,
12242 (void *)&cmd_set_vf_vlan_tag_tag,
12243 (void *)&cmd_set_vf_vlan_tag_port_id,
12244 (void *)&cmd_set_vf_vlan_tag_vf_id,
12245 (void *)&cmd_set_vf_vlan_tag_on_off,
12250 /* Common definition of VF and TC TX bandwidth configuration */
12251 struct cmd_vf_tc_bw_result {
12252 cmdline_fixed_string_t set;
12253 cmdline_fixed_string_t vf;
12254 cmdline_fixed_string_t tc;
12255 cmdline_fixed_string_t tx;
12256 cmdline_fixed_string_t min_bw;
12257 cmdline_fixed_string_t max_bw;
12258 cmdline_fixed_string_t strict_link_prio;
12263 cmdline_fixed_string_t bw_list;
12267 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12268 TOKEN_STRING_INITIALIZER
12269 (struct cmd_vf_tc_bw_result,
12271 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12272 TOKEN_STRING_INITIALIZER
12273 (struct cmd_vf_tc_bw_result,
12275 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12276 TOKEN_STRING_INITIALIZER
12277 (struct cmd_vf_tc_bw_result,
12279 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12280 TOKEN_STRING_INITIALIZER
12281 (struct cmd_vf_tc_bw_result,
12283 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12284 TOKEN_STRING_INITIALIZER
12285 (struct cmd_vf_tc_bw_result,
12286 strict_link_prio, "strict-link-priority");
12287 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12288 TOKEN_STRING_INITIALIZER
12289 (struct cmd_vf_tc_bw_result,
12290 min_bw, "min-bandwidth");
12291 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12292 TOKEN_STRING_INITIALIZER
12293 (struct cmd_vf_tc_bw_result,
12294 max_bw, "max-bandwidth");
12295 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12296 TOKEN_NUM_INITIALIZER
12297 (struct cmd_vf_tc_bw_result,
12299 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12300 TOKEN_NUM_INITIALIZER
12301 (struct cmd_vf_tc_bw_result,
12303 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12304 TOKEN_NUM_INITIALIZER
12305 (struct cmd_vf_tc_bw_result,
12307 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12308 TOKEN_NUM_INITIALIZER
12309 (struct cmd_vf_tc_bw_result,
12311 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12312 TOKEN_STRING_INITIALIZER
12313 (struct cmd_vf_tc_bw_result,
12315 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12316 TOKEN_NUM_INITIALIZER
12317 (struct cmd_vf_tc_bw_result,
12320 /* VF max bandwidth setting */
12322 cmd_vf_max_bw_parsed(
12323 void *parsed_result,
12324 __rte_unused struct cmdline *cl,
12325 __rte_unused void *data)
12327 struct cmd_vf_tc_bw_result *res = parsed_result;
12328 int ret = -ENOTSUP;
12330 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12333 #ifdef RTE_NET_I40E
12334 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12335 res->vf_id, res->bw);
12342 printf("invalid vf_id %d or bandwidth %d\n",
12343 res->vf_id, res->bw);
12346 printf("invalid port_id %d\n", res->port_id);
12349 printf("function not implemented\n");
12352 printf("programming error: (%s)\n", strerror(-ret));
12356 cmdline_parse_inst_t cmd_vf_max_bw = {
12357 .f = cmd_vf_max_bw_parsed,
12359 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12361 (void *)&cmd_vf_tc_bw_set,
12362 (void *)&cmd_vf_tc_bw_vf,
12363 (void *)&cmd_vf_tc_bw_tx,
12364 (void *)&cmd_vf_tc_bw_max_bw,
12365 (void *)&cmd_vf_tc_bw_port_id,
12366 (void *)&cmd_vf_tc_bw_vf_id,
12367 (void *)&cmd_vf_tc_bw_bw,
12373 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12378 const char *p, *p0 = str;
12385 p = strchr(p0, '(');
12387 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12391 p0 = strchr(p, ')');
12393 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12397 if (size >= sizeof(s)) {
12398 printf("The string size exceeds the internal buffer size\n");
12401 snprintf(s, sizeof(s), "%.*s", size, p);
12402 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12404 printf("Failed to get the bandwidth list. ");
12408 for (i = 0; i < ret; i++)
12409 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12414 /* TC min bandwidth setting */
12416 cmd_vf_tc_min_bw_parsed(
12417 void *parsed_result,
12418 __rte_unused struct cmdline *cl,
12419 __rte_unused void *data)
12421 struct cmd_vf_tc_bw_result *res = parsed_result;
12424 int ret = -ENOTSUP;
12426 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12429 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12433 #ifdef RTE_NET_I40E
12434 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12442 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12445 printf("invalid port_id %d\n", res->port_id);
12448 printf("function not implemented\n");
12451 printf("programming error: (%s)\n", strerror(-ret));
12455 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12456 .f = cmd_vf_tc_min_bw_parsed,
12458 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12459 " <bw1, bw2, ...>",
12461 (void *)&cmd_vf_tc_bw_set,
12462 (void *)&cmd_vf_tc_bw_vf,
12463 (void *)&cmd_vf_tc_bw_tc,
12464 (void *)&cmd_vf_tc_bw_tx,
12465 (void *)&cmd_vf_tc_bw_min_bw,
12466 (void *)&cmd_vf_tc_bw_port_id,
12467 (void *)&cmd_vf_tc_bw_vf_id,
12468 (void *)&cmd_vf_tc_bw_bw_list,
12474 cmd_tc_min_bw_parsed(
12475 void *parsed_result,
12476 __rte_unused struct cmdline *cl,
12477 __rte_unused void *data)
12479 struct cmd_vf_tc_bw_result *res = parsed_result;
12480 struct rte_port *port;
12483 int ret = -ENOTSUP;
12485 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12488 port = &ports[res->port_id];
12489 /** Check if the port is not started **/
12490 if (port->port_status != RTE_PORT_STOPPED) {
12491 printf("Please stop port %d first\n", res->port_id);
12495 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12499 #ifdef RTE_NET_IXGBE
12500 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12507 printf("invalid bandwidth\n");
12510 printf("invalid port_id %d\n", res->port_id);
12513 printf("function not implemented\n");
12516 printf("programming error: (%s)\n", strerror(-ret));
12520 cmdline_parse_inst_t cmd_tc_min_bw = {
12521 .f = cmd_tc_min_bw_parsed,
12523 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12525 (void *)&cmd_vf_tc_bw_set,
12526 (void *)&cmd_vf_tc_bw_tc,
12527 (void *)&cmd_vf_tc_bw_tx,
12528 (void *)&cmd_vf_tc_bw_min_bw,
12529 (void *)&cmd_vf_tc_bw_port_id,
12530 (void *)&cmd_vf_tc_bw_bw_list,
12535 /* TC max bandwidth setting */
12537 cmd_vf_tc_max_bw_parsed(
12538 void *parsed_result,
12539 __rte_unused struct cmdline *cl,
12540 __rte_unused void *data)
12542 struct cmd_vf_tc_bw_result *res = parsed_result;
12543 int ret = -ENOTSUP;
12545 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12548 #ifdef RTE_NET_I40E
12549 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12550 res->tc_no, res->bw);
12557 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
12558 res->vf_id, res->tc_no, res->bw);
12561 printf("invalid port_id %d\n", res->port_id);
12564 printf("function not implemented\n");
12567 printf("programming error: (%s)\n", strerror(-ret));
12571 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12572 .f = cmd_vf_tc_max_bw_parsed,
12574 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12577 (void *)&cmd_vf_tc_bw_set,
12578 (void *)&cmd_vf_tc_bw_vf,
12579 (void *)&cmd_vf_tc_bw_tc,
12580 (void *)&cmd_vf_tc_bw_tx,
12581 (void *)&cmd_vf_tc_bw_max_bw,
12582 (void *)&cmd_vf_tc_bw_port_id,
12583 (void *)&cmd_vf_tc_bw_vf_id,
12584 (void *)&cmd_vf_tc_bw_tc_no,
12585 (void *)&cmd_vf_tc_bw_bw,
12590 /** Set VXLAN encapsulation details */
12591 struct cmd_set_vxlan_result {
12592 cmdline_fixed_string_t set;
12593 cmdline_fixed_string_t vxlan;
12594 cmdline_fixed_string_t pos_token;
12595 cmdline_fixed_string_t ip_version;
12596 uint32_t vlan_present:1;
12600 cmdline_ipaddr_t ip_src;
12601 cmdline_ipaddr_t ip_dst;
12605 struct rte_ether_addr eth_src;
12606 struct rte_ether_addr eth_dst;
12609 cmdline_parse_token_string_t cmd_set_vxlan_set =
12610 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
12611 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
12612 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
12613 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
12614 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12616 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
12617 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12618 "vxlan-with-vlan");
12619 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
12620 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12622 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
12623 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
12625 cmdline_parse_token_string_t cmd_set_vxlan_vni =
12626 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12628 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
12629 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
12630 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
12631 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12633 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
12634 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
12635 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
12636 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12638 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
12639 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
12640 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
12641 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12643 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
12644 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
12645 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
12646 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12648 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
12649 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
12650 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
12651 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12653 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
12654 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
12655 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
12656 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12658 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
12659 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
12660 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
12661 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12663 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
12664 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
12665 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
12666 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12668 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
12669 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
12670 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
12671 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12673 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
12674 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
12676 static void cmd_set_vxlan_parsed(void *parsed_result,
12677 __rte_unused struct cmdline *cl,
12678 __rte_unused void *data)
12680 struct cmd_set_vxlan_result *res = parsed_result;
12685 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
12688 vxlan_encap_conf.select_tos_ttl = 0;
12689 if (strcmp(res->vxlan, "vxlan") == 0)
12690 vxlan_encap_conf.select_vlan = 0;
12691 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
12692 vxlan_encap_conf.select_vlan = 1;
12693 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
12694 vxlan_encap_conf.select_vlan = 0;
12695 vxlan_encap_conf.select_tos_ttl = 1;
12697 if (strcmp(res->ip_version, "ipv4") == 0)
12698 vxlan_encap_conf.select_ipv4 = 1;
12699 else if (strcmp(res->ip_version, "ipv6") == 0)
12700 vxlan_encap_conf.select_ipv4 = 0;
12703 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
12704 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
12705 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
12706 vxlan_encap_conf.ip_tos = res->tos;
12707 vxlan_encap_conf.ip_ttl = res->ttl;
12708 if (vxlan_encap_conf.select_ipv4) {
12709 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
12710 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
12712 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
12713 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
12715 if (vxlan_encap_conf.select_vlan)
12716 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
12717 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
12718 RTE_ETHER_ADDR_LEN);
12719 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
12720 RTE_ETHER_ADDR_LEN);
12723 cmdline_parse_inst_t cmd_set_vxlan = {
12724 .f = cmd_set_vxlan_parsed,
12726 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
12727 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
12728 " eth-src <eth-src> eth-dst <eth-dst>",
12730 (void *)&cmd_set_vxlan_set,
12731 (void *)&cmd_set_vxlan_vxlan,
12732 (void *)&cmd_set_vxlan_ip_version,
12733 (void *)&cmd_set_vxlan_ip_version_value,
12734 (void *)&cmd_set_vxlan_vni,
12735 (void *)&cmd_set_vxlan_vni_value,
12736 (void *)&cmd_set_vxlan_udp_src,
12737 (void *)&cmd_set_vxlan_udp_src_value,
12738 (void *)&cmd_set_vxlan_udp_dst,
12739 (void *)&cmd_set_vxlan_udp_dst_value,
12740 (void *)&cmd_set_vxlan_ip_src,
12741 (void *)&cmd_set_vxlan_ip_src_value,
12742 (void *)&cmd_set_vxlan_ip_dst,
12743 (void *)&cmd_set_vxlan_ip_dst_value,
12744 (void *)&cmd_set_vxlan_eth_src,
12745 (void *)&cmd_set_vxlan_eth_src_value,
12746 (void *)&cmd_set_vxlan_eth_dst,
12747 (void *)&cmd_set_vxlan_eth_dst_value,
12752 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
12753 .f = cmd_set_vxlan_parsed,
12755 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
12756 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
12757 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
12758 " eth-dst <eth-dst>",
12760 (void *)&cmd_set_vxlan_set,
12761 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
12762 (void *)&cmd_set_vxlan_ip_version,
12763 (void *)&cmd_set_vxlan_ip_version_value,
12764 (void *)&cmd_set_vxlan_vni,
12765 (void *)&cmd_set_vxlan_vni_value,
12766 (void *)&cmd_set_vxlan_udp_src,
12767 (void *)&cmd_set_vxlan_udp_src_value,
12768 (void *)&cmd_set_vxlan_udp_dst,
12769 (void *)&cmd_set_vxlan_udp_dst_value,
12770 (void *)&cmd_set_vxlan_ip_tos,
12771 (void *)&cmd_set_vxlan_ip_tos_value,
12772 (void *)&cmd_set_vxlan_ip_ttl,
12773 (void *)&cmd_set_vxlan_ip_ttl_value,
12774 (void *)&cmd_set_vxlan_ip_src,
12775 (void *)&cmd_set_vxlan_ip_src_value,
12776 (void *)&cmd_set_vxlan_ip_dst,
12777 (void *)&cmd_set_vxlan_ip_dst_value,
12778 (void *)&cmd_set_vxlan_eth_src,
12779 (void *)&cmd_set_vxlan_eth_src_value,
12780 (void *)&cmd_set_vxlan_eth_dst,
12781 (void *)&cmd_set_vxlan_eth_dst_value,
12786 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
12787 .f = cmd_set_vxlan_parsed,
12789 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
12790 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
12791 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
12794 (void *)&cmd_set_vxlan_set,
12795 (void *)&cmd_set_vxlan_vxlan_with_vlan,
12796 (void *)&cmd_set_vxlan_ip_version,
12797 (void *)&cmd_set_vxlan_ip_version_value,
12798 (void *)&cmd_set_vxlan_vni,
12799 (void *)&cmd_set_vxlan_vni_value,
12800 (void *)&cmd_set_vxlan_udp_src,
12801 (void *)&cmd_set_vxlan_udp_src_value,
12802 (void *)&cmd_set_vxlan_udp_dst,
12803 (void *)&cmd_set_vxlan_udp_dst_value,
12804 (void *)&cmd_set_vxlan_ip_src,
12805 (void *)&cmd_set_vxlan_ip_src_value,
12806 (void *)&cmd_set_vxlan_ip_dst,
12807 (void *)&cmd_set_vxlan_ip_dst_value,
12808 (void *)&cmd_set_vxlan_vlan,
12809 (void *)&cmd_set_vxlan_vlan_value,
12810 (void *)&cmd_set_vxlan_eth_src,
12811 (void *)&cmd_set_vxlan_eth_src_value,
12812 (void *)&cmd_set_vxlan_eth_dst,
12813 (void *)&cmd_set_vxlan_eth_dst_value,
12818 /** Set NVGRE encapsulation details */
12819 struct cmd_set_nvgre_result {
12820 cmdline_fixed_string_t set;
12821 cmdline_fixed_string_t nvgre;
12822 cmdline_fixed_string_t pos_token;
12823 cmdline_fixed_string_t ip_version;
12825 cmdline_ipaddr_t ip_src;
12826 cmdline_ipaddr_t ip_dst;
12828 struct rte_ether_addr eth_src;
12829 struct rte_ether_addr eth_dst;
12832 cmdline_parse_token_string_t cmd_set_nvgre_set =
12833 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
12834 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
12835 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
12836 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
12837 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
12838 "nvgre-with-vlan");
12839 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
12840 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12842 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
12843 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
12845 cmdline_parse_token_string_t cmd_set_nvgre_tni =
12846 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12848 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
12849 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
12850 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
12851 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12853 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
12854 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
12855 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
12856 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12858 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
12859 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
12860 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
12861 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12863 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
12864 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
12865 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
12866 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12868 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
12869 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
12870 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
12871 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12873 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
12874 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
12876 static void cmd_set_nvgre_parsed(void *parsed_result,
12877 __rte_unused struct cmdline *cl,
12878 __rte_unused void *data)
12880 struct cmd_set_nvgre_result *res = parsed_result;
12882 uint32_t nvgre_tni;
12885 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
12888 if (strcmp(res->nvgre, "nvgre") == 0)
12889 nvgre_encap_conf.select_vlan = 0;
12890 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
12891 nvgre_encap_conf.select_vlan = 1;
12892 if (strcmp(res->ip_version, "ipv4") == 0)
12893 nvgre_encap_conf.select_ipv4 = 1;
12894 else if (strcmp(res->ip_version, "ipv6") == 0)
12895 nvgre_encap_conf.select_ipv4 = 0;
12898 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
12899 if (nvgre_encap_conf.select_ipv4) {
12900 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
12901 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
12903 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
12904 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
12906 if (nvgre_encap_conf.select_vlan)
12907 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
12908 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
12909 RTE_ETHER_ADDR_LEN);
12910 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
12911 RTE_ETHER_ADDR_LEN);
12914 cmdline_parse_inst_t cmd_set_nvgre = {
12915 .f = cmd_set_nvgre_parsed,
12917 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
12918 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
12919 " eth-dst <eth-dst>",
12921 (void *)&cmd_set_nvgre_set,
12922 (void *)&cmd_set_nvgre_nvgre,
12923 (void *)&cmd_set_nvgre_ip_version,
12924 (void *)&cmd_set_nvgre_ip_version_value,
12925 (void *)&cmd_set_nvgre_tni,
12926 (void *)&cmd_set_nvgre_tni_value,
12927 (void *)&cmd_set_nvgre_ip_src,
12928 (void *)&cmd_set_nvgre_ip_src_value,
12929 (void *)&cmd_set_nvgre_ip_dst,
12930 (void *)&cmd_set_nvgre_ip_dst_value,
12931 (void *)&cmd_set_nvgre_eth_src,
12932 (void *)&cmd_set_nvgre_eth_src_value,
12933 (void *)&cmd_set_nvgre_eth_dst,
12934 (void *)&cmd_set_nvgre_eth_dst_value,
12939 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
12940 .f = cmd_set_nvgre_parsed,
12942 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
12943 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
12944 " eth-src <eth-src> eth-dst <eth-dst>",
12946 (void *)&cmd_set_nvgre_set,
12947 (void *)&cmd_set_nvgre_nvgre_with_vlan,
12948 (void *)&cmd_set_nvgre_ip_version,
12949 (void *)&cmd_set_nvgre_ip_version_value,
12950 (void *)&cmd_set_nvgre_tni,
12951 (void *)&cmd_set_nvgre_tni_value,
12952 (void *)&cmd_set_nvgre_ip_src,
12953 (void *)&cmd_set_nvgre_ip_src_value,
12954 (void *)&cmd_set_nvgre_ip_dst,
12955 (void *)&cmd_set_nvgre_ip_dst_value,
12956 (void *)&cmd_set_nvgre_vlan,
12957 (void *)&cmd_set_nvgre_vlan_value,
12958 (void *)&cmd_set_nvgre_eth_src,
12959 (void *)&cmd_set_nvgre_eth_src_value,
12960 (void *)&cmd_set_nvgre_eth_dst,
12961 (void *)&cmd_set_nvgre_eth_dst_value,
12966 /** Set L2 encapsulation details */
12967 struct cmd_set_l2_encap_result {
12968 cmdline_fixed_string_t set;
12969 cmdline_fixed_string_t l2_encap;
12970 cmdline_fixed_string_t pos_token;
12971 cmdline_fixed_string_t ip_version;
12972 uint32_t vlan_present:1;
12974 struct rte_ether_addr eth_src;
12975 struct rte_ether_addr eth_dst;
12978 cmdline_parse_token_string_t cmd_set_l2_encap_set =
12979 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
12980 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
12981 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
12982 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
12983 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
12984 "l2_encap-with-vlan");
12985 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
12986 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
12988 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
12989 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
12991 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
12992 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
12994 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
12995 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
12996 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
12997 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
12999 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13000 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13001 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13002 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13004 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13005 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13007 static void cmd_set_l2_encap_parsed(void *parsed_result,
13008 __rte_unused struct cmdline *cl,
13009 __rte_unused void *data)
13011 struct cmd_set_l2_encap_result *res = parsed_result;
13013 if (strcmp(res->l2_encap, "l2_encap") == 0)
13014 l2_encap_conf.select_vlan = 0;
13015 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13016 l2_encap_conf.select_vlan = 1;
13017 if (strcmp(res->ip_version, "ipv4") == 0)
13018 l2_encap_conf.select_ipv4 = 1;
13019 else if (strcmp(res->ip_version, "ipv6") == 0)
13020 l2_encap_conf.select_ipv4 = 0;
13023 if (l2_encap_conf.select_vlan)
13024 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13025 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13026 RTE_ETHER_ADDR_LEN);
13027 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13028 RTE_ETHER_ADDR_LEN);
13031 cmdline_parse_inst_t cmd_set_l2_encap = {
13032 .f = cmd_set_l2_encap_parsed,
13034 .help_str = "set l2_encap ip-version ipv4|ipv6"
13035 " eth-src <eth-src> eth-dst <eth-dst>",
13037 (void *)&cmd_set_l2_encap_set,
13038 (void *)&cmd_set_l2_encap_l2_encap,
13039 (void *)&cmd_set_l2_encap_ip_version,
13040 (void *)&cmd_set_l2_encap_ip_version_value,
13041 (void *)&cmd_set_l2_encap_eth_src,
13042 (void *)&cmd_set_l2_encap_eth_src_value,
13043 (void *)&cmd_set_l2_encap_eth_dst,
13044 (void *)&cmd_set_l2_encap_eth_dst_value,
13049 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13050 .f = cmd_set_l2_encap_parsed,
13052 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13053 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13055 (void *)&cmd_set_l2_encap_set,
13056 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13057 (void *)&cmd_set_l2_encap_ip_version,
13058 (void *)&cmd_set_l2_encap_ip_version_value,
13059 (void *)&cmd_set_l2_encap_vlan,
13060 (void *)&cmd_set_l2_encap_vlan_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 /** Set L2 decapsulation details */
13070 struct cmd_set_l2_decap_result {
13071 cmdline_fixed_string_t set;
13072 cmdline_fixed_string_t l2_decap;
13073 cmdline_fixed_string_t pos_token;
13074 uint32_t vlan_present:1;
13077 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13078 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13079 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13080 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13082 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13083 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13084 "l2_decap-with-vlan");
13086 static void cmd_set_l2_decap_parsed(void *parsed_result,
13087 __rte_unused struct cmdline *cl,
13088 __rte_unused void *data)
13090 struct cmd_set_l2_decap_result *res = parsed_result;
13092 if (strcmp(res->l2_decap, "l2_decap") == 0)
13093 l2_decap_conf.select_vlan = 0;
13094 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13095 l2_decap_conf.select_vlan = 1;
13098 cmdline_parse_inst_t cmd_set_l2_decap = {
13099 .f = cmd_set_l2_decap_parsed,
13101 .help_str = "set l2_decap",
13103 (void *)&cmd_set_l2_decap_set,
13104 (void *)&cmd_set_l2_decap_l2_decap,
13109 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13110 .f = cmd_set_l2_decap_parsed,
13112 .help_str = "set l2_decap-with-vlan",
13114 (void *)&cmd_set_l2_decap_set,
13115 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13120 /** Set MPLSoGRE encapsulation details */
13121 struct cmd_set_mplsogre_encap_result {
13122 cmdline_fixed_string_t set;
13123 cmdline_fixed_string_t mplsogre;
13124 cmdline_fixed_string_t pos_token;
13125 cmdline_fixed_string_t ip_version;
13126 uint32_t vlan_present:1;
13128 cmdline_ipaddr_t ip_src;
13129 cmdline_ipaddr_t ip_dst;
13131 struct rte_ether_addr eth_src;
13132 struct rte_ether_addr eth_dst;
13135 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13136 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13138 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13139 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13141 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13142 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13143 mplsogre, "mplsogre_encap-with-vlan");
13144 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13145 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13146 pos_token, "ip-version");
13147 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13148 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13149 ip_version, "ipv4#ipv6");
13150 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13151 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13152 pos_token, "label");
13153 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13154 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13156 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13157 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13158 pos_token, "ip-src");
13159 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13160 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13161 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13162 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13163 pos_token, "ip-dst");
13164 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13165 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13166 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13167 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13168 pos_token, "vlan-tci");
13169 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13170 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13172 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13173 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13174 pos_token, "eth-src");
13175 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13176 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13178 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13179 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13180 pos_token, "eth-dst");
13181 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13182 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13185 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13186 __rte_unused struct cmdline *cl,
13187 __rte_unused void *data)
13189 struct cmd_set_mplsogre_encap_result *res = parsed_result;
13191 uint32_t mplsogre_label;
13194 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13197 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13198 mplsogre_encap_conf.select_vlan = 0;
13199 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13200 mplsogre_encap_conf.select_vlan = 1;
13201 if (strcmp(res->ip_version, "ipv4") == 0)
13202 mplsogre_encap_conf.select_ipv4 = 1;
13203 else if (strcmp(res->ip_version, "ipv6") == 0)
13204 mplsogre_encap_conf.select_ipv4 = 0;
13207 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13208 if (mplsogre_encap_conf.select_ipv4) {
13209 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13210 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13212 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13213 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13215 if (mplsogre_encap_conf.select_vlan)
13216 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13217 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13218 RTE_ETHER_ADDR_LEN);
13219 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13220 RTE_ETHER_ADDR_LEN);
13223 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13224 .f = cmd_set_mplsogre_encap_parsed,
13226 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13227 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13228 " eth-dst <eth-dst>",
13230 (void *)&cmd_set_mplsogre_encap_set,
13231 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13232 (void *)&cmd_set_mplsogre_encap_ip_version,
13233 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13234 (void *)&cmd_set_mplsogre_encap_label,
13235 (void *)&cmd_set_mplsogre_encap_label_value,
13236 (void *)&cmd_set_mplsogre_encap_ip_src,
13237 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13238 (void *)&cmd_set_mplsogre_encap_ip_dst,
13239 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13240 (void *)&cmd_set_mplsogre_encap_eth_src,
13241 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13242 (void *)&cmd_set_mplsogre_encap_eth_dst,
13243 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13248 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13249 .f = cmd_set_mplsogre_encap_parsed,
13251 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13252 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
13253 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13255 (void *)&cmd_set_mplsogre_encap_set,
13256 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13257 (void *)&cmd_set_mplsogre_encap_ip_version,
13258 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13259 (void *)&cmd_set_mplsogre_encap_label,
13260 (void *)&cmd_set_mplsogre_encap_label_value,
13261 (void *)&cmd_set_mplsogre_encap_ip_src,
13262 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13263 (void *)&cmd_set_mplsogre_encap_ip_dst,
13264 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13265 (void *)&cmd_set_mplsogre_encap_vlan,
13266 (void *)&cmd_set_mplsogre_encap_vlan_value,
13267 (void *)&cmd_set_mplsogre_encap_eth_src,
13268 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13269 (void *)&cmd_set_mplsogre_encap_eth_dst,
13270 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13275 /** Set MPLSoGRE decapsulation details */
13276 struct cmd_set_mplsogre_decap_result {
13277 cmdline_fixed_string_t set;
13278 cmdline_fixed_string_t mplsogre;
13279 cmdline_fixed_string_t pos_token;
13280 cmdline_fixed_string_t ip_version;
13281 uint32_t vlan_present:1;
13284 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13285 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13287 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13288 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13290 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13291 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13292 mplsogre, "mplsogre_decap-with-vlan");
13293 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13294 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13295 pos_token, "ip-version");
13296 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13297 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13298 ip_version, "ipv4#ipv6");
13300 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13301 __rte_unused struct cmdline *cl,
13302 __rte_unused void *data)
13304 struct cmd_set_mplsogre_decap_result *res = parsed_result;
13306 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13307 mplsogre_decap_conf.select_vlan = 0;
13308 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13309 mplsogre_decap_conf.select_vlan = 1;
13310 if (strcmp(res->ip_version, "ipv4") == 0)
13311 mplsogre_decap_conf.select_ipv4 = 1;
13312 else if (strcmp(res->ip_version, "ipv6") == 0)
13313 mplsogre_decap_conf.select_ipv4 = 0;
13316 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13317 .f = cmd_set_mplsogre_decap_parsed,
13319 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13321 (void *)&cmd_set_mplsogre_decap_set,
13322 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13323 (void *)&cmd_set_mplsogre_decap_ip_version,
13324 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13329 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13330 .f = cmd_set_mplsogre_decap_parsed,
13332 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13334 (void *)&cmd_set_mplsogre_decap_set,
13335 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13336 (void *)&cmd_set_mplsogre_decap_ip_version,
13337 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13342 /** Set MPLSoUDP encapsulation details */
13343 struct cmd_set_mplsoudp_encap_result {
13344 cmdline_fixed_string_t set;
13345 cmdline_fixed_string_t mplsoudp;
13346 cmdline_fixed_string_t pos_token;
13347 cmdline_fixed_string_t ip_version;
13348 uint32_t vlan_present:1;
13352 cmdline_ipaddr_t ip_src;
13353 cmdline_ipaddr_t ip_dst;
13355 struct rte_ether_addr eth_src;
13356 struct rte_ether_addr eth_dst;
13359 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13360 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13362 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13363 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13365 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13366 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13367 mplsoudp, "mplsoudp_encap-with-vlan");
13368 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13369 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13370 pos_token, "ip-version");
13371 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13372 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13373 ip_version, "ipv4#ipv6");
13374 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13375 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13376 pos_token, "label");
13377 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13378 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13380 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13381 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13382 pos_token, "udp-src");
13383 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13384 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13386 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13387 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13388 pos_token, "udp-dst");
13389 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13390 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13392 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13393 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13394 pos_token, "ip-src");
13395 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13396 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13397 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13398 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13399 pos_token, "ip-dst");
13400 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13401 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13402 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13403 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13404 pos_token, "vlan-tci");
13405 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13406 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13408 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13409 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13410 pos_token, "eth-src");
13411 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13412 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13414 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13415 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13416 pos_token, "eth-dst");
13417 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13418 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13421 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13422 __rte_unused struct cmdline *cl,
13423 __rte_unused void *data)
13425 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13427 uint32_t mplsoudp_label;
13430 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13433 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13434 mplsoudp_encap_conf.select_vlan = 0;
13435 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13436 mplsoudp_encap_conf.select_vlan = 1;
13437 if (strcmp(res->ip_version, "ipv4") == 0)
13438 mplsoudp_encap_conf.select_ipv4 = 1;
13439 else if (strcmp(res->ip_version, "ipv6") == 0)
13440 mplsoudp_encap_conf.select_ipv4 = 0;
13443 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13444 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13445 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13446 if (mplsoudp_encap_conf.select_ipv4) {
13447 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13448 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13450 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13451 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13453 if (mplsoudp_encap_conf.select_vlan)
13454 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13455 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13456 RTE_ETHER_ADDR_LEN);
13457 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13458 RTE_ETHER_ADDR_LEN);
13461 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13462 .f = cmd_set_mplsoudp_encap_parsed,
13464 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13465 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13466 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13468 (void *)&cmd_set_mplsoudp_encap_set,
13469 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13470 (void *)&cmd_set_mplsoudp_encap_ip_version,
13471 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13472 (void *)&cmd_set_mplsoudp_encap_label,
13473 (void *)&cmd_set_mplsoudp_encap_label_value,
13474 (void *)&cmd_set_mplsoudp_encap_udp_src,
13475 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13476 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13477 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13478 (void *)&cmd_set_mplsoudp_encap_ip_src,
13479 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13480 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13481 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13482 (void *)&cmd_set_mplsoudp_encap_eth_src,
13483 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13484 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13485 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13490 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13491 .f = cmd_set_mplsoudp_encap_parsed,
13493 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13494 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
13495 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13496 " eth-src <eth-src> eth-dst <eth-dst>",
13498 (void *)&cmd_set_mplsoudp_encap_set,
13499 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13500 (void *)&cmd_set_mplsoudp_encap_ip_version,
13501 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13502 (void *)&cmd_set_mplsoudp_encap_label,
13503 (void *)&cmd_set_mplsoudp_encap_label_value,
13504 (void *)&cmd_set_mplsoudp_encap_udp_src,
13505 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13506 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13507 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13508 (void *)&cmd_set_mplsoudp_encap_ip_src,
13509 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13510 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13511 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13512 (void *)&cmd_set_mplsoudp_encap_vlan,
13513 (void *)&cmd_set_mplsoudp_encap_vlan_value,
13514 (void *)&cmd_set_mplsoudp_encap_eth_src,
13515 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13516 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13517 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13522 /** Set MPLSoUDP decapsulation details */
13523 struct cmd_set_mplsoudp_decap_result {
13524 cmdline_fixed_string_t set;
13525 cmdline_fixed_string_t mplsoudp;
13526 cmdline_fixed_string_t pos_token;
13527 cmdline_fixed_string_t ip_version;
13528 uint32_t vlan_present:1;
13531 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
13532 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
13534 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
13535 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
13537 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
13538 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13539 mplsoudp, "mplsoudp_decap-with-vlan");
13540 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
13541 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13542 pos_token, "ip-version");
13543 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
13544 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13545 ip_version, "ipv4#ipv6");
13547 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
13548 __rte_unused struct cmdline *cl,
13549 __rte_unused void *data)
13551 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
13553 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
13554 mplsoudp_decap_conf.select_vlan = 0;
13555 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
13556 mplsoudp_decap_conf.select_vlan = 1;
13557 if (strcmp(res->ip_version, "ipv4") == 0)
13558 mplsoudp_decap_conf.select_ipv4 = 1;
13559 else if (strcmp(res->ip_version, "ipv6") == 0)
13560 mplsoudp_decap_conf.select_ipv4 = 0;
13563 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
13564 .f = cmd_set_mplsoudp_decap_parsed,
13566 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
13568 (void *)&cmd_set_mplsoudp_decap_set,
13569 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
13570 (void *)&cmd_set_mplsoudp_decap_ip_version,
13571 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13576 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
13577 .f = cmd_set_mplsoudp_decap_parsed,
13579 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
13581 (void *)&cmd_set_mplsoudp_decap_set,
13582 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
13583 (void *)&cmd_set_mplsoudp_decap_ip_version,
13584 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13589 /* Strict link priority scheduling mode setting */
13591 cmd_strict_link_prio_parsed(
13592 void *parsed_result,
13593 __rte_unused struct cmdline *cl,
13594 __rte_unused void *data)
13596 struct cmd_vf_tc_bw_result *res = parsed_result;
13597 int ret = -ENOTSUP;
13599 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13602 #ifdef RTE_NET_I40E
13603 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
13610 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
13613 printf("invalid port_id %d\n", res->port_id);
13616 printf("function not implemented\n");
13619 printf("programming error: (%s)\n", strerror(-ret));
13623 cmdline_parse_inst_t cmd_strict_link_prio = {
13624 .f = cmd_strict_link_prio_parsed,
13626 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
13628 (void *)&cmd_vf_tc_bw_set,
13629 (void *)&cmd_vf_tc_bw_tx,
13630 (void *)&cmd_vf_tc_bw_strict_link_prio,
13631 (void *)&cmd_vf_tc_bw_port_id,
13632 (void *)&cmd_vf_tc_bw_tc_map,
13637 /* Load dynamic device personalization*/
13638 struct cmd_ddp_add_result {
13639 cmdline_fixed_string_t ddp;
13640 cmdline_fixed_string_t add;
13645 cmdline_parse_token_string_t cmd_ddp_add_ddp =
13646 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
13647 cmdline_parse_token_string_t cmd_ddp_add_add =
13648 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
13649 cmdline_parse_token_num_t cmd_ddp_add_port_id =
13650 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
13651 cmdline_parse_token_string_t cmd_ddp_add_filepath =
13652 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
13655 cmd_ddp_add_parsed(
13656 void *parsed_result,
13657 __rte_unused struct cmdline *cl,
13658 __rte_unused void *data)
13660 struct cmd_ddp_add_result *res = parsed_result;
13666 int ret = -ENOTSUP;
13668 if (!all_ports_stopped()) {
13669 printf("Please stop all ports first\n");
13673 filepath = strdup(res->filepath);
13674 if (filepath == NULL) {
13675 printf("Failed to allocate memory\n");
13678 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
13680 buff = open_file(file_fld[0], &size);
13682 free((void *)filepath);
13686 #ifdef RTE_NET_I40E
13687 if (ret == -ENOTSUP)
13688 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13690 RTE_PMD_I40E_PKG_OP_WR_ADD);
13693 if (ret == -EEXIST)
13694 printf("Profile has already existed.\n");
13696 printf("Failed to load profile.\n");
13697 else if (file_num == 2)
13698 save_file(file_fld[1], buff, size);
13701 free((void *)filepath);
13704 cmdline_parse_inst_t cmd_ddp_add = {
13705 .f = cmd_ddp_add_parsed,
13707 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
13709 (void *)&cmd_ddp_add_ddp,
13710 (void *)&cmd_ddp_add_add,
13711 (void *)&cmd_ddp_add_port_id,
13712 (void *)&cmd_ddp_add_filepath,
13717 /* Delete dynamic device personalization*/
13718 struct cmd_ddp_del_result {
13719 cmdline_fixed_string_t ddp;
13720 cmdline_fixed_string_t del;
13725 cmdline_parse_token_string_t cmd_ddp_del_ddp =
13726 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
13727 cmdline_parse_token_string_t cmd_ddp_del_del =
13728 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
13729 cmdline_parse_token_num_t cmd_ddp_del_port_id =
13730 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
13731 cmdline_parse_token_string_t cmd_ddp_del_filepath =
13732 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
13735 cmd_ddp_del_parsed(
13736 void *parsed_result,
13737 __rte_unused struct cmdline *cl,
13738 __rte_unused void *data)
13740 struct cmd_ddp_del_result *res = parsed_result;
13743 int ret = -ENOTSUP;
13745 if (!all_ports_stopped()) {
13746 printf("Please stop all ports first\n");
13750 buff = open_file(res->filepath, &size);
13754 #ifdef RTE_NET_I40E
13755 if (ret == -ENOTSUP)
13756 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13758 RTE_PMD_I40E_PKG_OP_WR_DEL);
13761 if (ret == -EACCES)
13762 printf("Profile does not exist.\n");
13764 printf("Failed to delete profile.\n");
13769 cmdline_parse_inst_t cmd_ddp_del = {
13770 .f = cmd_ddp_del_parsed,
13772 .help_str = "ddp del <port_id> <backup_profile_path>",
13774 (void *)&cmd_ddp_del_ddp,
13775 (void *)&cmd_ddp_del_del,
13776 (void *)&cmd_ddp_del_port_id,
13777 (void *)&cmd_ddp_del_filepath,
13782 /* Get dynamic device personalization profile info */
13783 struct cmd_ddp_info_result {
13784 cmdline_fixed_string_t ddp;
13785 cmdline_fixed_string_t get;
13786 cmdline_fixed_string_t info;
13790 cmdline_parse_token_string_t cmd_ddp_info_ddp =
13791 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
13792 cmdline_parse_token_string_t cmd_ddp_info_get =
13793 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
13794 cmdline_parse_token_string_t cmd_ddp_info_info =
13795 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
13796 cmdline_parse_token_string_t cmd_ddp_info_filepath =
13797 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
13800 cmd_ddp_info_parsed(
13801 void *parsed_result,
13802 __rte_unused struct cmdline *cl,
13803 __rte_unused void *data)
13805 struct cmd_ddp_info_result *res = parsed_result;
13808 int ret = -ENOTSUP;
13809 #ifdef RTE_NET_I40E
13812 uint32_t buff_size = 0;
13813 struct rte_pmd_i40e_profile_info info;
13814 uint32_t dev_num = 0;
13815 struct rte_pmd_i40e_ddp_device_id *devs;
13816 uint32_t proto_num = 0;
13817 struct rte_pmd_i40e_proto_info *proto = NULL;
13818 uint32_t pctype_num = 0;
13819 struct rte_pmd_i40e_ptype_info *pctype;
13820 uint32_t ptype_num = 0;
13821 struct rte_pmd_i40e_ptype_info *ptype;
13826 pkg = open_file(res->filepath, &pkg_size);
13830 #ifdef RTE_NET_I40E
13831 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13832 (uint8_t *)&info, sizeof(info),
13833 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
13835 printf("Global Track id: 0x%x\n", info.track_id);
13836 printf("Global Version: %d.%d.%d.%d\n",
13837 info.version.major,
13838 info.version.minor,
13839 info.version.update,
13840 info.version.draft);
13841 printf("Global Package name: %s\n\n", info.name);
13844 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13845 (uint8_t *)&info, sizeof(info),
13846 RTE_PMD_I40E_PKG_INFO_HEADER);
13848 printf("i40e Profile Track id: 0x%x\n", info.track_id);
13849 printf("i40e Profile Version: %d.%d.%d.%d\n",
13850 info.version.major,
13851 info.version.minor,
13852 info.version.update,
13853 info.version.draft);
13854 printf("i40e Profile name: %s\n\n", info.name);
13857 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13858 (uint8_t *)&buff_size, sizeof(buff_size),
13859 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
13860 if (!ret && buff_size) {
13861 buff = (uint8_t *)malloc(buff_size);
13863 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13865 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
13867 printf("Package Notes:\n%s\n\n", buff);
13872 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13873 (uint8_t *)&dev_num, sizeof(dev_num),
13874 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
13875 if (!ret && dev_num) {
13876 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
13877 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
13879 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13880 (uint8_t *)devs, buff_size,
13881 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
13883 printf("List of supported devices:\n");
13884 for (i = 0; i < dev_num; i++) {
13885 printf(" %04X:%04X %04X:%04X\n",
13886 devs[i].vendor_dev_id >> 16,
13887 devs[i].vendor_dev_id & 0xFFFF,
13888 devs[i].sub_vendor_dev_id >> 16,
13889 devs[i].sub_vendor_dev_id & 0xFFFF);
13897 /* get information about protocols and packet types */
13898 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13899 (uint8_t *)&proto_num, sizeof(proto_num),
13900 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
13901 if (ret || !proto_num)
13902 goto no_print_return;
13904 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
13905 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
13907 goto no_print_return;
13909 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
13911 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
13913 printf("List of used protocols:\n");
13914 for (i = 0; i < proto_num; i++)
13915 printf(" %2u: %s\n", proto[i].proto_id,
13919 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13920 (uint8_t *)&pctype_num, sizeof(pctype_num),
13921 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
13922 if (ret || !pctype_num)
13923 goto no_print_pctypes;
13925 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
13926 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
13928 goto no_print_pctypes;
13930 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
13932 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
13935 goto no_print_pctypes;
13938 printf("List of defined packet classification types:\n");
13939 for (i = 0; i < pctype_num; i++) {
13940 printf(" %2u:", pctype[i].ptype_id);
13941 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
13942 proto_id = pctype[i].protocols[j];
13943 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
13944 for (n = 0; n < proto_num; n++) {
13945 if (proto[n].proto_id == proto_id) {
13946 printf(" %s", proto[n].name);
13959 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
13961 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
13962 if (ret || !ptype_num)
13963 goto no_print_return;
13965 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
13966 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
13968 goto no_print_return;
13970 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
13972 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
13975 goto no_print_return;
13977 printf("List of defined packet types:\n");
13978 for (i = 0; i < ptype_num; i++) {
13979 printf(" %2u:", ptype[i].ptype_id);
13980 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
13981 proto_id = ptype[i].protocols[j];
13982 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
13983 for (n = 0; n < proto_num; n++) {
13984 if (proto[n].proto_id == proto_id) {
13985 printf(" %s", proto[n].name);
14001 if (ret == -ENOTSUP)
14002 printf("Function not supported in PMD driver\n");
14006 cmdline_parse_inst_t cmd_ddp_get_info = {
14007 .f = cmd_ddp_info_parsed,
14009 .help_str = "ddp get info <profile_path>",
14011 (void *)&cmd_ddp_info_ddp,
14012 (void *)&cmd_ddp_info_get,
14013 (void *)&cmd_ddp_info_info,
14014 (void *)&cmd_ddp_info_filepath,
14019 /* Get dynamic device personalization profile info list*/
14020 #define PROFILE_INFO_SIZE 48
14021 #define MAX_PROFILE_NUM 16
14023 struct cmd_ddp_get_list_result {
14024 cmdline_fixed_string_t ddp;
14025 cmdline_fixed_string_t get;
14026 cmdline_fixed_string_t list;
14030 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14031 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14032 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14033 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14034 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14035 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14036 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14037 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
14040 cmd_ddp_get_list_parsed(
14041 __rte_unused void *parsed_result,
14042 __rte_unused struct cmdline *cl,
14043 __rte_unused void *data)
14045 #ifdef RTE_NET_I40E
14046 struct cmd_ddp_get_list_result *res = parsed_result;
14047 struct rte_pmd_i40e_profile_list *p_list;
14048 struct rte_pmd_i40e_profile_info *p_info;
14053 int ret = -ENOTSUP;
14055 #ifdef RTE_NET_I40E
14056 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14057 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14059 printf("%s: Failed to malloc buffer\n", __func__);
14063 if (ret == -ENOTSUP)
14064 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14065 (uint8_t *)p_list, size);
14068 p_num = p_list->p_count;
14069 printf("Profile number is: %d\n\n", p_num);
14071 for (i = 0; i < p_num; i++) {
14072 p_info = &p_list->p_info[i];
14073 printf("Profile %d:\n", i);
14074 printf("Track id: 0x%x\n", p_info->track_id);
14075 printf("Version: %d.%d.%d.%d\n",
14076 p_info->version.major,
14077 p_info->version.minor,
14078 p_info->version.update,
14079 p_info->version.draft);
14080 printf("Profile name: %s\n\n", p_info->name);
14088 printf("Failed to get ddp list\n");
14091 cmdline_parse_inst_t cmd_ddp_get_list = {
14092 .f = cmd_ddp_get_list_parsed,
14094 .help_str = "ddp get list <port_id>",
14096 (void *)&cmd_ddp_get_list_ddp,
14097 (void *)&cmd_ddp_get_list_get,
14098 (void *)&cmd_ddp_get_list_list,
14099 (void *)&cmd_ddp_get_list_port_id,
14104 /* Configure input set */
14105 struct cmd_cfg_input_set_result {
14106 cmdline_fixed_string_t port;
14107 cmdline_fixed_string_t cfg;
14109 cmdline_fixed_string_t pctype;
14111 cmdline_fixed_string_t inset_type;
14112 cmdline_fixed_string_t opt;
14113 cmdline_fixed_string_t field;
14118 cmd_cfg_input_set_parsed(
14119 __rte_unused void *parsed_result,
14120 __rte_unused struct cmdline *cl,
14121 __rte_unused void *data)
14123 #ifdef RTE_NET_I40E
14124 struct cmd_cfg_input_set_result *res = parsed_result;
14125 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14126 struct rte_pmd_i40e_inset inset;
14128 int ret = -ENOTSUP;
14130 if (!all_ports_stopped()) {
14131 printf("Please stop all ports first\n");
14135 #ifdef RTE_NET_I40E
14136 if (!strcmp(res->inset_type, "hash_inset"))
14137 inset_type = INSET_HASH;
14138 else if (!strcmp(res->inset_type, "fdir_inset"))
14139 inset_type = INSET_FDIR;
14140 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14141 inset_type = INSET_FDIR_FLX;
14142 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14143 &inset, inset_type);
14145 printf("Failed to get input set.\n");
14149 if (!strcmp(res->opt, "get")) {
14150 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14153 printf("Field index %d is enabled.\n", res->field_idx);
14155 printf("Field index %d is disabled.\n", res->field_idx);
14157 } else if (!strcmp(res->opt, "set"))
14158 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14160 else if (!strcmp(res->opt, "clear"))
14161 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14164 printf("Failed to configure input set field.\n");
14168 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14169 &inset, inset_type);
14171 printf("Failed to set input set.\n");
14176 if (ret == -ENOTSUP)
14177 printf("Function not supported\n");
14180 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14181 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14183 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14184 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14186 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14187 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14189 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14190 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14192 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14193 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14195 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14196 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14198 "hash_inset#fdir_inset#fdir_flx_inset");
14199 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14200 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14201 opt, "get#set#clear");
14202 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14203 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14205 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14206 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14209 cmdline_parse_inst_t cmd_cfg_input_set = {
14210 .f = cmd_cfg_input_set_parsed,
14212 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14213 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
14215 (void *)&cmd_cfg_input_set_port,
14216 (void *)&cmd_cfg_input_set_cfg,
14217 (void *)&cmd_cfg_input_set_port_id,
14218 (void *)&cmd_cfg_input_set_pctype,
14219 (void *)&cmd_cfg_input_set_pctype_id,
14220 (void *)&cmd_cfg_input_set_inset_type,
14221 (void *)&cmd_cfg_input_set_opt,
14222 (void *)&cmd_cfg_input_set_field,
14223 (void *)&cmd_cfg_input_set_field_idx,
14228 /* Clear input set */
14229 struct cmd_clear_input_set_result {
14230 cmdline_fixed_string_t port;
14231 cmdline_fixed_string_t cfg;
14233 cmdline_fixed_string_t pctype;
14235 cmdline_fixed_string_t inset_type;
14236 cmdline_fixed_string_t clear;
14237 cmdline_fixed_string_t all;
14241 cmd_clear_input_set_parsed(
14242 __rte_unused void *parsed_result,
14243 __rte_unused struct cmdline *cl,
14244 __rte_unused void *data)
14246 #ifdef RTE_NET_I40E
14247 struct cmd_clear_input_set_result *res = parsed_result;
14248 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14249 struct rte_pmd_i40e_inset inset;
14251 int ret = -ENOTSUP;
14253 if (!all_ports_stopped()) {
14254 printf("Please stop all ports first\n");
14258 #ifdef RTE_NET_I40E
14259 if (!strcmp(res->inset_type, "hash_inset"))
14260 inset_type = INSET_HASH;
14261 else if (!strcmp(res->inset_type, "fdir_inset"))
14262 inset_type = INSET_FDIR;
14263 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14264 inset_type = INSET_FDIR_FLX;
14266 memset(&inset, 0, sizeof(inset));
14268 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14269 &inset, inset_type);
14271 printf("Failed to clear input set.\n");
14277 if (ret == -ENOTSUP)
14278 printf("Function not supported\n");
14281 cmdline_parse_token_string_t cmd_clear_input_set_port =
14282 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14284 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
14285 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14287 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
14288 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14290 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
14291 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14293 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
14294 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14296 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
14297 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14299 "hash_inset#fdir_inset#fdir_flx_inset");
14300 cmdline_parse_token_string_t cmd_clear_input_set_clear =
14301 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14303 cmdline_parse_token_string_t cmd_clear_input_set_all =
14304 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14307 cmdline_parse_inst_t cmd_clear_input_set = {
14308 .f = cmd_clear_input_set_parsed,
14310 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14311 "fdir_inset|fdir_flx_inset clear all",
14313 (void *)&cmd_clear_input_set_port,
14314 (void *)&cmd_clear_input_set_cfg,
14315 (void *)&cmd_clear_input_set_port_id,
14316 (void *)&cmd_clear_input_set_pctype,
14317 (void *)&cmd_clear_input_set_pctype_id,
14318 (void *)&cmd_clear_input_set_inset_type,
14319 (void *)&cmd_clear_input_set_clear,
14320 (void *)&cmd_clear_input_set_all,
14325 /* show vf stats */
14327 /* Common result structure for show vf stats */
14328 struct cmd_show_vf_stats_result {
14329 cmdline_fixed_string_t show;
14330 cmdline_fixed_string_t vf;
14331 cmdline_fixed_string_t stats;
14336 /* Common CLI fields show vf stats*/
14337 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14338 TOKEN_STRING_INITIALIZER
14339 (struct cmd_show_vf_stats_result,
14341 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14342 TOKEN_STRING_INITIALIZER
14343 (struct cmd_show_vf_stats_result,
14345 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14346 TOKEN_STRING_INITIALIZER
14347 (struct cmd_show_vf_stats_result,
14349 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14350 TOKEN_NUM_INITIALIZER
14351 (struct cmd_show_vf_stats_result,
14353 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14354 TOKEN_NUM_INITIALIZER
14355 (struct cmd_show_vf_stats_result,
14359 cmd_show_vf_stats_parsed(
14360 void *parsed_result,
14361 __rte_unused struct cmdline *cl,
14362 __rte_unused void *data)
14364 struct cmd_show_vf_stats_result *res = parsed_result;
14365 struct rte_eth_stats stats;
14366 int ret = -ENOTSUP;
14367 static const char *nic_stats_border = "########################";
14369 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14372 memset(&stats, 0, sizeof(stats));
14374 #ifdef RTE_NET_I40E
14375 if (ret == -ENOTSUP)
14376 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14380 #ifdef RTE_NET_BNXT
14381 if (ret == -ENOTSUP)
14382 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14391 printf("invalid vf_id %d\n", res->vf_id);
14394 printf("invalid port_id %d\n", res->port_id);
14397 printf("function not implemented\n");
14400 printf("programming error: (%s)\n", strerror(-ret));
14403 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14404 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14406 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14408 stats.ipackets, stats.imissed, stats.ibytes);
14409 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14410 printf(" RX-nombuf: %-10"PRIu64"\n",
14412 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14414 stats.opackets, stats.oerrors, stats.obytes);
14416 printf(" %s############################%s\n",
14417 nic_stats_border, nic_stats_border);
14420 cmdline_parse_inst_t cmd_show_vf_stats = {
14421 .f = cmd_show_vf_stats_parsed,
14423 .help_str = "show vf stats <port_id> <vf_id>",
14425 (void *)&cmd_show_vf_stats_show,
14426 (void *)&cmd_show_vf_stats_vf,
14427 (void *)&cmd_show_vf_stats_stats,
14428 (void *)&cmd_show_vf_stats_port_id,
14429 (void *)&cmd_show_vf_stats_vf_id,
14434 /* clear vf stats */
14436 /* Common result structure for clear vf stats */
14437 struct cmd_clear_vf_stats_result {
14438 cmdline_fixed_string_t clear;
14439 cmdline_fixed_string_t vf;
14440 cmdline_fixed_string_t stats;
14445 /* Common CLI fields clear vf stats*/
14446 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14447 TOKEN_STRING_INITIALIZER
14448 (struct cmd_clear_vf_stats_result,
14450 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
14451 TOKEN_STRING_INITIALIZER
14452 (struct cmd_clear_vf_stats_result,
14454 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
14455 TOKEN_STRING_INITIALIZER
14456 (struct cmd_clear_vf_stats_result,
14458 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
14459 TOKEN_NUM_INITIALIZER
14460 (struct cmd_clear_vf_stats_result,
14462 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
14463 TOKEN_NUM_INITIALIZER
14464 (struct cmd_clear_vf_stats_result,
14468 cmd_clear_vf_stats_parsed(
14469 void *parsed_result,
14470 __rte_unused struct cmdline *cl,
14471 __rte_unused void *data)
14473 struct cmd_clear_vf_stats_result *res = parsed_result;
14474 int ret = -ENOTSUP;
14476 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14479 #ifdef RTE_NET_I40E
14480 if (ret == -ENOTSUP)
14481 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
14484 #ifdef RTE_NET_BNXT
14485 if (ret == -ENOTSUP)
14486 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
14494 printf("invalid vf_id %d\n", res->vf_id);
14497 printf("invalid port_id %d\n", res->port_id);
14500 printf("function not implemented\n");
14503 printf("programming error: (%s)\n", strerror(-ret));
14507 cmdline_parse_inst_t cmd_clear_vf_stats = {
14508 .f = cmd_clear_vf_stats_parsed,
14510 .help_str = "clear vf stats <port_id> <vf_id>",
14512 (void *)&cmd_clear_vf_stats_clear,
14513 (void *)&cmd_clear_vf_stats_vf,
14514 (void *)&cmd_clear_vf_stats_stats,
14515 (void *)&cmd_clear_vf_stats_port_id,
14516 (void *)&cmd_clear_vf_stats_vf_id,
14521 /* port config pctype mapping reset */
14523 /* Common result structure for port config pctype mapping reset */
14524 struct cmd_pctype_mapping_reset_result {
14525 cmdline_fixed_string_t port;
14526 cmdline_fixed_string_t config;
14528 cmdline_fixed_string_t pctype;
14529 cmdline_fixed_string_t mapping;
14530 cmdline_fixed_string_t reset;
14533 /* Common CLI fields for port config pctype mapping reset*/
14534 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
14535 TOKEN_STRING_INITIALIZER
14536 (struct cmd_pctype_mapping_reset_result,
14538 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
14539 TOKEN_STRING_INITIALIZER
14540 (struct cmd_pctype_mapping_reset_result,
14542 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
14543 TOKEN_NUM_INITIALIZER
14544 (struct cmd_pctype_mapping_reset_result,
14546 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
14547 TOKEN_STRING_INITIALIZER
14548 (struct cmd_pctype_mapping_reset_result,
14550 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
14551 TOKEN_STRING_INITIALIZER
14552 (struct cmd_pctype_mapping_reset_result,
14553 mapping, "mapping");
14554 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
14555 TOKEN_STRING_INITIALIZER
14556 (struct cmd_pctype_mapping_reset_result,
14560 cmd_pctype_mapping_reset_parsed(
14561 void *parsed_result,
14562 __rte_unused struct cmdline *cl,
14563 __rte_unused void *data)
14565 struct cmd_pctype_mapping_reset_result *res = parsed_result;
14566 int ret = -ENOTSUP;
14568 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14571 #ifdef RTE_NET_I40E
14572 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
14579 printf("invalid port_id %d\n", res->port_id);
14582 printf("function not implemented\n");
14585 printf("programming error: (%s)\n", strerror(-ret));
14589 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
14590 .f = cmd_pctype_mapping_reset_parsed,
14592 .help_str = "port config <port_id> pctype mapping reset",
14594 (void *)&cmd_pctype_mapping_reset_port,
14595 (void *)&cmd_pctype_mapping_reset_config,
14596 (void *)&cmd_pctype_mapping_reset_port_id,
14597 (void *)&cmd_pctype_mapping_reset_pctype,
14598 (void *)&cmd_pctype_mapping_reset_mapping,
14599 (void *)&cmd_pctype_mapping_reset_reset,
14604 /* show port pctype mapping */
14606 /* Common result structure for show port pctype mapping */
14607 struct cmd_pctype_mapping_get_result {
14608 cmdline_fixed_string_t show;
14609 cmdline_fixed_string_t port;
14611 cmdline_fixed_string_t pctype;
14612 cmdline_fixed_string_t mapping;
14615 /* Common CLI fields for pctype mapping get */
14616 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
14617 TOKEN_STRING_INITIALIZER
14618 (struct cmd_pctype_mapping_get_result,
14620 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
14621 TOKEN_STRING_INITIALIZER
14622 (struct cmd_pctype_mapping_get_result,
14624 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
14625 TOKEN_NUM_INITIALIZER
14626 (struct cmd_pctype_mapping_get_result,
14628 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
14629 TOKEN_STRING_INITIALIZER
14630 (struct cmd_pctype_mapping_get_result,
14632 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
14633 TOKEN_STRING_INITIALIZER
14634 (struct cmd_pctype_mapping_get_result,
14635 mapping, "mapping");
14638 cmd_pctype_mapping_get_parsed(
14639 void *parsed_result,
14640 __rte_unused struct cmdline *cl,
14641 __rte_unused void *data)
14643 struct cmd_pctype_mapping_get_result *res = parsed_result;
14644 int ret = -ENOTSUP;
14645 #ifdef RTE_NET_I40E
14646 struct rte_pmd_i40e_flow_type_mapping
14647 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
14648 int i, j, first_pctype;
14651 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14654 #ifdef RTE_NET_I40E
14655 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
14662 printf("invalid port_id %d\n", res->port_id);
14665 printf("function not implemented\n");
14668 printf("programming error: (%s)\n", strerror(-ret));
14672 #ifdef RTE_NET_I40E
14673 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
14674 if (mapping[i].pctype != 0ULL) {
14677 printf("pctype: ");
14678 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
14679 if (mapping[i].pctype & (1ULL << j)) {
14680 printf(first_pctype ?
14681 "%02d" : ",%02d", j);
14685 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
14691 cmdline_parse_inst_t cmd_pctype_mapping_get = {
14692 .f = cmd_pctype_mapping_get_parsed,
14694 .help_str = "show port <port_id> pctype mapping",
14696 (void *)&cmd_pctype_mapping_get_show,
14697 (void *)&cmd_pctype_mapping_get_port,
14698 (void *)&cmd_pctype_mapping_get_port_id,
14699 (void *)&cmd_pctype_mapping_get_pctype,
14700 (void *)&cmd_pctype_mapping_get_mapping,
14705 /* port config pctype mapping update */
14707 /* Common result structure for port config pctype mapping update */
14708 struct cmd_pctype_mapping_update_result {
14709 cmdline_fixed_string_t port;
14710 cmdline_fixed_string_t config;
14712 cmdline_fixed_string_t pctype;
14713 cmdline_fixed_string_t mapping;
14714 cmdline_fixed_string_t update;
14715 cmdline_fixed_string_t pctype_list;
14716 uint16_t flow_type;
14719 /* Common CLI fields for pctype mapping update*/
14720 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
14721 TOKEN_STRING_INITIALIZER
14722 (struct cmd_pctype_mapping_update_result,
14724 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
14725 TOKEN_STRING_INITIALIZER
14726 (struct cmd_pctype_mapping_update_result,
14728 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
14729 TOKEN_NUM_INITIALIZER
14730 (struct cmd_pctype_mapping_update_result,
14732 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
14733 TOKEN_STRING_INITIALIZER
14734 (struct cmd_pctype_mapping_update_result,
14736 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
14737 TOKEN_STRING_INITIALIZER
14738 (struct cmd_pctype_mapping_update_result,
14739 mapping, "mapping");
14740 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
14741 TOKEN_STRING_INITIALIZER
14742 (struct cmd_pctype_mapping_update_result,
14744 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
14745 TOKEN_STRING_INITIALIZER
14746 (struct cmd_pctype_mapping_update_result,
14747 pctype_list, NULL);
14748 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
14749 TOKEN_NUM_INITIALIZER
14750 (struct cmd_pctype_mapping_update_result,
14751 flow_type, UINT16);
14754 cmd_pctype_mapping_update_parsed(
14755 void *parsed_result,
14756 __rte_unused struct cmdline *cl,
14757 __rte_unused void *data)
14759 struct cmd_pctype_mapping_update_result *res = parsed_result;
14760 int ret = -ENOTSUP;
14761 #ifdef RTE_NET_I40E
14762 struct rte_pmd_i40e_flow_type_mapping mapping;
14764 unsigned int nb_item;
14765 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
14768 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14771 #ifdef RTE_NET_I40E
14772 nb_item = parse_item_list(res->pctype_list, "pctypes",
14773 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
14774 mapping.flow_type = res->flow_type;
14775 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
14776 mapping.pctype |= (1ULL << pctype_list[i]);
14777 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
14787 printf("invalid pctype or flow type\n");
14790 printf("invalid port_id %d\n", res->port_id);
14793 printf("function not implemented\n");
14796 printf("programming error: (%s)\n", strerror(-ret));
14800 cmdline_parse_inst_t cmd_pctype_mapping_update = {
14801 .f = cmd_pctype_mapping_update_parsed,
14803 .help_str = "port config <port_id> pctype mapping update"
14804 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
14806 (void *)&cmd_pctype_mapping_update_port,
14807 (void *)&cmd_pctype_mapping_update_config,
14808 (void *)&cmd_pctype_mapping_update_port_id,
14809 (void *)&cmd_pctype_mapping_update_pctype,
14810 (void *)&cmd_pctype_mapping_update_mapping,
14811 (void *)&cmd_pctype_mapping_update_update,
14812 (void *)&cmd_pctype_mapping_update_pc_type,
14813 (void *)&cmd_pctype_mapping_update_flow_type,
14818 /* ptype mapping get */
14820 /* Common result structure for ptype mapping get */
14821 struct cmd_ptype_mapping_get_result {
14822 cmdline_fixed_string_t ptype;
14823 cmdline_fixed_string_t mapping;
14824 cmdline_fixed_string_t get;
14826 uint8_t valid_only;
14829 /* Common CLI fields for ptype mapping get */
14830 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
14831 TOKEN_STRING_INITIALIZER
14832 (struct cmd_ptype_mapping_get_result,
14834 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
14835 TOKEN_STRING_INITIALIZER
14836 (struct cmd_ptype_mapping_get_result,
14837 mapping, "mapping");
14838 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
14839 TOKEN_STRING_INITIALIZER
14840 (struct cmd_ptype_mapping_get_result,
14842 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
14843 TOKEN_NUM_INITIALIZER
14844 (struct cmd_ptype_mapping_get_result,
14846 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
14847 TOKEN_NUM_INITIALIZER
14848 (struct cmd_ptype_mapping_get_result,
14849 valid_only, UINT8);
14852 cmd_ptype_mapping_get_parsed(
14853 void *parsed_result,
14854 __rte_unused struct cmdline *cl,
14855 __rte_unused void *data)
14857 struct cmd_ptype_mapping_get_result *res = parsed_result;
14858 int ret = -ENOTSUP;
14859 #ifdef RTE_NET_I40E
14860 int max_ptype_num = 256;
14861 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
14866 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14869 #ifdef RTE_NET_I40E
14870 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
14881 printf("invalid port_id %d\n", res->port_id);
14884 printf("function not implemented\n");
14887 printf("programming error: (%s)\n", strerror(-ret));
14890 #ifdef RTE_NET_I40E
14892 for (i = 0; i < count; i++)
14893 printf("%3d\t0x%08x\n",
14894 mapping[i].hw_ptype, mapping[i].sw_ptype);
14899 cmdline_parse_inst_t cmd_ptype_mapping_get = {
14900 .f = cmd_ptype_mapping_get_parsed,
14902 .help_str = "ptype mapping get <port_id> <valid_only>",
14904 (void *)&cmd_ptype_mapping_get_ptype,
14905 (void *)&cmd_ptype_mapping_get_mapping,
14906 (void *)&cmd_ptype_mapping_get_get,
14907 (void *)&cmd_ptype_mapping_get_port_id,
14908 (void *)&cmd_ptype_mapping_get_valid_only,
14913 /* ptype mapping replace */
14915 /* Common result structure for ptype mapping replace */
14916 struct cmd_ptype_mapping_replace_result {
14917 cmdline_fixed_string_t ptype;
14918 cmdline_fixed_string_t mapping;
14919 cmdline_fixed_string_t replace;
14926 /* Common CLI fields for ptype mapping replace */
14927 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
14928 TOKEN_STRING_INITIALIZER
14929 (struct cmd_ptype_mapping_replace_result,
14931 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
14932 TOKEN_STRING_INITIALIZER
14933 (struct cmd_ptype_mapping_replace_result,
14934 mapping, "mapping");
14935 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
14936 TOKEN_STRING_INITIALIZER
14937 (struct cmd_ptype_mapping_replace_result,
14938 replace, "replace");
14939 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
14940 TOKEN_NUM_INITIALIZER
14941 (struct cmd_ptype_mapping_replace_result,
14943 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
14944 TOKEN_NUM_INITIALIZER
14945 (struct cmd_ptype_mapping_replace_result,
14947 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
14948 TOKEN_NUM_INITIALIZER
14949 (struct cmd_ptype_mapping_replace_result,
14951 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
14952 TOKEN_NUM_INITIALIZER
14953 (struct cmd_ptype_mapping_replace_result,
14957 cmd_ptype_mapping_replace_parsed(
14958 void *parsed_result,
14959 __rte_unused struct cmdline *cl,
14960 __rte_unused void *data)
14962 struct cmd_ptype_mapping_replace_result *res = parsed_result;
14963 int ret = -ENOTSUP;
14965 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14968 #ifdef RTE_NET_I40E
14969 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
14979 printf("invalid ptype 0x%8x or 0x%8x\n",
14980 res->target, res->pkt_type);
14983 printf("invalid port_id %d\n", res->port_id);
14986 printf("function not implemented\n");
14989 printf("programming error: (%s)\n", strerror(-ret));
14993 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
14994 .f = cmd_ptype_mapping_replace_parsed,
14997 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
14999 (void *)&cmd_ptype_mapping_replace_ptype,
15000 (void *)&cmd_ptype_mapping_replace_mapping,
15001 (void *)&cmd_ptype_mapping_replace_replace,
15002 (void *)&cmd_ptype_mapping_replace_port_id,
15003 (void *)&cmd_ptype_mapping_replace_target,
15004 (void *)&cmd_ptype_mapping_replace_mask,
15005 (void *)&cmd_ptype_mapping_replace_pkt_type,
15010 /* ptype mapping reset */
15012 /* Common result structure for ptype mapping reset */
15013 struct cmd_ptype_mapping_reset_result {
15014 cmdline_fixed_string_t ptype;
15015 cmdline_fixed_string_t mapping;
15016 cmdline_fixed_string_t reset;
15020 /* Common CLI fields for ptype mapping reset*/
15021 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15022 TOKEN_STRING_INITIALIZER
15023 (struct cmd_ptype_mapping_reset_result,
15025 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15026 TOKEN_STRING_INITIALIZER
15027 (struct cmd_ptype_mapping_reset_result,
15028 mapping, "mapping");
15029 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15030 TOKEN_STRING_INITIALIZER
15031 (struct cmd_ptype_mapping_reset_result,
15033 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15034 TOKEN_NUM_INITIALIZER
15035 (struct cmd_ptype_mapping_reset_result,
15039 cmd_ptype_mapping_reset_parsed(
15040 void *parsed_result,
15041 __rte_unused struct cmdline *cl,
15042 __rte_unused void *data)
15044 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15045 int ret = -ENOTSUP;
15047 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15050 #ifdef RTE_NET_I40E
15051 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15058 printf("invalid port_id %d\n", res->port_id);
15061 printf("function not implemented\n");
15064 printf("programming error: (%s)\n", strerror(-ret));
15068 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15069 .f = cmd_ptype_mapping_reset_parsed,
15071 .help_str = "ptype mapping reset <port_id>",
15073 (void *)&cmd_ptype_mapping_reset_ptype,
15074 (void *)&cmd_ptype_mapping_reset_mapping,
15075 (void *)&cmd_ptype_mapping_reset_reset,
15076 (void *)&cmd_ptype_mapping_reset_port_id,
15081 /* ptype mapping update */
15083 /* Common result structure for ptype mapping update */
15084 struct cmd_ptype_mapping_update_result {
15085 cmdline_fixed_string_t ptype;
15086 cmdline_fixed_string_t mapping;
15087 cmdline_fixed_string_t reset;
15093 /* Common CLI fields for ptype mapping update*/
15094 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15095 TOKEN_STRING_INITIALIZER
15096 (struct cmd_ptype_mapping_update_result,
15098 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15099 TOKEN_STRING_INITIALIZER
15100 (struct cmd_ptype_mapping_update_result,
15101 mapping, "mapping");
15102 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15103 TOKEN_STRING_INITIALIZER
15104 (struct cmd_ptype_mapping_update_result,
15106 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15107 TOKEN_NUM_INITIALIZER
15108 (struct cmd_ptype_mapping_update_result,
15110 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15111 TOKEN_NUM_INITIALIZER
15112 (struct cmd_ptype_mapping_update_result,
15114 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15115 TOKEN_NUM_INITIALIZER
15116 (struct cmd_ptype_mapping_update_result,
15120 cmd_ptype_mapping_update_parsed(
15121 void *parsed_result,
15122 __rte_unused struct cmdline *cl,
15123 __rte_unused void *data)
15125 struct cmd_ptype_mapping_update_result *res = parsed_result;
15126 int ret = -ENOTSUP;
15127 #ifdef RTE_NET_I40E
15128 struct rte_pmd_i40e_ptype_mapping mapping;
15130 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15133 #ifdef RTE_NET_I40E
15134 mapping.hw_ptype = res->hw_ptype;
15135 mapping.sw_ptype = res->sw_ptype;
15136 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15146 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15149 printf("invalid port_id %d\n", res->port_id);
15152 printf("function not implemented\n");
15155 printf("programming error: (%s)\n", strerror(-ret));
15159 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15160 .f = cmd_ptype_mapping_update_parsed,
15162 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15164 (void *)&cmd_ptype_mapping_update_ptype,
15165 (void *)&cmd_ptype_mapping_update_mapping,
15166 (void *)&cmd_ptype_mapping_update_update,
15167 (void *)&cmd_ptype_mapping_update_port_id,
15168 (void *)&cmd_ptype_mapping_update_hw_ptype,
15169 (void *)&cmd_ptype_mapping_update_sw_ptype,
15174 /* Common result structure for file commands */
15175 struct cmd_cmdfile_result {
15176 cmdline_fixed_string_t load;
15177 cmdline_fixed_string_t filename;
15180 /* Common CLI fields for file commands */
15181 cmdline_parse_token_string_t cmd_load_cmdfile =
15182 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15183 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15184 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15187 cmd_load_from_file_parsed(
15188 void *parsed_result,
15189 __rte_unused struct cmdline *cl,
15190 __rte_unused void *data)
15192 struct cmd_cmdfile_result *res = parsed_result;
15194 cmdline_read_from_file(res->filename);
15197 cmdline_parse_inst_t cmd_load_from_file = {
15198 .f = cmd_load_from_file_parsed,
15200 .help_str = "load <filename>",
15202 (void *)&cmd_load_cmdfile,
15203 (void *)&cmd_load_cmdfile_filename,
15208 /* Get Rx offloads capabilities */
15209 struct cmd_rx_offload_get_capa_result {
15210 cmdline_fixed_string_t show;
15211 cmdline_fixed_string_t port;
15213 cmdline_fixed_string_t rx_offload;
15214 cmdline_fixed_string_t capabilities;
15217 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
15218 TOKEN_STRING_INITIALIZER
15219 (struct cmd_rx_offload_get_capa_result,
15221 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
15222 TOKEN_STRING_INITIALIZER
15223 (struct cmd_rx_offload_get_capa_result,
15225 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
15226 TOKEN_NUM_INITIALIZER
15227 (struct cmd_rx_offload_get_capa_result,
15229 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
15230 TOKEN_STRING_INITIALIZER
15231 (struct cmd_rx_offload_get_capa_result,
15232 rx_offload, "rx_offload");
15233 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
15234 TOKEN_STRING_INITIALIZER
15235 (struct cmd_rx_offload_get_capa_result,
15236 capabilities, "capabilities");
15239 print_rx_offloads(uint64_t offloads)
15241 uint64_t single_offload;
15249 begin = __builtin_ctzll(offloads);
15250 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15252 single_offload = 1ULL << begin;
15253 for (bit = begin; bit < end; bit++) {
15254 if (offloads & single_offload)
15256 rte_eth_dev_rx_offload_name(single_offload));
15257 single_offload <<= 1;
15262 cmd_rx_offload_get_capa_parsed(
15263 void *parsed_result,
15264 __rte_unused struct cmdline *cl,
15265 __rte_unused void *data)
15267 struct cmd_rx_offload_get_capa_result *res = parsed_result;
15268 struct rte_eth_dev_info dev_info;
15269 portid_t port_id = res->port_id;
15270 uint64_t queue_offloads;
15271 uint64_t port_offloads;
15274 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15278 queue_offloads = dev_info.rx_queue_offload_capa;
15279 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
15281 printf("Rx Offloading Capabilities of port %d :\n", port_id);
15282 printf(" Per Queue :");
15283 print_rx_offloads(queue_offloads);
15286 printf(" Per Port :");
15287 print_rx_offloads(port_offloads);
15291 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
15292 .f = cmd_rx_offload_get_capa_parsed,
15294 .help_str = "show port <port_id> rx_offload capabilities",
15296 (void *)&cmd_rx_offload_get_capa_show,
15297 (void *)&cmd_rx_offload_get_capa_port,
15298 (void *)&cmd_rx_offload_get_capa_port_id,
15299 (void *)&cmd_rx_offload_get_capa_rx_offload,
15300 (void *)&cmd_rx_offload_get_capa_capabilities,
15305 /* Get Rx offloads configuration */
15306 struct cmd_rx_offload_get_configuration_result {
15307 cmdline_fixed_string_t show;
15308 cmdline_fixed_string_t port;
15310 cmdline_fixed_string_t rx_offload;
15311 cmdline_fixed_string_t configuration;
15314 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
15315 TOKEN_STRING_INITIALIZER
15316 (struct cmd_rx_offload_get_configuration_result,
15318 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
15319 TOKEN_STRING_INITIALIZER
15320 (struct cmd_rx_offload_get_configuration_result,
15322 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
15323 TOKEN_NUM_INITIALIZER
15324 (struct cmd_rx_offload_get_configuration_result,
15326 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
15327 TOKEN_STRING_INITIALIZER
15328 (struct cmd_rx_offload_get_configuration_result,
15329 rx_offload, "rx_offload");
15330 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
15331 TOKEN_STRING_INITIALIZER
15332 (struct cmd_rx_offload_get_configuration_result,
15333 configuration, "configuration");
15336 cmd_rx_offload_get_configuration_parsed(
15337 void *parsed_result,
15338 __rte_unused struct cmdline *cl,
15339 __rte_unused void *data)
15341 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
15342 struct rte_eth_dev_info dev_info;
15343 portid_t port_id = res->port_id;
15344 struct rte_port *port = &ports[port_id];
15345 uint64_t port_offloads;
15346 uint64_t queue_offloads;
15347 uint16_t nb_rx_queues;
15351 printf("Rx Offloading Configuration of port %d :\n", port_id);
15353 port_offloads = port->dev_conf.rxmode.offloads;
15355 print_rx_offloads(port_offloads);
15358 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15362 nb_rx_queues = dev_info.nb_rx_queues;
15363 for (q = 0; q < nb_rx_queues; q++) {
15364 queue_offloads = port->rx_conf[q].offloads;
15365 printf(" Queue[%2d] :", q);
15366 print_rx_offloads(queue_offloads);
15372 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
15373 .f = cmd_rx_offload_get_configuration_parsed,
15375 .help_str = "show port <port_id> rx_offload configuration",
15377 (void *)&cmd_rx_offload_get_configuration_show,
15378 (void *)&cmd_rx_offload_get_configuration_port,
15379 (void *)&cmd_rx_offload_get_configuration_port_id,
15380 (void *)&cmd_rx_offload_get_configuration_rx_offload,
15381 (void *)&cmd_rx_offload_get_configuration_configuration,
15386 /* Enable/Disable a per port offloading */
15387 struct cmd_config_per_port_rx_offload_result {
15388 cmdline_fixed_string_t port;
15389 cmdline_fixed_string_t config;
15391 cmdline_fixed_string_t rx_offload;
15392 cmdline_fixed_string_t offload;
15393 cmdline_fixed_string_t on_off;
15396 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
15397 TOKEN_STRING_INITIALIZER
15398 (struct cmd_config_per_port_rx_offload_result,
15400 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
15401 TOKEN_STRING_INITIALIZER
15402 (struct cmd_config_per_port_rx_offload_result,
15404 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
15405 TOKEN_NUM_INITIALIZER
15406 (struct cmd_config_per_port_rx_offload_result,
15408 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
15409 TOKEN_STRING_INITIALIZER
15410 (struct cmd_config_per_port_rx_offload_result,
15411 rx_offload, "rx_offload");
15412 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
15413 TOKEN_STRING_INITIALIZER
15414 (struct cmd_config_per_port_rx_offload_result,
15415 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
15416 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
15417 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
15418 "scatter#buffer_split#timestamp#security#"
15419 "keep_crc#rss_hash");
15420 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
15421 TOKEN_STRING_INITIALIZER
15422 (struct cmd_config_per_port_rx_offload_result,
15426 search_rx_offload(const char *name)
15428 uint64_t single_offload;
15429 const char *single_name;
15433 single_offload = 1;
15434 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
15435 single_name = rte_eth_dev_rx_offload_name(single_offload);
15436 if (!strcasecmp(single_name, name)) {
15440 single_offload <<= 1;
15444 return single_offload;
15450 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
15451 __rte_unused struct cmdline *cl,
15452 __rte_unused void *data)
15454 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
15455 portid_t port_id = res->port_id;
15456 struct rte_eth_dev_info dev_info;
15457 struct rte_port *port = &ports[port_id];
15458 uint64_t single_offload;
15459 uint16_t nb_rx_queues;
15463 if (port->port_status != RTE_PORT_STOPPED) {
15464 printf("Error: Can't config offload when Port %d "
15465 "is not stopped\n", port_id);
15469 single_offload = search_rx_offload(res->offload);
15470 if (single_offload == 0) {
15471 printf("Unknown offload name: %s\n", res->offload);
15475 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15479 nb_rx_queues = dev_info.nb_rx_queues;
15480 if (!strcmp(res->on_off, "on")) {
15481 port->dev_conf.rxmode.offloads |= single_offload;
15482 for (q = 0; q < nb_rx_queues; q++)
15483 port->rx_conf[q].offloads |= single_offload;
15485 port->dev_conf.rxmode.offloads &= ~single_offload;
15486 for (q = 0; q < nb_rx_queues; q++)
15487 port->rx_conf[q].offloads &= ~single_offload;
15490 cmd_reconfig_device_queue(port_id, 1, 1);
15493 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
15494 .f = cmd_config_per_port_rx_offload_parsed,
15496 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
15497 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
15498 "macsec_strip|header_split|vlan_filter|vlan_extend|"
15499 "jumbo_frame|scatter|buffer_split|timestamp|security|"
15500 "keep_crc|rss_hash on|off",
15502 (void *)&cmd_config_per_port_rx_offload_result_port,
15503 (void *)&cmd_config_per_port_rx_offload_result_config,
15504 (void *)&cmd_config_per_port_rx_offload_result_port_id,
15505 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
15506 (void *)&cmd_config_per_port_rx_offload_result_offload,
15507 (void *)&cmd_config_per_port_rx_offload_result_on_off,
15512 /* Enable/Disable a per queue offloading */
15513 struct cmd_config_per_queue_rx_offload_result {
15514 cmdline_fixed_string_t port;
15516 cmdline_fixed_string_t rxq;
15518 cmdline_fixed_string_t rx_offload;
15519 cmdline_fixed_string_t offload;
15520 cmdline_fixed_string_t on_off;
15523 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
15524 TOKEN_STRING_INITIALIZER
15525 (struct cmd_config_per_queue_rx_offload_result,
15527 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
15528 TOKEN_NUM_INITIALIZER
15529 (struct cmd_config_per_queue_rx_offload_result,
15531 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
15532 TOKEN_STRING_INITIALIZER
15533 (struct cmd_config_per_queue_rx_offload_result,
15535 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
15536 TOKEN_NUM_INITIALIZER
15537 (struct cmd_config_per_queue_rx_offload_result,
15539 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
15540 TOKEN_STRING_INITIALIZER
15541 (struct cmd_config_per_queue_rx_offload_result,
15542 rx_offload, "rx_offload");
15543 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
15544 TOKEN_STRING_INITIALIZER
15545 (struct cmd_config_per_queue_rx_offload_result,
15546 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
15547 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
15548 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
15549 "scatter#buffer_split#timestamp#security#keep_crc");
15550 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
15551 TOKEN_STRING_INITIALIZER
15552 (struct cmd_config_per_queue_rx_offload_result,
15556 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
15557 __rte_unused struct cmdline *cl,
15558 __rte_unused void *data)
15560 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
15561 struct rte_eth_dev_info dev_info;
15562 portid_t port_id = res->port_id;
15563 uint16_t queue_id = res->queue_id;
15564 struct rte_port *port = &ports[port_id];
15565 uint64_t single_offload;
15568 if (port->port_status != RTE_PORT_STOPPED) {
15569 printf("Error: Can't config offload when Port %d "
15570 "is not stopped\n", port_id);
15574 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15578 if (queue_id >= dev_info.nb_rx_queues) {
15579 printf("Error: input queue_id should be 0 ... "
15580 "%d\n", dev_info.nb_rx_queues - 1);
15584 single_offload = search_rx_offload(res->offload);
15585 if (single_offload == 0) {
15586 printf("Unknown offload name: %s\n", res->offload);
15590 if (!strcmp(res->on_off, "on"))
15591 port->rx_conf[queue_id].offloads |= single_offload;
15593 port->rx_conf[queue_id].offloads &= ~single_offload;
15595 cmd_reconfig_device_queue(port_id, 1, 1);
15598 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
15599 .f = cmd_config_per_queue_rx_offload_parsed,
15601 .help_str = "port <port_id> rxq <queue_id> rx_offload "
15602 "vlan_strip|ipv4_cksum|"
15603 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
15604 "macsec_strip|header_split|vlan_filter|vlan_extend|"
15605 "jumbo_frame|scatter|buffer_split|timestamp|security|"
15608 (void *)&cmd_config_per_queue_rx_offload_result_port,
15609 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
15610 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
15611 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
15612 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
15613 (void *)&cmd_config_per_queue_rx_offload_result_offload,
15614 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
15619 /* Get Tx offloads capabilities */
15620 struct cmd_tx_offload_get_capa_result {
15621 cmdline_fixed_string_t show;
15622 cmdline_fixed_string_t port;
15624 cmdline_fixed_string_t tx_offload;
15625 cmdline_fixed_string_t capabilities;
15628 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
15629 TOKEN_STRING_INITIALIZER
15630 (struct cmd_tx_offload_get_capa_result,
15632 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
15633 TOKEN_STRING_INITIALIZER
15634 (struct cmd_tx_offload_get_capa_result,
15636 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
15637 TOKEN_NUM_INITIALIZER
15638 (struct cmd_tx_offload_get_capa_result,
15640 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
15641 TOKEN_STRING_INITIALIZER
15642 (struct cmd_tx_offload_get_capa_result,
15643 tx_offload, "tx_offload");
15644 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
15645 TOKEN_STRING_INITIALIZER
15646 (struct cmd_tx_offload_get_capa_result,
15647 capabilities, "capabilities");
15650 print_tx_offloads(uint64_t offloads)
15652 uint64_t single_offload;
15660 begin = __builtin_ctzll(offloads);
15661 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15663 single_offload = 1ULL << begin;
15664 for (bit = begin; bit < end; bit++) {
15665 if (offloads & single_offload)
15667 rte_eth_dev_tx_offload_name(single_offload));
15668 single_offload <<= 1;
15673 cmd_tx_offload_get_capa_parsed(
15674 void *parsed_result,
15675 __rte_unused struct cmdline *cl,
15676 __rte_unused void *data)
15678 struct cmd_tx_offload_get_capa_result *res = parsed_result;
15679 struct rte_eth_dev_info dev_info;
15680 portid_t port_id = res->port_id;
15681 uint64_t queue_offloads;
15682 uint64_t port_offloads;
15685 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15689 queue_offloads = dev_info.tx_queue_offload_capa;
15690 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
15692 printf("Tx Offloading Capabilities of port %d :\n", port_id);
15693 printf(" Per Queue :");
15694 print_tx_offloads(queue_offloads);
15697 printf(" Per Port :");
15698 print_tx_offloads(port_offloads);
15702 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
15703 .f = cmd_tx_offload_get_capa_parsed,
15705 .help_str = "show port <port_id> tx_offload capabilities",
15707 (void *)&cmd_tx_offload_get_capa_show,
15708 (void *)&cmd_tx_offload_get_capa_port,
15709 (void *)&cmd_tx_offload_get_capa_port_id,
15710 (void *)&cmd_tx_offload_get_capa_tx_offload,
15711 (void *)&cmd_tx_offload_get_capa_capabilities,
15716 /* Get Tx offloads configuration */
15717 struct cmd_tx_offload_get_configuration_result {
15718 cmdline_fixed_string_t show;
15719 cmdline_fixed_string_t port;
15721 cmdline_fixed_string_t tx_offload;
15722 cmdline_fixed_string_t configuration;
15725 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
15726 TOKEN_STRING_INITIALIZER
15727 (struct cmd_tx_offload_get_configuration_result,
15729 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
15730 TOKEN_STRING_INITIALIZER
15731 (struct cmd_tx_offload_get_configuration_result,
15733 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
15734 TOKEN_NUM_INITIALIZER
15735 (struct cmd_tx_offload_get_configuration_result,
15737 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
15738 TOKEN_STRING_INITIALIZER
15739 (struct cmd_tx_offload_get_configuration_result,
15740 tx_offload, "tx_offload");
15741 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
15742 TOKEN_STRING_INITIALIZER
15743 (struct cmd_tx_offload_get_configuration_result,
15744 configuration, "configuration");
15747 cmd_tx_offload_get_configuration_parsed(
15748 void *parsed_result,
15749 __rte_unused struct cmdline *cl,
15750 __rte_unused void *data)
15752 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
15753 struct rte_eth_dev_info dev_info;
15754 portid_t port_id = res->port_id;
15755 struct rte_port *port = &ports[port_id];
15756 uint64_t port_offloads;
15757 uint64_t queue_offloads;
15758 uint16_t nb_tx_queues;
15762 printf("Tx Offloading Configuration of port %d :\n", port_id);
15764 port_offloads = port->dev_conf.txmode.offloads;
15766 print_tx_offloads(port_offloads);
15769 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15773 nb_tx_queues = dev_info.nb_tx_queues;
15774 for (q = 0; q < nb_tx_queues; q++) {
15775 queue_offloads = port->tx_conf[q].offloads;
15776 printf(" Queue[%2d] :", q);
15777 print_tx_offloads(queue_offloads);
15783 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
15784 .f = cmd_tx_offload_get_configuration_parsed,
15786 .help_str = "show port <port_id> tx_offload configuration",
15788 (void *)&cmd_tx_offload_get_configuration_show,
15789 (void *)&cmd_tx_offload_get_configuration_port,
15790 (void *)&cmd_tx_offload_get_configuration_port_id,
15791 (void *)&cmd_tx_offload_get_configuration_tx_offload,
15792 (void *)&cmd_tx_offload_get_configuration_configuration,
15797 /* Enable/Disable a per port offloading */
15798 struct cmd_config_per_port_tx_offload_result {
15799 cmdline_fixed_string_t port;
15800 cmdline_fixed_string_t config;
15802 cmdline_fixed_string_t tx_offload;
15803 cmdline_fixed_string_t offload;
15804 cmdline_fixed_string_t on_off;
15807 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
15808 TOKEN_STRING_INITIALIZER
15809 (struct cmd_config_per_port_tx_offload_result,
15811 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
15812 TOKEN_STRING_INITIALIZER
15813 (struct cmd_config_per_port_tx_offload_result,
15815 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
15816 TOKEN_NUM_INITIALIZER
15817 (struct cmd_config_per_port_tx_offload_result,
15819 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
15820 TOKEN_STRING_INITIALIZER
15821 (struct cmd_config_per_port_tx_offload_result,
15822 tx_offload, "tx_offload");
15823 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
15824 TOKEN_STRING_INITIALIZER
15825 (struct cmd_config_per_port_tx_offload_result,
15826 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
15827 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
15828 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
15829 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
15830 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
15831 "send_on_timestamp");
15832 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
15833 TOKEN_STRING_INITIALIZER
15834 (struct cmd_config_per_port_tx_offload_result,
15838 search_tx_offload(const char *name)
15840 uint64_t single_offload;
15841 const char *single_name;
15845 single_offload = 1;
15846 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
15847 single_name = rte_eth_dev_tx_offload_name(single_offload);
15848 if (single_name == NULL)
15850 if (!strcasecmp(single_name, name)) {
15853 } else if (!strcasecmp(single_name, "UNKNOWN"))
15855 single_offload <<= 1;
15859 return single_offload;
15865 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
15866 __rte_unused struct cmdline *cl,
15867 __rte_unused void *data)
15869 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
15870 portid_t port_id = res->port_id;
15871 struct rte_eth_dev_info dev_info;
15872 struct rte_port *port = &ports[port_id];
15873 uint64_t single_offload;
15874 uint16_t nb_tx_queues;
15878 if (port->port_status != RTE_PORT_STOPPED) {
15879 printf("Error: Can't config offload when Port %d "
15880 "is not stopped\n", port_id);
15884 single_offload = search_tx_offload(res->offload);
15885 if (single_offload == 0) {
15886 printf("Unknown offload name: %s\n", res->offload);
15890 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15894 nb_tx_queues = dev_info.nb_tx_queues;
15895 if (!strcmp(res->on_off, "on")) {
15896 port->dev_conf.txmode.offloads |= single_offload;
15897 for (q = 0; q < nb_tx_queues; q++)
15898 port->tx_conf[q].offloads |= single_offload;
15900 port->dev_conf.txmode.offloads &= ~single_offload;
15901 for (q = 0; q < nb_tx_queues; q++)
15902 port->tx_conf[q].offloads &= ~single_offload;
15905 cmd_reconfig_device_queue(port_id, 1, 1);
15908 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
15909 .f = cmd_config_per_port_tx_offload_parsed,
15911 .help_str = "port config <port_id> tx_offload "
15912 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
15913 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
15914 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
15915 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
15916 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
15917 "send_on_timestamp on|off",
15919 (void *)&cmd_config_per_port_tx_offload_result_port,
15920 (void *)&cmd_config_per_port_tx_offload_result_config,
15921 (void *)&cmd_config_per_port_tx_offload_result_port_id,
15922 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
15923 (void *)&cmd_config_per_port_tx_offload_result_offload,
15924 (void *)&cmd_config_per_port_tx_offload_result_on_off,
15929 /* Enable/Disable a per queue offloading */
15930 struct cmd_config_per_queue_tx_offload_result {
15931 cmdline_fixed_string_t port;
15933 cmdline_fixed_string_t txq;
15935 cmdline_fixed_string_t tx_offload;
15936 cmdline_fixed_string_t offload;
15937 cmdline_fixed_string_t on_off;
15940 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
15941 TOKEN_STRING_INITIALIZER
15942 (struct cmd_config_per_queue_tx_offload_result,
15944 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
15945 TOKEN_NUM_INITIALIZER
15946 (struct cmd_config_per_queue_tx_offload_result,
15948 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
15949 TOKEN_STRING_INITIALIZER
15950 (struct cmd_config_per_queue_tx_offload_result,
15952 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
15953 TOKEN_NUM_INITIALIZER
15954 (struct cmd_config_per_queue_tx_offload_result,
15956 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
15957 TOKEN_STRING_INITIALIZER
15958 (struct cmd_config_per_queue_tx_offload_result,
15959 tx_offload, "tx_offload");
15960 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
15961 TOKEN_STRING_INITIALIZER
15962 (struct cmd_config_per_queue_tx_offload_result,
15963 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
15964 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
15965 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
15966 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
15967 "mt_lockfree#multi_segs#mbuf_fast_free#security");
15968 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
15969 TOKEN_STRING_INITIALIZER
15970 (struct cmd_config_per_queue_tx_offload_result,
15974 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
15975 __rte_unused struct cmdline *cl,
15976 __rte_unused void *data)
15978 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
15979 struct rte_eth_dev_info dev_info;
15980 portid_t port_id = res->port_id;
15981 uint16_t queue_id = res->queue_id;
15982 struct rte_port *port = &ports[port_id];
15983 uint64_t single_offload;
15986 if (port->port_status != RTE_PORT_STOPPED) {
15987 printf("Error: Can't config offload when Port %d "
15988 "is not stopped\n", port_id);
15992 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15996 if (queue_id >= dev_info.nb_tx_queues) {
15997 printf("Error: input queue_id should be 0 ... "
15998 "%d\n", dev_info.nb_tx_queues - 1);
16002 single_offload = search_tx_offload(res->offload);
16003 if (single_offload == 0) {
16004 printf("Unknown offload name: %s\n", res->offload);
16008 if (!strcmp(res->on_off, "on"))
16009 port->tx_conf[queue_id].offloads |= single_offload;
16011 port->tx_conf[queue_id].offloads &= ~single_offload;
16013 cmd_reconfig_device_queue(port_id, 1, 1);
16016 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16017 .f = cmd_config_per_queue_tx_offload_parsed,
16019 .help_str = "port <port_id> txq <queue_id> tx_offload "
16020 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16021 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16022 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16023 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16024 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16027 (void *)&cmd_config_per_queue_tx_offload_result_port,
16028 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16029 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16030 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16031 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16032 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16033 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16038 /* *** configure tx_metadata for specific port *** */
16039 struct cmd_config_tx_metadata_specific_result {
16040 cmdline_fixed_string_t port;
16041 cmdline_fixed_string_t keyword;
16043 cmdline_fixed_string_t item;
16048 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16049 __rte_unused struct cmdline *cl,
16050 __rte_unused void *data)
16052 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16054 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16056 ports[res->port_id].tx_metadata = res->value;
16057 /* Add/remove callback to insert valid metadata in every Tx packet. */
16058 if (ports[res->port_id].tx_metadata)
16059 add_tx_md_callback(res->port_id);
16061 remove_tx_md_callback(res->port_id);
16062 rte_flow_dynf_metadata_register();
16065 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16066 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16068 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16069 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16070 keyword, "config");
16071 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16072 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16074 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16075 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16076 item, "tx_metadata");
16077 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16078 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16081 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16082 .f = cmd_config_tx_metadata_specific_parsed,
16084 .help_str = "port config <port_id> tx_metadata <value>",
16086 (void *)&cmd_config_tx_metadata_specific_port,
16087 (void *)&cmd_config_tx_metadata_specific_keyword,
16088 (void *)&cmd_config_tx_metadata_specific_id,
16089 (void *)&cmd_config_tx_metadata_specific_item,
16090 (void *)&cmd_config_tx_metadata_specific_value,
16095 /* *** set dynf *** */
16096 struct cmd_config_tx_dynf_specific_result {
16097 cmdline_fixed_string_t port;
16098 cmdline_fixed_string_t keyword;
16100 cmdline_fixed_string_t item;
16101 cmdline_fixed_string_t name;
16102 cmdline_fixed_string_t value;
16106 cmd_config_dynf_specific_parsed(void *parsed_result,
16107 __rte_unused struct cmdline *cl,
16108 __rte_unused void *data)
16110 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16111 struct rte_mbuf_dynflag desc_flag;
16113 uint64_t old_port_flags;
16115 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16117 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16119 if (strlcpy(desc_flag.name, res->name,
16120 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16121 printf("Flag name too long\n");
16124 desc_flag.flags = 0;
16125 flag = rte_mbuf_dynflag_register(&desc_flag);
16127 printf("Can't register flag\n");
16130 strcpy(dynf_names[flag], desc_flag.name);
16132 old_port_flags = ports[res->port_id].mbuf_dynf;
16133 if (!strcmp(res->value, "set")) {
16134 ports[res->port_id].mbuf_dynf |= 1UL << flag;
16135 if (old_port_flags == 0)
16136 add_tx_dynf_callback(res->port_id);
16138 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16139 if (ports[res->port_id].mbuf_dynf == 0)
16140 remove_tx_dynf_callback(res->port_id);
16144 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16145 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16147 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16148 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16149 keyword, "config");
16150 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
16151 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16153 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
16154 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16156 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
16157 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16159 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
16160 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16161 value, "set#clear");
16163 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
16164 .f = cmd_config_dynf_specific_parsed,
16166 .help_str = "port config <port id> dynf <name> set|clear",
16168 (void *)&cmd_config_tx_dynf_specific_port,
16169 (void *)&cmd_config_tx_dynf_specific_keyword,
16170 (void *)&cmd_config_tx_dynf_specific_port_id,
16171 (void *)&cmd_config_tx_dynf_specific_item,
16172 (void *)&cmd_config_tx_dynf_specific_name,
16173 (void *)&cmd_config_tx_dynf_specific_value,
16178 /* *** display tx_metadata per port configuration *** */
16179 struct cmd_show_tx_metadata_result {
16180 cmdline_fixed_string_t cmd_show;
16181 cmdline_fixed_string_t cmd_port;
16182 cmdline_fixed_string_t cmd_keyword;
16187 cmd_show_tx_metadata_parsed(void *parsed_result,
16188 __rte_unused struct cmdline *cl,
16189 __rte_unused void *data)
16191 struct cmd_show_tx_metadata_result *res = parsed_result;
16193 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16194 printf("invalid port id %u\n", res->cmd_pid);
16197 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
16198 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
16199 ports[res->cmd_pid].tx_metadata);
16203 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
16204 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16206 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
16207 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16209 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
16210 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
16212 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
16213 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16214 cmd_keyword, "tx_metadata");
16216 cmdline_parse_inst_t cmd_show_tx_metadata = {
16217 .f = cmd_show_tx_metadata_parsed,
16219 .help_str = "show port <port_id> tx_metadata",
16221 (void *)&cmd_show_tx_metadata_show,
16222 (void *)&cmd_show_tx_metadata_port,
16223 (void *)&cmd_show_tx_metadata_pid,
16224 (void *)&cmd_show_tx_metadata_keyword,
16229 /* *** show fec capability per port configuration *** */
16230 struct cmd_show_fec_capability_result {
16231 cmdline_fixed_string_t cmd_show;
16232 cmdline_fixed_string_t cmd_port;
16233 cmdline_fixed_string_t cmd_fec;
16234 cmdline_fixed_string_t cmd_keyword;
16239 cmd_show_fec_capability_parsed(void *parsed_result,
16240 __rte_unused struct cmdline *cl,
16241 __rte_unused void *data)
16243 #define FEC_CAP_NUM 2
16244 struct cmd_show_fec_capability_result *res = parsed_result;
16245 struct rte_eth_fec_capa speed_fec_capa[FEC_CAP_NUM];
16246 unsigned int num = FEC_CAP_NUM;
16247 unsigned int ret_num;
16250 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16251 printf("Invalid port id %u\n", res->cmd_pid);
16255 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
16256 if (ret == -ENOTSUP) {
16257 printf("Function not implemented\n");
16259 } else if (ret < 0) {
16260 printf("Get FEC capability failed\n");
16264 ret_num = (unsigned int)ret;
16265 show_fec_capability(ret_num, speed_fec_capa);
16268 cmdline_parse_token_string_t cmd_show_fec_capability_show =
16269 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16271 cmdline_parse_token_string_t cmd_show_fec_capability_port =
16272 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16274 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
16275 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
16277 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
16278 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16280 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
16281 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16282 cmd_keyword, "capabilities");
16284 cmdline_parse_inst_t cmd_show_capability = {
16285 .f = cmd_show_fec_capability_parsed,
16287 .help_str = "show port <port_id> fec capabilities",
16289 (void *)&cmd_show_fec_capability_show,
16290 (void *)&cmd_show_fec_capability_port,
16291 (void *)&cmd_show_fec_capability_pid,
16292 (void *)&cmd_show_fec_capability_fec,
16293 (void *)&cmd_show_fec_capability_keyword,
16298 /* *** show fec mode per port configuration *** */
16299 struct cmd_show_fec_metadata_result {
16300 cmdline_fixed_string_t cmd_show;
16301 cmdline_fixed_string_t cmd_port;
16302 cmdline_fixed_string_t cmd_keyword;
16307 cmd_show_fec_mode_parsed(void *parsed_result,
16308 __rte_unused struct cmdline *cl,
16309 __rte_unused void *data)
16311 #define FEC_NAME_SIZE 16
16312 struct cmd_show_fec_metadata_result *res = parsed_result;
16314 char buf[FEC_NAME_SIZE];
16317 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16318 printf("Invalid port id %u\n", res->cmd_pid);
16321 ret = rte_eth_fec_get(res->cmd_pid, &mode);
16322 if (ret == -ENOTSUP) {
16323 printf("Function not implemented\n");
16325 } else if (ret < 0) {
16326 printf("Get FEC mode failed\n");
16331 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
16332 strlcpy(buf, "off", sizeof(buf));
16334 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
16335 strlcpy(buf, "auto", sizeof(buf));
16337 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
16338 strlcpy(buf, "baser", sizeof(buf));
16340 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
16341 strlcpy(buf, "rs", sizeof(buf));
16347 printf("%s\n", buf);
16350 cmdline_parse_token_string_t cmd_show_fec_mode_show =
16351 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16353 cmdline_parse_token_string_t cmd_show_fec_mode_port =
16354 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16356 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
16357 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
16359 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
16360 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16361 cmd_keyword, "fec_mode");
16363 cmdline_parse_inst_t cmd_show_fec_mode = {
16364 .f = cmd_show_fec_mode_parsed,
16366 .help_str = "show port <port_id> fec_mode",
16368 (void *)&cmd_show_fec_mode_show,
16369 (void *)&cmd_show_fec_mode_port,
16370 (void *)&cmd_show_fec_mode_pid,
16371 (void *)&cmd_show_fec_mode_keyword,
16376 /* *** set fec mode per port configuration *** */
16377 struct cmd_set_port_fec_mode {
16378 cmdline_fixed_string_t set;
16379 cmdline_fixed_string_t port;
16381 cmdline_fixed_string_t fec_mode;
16382 cmdline_fixed_string_t fec_value;
16385 /* Common CLI fields for set fec mode */
16386 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
16387 TOKEN_STRING_INITIALIZER
16388 (struct cmd_set_port_fec_mode,
16390 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
16391 TOKEN_STRING_INITIALIZER
16392 (struct cmd_set_port_fec_mode,
16394 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
16395 TOKEN_NUM_INITIALIZER
16396 (struct cmd_set_port_fec_mode,
16398 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
16399 TOKEN_STRING_INITIALIZER
16400 (struct cmd_set_port_fec_mode,
16401 fec_mode, "fec_mode");
16402 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
16403 TOKEN_STRING_INITIALIZER
16404 (struct cmd_set_port_fec_mode,
16408 cmd_set_port_fec_mode_parsed(
16409 void *parsed_result,
16410 __rte_unused struct cmdline *cl,
16411 __rte_unused void *data)
16413 struct cmd_set_port_fec_mode *res = parsed_result;
16414 uint16_t port_id = res->port_id;
16418 ret = parse_fec_mode(res->fec_value, &mode);
16420 printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
16425 ret = rte_eth_fec_set(port_id, mode);
16426 if (ret == -ENOTSUP) {
16427 printf("Function not implemented\n");
16429 } else if (ret < 0) {
16430 printf("Set FEC mode failed\n");
16435 cmdline_parse_inst_t cmd_set_fec_mode = {
16436 .f = cmd_set_port_fec_mode_parsed,
16438 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
16440 (void *)&cmd_set_port_fec_mode_set,
16441 (void *)&cmd_set_port_fec_mode_port,
16442 (void *)&cmd_set_port_fec_mode_port_id,
16443 (void *)&cmd_set_port_fec_mode_str,
16444 (void *)&cmd_set_port_fec_mode_value,
16449 /* show port supported ptypes */
16451 /* Common result structure for show port ptypes */
16452 struct cmd_show_port_supported_ptypes_result {
16453 cmdline_fixed_string_t show;
16454 cmdline_fixed_string_t port;
16456 cmdline_fixed_string_t ptypes;
16459 /* Common CLI fields for show port ptypes */
16460 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
16461 TOKEN_STRING_INITIALIZER
16462 (struct cmd_show_port_supported_ptypes_result,
16464 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
16465 TOKEN_STRING_INITIALIZER
16466 (struct cmd_show_port_supported_ptypes_result,
16468 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
16469 TOKEN_NUM_INITIALIZER
16470 (struct cmd_show_port_supported_ptypes_result,
16472 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
16473 TOKEN_STRING_INITIALIZER
16474 (struct cmd_show_port_supported_ptypes_result,
16478 cmd_show_port_supported_ptypes_parsed(
16479 void *parsed_result,
16480 __rte_unused struct cmdline *cl,
16481 __rte_unused void *data)
16483 #define RSVD_PTYPE_MASK 0xf0000000
16484 #define MAX_PTYPES_PER_LAYER 16
16485 #define LTYPE_NAMESIZE 32
16486 #define PTYPE_NAMESIZE 256
16487 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
16488 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
16489 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
16490 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
16491 uint16_t port_id = res->port_id;
16494 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
16498 while (ptype_mask != RSVD_PTYPE_MASK) {
16500 switch (ptype_mask) {
16501 case RTE_PTYPE_L2_MASK:
16502 strlcpy(ltype, "L2", sizeof(ltype));
16504 case RTE_PTYPE_L3_MASK:
16505 strlcpy(ltype, "L3", sizeof(ltype));
16507 case RTE_PTYPE_L4_MASK:
16508 strlcpy(ltype, "L4", sizeof(ltype));
16510 case RTE_PTYPE_TUNNEL_MASK:
16511 strlcpy(ltype, "Tunnel", sizeof(ltype));
16513 case RTE_PTYPE_INNER_L2_MASK:
16514 strlcpy(ltype, "Inner L2", sizeof(ltype));
16516 case RTE_PTYPE_INNER_L3_MASK:
16517 strlcpy(ltype, "Inner L3", sizeof(ltype));
16519 case RTE_PTYPE_INNER_L4_MASK:
16520 strlcpy(ltype, "Inner L4", sizeof(ltype));
16526 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
16527 ptype_mask, ptypes,
16528 MAX_PTYPES_PER_LAYER);
16531 printf("Supported %s ptypes:\n", ltype);
16533 printf("%s ptypes unsupported\n", ltype);
16535 for (i = 0; i < ret; ++i) {
16536 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
16537 printf("%s\n", buf);
16544 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
16545 .f = cmd_show_port_supported_ptypes_parsed,
16547 .help_str = "show port <port_id> ptypes",
16549 (void *)&cmd_show_port_supported_ptypes_show,
16550 (void *)&cmd_show_port_supported_ptypes_port,
16551 (void *)&cmd_show_port_supported_ptypes_port_id,
16552 (void *)&cmd_show_port_supported_ptypes_ptypes,
16557 /* *** display rx/tx descriptor status *** */
16558 struct cmd_show_rx_tx_desc_status_result {
16559 cmdline_fixed_string_t cmd_show;
16560 cmdline_fixed_string_t cmd_port;
16561 cmdline_fixed_string_t cmd_keyword;
16562 cmdline_fixed_string_t cmd_desc;
16563 cmdline_fixed_string_t cmd_status;
16570 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
16571 __rte_unused struct cmdline *cl,
16572 __rte_unused void *data)
16574 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
16577 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16578 printf("invalid port id %u\n", res->cmd_pid);
16582 if (!strcmp(res->cmd_keyword, "rxq")) {
16583 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
16586 printf("Invalid queueid = %d\n", res->cmd_qid);
16589 if (rc == RTE_ETH_RX_DESC_AVAIL)
16590 printf("Desc status = AVAILABLE\n");
16591 else if (rc == RTE_ETH_RX_DESC_DONE)
16592 printf("Desc status = DONE\n");
16594 printf("Desc status = UNAVAILABLE\n");
16595 } else if (!strcmp(res->cmd_keyword, "txq")) {
16596 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
16599 printf("Invalid queueid = %d\n", res->cmd_qid);
16602 if (rc == RTE_ETH_TX_DESC_FULL)
16603 printf("Desc status = FULL\n");
16604 else if (rc == RTE_ETH_TX_DESC_DONE)
16605 printf("Desc status = DONE\n");
16607 printf("Desc status = UNAVAILABLE\n");
16611 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
16612 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16614 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
16615 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16617 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
16618 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16620 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
16621 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16622 cmd_keyword, "rxq#txq");
16623 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
16624 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16626 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
16627 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16629 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
16630 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16632 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
16633 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16634 cmd_status, "status");
16635 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
16636 .f = cmd_show_rx_tx_desc_status_parsed,
16638 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
16641 (void *)&cmd_show_rx_tx_desc_status_show,
16642 (void *)&cmd_show_rx_tx_desc_status_port,
16643 (void *)&cmd_show_rx_tx_desc_status_pid,
16644 (void *)&cmd_show_rx_tx_desc_status_keyword,
16645 (void *)&cmd_show_rx_tx_desc_status_qid,
16646 (void *)&cmd_show_rx_tx_desc_status_desc,
16647 (void *)&cmd_show_rx_tx_desc_status_did,
16648 (void *)&cmd_show_rx_tx_desc_status_status,
16653 /* Common result structure for set port ptypes */
16654 struct cmd_set_port_ptypes_result {
16655 cmdline_fixed_string_t set;
16656 cmdline_fixed_string_t port;
16658 cmdline_fixed_string_t ptype_mask;
16662 /* Common CLI fields for set port ptypes */
16663 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
16664 TOKEN_STRING_INITIALIZER
16665 (struct cmd_set_port_ptypes_result,
16667 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
16668 TOKEN_STRING_INITIALIZER
16669 (struct cmd_set_port_ptypes_result,
16671 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
16672 TOKEN_NUM_INITIALIZER
16673 (struct cmd_set_port_ptypes_result,
16675 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
16676 TOKEN_STRING_INITIALIZER
16677 (struct cmd_set_port_ptypes_result,
16678 ptype_mask, "ptype_mask");
16679 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
16680 TOKEN_NUM_INITIALIZER
16681 (struct cmd_set_port_ptypes_result,
16685 cmd_set_port_ptypes_parsed(
16686 void *parsed_result,
16687 __rte_unused struct cmdline *cl,
16688 __rte_unused void *data)
16690 struct cmd_set_port_ptypes_result *res = parsed_result;
16691 #define PTYPE_NAMESIZE 256
16692 char ptype_name[PTYPE_NAMESIZE];
16693 uint16_t port_id = res->port_id;
16694 uint32_t ptype_mask = res->mask;
16697 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
16700 printf("Port %d doesn't support any ptypes.\n", port_id);
16704 uint32_t ptypes[ret];
16706 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
16708 printf("Unable to set requested ptypes for Port %d\n", port_id);
16712 printf("Successfully set following ptypes for Port %d\n", port_id);
16713 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
16714 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
16715 printf("%s\n", ptype_name);
16718 clear_ptypes = false;
16721 cmdline_parse_inst_t cmd_set_port_ptypes = {
16722 .f = cmd_set_port_ptypes_parsed,
16724 .help_str = "set port <port_id> ptype_mask <mask>",
16726 (void *)&cmd_set_port_ptypes_set,
16727 (void *)&cmd_set_port_ptypes_port,
16728 (void *)&cmd_set_port_ptypes_port_id,
16729 (void *)&cmd_set_port_ptypes_mask_str,
16730 (void *)&cmd_set_port_ptypes_mask_u32,
16735 /* *** display mac addresses added to a port *** */
16736 struct cmd_showport_macs_result {
16737 cmdline_fixed_string_t cmd_show;
16738 cmdline_fixed_string_t cmd_port;
16739 cmdline_fixed_string_t cmd_keyword;
16744 cmd_showport_macs_parsed(void *parsed_result,
16745 __rte_unused struct cmdline *cl,
16746 __rte_unused void *data)
16748 struct cmd_showport_macs_result *res = parsed_result;
16750 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
16753 if (!strcmp(res->cmd_keyword, "macs"))
16754 show_macs(res->cmd_pid);
16755 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
16756 show_mcast_macs(res->cmd_pid);
16759 cmdline_parse_token_string_t cmd_showport_macs_show =
16760 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
16762 cmdline_parse_token_string_t cmd_showport_macs_port =
16763 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
16765 cmdline_parse_token_num_t cmd_showport_macs_pid =
16766 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
16768 cmdline_parse_token_string_t cmd_showport_macs_keyword =
16769 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
16770 cmd_keyword, "macs#mcast_macs");
16772 cmdline_parse_inst_t cmd_showport_macs = {
16773 .f = cmd_showport_macs_parsed,
16775 .help_str = "show port <port_id> macs|mcast_macs",
16777 (void *)&cmd_showport_macs_show,
16778 (void *)&cmd_showport_macs_port,
16779 (void *)&cmd_showport_macs_pid,
16780 (void *)&cmd_showport_macs_keyword,
16785 /* ******************************************************************************** */
16787 /* list of instructions */
16788 cmdline_parse_ctx_t main_ctx[] = {
16789 (cmdline_parse_inst_t *)&cmd_help_brief,
16790 (cmdline_parse_inst_t *)&cmd_help_long,
16791 (cmdline_parse_inst_t *)&cmd_quit,
16792 (cmdline_parse_inst_t *)&cmd_load_from_file,
16793 (cmdline_parse_inst_t *)&cmd_showport,
16794 (cmdline_parse_inst_t *)&cmd_showqueue,
16795 (cmdline_parse_inst_t *)&cmd_showeeprom,
16796 (cmdline_parse_inst_t *)&cmd_showportall,
16797 (cmdline_parse_inst_t *)&cmd_showdevice,
16798 (cmdline_parse_inst_t *)&cmd_showcfg,
16799 (cmdline_parse_inst_t *)&cmd_showfwdall,
16800 (cmdline_parse_inst_t *)&cmd_start,
16801 (cmdline_parse_inst_t *)&cmd_start_tx_first,
16802 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
16803 (cmdline_parse_inst_t *)&cmd_set_link_up,
16804 (cmdline_parse_inst_t *)&cmd_set_link_down,
16805 (cmdline_parse_inst_t *)&cmd_reset,
16806 (cmdline_parse_inst_t *)&cmd_set_numbers,
16807 (cmdline_parse_inst_t *)&cmd_set_log,
16808 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
16809 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
16810 (cmdline_parse_inst_t *)&cmd_set_txpkts,
16811 (cmdline_parse_inst_t *)&cmd_set_txsplit,
16812 (cmdline_parse_inst_t *)&cmd_set_txtimes,
16813 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
16814 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
16815 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
16816 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
16817 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
16818 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
16819 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
16820 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
16821 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
16822 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
16823 (cmdline_parse_inst_t *)&cmd_set_link_check,
16824 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
16825 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
16826 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
16827 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
16828 #ifdef RTE_NET_BOND
16829 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
16830 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
16831 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
16832 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
16833 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
16834 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
16835 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
16836 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
16837 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
16838 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
16839 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
16841 (cmdline_parse_inst_t *)&cmd_vlan_offload,
16842 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
16843 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
16844 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
16845 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
16846 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
16847 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
16848 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
16849 (cmdline_parse_inst_t *)&cmd_csum_set,
16850 (cmdline_parse_inst_t *)&cmd_csum_show,
16851 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
16852 (cmdline_parse_inst_t *)&cmd_tso_set,
16853 (cmdline_parse_inst_t *)&cmd_tso_show,
16854 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
16855 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
16856 (cmdline_parse_inst_t *)&cmd_gro_enable,
16857 (cmdline_parse_inst_t *)&cmd_gro_flush,
16858 (cmdline_parse_inst_t *)&cmd_gro_show,
16859 (cmdline_parse_inst_t *)&cmd_gso_enable,
16860 (cmdline_parse_inst_t *)&cmd_gso_size,
16861 (cmdline_parse_inst_t *)&cmd_gso_show,
16862 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
16863 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
16864 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
16865 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
16866 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
16867 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
16868 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
16869 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
16870 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
16871 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
16872 (cmdline_parse_inst_t *)&cmd_config_dcb,
16873 (cmdline_parse_inst_t *)&cmd_read_reg,
16874 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
16875 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
16876 (cmdline_parse_inst_t *)&cmd_write_reg,
16877 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
16878 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
16879 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
16880 (cmdline_parse_inst_t *)&cmd_stop,
16881 (cmdline_parse_inst_t *)&cmd_mac_addr,
16882 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
16883 (cmdline_parse_inst_t *)&cmd_set_qmap,
16884 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
16885 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
16886 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
16887 (cmdline_parse_inst_t *)&cmd_operate_port,
16888 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
16889 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
16890 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
16891 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
16892 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
16893 (cmdline_parse_inst_t *)&cmd_config_speed_all,
16894 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
16895 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
16896 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
16897 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
16898 (cmdline_parse_inst_t *)&cmd_config_mtu,
16899 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
16900 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
16901 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
16902 (cmdline_parse_inst_t *)&cmd_config_rss,
16903 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
16904 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
16905 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
16906 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
16907 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
16908 (cmdline_parse_inst_t *)&cmd_showport_reta,
16909 (cmdline_parse_inst_t *)&cmd_showport_macs,
16910 (cmdline_parse_inst_t *)&cmd_config_burst,
16911 (cmdline_parse_inst_t *)&cmd_config_thresh,
16912 (cmdline_parse_inst_t *)&cmd_config_threshold,
16913 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
16914 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
16915 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
16916 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
16917 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
16918 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
16919 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
16920 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
16921 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
16922 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
16923 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
16924 (cmdline_parse_inst_t *)&cmd_dump,
16925 (cmdline_parse_inst_t *)&cmd_dump_one,
16926 #ifdef RTE_NET_I40E
16927 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
16929 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
16930 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
16931 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
16932 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
16933 (cmdline_parse_inst_t *)&cmd_flow,
16934 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
16935 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
16936 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
16937 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
16938 (cmdline_parse_inst_t *)&cmd_create_port_meter,
16939 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
16940 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
16941 (cmdline_parse_inst_t *)&cmd_del_port_meter,
16942 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
16943 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
16944 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
16945 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
16946 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
16947 (cmdline_parse_inst_t *)&cmd_mcast_addr,
16948 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
16949 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
16950 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
16951 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
16952 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
16953 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
16954 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
16955 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
16956 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
16957 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
16958 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
16959 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
16960 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
16961 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
16962 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
16963 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
16964 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
16965 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
16966 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
16967 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
16968 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
16969 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
16970 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
16971 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
16972 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
16973 (cmdline_parse_inst_t *)&cmd_set_vxlan,
16974 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
16975 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
16976 (cmdline_parse_inst_t *)&cmd_set_nvgre,
16977 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
16978 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
16979 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
16980 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
16981 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
16982 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
16983 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
16984 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
16985 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
16986 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
16987 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
16988 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
16989 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
16990 (cmdline_parse_inst_t *)&cmd_ddp_add,
16991 (cmdline_parse_inst_t *)&cmd_ddp_del,
16992 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
16993 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
16994 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
16995 (cmdline_parse_inst_t *)&cmd_clear_input_set,
16996 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
16997 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
16998 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
16999 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
17000 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17001 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17002 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17003 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17005 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17006 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17007 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17008 (cmdline_parse_inst_t *)&cmd_queue_region,
17009 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17010 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17011 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17012 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17013 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17014 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17015 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17016 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17017 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17018 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17019 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17020 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17021 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17022 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17023 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17024 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17025 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17026 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
17027 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17028 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17029 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17030 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17031 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17032 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17033 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
17034 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
17035 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
17036 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17037 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17038 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17039 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17040 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17041 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17042 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17043 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17044 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17046 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17047 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17049 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
17050 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
17051 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
17052 (cmdline_parse_inst_t *)&cmd_set_raw,
17053 (cmdline_parse_inst_t *)&cmd_show_set_raw,
17054 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
17055 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
17056 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
17057 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
17058 (cmdline_parse_inst_t *)&cmd_show_capability,
17062 /* read cmdline commands from file */
17064 cmdline_read_from_file(const char *filename)
17066 struct cmdline *cl;
17068 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17070 printf("Failed to create file based cmdline context: %s\n",
17075 cmdline_interact(cl);
17080 printf("Read CLI commands from %s\n", filename);
17083 /* prompt function, called from main on MAIN lcore */
17087 /* initialize non-constant commands */
17088 cmd_set_fwd_mode_init();
17089 cmd_set_fwd_retry_mode_init();
17091 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17092 if (testpmd_cl == NULL)
17094 cmdline_interact(testpmd_cl);
17095 cmdline_stdin_exit(testpmd_cl);
17101 if (testpmd_cl != NULL)
17102 cmdline_quit(testpmd_cl);
17106 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17108 if (id == (portid_t)RTE_PORT_ALL) {
17111 RTE_ETH_FOREACH_DEV(pid) {
17112 /* check if need_reconfig has been set to 1 */
17113 if (ports[pid].need_reconfig == 0)
17114 ports[pid].need_reconfig = dev;
17115 /* check if need_reconfig_queues has been set to 1 */
17116 if (ports[pid].need_reconfig_queues == 0)
17117 ports[pid].need_reconfig_queues = queue;
17119 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17120 /* check if need_reconfig has been set to 1 */
17121 if (ports[id].need_reconfig == 0)
17122 ports[id].need_reconfig = dev;
17123 /* check if need_reconfig_queues has been set to 1 */
17124 if (ports[id].need_reconfig_queues == 0)
17125 ports[id].need_reconfig_queues = queue;