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,
1408 port_id, RTE_UINT16);
1410 cmdline_parse_inst_t cmd_operate_detach_port = {
1411 .f = cmd_operate_detach_port_parsed,
1413 .help_str = "port detach <port_id>",
1415 (void *)&cmd_operate_detach_port_port,
1416 (void *)&cmd_operate_detach_port_keyword,
1417 (void *)&cmd_operate_detach_port_port_id,
1422 /* *** detach device by identifier *** */
1423 struct cmd_operate_detach_device_result {
1424 cmdline_fixed_string_t device;
1425 cmdline_fixed_string_t keyword;
1426 cmdline_fixed_string_t identifier;
1429 static void cmd_operate_detach_device_parsed(void *parsed_result,
1430 __rte_unused struct cmdline *cl,
1431 __rte_unused void *data)
1433 struct cmd_operate_detach_device_result *res = parsed_result;
1435 if (!strcmp(res->keyword, "detach"))
1436 detach_devargs(res->identifier);
1438 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, RTE_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, RTE_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, RTE_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,
2054 cmdline_parse_token_num_t cmd_config_mtu_value =
2055 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2058 cmdline_parse_inst_t cmd_config_mtu = {
2059 .f = cmd_config_mtu_parsed,
2061 .help_str = "port config mtu <port_id> <value>",
2063 (void *)&cmd_config_mtu_port,
2064 (void *)&cmd_config_mtu_keyword,
2065 (void *)&cmd_config_mtu_mtu,
2066 (void *)&cmd_config_mtu_port_id,
2067 (void *)&cmd_config_mtu_value,
2072 /* *** configure rx mode *** */
2073 struct cmd_config_rx_mode_flag {
2074 cmdline_fixed_string_t port;
2075 cmdline_fixed_string_t keyword;
2076 cmdline_fixed_string_t all;
2077 cmdline_fixed_string_t name;
2078 cmdline_fixed_string_t value;
2082 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2083 __rte_unused struct cmdline *cl,
2084 __rte_unused void *data)
2086 struct cmd_config_rx_mode_flag *res = parsed_result;
2088 if (!all_ports_stopped()) {
2089 printf("Please stop all ports first\n");
2093 if (!strcmp(res->name, "drop-en")) {
2094 if (!strcmp(res->value, "on"))
2096 else if (!strcmp(res->value, "off"))
2099 printf("Unknown parameter\n");
2103 printf("Unknown parameter\n");
2109 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2112 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2113 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2114 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2115 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2117 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2118 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2119 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2120 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2122 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2123 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2126 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2127 .f = cmd_config_rx_mode_flag_parsed,
2129 .help_str = "port config all drop-en on|off",
2131 (void *)&cmd_config_rx_mode_flag_port,
2132 (void *)&cmd_config_rx_mode_flag_keyword,
2133 (void *)&cmd_config_rx_mode_flag_all,
2134 (void *)&cmd_config_rx_mode_flag_name,
2135 (void *)&cmd_config_rx_mode_flag_value,
2140 /* *** configure rss *** */
2141 struct cmd_config_rss {
2142 cmdline_fixed_string_t port;
2143 cmdline_fixed_string_t keyword;
2144 cmdline_fixed_string_t all;
2145 cmdline_fixed_string_t name;
2146 cmdline_fixed_string_t value;
2150 cmd_config_rss_parsed(void *parsed_result,
2151 __rte_unused struct cmdline *cl,
2152 __rte_unused void *data)
2154 struct cmd_config_rss *res = parsed_result;
2155 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2156 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2157 int use_default = 0;
2158 int all_updated = 1;
2163 if (!strcmp(res->value, "all"))
2164 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2165 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2166 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2167 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU;
2168 else if (!strcmp(res->value, "eth"))
2169 rss_conf.rss_hf = ETH_RSS_ETH;
2170 else if (!strcmp(res->value, "vlan"))
2171 rss_conf.rss_hf = ETH_RSS_VLAN;
2172 else if (!strcmp(res->value, "ip"))
2173 rss_conf.rss_hf = ETH_RSS_IP;
2174 else if (!strcmp(res->value, "udp"))
2175 rss_conf.rss_hf = ETH_RSS_UDP;
2176 else if (!strcmp(res->value, "tcp"))
2177 rss_conf.rss_hf = ETH_RSS_TCP;
2178 else if (!strcmp(res->value, "sctp"))
2179 rss_conf.rss_hf = ETH_RSS_SCTP;
2180 else if (!strcmp(res->value, "ether"))
2181 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2182 else if (!strcmp(res->value, "port"))
2183 rss_conf.rss_hf = ETH_RSS_PORT;
2184 else if (!strcmp(res->value, "vxlan"))
2185 rss_conf.rss_hf = ETH_RSS_VXLAN;
2186 else if (!strcmp(res->value, "geneve"))
2187 rss_conf.rss_hf = ETH_RSS_GENEVE;
2188 else if (!strcmp(res->value, "nvgre"))
2189 rss_conf.rss_hf = ETH_RSS_NVGRE;
2190 else if (!strcmp(res->value, "l3-pre32"))
2191 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2192 else if (!strcmp(res->value, "l3-pre40"))
2193 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2194 else if (!strcmp(res->value, "l3-pre48"))
2195 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2196 else if (!strcmp(res->value, "l3-pre56"))
2197 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2198 else if (!strcmp(res->value, "l3-pre64"))
2199 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2200 else if (!strcmp(res->value, "l3-pre96"))
2201 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2202 else if (!strcmp(res->value, "l3-src-only"))
2203 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2204 else if (!strcmp(res->value, "l3-dst-only"))
2205 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2206 else if (!strcmp(res->value, "l4-src-only"))
2207 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2208 else if (!strcmp(res->value, "l4-dst-only"))
2209 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2210 else if (!strcmp(res->value, "l2-src-only"))
2211 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2212 else if (!strcmp(res->value, "l2-dst-only"))
2213 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2214 else if (!strcmp(res->value, "l2tpv3"))
2215 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2216 else if (!strcmp(res->value, "esp"))
2217 rss_conf.rss_hf = ETH_RSS_ESP;
2218 else if (!strcmp(res->value, "ah"))
2219 rss_conf.rss_hf = ETH_RSS_AH;
2220 else if (!strcmp(res->value, "pfcp"))
2221 rss_conf.rss_hf = ETH_RSS_PFCP;
2222 else if (!strcmp(res->value, "pppoe"))
2223 rss_conf.rss_hf = ETH_RSS_PPPOE;
2224 else if (!strcmp(res->value, "gtpu"))
2225 rss_conf.rss_hf = ETH_RSS_GTPU;
2226 else if (!strcmp(res->value, "none"))
2227 rss_conf.rss_hf = 0;
2228 else if (!strcmp(res->value, "level-default")) {
2229 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2230 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2231 } else if (!strcmp(res->value, "level-outer")) {
2232 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2233 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2234 } else if (!strcmp(res->value, "level-inner")) {
2235 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2236 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2237 } else if (!strcmp(res->value, "default"))
2239 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2240 atoi(res->value) < 64)
2241 rss_conf.rss_hf = 1ULL << atoi(res->value);
2243 printf("Unknown parameter\n");
2246 rss_conf.rss_key = NULL;
2247 /* Update global configuration for RSS types. */
2248 RTE_ETH_FOREACH_DEV(i) {
2249 struct rte_eth_rss_conf local_rss_conf;
2251 ret = eth_dev_info_get_print_err(i, &dev_info);
2256 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2258 local_rss_conf = rss_conf;
2259 local_rss_conf.rss_hf = rss_conf.rss_hf &
2260 dev_info.flow_type_rss_offloads;
2261 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2262 printf("Port %u modified RSS hash function based on hardware support,"
2263 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2264 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2266 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2269 printf("Configuration of RSS hash at ethernet port %d "
2270 "failed with error (%d): %s.\n",
2271 i, -diag, strerror(-diag));
2274 if (all_updated && !use_default) {
2275 rss_hf = rss_conf.rss_hf;
2276 printf("rss_hf %#"PRIx64"\n", rss_hf);
2280 cmdline_parse_token_string_t cmd_config_rss_port =
2281 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2282 cmdline_parse_token_string_t cmd_config_rss_keyword =
2283 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2284 cmdline_parse_token_string_t cmd_config_rss_all =
2285 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2286 cmdline_parse_token_string_t cmd_config_rss_name =
2287 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2288 cmdline_parse_token_string_t cmd_config_rss_value =
2289 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2291 cmdline_parse_inst_t cmd_config_rss = {
2292 .f = cmd_config_rss_parsed,
2294 .help_str = "port config all rss "
2295 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2296 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|none|level-default|"
2297 "level-outer|level-inner|<flowtype_id>",
2299 (void *)&cmd_config_rss_port,
2300 (void *)&cmd_config_rss_keyword,
2301 (void *)&cmd_config_rss_all,
2302 (void *)&cmd_config_rss_name,
2303 (void *)&cmd_config_rss_value,
2308 /* *** configure rss hash key *** */
2309 struct cmd_config_rss_hash_key {
2310 cmdline_fixed_string_t port;
2311 cmdline_fixed_string_t config;
2313 cmdline_fixed_string_t rss_hash_key;
2314 cmdline_fixed_string_t rss_type;
2315 cmdline_fixed_string_t key;
2319 hexa_digit_to_value(char hexa_digit)
2321 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2322 return (uint8_t) (hexa_digit - '0');
2323 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2324 return (uint8_t) ((hexa_digit - 'a') + 10);
2325 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2326 return (uint8_t) ((hexa_digit - 'A') + 10);
2327 /* Invalid hexa digit */
2332 parse_and_check_key_hexa_digit(char *key, int idx)
2336 hexa_v = hexa_digit_to_value(key[idx]);
2338 printf("invalid key: character %c at position %d is not a "
2339 "valid hexa digit\n", key[idx], idx);
2344 cmd_config_rss_hash_key_parsed(void *parsed_result,
2345 __rte_unused struct cmdline *cl,
2346 __rte_unused void *data)
2348 struct cmd_config_rss_hash_key *res = parsed_result;
2349 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2353 struct rte_eth_dev_info dev_info;
2354 uint8_t hash_key_size;
2358 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2362 if (dev_info.hash_key_size > 0 &&
2363 dev_info.hash_key_size <= sizeof(hash_key))
2364 hash_key_size = dev_info.hash_key_size;
2366 printf("dev_info did not provide a valid hash key size\n");
2369 /* Check the length of the RSS hash key */
2370 key_len = strlen(res->key);
2371 if (key_len != (hash_key_size * 2)) {
2372 printf("key length: %d invalid - key must be a string of %d"
2373 " hexa-decimal numbers\n",
2374 (int) key_len, hash_key_size * 2);
2377 /* Translate RSS hash key into binary representation */
2378 for (i = 0; i < hash_key_size; i++) {
2379 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2382 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2385 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2387 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2391 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2392 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2393 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2394 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2396 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2397 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2399 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2400 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2401 rss_hash_key, "rss-hash-key");
2402 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2403 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2404 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2405 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2406 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2407 "ipv6-tcp-ex#ipv6-udp-ex#"
2408 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2409 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2410 "l2tpv3#esp#ah#pfcp#pppoe#gtpu");
2411 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2412 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2414 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2415 .f = cmd_config_rss_hash_key_parsed,
2417 .help_str = "port config <port_id> rss-hash-key "
2418 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2419 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2420 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2421 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2422 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2423 "l2tpv3|esp|ah|pfcp|pppoe|gtpu "
2424 "<string of hex digits (variable length, NIC dependent)>",
2426 (void *)&cmd_config_rss_hash_key_port,
2427 (void *)&cmd_config_rss_hash_key_config,
2428 (void *)&cmd_config_rss_hash_key_port_id,
2429 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2430 (void *)&cmd_config_rss_hash_key_rss_type,
2431 (void *)&cmd_config_rss_hash_key_value,
2436 /* *** configure port rxq/txq ring size *** */
2437 struct cmd_config_rxtx_ring_size {
2438 cmdline_fixed_string_t port;
2439 cmdline_fixed_string_t config;
2441 cmdline_fixed_string_t rxtxq;
2443 cmdline_fixed_string_t rsize;
2448 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2449 __rte_unused struct cmdline *cl,
2450 __rte_unused void *data)
2452 struct cmd_config_rxtx_ring_size *res = parsed_result;
2453 struct rte_port *port;
2456 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2459 if (res->portid == (portid_t)RTE_PORT_ALL) {
2460 printf("Invalid port id\n");
2464 port = &ports[res->portid];
2466 if (!strcmp(res->rxtxq, "rxq"))
2468 else if (!strcmp(res->rxtxq, "txq"))
2471 printf("Unknown parameter\n");
2475 if (isrx && rx_queue_id_is_invalid(res->qid))
2477 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2480 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2481 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2487 port->nb_rx_desc[res->qid] = res->size;
2489 port->nb_tx_desc[res->qid] = res->size;
2491 cmd_reconfig_device_queue(res->portid, 0, 1);
2494 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2495 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2497 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2498 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2500 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2501 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2502 portid, RTE_UINT16);
2503 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2504 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2506 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2507 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2509 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2510 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2511 rsize, "ring_size");
2512 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2513 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2516 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2517 .f = cmd_config_rxtx_ring_size_parsed,
2519 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2521 (void *)&cmd_config_rxtx_ring_size_port,
2522 (void *)&cmd_config_rxtx_ring_size_config,
2523 (void *)&cmd_config_rxtx_ring_size_portid,
2524 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2525 (void *)&cmd_config_rxtx_ring_size_qid,
2526 (void *)&cmd_config_rxtx_ring_size_rsize,
2527 (void *)&cmd_config_rxtx_ring_size_size,
2532 /* *** configure port rxq/txq start/stop *** */
2533 struct cmd_config_rxtx_queue {
2534 cmdline_fixed_string_t port;
2536 cmdline_fixed_string_t rxtxq;
2538 cmdline_fixed_string_t opname;
2542 cmd_config_rxtx_queue_parsed(void *parsed_result,
2543 __rte_unused struct cmdline *cl,
2544 __rte_unused void *data)
2546 struct cmd_config_rxtx_queue *res = parsed_result;
2551 if (test_done == 0) {
2552 printf("Please stop forwarding first\n");
2556 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2559 if (port_is_started(res->portid) != 1) {
2560 printf("Please start port %u first\n", res->portid);
2564 if (!strcmp(res->rxtxq, "rxq"))
2566 else if (!strcmp(res->rxtxq, "txq"))
2569 printf("Unknown parameter\n");
2573 if (isrx && rx_queue_id_is_invalid(res->qid))
2575 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2578 if (!strcmp(res->opname, "start"))
2580 else if (!strcmp(res->opname, "stop"))
2583 printf("Unknown parameter\n");
2587 if (isstart && isrx)
2588 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2589 else if (!isstart && isrx)
2590 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2591 else if (isstart && !isrx)
2592 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2594 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2596 if (ret == -ENOTSUP)
2597 printf("Function not supported in PMD driver\n");
2600 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2601 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2602 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2603 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2604 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2605 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2606 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2607 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2608 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2609 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2612 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2613 .f = cmd_config_rxtx_queue_parsed,
2615 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2617 (void *)&cmd_config_rxtx_queue_port,
2618 (void *)&cmd_config_rxtx_queue_portid,
2619 (void *)&cmd_config_rxtx_queue_rxtxq,
2620 (void *)&cmd_config_rxtx_queue_qid,
2621 (void *)&cmd_config_rxtx_queue_opname,
2626 /* *** configure port rxq/txq deferred start on/off *** */
2627 struct cmd_config_deferred_start_rxtx_queue {
2628 cmdline_fixed_string_t port;
2630 cmdline_fixed_string_t rxtxq;
2632 cmdline_fixed_string_t opname;
2633 cmdline_fixed_string_t state;
2637 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2638 __rte_unused struct cmdline *cl,
2639 __rte_unused void *data)
2641 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2642 struct rte_port *port;
2645 uint8_t needreconfig = 0;
2647 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2650 if (port_is_started(res->port_id) != 0) {
2651 printf("Please stop port %u first\n", res->port_id);
2655 port = &ports[res->port_id];
2657 isrx = !strcmp(res->rxtxq, "rxq");
2659 if (isrx && rx_queue_id_is_invalid(res->qid))
2661 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2664 ison = !strcmp(res->state, "on");
2666 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2667 port->rx_conf[res->qid].rx_deferred_start = ison;
2669 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2670 port->tx_conf[res->qid].tx_deferred_start = ison;
2675 cmd_reconfig_device_queue(res->port_id, 0, 1);
2678 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2679 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2681 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2682 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2683 port_id, RTE_UINT16);
2684 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2685 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2687 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2688 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2690 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2691 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2692 opname, "deferred_start");
2693 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2694 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2697 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2698 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2700 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2702 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2703 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2704 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2705 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2706 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2707 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2712 /* *** configure port rxq/txq setup *** */
2713 struct cmd_setup_rxtx_queue {
2714 cmdline_fixed_string_t port;
2716 cmdline_fixed_string_t rxtxq;
2718 cmdline_fixed_string_t setup;
2721 /* Common CLI fields for queue setup */
2722 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2723 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2724 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2725 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2726 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2727 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2728 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2729 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2730 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2731 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2734 cmd_setup_rxtx_queue_parsed(
2735 void *parsed_result,
2736 __rte_unused struct cmdline *cl,
2737 __rte_unused void *data)
2739 struct cmd_setup_rxtx_queue *res = parsed_result;
2740 struct rte_port *port;
2741 struct rte_mempool *mp;
2742 unsigned int socket_id;
2746 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2749 if (res->portid == (portid_t)RTE_PORT_ALL) {
2750 printf("Invalid port id\n");
2754 if (!strcmp(res->rxtxq, "rxq"))
2756 else if (!strcmp(res->rxtxq, "txq"))
2759 printf("Unknown parameter\n");
2763 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2764 printf("Invalid rx queue\n");
2766 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2767 printf("Invalid tx queue\n");
2771 port = &ports[res->portid];
2773 socket_id = rxring_numa[res->portid];
2774 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2775 socket_id = port->socket_id;
2777 mp = mbuf_pool_find(socket_id, 0);
2779 printf("Failed to setup RX queue: "
2780 "No mempool allocation"
2781 " on the socket %d\n",
2782 rxring_numa[res->portid]);
2785 ret = rx_queue_setup(res->portid,
2787 port->nb_rx_desc[res->qid],
2789 &port->rx_conf[res->qid],
2792 printf("Failed to setup RX queue\n");
2794 socket_id = txring_numa[res->portid];
2795 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2796 socket_id = port->socket_id;
2798 ret = rte_eth_tx_queue_setup(res->portid,
2800 port->nb_tx_desc[res->qid],
2802 &port->tx_conf[res->qid]);
2804 printf("Failed to setup TX queue\n");
2808 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2809 .f = cmd_setup_rxtx_queue_parsed,
2811 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2813 (void *)&cmd_setup_rxtx_queue_port,
2814 (void *)&cmd_setup_rxtx_queue_portid,
2815 (void *)&cmd_setup_rxtx_queue_rxtxq,
2816 (void *)&cmd_setup_rxtx_queue_qid,
2817 (void *)&cmd_setup_rxtx_queue_setup,
2823 /* *** Configure RSS RETA *** */
2824 struct cmd_config_rss_reta {
2825 cmdline_fixed_string_t port;
2826 cmdline_fixed_string_t keyword;
2828 cmdline_fixed_string_t name;
2829 cmdline_fixed_string_t list_name;
2830 cmdline_fixed_string_t list_of_items;
2834 parse_reta_config(const char *str,
2835 struct rte_eth_rss_reta_entry64 *reta_conf,
2836 uint16_t nb_entries)
2840 uint16_t hash_index, idx, shift;
2843 const char *p, *p0 = str;
2850 unsigned long int_fld[_NUM_FLD];
2851 char *str_fld[_NUM_FLD];
2853 while ((p = strchr(p0,'(')) != NULL) {
2855 if((p0 = strchr(p,')')) == NULL)
2859 if(size >= sizeof(s))
2862 snprintf(s, sizeof(s), "%.*s", size, p);
2863 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2865 for (i = 0; i < _NUM_FLD; i++) {
2867 int_fld[i] = strtoul(str_fld[i], &end, 0);
2868 if (errno != 0 || end == str_fld[i] ||
2873 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2874 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2876 if (hash_index >= nb_entries) {
2877 printf("Invalid RETA hash index=%d\n", hash_index);
2881 idx = hash_index / RTE_RETA_GROUP_SIZE;
2882 shift = hash_index % RTE_RETA_GROUP_SIZE;
2883 reta_conf[idx].mask |= (1ULL << shift);
2884 reta_conf[idx].reta[shift] = nb_queue;
2891 cmd_set_rss_reta_parsed(void *parsed_result,
2892 __rte_unused struct cmdline *cl,
2893 __rte_unused void *data)
2896 struct rte_eth_dev_info dev_info;
2897 struct rte_eth_rss_reta_entry64 reta_conf[8];
2898 struct cmd_config_rss_reta *res = parsed_result;
2900 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2904 if (dev_info.reta_size == 0) {
2905 printf("Redirection table size is 0 which is "
2906 "invalid for RSS\n");
2909 printf("The reta size of port %d is %u\n",
2910 res->port_id, dev_info.reta_size);
2911 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2912 printf("Currently do not support more than %u entries of "
2913 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2917 memset(reta_conf, 0, sizeof(reta_conf));
2918 if (!strcmp(res->list_name, "reta")) {
2919 if (parse_reta_config(res->list_of_items, reta_conf,
2920 dev_info.reta_size)) {
2921 printf("Invalid RSS Redirection Table "
2922 "config entered\n");
2925 ret = rte_eth_dev_rss_reta_update(res->port_id,
2926 reta_conf, dev_info.reta_size);
2928 printf("Bad redirection table parameter, "
2929 "return code = %d \n", ret);
2933 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2934 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2935 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2936 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2937 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2938 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
2939 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2940 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2941 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2942 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2943 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2944 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2946 cmdline_parse_inst_t cmd_config_rss_reta = {
2947 .f = cmd_set_rss_reta_parsed,
2949 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2951 (void *)&cmd_config_rss_reta_port,
2952 (void *)&cmd_config_rss_reta_keyword,
2953 (void *)&cmd_config_rss_reta_port_id,
2954 (void *)&cmd_config_rss_reta_name,
2955 (void *)&cmd_config_rss_reta_list_name,
2956 (void *)&cmd_config_rss_reta_list_of_items,
2961 /* *** SHOW PORT RETA INFO *** */
2962 struct cmd_showport_reta {
2963 cmdline_fixed_string_t show;
2964 cmdline_fixed_string_t port;
2966 cmdline_fixed_string_t rss;
2967 cmdline_fixed_string_t reta;
2969 cmdline_fixed_string_t list_of_items;
2973 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2974 uint16_t nb_entries,
2978 const char *p, *p0 = str;
2983 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2984 RTE_RETA_GROUP_SIZE;
2987 p = strchr(p0, '(');
2991 p0 = strchr(p, ')');
2995 if (size >= sizeof(s)) {
2996 printf("The string size exceeds the internal buffer size\n");
2999 snprintf(s, sizeof(s), "%.*s", size, p);
3000 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3001 if (ret <= 0 || ret != num) {
3002 printf("The bits of masks do not match the number of "
3003 "reta entries: %u\n", num);
3006 for (i = 0; i < ret; i++)
3007 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3013 cmd_showport_reta_parsed(void *parsed_result,
3014 __rte_unused struct cmdline *cl,
3015 __rte_unused void *data)
3017 struct cmd_showport_reta *res = parsed_result;
3018 struct rte_eth_rss_reta_entry64 reta_conf[8];
3019 struct rte_eth_dev_info dev_info;
3020 uint16_t max_reta_size;
3023 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3027 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3028 if (res->size == 0 || res->size > max_reta_size) {
3029 printf("Invalid redirection table size: %u (1-%u)\n",
3030 res->size, max_reta_size);
3034 memset(reta_conf, 0, sizeof(reta_conf));
3035 if (showport_parse_reta_config(reta_conf, res->size,
3036 res->list_of_items) < 0) {
3037 printf("Invalid string: %s for reta masks\n",
3038 res->list_of_items);
3041 port_rss_reta_info(res->port_id, reta_conf, res->size);
3044 cmdline_parse_token_string_t cmd_showport_reta_show =
3045 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3046 cmdline_parse_token_string_t cmd_showport_reta_port =
3047 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3048 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3049 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3050 cmdline_parse_token_string_t cmd_showport_reta_rss =
3051 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3052 cmdline_parse_token_string_t cmd_showport_reta_reta =
3053 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3054 cmdline_parse_token_num_t cmd_showport_reta_size =
3055 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3056 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3057 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3058 list_of_items, NULL);
3060 cmdline_parse_inst_t cmd_showport_reta = {
3061 .f = cmd_showport_reta_parsed,
3063 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3065 (void *)&cmd_showport_reta_show,
3066 (void *)&cmd_showport_reta_port,
3067 (void *)&cmd_showport_reta_port_id,
3068 (void *)&cmd_showport_reta_rss,
3069 (void *)&cmd_showport_reta_reta,
3070 (void *)&cmd_showport_reta_size,
3071 (void *)&cmd_showport_reta_list_of_items,
3076 /* *** Show RSS hash configuration *** */
3077 struct cmd_showport_rss_hash {
3078 cmdline_fixed_string_t show;
3079 cmdline_fixed_string_t port;
3081 cmdline_fixed_string_t rss_hash;
3082 cmdline_fixed_string_t rss_type;
3083 cmdline_fixed_string_t key; /* optional argument */
3086 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3087 __rte_unused struct cmdline *cl,
3090 struct cmd_showport_rss_hash *res = parsed_result;
3092 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3095 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3096 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3097 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3098 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3099 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3100 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3102 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3103 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3105 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3106 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3108 cmdline_parse_inst_t cmd_showport_rss_hash = {
3109 .f = cmd_showport_rss_hash_parsed,
3111 .help_str = "show port <port_id> rss-hash",
3113 (void *)&cmd_showport_rss_hash_show,
3114 (void *)&cmd_showport_rss_hash_port,
3115 (void *)&cmd_showport_rss_hash_port_id,
3116 (void *)&cmd_showport_rss_hash_rss_hash,
3121 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3122 .f = cmd_showport_rss_hash_parsed,
3124 .help_str = "show port <port_id> rss-hash key",
3126 (void *)&cmd_showport_rss_hash_show,
3127 (void *)&cmd_showport_rss_hash_port,
3128 (void *)&cmd_showport_rss_hash_port_id,
3129 (void *)&cmd_showport_rss_hash_rss_hash,
3130 (void *)&cmd_showport_rss_hash_rss_key,
3135 /* *** Configure DCB *** */
3136 struct cmd_config_dcb {
3137 cmdline_fixed_string_t port;
3138 cmdline_fixed_string_t config;
3140 cmdline_fixed_string_t dcb;
3141 cmdline_fixed_string_t vt;
3142 cmdline_fixed_string_t vt_en;
3144 cmdline_fixed_string_t pfc;
3145 cmdline_fixed_string_t pfc_en;
3149 cmd_config_dcb_parsed(void *parsed_result,
3150 __rte_unused struct cmdline *cl,
3151 __rte_unused void *data)
3153 struct cmd_config_dcb *res = parsed_result;
3154 portid_t port_id = res->port_id;
3155 struct rte_port *port;
3159 port = &ports[port_id];
3160 /** Check if the port is not started **/
3161 if (port->port_status != RTE_PORT_STOPPED) {
3162 printf("Please stop port %d first\n", port_id);
3166 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3167 printf("The invalid number of traffic class,"
3168 " only 4 or 8 allowed.\n");
3172 if (nb_fwd_lcores < res->num_tcs) {
3173 printf("nb_cores shouldn't be less than number of TCs.\n");
3176 if (!strncmp(res->pfc_en, "on", 2))
3181 /* DCB in VT mode */
3182 if (!strncmp(res->vt_en, "on", 2))
3183 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3184 (enum rte_eth_nb_tcs)res->num_tcs,
3187 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3188 (enum rte_eth_nb_tcs)res->num_tcs,
3193 printf("Cannot initialize network ports.\n");
3197 cmd_reconfig_device_queue(port_id, 1, 1);
3200 cmdline_parse_token_string_t cmd_config_dcb_port =
3201 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3202 cmdline_parse_token_string_t cmd_config_dcb_config =
3203 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3204 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3205 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3206 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3207 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3208 cmdline_parse_token_string_t cmd_config_dcb_vt =
3209 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3210 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3211 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3212 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3213 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3214 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3215 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3216 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3217 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3219 cmdline_parse_inst_t cmd_config_dcb = {
3220 .f = cmd_config_dcb_parsed,
3222 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3224 (void *)&cmd_config_dcb_port,
3225 (void *)&cmd_config_dcb_config,
3226 (void *)&cmd_config_dcb_port_id,
3227 (void *)&cmd_config_dcb_dcb,
3228 (void *)&cmd_config_dcb_vt,
3229 (void *)&cmd_config_dcb_vt_en,
3230 (void *)&cmd_config_dcb_num_tcs,
3231 (void *)&cmd_config_dcb_pfc,
3232 (void *)&cmd_config_dcb_pfc_en,
3237 /* *** configure number of packets per burst *** */
3238 struct cmd_config_burst {
3239 cmdline_fixed_string_t port;
3240 cmdline_fixed_string_t keyword;
3241 cmdline_fixed_string_t all;
3242 cmdline_fixed_string_t name;
3247 cmd_config_burst_parsed(void *parsed_result,
3248 __rte_unused struct cmdline *cl,
3249 __rte_unused void *data)
3251 struct cmd_config_burst *res = parsed_result;
3252 struct rte_eth_dev_info dev_info;
3253 uint16_t rec_nb_pkts;
3256 if (!all_ports_stopped()) {
3257 printf("Please stop all ports first\n");
3261 if (!strcmp(res->name, "burst")) {
3262 if (res->value == 0) {
3263 /* If user gives a value of zero, query the PMD for
3264 * its recommended Rx burst size. Testpmd uses a single
3265 * size for all ports, so assume all ports are the same
3266 * NIC model and use the values from Port 0.
3268 ret = eth_dev_info_get_print_err(0, &dev_info);
3272 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3274 if (rec_nb_pkts == 0) {
3275 printf("PMD does not recommend a burst size.\n"
3276 "User provided value must be between"
3277 " 1 and %d\n", MAX_PKT_BURST);
3279 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3280 printf("PMD recommended burst size of %d"
3281 " exceeds maximum value of %d\n",
3282 rec_nb_pkts, MAX_PKT_BURST);
3285 printf("Using PMD-provided burst value of %d\n",
3287 nb_pkt_per_burst = rec_nb_pkts;
3288 } else if (res->value > MAX_PKT_BURST) {
3289 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3292 nb_pkt_per_burst = res->value;
3294 printf("Unknown parameter\n");
3300 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3303 cmdline_parse_token_string_t cmd_config_burst_port =
3304 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3305 cmdline_parse_token_string_t cmd_config_burst_keyword =
3306 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3307 cmdline_parse_token_string_t cmd_config_burst_all =
3308 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3309 cmdline_parse_token_string_t cmd_config_burst_name =
3310 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3311 cmdline_parse_token_num_t cmd_config_burst_value =
3312 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3314 cmdline_parse_inst_t cmd_config_burst = {
3315 .f = cmd_config_burst_parsed,
3317 .help_str = "port config all burst <value>",
3319 (void *)&cmd_config_burst_port,
3320 (void *)&cmd_config_burst_keyword,
3321 (void *)&cmd_config_burst_all,
3322 (void *)&cmd_config_burst_name,
3323 (void *)&cmd_config_burst_value,
3328 /* *** configure rx/tx queues *** */
3329 struct cmd_config_thresh {
3330 cmdline_fixed_string_t port;
3331 cmdline_fixed_string_t keyword;
3332 cmdline_fixed_string_t all;
3333 cmdline_fixed_string_t name;
3338 cmd_config_thresh_parsed(void *parsed_result,
3339 __rte_unused struct cmdline *cl,
3340 __rte_unused void *data)
3342 struct cmd_config_thresh *res = parsed_result;
3344 if (!all_ports_stopped()) {
3345 printf("Please stop all ports first\n");
3349 if (!strcmp(res->name, "txpt"))
3350 tx_pthresh = res->value;
3351 else if(!strcmp(res->name, "txht"))
3352 tx_hthresh = res->value;
3353 else if(!strcmp(res->name, "txwt"))
3354 tx_wthresh = res->value;
3355 else if(!strcmp(res->name, "rxpt"))
3356 rx_pthresh = res->value;
3357 else if(!strcmp(res->name, "rxht"))
3358 rx_hthresh = res->value;
3359 else if(!strcmp(res->name, "rxwt"))
3360 rx_wthresh = res->value;
3362 printf("Unknown parameter\n");
3368 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3371 cmdline_parse_token_string_t cmd_config_thresh_port =
3372 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3373 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3374 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3375 cmdline_parse_token_string_t cmd_config_thresh_all =
3376 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3377 cmdline_parse_token_string_t cmd_config_thresh_name =
3378 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3379 "txpt#txht#txwt#rxpt#rxht#rxwt");
3380 cmdline_parse_token_num_t cmd_config_thresh_value =
3381 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3383 cmdline_parse_inst_t cmd_config_thresh = {
3384 .f = cmd_config_thresh_parsed,
3386 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3388 (void *)&cmd_config_thresh_port,
3389 (void *)&cmd_config_thresh_keyword,
3390 (void *)&cmd_config_thresh_all,
3391 (void *)&cmd_config_thresh_name,
3392 (void *)&cmd_config_thresh_value,
3397 /* *** configure free/rs threshold *** */
3398 struct cmd_config_threshold {
3399 cmdline_fixed_string_t port;
3400 cmdline_fixed_string_t keyword;
3401 cmdline_fixed_string_t all;
3402 cmdline_fixed_string_t name;
3407 cmd_config_threshold_parsed(void *parsed_result,
3408 __rte_unused struct cmdline *cl,
3409 __rte_unused void *data)
3411 struct cmd_config_threshold *res = parsed_result;
3413 if (!all_ports_stopped()) {
3414 printf("Please stop all ports first\n");
3418 if (!strcmp(res->name, "txfreet"))
3419 tx_free_thresh = res->value;
3420 else if (!strcmp(res->name, "txrst"))
3421 tx_rs_thresh = res->value;
3422 else if (!strcmp(res->name, "rxfreet"))
3423 rx_free_thresh = res->value;
3425 printf("Unknown parameter\n");
3431 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3434 cmdline_parse_token_string_t cmd_config_threshold_port =
3435 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3436 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3437 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3439 cmdline_parse_token_string_t cmd_config_threshold_all =
3440 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3441 cmdline_parse_token_string_t cmd_config_threshold_name =
3442 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3443 "txfreet#txrst#rxfreet");
3444 cmdline_parse_token_num_t cmd_config_threshold_value =
3445 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3447 cmdline_parse_inst_t cmd_config_threshold = {
3448 .f = cmd_config_threshold_parsed,
3450 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3452 (void *)&cmd_config_threshold_port,
3453 (void *)&cmd_config_threshold_keyword,
3454 (void *)&cmd_config_threshold_all,
3455 (void *)&cmd_config_threshold_name,
3456 (void *)&cmd_config_threshold_value,
3462 struct cmd_stop_result {
3463 cmdline_fixed_string_t stop;
3466 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3467 __rte_unused struct cmdline *cl,
3468 __rte_unused void *data)
3470 stop_packet_forwarding();
3473 cmdline_parse_token_string_t cmd_stop_stop =
3474 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3476 cmdline_parse_inst_t cmd_stop = {
3477 .f = cmd_stop_parsed,
3479 .help_str = "stop: Stop packet forwarding",
3481 (void *)&cmd_stop_stop,
3486 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3489 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3490 unsigned int *parsed_items, int check_unique_values)
3492 unsigned int nb_item;
3500 * First parse all items in the list and store their value.
3505 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3507 if ((c >= '0') && (c <= '9')) {
3508 value = (unsigned int) (value * 10 + (c - '0'));
3513 printf("character %c is not a decimal digit\n", c);
3517 printf("No valid value before comma\n");
3520 if (nb_item < max_items) {
3521 parsed_items[nb_item] = value;
3527 if (nb_item >= max_items) {
3528 printf("Number of %s = %u > %u (maximum items)\n",
3529 item_name, nb_item + 1, max_items);
3532 parsed_items[nb_item++] = value;
3533 if (! check_unique_values)
3537 * Then, check that all values in the list are differents.
3538 * No optimization here...
3540 for (i = 0; i < nb_item; i++) {
3541 for (j = i + 1; j < nb_item; j++) {
3542 if (parsed_items[j] == parsed_items[i]) {
3543 printf("duplicated %s %u at index %u and %u\n",
3544 item_name, parsed_items[i], i, j);
3552 struct cmd_set_list_result {
3553 cmdline_fixed_string_t cmd_keyword;
3554 cmdline_fixed_string_t list_name;
3555 cmdline_fixed_string_t list_of_items;
3558 static void cmd_set_list_parsed(void *parsed_result,
3559 __rte_unused struct cmdline *cl,
3560 __rte_unused void *data)
3562 struct cmd_set_list_result *res;
3564 unsigned int lcorelist[RTE_MAX_LCORE];
3565 unsigned int portlist[RTE_MAX_ETHPORTS];
3567 unsigned int nb_item;
3569 if (test_done == 0) {
3570 printf("Please stop forwarding first\n");
3574 res = parsed_result;
3575 if (!strcmp(res->list_name, "corelist")) {
3576 nb_item = parse_item_list(res->list_of_items, "core",
3578 parsed_items.lcorelist, 1);
3580 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3585 if (!strcmp(res->list_name, "portlist")) {
3586 nb_item = parse_item_list(res->list_of_items, "port",
3588 parsed_items.portlist, 1);
3590 set_fwd_ports_list(parsed_items.portlist, nb_item);
3596 cmdline_parse_token_string_t cmd_set_list_keyword =
3597 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3599 cmdline_parse_token_string_t cmd_set_list_name =
3600 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3601 "corelist#portlist");
3602 cmdline_parse_token_string_t cmd_set_list_of_items =
3603 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3606 cmdline_parse_inst_t cmd_set_fwd_list = {
3607 .f = cmd_set_list_parsed,
3609 .help_str = "set corelist|portlist <list0[,list1]*>",
3611 (void *)&cmd_set_list_keyword,
3612 (void *)&cmd_set_list_name,
3613 (void *)&cmd_set_list_of_items,
3618 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3620 struct cmd_setmask_result {
3621 cmdline_fixed_string_t set;
3622 cmdline_fixed_string_t mask;
3626 static void cmd_set_mask_parsed(void *parsed_result,
3627 __rte_unused struct cmdline *cl,
3628 __rte_unused void *data)
3630 struct cmd_setmask_result *res = parsed_result;
3632 if (test_done == 0) {
3633 printf("Please stop forwarding first\n");
3636 if (!strcmp(res->mask, "coremask")) {
3637 set_fwd_lcores_mask(res->hexavalue);
3639 } else if (!strcmp(res->mask, "portmask")) {
3640 set_fwd_ports_mask(res->hexavalue);
3645 cmdline_parse_token_string_t cmd_setmask_set =
3646 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3647 cmdline_parse_token_string_t cmd_setmask_mask =
3648 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3649 "coremask#portmask");
3650 cmdline_parse_token_num_t cmd_setmask_value =
3651 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3653 cmdline_parse_inst_t cmd_set_fwd_mask = {
3654 .f = cmd_set_mask_parsed,
3656 .help_str = "set coremask|portmask <hexadecimal value>",
3658 (void *)&cmd_setmask_set,
3659 (void *)&cmd_setmask_mask,
3660 (void *)&cmd_setmask_value,
3666 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3668 struct cmd_set_result {
3669 cmdline_fixed_string_t set;
3670 cmdline_fixed_string_t what;
3674 static void cmd_set_parsed(void *parsed_result,
3675 __rte_unused struct cmdline *cl,
3676 __rte_unused void *data)
3678 struct cmd_set_result *res = parsed_result;
3679 if (!strcmp(res->what, "nbport")) {
3680 set_fwd_ports_number(res->value);
3682 } else if (!strcmp(res->what, "nbcore")) {
3683 set_fwd_lcores_number(res->value);
3685 } else if (!strcmp(res->what, "burst"))
3686 set_nb_pkt_per_burst(res->value);
3687 else if (!strcmp(res->what, "verbose"))
3688 set_verbose_level(res->value);
3691 cmdline_parse_token_string_t cmd_set_set =
3692 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3693 cmdline_parse_token_string_t cmd_set_what =
3694 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3695 "nbport#nbcore#burst#verbose");
3696 cmdline_parse_token_num_t cmd_set_value =
3697 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3699 cmdline_parse_inst_t cmd_set_numbers = {
3700 .f = cmd_set_parsed,
3702 .help_str = "set nbport|nbcore|burst|verbose <value>",
3704 (void *)&cmd_set_set,
3705 (void *)&cmd_set_what,
3706 (void *)&cmd_set_value,
3711 /* *** SET LOG LEVEL CONFIGURATION *** */
3713 struct cmd_set_log_result {
3714 cmdline_fixed_string_t set;
3715 cmdline_fixed_string_t log;
3716 cmdline_fixed_string_t type;
3721 cmd_set_log_parsed(void *parsed_result,
3722 __rte_unused struct cmdline *cl,
3723 __rte_unused void *data)
3725 struct cmd_set_log_result *res;
3728 res = parsed_result;
3729 if (!strcmp(res->type, "global"))
3730 rte_log_set_global_level(res->level);
3732 ret = rte_log_set_level_regexp(res->type, res->level);
3734 printf("Unable to set log level\n");
3738 cmdline_parse_token_string_t cmd_set_log_set =
3739 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3740 cmdline_parse_token_string_t cmd_set_log_log =
3741 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3742 cmdline_parse_token_string_t cmd_set_log_type =
3743 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3744 cmdline_parse_token_num_t cmd_set_log_level =
3745 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3747 cmdline_parse_inst_t cmd_set_log = {
3748 .f = cmd_set_log_parsed,
3750 .help_str = "set log global|<type> <level>",
3752 (void *)&cmd_set_log_set,
3753 (void *)&cmd_set_log_log,
3754 (void *)&cmd_set_log_type,
3755 (void *)&cmd_set_log_level,
3760 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3762 struct cmd_set_rxoffs_result {
3763 cmdline_fixed_string_t cmd_keyword;
3764 cmdline_fixed_string_t rxoffs;
3765 cmdline_fixed_string_t seg_offsets;
3769 cmd_set_rxoffs_parsed(void *parsed_result,
3770 __rte_unused struct cmdline *cl,
3771 __rte_unused void *data)
3773 struct cmd_set_rxoffs_result *res;
3774 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3775 unsigned int nb_segs;
3777 res = parsed_result;
3778 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3779 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3781 set_rx_pkt_offsets(seg_offsets, nb_segs);
3784 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3785 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3786 cmd_keyword, "set");
3787 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3788 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3790 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3791 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3794 cmdline_parse_inst_t cmd_set_rxoffs = {
3795 .f = cmd_set_rxoffs_parsed,
3797 .help_str = "set rxoffs <len0[,len1]*>",
3799 (void *)&cmd_set_rxoffs_keyword,
3800 (void *)&cmd_set_rxoffs_name,
3801 (void *)&cmd_set_rxoffs_offsets,
3806 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3808 struct cmd_set_rxpkts_result {
3809 cmdline_fixed_string_t cmd_keyword;
3810 cmdline_fixed_string_t rxpkts;
3811 cmdline_fixed_string_t seg_lengths;
3815 cmd_set_rxpkts_parsed(void *parsed_result,
3816 __rte_unused struct cmdline *cl,
3817 __rte_unused void *data)
3819 struct cmd_set_rxpkts_result *res;
3820 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3821 unsigned int nb_segs;
3823 res = parsed_result;
3824 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3825 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3827 set_rx_pkt_segments(seg_lengths, nb_segs);
3830 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3831 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3832 cmd_keyword, "set");
3833 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3834 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3836 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3837 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3840 cmdline_parse_inst_t cmd_set_rxpkts = {
3841 .f = cmd_set_rxpkts_parsed,
3843 .help_str = "set rxpkts <len0[,len1]*>",
3845 (void *)&cmd_set_rxpkts_keyword,
3846 (void *)&cmd_set_rxpkts_name,
3847 (void *)&cmd_set_rxpkts_lengths,
3852 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3854 struct cmd_set_txpkts_result {
3855 cmdline_fixed_string_t cmd_keyword;
3856 cmdline_fixed_string_t txpkts;
3857 cmdline_fixed_string_t seg_lengths;
3861 cmd_set_txpkts_parsed(void *parsed_result,
3862 __rte_unused struct cmdline *cl,
3863 __rte_unused void *data)
3865 struct cmd_set_txpkts_result *res;
3866 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3867 unsigned int nb_segs;
3869 res = parsed_result;
3870 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3871 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3873 set_tx_pkt_segments(seg_lengths, nb_segs);
3876 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3877 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3878 cmd_keyword, "set");
3879 cmdline_parse_token_string_t cmd_set_txpkts_name =
3880 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3882 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3883 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3886 cmdline_parse_inst_t cmd_set_txpkts = {
3887 .f = cmd_set_txpkts_parsed,
3889 .help_str = "set txpkts <len0[,len1]*>",
3891 (void *)&cmd_set_txpkts_keyword,
3892 (void *)&cmd_set_txpkts_name,
3893 (void *)&cmd_set_txpkts_lengths,
3898 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3900 struct cmd_set_txsplit_result {
3901 cmdline_fixed_string_t cmd_keyword;
3902 cmdline_fixed_string_t txsplit;
3903 cmdline_fixed_string_t mode;
3907 cmd_set_txsplit_parsed(void *parsed_result,
3908 __rte_unused struct cmdline *cl,
3909 __rte_unused void *data)
3911 struct cmd_set_txsplit_result *res;
3913 res = parsed_result;
3914 set_tx_pkt_split(res->mode);
3917 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3918 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3919 cmd_keyword, "set");
3920 cmdline_parse_token_string_t cmd_set_txsplit_name =
3921 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3922 txsplit, "txsplit");
3923 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3924 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3927 cmdline_parse_inst_t cmd_set_txsplit = {
3928 .f = cmd_set_txsplit_parsed,
3930 .help_str = "set txsplit on|off|rand",
3932 (void *)&cmd_set_txsplit_keyword,
3933 (void *)&cmd_set_txsplit_name,
3934 (void *)&cmd_set_txsplit_mode,
3939 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
3941 struct cmd_set_txtimes_result {
3942 cmdline_fixed_string_t cmd_keyword;
3943 cmdline_fixed_string_t txtimes;
3944 cmdline_fixed_string_t tx_times;
3948 cmd_set_txtimes_parsed(void *parsed_result,
3949 __rte_unused struct cmdline *cl,
3950 __rte_unused void *data)
3952 struct cmd_set_txtimes_result *res;
3953 unsigned int tx_times[2] = {0, 0};
3954 unsigned int n_times;
3956 res = parsed_result;
3957 n_times = parse_item_list(res->tx_times, "tx times",
3960 set_tx_pkt_times(tx_times);
3963 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
3964 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3965 cmd_keyword, "set");
3966 cmdline_parse_token_string_t cmd_set_txtimes_name =
3967 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3968 txtimes, "txtimes");
3969 cmdline_parse_token_string_t cmd_set_txtimes_value =
3970 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3973 cmdline_parse_inst_t cmd_set_txtimes = {
3974 .f = cmd_set_txtimes_parsed,
3976 .help_str = "set txtimes <inter_burst>,<intra_burst>",
3978 (void *)&cmd_set_txtimes_keyword,
3979 (void *)&cmd_set_txtimes_name,
3980 (void *)&cmd_set_txtimes_value,
3985 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3986 struct cmd_rx_vlan_filter_all_result {
3987 cmdline_fixed_string_t rx_vlan;
3988 cmdline_fixed_string_t what;
3989 cmdline_fixed_string_t all;
3994 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3995 __rte_unused struct cmdline *cl,
3996 __rte_unused void *data)
3998 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4000 if (!strcmp(res->what, "add"))
4001 rx_vlan_all_filter_set(res->port_id, 1);
4003 rx_vlan_all_filter_set(res->port_id, 0);
4006 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4007 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4008 rx_vlan, "rx_vlan");
4009 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4010 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4012 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4013 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4015 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4016 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4017 port_id, RTE_UINT16);
4019 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4020 .f = cmd_rx_vlan_filter_all_parsed,
4022 .help_str = "rx_vlan add|rm all <port_id>: "
4023 "Add/Remove all identifiers to/from the set of VLAN "
4024 "identifiers filtered by a port",
4026 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4027 (void *)&cmd_rx_vlan_filter_all_what,
4028 (void *)&cmd_rx_vlan_filter_all_all,
4029 (void *)&cmd_rx_vlan_filter_all_portid,
4034 /* *** VLAN OFFLOAD SET ON A PORT *** */
4035 struct cmd_vlan_offload_result {
4036 cmdline_fixed_string_t vlan;
4037 cmdline_fixed_string_t set;
4038 cmdline_fixed_string_t vlan_type;
4039 cmdline_fixed_string_t what;
4040 cmdline_fixed_string_t on;
4041 cmdline_fixed_string_t port_id;
4045 cmd_vlan_offload_parsed(void *parsed_result,
4046 __rte_unused struct cmdline *cl,
4047 __rte_unused void *data)
4050 struct cmd_vlan_offload_result *res = parsed_result;
4053 portid_t port_id = 0;
4057 len = strnlen(str, STR_TOKEN_SIZE);
4059 /* Get port_id first */
4067 tmp = strtoul(str, NULL, 0);
4068 /* If port_id greater that what portid_t can represent, return */
4069 if(tmp >= RTE_MAX_ETHPORTS)
4071 port_id = (portid_t)tmp;
4073 if (!strcmp(res->on, "on"))
4078 if (!strcmp(res->what, "strip"))
4079 rx_vlan_strip_set(port_id, on);
4080 else if(!strcmp(res->what, "stripq")){
4081 uint16_t queue_id = 0;
4083 /* No queue_id, return */
4085 printf("must specify (port,queue_id)\n");
4088 tmp = strtoul(str + i + 1, NULL, 0);
4089 /* If queue_id greater that what 16-bits can represent, return */
4093 queue_id = (uint16_t)tmp;
4094 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4096 else if (!strcmp(res->what, "filter"))
4097 rx_vlan_filter_set(port_id, on);
4098 else if (!strcmp(res->what, "qinq_strip"))
4099 rx_vlan_qinq_strip_set(port_id, on);
4101 vlan_extend_set(port_id, on);
4106 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4107 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4109 cmdline_parse_token_string_t cmd_vlan_offload_set =
4110 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4112 cmdline_parse_token_string_t cmd_vlan_offload_what =
4113 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4114 what, "strip#filter#qinq_strip#extend#stripq");
4115 cmdline_parse_token_string_t cmd_vlan_offload_on =
4116 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4118 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4119 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4122 cmdline_parse_inst_t cmd_vlan_offload = {
4123 .f = cmd_vlan_offload_parsed,
4125 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4126 "<port_id[,queue_id]>: "
4127 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4129 (void *)&cmd_vlan_offload_vlan,
4130 (void *)&cmd_vlan_offload_set,
4131 (void *)&cmd_vlan_offload_what,
4132 (void *)&cmd_vlan_offload_on,
4133 (void *)&cmd_vlan_offload_portid,
4138 /* *** VLAN TPID SET ON A PORT *** */
4139 struct cmd_vlan_tpid_result {
4140 cmdline_fixed_string_t vlan;
4141 cmdline_fixed_string_t set;
4142 cmdline_fixed_string_t vlan_type;
4143 cmdline_fixed_string_t what;
4149 cmd_vlan_tpid_parsed(void *parsed_result,
4150 __rte_unused struct cmdline *cl,
4151 __rte_unused void *data)
4153 struct cmd_vlan_tpid_result *res = parsed_result;
4154 enum rte_vlan_type vlan_type;
4156 if (!strcmp(res->vlan_type, "inner"))
4157 vlan_type = ETH_VLAN_TYPE_INNER;
4158 else if (!strcmp(res->vlan_type, "outer"))
4159 vlan_type = ETH_VLAN_TYPE_OUTER;
4161 printf("Unknown vlan type\n");
4164 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4167 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4168 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4170 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4171 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4173 cmdline_parse_token_string_t cmd_vlan_type =
4174 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4175 vlan_type, "inner#outer");
4176 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4177 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4179 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4180 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4182 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4183 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4184 port_id, RTE_UINT16);
4186 cmdline_parse_inst_t cmd_vlan_tpid = {
4187 .f = cmd_vlan_tpid_parsed,
4189 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4190 "Set the VLAN Ether type",
4192 (void *)&cmd_vlan_tpid_vlan,
4193 (void *)&cmd_vlan_tpid_set,
4194 (void *)&cmd_vlan_type,
4195 (void *)&cmd_vlan_tpid_what,
4196 (void *)&cmd_vlan_tpid_tpid,
4197 (void *)&cmd_vlan_tpid_portid,
4202 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4203 struct cmd_rx_vlan_filter_result {
4204 cmdline_fixed_string_t rx_vlan;
4205 cmdline_fixed_string_t what;
4211 cmd_rx_vlan_filter_parsed(void *parsed_result,
4212 __rte_unused struct cmdline *cl,
4213 __rte_unused void *data)
4215 struct cmd_rx_vlan_filter_result *res = parsed_result;
4217 if (!strcmp(res->what, "add"))
4218 rx_vft_set(res->port_id, res->vlan_id, 1);
4220 rx_vft_set(res->port_id, res->vlan_id, 0);
4223 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4224 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4225 rx_vlan, "rx_vlan");
4226 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4227 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4229 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4230 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4231 vlan_id, RTE_UINT16);
4232 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4233 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4234 port_id, RTE_UINT16);
4236 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4237 .f = cmd_rx_vlan_filter_parsed,
4239 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4240 "Add/Remove a VLAN identifier to/from the set of VLAN "
4241 "identifiers filtered by a port",
4243 (void *)&cmd_rx_vlan_filter_rx_vlan,
4244 (void *)&cmd_rx_vlan_filter_what,
4245 (void *)&cmd_rx_vlan_filter_vlanid,
4246 (void *)&cmd_rx_vlan_filter_portid,
4251 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4252 struct cmd_tx_vlan_set_result {
4253 cmdline_fixed_string_t tx_vlan;
4254 cmdline_fixed_string_t set;
4260 cmd_tx_vlan_set_parsed(void *parsed_result,
4261 __rte_unused struct cmdline *cl,
4262 __rte_unused void *data)
4264 struct cmd_tx_vlan_set_result *res = parsed_result;
4266 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4269 if (!port_is_stopped(res->port_id)) {
4270 printf("Please stop port %d first\n", res->port_id);
4274 tx_vlan_set(res->port_id, res->vlan_id);
4276 cmd_reconfig_device_queue(res->port_id, 1, 1);
4279 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4280 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4281 tx_vlan, "tx_vlan");
4282 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4283 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4285 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4286 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4287 port_id, RTE_UINT16);
4288 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4289 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4290 vlan_id, RTE_UINT16);
4292 cmdline_parse_inst_t cmd_tx_vlan_set = {
4293 .f = cmd_tx_vlan_set_parsed,
4295 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4296 "Enable hardware insertion of a single VLAN header "
4297 "with a given TAG Identifier in packets sent on a port",
4299 (void *)&cmd_tx_vlan_set_tx_vlan,
4300 (void *)&cmd_tx_vlan_set_set,
4301 (void *)&cmd_tx_vlan_set_portid,
4302 (void *)&cmd_tx_vlan_set_vlanid,
4307 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4308 struct cmd_tx_vlan_set_qinq_result {
4309 cmdline_fixed_string_t tx_vlan;
4310 cmdline_fixed_string_t set;
4313 uint16_t vlan_id_outer;
4317 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4318 __rte_unused struct cmdline *cl,
4319 __rte_unused void *data)
4321 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4323 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4326 if (!port_is_stopped(res->port_id)) {
4327 printf("Please stop port %d first\n", res->port_id);
4331 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4333 cmd_reconfig_device_queue(res->port_id, 1, 1);
4336 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4337 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4338 tx_vlan, "tx_vlan");
4339 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4340 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4342 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4343 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4344 port_id, RTE_UINT16);
4345 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4346 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4347 vlan_id, RTE_UINT16);
4348 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4349 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4350 vlan_id_outer, RTE_UINT16);
4352 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4353 .f = cmd_tx_vlan_set_qinq_parsed,
4355 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4356 "Enable hardware insertion of double VLAN header "
4357 "with given TAG Identifiers in packets sent on a port",
4359 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4360 (void *)&cmd_tx_vlan_set_qinq_set,
4361 (void *)&cmd_tx_vlan_set_qinq_portid,
4362 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4363 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4368 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4369 struct cmd_tx_vlan_set_pvid_result {
4370 cmdline_fixed_string_t tx_vlan;
4371 cmdline_fixed_string_t set;
4372 cmdline_fixed_string_t pvid;
4375 cmdline_fixed_string_t mode;
4379 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4380 __rte_unused struct cmdline *cl,
4381 __rte_unused void *data)
4383 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4385 if (strcmp(res->mode, "on") == 0)
4386 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4388 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4391 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4392 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4393 tx_vlan, "tx_vlan");
4394 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4395 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4397 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4398 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4400 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4401 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4402 port_id, RTE_UINT16);
4403 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4404 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4405 vlan_id, RTE_UINT16);
4406 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4407 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4410 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4411 .f = cmd_tx_vlan_set_pvid_parsed,
4413 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4415 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4416 (void *)&cmd_tx_vlan_set_pvid_set,
4417 (void *)&cmd_tx_vlan_set_pvid_pvid,
4418 (void *)&cmd_tx_vlan_set_pvid_port_id,
4419 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4420 (void *)&cmd_tx_vlan_set_pvid_mode,
4425 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4426 struct cmd_tx_vlan_reset_result {
4427 cmdline_fixed_string_t tx_vlan;
4428 cmdline_fixed_string_t reset;
4433 cmd_tx_vlan_reset_parsed(void *parsed_result,
4434 __rte_unused struct cmdline *cl,
4435 __rte_unused void *data)
4437 struct cmd_tx_vlan_reset_result *res = parsed_result;
4439 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4442 if (!port_is_stopped(res->port_id)) {
4443 printf("Please stop port %d first\n", res->port_id);
4447 tx_vlan_reset(res->port_id);
4449 cmd_reconfig_device_queue(res->port_id, 1, 1);
4452 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4453 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4454 tx_vlan, "tx_vlan");
4455 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4456 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4458 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4459 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4460 port_id, RTE_UINT16);
4462 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4463 .f = cmd_tx_vlan_reset_parsed,
4465 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4466 "VLAN header in packets sent on a port",
4468 (void *)&cmd_tx_vlan_reset_tx_vlan,
4469 (void *)&cmd_tx_vlan_reset_reset,
4470 (void *)&cmd_tx_vlan_reset_portid,
4476 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4477 struct cmd_csum_result {
4478 cmdline_fixed_string_t csum;
4479 cmdline_fixed_string_t mode;
4480 cmdline_fixed_string_t proto;
4481 cmdline_fixed_string_t hwsw;
4486 csum_show(int port_id)
4488 struct rte_eth_dev_info dev_info;
4489 uint64_t tx_offloads;
4492 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4493 printf("Parse tunnel is %s\n",
4494 (ports[port_id].parse_tunnel) ? "on" : "off");
4495 printf("IP checksum offload is %s\n",
4496 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4497 printf("UDP checksum offload is %s\n",
4498 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4499 printf("TCP checksum offload is %s\n",
4500 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4501 printf("SCTP checksum offload is %s\n",
4502 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4503 printf("Outer-Ip checksum offload is %s\n",
4504 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4505 printf("Outer-Udp checksum offload is %s\n",
4506 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4508 /* display warnings if configuration is not supported by the NIC */
4509 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4513 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4514 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4515 printf("Warning: hardware IP checksum enabled but not "
4516 "supported by port %d\n", port_id);
4518 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4519 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4520 printf("Warning: hardware UDP checksum enabled but not "
4521 "supported by port %d\n", port_id);
4523 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4524 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4525 printf("Warning: hardware TCP checksum enabled but not "
4526 "supported by port %d\n", port_id);
4528 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4529 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4530 printf("Warning: hardware SCTP checksum enabled but not "
4531 "supported by port %d\n", port_id);
4533 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4534 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4535 printf("Warning: hardware outer IP checksum enabled but not "
4536 "supported by port %d\n", port_id);
4538 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4539 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4541 printf("Warning: hardware outer UDP checksum enabled but not "
4542 "supported by port %d\n", port_id);
4547 cmd_config_queue_tx_offloads(struct rte_port *port)
4551 /* Apply queue tx offloads configuration */
4552 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4553 port->tx_conf[k].offloads =
4554 port->dev_conf.txmode.offloads;
4558 cmd_csum_parsed(void *parsed_result,
4559 __rte_unused struct cmdline *cl,
4560 __rte_unused void *data)
4562 struct cmd_csum_result *res = parsed_result;
4564 uint64_t csum_offloads = 0;
4565 struct rte_eth_dev_info dev_info;
4568 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4569 printf("invalid port %d\n", res->port_id);
4572 if (!port_is_stopped(res->port_id)) {
4573 printf("Please stop port %d first\n", res->port_id);
4577 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4581 if (!strcmp(res->mode, "set")) {
4583 if (!strcmp(res->hwsw, "hw"))
4586 if (!strcmp(res->proto, "ip")) {
4587 if (hw == 0 || (dev_info.tx_offload_capa &
4588 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4589 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4591 printf("IP checksum offload is not supported "
4592 "by port %u\n", res->port_id);
4594 } else if (!strcmp(res->proto, "udp")) {
4595 if (hw == 0 || (dev_info.tx_offload_capa &
4596 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4597 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4599 printf("UDP checksum offload is not supported "
4600 "by port %u\n", res->port_id);
4602 } else if (!strcmp(res->proto, "tcp")) {
4603 if (hw == 0 || (dev_info.tx_offload_capa &
4604 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4605 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4607 printf("TCP checksum offload is not supported "
4608 "by port %u\n", res->port_id);
4610 } else if (!strcmp(res->proto, "sctp")) {
4611 if (hw == 0 || (dev_info.tx_offload_capa &
4612 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4613 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4615 printf("SCTP checksum offload is not supported "
4616 "by port %u\n", res->port_id);
4618 } else if (!strcmp(res->proto, "outer-ip")) {
4619 if (hw == 0 || (dev_info.tx_offload_capa &
4620 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4622 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4624 printf("Outer IP checksum offload is not "
4625 "supported by port %u\n", res->port_id);
4627 } else if (!strcmp(res->proto, "outer-udp")) {
4628 if (hw == 0 || (dev_info.tx_offload_capa &
4629 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4631 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4633 printf("Outer UDP checksum offload is not "
4634 "supported by port %u\n", res->port_id);
4639 ports[res->port_id].dev_conf.txmode.offloads |=
4642 ports[res->port_id].dev_conf.txmode.offloads &=
4645 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4647 csum_show(res->port_id);
4649 cmd_reconfig_device_queue(res->port_id, 1, 1);
4652 cmdline_parse_token_string_t cmd_csum_csum =
4653 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4655 cmdline_parse_token_string_t cmd_csum_mode =
4656 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4658 cmdline_parse_token_string_t cmd_csum_proto =
4659 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4660 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4661 cmdline_parse_token_string_t cmd_csum_hwsw =
4662 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4664 cmdline_parse_token_num_t cmd_csum_portid =
4665 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4666 port_id, RTE_UINT16);
4668 cmdline_parse_inst_t cmd_csum_set = {
4669 .f = cmd_csum_parsed,
4671 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4672 "Enable/Disable hardware calculation of L3/L4 checksum when "
4673 "using csum forward engine",
4675 (void *)&cmd_csum_csum,
4676 (void *)&cmd_csum_mode,
4677 (void *)&cmd_csum_proto,
4678 (void *)&cmd_csum_hwsw,
4679 (void *)&cmd_csum_portid,
4684 cmdline_parse_token_string_t cmd_csum_mode_show =
4685 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4688 cmdline_parse_inst_t cmd_csum_show = {
4689 .f = cmd_csum_parsed,
4691 .help_str = "csum show <port_id>: Show checksum offload configuration",
4693 (void *)&cmd_csum_csum,
4694 (void *)&cmd_csum_mode_show,
4695 (void *)&cmd_csum_portid,
4700 /* Enable/disable tunnel parsing */
4701 struct cmd_csum_tunnel_result {
4702 cmdline_fixed_string_t csum;
4703 cmdline_fixed_string_t parse;
4704 cmdline_fixed_string_t onoff;
4709 cmd_csum_tunnel_parsed(void *parsed_result,
4710 __rte_unused struct cmdline *cl,
4711 __rte_unused void *data)
4713 struct cmd_csum_tunnel_result *res = parsed_result;
4715 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4718 if (!strcmp(res->onoff, "on"))
4719 ports[res->port_id].parse_tunnel = 1;
4721 ports[res->port_id].parse_tunnel = 0;
4723 csum_show(res->port_id);
4726 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4727 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4729 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4730 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4731 parse, "parse-tunnel");
4732 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4733 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4735 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4736 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4737 port_id, RTE_UINT16);
4739 cmdline_parse_inst_t cmd_csum_tunnel = {
4740 .f = cmd_csum_tunnel_parsed,
4742 .help_str = "csum parse-tunnel on|off <port_id>: "
4743 "Enable/Disable parsing of tunnels for csum engine",
4745 (void *)&cmd_csum_tunnel_csum,
4746 (void *)&cmd_csum_tunnel_parse,
4747 (void *)&cmd_csum_tunnel_onoff,
4748 (void *)&cmd_csum_tunnel_portid,
4753 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4754 struct cmd_tso_set_result {
4755 cmdline_fixed_string_t tso;
4756 cmdline_fixed_string_t mode;
4762 cmd_tso_set_parsed(void *parsed_result,
4763 __rte_unused struct cmdline *cl,
4764 __rte_unused void *data)
4766 struct cmd_tso_set_result *res = parsed_result;
4767 struct rte_eth_dev_info dev_info;
4770 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4772 if (!port_is_stopped(res->port_id)) {
4773 printf("Please stop port %d first\n", res->port_id);
4777 if (!strcmp(res->mode, "set"))
4778 ports[res->port_id].tso_segsz = res->tso_segsz;
4780 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4784 if ((ports[res->port_id].tso_segsz != 0) &&
4785 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4786 printf("Error: TSO is not supported by port %d\n",
4791 if (ports[res->port_id].tso_segsz == 0) {
4792 ports[res->port_id].dev_conf.txmode.offloads &=
4793 ~DEV_TX_OFFLOAD_TCP_TSO;
4794 printf("TSO for non-tunneled packets is disabled\n");
4796 ports[res->port_id].dev_conf.txmode.offloads |=
4797 DEV_TX_OFFLOAD_TCP_TSO;
4798 printf("TSO segment size for non-tunneled packets is %d\n",
4799 ports[res->port_id].tso_segsz);
4801 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4803 /* display warnings if configuration is not supported by the NIC */
4804 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4808 if ((ports[res->port_id].tso_segsz != 0) &&
4809 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4810 printf("Warning: TSO enabled but not "
4811 "supported by port %d\n", res->port_id);
4814 cmd_reconfig_device_queue(res->port_id, 1, 1);
4817 cmdline_parse_token_string_t cmd_tso_set_tso =
4818 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4820 cmdline_parse_token_string_t cmd_tso_set_mode =
4821 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4823 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4824 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4825 tso_segsz, RTE_UINT16);
4826 cmdline_parse_token_num_t cmd_tso_set_portid =
4827 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4828 port_id, RTE_UINT16);
4830 cmdline_parse_inst_t cmd_tso_set = {
4831 .f = cmd_tso_set_parsed,
4833 .help_str = "tso set <tso_segsz> <port_id>: "
4834 "Set TSO segment size of non-tunneled packets for csum engine "
4837 (void *)&cmd_tso_set_tso,
4838 (void *)&cmd_tso_set_mode,
4839 (void *)&cmd_tso_set_tso_segsz,
4840 (void *)&cmd_tso_set_portid,
4845 cmdline_parse_token_string_t cmd_tso_show_mode =
4846 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4850 cmdline_parse_inst_t cmd_tso_show = {
4851 .f = cmd_tso_set_parsed,
4853 .help_str = "tso show <port_id>: "
4854 "Show TSO segment size of non-tunneled packets for csum engine",
4856 (void *)&cmd_tso_set_tso,
4857 (void *)&cmd_tso_show_mode,
4858 (void *)&cmd_tso_set_portid,
4863 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4864 struct cmd_tunnel_tso_set_result {
4865 cmdline_fixed_string_t tso;
4866 cmdline_fixed_string_t mode;
4871 static struct rte_eth_dev_info
4872 check_tunnel_tso_nic_support(portid_t port_id)
4874 struct rte_eth_dev_info dev_info;
4876 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4879 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4880 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4881 "not enabled for port %d\n", port_id);
4882 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4883 printf("Warning: GRE TUNNEL TSO not supported therefore "
4884 "not enabled for port %d\n", port_id);
4885 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4886 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4887 "not enabled for port %d\n", port_id);
4888 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4889 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4890 "not enabled for port %d\n", port_id);
4891 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4892 printf("Warning: IP TUNNEL TSO not supported therefore "
4893 "not enabled for port %d\n", port_id);
4894 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4895 printf("Warning: UDP TUNNEL TSO not supported therefore "
4896 "not enabled for port %d\n", port_id);
4901 cmd_tunnel_tso_set_parsed(void *parsed_result,
4902 __rte_unused struct cmdline *cl,
4903 __rte_unused void *data)
4905 struct cmd_tunnel_tso_set_result *res = parsed_result;
4906 struct rte_eth_dev_info dev_info;
4908 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4910 if (!port_is_stopped(res->port_id)) {
4911 printf("Please stop port %d first\n", res->port_id);
4915 if (!strcmp(res->mode, "set"))
4916 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4918 dev_info = check_tunnel_tso_nic_support(res->port_id);
4919 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4920 ports[res->port_id].dev_conf.txmode.offloads &=
4921 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4922 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4923 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4924 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4925 DEV_TX_OFFLOAD_IP_TNL_TSO |
4926 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4927 printf("TSO for tunneled packets is disabled\n");
4929 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4930 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4931 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4932 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4933 DEV_TX_OFFLOAD_IP_TNL_TSO |
4934 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4936 ports[res->port_id].dev_conf.txmode.offloads |=
4937 (tso_offloads & dev_info.tx_offload_capa);
4938 printf("TSO segment size for tunneled packets is %d\n",
4939 ports[res->port_id].tunnel_tso_segsz);
4941 /* Below conditions are needed to make it work:
4942 * (1) tunnel TSO is supported by the NIC;
4943 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4945 * (3) for tunneled pkts with outer L3 of IPv4,
4946 * "csum set outer-ip" must be set to hw, because after tso,
4947 * total_len of outer IP header is changed, and the checksum
4948 * of outer IP header calculated by sw should be wrong; that
4949 * is not necessary for IPv6 tunneled pkts because there's no
4950 * checksum in IP header anymore.
4953 if (!ports[res->port_id].parse_tunnel)
4954 printf("Warning: csum parse_tunnel must be set "
4955 "so that tunneled packets are recognized\n");
4956 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4957 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4958 printf("Warning: csum set outer-ip must be set to hw "
4959 "if outer L3 is IPv4; not necessary for IPv6\n");
4962 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4963 cmd_reconfig_device_queue(res->port_id, 1, 1);
4966 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4967 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4969 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4970 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4972 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4973 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4974 tso_segsz, RTE_UINT16);
4975 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4976 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4977 port_id, RTE_UINT16);
4979 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4980 .f = cmd_tunnel_tso_set_parsed,
4982 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4983 "Set TSO segment size of tunneled packets for csum engine "
4986 (void *)&cmd_tunnel_tso_set_tso,
4987 (void *)&cmd_tunnel_tso_set_mode,
4988 (void *)&cmd_tunnel_tso_set_tso_segsz,
4989 (void *)&cmd_tunnel_tso_set_portid,
4994 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4995 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4999 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5000 .f = cmd_tunnel_tso_set_parsed,
5002 .help_str = "tunnel_tso show <port_id> "
5003 "Show TSO segment size of tunneled packets for csum engine",
5005 (void *)&cmd_tunnel_tso_set_tso,
5006 (void *)&cmd_tunnel_tso_show_mode,
5007 (void *)&cmd_tunnel_tso_set_portid,
5012 /* *** SET GRO FOR A PORT *** */
5013 struct cmd_gro_enable_result {
5014 cmdline_fixed_string_t cmd_set;
5015 cmdline_fixed_string_t cmd_port;
5016 cmdline_fixed_string_t cmd_keyword;
5017 cmdline_fixed_string_t cmd_onoff;
5022 cmd_gro_enable_parsed(void *parsed_result,
5023 __rte_unused struct cmdline *cl,
5024 __rte_unused void *data)
5026 struct cmd_gro_enable_result *res;
5028 res = parsed_result;
5029 if (!strcmp(res->cmd_keyword, "gro"))
5030 setup_gro(res->cmd_onoff, res->cmd_pid);
5033 cmdline_parse_token_string_t cmd_gro_enable_set =
5034 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5036 cmdline_parse_token_string_t cmd_gro_enable_port =
5037 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5038 cmd_keyword, "port");
5039 cmdline_parse_token_num_t cmd_gro_enable_pid =
5040 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5041 cmd_pid, RTE_UINT16);
5042 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5043 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5044 cmd_keyword, "gro");
5045 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5046 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5047 cmd_onoff, "on#off");
5049 cmdline_parse_inst_t cmd_gro_enable = {
5050 .f = cmd_gro_enable_parsed,
5052 .help_str = "set port <port_id> gro on|off",
5054 (void *)&cmd_gro_enable_set,
5055 (void *)&cmd_gro_enable_port,
5056 (void *)&cmd_gro_enable_pid,
5057 (void *)&cmd_gro_enable_keyword,
5058 (void *)&cmd_gro_enable_onoff,
5063 /* *** DISPLAY GRO CONFIGURATION *** */
5064 struct cmd_gro_show_result {
5065 cmdline_fixed_string_t cmd_show;
5066 cmdline_fixed_string_t cmd_port;
5067 cmdline_fixed_string_t cmd_keyword;
5072 cmd_gro_show_parsed(void *parsed_result,
5073 __rte_unused struct cmdline *cl,
5074 __rte_unused void *data)
5076 struct cmd_gro_show_result *res;
5078 res = parsed_result;
5079 if (!strcmp(res->cmd_keyword, "gro"))
5080 show_gro(res->cmd_pid);
5083 cmdline_parse_token_string_t cmd_gro_show_show =
5084 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5086 cmdline_parse_token_string_t cmd_gro_show_port =
5087 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5089 cmdline_parse_token_num_t cmd_gro_show_pid =
5090 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5091 cmd_pid, RTE_UINT16);
5092 cmdline_parse_token_string_t cmd_gro_show_keyword =
5093 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5094 cmd_keyword, "gro");
5096 cmdline_parse_inst_t cmd_gro_show = {
5097 .f = cmd_gro_show_parsed,
5099 .help_str = "show port <port_id> gro",
5101 (void *)&cmd_gro_show_show,
5102 (void *)&cmd_gro_show_port,
5103 (void *)&cmd_gro_show_pid,
5104 (void *)&cmd_gro_show_keyword,
5109 /* *** SET FLUSH CYCLES FOR GRO *** */
5110 struct cmd_gro_flush_result {
5111 cmdline_fixed_string_t cmd_set;
5112 cmdline_fixed_string_t cmd_keyword;
5113 cmdline_fixed_string_t cmd_flush;
5118 cmd_gro_flush_parsed(void *parsed_result,
5119 __rte_unused struct cmdline *cl,
5120 __rte_unused void *data)
5122 struct cmd_gro_flush_result *res;
5124 res = parsed_result;
5125 if ((!strcmp(res->cmd_keyword, "gro")) &&
5126 (!strcmp(res->cmd_flush, "flush")))
5127 setup_gro_flush_cycles(res->cmd_cycles);
5130 cmdline_parse_token_string_t cmd_gro_flush_set =
5131 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5133 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5134 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5135 cmd_keyword, "gro");
5136 cmdline_parse_token_string_t cmd_gro_flush_flush =
5137 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5138 cmd_flush, "flush");
5139 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5140 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5141 cmd_cycles, RTE_UINT8);
5143 cmdline_parse_inst_t cmd_gro_flush = {
5144 .f = cmd_gro_flush_parsed,
5146 .help_str = "set gro flush <cycles>",
5148 (void *)&cmd_gro_flush_set,
5149 (void *)&cmd_gro_flush_keyword,
5150 (void *)&cmd_gro_flush_flush,
5151 (void *)&cmd_gro_flush_cycles,
5156 /* *** ENABLE/DISABLE GSO *** */
5157 struct cmd_gso_enable_result {
5158 cmdline_fixed_string_t cmd_set;
5159 cmdline_fixed_string_t cmd_port;
5160 cmdline_fixed_string_t cmd_keyword;
5161 cmdline_fixed_string_t cmd_mode;
5166 cmd_gso_enable_parsed(void *parsed_result,
5167 __rte_unused struct cmdline *cl,
5168 __rte_unused void *data)
5170 struct cmd_gso_enable_result *res;
5172 res = parsed_result;
5173 if (!strcmp(res->cmd_keyword, "gso"))
5174 setup_gso(res->cmd_mode, res->cmd_pid);
5177 cmdline_parse_token_string_t cmd_gso_enable_set =
5178 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5180 cmdline_parse_token_string_t cmd_gso_enable_port =
5181 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5183 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5184 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5185 cmd_keyword, "gso");
5186 cmdline_parse_token_string_t cmd_gso_enable_mode =
5187 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5188 cmd_mode, "on#off");
5189 cmdline_parse_token_num_t cmd_gso_enable_pid =
5190 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5191 cmd_pid, RTE_UINT16);
5193 cmdline_parse_inst_t cmd_gso_enable = {
5194 .f = cmd_gso_enable_parsed,
5196 .help_str = "set port <port_id> gso on|off",
5198 (void *)&cmd_gso_enable_set,
5199 (void *)&cmd_gso_enable_port,
5200 (void *)&cmd_gso_enable_pid,
5201 (void *)&cmd_gso_enable_keyword,
5202 (void *)&cmd_gso_enable_mode,
5207 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5208 struct cmd_gso_size_result {
5209 cmdline_fixed_string_t cmd_set;
5210 cmdline_fixed_string_t cmd_keyword;
5211 cmdline_fixed_string_t cmd_segsz;
5216 cmd_gso_size_parsed(void *parsed_result,
5217 __rte_unused struct cmdline *cl,
5218 __rte_unused void *data)
5220 struct cmd_gso_size_result *res = parsed_result;
5222 if (test_done == 0) {
5223 printf("Before setting GSO segsz, please first"
5224 " stop forwarding\n");
5228 if (!strcmp(res->cmd_keyword, "gso") &&
5229 !strcmp(res->cmd_segsz, "segsz")) {
5230 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5231 printf("gso_size should be larger than %zu."
5232 " Please input a legal value\n",
5233 RTE_GSO_SEG_SIZE_MIN);
5235 gso_max_segment_size = res->cmd_size;
5239 cmdline_parse_token_string_t cmd_gso_size_set =
5240 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5242 cmdline_parse_token_string_t cmd_gso_size_keyword =
5243 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5244 cmd_keyword, "gso");
5245 cmdline_parse_token_string_t cmd_gso_size_segsz =
5246 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5247 cmd_segsz, "segsz");
5248 cmdline_parse_token_num_t cmd_gso_size_size =
5249 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5250 cmd_size, RTE_UINT16);
5252 cmdline_parse_inst_t cmd_gso_size = {
5253 .f = cmd_gso_size_parsed,
5255 .help_str = "set gso segsz <length>",
5257 (void *)&cmd_gso_size_set,
5258 (void *)&cmd_gso_size_keyword,
5259 (void *)&cmd_gso_size_segsz,
5260 (void *)&cmd_gso_size_size,
5265 /* *** SHOW GSO CONFIGURATION *** */
5266 struct cmd_gso_show_result {
5267 cmdline_fixed_string_t cmd_show;
5268 cmdline_fixed_string_t cmd_port;
5269 cmdline_fixed_string_t cmd_keyword;
5274 cmd_gso_show_parsed(void *parsed_result,
5275 __rte_unused struct cmdline *cl,
5276 __rte_unused void *data)
5278 struct cmd_gso_show_result *res = parsed_result;
5280 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5281 printf("invalid port id %u\n", res->cmd_pid);
5284 if (!strcmp(res->cmd_keyword, "gso")) {
5285 if (gso_ports[res->cmd_pid].enable) {
5286 printf("Max GSO'd packet size: %uB\n"
5287 "Supported GSO types: TCP/IPv4, "
5288 "UDP/IPv4, VxLAN with inner "
5289 "TCP/IPv4 packet, GRE with inner "
5290 "TCP/IPv4 packet\n",
5291 gso_max_segment_size);
5293 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5297 cmdline_parse_token_string_t cmd_gso_show_show =
5298 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5300 cmdline_parse_token_string_t cmd_gso_show_port =
5301 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5303 cmdline_parse_token_string_t cmd_gso_show_keyword =
5304 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5305 cmd_keyword, "gso");
5306 cmdline_parse_token_num_t cmd_gso_show_pid =
5307 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5308 cmd_pid, RTE_UINT16);
5310 cmdline_parse_inst_t cmd_gso_show = {
5311 .f = cmd_gso_show_parsed,
5313 .help_str = "show port <port_id> gso",
5315 (void *)&cmd_gso_show_show,
5316 (void *)&cmd_gso_show_port,
5317 (void *)&cmd_gso_show_pid,
5318 (void *)&cmd_gso_show_keyword,
5323 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5324 struct cmd_set_flush_rx {
5325 cmdline_fixed_string_t set;
5326 cmdline_fixed_string_t flush_rx;
5327 cmdline_fixed_string_t mode;
5331 cmd_set_flush_rx_parsed(void *parsed_result,
5332 __rte_unused struct cmdline *cl,
5333 __rte_unused void *data)
5335 struct cmd_set_flush_rx *res = parsed_result;
5336 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5339 cmdline_parse_token_string_t cmd_setflushrx_set =
5340 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5342 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5343 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5344 flush_rx, "flush_rx");
5345 cmdline_parse_token_string_t cmd_setflushrx_mode =
5346 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5350 cmdline_parse_inst_t cmd_set_flush_rx = {
5351 .f = cmd_set_flush_rx_parsed,
5352 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5355 (void *)&cmd_setflushrx_set,
5356 (void *)&cmd_setflushrx_flush_rx,
5357 (void *)&cmd_setflushrx_mode,
5362 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5363 struct cmd_set_link_check {
5364 cmdline_fixed_string_t set;
5365 cmdline_fixed_string_t link_check;
5366 cmdline_fixed_string_t mode;
5370 cmd_set_link_check_parsed(void *parsed_result,
5371 __rte_unused struct cmdline *cl,
5372 __rte_unused void *data)
5374 struct cmd_set_link_check *res = parsed_result;
5375 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5378 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5379 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5381 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5382 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5383 link_check, "link_check");
5384 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5385 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5389 cmdline_parse_inst_t cmd_set_link_check = {
5390 .f = cmd_set_link_check_parsed,
5391 .help_str = "set link_check on|off: Enable/Disable link status check "
5392 "when starting/stopping a port",
5395 (void *)&cmd_setlinkcheck_set,
5396 (void *)&cmd_setlinkcheck_link_check,
5397 (void *)&cmd_setlinkcheck_mode,
5402 /* *** SET NIC BYPASS MODE *** */
5403 struct cmd_set_bypass_mode_result {
5404 cmdline_fixed_string_t set;
5405 cmdline_fixed_string_t bypass;
5406 cmdline_fixed_string_t mode;
5407 cmdline_fixed_string_t value;
5412 cmd_set_bypass_mode_parsed(void *parsed_result,
5413 __rte_unused struct cmdline *cl,
5414 __rte_unused void *data)
5416 struct cmd_set_bypass_mode_result *res = parsed_result;
5417 portid_t port_id = res->port_id;
5418 int32_t rc = -EINVAL;
5420 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5421 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5423 if (!strcmp(res->value, "bypass"))
5424 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5425 else if (!strcmp(res->value, "isolate"))
5426 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5428 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5430 /* Set the bypass mode for the relevant port. */
5431 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5434 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5437 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5438 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5440 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5441 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5443 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5444 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5446 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5447 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5448 value, "normal#bypass#isolate");
5449 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5450 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5451 port_id, RTE_UINT16);
5453 cmdline_parse_inst_t cmd_set_bypass_mode = {
5454 .f = cmd_set_bypass_mode_parsed,
5455 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5456 "Set the NIC bypass mode for port_id",
5459 (void *)&cmd_setbypass_mode_set,
5460 (void *)&cmd_setbypass_mode_bypass,
5461 (void *)&cmd_setbypass_mode_mode,
5462 (void *)&cmd_setbypass_mode_value,
5463 (void *)&cmd_setbypass_mode_port,
5468 /* *** SET NIC BYPASS EVENT *** */
5469 struct cmd_set_bypass_event_result {
5470 cmdline_fixed_string_t set;
5471 cmdline_fixed_string_t bypass;
5472 cmdline_fixed_string_t event;
5473 cmdline_fixed_string_t event_value;
5474 cmdline_fixed_string_t mode;
5475 cmdline_fixed_string_t mode_value;
5480 cmd_set_bypass_event_parsed(void *parsed_result,
5481 __rte_unused struct cmdline *cl,
5482 __rte_unused void *data)
5484 int32_t rc = -EINVAL;
5485 struct cmd_set_bypass_event_result *res = parsed_result;
5486 portid_t port_id = res->port_id;
5488 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5489 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5490 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5492 if (!strcmp(res->event_value, "timeout"))
5493 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5494 else if (!strcmp(res->event_value, "os_on"))
5495 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5496 else if (!strcmp(res->event_value, "os_off"))
5497 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5498 else if (!strcmp(res->event_value, "power_on"))
5499 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5500 else if (!strcmp(res->event_value, "power_off"))
5501 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5503 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5505 if (!strcmp(res->mode_value, "bypass"))
5506 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5507 else if (!strcmp(res->mode_value, "isolate"))
5508 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5510 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5512 /* Set the watchdog timeout. */
5513 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5516 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5517 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5521 printf("Failed to set timeout value %u "
5522 "for port %d, errto code: %d.\n",
5523 bypass_timeout, port_id, rc);
5527 /* Set the bypass event to transition to bypass mode. */
5528 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5533 printf("\t Failed to set bypass event for port = %d.\n",
5537 cmdline_parse_token_string_t cmd_setbypass_event_set =
5538 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5540 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5541 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5543 cmdline_parse_token_string_t cmd_setbypass_event_event =
5544 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5546 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5547 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5548 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5549 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5550 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5552 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5553 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5554 mode_value, "normal#bypass#isolate");
5555 cmdline_parse_token_num_t cmd_setbypass_event_port =
5556 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5557 port_id, RTE_UINT16);
5559 cmdline_parse_inst_t cmd_set_bypass_event = {
5560 .f = cmd_set_bypass_event_parsed,
5561 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5562 "power_off mode normal|bypass|isolate <port_id>: "
5563 "Set the NIC bypass event mode for port_id",
5566 (void *)&cmd_setbypass_event_set,
5567 (void *)&cmd_setbypass_event_bypass,
5568 (void *)&cmd_setbypass_event_event,
5569 (void *)&cmd_setbypass_event_event_value,
5570 (void *)&cmd_setbypass_event_mode,
5571 (void *)&cmd_setbypass_event_mode_value,
5572 (void *)&cmd_setbypass_event_port,
5578 /* *** SET NIC BYPASS TIMEOUT *** */
5579 struct cmd_set_bypass_timeout_result {
5580 cmdline_fixed_string_t set;
5581 cmdline_fixed_string_t bypass;
5582 cmdline_fixed_string_t timeout;
5583 cmdline_fixed_string_t value;
5587 cmd_set_bypass_timeout_parsed(void *parsed_result,
5588 __rte_unused struct cmdline *cl,
5589 __rte_unused void *data)
5591 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5593 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5594 if (!strcmp(res->value, "1.5"))
5595 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5596 else if (!strcmp(res->value, "2"))
5597 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5598 else if (!strcmp(res->value, "3"))
5599 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5600 else if (!strcmp(res->value, "4"))
5601 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5602 else if (!strcmp(res->value, "8"))
5603 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5604 else if (!strcmp(res->value, "16"))
5605 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5606 else if (!strcmp(res->value, "32"))
5607 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5609 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5613 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5614 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5616 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5617 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5619 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5620 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5621 timeout, "timeout");
5622 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5623 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5624 value, "0#1.5#2#3#4#8#16#32");
5626 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5627 .f = cmd_set_bypass_timeout_parsed,
5628 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5629 "Set the NIC bypass watchdog timeout in seconds",
5632 (void *)&cmd_setbypass_timeout_set,
5633 (void *)&cmd_setbypass_timeout_bypass,
5634 (void *)&cmd_setbypass_timeout_timeout,
5635 (void *)&cmd_setbypass_timeout_value,
5640 /* *** SHOW NIC BYPASS MODE *** */
5641 struct cmd_show_bypass_config_result {
5642 cmdline_fixed_string_t show;
5643 cmdline_fixed_string_t bypass;
5644 cmdline_fixed_string_t config;
5649 cmd_show_bypass_config_parsed(void *parsed_result,
5650 __rte_unused struct cmdline *cl,
5651 __rte_unused void *data)
5653 struct cmd_show_bypass_config_result *res = parsed_result;
5654 portid_t port_id = res->port_id;
5656 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5657 uint32_t event_mode;
5658 uint32_t bypass_mode;
5659 uint32_t timeout = bypass_timeout;
5662 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5663 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5664 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5665 {"UNKNOWN", "normal", "bypass", "isolate"};
5666 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5674 /* Display the bypass mode.*/
5675 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5676 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5680 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5681 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5683 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5686 /* Display the bypass timeout.*/
5687 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5688 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5690 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5692 /* Display the bypass events and associated modes. */
5693 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5695 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5696 printf("\tFailed to get bypass mode for event = %s\n",
5699 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5700 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5702 printf("\tbypass event: %-16s = %s\n", events[i],
5708 printf("\tFailed to get bypass configuration for port = %d\n",
5712 cmdline_parse_token_string_t cmd_showbypass_config_show =
5713 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5715 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5716 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5718 cmdline_parse_token_string_t cmd_showbypass_config_config =
5719 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5721 cmdline_parse_token_num_t cmd_showbypass_config_port =
5722 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5723 port_id, RTE_UINT16);
5725 cmdline_parse_inst_t cmd_show_bypass_config = {
5726 .f = cmd_show_bypass_config_parsed,
5727 .help_str = "show bypass config <port_id>: "
5728 "Show the NIC bypass config for port_id",
5731 (void *)&cmd_showbypass_config_show,
5732 (void *)&cmd_showbypass_config_bypass,
5733 (void *)&cmd_showbypass_config_config,
5734 (void *)&cmd_showbypass_config_port,
5740 /* *** SET BONDING MODE *** */
5741 struct cmd_set_bonding_mode_result {
5742 cmdline_fixed_string_t set;
5743 cmdline_fixed_string_t bonding;
5744 cmdline_fixed_string_t mode;
5749 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5750 __rte_unused struct cmdline *cl,
5751 __rte_unused void *data)
5753 struct cmd_set_bonding_mode_result *res = parsed_result;
5754 portid_t port_id = res->port_id;
5756 /* Set the bonding mode for the relevant port. */
5757 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5758 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5761 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5762 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5764 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5765 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5766 bonding, "bonding");
5767 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5768 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5770 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5771 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5773 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5774 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5775 port_id, RTE_UINT16);
5777 cmdline_parse_inst_t cmd_set_bonding_mode = {
5778 .f = cmd_set_bonding_mode_parsed,
5779 .help_str = "set bonding mode <mode_value> <port_id>: "
5780 "Set the bonding mode for port_id",
5783 (void *) &cmd_setbonding_mode_set,
5784 (void *) &cmd_setbonding_mode_bonding,
5785 (void *) &cmd_setbonding_mode_mode,
5786 (void *) &cmd_setbonding_mode_value,
5787 (void *) &cmd_setbonding_mode_port,
5792 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5793 struct cmd_set_bonding_lacp_dedicated_queues_result {
5794 cmdline_fixed_string_t set;
5795 cmdline_fixed_string_t bonding;
5796 cmdline_fixed_string_t lacp;
5797 cmdline_fixed_string_t dedicated_queues;
5799 cmdline_fixed_string_t mode;
5802 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5803 __rte_unused struct cmdline *cl,
5804 __rte_unused void *data)
5806 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5807 portid_t port_id = res->port_id;
5808 struct rte_port *port;
5810 port = &ports[port_id];
5812 /** Check if the port is not started **/
5813 if (port->port_status != RTE_PORT_STOPPED) {
5814 printf("Please stop port %d first\n", port_id);
5818 if (!strcmp(res->mode, "enable")) {
5819 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5820 printf("Dedicate queues for LACP control packets"
5823 printf("Enabling dedicate queues for LACP control "
5824 "packets on port %d failed\n", port_id);
5825 } else if (!strcmp(res->mode, "disable")) {
5826 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5827 printf("Dedicated queues for LACP control packets "
5830 printf("Disabling dedicated queues for LACP control "
5831 "traffic on port %d failed\n", port_id);
5835 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5836 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5838 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5839 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5840 bonding, "bonding");
5841 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5842 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5844 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5845 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5846 dedicated_queues, "dedicated_queues");
5847 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5848 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5849 port_id, RTE_UINT16);
5850 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5851 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5852 mode, "enable#disable");
5854 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5855 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5856 .help_str = "set bonding lacp dedicated_queues <port_id> "
5858 "Enable/disable dedicated queues for LACP control traffic for port_id",
5861 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5862 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5863 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5864 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5865 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5866 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5871 /* *** SET BALANCE XMIT POLICY *** */
5872 struct cmd_set_bonding_balance_xmit_policy_result {
5873 cmdline_fixed_string_t set;
5874 cmdline_fixed_string_t bonding;
5875 cmdline_fixed_string_t balance_xmit_policy;
5877 cmdline_fixed_string_t policy;
5880 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5881 __rte_unused struct cmdline *cl,
5882 __rte_unused void *data)
5884 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5885 portid_t port_id = res->port_id;
5888 if (!strcmp(res->policy, "l2")) {
5889 policy = BALANCE_XMIT_POLICY_LAYER2;
5890 } else if (!strcmp(res->policy, "l23")) {
5891 policy = BALANCE_XMIT_POLICY_LAYER23;
5892 } else if (!strcmp(res->policy, "l34")) {
5893 policy = BALANCE_XMIT_POLICY_LAYER34;
5895 printf("\t Invalid xmit policy selection");
5899 /* Set the bonding mode for the relevant port. */
5900 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5901 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5906 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5907 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5909 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5910 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5911 bonding, "bonding");
5912 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5913 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5914 balance_xmit_policy, "balance_xmit_policy");
5915 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5916 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5917 port_id, RTE_UINT16);
5918 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5919 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5920 policy, "l2#l23#l34");
5922 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5923 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5924 .help_str = "set bonding balance_xmit_policy <port_id> "
5926 "Set the bonding balance_xmit_policy for port_id",
5929 (void *)&cmd_setbonding_balance_xmit_policy_set,
5930 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5931 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5932 (void *)&cmd_setbonding_balance_xmit_policy_port,
5933 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5938 /* *** SHOW NIC BONDING CONFIGURATION *** */
5939 struct cmd_show_bonding_config_result {
5940 cmdline_fixed_string_t show;
5941 cmdline_fixed_string_t bonding;
5942 cmdline_fixed_string_t config;
5946 static void cmd_show_bonding_config_parsed(void *parsed_result,
5947 __rte_unused struct cmdline *cl,
5948 __rte_unused void *data)
5950 struct cmd_show_bonding_config_result *res = parsed_result;
5951 int bonding_mode, agg_mode;
5952 portid_t slaves[RTE_MAX_ETHPORTS];
5953 int num_slaves, num_active_slaves;
5956 portid_t port_id = res->port_id;
5958 /* Display the bonding mode.*/
5959 bonding_mode = rte_eth_bond_mode_get(port_id);
5960 if (bonding_mode < 0) {
5961 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5964 printf("\tBonding mode: %d\n", bonding_mode);
5966 if (bonding_mode == BONDING_MODE_BALANCE) {
5967 int balance_xmit_policy;
5969 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5970 if (balance_xmit_policy < 0) {
5971 printf("\tFailed to get balance xmit policy for port = %d\n",
5975 printf("\tBalance Xmit Policy: ");
5977 switch (balance_xmit_policy) {
5978 case BALANCE_XMIT_POLICY_LAYER2:
5979 printf("BALANCE_XMIT_POLICY_LAYER2");
5981 case BALANCE_XMIT_POLICY_LAYER23:
5982 printf("BALANCE_XMIT_POLICY_LAYER23");
5984 case BALANCE_XMIT_POLICY_LAYER34:
5985 printf("BALANCE_XMIT_POLICY_LAYER34");
5992 if (bonding_mode == BONDING_MODE_8023AD) {
5993 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5994 printf("\tIEEE802.3AD Aggregator Mode: ");
5997 printf("bandwidth");
6009 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6011 if (num_slaves < 0) {
6012 printf("\tFailed to get slave list for port = %d\n", port_id);
6015 if (num_slaves > 0) {
6016 printf("\tSlaves (%d): [", num_slaves);
6017 for (i = 0; i < num_slaves - 1; i++)
6018 printf("%d ", slaves[i]);
6020 printf("%d]\n", slaves[num_slaves - 1]);
6022 printf("\tSlaves: []\n");
6026 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6029 if (num_active_slaves < 0) {
6030 printf("\tFailed to get active slave list for port = %d\n", port_id);
6033 if (num_active_slaves > 0) {
6034 printf("\tActive Slaves (%d): [", num_active_slaves);
6035 for (i = 0; i < num_active_slaves - 1; i++)
6036 printf("%d ", slaves[i]);
6038 printf("%d]\n", slaves[num_active_slaves - 1]);
6041 printf("\tActive Slaves: []\n");
6045 primary_id = rte_eth_bond_primary_get(port_id);
6046 if (primary_id < 0) {
6047 printf("\tFailed to get primary slave for port = %d\n", port_id);
6050 printf("\tPrimary: [%d]\n", primary_id);
6054 cmdline_parse_token_string_t cmd_showbonding_config_show =
6055 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6057 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6058 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6059 bonding, "bonding");
6060 cmdline_parse_token_string_t cmd_showbonding_config_config =
6061 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6063 cmdline_parse_token_num_t cmd_showbonding_config_port =
6064 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6065 port_id, RTE_UINT16);
6067 cmdline_parse_inst_t cmd_show_bonding_config = {
6068 .f = cmd_show_bonding_config_parsed,
6069 .help_str = "show bonding config <port_id>: "
6070 "Show the bonding config for port_id",
6073 (void *)&cmd_showbonding_config_show,
6074 (void *)&cmd_showbonding_config_bonding,
6075 (void *)&cmd_showbonding_config_config,
6076 (void *)&cmd_showbonding_config_port,
6081 /* *** SET BONDING PRIMARY *** */
6082 struct cmd_set_bonding_primary_result {
6083 cmdline_fixed_string_t set;
6084 cmdline_fixed_string_t bonding;
6085 cmdline_fixed_string_t primary;
6090 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6091 __rte_unused struct cmdline *cl,
6092 __rte_unused void *data)
6094 struct cmd_set_bonding_primary_result *res = parsed_result;
6095 portid_t master_port_id = res->port_id;
6096 portid_t slave_port_id = res->slave_id;
6098 /* Set the primary slave for a bonded device. */
6099 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6100 printf("\t Failed to set primary slave for port = %d.\n",
6107 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6108 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6110 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6111 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6112 bonding, "bonding");
6113 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6114 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6115 primary, "primary");
6116 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6117 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6118 slave_id, RTE_UINT16);
6119 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6120 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6121 port_id, RTE_UINT16);
6123 cmdline_parse_inst_t cmd_set_bonding_primary = {
6124 .f = cmd_set_bonding_primary_parsed,
6125 .help_str = "set bonding primary <slave_id> <port_id>: "
6126 "Set the primary slave for port_id",
6129 (void *)&cmd_setbonding_primary_set,
6130 (void *)&cmd_setbonding_primary_bonding,
6131 (void *)&cmd_setbonding_primary_primary,
6132 (void *)&cmd_setbonding_primary_slave,
6133 (void *)&cmd_setbonding_primary_port,
6138 /* *** ADD SLAVE *** */
6139 struct cmd_add_bonding_slave_result {
6140 cmdline_fixed_string_t add;
6141 cmdline_fixed_string_t bonding;
6142 cmdline_fixed_string_t slave;
6147 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6148 __rte_unused struct cmdline *cl,
6149 __rte_unused void *data)
6151 struct cmd_add_bonding_slave_result *res = parsed_result;
6152 portid_t master_port_id = res->port_id;
6153 portid_t slave_port_id = res->slave_id;
6155 /* add the slave for a bonded device. */
6156 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6157 printf("\t Failed to add slave %d to master port = %d.\n",
6158 slave_port_id, master_port_id);
6162 set_port_slave_flag(slave_port_id);
6165 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6166 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6168 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6169 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6170 bonding, "bonding");
6171 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6172 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6174 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6175 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6176 slave_id, RTE_UINT16);
6177 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6178 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6179 port_id, RTE_UINT16);
6181 cmdline_parse_inst_t cmd_add_bonding_slave = {
6182 .f = cmd_add_bonding_slave_parsed,
6183 .help_str = "add bonding slave <slave_id> <port_id>: "
6184 "Add a slave device to a bonded device",
6187 (void *)&cmd_addbonding_slave_add,
6188 (void *)&cmd_addbonding_slave_bonding,
6189 (void *)&cmd_addbonding_slave_slave,
6190 (void *)&cmd_addbonding_slave_slaveid,
6191 (void *)&cmd_addbonding_slave_port,
6196 /* *** REMOVE SLAVE *** */
6197 struct cmd_remove_bonding_slave_result {
6198 cmdline_fixed_string_t remove;
6199 cmdline_fixed_string_t bonding;
6200 cmdline_fixed_string_t slave;
6205 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6206 __rte_unused struct cmdline *cl,
6207 __rte_unused void *data)
6209 struct cmd_remove_bonding_slave_result *res = parsed_result;
6210 portid_t master_port_id = res->port_id;
6211 portid_t slave_port_id = res->slave_id;
6213 /* remove the slave from a bonded device. */
6214 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6215 printf("\t Failed to remove slave %d from master port = %d.\n",
6216 slave_port_id, master_port_id);
6220 clear_port_slave_flag(slave_port_id);
6223 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6224 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6226 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6227 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6228 bonding, "bonding");
6229 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6230 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6232 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6233 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6234 slave_id, RTE_UINT16);
6235 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6236 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6237 port_id, RTE_UINT16);
6239 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6240 .f = cmd_remove_bonding_slave_parsed,
6241 .help_str = "remove bonding slave <slave_id> <port_id>: "
6242 "Remove a slave device from a bonded device",
6245 (void *)&cmd_removebonding_slave_remove,
6246 (void *)&cmd_removebonding_slave_bonding,
6247 (void *)&cmd_removebonding_slave_slave,
6248 (void *)&cmd_removebonding_slave_slaveid,
6249 (void *)&cmd_removebonding_slave_port,
6254 /* *** CREATE BONDED DEVICE *** */
6255 struct cmd_create_bonded_device_result {
6256 cmdline_fixed_string_t create;
6257 cmdline_fixed_string_t bonded;
6258 cmdline_fixed_string_t device;
6263 static int bond_dev_num = 0;
6265 static void cmd_create_bonded_device_parsed(void *parsed_result,
6266 __rte_unused struct cmdline *cl,
6267 __rte_unused void *data)
6269 struct cmd_create_bonded_device_result *res = parsed_result;
6270 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6274 if (test_done == 0) {
6275 printf("Please stop forwarding first\n");
6279 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6282 /* Create a new bonded device. */
6283 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6285 printf("\t Failed to create bonded device.\n");
6288 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6291 /* Update number of ports */
6292 nb_ports = rte_eth_dev_count_avail();
6293 reconfig(port_id, res->socket);
6294 ret = rte_eth_promiscuous_enable(port_id);
6296 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6297 port_id, rte_strerror(-ret));
6299 ports[port_id].need_setup = 0;
6300 ports[port_id].port_status = RTE_PORT_STOPPED;
6305 cmdline_parse_token_string_t cmd_createbonded_device_create =
6306 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6308 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6309 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6311 cmdline_parse_token_string_t cmd_createbonded_device_device =
6312 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6314 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6315 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6317 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6318 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6321 cmdline_parse_inst_t cmd_create_bonded_device = {
6322 .f = cmd_create_bonded_device_parsed,
6323 .help_str = "create bonded device <mode> <socket>: "
6324 "Create a new bonded device with specific bonding mode and socket",
6327 (void *)&cmd_createbonded_device_create,
6328 (void *)&cmd_createbonded_device_bonded,
6329 (void *)&cmd_createbonded_device_device,
6330 (void *)&cmd_createbonded_device_mode,
6331 (void *)&cmd_createbonded_device_socket,
6336 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6337 struct cmd_set_bond_mac_addr_result {
6338 cmdline_fixed_string_t set;
6339 cmdline_fixed_string_t bonding;
6340 cmdline_fixed_string_t mac_addr;
6342 struct rte_ether_addr address;
6345 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6346 __rte_unused struct cmdline *cl,
6347 __rte_unused void *data)
6349 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6352 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6355 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6357 /* check the return value and print it if is < 0 */
6359 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6362 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6363 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6364 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6365 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6367 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6368 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6370 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6371 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6372 port_num, RTE_UINT16);
6373 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6374 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6376 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6377 .f = cmd_set_bond_mac_addr_parsed,
6379 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6381 (void *)&cmd_set_bond_mac_addr_set,
6382 (void *)&cmd_set_bond_mac_addr_bonding,
6383 (void *)&cmd_set_bond_mac_addr_mac,
6384 (void *)&cmd_set_bond_mac_addr_portnum,
6385 (void *)&cmd_set_bond_mac_addr_addr,
6391 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6392 struct cmd_set_bond_mon_period_result {
6393 cmdline_fixed_string_t set;
6394 cmdline_fixed_string_t bonding;
6395 cmdline_fixed_string_t mon_period;
6400 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6401 __rte_unused struct cmdline *cl,
6402 __rte_unused void *data)
6404 struct cmd_set_bond_mon_period_result *res = parsed_result;
6407 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6409 /* check the return value and print it if is < 0 */
6411 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6414 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6415 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6417 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6418 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6419 bonding, "bonding");
6420 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6421 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6422 mon_period, "mon_period");
6423 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6424 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6425 port_num, RTE_UINT16);
6426 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6427 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6428 period_ms, RTE_UINT32);
6430 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6431 .f = cmd_set_bond_mon_period_parsed,
6433 .help_str = "set bonding mon_period <port_id> <period_ms>",
6435 (void *)&cmd_set_bond_mon_period_set,
6436 (void *)&cmd_set_bond_mon_period_bonding,
6437 (void *)&cmd_set_bond_mon_period_mon_period,
6438 (void *)&cmd_set_bond_mon_period_portnum,
6439 (void *)&cmd_set_bond_mon_period_period_ms,
6446 struct cmd_set_bonding_agg_mode_policy_result {
6447 cmdline_fixed_string_t set;
6448 cmdline_fixed_string_t bonding;
6449 cmdline_fixed_string_t agg_mode;
6451 cmdline_fixed_string_t policy;
6456 cmd_set_bonding_agg_mode(void *parsed_result,
6457 __rte_unused struct cmdline *cl,
6458 __rte_unused void *data)
6460 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6461 uint8_t policy = AGG_BANDWIDTH;
6463 if (!strcmp(res->policy, "bandwidth"))
6464 policy = AGG_BANDWIDTH;
6465 else if (!strcmp(res->policy, "stable"))
6466 policy = AGG_STABLE;
6467 else if (!strcmp(res->policy, "count"))
6470 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6474 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6475 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6477 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6478 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6479 bonding, "bonding");
6481 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6482 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6483 agg_mode, "agg_mode");
6485 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6486 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6487 port_num, RTE_UINT16);
6489 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6490 TOKEN_STRING_INITIALIZER(
6491 struct cmd_set_bonding_balance_xmit_policy_result,
6492 policy, "stable#bandwidth#count");
6494 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6495 .f = cmd_set_bonding_agg_mode,
6497 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6499 (void *)&cmd_set_bonding_agg_mode_set,
6500 (void *)&cmd_set_bonding_agg_mode_bonding,
6501 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6502 (void *)&cmd_set_bonding_agg_mode_portnum,
6503 (void *)&cmd_set_bonding_agg_mode_policy_string,
6509 #endif /* RTE_NET_BOND */
6511 /* *** SET FORWARDING MODE *** */
6512 struct cmd_set_fwd_mode_result {
6513 cmdline_fixed_string_t set;
6514 cmdline_fixed_string_t fwd;
6515 cmdline_fixed_string_t mode;
6518 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6519 __rte_unused struct cmdline *cl,
6520 __rte_unused void *data)
6522 struct cmd_set_fwd_mode_result *res = parsed_result;
6525 set_pkt_forwarding_mode(res->mode);
6528 cmdline_parse_token_string_t cmd_setfwd_set =
6529 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6530 cmdline_parse_token_string_t cmd_setfwd_fwd =
6531 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6532 cmdline_parse_token_string_t cmd_setfwd_mode =
6533 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6534 "" /* defined at init */);
6536 cmdline_parse_inst_t cmd_set_fwd_mode = {
6537 .f = cmd_set_fwd_mode_parsed,
6539 .help_str = NULL, /* defined at init */
6541 (void *)&cmd_setfwd_set,
6542 (void *)&cmd_setfwd_fwd,
6543 (void *)&cmd_setfwd_mode,
6548 static void cmd_set_fwd_mode_init(void)
6551 static char token[128];
6552 static char help[256];
6553 cmdline_parse_token_string_t *token_struct;
6555 modes = list_pkt_forwarding_modes();
6556 snprintf(help, sizeof(help), "set fwd %s: "
6557 "Set packet forwarding mode", modes);
6558 cmd_set_fwd_mode.help_str = help;
6560 /* string token separator is # */
6561 for (c = token; *modes != '\0'; modes++)
6566 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6567 token_struct->string_data.str = token;
6570 /* *** SET RETRY FORWARDING MODE *** */
6571 struct cmd_set_fwd_retry_mode_result {
6572 cmdline_fixed_string_t set;
6573 cmdline_fixed_string_t fwd;
6574 cmdline_fixed_string_t mode;
6575 cmdline_fixed_string_t retry;
6578 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6579 __rte_unused struct cmdline *cl,
6580 __rte_unused void *data)
6582 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6585 set_pkt_forwarding_mode(res->mode);
6588 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6589 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6591 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6592 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6594 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6595 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6597 "" /* defined at init */);
6598 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6599 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6602 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6603 .f = cmd_set_fwd_retry_mode_parsed,
6605 .help_str = NULL, /* defined at init */
6607 (void *)&cmd_setfwd_retry_set,
6608 (void *)&cmd_setfwd_retry_fwd,
6609 (void *)&cmd_setfwd_retry_mode,
6610 (void *)&cmd_setfwd_retry_retry,
6615 static void cmd_set_fwd_retry_mode_init(void)
6618 static char token[128];
6619 static char help[256];
6620 cmdline_parse_token_string_t *token_struct;
6622 modes = list_pkt_forwarding_retry_modes();
6623 snprintf(help, sizeof(help), "set fwd %s retry: "
6624 "Set packet forwarding mode with retry", modes);
6625 cmd_set_fwd_retry_mode.help_str = help;
6627 /* string token separator is # */
6628 for (c = token; *modes != '\0'; modes++)
6633 token_struct = (cmdline_parse_token_string_t *)
6634 cmd_set_fwd_retry_mode.tokens[2];
6635 token_struct->string_data.str = token;
6638 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6639 struct cmd_set_burst_tx_retry_result {
6640 cmdline_fixed_string_t set;
6641 cmdline_fixed_string_t burst;
6642 cmdline_fixed_string_t tx;
6643 cmdline_fixed_string_t delay;
6645 cmdline_fixed_string_t retry;
6649 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6650 __rte_unused struct cmdline *cl,
6651 __rte_unused void *data)
6653 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6655 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6656 && !strcmp(res->tx, "tx")) {
6657 if (!strcmp(res->delay, "delay"))
6658 burst_tx_delay_time = res->time;
6659 if (!strcmp(res->retry, "retry"))
6660 burst_tx_retry_num = res->retry_num;
6665 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6666 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6667 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6668 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6670 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6671 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6672 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6673 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6674 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6675 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
6677 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6678 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6679 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6680 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
6683 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6684 .f = cmd_set_burst_tx_retry_parsed,
6685 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6687 (void *)&cmd_set_burst_tx_retry_set,
6688 (void *)&cmd_set_burst_tx_retry_burst,
6689 (void *)&cmd_set_burst_tx_retry_tx,
6690 (void *)&cmd_set_burst_tx_retry_delay,
6691 (void *)&cmd_set_burst_tx_retry_time,
6692 (void *)&cmd_set_burst_tx_retry_retry,
6693 (void *)&cmd_set_burst_tx_retry_retry_num,
6698 /* *** SET PROMISC MODE *** */
6699 struct cmd_set_promisc_mode_result {
6700 cmdline_fixed_string_t set;
6701 cmdline_fixed_string_t promisc;
6702 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6703 uint16_t port_num; /* valid if "allports" argument == 0 */
6704 cmdline_fixed_string_t mode;
6707 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6708 __rte_unused struct cmdline *cl,
6711 struct cmd_set_promisc_mode_result *res = parsed_result;
6715 if (!strcmp(res->mode, "on"))
6722 RTE_ETH_FOREACH_DEV(i)
6723 eth_set_promisc_mode(i, enable);
6725 eth_set_promisc_mode(res->port_num, enable);
6729 cmdline_parse_token_string_t cmd_setpromisc_set =
6730 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6731 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6732 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6734 cmdline_parse_token_string_t cmd_setpromisc_portall =
6735 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6737 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6738 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6740 cmdline_parse_token_string_t cmd_setpromisc_mode =
6741 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6744 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6745 .f = cmd_set_promisc_mode_parsed,
6747 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6749 (void *)&cmd_setpromisc_set,
6750 (void *)&cmd_setpromisc_promisc,
6751 (void *)&cmd_setpromisc_portall,
6752 (void *)&cmd_setpromisc_mode,
6757 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6758 .f = cmd_set_promisc_mode_parsed,
6760 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6762 (void *)&cmd_setpromisc_set,
6763 (void *)&cmd_setpromisc_promisc,
6764 (void *)&cmd_setpromisc_portnum,
6765 (void *)&cmd_setpromisc_mode,
6770 /* *** SET ALLMULTI MODE *** */
6771 struct cmd_set_allmulti_mode_result {
6772 cmdline_fixed_string_t set;
6773 cmdline_fixed_string_t allmulti;
6774 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6775 uint16_t port_num; /* valid if "allports" argument == 0 */
6776 cmdline_fixed_string_t mode;
6779 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6780 __rte_unused struct cmdline *cl,
6783 struct cmd_set_allmulti_mode_result *res = parsed_result;
6787 if (!strcmp(res->mode, "on"))
6794 RTE_ETH_FOREACH_DEV(i) {
6795 eth_set_allmulticast_mode(i, enable);
6799 eth_set_allmulticast_mode(res->port_num, enable);
6803 cmdline_parse_token_string_t cmd_setallmulti_set =
6804 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6805 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6806 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6808 cmdline_parse_token_string_t cmd_setallmulti_portall =
6809 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6811 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6812 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6814 cmdline_parse_token_string_t cmd_setallmulti_mode =
6815 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6818 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6819 .f = cmd_set_allmulti_mode_parsed,
6821 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6823 (void *)&cmd_setallmulti_set,
6824 (void *)&cmd_setallmulti_allmulti,
6825 (void *)&cmd_setallmulti_portall,
6826 (void *)&cmd_setallmulti_mode,
6831 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6832 .f = cmd_set_allmulti_mode_parsed,
6834 .help_str = "set allmulti <port_id> on|off: "
6835 "Set allmulti mode on port_id",
6837 (void *)&cmd_setallmulti_set,
6838 (void *)&cmd_setallmulti_allmulti,
6839 (void *)&cmd_setallmulti_portnum,
6840 (void *)&cmd_setallmulti_mode,
6845 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6846 struct cmd_link_flow_ctrl_set_result {
6847 cmdline_fixed_string_t set;
6848 cmdline_fixed_string_t flow_ctrl;
6849 cmdline_fixed_string_t rx;
6850 cmdline_fixed_string_t rx_lfc_mode;
6851 cmdline_fixed_string_t tx;
6852 cmdline_fixed_string_t tx_lfc_mode;
6853 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6854 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6855 cmdline_fixed_string_t autoneg_str;
6856 cmdline_fixed_string_t autoneg;
6857 cmdline_fixed_string_t hw_str;
6858 uint32_t high_water;
6859 cmdline_fixed_string_t lw_str;
6861 cmdline_fixed_string_t pt_str;
6862 uint16_t pause_time;
6863 cmdline_fixed_string_t xon_str;
6868 cmdline_parse_token_string_t cmd_lfc_set_set =
6869 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6871 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6872 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6873 flow_ctrl, "flow_ctrl");
6874 cmdline_parse_token_string_t cmd_lfc_set_rx =
6875 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6877 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6878 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6879 rx_lfc_mode, "on#off");
6880 cmdline_parse_token_string_t cmd_lfc_set_tx =
6881 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6883 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6884 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6885 tx_lfc_mode, "on#off");
6886 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6887 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6888 hw_str, "high_water");
6889 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6890 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6891 high_water, RTE_UINT32);
6892 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6893 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6894 lw_str, "low_water");
6895 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6896 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6897 low_water, RTE_UINT32);
6898 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6899 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6900 pt_str, "pause_time");
6901 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6902 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6903 pause_time, RTE_UINT16);
6904 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6905 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6906 xon_str, "send_xon");
6907 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6908 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6909 send_xon, RTE_UINT16);
6910 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6911 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6912 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6913 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6914 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6915 mac_ctrl_frame_fwd_mode, "on#off");
6916 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6917 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6918 autoneg_str, "autoneg");
6919 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6920 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6922 cmdline_parse_token_num_t cmd_lfc_set_portid =
6923 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6924 port_id, RTE_UINT16);
6926 /* forward declaration */
6928 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6931 cmdline_parse_inst_t cmd_link_flow_control_set = {
6932 .f = cmd_link_flow_ctrl_set_parsed,
6934 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6935 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6936 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6938 (void *)&cmd_lfc_set_set,
6939 (void *)&cmd_lfc_set_flow_ctrl,
6940 (void *)&cmd_lfc_set_rx,
6941 (void *)&cmd_lfc_set_rx_mode,
6942 (void *)&cmd_lfc_set_tx,
6943 (void *)&cmd_lfc_set_tx_mode,
6944 (void *)&cmd_lfc_set_high_water,
6945 (void *)&cmd_lfc_set_low_water,
6946 (void *)&cmd_lfc_set_pause_time,
6947 (void *)&cmd_lfc_set_send_xon,
6948 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6949 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6950 (void *)&cmd_lfc_set_autoneg_str,
6951 (void *)&cmd_lfc_set_autoneg,
6952 (void *)&cmd_lfc_set_portid,
6957 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6958 .f = cmd_link_flow_ctrl_set_parsed,
6959 .data = (void *)&cmd_link_flow_control_set_rx,
6960 .help_str = "set flow_ctrl rx on|off <port_id>: "
6961 "Change rx flow control parameter",
6963 (void *)&cmd_lfc_set_set,
6964 (void *)&cmd_lfc_set_flow_ctrl,
6965 (void *)&cmd_lfc_set_rx,
6966 (void *)&cmd_lfc_set_rx_mode,
6967 (void *)&cmd_lfc_set_portid,
6972 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6973 .f = cmd_link_flow_ctrl_set_parsed,
6974 .data = (void *)&cmd_link_flow_control_set_tx,
6975 .help_str = "set flow_ctrl tx on|off <port_id>: "
6976 "Change tx flow control parameter",
6978 (void *)&cmd_lfc_set_set,
6979 (void *)&cmd_lfc_set_flow_ctrl,
6980 (void *)&cmd_lfc_set_tx,
6981 (void *)&cmd_lfc_set_tx_mode,
6982 (void *)&cmd_lfc_set_portid,
6987 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6988 .f = cmd_link_flow_ctrl_set_parsed,
6989 .data = (void *)&cmd_link_flow_control_set_hw,
6990 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6991 "Change high water flow control parameter",
6993 (void *)&cmd_lfc_set_set,
6994 (void *)&cmd_lfc_set_flow_ctrl,
6995 (void *)&cmd_lfc_set_high_water_str,
6996 (void *)&cmd_lfc_set_high_water,
6997 (void *)&cmd_lfc_set_portid,
7002 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7003 .f = cmd_link_flow_ctrl_set_parsed,
7004 .data = (void *)&cmd_link_flow_control_set_lw,
7005 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7006 "Change low water flow control parameter",
7008 (void *)&cmd_lfc_set_set,
7009 (void *)&cmd_lfc_set_flow_ctrl,
7010 (void *)&cmd_lfc_set_low_water_str,
7011 (void *)&cmd_lfc_set_low_water,
7012 (void *)&cmd_lfc_set_portid,
7017 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7018 .f = cmd_link_flow_ctrl_set_parsed,
7019 .data = (void *)&cmd_link_flow_control_set_pt,
7020 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7021 "Change pause time flow control parameter",
7023 (void *)&cmd_lfc_set_set,
7024 (void *)&cmd_lfc_set_flow_ctrl,
7025 (void *)&cmd_lfc_set_pause_time_str,
7026 (void *)&cmd_lfc_set_pause_time,
7027 (void *)&cmd_lfc_set_portid,
7032 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7033 .f = cmd_link_flow_ctrl_set_parsed,
7034 .data = (void *)&cmd_link_flow_control_set_xon,
7035 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7036 "Change send_xon flow control parameter",
7038 (void *)&cmd_lfc_set_set,
7039 (void *)&cmd_lfc_set_flow_ctrl,
7040 (void *)&cmd_lfc_set_send_xon_str,
7041 (void *)&cmd_lfc_set_send_xon,
7042 (void *)&cmd_lfc_set_portid,
7047 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7048 .f = cmd_link_flow_ctrl_set_parsed,
7049 .data = (void *)&cmd_link_flow_control_set_macfwd,
7050 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7051 "Change mac ctrl fwd flow control parameter",
7053 (void *)&cmd_lfc_set_set,
7054 (void *)&cmd_lfc_set_flow_ctrl,
7055 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7056 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7057 (void *)&cmd_lfc_set_portid,
7062 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7063 .f = cmd_link_flow_ctrl_set_parsed,
7064 .data = (void *)&cmd_link_flow_control_set_autoneg,
7065 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7066 "Change autoneg flow control parameter",
7068 (void *)&cmd_lfc_set_set,
7069 (void *)&cmd_lfc_set_flow_ctrl,
7070 (void *)&cmd_lfc_set_autoneg_str,
7071 (void *)&cmd_lfc_set_autoneg,
7072 (void *)&cmd_lfc_set_portid,
7078 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7079 __rte_unused struct cmdline *cl,
7082 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7083 cmdline_parse_inst_t *cmd = data;
7084 struct rte_eth_fc_conf fc_conf;
7090 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7091 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7092 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7093 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7095 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7096 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7099 /* Partial command line, retrieve current configuration */
7101 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7103 printf("cannot get current flow ctrl parameters, return"
7104 "code = %d\n", ret);
7108 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7109 (fc_conf.mode == RTE_FC_FULL))
7111 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7112 (fc_conf.mode == RTE_FC_FULL))
7116 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7117 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7119 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7120 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7122 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7124 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7125 fc_conf.high_water = res->high_water;
7127 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7128 fc_conf.low_water = res->low_water;
7130 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7131 fc_conf.pause_time = res->pause_time;
7133 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7134 fc_conf.send_xon = res->send_xon;
7136 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7137 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7138 fc_conf.mac_ctrl_frame_fwd = 1;
7140 fc_conf.mac_ctrl_frame_fwd = 0;
7143 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7144 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7146 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7148 printf("bad flow contrl parameter, return code = %d \n", ret);
7151 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7152 struct cmd_priority_flow_ctrl_set_result {
7153 cmdline_fixed_string_t set;
7154 cmdline_fixed_string_t pfc_ctrl;
7155 cmdline_fixed_string_t rx;
7156 cmdline_fixed_string_t rx_pfc_mode;
7157 cmdline_fixed_string_t tx;
7158 cmdline_fixed_string_t tx_pfc_mode;
7159 uint32_t high_water;
7161 uint16_t pause_time;
7167 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7168 __rte_unused struct cmdline *cl,
7169 __rte_unused void *data)
7171 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7172 struct rte_eth_pfc_conf pfc_conf;
7173 int rx_fc_enable, tx_fc_enable;
7177 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7178 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7179 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7180 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7182 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7183 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7186 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7187 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7188 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7189 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7190 pfc_conf.fc.high_water = res->high_water;
7191 pfc_conf.fc.low_water = res->low_water;
7192 pfc_conf.fc.pause_time = res->pause_time;
7193 pfc_conf.priority = res->priority;
7195 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7197 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7200 cmdline_parse_token_string_t cmd_pfc_set_set =
7201 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7203 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7204 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7205 pfc_ctrl, "pfc_ctrl");
7206 cmdline_parse_token_string_t cmd_pfc_set_rx =
7207 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7209 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7210 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7211 rx_pfc_mode, "on#off");
7212 cmdline_parse_token_string_t cmd_pfc_set_tx =
7213 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7215 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7216 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7217 tx_pfc_mode, "on#off");
7218 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7219 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7220 high_water, RTE_UINT32);
7221 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7222 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7223 low_water, RTE_UINT32);
7224 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7225 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7226 pause_time, RTE_UINT16);
7227 cmdline_parse_token_num_t cmd_pfc_set_priority =
7228 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7229 priority, RTE_UINT8);
7230 cmdline_parse_token_num_t cmd_pfc_set_portid =
7231 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7232 port_id, RTE_UINT16);
7234 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7235 .f = cmd_priority_flow_ctrl_set_parsed,
7237 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7238 "<pause_time> <priority> <port_id>: "
7239 "Configure the Ethernet priority flow control",
7241 (void *)&cmd_pfc_set_set,
7242 (void *)&cmd_pfc_set_flow_ctrl,
7243 (void *)&cmd_pfc_set_rx,
7244 (void *)&cmd_pfc_set_rx_mode,
7245 (void *)&cmd_pfc_set_tx,
7246 (void *)&cmd_pfc_set_tx_mode,
7247 (void *)&cmd_pfc_set_high_water,
7248 (void *)&cmd_pfc_set_low_water,
7249 (void *)&cmd_pfc_set_pause_time,
7250 (void *)&cmd_pfc_set_priority,
7251 (void *)&cmd_pfc_set_portid,
7256 /* *** RESET CONFIGURATION *** */
7257 struct cmd_reset_result {
7258 cmdline_fixed_string_t reset;
7259 cmdline_fixed_string_t def;
7262 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7264 __rte_unused void *data)
7266 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7267 set_def_fwd_config();
7270 cmdline_parse_token_string_t cmd_reset_set =
7271 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7272 cmdline_parse_token_string_t cmd_reset_def =
7273 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7276 cmdline_parse_inst_t cmd_reset = {
7277 .f = cmd_reset_parsed,
7279 .help_str = "set default: Reset default forwarding configuration",
7281 (void *)&cmd_reset_set,
7282 (void *)&cmd_reset_def,
7287 /* *** START FORWARDING *** */
7288 struct cmd_start_result {
7289 cmdline_fixed_string_t start;
7292 cmdline_parse_token_string_t cmd_start_start =
7293 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7295 static void cmd_start_parsed(__rte_unused void *parsed_result,
7296 __rte_unused struct cmdline *cl,
7297 __rte_unused void *data)
7299 start_packet_forwarding(0);
7302 cmdline_parse_inst_t cmd_start = {
7303 .f = cmd_start_parsed,
7305 .help_str = "start: Start packet forwarding",
7307 (void *)&cmd_start_start,
7312 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7313 struct cmd_start_tx_first_result {
7314 cmdline_fixed_string_t start;
7315 cmdline_fixed_string_t tx_first;
7319 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7320 __rte_unused struct cmdline *cl,
7321 __rte_unused void *data)
7323 start_packet_forwarding(1);
7326 cmdline_parse_token_string_t cmd_start_tx_first_start =
7327 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7329 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7330 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7331 tx_first, "tx_first");
7333 cmdline_parse_inst_t cmd_start_tx_first = {
7334 .f = cmd_start_tx_first_parsed,
7336 .help_str = "start tx_first: Start packet forwarding, "
7337 "after sending 1 burst of packets",
7339 (void *)&cmd_start_tx_first_start,
7340 (void *)&cmd_start_tx_first_tx_first,
7345 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7346 struct cmd_start_tx_first_n_result {
7347 cmdline_fixed_string_t start;
7348 cmdline_fixed_string_t tx_first;
7353 cmd_start_tx_first_n_parsed(void *parsed_result,
7354 __rte_unused struct cmdline *cl,
7355 __rte_unused void *data)
7357 struct cmd_start_tx_first_n_result *res = parsed_result;
7359 start_packet_forwarding(res->tx_num);
7362 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7363 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7365 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7366 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7367 tx_first, "tx_first");
7368 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7369 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7370 tx_num, RTE_UINT32);
7372 cmdline_parse_inst_t cmd_start_tx_first_n = {
7373 .f = cmd_start_tx_first_n_parsed,
7375 .help_str = "start tx_first <num>: "
7376 "packet forwarding, after sending <num> bursts of packets",
7378 (void *)&cmd_start_tx_first_n_start,
7379 (void *)&cmd_start_tx_first_n_tx_first,
7380 (void *)&cmd_start_tx_first_n_tx_num,
7385 /* *** SET LINK UP *** */
7386 struct cmd_set_link_up_result {
7387 cmdline_fixed_string_t set;
7388 cmdline_fixed_string_t link_up;
7389 cmdline_fixed_string_t port;
7393 cmdline_parse_token_string_t cmd_set_link_up_set =
7394 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7395 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7396 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7398 cmdline_parse_token_string_t cmd_set_link_up_port =
7399 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7400 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7401 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7404 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7405 __rte_unused struct cmdline *cl,
7406 __rte_unused void *data)
7408 struct cmd_set_link_up_result *res = parsed_result;
7409 dev_set_link_up(res->port_id);
7412 cmdline_parse_inst_t cmd_set_link_up = {
7413 .f = cmd_set_link_up_parsed,
7415 .help_str = "set link-up port <port id>",
7417 (void *)&cmd_set_link_up_set,
7418 (void *)&cmd_set_link_up_link_up,
7419 (void *)&cmd_set_link_up_port,
7420 (void *)&cmd_set_link_up_port_id,
7425 /* *** SET LINK DOWN *** */
7426 struct cmd_set_link_down_result {
7427 cmdline_fixed_string_t set;
7428 cmdline_fixed_string_t link_down;
7429 cmdline_fixed_string_t port;
7433 cmdline_parse_token_string_t cmd_set_link_down_set =
7434 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7435 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7436 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7438 cmdline_parse_token_string_t cmd_set_link_down_port =
7439 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7440 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7441 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7444 static void cmd_set_link_down_parsed(
7445 __rte_unused void *parsed_result,
7446 __rte_unused struct cmdline *cl,
7447 __rte_unused void *data)
7449 struct cmd_set_link_down_result *res = parsed_result;
7450 dev_set_link_down(res->port_id);
7453 cmdline_parse_inst_t cmd_set_link_down = {
7454 .f = cmd_set_link_down_parsed,
7456 .help_str = "set link-down port <port id>",
7458 (void *)&cmd_set_link_down_set,
7459 (void *)&cmd_set_link_down_link_down,
7460 (void *)&cmd_set_link_down_port,
7461 (void *)&cmd_set_link_down_port_id,
7466 /* *** SHOW CFG *** */
7467 struct cmd_showcfg_result {
7468 cmdline_fixed_string_t show;
7469 cmdline_fixed_string_t cfg;
7470 cmdline_fixed_string_t what;
7473 static void cmd_showcfg_parsed(void *parsed_result,
7474 __rte_unused struct cmdline *cl,
7475 __rte_unused void *data)
7477 struct cmd_showcfg_result *res = parsed_result;
7478 if (!strcmp(res->what, "rxtx"))
7479 rxtx_config_display();
7480 else if (!strcmp(res->what, "cores"))
7481 fwd_lcores_config_display();
7482 else if (!strcmp(res->what, "fwd"))
7483 pkt_fwd_config_display(&cur_fwd_config);
7484 else if (!strcmp(res->what, "rxoffs"))
7485 show_rx_pkt_offsets();
7486 else if (!strcmp(res->what, "rxpkts"))
7487 show_rx_pkt_segments();
7488 else if (!strcmp(res->what, "txpkts"))
7489 show_tx_pkt_segments();
7490 else if (!strcmp(res->what, "txtimes"))
7491 show_tx_pkt_times();
7494 cmdline_parse_token_string_t cmd_showcfg_show =
7495 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7496 cmdline_parse_token_string_t cmd_showcfg_port =
7497 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7498 cmdline_parse_token_string_t cmd_showcfg_what =
7499 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7500 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7502 cmdline_parse_inst_t cmd_showcfg = {
7503 .f = cmd_showcfg_parsed,
7505 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7507 (void *)&cmd_showcfg_show,
7508 (void *)&cmd_showcfg_port,
7509 (void *)&cmd_showcfg_what,
7514 /* *** SHOW ALL PORT INFO *** */
7515 struct cmd_showportall_result {
7516 cmdline_fixed_string_t show;
7517 cmdline_fixed_string_t port;
7518 cmdline_fixed_string_t what;
7519 cmdline_fixed_string_t all;
7522 static void cmd_showportall_parsed(void *parsed_result,
7523 __rte_unused struct cmdline *cl,
7524 __rte_unused void *data)
7528 struct cmd_showportall_result *res = parsed_result;
7529 if (!strcmp(res->show, "clear")) {
7530 if (!strcmp(res->what, "stats"))
7531 RTE_ETH_FOREACH_DEV(i)
7533 else if (!strcmp(res->what, "xstats"))
7534 RTE_ETH_FOREACH_DEV(i)
7535 nic_xstats_clear(i);
7536 } else if (!strcmp(res->what, "info"))
7537 RTE_ETH_FOREACH_DEV(i)
7538 port_infos_display(i);
7539 else if (!strcmp(res->what, "summary")) {
7540 port_summary_header_display();
7541 RTE_ETH_FOREACH_DEV(i)
7542 port_summary_display(i);
7544 else if (!strcmp(res->what, "stats"))
7545 RTE_ETH_FOREACH_DEV(i)
7546 nic_stats_display(i);
7547 else if (!strcmp(res->what, "xstats"))
7548 RTE_ETH_FOREACH_DEV(i)
7549 nic_xstats_display(i);
7550 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7551 else if (!strcmp(res->what, "fdir"))
7552 RTE_ETH_FOREACH_DEV(i)
7555 else if (!strcmp(res->what, "stat_qmap"))
7556 RTE_ETH_FOREACH_DEV(i)
7557 nic_stats_mapping_display(i);
7558 else if (!strcmp(res->what, "dcb_tc"))
7559 RTE_ETH_FOREACH_DEV(i)
7560 port_dcb_info_display(i);
7561 else if (!strcmp(res->what, "cap"))
7562 RTE_ETH_FOREACH_DEV(i)
7563 port_offload_cap_display(i);
7566 cmdline_parse_token_string_t cmd_showportall_show =
7567 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7569 cmdline_parse_token_string_t cmd_showportall_port =
7570 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7571 cmdline_parse_token_string_t cmd_showportall_what =
7572 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7573 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7574 cmdline_parse_token_string_t cmd_showportall_all =
7575 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7576 cmdline_parse_inst_t cmd_showportall = {
7577 .f = cmd_showportall_parsed,
7579 .help_str = "show|clear port "
7580 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7582 (void *)&cmd_showportall_show,
7583 (void *)&cmd_showportall_port,
7584 (void *)&cmd_showportall_what,
7585 (void *)&cmd_showportall_all,
7590 /* *** SHOW PORT INFO *** */
7591 struct cmd_showport_result {
7592 cmdline_fixed_string_t show;
7593 cmdline_fixed_string_t port;
7594 cmdline_fixed_string_t what;
7598 static void cmd_showport_parsed(void *parsed_result,
7599 __rte_unused struct cmdline *cl,
7600 __rte_unused void *data)
7602 struct cmd_showport_result *res = parsed_result;
7603 if (!strcmp(res->show, "clear")) {
7604 if (!strcmp(res->what, "stats"))
7605 nic_stats_clear(res->portnum);
7606 else if (!strcmp(res->what, "xstats"))
7607 nic_xstats_clear(res->portnum);
7608 } else if (!strcmp(res->what, "info"))
7609 port_infos_display(res->portnum);
7610 else if (!strcmp(res->what, "summary")) {
7611 port_summary_header_display();
7612 port_summary_display(res->portnum);
7614 else if (!strcmp(res->what, "stats"))
7615 nic_stats_display(res->portnum);
7616 else if (!strcmp(res->what, "xstats"))
7617 nic_xstats_display(res->portnum);
7618 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7619 else if (!strcmp(res->what, "fdir"))
7620 fdir_get_infos(res->portnum);
7622 else if (!strcmp(res->what, "stat_qmap"))
7623 nic_stats_mapping_display(res->portnum);
7624 else if (!strcmp(res->what, "dcb_tc"))
7625 port_dcb_info_display(res->portnum);
7626 else if (!strcmp(res->what, "cap"))
7627 port_offload_cap_display(res->portnum);
7630 cmdline_parse_token_string_t cmd_showport_show =
7631 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7633 cmdline_parse_token_string_t cmd_showport_port =
7634 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7635 cmdline_parse_token_string_t cmd_showport_what =
7636 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7637 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7638 cmdline_parse_token_num_t cmd_showport_portnum =
7639 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
7641 cmdline_parse_inst_t cmd_showport = {
7642 .f = cmd_showport_parsed,
7644 .help_str = "show|clear port "
7645 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7648 (void *)&cmd_showport_show,
7649 (void *)&cmd_showport_port,
7650 (void *)&cmd_showport_what,
7651 (void *)&cmd_showport_portnum,
7656 /* *** SHOW DEVICE INFO *** */
7657 struct cmd_showdevice_result {
7658 cmdline_fixed_string_t show;
7659 cmdline_fixed_string_t device;
7660 cmdline_fixed_string_t what;
7661 cmdline_fixed_string_t identifier;
7664 static void cmd_showdevice_parsed(void *parsed_result,
7665 __rte_unused struct cmdline *cl,
7666 __rte_unused void *data)
7668 struct cmd_showdevice_result *res = parsed_result;
7669 if (!strcmp(res->what, "info")) {
7670 if (!strcmp(res->identifier, "all"))
7671 device_infos_display(NULL);
7673 device_infos_display(res->identifier);
7677 cmdline_parse_token_string_t cmd_showdevice_show =
7678 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7680 cmdline_parse_token_string_t cmd_showdevice_device =
7681 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7682 cmdline_parse_token_string_t cmd_showdevice_what =
7683 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7685 cmdline_parse_token_string_t cmd_showdevice_identifier =
7686 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7689 cmdline_parse_inst_t cmd_showdevice = {
7690 .f = cmd_showdevice_parsed,
7692 .help_str = "show device info <identifier>|all",
7694 (void *)&cmd_showdevice_show,
7695 (void *)&cmd_showdevice_device,
7696 (void *)&cmd_showdevice_what,
7697 (void *)&cmd_showdevice_identifier,
7702 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7703 struct cmd_showeeprom_result {
7704 cmdline_fixed_string_t show;
7705 cmdline_fixed_string_t port;
7707 cmdline_fixed_string_t type;
7710 static void cmd_showeeprom_parsed(void *parsed_result,
7711 __rte_unused struct cmdline *cl,
7712 __rte_unused void *data)
7714 struct cmd_showeeprom_result *res = parsed_result;
7716 if (!strcmp(res->type, "eeprom"))
7717 port_eeprom_display(res->portnum);
7718 else if (!strcmp(res->type, "module_eeprom"))
7719 port_module_eeprom_display(res->portnum);
7721 printf("Unknown argument\n");
7724 cmdline_parse_token_string_t cmd_showeeprom_show =
7725 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7726 cmdline_parse_token_string_t cmd_showeeprom_port =
7727 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7728 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7729 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7731 cmdline_parse_token_string_t cmd_showeeprom_type =
7732 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7734 cmdline_parse_inst_t cmd_showeeprom = {
7735 .f = cmd_showeeprom_parsed,
7737 .help_str = "show port <port_id> module_eeprom|eeprom",
7739 (void *)&cmd_showeeprom_show,
7740 (void *)&cmd_showeeprom_port,
7741 (void *)&cmd_showeeprom_portnum,
7742 (void *)&cmd_showeeprom_type,
7747 /* *** SHOW QUEUE INFO *** */
7748 struct cmd_showqueue_result {
7749 cmdline_fixed_string_t show;
7750 cmdline_fixed_string_t type;
7751 cmdline_fixed_string_t what;
7757 cmd_showqueue_parsed(void *parsed_result,
7758 __rte_unused struct cmdline *cl,
7759 __rte_unused void *data)
7761 struct cmd_showqueue_result *res = parsed_result;
7763 if (!strcmp(res->type, "rxq"))
7764 rx_queue_infos_display(res->portnum, res->queuenum);
7765 else if (!strcmp(res->type, "txq"))
7766 tx_queue_infos_display(res->portnum, res->queuenum);
7769 cmdline_parse_token_string_t cmd_showqueue_show =
7770 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7771 cmdline_parse_token_string_t cmd_showqueue_type =
7772 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7773 cmdline_parse_token_string_t cmd_showqueue_what =
7774 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7775 cmdline_parse_token_num_t cmd_showqueue_portnum =
7776 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
7778 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7779 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
7782 cmdline_parse_inst_t cmd_showqueue = {
7783 .f = cmd_showqueue_parsed,
7785 .help_str = "show rxq|txq info <port_id> <queue_id>",
7787 (void *)&cmd_showqueue_show,
7788 (void *)&cmd_showqueue_type,
7789 (void *)&cmd_showqueue_what,
7790 (void *)&cmd_showqueue_portnum,
7791 (void *)&cmd_showqueue_queuenum,
7796 /* show/clear fwd engine statistics */
7798 cmdline_fixed_string_t action;
7799 cmdline_fixed_string_t fwd;
7800 cmdline_fixed_string_t stats;
7801 cmdline_fixed_string_t all;
7804 cmdline_parse_token_string_t cmd_fwd_action =
7805 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7806 cmdline_parse_token_string_t cmd_fwd_fwd =
7807 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7808 cmdline_parse_token_string_t cmd_fwd_stats =
7809 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7810 cmdline_parse_token_string_t cmd_fwd_all =
7811 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7814 cmd_showfwdall_parsed(void *parsed_result,
7815 __rte_unused struct cmdline *cl,
7816 __rte_unused void *data)
7818 struct fwd_result *res = parsed_result;
7820 if (!strcmp(res->action, "show"))
7821 fwd_stats_display();
7826 static cmdline_parse_inst_t cmd_showfwdall = {
7827 .f = cmd_showfwdall_parsed,
7829 .help_str = "show|clear fwd stats all",
7831 (void *)&cmd_fwd_action,
7832 (void *)&cmd_fwd_fwd,
7833 (void *)&cmd_fwd_stats,
7834 (void *)&cmd_fwd_all,
7839 /* *** READ PORT REGISTER *** */
7840 struct cmd_read_reg_result {
7841 cmdline_fixed_string_t read;
7842 cmdline_fixed_string_t reg;
7848 cmd_read_reg_parsed(void *parsed_result,
7849 __rte_unused struct cmdline *cl,
7850 __rte_unused void *data)
7852 struct cmd_read_reg_result *res = parsed_result;
7853 port_reg_display(res->port_id, res->reg_off);
7856 cmdline_parse_token_string_t cmd_read_reg_read =
7857 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7858 cmdline_parse_token_string_t cmd_read_reg_reg =
7859 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7860 cmdline_parse_token_num_t cmd_read_reg_port_id =
7861 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
7862 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7863 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
7865 cmdline_parse_inst_t cmd_read_reg = {
7866 .f = cmd_read_reg_parsed,
7868 .help_str = "read reg <port_id> <reg_off>",
7870 (void *)&cmd_read_reg_read,
7871 (void *)&cmd_read_reg_reg,
7872 (void *)&cmd_read_reg_port_id,
7873 (void *)&cmd_read_reg_reg_off,
7878 /* *** READ PORT REGISTER BIT FIELD *** */
7879 struct cmd_read_reg_bit_field_result {
7880 cmdline_fixed_string_t read;
7881 cmdline_fixed_string_t regfield;
7889 cmd_read_reg_bit_field_parsed(void *parsed_result,
7890 __rte_unused struct cmdline *cl,
7891 __rte_unused void *data)
7893 struct cmd_read_reg_bit_field_result *res = parsed_result;
7894 port_reg_bit_field_display(res->port_id, res->reg_off,
7895 res->bit1_pos, res->bit2_pos);
7898 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7899 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7901 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7902 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7903 regfield, "regfield");
7904 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7905 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7907 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7908 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7910 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7911 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7913 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7914 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7917 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7918 .f = cmd_read_reg_bit_field_parsed,
7920 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7921 "Read register bit field between bit_x and bit_y included",
7923 (void *)&cmd_read_reg_bit_field_read,
7924 (void *)&cmd_read_reg_bit_field_regfield,
7925 (void *)&cmd_read_reg_bit_field_port_id,
7926 (void *)&cmd_read_reg_bit_field_reg_off,
7927 (void *)&cmd_read_reg_bit_field_bit1_pos,
7928 (void *)&cmd_read_reg_bit_field_bit2_pos,
7933 /* *** READ PORT REGISTER BIT *** */
7934 struct cmd_read_reg_bit_result {
7935 cmdline_fixed_string_t read;
7936 cmdline_fixed_string_t regbit;
7943 cmd_read_reg_bit_parsed(void *parsed_result,
7944 __rte_unused struct cmdline *cl,
7945 __rte_unused void *data)
7947 struct cmd_read_reg_bit_result *res = parsed_result;
7948 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7951 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7952 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7953 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7954 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7956 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7957 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
7959 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7960 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
7962 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7963 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
7966 cmdline_parse_inst_t cmd_read_reg_bit = {
7967 .f = cmd_read_reg_bit_parsed,
7969 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7971 (void *)&cmd_read_reg_bit_read,
7972 (void *)&cmd_read_reg_bit_regbit,
7973 (void *)&cmd_read_reg_bit_port_id,
7974 (void *)&cmd_read_reg_bit_reg_off,
7975 (void *)&cmd_read_reg_bit_bit_pos,
7980 /* *** WRITE PORT REGISTER *** */
7981 struct cmd_write_reg_result {
7982 cmdline_fixed_string_t write;
7983 cmdline_fixed_string_t reg;
7990 cmd_write_reg_parsed(void *parsed_result,
7991 __rte_unused struct cmdline *cl,
7992 __rte_unused void *data)
7994 struct cmd_write_reg_result *res = parsed_result;
7995 port_reg_set(res->port_id, res->reg_off, res->value);
7998 cmdline_parse_token_string_t cmd_write_reg_write =
7999 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8000 cmdline_parse_token_string_t cmd_write_reg_reg =
8001 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8002 cmdline_parse_token_num_t cmd_write_reg_port_id =
8003 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8004 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8005 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8006 cmdline_parse_token_num_t cmd_write_reg_value =
8007 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8009 cmdline_parse_inst_t cmd_write_reg = {
8010 .f = cmd_write_reg_parsed,
8012 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8014 (void *)&cmd_write_reg_write,
8015 (void *)&cmd_write_reg_reg,
8016 (void *)&cmd_write_reg_port_id,
8017 (void *)&cmd_write_reg_reg_off,
8018 (void *)&cmd_write_reg_value,
8023 /* *** WRITE PORT REGISTER BIT FIELD *** */
8024 struct cmd_write_reg_bit_field_result {
8025 cmdline_fixed_string_t write;
8026 cmdline_fixed_string_t regfield;
8035 cmd_write_reg_bit_field_parsed(void *parsed_result,
8036 __rte_unused struct cmdline *cl,
8037 __rte_unused void *data)
8039 struct cmd_write_reg_bit_field_result *res = parsed_result;
8040 port_reg_bit_field_set(res->port_id, res->reg_off,
8041 res->bit1_pos, res->bit2_pos, res->value);
8044 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8045 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8047 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8048 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8049 regfield, "regfield");
8050 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8051 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8053 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8054 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8056 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8057 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8059 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8060 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8062 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8063 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8066 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8067 .f = cmd_write_reg_bit_field_parsed,
8069 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8071 "Set register bit field between bit_x and bit_y included",
8073 (void *)&cmd_write_reg_bit_field_write,
8074 (void *)&cmd_write_reg_bit_field_regfield,
8075 (void *)&cmd_write_reg_bit_field_port_id,
8076 (void *)&cmd_write_reg_bit_field_reg_off,
8077 (void *)&cmd_write_reg_bit_field_bit1_pos,
8078 (void *)&cmd_write_reg_bit_field_bit2_pos,
8079 (void *)&cmd_write_reg_bit_field_value,
8084 /* *** WRITE PORT REGISTER BIT *** */
8085 struct cmd_write_reg_bit_result {
8086 cmdline_fixed_string_t write;
8087 cmdline_fixed_string_t regbit;
8095 cmd_write_reg_bit_parsed(void *parsed_result,
8096 __rte_unused struct cmdline *cl,
8097 __rte_unused void *data)
8099 struct cmd_write_reg_bit_result *res = parsed_result;
8100 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8103 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8104 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8106 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8107 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8109 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8110 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8112 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8113 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8115 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8116 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8118 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8119 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8122 cmdline_parse_inst_t cmd_write_reg_bit = {
8123 .f = cmd_write_reg_bit_parsed,
8125 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8128 (void *)&cmd_write_reg_bit_write,
8129 (void *)&cmd_write_reg_bit_regbit,
8130 (void *)&cmd_write_reg_bit_port_id,
8131 (void *)&cmd_write_reg_bit_reg_off,
8132 (void *)&cmd_write_reg_bit_bit_pos,
8133 (void *)&cmd_write_reg_bit_value,
8138 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8139 struct cmd_read_rxd_txd_result {
8140 cmdline_fixed_string_t read;
8141 cmdline_fixed_string_t rxd_txd;
8148 cmd_read_rxd_txd_parsed(void *parsed_result,
8149 __rte_unused struct cmdline *cl,
8150 __rte_unused void *data)
8152 struct cmd_read_rxd_txd_result *res = parsed_result;
8154 if (!strcmp(res->rxd_txd, "rxd"))
8155 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8156 else if (!strcmp(res->rxd_txd, "txd"))
8157 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8160 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8161 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8162 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8163 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8165 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8166 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8168 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8169 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8171 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8172 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8175 cmdline_parse_inst_t cmd_read_rxd_txd = {
8176 .f = cmd_read_rxd_txd_parsed,
8178 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8180 (void *)&cmd_read_rxd_txd_read,
8181 (void *)&cmd_read_rxd_txd_rxd_txd,
8182 (void *)&cmd_read_rxd_txd_port_id,
8183 (void *)&cmd_read_rxd_txd_queue_id,
8184 (void *)&cmd_read_rxd_txd_desc_id,
8190 struct cmd_quit_result {
8191 cmdline_fixed_string_t quit;
8194 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8196 __rte_unused void *data)
8201 cmdline_parse_token_string_t cmd_quit_quit =
8202 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8204 cmdline_parse_inst_t cmd_quit = {
8205 .f = cmd_quit_parsed,
8207 .help_str = "quit: Exit application",
8209 (void *)&cmd_quit_quit,
8214 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8215 struct cmd_mac_addr_result {
8216 cmdline_fixed_string_t mac_addr_cmd;
8217 cmdline_fixed_string_t what;
8219 struct rte_ether_addr address;
8222 static void cmd_mac_addr_parsed(void *parsed_result,
8223 __rte_unused struct cmdline *cl,
8224 __rte_unused void *data)
8226 struct cmd_mac_addr_result *res = parsed_result;
8229 if (strcmp(res->what, "add") == 0)
8230 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8231 else if (strcmp(res->what, "set") == 0)
8232 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8235 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8237 /* check the return value and print it if is < 0 */
8239 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8243 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8244 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8246 cmdline_parse_token_string_t cmd_mac_addr_what =
8247 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8249 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8250 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8252 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8253 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8255 cmdline_parse_inst_t cmd_mac_addr = {
8256 .f = cmd_mac_addr_parsed,
8258 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8259 "Add/Remove/Set MAC address on port_id",
8261 (void *)&cmd_mac_addr_cmd,
8262 (void *)&cmd_mac_addr_what,
8263 (void *)&cmd_mac_addr_portnum,
8264 (void *)&cmd_mac_addr_addr,
8269 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8270 struct cmd_eth_peer_result {
8271 cmdline_fixed_string_t set;
8272 cmdline_fixed_string_t eth_peer;
8274 cmdline_fixed_string_t peer_addr;
8277 static void cmd_set_eth_peer_parsed(void *parsed_result,
8278 __rte_unused struct cmdline *cl,
8279 __rte_unused void *data)
8281 struct cmd_eth_peer_result *res = parsed_result;
8283 if (test_done == 0) {
8284 printf("Please stop forwarding first\n");
8287 if (!strcmp(res->eth_peer, "eth-peer")) {
8288 set_fwd_eth_peer(res->port_id, res->peer_addr);
8292 cmdline_parse_token_string_t cmd_eth_peer_set =
8293 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8294 cmdline_parse_token_string_t cmd_eth_peer =
8295 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8296 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8297 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8299 cmdline_parse_token_string_t cmd_eth_peer_addr =
8300 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8302 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8303 .f = cmd_set_eth_peer_parsed,
8305 .help_str = "set eth-peer <port_id> <peer_mac>",
8307 (void *)&cmd_eth_peer_set,
8308 (void *)&cmd_eth_peer,
8309 (void *)&cmd_eth_peer_port_id,
8310 (void *)&cmd_eth_peer_addr,
8315 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8316 struct cmd_set_qmap_result {
8317 cmdline_fixed_string_t set;
8318 cmdline_fixed_string_t qmap;
8319 cmdline_fixed_string_t what;
8326 cmd_set_qmap_parsed(void *parsed_result,
8327 __rte_unused struct cmdline *cl,
8328 __rte_unused void *data)
8330 struct cmd_set_qmap_result *res = parsed_result;
8331 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8333 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8336 cmdline_parse_token_string_t cmd_setqmap_set =
8337 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8339 cmdline_parse_token_string_t cmd_setqmap_qmap =
8340 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8342 cmdline_parse_token_string_t cmd_setqmap_what =
8343 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8345 cmdline_parse_token_num_t cmd_setqmap_portid =
8346 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8347 port_id, RTE_UINT16);
8348 cmdline_parse_token_num_t cmd_setqmap_queueid =
8349 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8350 queue_id, RTE_UINT16);
8351 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8352 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8353 map_value, RTE_UINT8);
8355 cmdline_parse_inst_t cmd_set_qmap = {
8356 .f = cmd_set_qmap_parsed,
8358 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8359 "Set statistics mapping value on tx|rx queue_id of port_id",
8361 (void *)&cmd_setqmap_set,
8362 (void *)&cmd_setqmap_qmap,
8363 (void *)&cmd_setqmap_what,
8364 (void *)&cmd_setqmap_portid,
8365 (void *)&cmd_setqmap_queueid,
8366 (void *)&cmd_setqmap_mapvalue,
8371 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8372 struct cmd_set_xstats_hide_zero_result {
8373 cmdline_fixed_string_t keyword;
8374 cmdline_fixed_string_t name;
8375 cmdline_fixed_string_t on_off;
8379 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8380 __rte_unused struct cmdline *cl,
8381 __rte_unused void *data)
8383 struct cmd_set_xstats_hide_zero_result *res;
8384 uint16_t on_off = 0;
8386 res = parsed_result;
8387 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8388 set_xstats_hide_zero(on_off);
8391 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8392 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8394 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8395 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8396 name, "xstats-hide-zero");
8397 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8398 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8401 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8402 .f = cmd_set_xstats_hide_zero_parsed,
8404 .help_str = "set xstats-hide-zero on|off",
8406 (void *)&cmd_set_xstats_hide_zero_keyword,
8407 (void *)&cmd_set_xstats_hide_zero_name,
8408 (void *)&cmd_set_xstats_hide_zero_on_off,
8413 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8414 struct cmd_set_record_core_cycles_result {
8415 cmdline_fixed_string_t keyword;
8416 cmdline_fixed_string_t name;
8417 cmdline_fixed_string_t on_off;
8421 cmd_set_record_core_cycles_parsed(void *parsed_result,
8422 __rte_unused struct cmdline *cl,
8423 __rte_unused void *data)
8425 struct cmd_set_record_core_cycles_result *res;
8426 uint16_t on_off = 0;
8428 res = parsed_result;
8429 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8430 set_record_core_cycles(on_off);
8433 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8434 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8436 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8437 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8438 name, "record-core-cycles");
8439 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8440 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8443 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8444 .f = cmd_set_record_core_cycles_parsed,
8446 .help_str = "set record-core-cycles on|off",
8448 (void *)&cmd_set_record_core_cycles_keyword,
8449 (void *)&cmd_set_record_core_cycles_name,
8450 (void *)&cmd_set_record_core_cycles_on_off,
8455 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8456 struct cmd_set_record_burst_stats_result {
8457 cmdline_fixed_string_t keyword;
8458 cmdline_fixed_string_t name;
8459 cmdline_fixed_string_t on_off;
8463 cmd_set_record_burst_stats_parsed(void *parsed_result,
8464 __rte_unused struct cmdline *cl,
8465 __rte_unused void *data)
8467 struct cmd_set_record_burst_stats_result *res;
8468 uint16_t on_off = 0;
8470 res = parsed_result;
8471 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8472 set_record_burst_stats(on_off);
8475 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8476 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8478 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8479 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8480 name, "record-burst-stats");
8481 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8482 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8485 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8486 .f = cmd_set_record_burst_stats_parsed,
8488 .help_str = "set record-burst-stats on|off",
8490 (void *)&cmd_set_record_burst_stats_keyword,
8491 (void *)&cmd_set_record_burst_stats_name,
8492 (void *)&cmd_set_record_burst_stats_on_off,
8497 /* *** CONFIGURE UNICAST HASH TABLE *** */
8498 struct cmd_set_uc_hash_table {
8499 cmdline_fixed_string_t set;
8500 cmdline_fixed_string_t port;
8502 cmdline_fixed_string_t what;
8503 struct rte_ether_addr address;
8504 cmdline_fixed_string_t mode;
8508 cmd_set_uc_hash_parsed(void *parsed_result,
8509 __rte_unused struct cmdline *cl,
8510 __rte_unused void *data)
8513 struct cmd_set_uc_hash_table *res = parsed_result;
8515 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8517 if (strcmp(res->what, "uta") == 0)
8518 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8519 &res->address,(uint8_t)is_on);
8521 printf("bad unicast hash table parameter, return code = %d \n", ret);
8525 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8526 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8528 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8529 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8531 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8532 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8533 port_id, RTE_UINT16);
8534 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8535 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8537 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8538 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8540 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8541 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8544 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8545 .f = cmd_set_uc_hash_parsed,
8547 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8549 (void *)&cmd_set_uc_hash_set,
8550 (void *)&cmd_set_uc_hash_port,
8551 (void *)&cmd_set_uc_hash_portid,
8552 (void *)&cmd_set_uc_hash_what,
8553 (void *)&cmd_set_uc_hash_mac,
8554 (void *)&cmd_set_uc_hash_mode,
8559 struct cmd_set_uc_all_hash_table {
8560 cmdline_fixed_string_t set;
8561 cmdline_fixed_string_t port;
8563 cmdline_fixed_string_t what;
8564 cmdline_fixed_string_t value;
8565 cmdline_fixed_string_t mode;
8569 cmd_set_uc_all_hash_parsed(void *parsed_result,
8570 __rte_unused struct cmdline *cl,
8571 __rte_unused void *data)
8574 struct cmd_set_uc_all_hash_table *res = parsed_result;
8576 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8578 if ((strcmp(res->what, "uta") == 0) &&
8579 (strcmp(res->value, "all") == 0))
8580 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8582 printf("bad unicast hash table parameter,"
8583 "return code = %d \n", ret);
8586 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8587 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8589 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8590 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8592 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8593 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8594 port_id, RTE_UINT16);
8595 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8596 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8598 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8599 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8601 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8602 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8605 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8606 .f = cmd_set_uc_all_hash_parsed,
8608 .help_str = "set port <port_id> uta all on|off",
8610 (void *)&cmd_set_uc_all_hash_set,
8611 (void *)&cmd_set_uc_all_hash_port,
8612 (void *)&cmd_set_uc_all_hash_portid,
8613 (void *)&cmd_set_uc_all_hash_what,
8614 (void *)&cmd_set_uc_all_hash_value,
8615 (void *)&cmd_set_uc_all_hash_mode,
8620 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8621 struct cmd_set_vf_traffic {
8622 cmdline_fixed_string_t set;
8623 cmdline_fixed_string_t port;
8625 cmdline_fixed_string_t vf;
8627 cmdline_fixed_string_t what;
8628 cmdline_fixed_string_t mode;
8632 cmd_set_vf_traffic_parsed(void *parsed_result,
8633 __rte_unused struct cmdline *cl,
8634 __rte_unused void *data)
8636 struct cmd_set_vf_traffic *res = parsed_result;
8637 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8638 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8640 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8643 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8644 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8646 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8647 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8649 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8650 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8651 port_id, RTE_UINT16);
8652 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8653 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8655 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8656 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8658 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8659 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8661 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8662 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8665 cmdline_parse_inst_t cmd_set_vf_traffic = {
8666 .f = cmd_set_vf_traffic_parsed,
8668 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8670 (void *)&cmd_setvf_traffic_set,
8671 (void *)&cmd_setvf_traffic_port,
8672 (void *)&cmd_setvf_traffic_portid,
8673 (void *)&cmd_setvf_traffic_vf,
8674 (void *)&cmd_setvf_traffic_vfid,
8675 (void *)&cmd_setvf_traffic_what,
8676 (void *)&cmd_setvf_traffic_mode,
8681 /* *** CONFIGURE VF RECEIVE MODE *** */
8682 struct cmd_set_vf_rxmode {
8683 cmdline_fixed_string_t set;
8684 cmdline_fixed_string_t port;
8686 cmdline_fixed_string_t vf;
8688 cmdline_fixed_string_t what;
8689 cmdline_fixed_string_t mode;
8690 cmdline_fixed_string_t on;
8694 cmd_set_vf_rxmode_parsed(void *parsed_result,
8695 __rte_unused struct cmdline *cl,
8696 __rte_unused void *data)
8699 uint16_t vf_rxmode = 0;
8700 struct cmd_set_vf_rxmode *res = parsed_result;
8702 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8703 if (!strcmp(res->what,"rxmode")) {
8704 if (!strcmp(res->mode, "AUPE"))
8705 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8706 else if (!strcmp(res->mode, "ROPE"))
8707 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8708 else if (!strcmp(res->mode, "BAM"))
8709 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8710 else if (!strncmp(res->mode, "MPE",3))
8711 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8714 RTE_SET_USED(is_on);
8716 #ifdef RTE_NET_IXGBE
8717 if (ret == -ENOTSUP)
8718 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8719 vf_rxmode, (uint8_t)is_on);
8722 if (ret == -ENOTSUP)
8723 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8724 vf_rxmode, (uint8_t)is_on);
8727 printf("bad VF receive mode parameter, return code = %d \n",
8731 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8732 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8734 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8735 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8737 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8738 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8739 port_id, RTE_UINT16);
8740 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8741 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8743 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8744 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8746 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8747 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8749 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8750 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8751 mode, "AUPE#ROPE#BAM#MPE");
8752 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8753 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8756 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8757 .f = cmd_set_vf_rxmode_parsed,
8759 .help_str = "set port <port_id> vf <vf_id> rxmode "
8760 "AUPE|ROPE|BAM|MPE on|off",
8762 (void *)&cmd_set_vf_rxmode_set,
8763 (void *)&cmd_set_vf_rxmode_port,
8764 (void *)&cmd_set_vf_rxmode_portid,
8765 (void *)&cmd_set_vf_rxmode_vf,
8766 (void *)&cmd_set_vf_rxmode_vfid,
8767 (void *)&cmd_set_vf_rxmode_what,
8768 (void *)&cmd_set_vf_rxmode_mode,
8769 (void *)&cmd_set_vf_rxmode_on,
8774 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8775 struct cmd_vf_mac_addr_result {
8776 cmdline_fixed_string_t mac_addr_cmd;
8777 cmdline_fixed_string_t what;
8778 cmdline_fixed_string_t port;
8780 cmdline_fixed_string_t vf;
8782 struct rte_ether_addr address;
8785 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8786 __rte_unused struct cmdline *cl,
8787 __rte_unused void *data)
8789 struct cmd_vf_mac_addr_result *res = parsed_result;
8792 if (strcmp(res->what, "add") != 0)
8796 if (ret == -ENOTSUP)
8797 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8801 if (ret == -ENOTSUP)
8802 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8807 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8811 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8812 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8813 mac_addr_cmd,"mac_addr");
8814 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8815 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8817 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8818 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8820 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8821 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8822 port_num, RTE_UINT16);
8823 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8824 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8826 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8827 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8829 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8830 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8833 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8834 .f = cmd_vf_mac_addr_parsed,
8836 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8837 "Add MAC address filtering for a VF on port_id",
8839 (void *)&cmd_vf_mac_addr_cmd,
8840 (void *)&cmd_vf_mac_addr_what,
8841 (void *)&cmd_vf_mac_addr_port,
8842 (void *)&cmd_vf_mac_addr_portnum,
8843 (void *)&cmd_vf_mac_addr_vf,
8844 (void *)&cmd_vf_mac_addr_vfnum,
8845 (void *)&cmd_vf_mac_addr_addr,
8850 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8851 struct cmd_vf_rx_vlan_filter {
8852 cmdline_fixed_string_t rx_vlan;
8853 cmdline_fixed_string_t what;
8855 cmdline_fixed_string_t port;
8857 cmdline_fixed_string_t vf;
8862 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8863 __rte_unused struct cmdline *cl,
8864 __rte_unused void *data)
8866 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8869 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8871 #ifdef RTE_NET_IXGBE
8872 if (ret == -ENOTSUP)
8873 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8874 res->vlan_id, res->vf_mask, is_add);
8877 if (ret == -ENOTSUP)
8878 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8879 res->vlan_id, res->vf_mask, is_add);
8882 if (ret == -ENOTSUP)
8883 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8884 res->vlan_id, res->vf_mask, is_add);
8891 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8892 res->vlan_id, res->vf_mask);
8895 printf("invalid port_id %d\n", res->port_id);
8898 printf("function not implemented or supported\n");
8901 printf("programming error: (%s)\n", strerror(-ret));
8905 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8906 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8907 rx_vlan, "rx_vlan");
8908 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8909 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8911 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8912 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8913 vlan_id, RTE_UINT16);
8914 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8915 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8917 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8918 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8919 port_id, RTE_UINT16);
8920 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8921 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8923 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8924 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8925 vf_mask, RTE_UINT64);
8927 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8928 .f = cmd_vf_rx_vlan_filter_parsed,
8930 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8931 "(vf_mask = hexadecimal VF mask)",
8933 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8934 (void *)&cmd_vf_rx_vlan_filter_what,
8935 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8936 (void *)&cmd_vf_rx_vlan_filter_port,
8937 (void *)&cmd_vf_rx_vlan_filter_portid,
8938 (void *)&cmd_vf_rx_vlan_filter_vf,
8939 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8944 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8945 struct cmd_queue_rate_limit_result {
8946 cmdline_fixed_string_t set;
8947 cmdline_fixed_string_t port;
8949 cmdline_fixed_string_t queue;
8951 cmdline_fixed_string_t rate;
8955 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8956 __rte_unused struct cmdline *cl,
8957 __rte_unused void *data)
8959 struct cmd_queue_rate_limit_result *res = parsed_result;
8962 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8963 && (strcmp(res->queue, "queue") == 0)
8964 && (strcmp(res->rate, "rate") == 0))
8965 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8968 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8972 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8973 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8975 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8976 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8978 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8979 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8980 port_num, RTE_UINT16);
8981 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8982 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8984 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8985 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8986 queue_num, RTE_UINT8);
8987 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8988 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8990 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8991 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8992 rate_num, RTE_UINT16);
8994 cmdline_parse_inst_t cmd_queue_rate_limit = {
8995 .f = cmd_queue_rate_limit_parsed,
8997 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8998 "Set rate limit for a queue on port_id",
9000 (void *)&cmd_queue_rate_limit_set,
9001 (void *)&cmd_queue_rate_limit_port,
9002 (void *)&cmd_queue_rate_limit_portnum,
9003 (void *)&cmd_queue_rate_limit_queue,
9004 (void *)&cmd_queue_rate_limit_queuenum,
9005 (void *)&cmd_queue_rate_limit_rate,
9006 (void *)&cmd_queue_rate_limit_ratenum,
9011 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9012 struct cmd_vf_rate_limit_result {
9013 cmdline_fixed_string_t set;
9014 cmdline_fixed_string_t port;
9016 cmdline_fixed_string_t vf;
9018 cmdline_fixed_string_t rate;
9020 cmdline_fixed_string_t q_msk;
9024 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9025 __rte_unused struct cmdline *cl,
9026 __rte_unused void *data)
9028 struct cmd_vf_rate_limit_result *res = parsed_result;
9031 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9032 && (strcmp(res->vf, "vf") == 0)
9033 && (strcmp(res->rate, "rate") == 0)
9034 && (strcmp(res->q_msk, "queue_mask") == 0))
9035 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9036 res->rate_num, res->q_msk_val);
9038 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9042 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9043 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9045 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9046 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9048 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9049 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9050 port_num, RTE_UINT16);
9051 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9052 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9054 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9055 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9057 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9058 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9060 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9061 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9062 rate_num, RTE_UINT16);
9063 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9064 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9065 q_msk, "queue_mask");
9066 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9067 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9068 q_msk_val, RTE_UINT64);
9070 cmdline_parse_inst_t cmd_vf_rate_limit = {
9071 .f = cmd_vf_rate_limit_parsed,
9073 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9074 "queue_mask <queue_mask_value>: "
9075 "Set rate limit for queues of VF on port_id",
9077 (void *)&cmd_vf_rate_limit_set,
9078 (void *)&cmd_vf_rate_limit_port,
9079 (void *)&cmd_vf_rate_limit_portnum,
9080 (void *)&cmd_vf_rate_limit_vf,
9081 (void *)&cmd_vf_rate_limit_vfnum,
9082 (void *)&cmd_vf_rate_limit_rate,
9083 (void *)&cmd_vf_rate_limit_ratenum,
9084 (void *)&cmd_vf_rate_limit_q_msk,
9085 (void *)&cmd_vf_rate_limit_q_msk_val,
9090 /* *** CONFIGURE TUNNEL UDP PORT *** */
9091 struct cmd_tunnel_udp_config {
9092 cmdline_fixed_string_t cmd;
9093 cmdline_fixed_string_t what;
9099 cmd_tunnel_udp_config_parsed(void *parsed_result,
9100 __rte_unused struct cmdline *cl,
9101 __rte_unused void *data)
9103 struct cmd_tunnel_udp_config *res = parsed_result;
9104 struct rte_eth_udp_tunnel tunnel_udp;
9107 tunnel_udp.udp_port = res->udp_port;
9109 if (!strcmp(res->cmd, "rx_vxlan_port"))
9110 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9112 if (!strcmp(res->what, "add"))
9113 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9116 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9120 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9123 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9124 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9125 cmd, "rx_vxlan_port");
9126 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9127 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9129 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9130 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9131 udp_port, RTE_UINT16);
9132 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9133 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9134 port_id, RTE_UINT16);
9136 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9137 .f = cmd_tunnel_udp_config_parsed,
9139 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9140 "Add/Remove a tunneling UDP port filter",
9142 (void *)&cmd_tunnel_udp_config_cmd,
9143 (void *)&cmd_tunnel_udp_config_what,
9144 (void *)&cmd_tunnel_udp_config_udp_port,
9145 (void *)&cmd_tunnel_udp_config_port_id,
9150 struct cmd_config_tunnel_udp_port {
9151 cmdline_fixed_string_t port;
9152 cmdline_fixed_string_t config;
9154 cmdline_fixed_string_t udp_tunnel_port;
9155 cmdline_fixed_string_t action;
9156 cmdline_fixed_string_t tunnel_type;
9161 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9162 __rte_unused struct cmdline *cl,
9163 __rte_unused void *data)
9165 struct cmd_config_tunnel_udp_port *res = parsed_result;
9166 struct rte_eth_udp_tunnel tunnel_udp;
9169 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9172 tunnel_udp.udp_port = res->udp_port;
9174 if (!strcmp(res->tunnel_type, "vxlan")) {
9175 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9176 } else if (!strcmp(res->tunnel_type, "geneve")) {
9177 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9178 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9179 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9181 printf("Invalid tunnel type\n");
9185 if (!strcmp(res->action, "add"))
9186 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9189 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9193 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9196 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9197 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9199 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9200 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9202 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9203 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9205 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9206 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9209 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9210 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9212 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9213 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9214 "vxlan#geneve#vxlan-gpe");
9215 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9216 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9219 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9220 .f = cmd_cfg_tunnel_udp_port_parsed,
9222 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9224 (void *)&cmd_config_tunnel_udp_port_port,
9225 (void *)&cmd_config_tunnel_udp_port_config,
9226 (void *)&cmd_config_tunnel_udp_port_port_id,
9227 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9228 (void *)&cmd_config_tunnel_udp_port_action,
9229 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9230 (void *)&cmd_config_tunnel_udp_port_value,
9235 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9236 struct cmd_set_mirror_mask_result {
9237 cmdline_fixed_string_t set;
9238 cmdline_fixed_string_t port;
9240 cmdline_fixed_string_t mirror;
9242 cmdline_fixed_string_t what;
9243 cmdline_fixed_string_t value;
9244 cmdline_fixed_string_t dstpool;
9246 cmdline_fixed_string_t on;
9249 cmdline_parse_token_string_t cmd_mirror_mask_set =
9250 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9252 cmdline_parse_token_string_t cmd_mirror_mask_port =
9253 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9255 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9256 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9257 port_id, RTE_UINT16);
9258 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9259 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9260 mirror, "mirror-rule");
9261 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9262 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9263 rule_id, RTE_UINT8);
9264 cmdline_parse_token_string_t cmd_mirror_mask_what =
9265 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9266 what, "pool-mirror-up#pool-mirror-down"
9268 cmdline_parse_token_string_t cmd_mirror_mask_value =
9269 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9271 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9272 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9273 dstpool, "dst-pool");
9274 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9275 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9276 dstpool_id, RTE_UINT8);
9277 cmdline_parse_token_string_t cmd_mirror_mask_on =
9278 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9282 cmd_set_mirror_mask_parsed(void *parsed_result,
9283 __rte_unused struct cmdline *cl,
9284 __rte_unused void *data)
9287 struct cmd_set_mirror_mask_result *res = parsed_result;
9288 struct rte_eth_mirror_conf mr_conf;
9290 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9292 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9294 mr_conf.dst_pool = res->dstpool_id;
9296 if (!strcmp(res->what, "pool-mirror-up")) {
9297 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9298 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9299 } else if (!strcmp(res->what, "pool-mirror-down")) {
9300 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9301 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9302 } else if (!strcmp(res->what, "vlan-mirror")) {
9303 mr_conf.rule_type = ETH_MIRROR_VLAN;
9304 nb_item = parse_item_list(res->value, "vlan",
9305 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9309 for (i = 0; i < nb_item; i++) {
9310 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9311 printf("Invalid vlan_id: must be < 4096\n");
9315 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9316 mr_conf.vlan.vlan_mask |= 1ULL << i;
9320 if (!strcmp(res->on, "on"))
9321 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9324 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9327 printf("mirror rule add error: (%s)\n", strerror(-ret));
9330 cmdline_parse_inst_t cmd_set_mirror_mask = {
9331 .f = cmd_set_mirror_mask_parsed,
9333 .help_str = "set port <port_id> mirror-rule <rule_id> "
9334 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9335 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9337 (void *)&cmd_mirror_mask_set,
9338 (void *)&cmd_mirror_mask_port,
9339 (void *)&cmd_mirror_mask_portid,
9340 (void *)&cmd_mirror_mask_mirror,
9341 (void *)&cmd_mirror_mask_ruleid,
9342 (void *)&cmd_mirror_mask_what,
9343 (void *)&cmd_mirror_mask_value,
9344 (void *)&cmd_mirror_mask_dstpool,
9345 (void *)&cmd_mirror_mask_poolid,
9346 (void *)&cmd_mirror_mask_on,
9351 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9352 struct cmd_set_mirror_link_result {
9353 cmdline_fixed_string_t set;
9354 cmdline_fixed_string_t port;
9356 cmdline_fixed_string_t mirror;
9358 cmdline_fixed_string_t what;
9359 cmdline_fixed_string_t dstpool;
9361 cmdline_fixed_string_t on;
9364 cmdline_parse_token_string_t cmd_mirror_link_set =
9365 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9367 cmdline_parse_token_string_t cmd_mirror_link_port =
9368 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9370 cmdline_parse_token_num_t cmd_mirror_link_portid =
9371 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9372 port_id, RTE_UINT16);
9373 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9374 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9375 mirror, "mirror-rule");
9376 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9377 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9378 rule_id, RTE_UINT8);
9379 cmdline_parse_token_string_t cmd_mirror_link_what =
9380 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9381 what, "uplink-mirror#downlink-mirror");
9382 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9383 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9384 dstpool, "dst-pool");
9385 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9386 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9387 dstpool_id, RTE_UINT8);
9388 cmdline_parse_token_string_t cmd_mirror_link_on =
9389 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9393 cmd_set_mirror_link_parsed(void *parsed_result,
9394 __rte_unused struct cmdline *cl,
9395 __rte_unused void *data)
9398 struct cmd_set_mirror_link_result *res = parsed_result;
9399 struct rte_eth_mirror_conf mr_conf;
9401 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9402 if (!strcmp(res->what, "uplink-mirror"))
9403 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9405 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9407 mr_conf.dst_pool = res->dstpool_id;
9409 if (!strcmp(res->on, "on"))
9410 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9413 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9416 /* check the return value and print it if is < 0 */
9418 printf("mirror rule add error: (%s)\n", strerror(-ret));
9422 cmdline_parse_inst_t cmd_set_mirror_link = {
9423 .f = cmd_set_mirror_link_parsed,
9425 .help_str = "set port <port_id> mirror-rule <rule_id> "
9426 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9428 (void *)&cmd_mirror_link_set,
9429 (void *)&cmd_mirror_link_port,
9430 (void *)&cmd_mirror_link_portid,
9431 (void *)&cmd_mirror_link_mirror,
9432 (void *)&cmd_mirror_link_ruleid,
9433 (void *)&cmd_mirror_link_what,
9434 (void *)&cmd_mirror_link_dstpool,
9435 (void *)&cmd_mirror_link_poolid,
9436 (void *)&cmd_mirror_link_on,
9441 /* *** RESET VM MIRROR RULE *** */
9442 struct cmd_rm_mirror_rule_result {
9443 cmdline_fixed_string_t reset;
9444 cmdline_fixed_string_t port;
9446 cmdline_fixed_string_t mirror;
9450 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9451 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9453 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9454 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9456 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9457 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9458 port_id, RTE_UINT16);
9459 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9460 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9461 mirror, "mirror-rule");
9462 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9463 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9464 rule_id, RTE_UINT8);
9467 cmd_reset_mirror_rule_parsed(void *parsed_result,
9468 __rte_unused struct cmdline *cl,
9469 __rte_unused void *data)
9472 struct cmd_set_mirror_link_result *res = parsed_result;
9474 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9476 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9479 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9480 .f = cmd_reset_mirror_rule_parsed,
9482 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9484 (void *)&cmd_rm_mirror_rule_reset,
9485 (void *)&cmd_rm_mirror_rule_port,
9486 (void *)&cmd_rm_mirror_rule_portid,
9487 (void *)&cmd_rm_mirror_rule_mirror,
9488 (void *)&cmd_rm_mirror_rule_ruleid,
9493 /* ******************************************************************************** */
9495 struct cmd_dump_result {
9496 cmdline_fixed_string_t dump;
9500 dump_struct_sizes(void)
9502 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9503 DUMP_SIZE(struct rte_mbuf);
9504 DUMP_SIZE(struct rte_mempool);
9505 DUMP_SIZE(struct rte_ring);
9510 /* Dump the socket memory statistics on console */
9512 dump_socket_mem(FILE *f)
9514 struct rte_malloc_socket_stats socket_stats;
9519 unsigned int n_alloc = 0;
9520 unsigned int n_free = 0;
9521 static size_t last_allocs;
9522 static size_t last_total;
9525 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9526 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9527 !socket_stats.heap_totalsz_bytes)
9529 total += socket_stats.heap_totalsz_bytes;
9530 alloc += socket_stats.heap_allocsz_bytes;
9531 free += socket_stats.heap_freesz_bytes;
9532 n_alloc += socket_stats.alloc_count;
9533 n_free += socket_stats.free_count;
9535 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9537 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9538 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9539 (double)socket_stats.heap_allocsz_bytes * 100 /
9540 (double)socket_stats.heap_totalsz_bytes,
9541 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9542 socket_stats.alloc_count,
9543 socket_stats.free_count);
9546 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9547 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9548 (double)alloc * 100 / (double)total,
9549 (double)free / (1024 * 1024),
9552 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9553 ((double)total - (double)last_total) / (1024 * 1024),
9554 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9555 last_allocs = alloc;
9559 static void cmd_dump_parsed(void *parsed_result,
9560 __rte_unused struct cmdline *cl,
9561 __rte_unused void *data)
9563 struct cmd_dump_result *res = parsed_result;
9565 if (!strcmp(res->dump, "dump_physmem"))
9566 rte_dump_physmem_layout(stdout);
9567 else if (!strcmp(res->dump, "dump_socket_mem"))
9568 dump_socket_mem(stdout);
9569 else if (!strcmp(res->dump, "dump_memzone"))
9570 rte_memzone_dump(stdout);
9571 else if (!strcmp(res->dump, "dump_struct_sizes"))
9572 dump_struct_sizes();
9573 else if (!strcmp(res->dump, "dump_ring"))
9574 rte_ring_list_dump(stdout);
9575 else if (!strcmp(res->dump, "dump_mempool"))
9576 rte_mempool_list_dump(stdout);
9577 else if (!strcmp(res->dump, "dump_devargs"))
9578 rte_devargs_dump(stdout);
9579 else if (!strcmp(res->dump, "dump_log_types"))
9580 rte_log_dump(stdout);
9583 cmdline_parse_token_string_t cmd_dump_dump =
9584 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9588 "dump_struct_sizes#"
9594 cmdline_parse_inst_t cmd_dump = {
9595 .f = cmd_dump_parsed, /* function to call */
9596 .data = NULL, /* 2nd arg of func */
9597 .help_str = "Dump status",
9598 .tokens = { /* token list, NULL terminated */
9599 (void *)&cmd_dump_dump,
9604 /* ******************************************************************************** */
9606 struct cmd_dump_one_result {
9607 cmdline_fixed_string_t dump;
9608 cmdline_fixed_string_t name;
9611 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9612 __rte_unused void *data)
9614 struct cmd_dump_one_result *res = parsed_result;
9616 if (!strcmp(res->dump, "dump_ring")) {
9618 r = rte_ring_lookup(res->name);
9620 cmdline_printf(cl, "Cannot find ring\n");
9623 rte_ring_dump(stdout, r);
9624 } else if (!strcmp(res->dump, "dump_mempool")) {
9625 struct rte_mempool *mp;
9626 mp = rte_mempool_lookup(res->name);
9628 cmdline_printf(cl, "Cannot find mempool\n");
9631 rte_mempool_dump(stdout, mp);
9635 cmdline_parse_token_string_t cmd_dump_one_dump =
9636 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9637 "dump_ring#dump_mempool");
9639 cmdline_parse_token_string_t cmd_dump_one_name =
9640 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9642 cmdline_parse_inst_t cmd_dump_one = {
9643 .f = cmd_dump_one_parsed, /* function to call */
9644 .data = NULL, /* 2nd arg of func */
9645 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9646 .tokens = { /* token list, NULL terminated */
9647 (void *)&cmd_dump_one_dump,
9648 (void *)&cmd_dump_one_name,
9653 /* *** queue region set *** */
9654 struct cmd_queue_region_result {
9655 cmdline_fixed_string_t set;
9656 cmdline_fixed_string_t port;
9658 cmdline_fixed_string_t cmd;
9659 cmdline_fixed_string_t region;
9661 cmdline_fixed_string_t queue_start_index;
9663 cmdline_fixed_string_t queue_num;
9664 uint8_t queue_num_value;
9668 cmd_queue_region_parsed(void *parsed_result,
9669 __rte_unused struct cmdline *cl,
9670 __rte_unused void *data)
9672 struct cmd_queue_region_result *res = parsed_result;
9675 struct rte_pmd_i40e_queue_region_conf region_conf;
9676 enum rte_pmd_i40e_queue_region_op op_type;
9679 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9683 memset(®ion_conf, 0, sizeof(region_conf));
9684 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9685 region_conf.region_id = res->region_id;
9686 region_conf.queue_num = res->queue_num_value;
9687 region_conf.queue_start_index = res->queue_id;
9689 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9690 op_type, ®ion_conf);
9697 printf("function not implemented or supported\n");
9700 printf("queue region config error: (%s)\n", strerror(-ret));
9704 cmdline_parse_token_string_t cmd_queue_region_set =
9705 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9707 cmdline_parse_token_string_t cmd_queue_region_port =
9708 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9709 cmdline_parse_token_num_t cmd_queue_region_port_id =
9710 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9711 port_id, RTE_UINT16);
9712 cmdline_parse_token_string_t cmd_queue_region_cmd =
9713 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9714 cmd, "queue-region");
9715 cmdline_parse_token_string_t cmd_queue_region_id =
9716 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9717 region, "region_id");
9718 cmdline_parse_token_num_t cmd_queue_region_index =
9719 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9720 region_id, RTE_UINT8);
9721 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9722 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9723 queue_start_index, "queue_start_index");
9724 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9725 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9726 queue_id, RTE_UINT8);
9727 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9728 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9729 queue_num, "queue_num");
9730 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9731 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9732 queue_num_value, RTE_UINT8);
9734 cmdline_parse_inst_t cmd_queue_region = {
9735 .f = cmd_queue_region_parsed,
9737 .help_str = "set port <port_id> queue-region region_id <value> "
9738 "queue_start_index <value> queue_num <value>: Set a queue region",
9740 (void *)&cmd_queue_region_set,
9741 (void *)&cmd_queue_region_port,
9742 (void *)&cmd_queue_region_port_id,
9743 (void *)&cmd_queue_region_cmd,
9744 (void *)&cmd_queue_region_id,
9745 (void *)&cmd_queue_region_index,
9746 (void *)&cmd_queue_region_queue_start_index,
9747 (void *)&cmd_queue_region_queue_id,
9748 (void *)&cmd_queue_region_queue_num,
9749 (void *)&cmd_queue_region_queue_num_value,
9754 /* *** queue region and flowtype set *** */
9755 struct cmd_region_flowtype_result {
9756 cmdline_fixed_string_t set;
9757 cmdline_fixed_string_t port;
9759 cmdline_fixed_string_t cmd;
9760 cmdline_fixed_string_t region;
9762 cmdline_fixed_string_t flowtype;
9763 uint8_t flowtype_id;
9767 cmd_region_flowtype_parsed(void *parsed_result,
9768 __rte_unused struct cmdline *cl,
9769 __rte_unused void *data)
9771 struct cmd_region_flowtype_result *res = parsed_result;
9774 struct rte_pmd_i40e_queue_region_conf region_conf;
9775 enum rte_pmd_i40e_queue_region_op op_type;
9778 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9782 memset(®ion_conf, 0, sizeof(region_conf));
9784 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9785 region_conf.region_id = res->region_id;
9786 region_conf.hw_flowtype = res->flowtype_id;
9788 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9789 op_type, ®ion_conf);
9796 printf("function not implemented or supported\n");
9799 printf("region flowtype config error: (%s)\n", strerror(-ret));
9803 cmdline_parse_token_string_t cmd_region_flowtype_set =
9804 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9806 cmdline_parse_token_string_t cmd_region_flowtype_port =
9807 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9809 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9810 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9811 port_id, RTE_UINT16);
9812 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9813 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9814 cmd, "queue-region");
9815 cmdline_parse_token_string_t cmd_region_flowtype_index =
9816 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9817 region, "region_id");
9818 cmdline_parse_token_num_t cmd_region_flowtype_id =
9819 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9820 region_id, RTE_UINT8);
9821 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9822 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9823 flowtype, "flowtype");
9824 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9825 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9826 flowtype_id, RTE_UINT8);
9827 cmdline_parse_inst_t cmd_region_flowtype = {
9828 .f = cmd_region_flowtype_parsed,
9830 .help_str = "set port <port_id> queue-region region_id <value> "
9831 "flowtype <value>: Set a flowtype region index",
9833 (void *)&cmd_region_flowtype_set,
9834 (void *)&cmd_region_flowtype_port,
9835 (void *)&cmd_region_flowtype_port_index,
9836 (void *)&cmd_region_flowtype_cmd,
9837 (void *)&cmd_region_flowtype_index,
9838 (void *)&cmd_region_flowtype_id,
9839 (void *)&cmd_region_flowtype_flow_index,
9840 (void *)&cmd_region_flowtype_flow_id,
9845 /* *** User Priority (UP) to queue region (region_id) set *** */
9846 struct cmd_user_priority_region_result {
9847 cmdline_fixed_string_t set;
9848 cmdline_fixed_string_t port;
9850 cmdline_fixed_string_t cmd;
9851 cmdline_fixed_string_t user_priority;
9852 uint8_t user_priority_id;
9853 cmdline_fixed_string_t region;
9858 cmd_user_priority_region_parsed(void *parsed_result,
9859 __rte_unused struct cmdline *cl,
9860 __rte_unused void *data)
9862 struct cmd_user_priority_region_result *res = parsed_result;
9865 struct rte_pmd_i40e_queue_region_conf region_conf;
9866 enum rte_pmd_i40e_queue_region_op op_type;
9869 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9873 memset(®ion_conf, 0, sizeof(region_conf));
9874 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9875 region_conf.user_priority = res->user_priority_id;
9876 region_conf.region_id = res->region_id;
9878 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9879 op_type, ®ion_conf);
9886 printf("function not implemented or supported\n");
9889 printf("user_priority region config error: (%s)\n",
9894 cmdline_parse_token_string_t cmd_user_priority_region_set =
9895 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9897 cmdline_parse_token_string_t cmd_user_priority_region_port =
9898 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9900 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9901 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9902 port_id, RTE_UINT16);
9903 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9904 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9905 cmd, "queue-region");
9906 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9907 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9908 user_priority, "UP");
9909 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9910 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9911 user_priority_id, RTE_UINT8);
9912 cmdline_parse_token_string_t cmd_user_priority_region_region =
9913 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9914 region, "region_id");
9915 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9916 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9917 region_id, RTE_UINT8);
9919 cmdline_parse_inst_t cmd_user_priority_region = {
9920 .f = cmd_user_priority_region_parsed,
9922 .help_str = "set port <port_id> queue-region UP <value> "
9923 "region_id <value>: Set the mapping of User Priority (UP) "
9924 "to queue region (region_id) ",
9926 (void *)&cmd_user_priority_region_set,
9927 (void *)&cmd_user_priority_region_port,
9928 (void *)&cmd_user_priority_region_port_index,
9929 (void *)&cmd_user_priority_region_cmd,
9930 (void *)&cmd_user_priority_region_UP,
9931 (void *)&cmd_user_priority_region_UP_id,
9932 (void *)&cmd_user_priority_region_region,
9933 (void *)&cmd_user_priority_region_region_id,
9938 /* *** flush all queue region related configuration *** */
9939 struct cmd_flush_queue_region_result {
9940 cmdline_fixed_string_t set;
9941 cmdline_fixed_string_t port;
9943 cmdline_fixed_string_t cmd;
9944 cmdline_fixed_string_t flush;
9945 cmdline_fixed_string_t what;
9949 cmd_flush_queue_region_parsed(void *parsed_result,
9950 __rte_unused struct cmdline *cl,
9951 __rte_unused void *data)
9953 struct cmd_flush_queue_region_result *res = parsed_result;
9956 struct rte_pmd_i40e_queue_region_conf region_conf;
9957 enum rte_pmd_i40e_queue_region_op op_type;
9960 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9964 memset(®ion_conf, 0, sizeof(region_conf));
9966 if (strcmp(res->what, "on") == 0)
9967 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9969 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9971 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9972 op_type, ®ion_conf);
9979 printf("function not implemented or supported\n");
9982 printf("queue region config flush error: (%s)\n",
9987 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9988 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9990 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9991 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9993 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9994 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9995 port_id, RTE_UINT16);
9996 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9997 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9998 cmd, "queue-region");
9999 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10000 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10002 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10003 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10006 cmdline_parse_inst_t cmd_flush_queue_region = {
10007 .f = cmd_flush_queue_region_parsed,
10009 .help_str = "set port <port_id> queue-region flush on|off"
10010 ": flush all queue region related configuration",
10012 (void *)&cmd_flush_queue_region_set,
10013 (void *)&cmd_flush_queue_region_port,
10014 (void *)&cmd_flush_queue_region_port_index,
10015 (void *)&cmd_flush_queue_region_cmd,
10016 (void *)&cmd_flush_queue_region_flush,
10017 (void *)&cmd_flush_queue_region_what,
10022 /* *** get all queue region related configuration info *** */
10023 struct cmd_show_queue_region_info {
10024 cmdline_fixed_string_t show;
10025 cmdline_fixed_string_t port;
10027 cmdline_fixed_string_t cmd;
10031 cmd_show_queue_region_info_parsed(void *parsed_result,
10032 __rte_unused struct cmdline *cl,
10033 __rte_unused void *data)
10035 struct cmd_show_queue_region_info *res = parsed_result;
10036 int ret = -ENOTSUP;
10037 #ifdef RTE_NET_I40E
10038 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10039 enum rte_pmd_i40e_queue_region_op op_type;
10042 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10045 #ifdef RTE_NET_I40E
10046 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10048 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10050 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10051 op_type, &rte_pmd_regions);
10053 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10060 printf("function not implemented or supported\n");
10063 printf("queue region config info show error: (%s)\n",
10068 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10069 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10071 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10072 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10074 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10075 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10076 port_id, RTE_UINT16);
10077 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10078 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10079 cmd, "queue-region");
10081 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10082 .f = cmd_show_queue_region_info_parsed,
10084 .help_str = "show port <port_id> queue-region"
10085 ": show all queue region related configuration info",
10087 (void *)&cmd_show_queue_region_info_get,
10088 (void *)&cmd_show_queue_region_info_port,
10089 (void *)&cmd_show_queue_region_info_port_index,
10090 (void *)&cmd_show_queue_region_info_cmd,
10095 /* *** Filters Control *** */
10098 str2flowtype(char *string)
10101 static const struct {
10104 } flowtype_str[] = {
10105 {"raw", RTE_ETH_FLOW_RAW},
10106 {"ipv4", RTE_ETH_FLOW_IPV4},
10107 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10108 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10109 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10110 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10111 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10112 {"ipv6", RTE_ETH_FLOW_IPV6},
10113 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10114 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10115 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10116 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10117 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10118 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10121 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10122 if (!strcmp(flowtype_str[i].str, string))
10123 return flowtype_str[i].type;
10126 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10127 return (uint16_t)atoi(string);
10129 return RTE_ETH_FLOW_UNKNOWN;
10132 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10134 if ((ip_addr).family == AF_INET) \
10135 (ip) = (ip_addr).addr.ipv4.s_addr; \
10137 printf("invalid parameter.\n"); \
10142 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10144 if ((ip_addr).family == AF_INET6) \
10145 rte_memcpy(&(ip), \
10146 &((ip_addr).addr.ipv6), \
10147 sizeof(struct in6_addr)); \
10149 printf("invalid parameter.\n"); \
10154 #ifdef RTE_NET_I40E
10156 /* *** deal with flow director filter *** */
10157 struct cmd_flow_director_result {
10158 cmdline_fixed_string_t flow_director_filter;
10160 cmdline_fixed_string_t mode;
10161 cmdline_fixed_string_t mode_value;
10162 cmdline_fixed_string_t ops;
10163 cmdline_fixed_string_t flow;
10164 cmdline_fixed_string_t flow_type;
10165 cmdline_fixed_string_t drop;
10166 cmdline_fixed_string_t queue;
10168 cmdline_fixed_string_t fd_id;
10169 uint32_t fd_id_value;
10170 cmdline_fixed_string_t packet;
10175 cmd_flow_director_filter_parsed(void *parsed_result,
10176 __rte_unused struct cmdline *cl,
10177 __rte_unused void *data)
10179 struct cmd_flow_director_result *res = parsed_result;
10181 struct rte_pmd_i40e_flow_type_mapping
10182 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10183 struct rte_pmd_i40e_pkt_template_conf conf;
10184 uint16_t flow_type = str2flowtype(res->flow_type);
10185 uint16_t i, port = res->port_id;
10188 memset(&conf, 0, sizeof(conf));
10190 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10191 printf("Invalid flow type specified.\n");
10194 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10198 if (mapping[flow_type].pctype == 0ULL) {
10199 printf("Invalid flow type specified.\n");
10202 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10203 if (mapping[flow_type].pctype & (1ULL << i)) {
10204 conf.input.pctype = i;
10209 conf.input.packet = open_file(res->filepath,
10210 &conf.input.length);
10211 if (!conf.input.packet)
10213 if (!strcmp(res->drop, "drop"))
10214 conf.action.behavior =
10215 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10217 conf.action.behavior =
10218 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10219 conf.action.report_status =
10220 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10221 conf.action.rx_queue = res->queue_id;
10222 conf.soft_id = res->fd_id_value;
10223 add = strcmp(res->ops, "del") ? 1 : 0;
10224 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10228 printf("flow director config error: (%s)\n",
10230 close_file(conf.input.packet);
10233 cmdline_parse_token_string_t cmd_flow_director_filter =
10234 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10235 flow_director_filter, "flow_director_filter");
10236 cmdline_parse_token_num_t cmd_flow_director_port_id =
10237 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10238 port_id, RTE_UINT16);
10239 cmdline_parse_token_string_t cmd_flow_director_ops =
10240 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10241 ops, "add#del#update");
10242 cmdline_parse_token_string_t cmd_flow_director_flow =
10243 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10245 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10246 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10248 cmdline_parse_token_string_t cmd_flow_director_drop =
10249 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10251 cmdline_parse_token_string_t cmd_flow_director_queue =
10252 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10254 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10255 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10256 queue_id, RTE_UINT16);
10257 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10258 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10260 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10261 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10262 fd_id_value, RTE_UINT32);
10264 cmdline_parse_token_string_t cmd_flow_director_mode =
10265 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10267 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10268 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10269 mode_value, "raw");
10270 cmdline_parse_token_string_t cmd_flow_director_packet =
10271 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10273 cmdline_parse_token_string_t cmd_flow_director_filepath =
10274 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10277 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10278 .f = cmd_flow_director_filter_parsed,
10280 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10281 "director entry on NIC",
10283 (void *)&cmd_flow_director_filter,
10284 (void *)&cmd_flow_director_port_id,
10285 (void *)&cmd_flow_director_mode,
10286 (void *)&cmd_flow_director_mode_raw,
10287 (void *)&cmd_flow_director_ops,
10288 (void *)&cmd_flow_director_flow,
10289 (void *)&cmd_flow_director_flow_type,
10290 (void *)&cmd_flow_director_drop,
10291 (void *)&cmd_flow_director_queue,
10292 (void *)&cmd_flow_director_queue_id,
10293 (void *)&cmd_flow_director_fd_id,
10294 (void *)&cmd_flow_director_fd_id_value,
10295 (void *)&cmd_flow_director_packet,
10296 (void *)&cmd_flow_director_filepath,
10301 #endif /* RTE_NET_I40E */
10303 /* *** deal with flow director mask *** */
10304 struct cmd_flow_director_mask_result {
10305 cmdline_fixed_string_t flow_director_mask;
10307 cmdline_fixed_string_t mode;
10308 cmdline_fixed_string_t mode_value;
10309 cmdline_fixed_string_t vlan;
10310 uint16_t vlan_mask;
10311 cmdline_fixed_string_t src_mask;
10312 cmdline_ipaddr_t ipv4_src;
10313 cmdline_ipaddr_t ipv6_src;
10315 cmdline_fixed_string_t dst_mask;
10316 cmdline_ipaddr_t ipv4_dst;
10317 cmdline_ipaddr_t ipv6_dst;
10319 cmdline_fixed_string_t mac;
10320 uint8_t mac_addr_byte_mask;
10321 cmdline_fixed_string_t tunnel_id;
10322 uint32_t tunnel_id_mask;
10323 cmdline_fixed_string_t tunnel_type;
10324 uint8_t tunnel_type_mask;
10328 cmd_flow_director_mask_parsed(void *parsed_result,
10329 __rte_unused struct cmdline *cl,
10330 __rte_unused void *data)
10332 struct cmd_flow_director_mask_result *res = parsed_result;
10333 struct rte_eth_fdir_masks *mask;
10334 struct rte_port *port;
10336 port = &ports[res->port_id];
10337 /** Check if the port is not started **/
10338 if (port->port_status != RTE_PORT_STOPPED) {
10339 printf("Please stop port %d first\n", res->port_id);
10343 mask = &port->dev_conf.fdir_conf.mask;
10345 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10346 if (strcmp(res->mode_value, "MAC-VLAN")) {
10347 printf("Please set mode to MAC-VLAN.\n");
10351 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10352 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10353 if (strcmp(res->mode_value, "Tunnel")) {
10354 printf("Please set mode to Tunnel.\n");
10358 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10359 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10360 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10361 mask->tunnel_type_mask = res->tunnel_type_mask;
10363 if (strcmp(res->mode_value, "IP")) {
10364 printf("Please set mode to IP.\n");
10368 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10369 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10370 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10371 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10372 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10373 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10374 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10377 cmd_reconfig_device_queue(res->port_id, 1, 1);
10380 cmdline_parse_token_string_t cmd_flow_director_mask =
10381 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10382 flow_director_mask, "flow_director_mask");
10383 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10384 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10385 port_id, RTE_UINT16);
10386 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10387 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10389 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10390 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10391 vlan_mask, RTE_UINT16);
10392 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10393 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10394 src_mask, "src_mask");
10395 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10396 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10398 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10399 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10401 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10402 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10403 port_src, RTE_UINT16);
10404 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10405 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10406 dst_mask, "dst_mask");
10407 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10408 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10410 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10411 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10413 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10414 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10415 port_dst, RTE_UINT16);
10417 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10418 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10420 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10421 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10423 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10424 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10425 mode_value, "MAC-VLAN");
10426 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10427 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10428 mode_value, "Tunnel");
10429 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10430 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10432 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10433 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10434 mac_addr_byte_mask, RTE_UINT8);
10435 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10436 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10437 tunnel_type, "tunnel-type");
10438 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10439 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10440 tunnel_type_mask, RTE_UINT8);
10441 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10442 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10443 tunnel_id, "tunnel-id");
10444 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10445 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10446 tunnel_id_mask, RTE_UINT32);
10448 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10449 .f = cmd_flow_director_mask_parsed,
10451 .help_str = "flow_director_mask ... : "
10452 "Set IP mode flow director's mask on NIC",
10454 (void *)&cmd_flow_director_mask,
10455 (void *)&cmd_flow_director_mask_port_id,
10456 (void *)&cmd_flow_director_mask_mode,
10457 (void *)&cmd_flow_director_mask_mode_ip,
10458 (void *)&cmd_flow_director_mask_vlan,
10459 (void *)&cmd_flow_director_mask_vlan_value,
10460 (void *)&cmd_flow_director_mask_src,
10461 (void *)&cmd_flow_director_mask_ipv4_src,
10462 (void *)&cmd_flow_director_mask_ipv6_src,
10463 (void *)&cmd_flow_director_mask_port_src,
10464 (void *)&cmd_flow_director_mask_dst,
10465 (void *)&cmd_flow_director_mask_ipv4_dst,
10466 (void *)&cmd_flow_director_mask_ipv6_dst,
10467 (void *)&cmd_flow_director_mask_port_dst,
10472 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10473 .f = cmd_flow_director_mask_parsed,
10475 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10476 "flow director's mask on NIC",
10478 (void *)&cmd_flow_director_mask,
10479 (void *)&cmd_flow_director_mask_port_id,
10480 (void *)&cmd_flow_director_mask_mode,
10481 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10482 (void *)&cmd_flow_director_mask_vlan,
10483 (void *)&cmd_flow_director_mask_vlan_value,
10488 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10489 .f = cmd_flow_director_mask_parsed,
10491 .help_str = "flow_director_mask ... : Set tunnel mode "
10492 "flow director's mask on NIC",
10494 (void *)&cmd_flow_director_mask,
10495 (void *)&cmd_flow_director_mask_port_id,
10496 (void *)&cmd_flow_director_mask_mode,
10497 (void *)&cmd_flow_director_mask_mode_tunnel,
10498 (void *)&cmd_flow_director_mask_vlan,
10499 (void *)&cmd_flow_director_mask_vlan_value,
10500 (void *)&cmd_flow_director_mask_mac,
10501 (void *)&cmd_flow_director_mask_mac_value,
10502 (void *)&cmd_flow_director_mask_tunnel_type,
10503 (void *)&cmd_flow_director_mask_tunnel_type_value,
10504 (void *)&cmd_flow_director_mask_tunnel_id,
10505 (void *)&cmd_flow_director_mask_tunnel_id_value,
10510 /* *** deal with flow director flexible payload configuration *** */
10511 struct cmd_flow_director_flexpayload_result {
10512 cmdline_fixed_string_t flow_director_flexpayload;
10514 cmdline_fixed_string_t payload_layer;
10515 cmdline_fixed_string_t payload_cfg;
10519 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10522 const char *p, *p0 = q_arg;
10524 unsigned long int_fld;
10525 char *str_fld[max_num];
10530 p = strchr(p0, '(');
10534 p0 = strchr(p, ')');
10539 if (size >= sizeof(s))
10542 snprintf(s, sizeof(s), "%.*s", size, p);
10543 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10544 if (ret < 0 || ret > max_num)
10546 for (i = 0; i < ret; i++) {
10548 int_fld = strtoul(str_fld[i], &end, 0);
10549 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10551 offsets[i] = (uint16_t)int_fld;
10557 cmd_flow_director_flxpld_parsed(void *parsed_result,
10558 __rte_unused struct cmdline *cl,
10559 __rte_unused void *data)
10561 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10562 struct rte_eth_flex_payload_cfg flex_cfg;
10563 struct rte_port *port;
10566 port = &ports[res->port_id];
10567 /** Check if the port is not started **/
10568 if (port->port_status != RTE_PORT_STOPPED) {
10569 printf("Please stop port %d first\n", res->port_id);
10573 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10575 if (!strcmp(res->payload_layer, "raw"))
10576 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10577 else if (!strcmp(res->payload_layer, "l2"))
10578 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10579 else if (!strcmp(res->payload_layer, "l3"))
10580 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10581 else if (!strcmp(res->payload_layer, "l4"))
10582 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10584 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10585 RTE_ETH_FDIR_MAX_FLEXLEN);
10587 printf("error: Cannot parse flex payload input.\n");
10591 fdir_set_flex_payload(res->port_id, &flex_cfg);
10592 cmd_reconfig_device_queue(res->port_id, 1, 1);
10595 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10596 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10597 flow_director_flexpayload,
10598 "flow_director_flex_payload");
10599 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10600 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10601 port_id, RTE_UINT16);
10602 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10603 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10604 payload_layer, "raw#l2#l3#l4");
10605 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10606 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10607 payload_cfg, NULL);
10609 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10610 .f = cmd_flow_director_flxpld_parsed,
10612 .help_str = "flow_director_flexpayload ... : "
10613 "Set flow director's flex payload on NIC",
10615 (void *)&cmd_flow_director_flexpayload,
10616 (void *)&cmd_flow_director_flexpayload_port_id,
10617 (void *)&cmd_flow_director_flexpayload_payload_layer,
10618 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10623 /* Generic flow interface command. */
10624 extern cmdline_parse_inst_t cmd_flow;
10626 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10627 struct cmd_mcast_addr_result {
10628 cmdline_fixed_string_t mcast_addr_cmd;
10629 cmdline_fixed_string_t what;
10631 struct rte_ether_addr mc_addr;
10634 static void cmd_mcast_addr_parsed(void *parsed_result,
10635 __rte_unused struct cmdline *cl,
10636 __rte_unused void *data)
10638 struct cmd_mcast_addr_result *res = parsed_result;
10640 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
10641 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10642 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10643 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10644 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10647 if (strcmp(res->what, "add") == 0)
10648 mcast_addr_add(res->port_num, &res->mc_addr);
10650 mcast_addr_remove(res->port_num, &res->mc_addr);
10653 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10654 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10655 mcast_addr_cmd, "mcast_addr");
10656 cmdline_parse_token_string_t cmd_mcast_addr_what =
10657 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10659 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10660 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
10662 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10663 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10665 cmdline_parse_inst_t cmd_mcast_addr = {
10666 .f = cmd_mcast_addr_parsed,
10668 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10669 "Add/Remove multicast MAC address on port_id",
10671 (void *)&cmd_mcast_addr_cmd,
10672 (void *)&cmd_mcast_addr_what,
10673 (void *)&cmd_mcast_addr_portnum,
10674 (void *)&cmd_mcast_addr_addr,
10679 /* vf vlan anti spoof configuration */
10681 /* Common result structure for vf vlan anti spoof */
10682 struct cmd_vf_vlan_anti_spoof_result {
10683 cmdline_fixed_string_t set;
10684 cmdline_fixed_string_t vf;
10685 cmdline_fixed_string_t vlan;
10686 cmdline_fixed_string_t antispoof;
10689 cmdline_fixed_string_t on_off;
10692 /* Common CLI fields for vf vlan anti spoof enable disable */
10693 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10694 TOKEN_STRING_INITIALIZER
10695 (struct cmd_vf_vlan_anti_spoof_result,
10697 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10698 TOKEN_STRING_INITIALIZER
10699 (struct cmd_vf_vlan_anti_spoof_result,
10701 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10702 TOKEN_STRING_INITIALIZER
10703 (struct cmd_vf_vlan_anti_spoof_result,
10705 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10706 TOKEN_STRING_INITIALIZER
10707 (struct cmd_vf_vlan_anti_spoof_result,
10708 antispoof, "antispoof");
10709 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10710 TOKEN_NUM_INITIALIZER
10711 (struct cmd_vf_vlan_anti_spoof_result,
10712 port_id, RTE_UINT16);
10713 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10714 TOKEN_NUM_INITIALIZER
10715 (struct cmd_vf_vlan_anti_spoof_result,
10716 vf_id, RTE_UINT32);
10717 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10718 TOKEN_STRING_INITIALIZER
10719 (struct cmd_vf_vlan_anti_spoof_result,
10723 cmd_set_vf_vlan_anti_spoof_parsed(
10724 void *parsed_result,
10725 __rte_unused struct cmdline *cl,
10726 __rte_unused void *data)
10728 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10729 int ret = -ENOTSUP;
10731 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10733 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10736 #ifdef RTE_NET_IXGBE
10737 if (ret == -ENOTSUP)
10738 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10739 res->vf_id, is_on);
10741 #ifdef RTE_NET_I40E
10742 if (ret == -ENOTSUP)
10743 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10744 res->vf_id, is_on);
10746 #ifdef RTE_NET_BNXT
10747 if (ret == -ENOTSUP)
10748 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
10749 res->vf_id, is_on);
10756 printf("invalid vf_id %d\n", res->vf_id);
10759 printf("invalid port_id %d\n", res->port_id);
10762 printf("function not implemented\n");
10765 printf("programming error: (%s)\n", strerror(-ret));
10769 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10770 .f = cmd_set_vf_vlan_anti_spoof_parsed,
10772 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10774 (void *)&cmd_vf_vlan_anti_spoof_set,
10775 (void *)&cmd_vf_vlan_anti_spoof_vf,
10776 (void *)&cmd_vf_vlan_anti_spoof_vlan,
10777 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
10778 (void *)&cmd_vf_vlan_anti_spoof_port_id,
10779 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
10780 (void *)&cmd_vf_vlan_anti_spoof_on_off,
10785 /* vf mac anti spoof configuration */
10787 /* Common result structure for vf mac anti spoof */
10788 struct cmd_vf_mac_anti_spoof_result {
10789 cmdline_fixed_string_t set;
10790 cmdline_fixed_string_t vf;
10791 cmdline_fixed_string_t mac;
10792 cmdline_fixed_string_t antispoof;
10795 cmdline_fixed_string_t on_off;
10798 /* Common CLI fields for vf mac anti spoof enable disable */
10799 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
10800 TOKEN_STRING_INITIALIZER
10801 (struct cmd_vf_mac_anti_spoof_result,
10803 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
10804 TOKEN_STRING_INITIALIZER
10805 (struct cmd_vf_mac_anti_spoof_result,
10807 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
10808 TOKEN_STRING_INITIALIZER
10809 (struct cmd_vf_mac_anti_spoof_result,
10811 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
10812 TOKEN_STRING_INITIALIZER
10813 (struct cmd_vf_mac_anti_spoof_result,
10814 antispoof, "antispoof");
10815 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
10816 TOKEN_NUM_INITIALIZER
10817 (struct cmd_vf_mac_anti_spoof_result,
10818 port_id, RTE_UINT16);
10819 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
10820 TOKEN_NUM_INITIALIZER
10821 (struct cmd_vf_mac_anti_spoof_result,
10822 vf_id, RTE_UINT32);
10823 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
10824 TOKEN_STRING_INITIALIZER
10825 (struct cmd_vf_mac_anti_spoof_result,
10829 cmd_set_vf_mac_anti_spoof_parsed(
10830 void *parsed_result,
10831 __rte_unused struct cmdline *cl,
10832 __rte_unused void *data)
10834 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
10835 int ret = -ENOTSUP;
10837 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10839 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10842 #ifdef RTE_NET_IXGBE
10843 if (ret == -ENOTSUP)
10844 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
10845 res->vf_id, is_on);
10847 #ifdef RTE_NET_I40E
10848 if (ret == -ENOTSUP)
10849 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
10850 res->vf_id, is_on);
10852 #ifdef RTE_NET_BNXT
10853 if (ret == -ENOTSUP)
10854 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
10855 res->vf_id, is_on);
10862 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
10865 printf("invalid port_id %d\n", res->port_id);
10868 printf("function not implemented\n");
10871 printf("programming error: (%s)\n", strerror(-ret));
10875 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
10876 .f = cmd_set_vf_mac_anti_spoof_parsed,
10878 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
10880 (void *)&cmd_vf_mac_anti_spoof_set,
10881 (void *)&cmd_vf_mac_anti_spoof_vf,
10882 (void *)&cmd_vf_mac_anti_spoof_mac,
10883 (void *)&cmd_vf_mac_anti_spoof_antispoof,
10884 (void *)&cmd_vf_mac_anti_spoof_port_id,
10885 (void *)&cmd_vf_mac_anti_spoof_vf_id,
10886 (void *)&cmd_vf_mac_anti_spoof_on_off,
10891 /* vf vlan strip queue configuration */
10893 /* Common result structure for vf mac anti spoof */
10894 struct cmd_vf_vlan_stripq_result {
10895 cmdline_fixed_string_t set;
10896 cmdline_fixed_string_t vf;
10897 cmdline_fixed_string_t vlan;
10898 cmdline_fixed_string_t stripq;
10901 cmdline_fixed_string_t on_off;
10904 /* Common CLI fields for vf vlan strip enable disable */
10905 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
10906 TOKEN_STRING_INITIALIZER
10907 (struct cmd_vf_vlan_stripq_result,
10909 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
10910 TOKEN_STRING_INITIALIZER
10911 (struct cmd_vf_vlan_stripq_result,
10913 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
10914 TOKEN_STRING_INITIALIZER
10915 (struct cmd_vf_vlan_stripq_result,
10917 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
10918 TOKEN_STRING_INITIALIZER
10919 (struct cmd_vf_vlan_stripq_result,
10921 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
10922 TOKEN_NUM_INITIALIZER
10923 (struct cmd_vf_vlan_stripq_result,
10924 port_id, RTE_UINT16);
10925 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
10926 TOKEN_NUM_INITIALIZER
10927 (struct cmd_vf_vlan_stripq_result,
10928 vf_id, RTE_UINT16);
10929 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
10930 TOKEN_STRING_INITIALIZER
10931 (struct cmd_vf_vlan_stripq_result,
10935 cmd_set_vf_vlan_stripq_parsed(
10936 void *parsed_result,
10937 __rte_unused struct cmdline *cl,
10938 __rte_unused void *data)
10940 struct cmd_vf_vlan_stripq_result *res = parsed_result;
10941 int ret = -ENOTSUP;
10943 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10945 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10948 #ifdef RTE_NET_IXGBE
10949 if (ret == -ENOTSUP)
10950 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
10951 res->vf_id, is_on);
10953 #ifdef RTE_NET_I40E
10954 if (ret == -ENOTSUP)
10955 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
10956 res->vf_id, is_on);
10958 #ifdef RTE_NET_BNXT
10959 if (ret == -ENOTSUP)
10960 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
10961 res->vf_id, is_on);
10968 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
10971 printf("invalid port_id %d\n", res->port_id);
10974 printf("function not implemented\n");
10977 printf("programming error: (%s)\n", strerror(-ret));
10981 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
10982 .f = cmd_set_vf_vlan_stripq_parsed,
10984 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
10986 (void *)&cmd_vf_vlan_stripq_set,
10987 (void *)&cmd_vf_vlan_stripq_vf,
10988 (void *)&cmd_vf_vlan_stripq_vlan,
10989 (void *)&cmd_vf_vlan_stripq_stripq,
10990 (void *)&cmd_vf_vlan_stripq_port_id,
10991 (void *)&cmd_vf_vlan_stripq_vf_id,
10992 (void *)&cmd_vf_vlan_stripq_on_off,
10997 /* vf vlan insert configuration */
10999 /* Common result structure for vf vlan insert */
11000 struct cmd_vf_vlan_insert_result {
11001 cmdline_fixed_string_t set;
11002 cmdline_fixed_string_t vf;
11003 cmdline_fixed_string_t vlan;
11004 cmdline_fixed_string_t insert;
11010 /* Common CLI fields for vf vlan insert enable disable */
11011 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11012 TOKEN_STRING_INITIALIZER
11013 (struct cmd_vf_vlan_insert_result,
11015 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11016 TOKEN_STRING_INITIALIZER
11017 (struct cmd_vf_vlan_insert_result,
11019 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11020 TOKEN_STRING_INITIALIZER
11021 (struct cmd_vf_vlan_insert_result,
11023 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11024 TOKEN_STRING_INITIALIZER
11025 (struct cmd_vf_vlan_insert_result,
11027 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11028 TOKEN_NUM_INITIALIZER
11029 (struct cmd_vf_vlan_insert_result,
11030 port_id, RTE_UINT16);
11031 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11032 TOKEN_NUM_INITIALIZER
11033 (struct cmd_vf_vlan_insert_result,
11034 vf_id, RTE_UINT16);
11035 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11036 TOKEN_NUM_INITIALIZER
11037 (struct cmd_vf_vlan_insert_result,
11038 vlan_id, RTE_UINT16);
11041 cmd_set_vf_vlan_insert_parsed(
11042 void *parsed_result,
11043 __rte_unused struct cmdline *cl,
11044 __rte_unused void *data)
11046 struct cmd_vf_vlan_insert_result *res = parsed_result;
11047 int ret = -ENOTSUP;
11049 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11052 #ifdef RTE_NET_IXGBE
11053 if (ret == -ENOTSUP)
11054 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11057 #ifdef RTE_NET_I40E
11058 if (ret == -ENOTSUP)
11059 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11062 #ifdef RTE_NET_BNXT
11063 if (ret == -ENOTSUP)
11064 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11072 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11075 printf("invalid port_id %d\n", res->port_id);
11078 printf("function not implemented\n");
11081 printf("programming error: (%s)\n", strerror(-ret));
11085 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11086 .f = cmd_set_vf_vlan_insert_parsed,
11088 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11090 (void *)&cmd_vf_vlan_insert_set,
11091 (void *)&cmd_vf_vlan_insert_vf,
11092 (void *)&cmd_vf_vlan_insert_vlan,
11093 (void *)&cmd_vf_vlan_insert_insert,
11094 (void *)&cmd_vf_vlan_insert_port_id,
11095 (void *)&cmd_vf_vlan_insert_vf_id,
11096 (void *)&cmd_vf_vlan_insert_vlan_id,
11101 /* tx loopback configuration */
11103 /* Common result structure for tx loopback */
11104 struct cmd_tx_loopback_result {
11105 cmdline_fixed_string_t set;
11106 cmdline_fixed_string_t tx;
11107 cmdline_fixed_string_t loopback;
11109 cmdline_fixed_string_t on_off;
11112 /* Common CLI fields for tx loopback enable disable */
11113 cmdline_parse_token_string_t cmd_tx_loopback_set =
11114 TOKEN_STRING_INITIALIZER
11115 (struct cmd_tx_loopback_result,
11117 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11118 TOKEN_STRING_INITIALIZER
11119 (struct cmd_tx_loopback_result,
11121 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11122 TOKEN_STRING_INITIALIZER
11123 (struct cmd_tx_loopback_result,
11124 loopback, "loopback");
11125 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11126 TOKEN_NUM_INITIALIZER
11127 (struct cmd_tx_loopback_result,
11128 port_id, RTE_UINT16);
11129 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11130 TOKEN_STRING_INITIALIZER
11131 (struct cmd_tx_loopback_result,
11135 cmd_set_tx_loopback_parsed(
11136 void *parsed_result,
11137 __rte_unused struct cmdline *cl,
11138 __rte_unused void *data)
11140 struct cmd_tx_loopback_result *res = parsed_result;
11141 int ret = -ENOTSUP;
11143 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11145 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11148 #ifdef RTE_NET_IXGBE
11149 if (ret == -ENOTSUP)
11150 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11152 #ifdef RTE_NET_I40E
11153 if (ret == -ENOTSUP)
11154 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11156 #ifdef RTE_NET_BNXT
11157 if (ret == -ENOTSUP)
11158 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11160 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11161 if (ret == -ENOTSUP)
11162 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11169 printf("invalid is_on %d\n", is_on);
11172 printf("invalid port_id %d\n", res->port_id);
11175 printf("function not implemented\n");
11178 printf("programming error: (%s)\n", strerror(-ret));
11182 cmdline_parse_inst_t cmd_set_tx_loopback = {
11183 .f = cmd_set_tx_loopback_parsed,
11185 .help_str = "set tx loopback <port_id> on|off",
11187 (void *)&cmd_tx_loopback_set,
11188 (void *)&cmd_tx_loopback_tx,
11189 (void *)&cmd_tx_loopback_loopback,
11190 (void *)&cmd_tx_loopback_port_id,
11191 (void *)&cmd_tx_loopback_on_off,
11196 /* all queues drop enable configuration */
11198 /* Common result structure for all queues drop enable */
11199 struct cmd_all_queues_drop_en_result {
11200 cmdline_fixed_string_t set;
11201 cmdline_fixed_string_t all;
11202 cmdline_fixed_string_t queues;
11203 cmdline_fixed_string_t drop;
11205 cmdline_fixed_string_t on_off;
11208 /* Common CLI fields for tx loopback enable disable */
11209 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11210 TOKEN_STRING_INITIALIZER
11211 (struct cmd_all_queues_drop_en_result,
11213 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11214 TOKEN_STRING_INITIALIZER
11215 (struct cmd_all_queues_drop_en_result,
11217 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11218 TOKEN_STRING_INITIALIZER
11219 (struct cmd_all_queues_drop_en_result,
11221 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11222 TOKEN_STRING_INITIALIZER
11223 (struct cmd_all_queues_drop_en_result,
11225 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11226 TOKEN_NUM_INITIALIZER
11227 (struct cmd_all_queues_drop_en_result,
11228 port_id, RTE_UINT16);
11229 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11230 TOKEN_STRING_INITIALIZER
11231 (struct cmd_all_queues_drop_en_result,
11235 cmd_set_all_queues_drop_en_parsed(
11236 void *parsed_result,
11237 __rte_unused struct cmdline *cl,
11238 __rte_unused void *data)
11240 struct cmd_all_queues_drop_en_result *res = parsed_result;
11241 int ret = -ENOTSUP;
11242 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11244 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11247 #ifdef RTE_NET_IXGBE
11248 if (ret == -ENOTSUP)
11249 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11251 #ifdef RTE_NET_BNXT
11252 if (ret == -ENOTSUP)
11253 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11259 printf("invalid is_on %d\n", is_on);
11262 printf("invalid port_id %d\n", res->port_id);
11265 printf("function not implemented\n");
11268 printf("programming error: (%s)\n", strerror(-ret));
11272 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11273 .f = cmd_set_all_queues_drop_en_parsed,
11275 .help_str = "set all queues drop <port_id> on|off",
11277 (void *)&cmd_all_queues_drop_en_set,
11278 (void *)&cmd_all_queues_drop_en_all,
11279 (void *)&cmd_all_queues_drop_en_queues,
11280 (void *)&cmd_all_queues_drop_en_drop,
11281 (void *)&cmd_all_queues_drop_en_port_id,
11282 (void *)&cmd_all_queues_drop_en_on_off,
11287 /* vf split drop enable configuration */
11289 /* Common result structure for vf split drop enable */
11290 struct cmd_vf_split_drop_en_result {
11291 cmdline_fixed_string_t set;
11292 cmdline_fixed_string_t vf;
11293 cmdline_fixed_string_t split;
11294 cmdline_fixed_string_t drop;
11297 cmdline_fixed_string_t on_off;
11300 /* Common CLI fields for vf split drop enable disable */
11301 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11302 TOKEN_STRING_INITIALIZER
11303 (struct cmd_vf_split_drop_en_result,
11305 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11306 TOKEN_STRING_INITIALIZER
11307 (struct cmd_vf_split_drop_en_result,
11309 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11310 TOKEN_STRING_INITIALIZER
11311 (struct cmd_vf_split_drop_en_result,
11313 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11314 TOKEN_STRING_INITIALIZER
11315 (struct cmd_vf_split_drop_en_result,
11317 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11318 TOKEN_NUM_INITIALIZER
11319 (struct cmd_vf_split_drop_en_result,
11320 port_id, RTE_UINT16);
11321 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11322 TOKEN_NUM_INITIALIZER
11323 (struct cmd_vf_split_drop_en_result,
11324 vf_id, RTE_UINT16);
11325 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11326 TOKEN_STRING_INITIALIZER
11327 (struct cmd_vf_split_drop_en_result,
11331 cmd_set_vf_split_drop_en_parsed(
11332 void *parsed_result,
11333 __rte_unused struct cmdline *cl,
11334 __rte_unused void *data)
11336 struct cmd_vf_split_drop_en_result *res = parsed_result;
11337 int ret = -ENOTSUP;
11338 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11340 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11343 #ifdef RTE_NET_IXGBE
11344 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11351 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11354 printf("invalid port_id %d\n", res->port_id);
11357 printf("not supported on port %d\n", res->port_id);
11360 printf("programming error: (%s)\n", strerror(-ret));
11364 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11365 .f = cmd_set_vf_split_drop_en_parsed,
11367 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11369 (void *)&cmd_vf_split_drop_en_set,
11370 (void *)&cmd_vf_split_drop_en_vf,
11371 (void *)&cmd_vf_split_drop_en_split,
11372 (void *)&cmd_vf_split_drop_en_drop,
11373 (void *)&cmd_vf_split_drop_en_port_id,
11374 (void *)&cmd_vf_split_drop_en_vf_id,
11375 (void *)&cmd_vf_split_drop_en_on_off,
11380 /* vf mac address configuration */
11382 /* Common result structure for vf mac address */
11383 struct cmd_set_vf_mac_addr_result {
11384 cmdline_fixed_string_t set;
11385 cmdline_fixed_string_t vf;
11386 cmdline_fixed_string_t mac;
11387 cmdline_fixed_string_t addr;
11390 struct rte_ether_addr mac_addr;
11394 /* Common CLI fields for vf split drop enable disable */
11395 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11396 TOKEN_STRING_INITIALIZER
11397 (struct cmd_set_vf_mac_addr_result,
11399 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11400 TOKEN_STRING_INITIALIZER
11401 (struct cmd_set_vf_mac_addr_result,
11403 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11404 TOKEN_STRING_INITIALIZER
11405 (struct cmd_set_vf_mac_addr_result,
11407 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11408 TOKEN_STRING_INITIALIZER
11409 (struct cmd_set_vf_mac_addr_result,
11411 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11412 TOKEN_NUM_INITIALIZER
11413 (struct cmd_set_vf_mac_addr_result,
11414 port_id, RTE_UINT16);
11415 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11416 TOKEN_NUM_INITIALIZER
11417 (struct cmd_set_vf_mac_addr_result,
11418 vf_id, RTE_UINT16);
11419 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11420 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11424 cmd_set_vf_mac_addr_parsed(
11425 void *parsed_result,
11426 __rte_unused struct cmdline *cl,
11427 __rte_unused void *data)
11429 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11430 int ret = -ENOTSUP;
11432 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11435 #ifdef RTE_NET_IXGBE
11436 if (ret == -ENOTSUP)
11437 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11440 #ifdef RTE_NET_I40E
11441 if (ret == -ENOTSUP)
11442 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11445 #ifdef RTE_NET_BNXT
11446 if (ret == -ENOTSUP)
11447 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11455 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11458 printf("invalid port_id %d\n", res->port_id);
11461 printf("function not implemented\n");
11464 printf("programming error: (%s)\n", strerror(-ret));
11468 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11469 .f = cmd_set_vf_mac_addr_parsed,
11471 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11473 (void *)&cmd_set_vf_mac_addr_set,
11474 (void *)&cmd_set_vf_mac_addr_vf,
11475 (void *)&cmd_set_vf_mac_addr_mac,
11476 (void *)&cmd_set_vf_mac_addr_addr,
11477 (void *)&cmd_set_vf_mac_addr_port_id,
11478 (void *)&cmd_set_vf_mac_addr_vf_id,
11479 (void *)&cmd_set_vf_mac_addr_mac_addr,
11484 /* MACsec configuration */
11486 /* Common result structure for MACsec offload enable */
11487 struct cmd_macsec_offload_on_result {
11488 cmdline_fixed_string_t set;
11489 cmdline_fixed_string_t macsec;
11490 cmdline_fixed_string_t offload;
11492 cmdline_fixed_string_t on;
11493 cmdline_fixed_string_t encrypt;
11494 cmdline_fixed_string_t en_on_off;
11495 cmdline_fixed_string_t replay_protect;
11496 cmdline_fixed_string_t rp_on_off;
11499 /* Common CLI fields for MACsec offload disable */
11500 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11501 TOKEN_STRING_INITIALIZER
11502 (struct cmd_macsec_offload_on_result,
11504 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11505 TOKEN_STRING_INITIALIZER
11506 (struct cmd_macsec_offload_on_result,
11508 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11509 TOKEN_STRING_INITIALIZER
11510 (struct cmd_macsec_offload_on_result,
11511 offload, "offload");
11512 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11513 TOKEN_NUM_INITIALIZER
11514 (struct cmd_macsec_offload_on_result,
11515 port_id, RTE_UINT16);
11516 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11517 TOKEN_STRING_INITIALIZER
11518 (struct cmd_macsec_offload_on_result,
11520 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11521 TOKEN_STRING_INITIALIZER
11522 (struct cmd_macsec_offload_on_result,
11523 encrypt, "encrypt");
11524 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11525 TOKEN_STRING_INITIALIZER
11526 (struct cmd_macsec_offload_on_result,
11527 en_on_off, "on#off");
11528 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11529 TOKEN_STRING_INITIALIZER
11530 (struct cmd_macsec_offload_on_result,
11531 replay_protect, "replay-protect");
11532 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11533 TOKEN_STRING_INITIALIZER
11534 (struct cmd_macsec_offload_on_result,
11535 rp_on_off, "on#off");
11538 cmd_set_macsec_offload_on_parsed(
11539 void *parsed_result,
11540 __rte_unused struct cmdline *cl,
11541 __rte_unused void *data)
11543 struct cmd_macsec_offload_on_result *res = parsed_result;
11544 int ret = -ENOTSUP;
11545 portid_t port_id = res->port_id;
11546 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11547 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11548 struct rte_eth_dev_info dev_info;
11550 if (port_id_is_invalid(port_id, ENABLED_WARN))
11552 if (!port_is_stopped(port_id)) {
11553 printf("Please stop port %d first\n", port_id);
11557 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11561 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11562 #ifdef RTE_NET_IXGBE
11563 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11571 ports[port_id].dev_conf.txmode.offloads |=
11572 DEV_TX_OFFLOAD_MACSEC_INSERT;
11573 cmd_reconfig_device_queue(port_id, 1, 1);
11576 printf("invalid port_id %d\n", port_id);
11579 printf("not supported on port %d\n", port_id);
11582 printf("programming error: (%s)\n", strerror(-ret));
11586 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11587 .f = cmd_set_macsec_offload_on_parsed,
11589 .help_str = "set macsec offload <port_id> on "
11590 "encrypt on|off replay-protect on|off",
11592 (void *)&cmd_macsec_offload_on_set,
11593 (void *)&cmd_macsec_offload_on_macsec,
11594 (void *)&cmd_macsec_offload_on_offload,
11595 (void *)&cmd_macsec_offload_on_port_id,
11596 (void *)&cmd_macsec_offload_on_on,
11597 (void *)&cmd_macsec_offload_on_encrypt,
11598 (void *)&cmd_macsec_offload_on_en_on_off,
11599 (void *)&cmd_macsec_offload_on_replay_protect,
11600 (void *)&cmd_macsec_offload_on_rp_on_off,
11605 /* Common result structure for MACsec offload disable */
11606 struct cmd_macsec_offload_off_result {
11607 cmdline_fixed_string_t set;
11608 cmdline_fixed_string_t macsec;
11609 cmdline_fixed_string_t offload;
11611 cmdline_fixed_string_t off;
11614 /* Common CLI fields for MACsec offload disable */
11615 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11616 TOKEN_STRING_INITIALIZER
11617 (struct cmd_macsec_offload_off_result,
11619 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11620 TOKEN_STRING_INITIALIZER
11621 (struct cmd_macsec_offload_off_result,
11623 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11624 TOKEN_STRING_INITIALIZER
11625 (struct cmd_macsec_offload_off_result,
11626 offload, "offload");
11627 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11628 TOKEN_NUM_INITIALIZER
11629 (struct cmd_macsec_offload_off_result,
11630 port_id, RTE_UINT16);
11631 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11632 TOKEN_STRING_INITIALIZER
11633 (struct cmd_macsec_offload_off_result,
11637 cmd_set_macsec_offload_off_parsed(
11638 void *parsed_result,
11639 __rte_unused struct cmdline *cl,
11640 __rte_unused void *data)
11642 struct cmd_macsec_offload_off_result *res = parsed_result;
11643 int ret = -ENOTSUP;
11644 struct rte_eth_dev_info dev_info;
11645 portid_t port_id = res->port_id;
11647 if (port_id_is_invalid(port_id, ENABLED_WARN))
11649 if (!port_is_stopped(port_id)) {
11650 printf("Please stop port %d first\n", port_id);
11654 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11658 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11659 #ifdef RTE_NET_IXGBE
11660 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11665 ports[port_id].dev_conf.txmode.offloads &=
11666 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
11667 cmd_reconfig_device_queue(port_id, 1, 1);
11670 printf("invalid port_id %d\n", port_id);
11673 printf("not supported on port %d\n", port_id);
11676 printf("programming error: (%s)\n", strerror(-ret));
11680 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11681 .f = cmd_set_macsec_offload_off_parsed,
11683 .help_str = "set macsec offload <port_id> off",
11685 (void *)&cmd_macsec_offload_off_set,
11686 (void *)&cmd_macsec_offload_off_macsec,
11687 (void *)&cmd_macsec_offload_off_offload,
11688 (void *)&cmd_macsec_offload_off_port_id,
11689 (void *)&cmd_macsec_offload_off_off,
11694 /* Common result structure for MACsec secure connection configure */
11695 struct cmd_macsec_sc_result {
11696 cmdline_fixed_string_t set;
11697 cmdline_fixed_string_t macsec;
11698 cmdline_fixed_string_t sc;
11699 cmdline_fixed_string_t tx_rx;
11701 struct rte_ether_addr mac;
11705 /* Common CLI fields for MACsec secure connection configure */
11706 cmdline_parse_token_string_t cmd_macsec_sc_set =
11707 TOKEN_STRING_INITIALIZER
11708 (struct cmd_macsec_sc_result,
11710 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11711 TOKEN_STRING_INITIALIZER
11712 (struct cmd_macsec_sc_result,
11714 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11715 TOKEN_STRING_INITIALIZER
11716 (struct cmd_macsec_sc_result,
11718 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11719 TOKEN_STRING_INITIALIZER
11720 (struct cmd_macsec_sc_result,
11722 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11723 TOKEN_NUM_INITIALIZER
11724 (struct cmd_macsec_sc_result,
11725 port_id, RTE_UINT16);
11726 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11727 TOKEN_ETHERADDR_INITIALIZER
11728 (struct cmd_macsec_sc_result,
11730 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11731 TOKEN_NUM_INITIALIZER
11732 (struct cmd_macsec_sc_result,
11736 cmd_set_macsec_sc_parsed(
11737 void *parsed_result,
11738 __rte_unused struct cmdline *cl,
11739 __rte_unused void *data)
11741 struct cmd_macsec_sc_result *res = parsed_result;
11742 int ret = -ENOTSUP;
11743 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11745 #ifdef RTE_NET_IXGBE
11747 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11748 res->mac.addr_bytes) :
11749 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11750 res->mac.addr_bytes, res->pi);
11752 RTE_SET_USED(is_tx);
11758 printf("invalid port_id %d\n", res->port_id);
11761 printf("not supported on port %d\n", res->port_id);
11764 printf("programming error: (%s)\n", strerror(-ret));
11768 cmdline_parse_inst_t cmd_set_macsec_sc = {
11769 .f = cmd_set_macsec_sc_parsed,
11771 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11773 (void *)&cmd_macsec_sc_set,
11774 (void *)&cmd_macsec_sc_macsec,
11775 (void *)&cmd_macsec_sc_sc,
11776 (void *)&cmd_macsec_sc_tx_rx,
11777 (void *)&cmd_macsec_sc_port_id,
11778 (void *)&cmd_macsec_sc_mac,
11779 (void *)&cmd_macsec_sc_pi,
11784 /* Common result structure for MACsec secure connection configure */
11785 struct cmd_macsec_sa_result {
11786 cmdline_fixed_string_t set;
11787 cmdline_fixed_string_t macsec;
11788 cmdline_fixed_string_t sa;
11789 cmdline_fixed_string_t tx_rx;
11794 cmdline_fixed_string_t key;
11797 /* Common CLI fields for MACsec secure connection configure */
11798 cmdline_parse_token_string_t cmd_macsec_sa_set =
11799 TOKEN_STRING_INITIALIZER
11800 (struct cmd_macsec_sa_result,
11802 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11803 TOKEN_STRING_INITIALIZER
11804 (struct cmd_macsec_sa_result,
11806 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11807 TOKEN_STRING_INITIALIZER
11808 (struct cmd_macsec_sa_result,
11810 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11811 TOKEN_STRING_INITIALIZER
11812 (struct cmd_macsec_sa_result,
11814 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11815 TOKEN_NUM_INITIALIZER
11816 (struct cmd_macsec_sa_result,
11817 port_id, RTE_UINT16);
11818 cmdline_parse_token_num_t cmd_macsec_sa_idx =
11819 TOKEN_NUM_INITIALIZER
11820 (struct cmd_macsec_sa_result,
11822 cmdline_parse_token_num_t cmd_macsec_sa_an =
11823 TOKEN_NUM_INITIALIZER
11824 (struct cmd_macsec_sa_result,
11826 cmdline_parse_token_num_t cmd_macsec_sa_pn =
11827 TOKEN_NUM_INITIALIZER
11828 (struct cmd_macsec_sa_result,
11830 cmdline_parse_token_string_t cmd_macsec_sa_key =
11831 TOKEN_STRING_INITIALIZER
11832 (struct cmd_macsec_sa_result,
11836 cmd_set_macsec_sa_parsed(
11837 void *parsed_result,
11838 __rte_unused struct cmdline *cl,
11839 __rte_unused void *data)
11841 struct cmd_macsec_sa_result *res = parsed_result;
11842 int ret = -ENOTSUP;
11843 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11844 uint8_t key[16] = { 0 };
11850 key_len = strlen(res->key) / 2;
11854 for (i = 0; i < key_len; i++) {
11855 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
11858 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
11861 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
11864 #ifdef RTE_NET_IXGBE
11866 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
11867 res->idx, res->an, res->pn, key) :
11868 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
11869 res->idx, res->an, res->pn, key);
11871 RTE_SET_USED(is_tx);
11878 printf("invalid idx %d or an %d\n", res->idx, res->an);
11881 printf("invalid port_id %d\n", res->port_id);
11884 printf("not supported on port %d\n", res->port_id);
11887 printf("programming error: (%s)\n", strerror(-ret));
11891 cmdline_parse_inst_t cmd_set_macsec_sa = {
11892 .f = cmd_set_macsec_sa_parsed,
11894 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
11896 (void *)&cmd_macsec_sa_set,
11897 (void *)&cmd_macsec_sa_macsec,
11898 (void *)&cmd_macsec_sa_sa,
11899 (void *)&cmd_macsec_sa_tx_rx,
11900 (void *)&cmd_macsec_sa_port_id,
11901 (void *)&cmd_macsec_sa_idx,
11902 (void *)&cmd_macsec_sa_an,
11903 (void *)&cmd_macsec_sa_pn,
11904 (void *)&cmd_macsec_sa_key,
11909 /* VF unicast promiscuous mode configuration */
11911 /* Common result structure for VF unicast promiscuous mode */
11912 struct cmd_vf_promisc_result {
11913 cmdline_fixed_string_t set;
11914 cmdline_fixed_string_t vf;
11915 cmdline_fixed_string_t promisc;
11918 cmdline_fixed_string_t on_off;
11921 /* Common CLI fields for VF unicast promiscuous mode enable disable */
11922 cmdline_parse_token_string_t cmd_vf_promisc_set =
11923 TOKEN_STRING_INITIALIZER
11924 (struct cmd_vf_promisc_result,
11926 cmdline_parse_token_string_t cmd_vf_promisc_vf =
11927 TOKEN_STRING_INITIALIZER
11928 (struct cmd_vf_promisc_result,
11930 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
11931 TOKEN_STRING_INITIALIZER
11932 (struct cmd_vf_promisc_result,
11933 promisc, "promisc");
11934 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
11935 TOKEN_NUM_INITIALIZER
11936 (struct cmd_vf_promisc_result,
11937 port_id, RTE_UINT16);
11938 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
11939 TOKEN_NUM_INITIALIZER
11940 (struct cmd_vf_promisc_result,
11941 vf_id, RTE_UINT32);
11942 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
11943 TOKEN_STRING_INITIALIZER
11944 (struct cmd_vf_promisc_result,
11948 cmd_set_vf_promisc_parsed(
11949 void *parsed_result,
11950 __rte_unused struct cmdline *cl,
11951 __rte_unused void *data)
11953 struct cmd_vf_promisc_result *res = parsed_result;
11954 int ret = -ENOTSUP;
11956 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11958 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11961 #ifdef RTE_NET_I40E
11962 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
11963 res->vf_id, is_on);
11970 printf("invalid vf_id %d\n", res->vf_id);
11973 printf("invalid port_id %d\n", res->port_id);
11976 printf("function not implemented\n");
11979 printf("programming error: (%s)\n", strerror(-ret));
11983 cmdline_parse_inst_t cmd_set_vf_promisc = {
11984 .f = cmd_set_vf_promisc_parsed,
11986 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
11987 "Set unicast promiscuous mode for a VF from the PF",
11989 (void *)&cmd_vf_promisc_set,
11990 (void *)&cmd_vf_promisc_vf,
11991 (void *)&cmd_vf_promisc_promisc,
11992 (void *)&cmd_vf_promisc_port_id,
11993 (void *)&cmd_vf_promisc_vf_id,
11994 (void *)&cmd_vf_promisc_on_off,
11999 /* VF multicast promiscuous mode configuration */
12001 /* Common result structure for VF multicast promiscuous mode */
12002 struct cmd_vf_allmulti_result {
12003 cmdline_fixed_string_t set;
12004 cmdline_fixed_string_t vf;
12005 cmdline_fixed_string_t allmulti;
12008 cmdline_fixed_string_t on_off;
12011 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12012 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12013 TOKEN_STRING_INITIALIZER
12014 (struct cmd_vf_allmulti_result,
12016 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12017 TOKEN_STRING_INITIALIZER
12018 (struct cmd_vf_allmulti_result,
12020 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12021 TOKEN_STRING_INITIALIZER
12022 (struct cmd_vf_allmulti_result,
12023 allmulti, "allmulti");
12024 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12025 TOKEN_NUM_INITIALIZER
12026 (struct cmd_vf_allmulti_result,
12027 port_id, RTE_UINT16);
12028 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12029 TOKEN_NUM_INITIALIZER
12030 (struct cmd_vf_allmulti_result,
12031 vf_id, RTE_UINT32);
12032 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12033 TOKEN_STRING_INITIALIZER
12034 (struct cmd_vf_allmulti_result,
12038 cmd_set_vf_allmulti_parsed(
12039 void *parsed_result,
12040 __rte_unused struct cmdline *cl,
12041 __rte_unused void *data)
12043 struct cmd_vf_allmulti_result *res = parsed_result;
12044 int ret = -ENOTSUP;
12046 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12048 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12051 #ifdef RTE_NET_I40E
12052 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12053 res->vf_id, is_on);
12060 printf("invalid vf_id %d\n", res->vf_id);
12063 printf("invalid port_id %d\n", res->port_id);
12066 printf("function not implemented\n");
12069 printf("programming error: (%s)\n", strerror(-ret));
12073 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12074 .f = cmd_set_vf_allmulti_parsed,
12076 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12077 "Set multicast promiscuous mode for a VF from the PF",
12079 (void *)&cmd_vf_allmulti_set,
12080 (void *)&cmd_vf_allmulti_vf,
12081 (void *)&cmd_vf_allmulti_allmulti,
12082 (void *)&cmd_vf_allmulti_port_id,
12083 (void *)&cmd_vf_allmulti_vf_id,
12084 (void *)&cmd_vf_allmulti_on_off,
12089 /* vf broadcast mode configuration */
12091 /* Common result structure for vf broadcast */
12092 struct cmd_set_vf_broadcast_result {
12093 cmdline_fixed_string_t set;
12094 cmdline_fixed_string_t vf;
12095 cmdline_fixed_string_t broadcast;
12098 cmdline_fixed_string_t on_off;
12101 /* Common CLI fields for vf broadcast enable disable */
12102 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12103 TOKEN_STRING_INITIALIZER
12104 (struct cmd_set_vf_broadcast_result,
12106 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12107 TOKEN_STRING_INITIALIZER
12108 (struct cmd_set_vf_broadcast_result,
12110 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12111 TOKEN_STRING_INITIALIZER
12112 (struct cmd_set_vf_broadcast_result,
12113 broadcast, "broadcast");
12114 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12115 TOKEN_NUM_INITIALIZER
12116 (struct cmd_set_vf_broadcast_result,
12117 port_id, RTE_UINT16);
12118 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12119 TOKEN_NUM_INITIALIZER
12120 (struct cmd_set_vf_broadcast_result,
12121 vf_id, RTE_UINT16);
12122 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12123 TOKEN_STRING_INITIALIZER
12124 (struct cmd_set_vf_broadcast_result,
12128 cmd_set_vf_broadcast_parsed(
12129 void *parsed_result,
12130 __rte_unused struct cmdline *cl,
12131 __rte_unused void *data)
12133 struct cmd_set_vf_broadcast_result *res = parsed_result;
12134 int ret = -ENOTSUP;
12136 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12138 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12141 #ifdef RTE_NET_I40E
12142 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12143 res->vf_id, is_on);
12150 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12153 printf("invalid port_id %d\n", res->port_id);
12156 printf("function not implemented\n");
12159 printf("programming error: (%s)\n", strerror(-ret));
12163 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12164 .f = cmd_set_vf_broadcast_parsed,
12166 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12168 (void *)&cmd_set_vf_broadcast_set,
12169 (void *)&cmd_set_vf_broadcast_vf,
12170 (void *)&cmd_set_vf_broadcast_broadcast,
12171 (void *)&cmd_set_vf_broadcast_port_id,
12172 (void *)&cmd_set_vf_broadcast_vf_id,
12173 (void *)&cmd_set_vf_broadcast_on_off,
12178 /* vf vlan tag configuration */
12180 /* Common result structure for vf vlan tag */
12181 struct cmd_set_vf_vlan_tag_result {
12182 cmdline_fixed_string_t set;
12183 cmdline_fixed_string_t vf;
12184 cmdline_fixed_string_t vlan;
12185 cmdline_fixed_string_t tag;
12188 cmdline_fixed_string_t on_off;
12191 /* Common CLI fields for vf vlan tag enable disable */
12192 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12193 TOKEN_STRING_INITIALIZER
12194 (struct cmd_set_vf_vlan_tag_result,
12196 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12197 TOKEN_STRING_INITIALIZER
12198 (struct cmd_set_vf_vlan_tag_result,
12200 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12201 TOKEN_STRING_INITIALIZER
12202 (struct cmd_set_vf_vlan_tag_result,
12204 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12205 TOKEN_STRING_INITIALIZER
12206 (struct cmd_set_vf_vlan_tag_result,
12208 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12209 TOKEN_NUM_INITIALIZER
12210 (struct cmd_set_vf_vlan_tag_result,
12211 port_id, RTE_UINT16);
12212 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12213 TOKEN_NUM_INITIALIZER
12214 (struct cmd_set_vf_vlan_tag_result,
12215 vf_id, RTE_UINT16);
12216 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12217 TOKEN_STRING_INITIALIZER
12218 (struct cmd_set_vf_vlan_tag_result,
12222 cmd_set_vf_vlan_tag_parsed(
12223 void *parsed_result,
12224 __rte_unused struct cmdline *cl,
12225 __rte_unused void *data)
12227 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12228 int ret = -ENOTSUP;
12230 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12232 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12235 #ifdef RTE_NET_I40E
12236 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12237 res->vf_id, is_on);
12244 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12247 printf("invalid port_id %d\n", res->port_id);
12250 printf("function not implemented\n");
12253 printf("programming error: (%s)\n", strerror(-ret));
12257 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12258 .f = cmd_set_vf_vlan_tag_parsed,
12260 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12262 (void *)&cmd_set_vf_vlan_tag_set,
12263 (void *)&cmd_set_vf_vlan_tag_vf,
12264 (void *)&cmd_set_vf_vlan_tag_vlan,
12265 (void *)&cmd_set_vf_vlan_tag_tag,
12266 (void *)&cmd_set_vf_vlan_tag_port_id,
12267 (void *)&cmd_set_vf_vlan_tag_vf_id,
12268 (void *)&cmd_set_vf_vlan_tag_on_off,
12273 /* Common definition of VF and TC TX bandwidth configuration */
12274 struct cmd_vf_tc_bw_result {
12275 cmdline_fixed_string_t set;
12276 cmdline_fixed_string_t vf;
12277 cmdline_fixed_string_t tc;
12278 cmdline_fixed_string_t tx;
12279 cmdline_fixed_string_t min_bw;
12280 cmdline_fixed_string_t max_bw;
12281 cmdline_fixed_string_t strict_link_prio;
12286 cmdline_fixed_string_t bw_list;
12290 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12291 TOKEN_STRING_INITIALIZER
12292 (struct cmd_vf_tc_bw_result,
12294 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12295 TOKEN_STRING_INITIALIZER
12296 (struct cmd_vf_tc_bw_result,
12298 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12299 TOKEN_STRING_INITIALIZER
12300 (struct cmd_vf_tc_bw_result,
12302 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12303 TOKEN_STRING_INITIALIZER
12304 (struct cmd_vf_tc_bw_result,
12306 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12307 TOKEN_STRING_INITIALIZER
12308 (struct cmd_vf_tc_bw_result,
12309 strict_link_prio, "strict-link-priority");
12310 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12311 TOKEN_STRING_INITIALIZER
12312 (struct cmd_vf_tc_bw_result,
12313 min_bw, "min-bandwidth");
12314 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12315 TOKEN_STRING_INITIALIZER
12316 (struct cmd_vf_tc_bw_result,
12317 max_bw, "max-bandwidth");
12318 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12319 TOKEN_NUM_INITIALIZER
12320 (struct cmd_vf_tc_bw_result,
12321 port_id, RTE_UINT16);
12322 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12323 TOKEN_NUM_INITIALIZER
12324 (struct cmd_vf_tc_bw_result,
12325 vf_id, RTE_UINT16);
12326 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12327 TOKEN_NUM_INITIALIZER
12328 (struct cmd_vf_tc_bw_result,
12330 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12331 TOKEN_NUM_INITIALIZER
12332 (struct cmd_vf_tc_bw_result,
12334 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12335 TOKEN_STRING_INITIALIZER
12336 (struct cmd_vf_tc_bw_result,
12338 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12339 TOKEN_NUM_INITIALIZER
12340 (struct cmd_vf_tc_bw_result,
12341 tc_map, RTE_UINT8);
12343 /* VF max bandwidth setting */
12345 cmd_vf_max_bw_parsed(
12346 void *parsed_result,
12347 __rte_unused struct cmdline *cl,
12348 __rte_unused void *data)
12350 struct cmd_vf_tc_bw_result *res = parsed_result;
12351 int ret = -ENOTSUP;
12353 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12356 #ifdef RTE_NET_I40E
12357 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12358 res->vf_id, res->bw);
12365 printf("invalid vf_id %d or bandwidth %d\n",
12366 res->vf_id, res->bw);
12369 printf("invalid port_id %d\n", res->port_id);
12372 printf("function not implemented\n");
12375 printf("programming error: (%s)\n", strerror(-ret));
12379 cmdline_parse_inst_t cmd_vf_max_bw = {
12380 .f = cmd_vf_max_bw_parsed,
12382 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12384 (void *)&cmd_vf_tc_bw_set,
12385 (void *)&cmd_vf_tc_bw_vf,
12386 (void *)&cmd_vf_tc_bw_tx,
12387 (void *)&cmd_vf_tc_bw_max_bw,
12388 (void *)&cmd_vf_tc_bw_port_id,
12389 (void *)&cmd_vf_tc_bw_vf_id,
12390 (void *)&cmd_vf_tc_bw_bw,
12396 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12401 const char *p, *p0 = str;
12408 p = strchr(p0, '(');
12410 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12414 p0 = strchr(p, ')');
12416 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12420 if (size >= sizeof(s)) {
12421 printf("The string size exceeds the internal buffer size\n");
12424 snprintf(s, sizeof(s), "%.*s", size, p);
12425 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12427 printf("Failed to get the bandwidth list. ");
12431 for (i = 0; i < ret; i++)
12432 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12437 /* TC min bandwidth setting */
12439 cmd_vf_tc_min_bw_parsed(
12440 void *parsed_result,
12441 __rte_unused struct cmdline *cl,
12442 __rte_unused void *data)
12444 struct cmd_vf_tc_bw_result *res = parsed_result;
12447 int ret = -ENOTSUP;
12449 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12452 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12456 #ifdef RTE_NET_I40E
12457 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12465 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12468 printf("invalid port_id %d\n", res->port_id);
12471 printf("function not implemented\n");
12474 printf("programming error: (%s)\n", strerror(-ret));
12478 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12479 .f = cmd_vf_tc_min_bw_parsed,
12481 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12482 " <bw1, bw2, ...>",
12484 (void *)&cmd_vf_tc_bw_set,
12485 (void *)&cmd_vf_tc_bw_vf,
12486 (void *)&cmd_vf_tc_bw_tc,
12487 (void *)&cmd_vf_tc_bw_tx,
12488 (void *)&cmd_vf_tc_bw_min_bw,
12489 (void *)&cmd_vf_tc_bw_port_id,
12490 (void *)&cmd_vf_tc_bw_vf_id,
12491 (void *)&cmd_vf_tc_bw_bw_list,
12497 cmd_tc_min_bw_parsed(
12498 void *parsed_result,
12499 __rte_unused struct cmdline *cl,
12500 __rte_unused void *data)
12502 struct cmd_vf_tc_bw_result *res = parsed_result;
12503 struct rte_port *port;
12506 int ret = -ENOTSUP;
12508 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12511 port = &ports[res->port_id];
12512 /** Check if the port is not started **/
12513 if (port->port_status != RTE_PORT_STOPPED) {
12514 printf("Please stop port %d first\n", res->port_id);
12518 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12522 #ifdef RTE_NET_IXGBE
12523 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12530 printf("invalid bandwidth\n");
12533 printf("invalid port_id %d\n", res->port_id);
12536 printf("function not implemented\n");
12539 printf("programming error: (%s)\n", strerror(-ret));
12543 cmdline_parse_inst_t cmd_tc_min_bw = {
12544 .f = cmd_tc_min_bw_parsed,
12546 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12548 (void *)&cmd_vf_tc_bw_set,
12549 (void *)&cmd_vf_tc_bw_tc,
12550 (void *)&cmd_vf_tc_bw_tx,
12551 (void *)&cmd_vf_tc_bw_min_bw,
12552 (void *)&cmd_vf_tc_bw_port_id,
12553 (void *)&cmd_vf_tc_bw_bw_list,
12558 /* TC max bandwidth setting */
12560 cmd_vf_tc_max_bw_parsed(
12561 void *parsed_result,
12562 __rte_unused struct cmdline *cl,
12563 __rte_unused void *data)
12565 struct cmd_vf_tc_bw_result *res = parsed_result;
12566 int ret = -ENOTSUP;
12568 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12571 #ifdef RTE_NET_I40E
12572 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12573 res->tc_no, res->bw);
12580 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
12581 res->vf_id, res->tc_no, res->bw);
12584 printf("invalid port_id %d\n", res->port_id);
12587 printf("function not implemented\n");
12590 printf("programming error: (%s)\n", strerror(-ret));
12594 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12595 .f = cmd_vf_tc_max_bw_parsed,
12597 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12600 (void *)&cmd_vf_tc_bw_set,
12601 (void *)&cmd_vf_tc_bw_vf,
12602 (void *)&cmd_vf_tc_bw_tc,
12603 (void *)&cmd_vf_tc_bw_tx,
12604 (void *)&cmd_vf_tc_bw_max_bw,
12605 (void *)&cmd_vf_tc_bw_port_id,
12606 (void *)&cmd_vf_tc_bw_vf_id,
12607 (void *)&cmd_vf_tc_bw_tc_no,
12608 (void *)&cmd_vf_tc_bw_bw,
12613 /** Set VXLAN encapsulation details */
12614 struct cmd_set_vxlan_result {
12615 cmdline_fixed_string_t set;
12616 cmdline_fixed_string_t vxlan;
12617 cmdline_fixed_string_t pos_token;
12618 cmdline_fixed_string_t ip_version;
12619 uint32_t vlan_present:1;
12623 cmdline_ipaddr_t ip_src;
12624 cmdline_ipaddr_t ip_dst;
12628 struct rte_ether_addr eth_src;
12629 struct rte_ether_addr eth_dst;
12632 cmdline_parse_token_string_t cmd_set_vxlan_set =
12633 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
12634 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
12635 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
12636 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
12637 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12639 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
12640 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12641 "vxlan-with-vlan");
12642 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
12643 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12645 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
12646 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
12648 cmdline_parse_token_string_t cmd_set_vxlan_vni =
12649 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12651 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
12652 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
12653 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
12654 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12656 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
12657 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
12658 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
12659 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12661 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
12662 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
12663 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
12664 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12666 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
12667 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
12668 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
12669 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12671 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
12672 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
12673 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
12674 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12676 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
12677 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
12678 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
12679 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12681 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
12682 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
12683 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
12684 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12686 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
12687 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
12688 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
12689 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12691 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
12692 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
12693 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
12694 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12696 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
12697 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
12699 static void cmd_set_vxlan_parsed(void *parsed_result,
12700 __rte_unused struct cmdline *cl,
12701 __rte_unused void *data)
12703 struct cmd_set_vxlan_result *res = parsed_result;
12708 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
12711 vxlan_encap_conf.select_tos_ttl = 0;
12712 if (strcmp(res->vxlan, "vxlan") == 0)
12713 vxlan_encap_conf.select_vlan = 0;
12714 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
12715 vxlan_encap_conf.select_vlan = 1;
12716 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
12717 vxlan_encap_conf.select_vlan = 0;
12718 vxlan_encap_conf.select_tos_ttl = 1;
12720 if (strcmp(res->ip_version, "ipv4") == 0)
12721 vxlan_encap_conf.select_ipv4 = 1;
12722 else if (strcmp(res->ip_version, "ipv6") == 0)
12723 vxlan_encap_conf.select_ipv4 = 0;
12726 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
12727 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
12728 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
12729 vxlan_encap_conf.ip_tos = res->tos;
12730 vxlan_encap_conf.ip_ttl = res->ttl;
12731 if (vxlan_encap_conf.select_ipv4) {
12732 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
12733 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
12735 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
12736 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
12738 if (vxlan_encap_conf.select_vlan)
12739 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
12740 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
12741 RTE_ETHER_ADDR_LEN);
12742 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
12743 RTE_ETHER_ADDR_LEN);
12746 cmdline_parse_inst_t cmd_set_vxlan = {
12747 .f = cmd_set_vxlan_parsed,
12749 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
12750 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
12751 " eth-src <eth-src> eth-dst <eth-dst>",
12753 (void *)&cmd_set_vxlan_set,
12754 (void *)&cmd_set_vxlan_vxlan,
12755 (void *)&cmd_set_vxlan_ip_version,
12756 (void *)&cmd_set_vxlan_ip_version_value,
12757 (void *)&cmd_set_vxlan_vni,
12758 (void *)&cmd_set_vxlan_vni_value,
12759 (void *)&cmd_set_vxlan_udp_src,
12760 (void *)&cmd_set_vxlan_udp_src_value,
12761 (void *)&cmd_set_vxlan_udp_dst,
12762 (void *)&cmd_set_vxlan_udp_dst_value,
12763 (void *)&cmd_set_vxlan_ip_src,
12764 (void *)&cmd_set_vxlan_ip_src_value,
12765 (void *)&cmd_set_vxlan_ip_dst,
12766 (void *)&cmd_set_vxlan_ip_dst_value,
12767 (void *)&cmd_set_vxlan_eth_src,
12768 (void *)&cmd_set_vxlan_eth_src_value,
12769 (void *)&cmd_set_vxlan_eth_dst,
12770 (void *)&cmd_set_vxlan_eth_dst_value,
12775 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
12776 .f = cmd_set_vxlan_parsed,
12778 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
12779 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
12780 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
12781 " eth-dst <eth-dst>",
12783 (void *)&cmd_set_vxlan_set,
12784 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
12785 (void *)&cmd_set_vxlan_ip_version,
12786 (void *)&cmd_set_vxlan_ip_version_value,
12787 (void *)&cmd_set_vxlan_vni,
12788 (void *)&cmd_set_vxlan_vni_value,
12789 (void *)&cmd_set_vxlan_udp_src,
12790 (void *)&cmd_set_vxlan_udp_src_value,
12791 (void *)&cmd_set_vxlan_udp_dst,
12792 (void *)&cmd_set_vxlan_udp_dst_value,
12793 (void *)&cmd_set_vxlan_ip_tos,
12794 (void *)&cmd_set_vxlan_ip_tos_value,
12795 (void *)&cmd_set_vxlan_ip_ttl,
12796 (void *)&cmd_set_vxlan_ip_ttl_value,
12797 (void *)&cmd_set_vxlan_ip_src,
12798 (void *)&cmd_set_vxlan_ip_src_value,
12799 (void *)&cmd_set_vxlan_ip_dst,
12800 (void *)&cmd_set_vxlan_ip_dst_value,
12801 (void *)&cmd_set_vxlan_eth_src,
12802 (void *)&cmd_set_vxlan_eth_src_value,
12803 (void *)&cmd_set_vxlan_eth_dst,
12804 (void *)&cmd_set_vxlan_eth_dst_value,
12809 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
12810 .f = cmd_set_vxlan_parsed,
12812 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
12813 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
12814 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
12817 (void *)&cmd_set_vxlan_set,
12818 (void *)&cmd_set_vxlan_vxlan_with_vlan,
12819 (void *)&cmd_set_vxlan_ip_version,
12820 (void *)&cmd_set_vxlan_ip_version_value,
12821 (void *)&cmd_set_vxlan_vni,
12822 (void *)&cmd_set_vxlan_vni_value,
12823 (void *)&cmd_set_vxlan_udp_src,
12824 (void *)&cmd_set_vxlan_udp_src_value,
12825 (void *)&cmd_set_vxlan_udp_dst,
12826 (void *)&cmd_set_vxlan_udp_dst_value,
12827 (void *)&cmd_set_vxlan_ip_src,
12828 (void *)&cmd_set_vxlan_ip_src_value,
12829 (void *)&cmd_set_vxlan_ip_dst,
12830 (void *)&cmd_set_vxlan_ip_dst_value,
12831 (void *)&cmd_set_vxlan_vlan,
12832 (void *)&cmd_set_vxlan_vlan_value,
12833 (void *)&cmd_set_vxlan_eth_src,
12834 (void *)&cmd_set_vxlan_eth_src_value,
12835 (void *)&cmd_set_vxlan_eth_dst,
12836 (void *)&cmd_set_vxlan_eth_dst_value,
12841 /** Set NVGRE encapsulation details */
12842 struct cmd_set_nvgre_result {
12843 cmdline_fixed_string_t set;
12844 cmdline_fixed_string_t nvgre;
12845 cmdline_fixed_string_t pos_token;
12846 cmdline_fixed_string_t ip_version;
12848 cmdline_ipaddr_t ip_src;
12849 cmdline_ipaddr_t ip_dst;
12851 struct rte_ether_addr eth_src;
12852 struct rte_ether_addr eth_dst;
12855 cmdline_parse_token_string_t cmd_set_nvgre_set =
12856 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
12857 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
12858 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
12859 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
12860 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
12861 "nvgre-with-vlan");
12862 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
12863 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12865 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
12866 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
12868 cmdline_parse_token_string_t cmd_set_nvgre_tni =
12869 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12871 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
12872 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
12873 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
12874 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12876 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
12877 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
12878 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
12879 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12881 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
12882 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
12883 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
12884 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12886 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
12887 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
12888 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
12889 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12891 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
12892 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
12893 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
12894 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12896 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
12897 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
12899 static void cmd_set_nvgre_parsed(void *parsed_result,
12900 __rte_unused struct cmdline *cl,
12901 __rte_unused void *data)
12903 struct cmd_set_nvgre_result *res = parsed_result;
12905 uint32_t nvgre_tni;
12908 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
12911 if (strcmp(res->nvgre, "nvgre") == 0)
12912 nvgre_encap_conf.select_vlan = 0;
12913 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
12914 nvgre_encap_conf.select_vlan = 1;
12915 if (strcmp(res->ip_version, "ipv4") == 0)
12916 nvgre_encap_conf.select_ipv4 = 1;
12917 else if (strcmp(res->ip_version, "ipv6") == 0)
12918 nvgre_encap_conf.select_ipv4 = 0;
12921 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
12922 if (nvgre_encap_conf.select_ipv4) {
12923 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
12924 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
12926 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
12927 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
12929 if (nvgre_encap_conf.select_vlan)
12930 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
12931 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
12932 RTE_ETHER_ADDR_LEN);
12933 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
12934 RTE_ETHER_ADDR_LEN);
12937 cmdline_parse_inst_t cmd_set_nvgre = {
12938 .f = cmd_set_nvgre_parsed,
12940 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
12941 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
12942 " eth-dst <eth-dst>",
12944 (void *)&cmd_set_nvgre_set,
12945 (void *)&cmd_set_nvgre_nvgre,
12946 (void *)&cmd_set_nvgre_ip_version,
12947 (void *)&cmd_set_nvgre_ip_version_value,
12948 (void *)&cmd_set_nvgre_tni,
12949 (void *)&cmd_set_nvgre_tni_value,
12950 (void *)&cmd_set_nvgre_ip_src,
12951 (void *)&cmd_set_nvgre_ip_src_value,
12952 (void *)&cmd_set_nvgre_ip_dst,
12953 (void *)&cmd_set_nvgre_ip_dst_value,
12954 (void *)&cmd_set_nvgre_eth_src,
12955 (void *)&cmd_set_nvgre_eth_src_value,
12956 (void *)&cmd_set_nvgre_eth_dst,
12957 (void *)&cmd_set_nvgre_eth_dst_value,
12962 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
12963 .f = cmd_set_nvgre_parsed,
12965 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
12966 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
12967 " eth-src <eth-src> eth-dst <eth-dst>",
12969 (void *)&cmd_set_nvgre_set,
12970 (void *)&cmd_set_nvgre_nvgre_with_vlan,
12971 (void *)&cmd_set_nvgre_ip_version,
12972 (void *)&cmd_set_nvgre_ip_version_value,
12973 (void *)&cmd_set_nvgre_tni,
12974 (void *)&cmd_set_nvgre_tni_value,
12975 (void *)&cmd_set_nvgre_ip_src,
12976 (void *)&cmd_set_nvgre_ip_src_value,
12977 (void *)&cmd_set_nvgre_ip_dst,
12978 (void *)&cmd_set_nvgre_ip_dst_value,
12979 (void *)&cmd_set_nvgre_vlan,
12980 (void *)&cmd_set_nvgre_vlan_value,
12981 (void *)&cmd_set_nvgre_eth_src,
12982 (void *)&cmd_set_nvgre_eth_src_value,
12983 (void *)&cmd_set_nvgre_eth_dst,
12984 (void *)&cmd_set_nvgre_eth_dst_value,
12989 /** Set L2 encapsulation details */
12990 struct cmd_set_l2_encap_result {
12991 cmdline_fixed_string_t set;
12992 cmdline_fixed_string_t l2_encap;
12993 cmdline_fixed_string_t pos_token;
12994 cmdline_fixed_string_t ip_version;
12995 uint32_t vlan_present:1;
12997 struct rte_ether_addr eth_src;
12998 struct rte_ether_addr eth_dst;
13001 cmdline_parse_token_string_t cmd_set_l2_encap_set =
13002 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13003 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13004 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13005 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13006 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13007 "l2_encap-with-vlan");
13008 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13009 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13011 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13012 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13014 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13015 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13017 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13018 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13019 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13020 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13022 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13023 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13024 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13025 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13027 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13028 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13030 static void cmd_set_l2_encap_parsed(void *parsed_result,
13031 __rte_unused struct cmdline *cl,
13032 __rte_unused void *data)
13034 struct cmd_set_l2_encap_result *res = parsed_result;
13036 if (strcmp(res->l2_encap, "l2_encap") == 0)
13037 l2_encap_conf.select_vlan = 0;
13038 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13039 l2_encap_conf.select_vlan = 1;
13040 if (strcmp(res->ip_version, "ipv4") == 0)
13041 l2_encap_conf.select_ipv4 = 1;
13042 else if (strcmp(res->ip_version, "ipv6") == 0)
13043 l2_encap_conf.select_ipv4 = 0;
13046 if (l2_encap_conf.select_vlan)
13047 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13048 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13049 RTE_ETHER_ADDR_LEN);
13050 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13051 RTE_ETHER_ADDR_LEN);
13054 cmdline_parse_inst_t cmd_set_l2_encap = {
13055 .f = cmd_set_l2_encap_parsed,
13057 .help_str = "set l2_encap ip-version ipv4|ipv6"
13058 " eth-src <eth-src> eth-dst <eth-dst>",
13060 (void *)&cmd_set_l2_encap_set,
13061 (void *)&cmd_set_l2_encap_l2_encap,
13062 (void *)&cmd_set_l2_encap_ip_version,
13063 (void *)&cmd_set_l2_encap_ip_version_value,
13064 (void *)&cmd_set_l2_encap_eth_src,
13065 (void *)&cmd_set_l2_encap_eth_src_value,
13066 (void *)&cmd_set_l2_encap_eth_dst,
13067 (void *)&cmd_set_l2_encap_eth_dst_value,
13072 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13073 .f = cmd_set_l2_encap_parsed,
13075 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13076 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13078 (void *)&cmd_set_l2_encap_set,
13079 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13080 (void *)&cmd_set_l2_encap_ip_version,
13081 (void *)&cmd_set_l2_encap_ip_version_value,
13082 (void *)&cmd_set_l2_encap_vlan,
13083 (void *)&cmd_set_l2_encap_vlan_value,
13084 (void *)&cmd_set_l2_encap_eth_src,
13085 (void *)&cmd_set_l2_encap_eth_src_value,
13086 (void *)&cmd_set_l2_encap_eth_dst,
13087 (void *)&cmd_set_l2_encap_eth_dst_value,
13092 /** Set L2 decapsulation details */
13093 struct cmd_set_l2_decap_result {
13094 cmdline_fixed_string_t set;
13095 cmdline_fixed_string_t l2_decap;
13096 cmdline_fixed_string_t pos_token;
13097 uint32_t vlan_present:1;
13100 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13101 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13102 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13103 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13105 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13106 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13107 "l2_decap-with-vlan");
13109 static void cmd_set_l2_decap_parsed(void *parsed_result,
13110 __rte_unused struct cmdline *cl,
13111 __rte_unused void *data)
13113 struct cmd_set_l2_decap_result *res = parsed_result;
13115 if (strcmp(res->l2_decap, "l2_decap") == 0)
13116 l2_decap_conf.select_vlan = 0;
13117 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13118 l2_decap_conf.select_vlan = 1;
13121 cmdline_parse_inst_t cmd_set_l2_decap = {
13122 .f = cmd_set_l2_decap_parsed,
13124 .help_str = "set l2_decap",
13126 (void *)&cmd_set_l2_decap_set,
13127 (void *)&cmd_set_l2_decap_l2_decap,
13132 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13133 .f = cmd_set_l2_decap_parsed,
13135 .help_str = "set l2_decap-with-vlan",
13137 (void *)&cmd_set_l2_decap_set,
13138 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13143 /** Set MPLSoGRE encapsulation details */
13144 struct cmd_set_mplsogre_encap_result {
13145 cmdline_fixed_string_t set;
13146 cmdline_fixed_string_t mplsogre;
13147 cmdline_fixed_string_t pos_token;
13148 cmdline_fixed_string_t ip_version;
13149 uint32_t vlan_present:1;
13151 cmdline_ipaddr_t ip_src;
13152 cmdline_ipaddr_t ip_dst;
13154 struct rte_ether_addr eth_src;
13155 struct rte_ether_addr eth_dst;
13158 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13159 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13161 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13162 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13164 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13165 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13166 mplsogre, "mplsogre_encap-with-vlan");
13167 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13168 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13169 pos_token, "ip-version");
13170 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13171 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13172 ip_version, "ipv4#ipv6");
13173 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13174 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13175 pos_token, "label");
13176 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13177 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13179 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13180 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13181 pos_token, "ip-src");
13182 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13183 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13184 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13185 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13186 pos_token, "ip-dst");
13187 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13188 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13189 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13190 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13191 pos_token, "vlan-tci");
13192 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13193 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13195 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13196 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13197 pos_token, "eth-src");
13198 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13199 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13201 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13202 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13203 pos_token, "eth-dst");
13204 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13205 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13208 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13209 __rte_unused struct cmdline *cl,
13210 __rte_unused void *data)
13212 struct cmd_set_mplsogre_encap_result *res = parsed_result;
13214 uint32_t mplsogre_label;
13217 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13220 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13221 mplsogre_encap_conf.select_vlan = 0;
13222 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13223 mplsogre_encap_conf.select_vlan = 1;
13224 if (strcmp(res->ip_version, "ipv4") == 0)
13225 mplsogre_encap_conf.select_ipv4 = 1;
13226 else if (strcmp(res->ip_version, "ipv6") == 0)
13227 mplsogre_encap_conf.select_ipv4 = 0;
13230 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13231 if (mplsogre_encap_conf.select_ipv4) {
13232 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13233 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13235 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13236 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13238 if (mplsogre_encap_conf.select_vlan)
13239 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13240 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13241 RTE_ETHER_ADDR_LEN);
13242 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13243 RTE_ETHER_ADDR_LEN);
13246 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13247 .f = cmd_set_mplsogre_encap_parsed,
13249 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13250 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13251 " eth-dst <eth-dst>",
13253 (void *)&cmd_set_mplsogre_encap_set,
13254 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13255 (void *)&cmd_set_mplsogre_encap_ip_version,
13256 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13257 (void *)&cmd_set_mplsogre_encap_label,
13258 (void *)&cmd_set_mplsogre_encap_label_value,
13259 (void *)&cmd_set_mplsogre_encap_ip_src,
13260 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13261 (void *)&cmd_set_mplsogre_encap_ip_dst,
13262 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13263 (void *)&cmd_set_mplsogre_encap_eth_src,
13264 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13265 (void *)&cmd_set_mplsogre_encap_eth_dst,
13266 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13271 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13272 .f = cmd_set_mplsogre_encap_parsed,
13274 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13275 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
13276 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13278 (void *)&cmd_set_mplsogre_encap_set,
13279 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13280 (void *)&cmd_set_mplsogre_encap_ip_version,
13281 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13282 (void *)&cmd_set_mplsogre_encap_label,
13283 (void *)&cmd_set_mplsogre_encap_label_value,
13284 (void *)&cmd_set_mplsogre_encap_ip_src,
13285 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13286 (void *)&cmd_set_mplsogre_encap_ip_dst,
13287 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13288 (void *)&cmd_set_mplsogre_encap_vlan,
13289 (void *)&cmd_set_mplsogre_encap_vlan_value,
13290 (void *)&cmd_set_mplsogre_encap_eth_src,
13291 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13292 (void *)&cmd_set_mplsogre_encap_eth_dst,
13293 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13298 /** Set MPLSoGRE decapsulation details */
13299 struct cmd_set_mplsogre_decap_result {
13300 cmdline_fixed_string_t set;
13301 cmdline_fixed_string_t mplsogre;
13302 cmdline_fixed_string_t pos_token;
13303 cmdline_fixed_string_t ip_version;
13304 uint32_t vlan_present:1;
13307 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13308 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13310 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13311 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13313 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13314 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13315 mplsogre, "mplsogre_decap-with-vlan");
13316 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13317 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13318 pos_token, "ip-version");
13319 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13320 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13321 ip_version, "ipv4#ipv6");
13323 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13324 __rte_unused struct cmdline *cl,
13325 __rte_unused void *data)
13327 struct cmd_set_mplsogre_decap_result *res = parsed_result;
13329 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13330 mplsogre_decap_conf.select_vlan = 0;
13331 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13332 mplsogre_decap_conf.select_vlan = 1;
13333 if (strcmp(res->ip_version, "ipv4") == 0)
13334 mplsogre_decap_conf.select_ipv4 = 1;
13335 else if (strcmp(res->ip_version, "ipv6") == 0)
13336 mplsogre_decap_conf.select_ipv4 = 0;
13339 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13340 .f = cmd_set_mplsogre_decap_parsed,
13342 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13344 (void *)&cmd_set_mplsogre_decap_set,
13345 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13346 (void *)&cmd_set_mplsogre_decap_ip_version,
13347 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13352 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13353 .f = cmd_set_mplsogre_decap_parsed,
13355 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13357 (void *)&cmd_set_mplsogre_decap_set,
13358 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13359 (void *)&cmd_set_mplsogre_decap_ip_version,
13360 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13365 /** Set MPLSoUDP encapsulation details */
13366 struct cmd_set_mplsoudp_encap_result {
13367 cmdline_fixed_string_t set;
13368 cmdline_fixed_string_t mplsoudp;
13369 cmdline_fixed_string_t pos_token;
13370 cmdline_fixed_string_t ip_version;
13371 uint32_t vlan_present:1;
13375 cmdline_ipaddr_t ip_src;
13376 cmdline_ipaddr_t ip_dst;
13378 struct rte_ether_addr eth_src;
13379 struct rte_ether_addr eth_dst;
13382 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13383 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13385 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13386 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13388 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13389 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13390 mplsoudp, "mplsoudp_encap-with-vlan");
13391 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13392 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13393 pos_token, "ip-version");
13394 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13395 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13396 ip_version, "ipv4#ipv6");
13397 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13398 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13399 pos_token, "label");
13400 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13401 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13403 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13404 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13405 pos_token, "udp-src");
13406 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13407 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13409 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13410 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13411 pos_token, "udp-dst");
13412 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13413 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13415 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13416 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13417 pos_token, "ip-src");
13418 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13419 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13420 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13421 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13422 pos_token, "ip-dst");
13423 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13424 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13425 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13426 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13427 pos_token, "vlan-tci");
13428 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13429 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13431 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13432 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13433 pos_token, "eth-src");
13434 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13435 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13437 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13438 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13439 pos_token, "eth-dst");
13440 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13441 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13444 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13445 __rte_unused struct cmdline *cl,
13446 __rte_unused void *data)
13448 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13450 uint32_t mplsoudp_label;
13453 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13456 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13457 mplsoudp_encap_conf.select_vlan = 0;
13458 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13459 mplsoudp_encap_conf.select_vlan = 1;
13460 if (strcmp(res->ip_version, "ipv4") == 0)
13461 mplsoudp_encap_conf.select_ipv4 = 1;
13462 else if (strcmp(res->ip_version, "ipv6") == 0)
13463 mplsoudp_encap_conf.select_ipv4 = 0;
13466 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13467 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13468 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13469 if (mplsoudp_encap_conf.select_ipv4) {
13470 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13471 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13473 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13474 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13476 if (mplsoudp_encap_conf.select_vlan)
13477 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13478 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13479 RTE_ETHER_ADDR_LEN);
13480 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13481 RTE_ETHER_ADDR_LEN);
13484 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13485 .f = cmd_set_mplsoudp_encap_parsed,
13487 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13488 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13489 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13491 (void *)&cmd_set_mplsoudp_encap_set,
13492 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13493 (void *)&cmd_set_mplsoudp_encap_ip_version,
13494 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13495 (void *)&cmd_set_mplsoudp_encap_label,
13496 (void *)&cmd_set_mplsoudp_encap_label_value,
13497 (void *)&cmd_set_mplsoudp_encap_udp_src,
13498 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13499 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13500 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13501 (void *)&cmd_set_mplsoudp_encap_ip_src,
13502 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13503 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13504 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13505 (void *)&cmd_set_mplsoudp_encap_eth_src,
13506 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13507 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13508 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13513 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13514 .f = cmd_set_mplsoudp_encap_parsed,
13516 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13517 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
13518 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13519 " eth-src <eth-src> eth-dst <eth-dst>",
13521 (void *)&cmd_set_mplsoudp_encap_set,
13522 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13523 (void *)&cmd_set_mplsoudp_encap_ip_version,
13524 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13525 (void *)&cmd_set_mplsoudp_encap_label,
13526 (void *)&cmd_set_mplsoudp_encap_label_value,
13527 (void *)&cmd_set_mplsoudp_encap_udp_src,
13528 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13529 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13530 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13531 (void *)&cmd_set_mplsoudp_encap_ip_src,
13532 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13533 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13534 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13535 (void *)&cmd_set_mplsoudp_encap_vlan,
13536 (void *)&cmd_set_mplsoudp_encap_vlan_value,
13537 (void *)&cmd_set_mplsoudp_encap_eth_src,
13538 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13539 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13540 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13545 /** Set MPLSoUDP decapsulation details */
13546 struct cmd_set_mplsoudp_decap_result {
13547 cmdline_fixed_string_t set;
13548 cmdline_fixed_string_t mplsoudp;
13549 cmdline_fixed_string_t pos_token;
13550 cmdline_fixed_string_t ip_version;
13551 uint32_t vlan_present:1;
13554 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
13555 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
13557 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
13558 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
13560 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
13561 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13562 mplsoudp, "mplsoudp_decap-with-vlan");
13563 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
13564 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13565 pos_token, "ip-version");
13566 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
13567 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13568 ip_version, "ipv4#ipv6");
13570 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
13571 __rte_unused struct cmdline *cl,
13572 __rte_unused void *data)
13574 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
13576 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
13577 mplsoudp_decap_conf.select_vlan = 0;
13578 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
13579 mplsoudp_decap_conf.select_vlan = 1;
13580 if (strcmp(res->ip_version, "ipv4") == 0)
13581 mplsoudp_decap_conf.select_ipv4 = 1;
13582 else if (strcmp(res->ip_version, "ipv6") == 0)
13583 mplsoudp_decap_conf.select_ipv4 = 0;
13586 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
13587 .f = cmd_set_mplsoudp_decap_parsed,
13589 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
13591 (void *)&cmd_set_mplsoudp_decap_set,
13592 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
13593 (void *)&cmd_set_mplsoudp_decap_ip_version,
13594 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13599 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
13600 .f = cmd_set_mplsoudp_decap_parsed,
13602 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
13604 (void *)&cmd_set_mplsoudp_decap_set,
13605 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
13606 (void *)&cmd_set_mplsoudp_decap_ip_version,
13607 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13612 /* Strict link priority scheduling mode setting */
13614 cmd_strict_link_prio_parsed(
13615 void *parsed_result,
13616 __rte_unused struct cmdline *cl,
13617 __rte_unused void *data)
13619 struct cmd_vf_tc_bw_result *res = parsed_result;
13620 int ret = -ENOTSUP;
13622 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13625 #ifdef RTE_NET_I40E
13626 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
13633 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
13636 printf("invalid port_id %d\n", res->port_id);
13639 printf("function not implemented\n");
13642 printf("programming error: (%s)\n", strerror(-ret));
13646 cmdline_parse_inst_t cmd_strict_link_prio = {
13647 .f = cmd_strict_link_prio_parsed,
13649 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
13651 (void *)&cmd_vf_tc_bw_set,
13652 (void *)&cmd_vf_tc_bw_tx,
13653 (void *)&cmd_vf_tc_bw_strict_link_prio,
13654 (void *)&cmd_vf_tc_bw_port_id,
13655 (void *)&cmd_vf_tc_bw_tc_map,
13660 /* Load dynamic device personalization*/
13661 struct cmd_ddp_add_result {
13662 cmdline_fixed_string_t ddp;
13663 cmdline_fixed_string_t add;
13668 cmdline_parse_token_string_t cmd_ddp_add_ddp =
13669 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
13670 cmdline_parse_token_string_t cmd_ddp_add_add =
13671 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
13672 cmdline_parse_token_num_t cmd_ddp_add_port_id =
13673 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
13675 cmdline_parse_token_string_t cmd_ddp_add_filepath =
13676 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
13679 cmd_ddp_add_parsed(
13680 void *parsed_result,
13681 __rte_unused struct cmdline *cl,
13682 __rte_unused void *data)
13684 struct cmd_ddp_add_result *res = parsed_result;
13690 int ret = -ENOTSUP;
13692 if (!all_ports_stopped()) {
13693 printf("Please stop all ports first\n");
13697 filepath = strdup(res->filepath);
13698 if (filepath == NULL) {
13699 printf("Failed to allocate memory\n");
13702 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
13704 buff = open_file(file_fld[0], &size);
13706 free((void *)filepath);
13710 #ifdef RTE_NET_I40E
13711 if (ret == -ENOTSUP)
13712 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13714 RTE_PMD_I40E_PKG_OP_WR_ADD);
13717 if (ret == -EEXIST)
13718 printf("Profile has already existed.\n");
13720 printf("Failed to load profile.\n");
13721 else if (file_num == 2)
13722 save_file(file_fld[1], buff, size);
13725 free((void *)filepath);
13728 cmdline_parse_inst_t cmd_ddp_add = {
13729 .f = cmd_ddp_add_parsed,
13731 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
13733 (void *)&cmd_ddp_add_ddp,
13734 (void *)&cmd_ddp_add_add,
13735 (void *)&cmd_ddp_add_port_id,
13736 (void *)&cmd_ddp_add_filepath,
13741 /* Delete dynamic device personalization*/
13742 struct cmd_ddp_del_result {
13743 cmdline_fixed_string_t ddp;
13744 cmdline_fixed_string_t del;
13749 cmdline_parse_token_string_t cmd_ddp_del_ddp =
13750 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
13751 cmdline_parse_token_string_t cmd_ddp_del_del =
13752 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
13753 cmdline_parse_token_num_t cmd_ddp_del_port_id =
13754 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
13755 cmdline_parse_token_string_t cmd_ddp_del_filepath =
13756 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
13759 cmd_ddp_del_parsed(
13760 void *parsed_result,
13761 __rte_unused struct cmdline *cl,
13762 __rte_unused void *data)
13764 struct cmd_ddp_del_result *res = parsed_result;
13767 int ret = -ENOTSUP;
13769 if (!all_ports_stopped()) {
13770 printf("Please stop all ports first\n");
13774 buff = open_file(res->filepath, &size);
13778 #ifdef RTE_NET_I40E
13779 if (ret == -ENOTSUP)
13780 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13782 RTE_PMD_I40E_PKG_OP_WR_DEL);
13785 if (ret == -EACCES)
13786 printf("Profile does not exist.\n");
13788 printf("Failed to delete profile.\n");
13793 cmdline_parse_inst_t cmd_ddp_del = {
13794 .f = cmd_ddp_del_parsed,
13796 .help_str = "ddp del <port_id> <backup_profile_path>",
13798 (void *)&cmd_ddp_del_ddp,
13799 (void *)&cmd_ddp_del_del,
13800 (void *)&cmd_ddp_del_port_id,
13801 (void *)&cmd_ddp_del_filepath,
13806 /* Get dynamic device personalization profile info */
13807 struct cmd_ddp_info_result {
13808 cmdline_fixed_string_t ddp;
13809 cmdline_fixed_string_t get;
13810 cmdline_fixed_string_t info;
13814 cmdline_parse_token_string_t cmd_ddp_info_ddp =
13815 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
13816 cmdline_parse_token_string_t cmd_ddp_info_get =
13817 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
13818 cmdline_parse_token_string_t cmd_ddp_info_info =
13819 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
13820 cmdline_parse_token_string_t cmd_ddp_info_filepath =
13821 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
13824 cmd_ddp_info_parsed(
13825 void *parsed_result,
13826 __rte_unused struct cmdline *cl,
13827 __rte_unused void *data)
13829 struct cmd_ddp_info_result *res = parsed_result;
13832 int ret = -ENOTSUP;
13833 #ifdef RTE_NET_I40E
13836 uint32_t buff_size = 0;
13837 struct rte_pmd_i40e_profile_info info;
13838 uint32_t dev_num = 0;
13839 struct rte_pmd_i40e_ddp_device_id *devs;
13840 uint32_t proto_num = 0;
13841 struct rte_pmd_i40e_proto_info *proto = NULL;
13842 uint32_t pctype_num = 0;
13843 struct rte_pmd_i40e_ptype_info *pctype;
13844 uint32_t ptype_num = 0;
13845 struct rte_pmd_i40e_ptype_info *ptype;
13850 pkg = open_file(res->filepath, &pkg_size);
13854 #ifdef RTE_NET_I40E
13855 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13856 (uint8_t *)&info, sizeof(info),
13857 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
13859 printf("Global Track id: 0x%x\n", info.track_id);
13860 printf("Global Version: %d.%d.%d.%d\n",
13861 info.version.major,
13862 info.version.minor,
13863 info.version.update,
13864 info.version.draft);
13865 printf("Global Package name: %s\n\n", info.name);
13868 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13869 (uint8_t *)&info, sizeof(info),
13870 RTE_PMD_I40E_PKG_INFO_HEADER);
13872 printf("i40e Profile Track id: 0x%x\n", info.track_id);
13873 printf("i40e Profile Version: %d.%d.%d.%d\n",
13874 info.version.major,
13875 info.version.minor,
13876 info.version.update,
13877 info.version.draft);
13878 printf("i40e Profile name: %s\n\n", info.name);
13881 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13882 (uint8_t *)&buff_size, sizeof(buff_size),
13883 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
13884 if (!ret && buff_size) {
13885 buff = (uint8_t *)malloc(buff_size);
13887 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13889 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
13891 printf("Package Notes:\n%s\n\n", buff);
13896 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13897 (uint8_t *)&dev_num, sizeof(dev_num),
13898 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
13899 if (!ret && dev_num) {
13900 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
13901 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
13903 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13904 (uint8_t *)devs, buff_size,
13905 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
13907 printf("List of supported devices:\n");
13908 for (i = 0; i < dev_num; i++) {
13909 printf(" %04X:%04X %04X:%04X\n",
13910 devs[i].vendor_dev_id >> 16,
13911 devs[i].vendor_dev_id & 0xFFFF,
13912 devs[i].sub_vendor_dev_id >> 16,
13913 devs[i].sub_vendor_dev_id & 0xFFFF);
13921 /* get information about protocols and packet types */
13922 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13923 (uint8_t *)&proto_num, sizeof(proto_num),
13924 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
13925 if (ret || !proto_num)
13926 goto no_print_return;
13928 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
13929 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
13931 goto no_print_return;
13933 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
13935 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
13937 printf("List of used protocols:\n");
13938 for (i = 0; i < proto_num; i++)
13939 printf(" %2u: %s\n", proto[i].proto_id,
13943 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13944 (uint8_t *)&pctype_num, sizeof(pctype_num),
13945 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
13946 if (ret || !pctype_num)
13947 goto no_print_pctypes;
13949 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
13950 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
13952 goto no_print_pctypes;
13954 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
13956 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
13959 goto no_print_pctypes;
13962 printf("List of defined packet classification types:\n");
13963 for (i = 0; i < pctype_num; i++) {
13964 printf(" %2u:", pctype[i].ptype_id);
13965 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
13966 proto_id = pctype[i].protocols[j];
13967 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
13968 for (n = 0; n < proto_num; n++) {
13969 if (proto[n].proto_id == proto_id) {
13970 printf(" %s", proto[n].name);
13983 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
13985 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
13986 if (ret || !ptype_num)
13987 goto no_print_return;
13989 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
13990 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
13992 goto no_print_return;
13994 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
13996 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
13999 goto no_print_return;
14001 printf("List of defined packet types:\n");
14002 for (i = 0; i < ptype_num; i++) {
14003 printf(" %2u:", ptype[i].ptype_id);
14004 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14005 proto_id = ptype[i].protocols[j];
14006 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14007 for (n = 0; n < proto_num; n++) {
14008 if (proto[n].proto_id == proto_id) {
14009 printf(" %s", proto[n].name);
14025 if (ret == -ENOTSUP)
14026 printf("Function not supported in PMD driver\n");
14030 cmdline_parse_inst_t cmd_ddp_get_info = {
14031 .f = cmd_ddp_info_parsed,
14033 .help_str = "ddp get info <profile_path>",
14035 (void *)&cmd_ddp_info_ddp,
14036 (void *)&cmd_ddp_info_get,
14037 (void *)&cmd_ddp_info_info,
14038 (void *)&cmd_ddp_info_filepath,
14043 /* Get dynamic device personalization profile info list*/
14044 #define PROFILE_INFO_SIZE 48
14045 #define MAX_PROFILE_NUM 16
14047 struct cmd_ddp_get_list_result {
14048 cmdline_fixed_string_t ddp;
14049 cmdline_fixed_string_t get;
14050 cmdline_fixed_string_t list;
14054 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14055 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14056 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14057 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14058 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14059 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14060 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14061 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14065 cmd_ddp_get_list_parsed(
14066 __rte_unused void *parsed_result,
14067 __rte_unused struct cmdline *cl,
14068 __rte_unused void *data)
14070 #ifdef RTE_NET_I40E
14071 struct cmd_ddp_get_list_result *res = parsed_result;
14072 struct rte_pmd_i40e_profile_list *p_list;
14073 struct rte_pmd_i40e_profile_info *p_info;
14078 int ret = -ENOTSUP;
14080 #ifdef RTE_NET_I40E
14081 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14082 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14084 printf("%s: Failed to malloc buffer\n", __func__);
14088 if (ret == -ENOTSUP)
14089 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14090 (uint8_t *)p_list, size);
14093 p_num = p_list->p_count;
14094 printf("Profile number is: %d\n\n", p_num);
14096 for (i = 0; i < p_num; i++) {
14097 p_info = &p_list->p_info[i];
14098 printf("Profile %d:\n", i);
14099 printf("Track id: 0x%x\n", p_info->track_id);
14100 printf("Version: %d.%d.%d.%d\n",
14101 p_info->version.major,
14102 p_info->version.minor,
14103 p_info->version.update,
14104 p_info->version.draft);
14105 printf("Profile name: %s\n\n", p_info->name);
14113 printf("Failed to get ddp list\n");
14116 cmdline_parse_inst_t cmd_ddp_get_list = {
14117 .f = cmd_ddp_get_list_parsed,
14119 .help_str = "ddp get list <port_id>",
14121 (void *)&cmd_ddp_get_list_ddp,
14122 (void *)&cmd_ddp_get_list_get,
14123 (void *)&cmd_ddp_get_list_list,
14124 (void *)&cmd_ddp_get_list_port_id,
14129 /* Configure input set */
14130 struct cmd_cfg_input_set_result {
14131 cmdline_fixed_string_t port;
14132 cmdline_fixed_string_t cfg;
14134 cmdline_fixed_string_t pctype;
14136 cmdline_fixed_string_t inset_type;
14137 cmdline_fixed_string_t opt;
14138 cmdline_fixed_string_t field;
14143 cmd_cfg_input_set_parsed(
14144 __rte_unused void *parsed_result,
14145 __rte_unused struct cmdline *cl,
14146 __rte_unused void *data)
14148 #ifdef RTE_NET_I40E
14149 struct cmd_cfg_input_set_result *res = parsed_result;
14150 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14151 struct rte_pmd_i40e_inset inset;
14153 int ret = -ENOTSUP;
14155 if (!all_ports_stopped()) {
14156 printf("Please stop all ports first\n");
14160 #ifdef RTE_NET_I40E
14161 if (!strcmp(res->inset_type, "hash_inset"))
14162 inset_type = INSET_HASH;
14163 else if (!strcmp(res->inset_type, "fdir_inset"))
14164 inset_type = INSET_FDIR;
14165 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14166 inset_type = INSET_FDIR_FLX;
14167 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14168 &inset, inset_type);
14170 printf("Failed to get input set.\n");
14174 if (!strcmp(res->opt, "get")) {
14175 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14178 printf("Field index %d is enabled.\n", res->field_idx);
14180 printf("Field index %d is disabled.\n", res->field_idx);
14182 } else if (!strcmp(res->opt, "set"))
14183 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14185 else if (!strcmp(res->opt, "clear"))
14186 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14189 printf("Failed to configure input set field.\n");
14193 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14194 &inset, inset_type);
14196 printf("Failed to set input set.\n");
14201 if (ret == -ENOTSUP)
14202 printf("Function not supported\n");
14205 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14206 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14208 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14209 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14211 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14212 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14213 port_id, RTE_UINT16);
14214 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14215 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14217 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14218 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14219 pctype_id, RTE_UINT8);
14220 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14221 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14223 "hash_inset#fdir_inset#fdir_flx_inset");
14224 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14225 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14226 opt, "get#set#clear");
14227 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14228 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14230 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14231 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14232 field_idx, RTE_UINT8);
14234 cmdline_parse_inst_t cmd_cfg_input_set = {
14235 .f = cmd_cfg_input_set_parsed,
14237 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14238 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
14240 (void *)&cmd_cfg_input_set_port,
14241 (void *)&cmd_cfg_input_set_cfg,
14242 (void *)&cmd_cfg_input_set_port_id,
14243 (void *)&cmd_cfg_input_set_pctype,
14244 (void *)&cmd_cfg_input_set_pctype_id,
14245 (void *)&cmd_cfg_input_set_inset_type,
14246 (void *)&cmd_cfg_input_set_opt,
14247 (void *)&cmd_cfg_input_set_field,
14248 (void *)&cmd_cfg_input_set_field_idx,
14253 /* Clear input set */
14254 struct cmd_clear_input_set_result {
14255 cmdline_fixed_string_t port;
14256 cmdline_fixed_string_t cfg;
14258 cmdline_fixed_string_t pctype;
14260 cmdline_fixed_string_t inset_type;
14261 cmdline_fixed_string_t clear;
14262 cmdline_fixed_string_t all;
14266 cmd_clear_input_set_parsed(
14267 __rte_unused void *parsed_result,
14268 __rte_unused struct cmdline *cl,
14269 __rte_unused void *data)
14271 #ifdef RTE_NET_I40E
14272 struct cmd_clear_input_set_result *res = parsed_result;
14273 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14274 struct rte_pmd_i40e_inset inset;
14276 int ret = -ENOTSUP;
14278 if (!all_ports_stopped()) {
14279 printf("Please stop all ports first\n");
14283 #ifdef RTE_NET_I40E
14284 if (!strcmp(res->inset_type, "hash_inset"))
14285 inset_type = INSET_HASH;
14286 else if (!strcmp(res->inset_type, "fdir_inset"))
14287 inset_type = INSET_FDIR;
14288 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14289 inset_type = INSET_FDIR_FLX;
14291 memset(&inset, 0, sizeof(inset));
14293 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14294 &inset, inset_type);
14296 printf("Failed to clear input set.\n");
14302 if (ret == -ENOTSUP)
14303 printf("Function not supported\n");
14306 cmdline_parse_token_string_t cmd_clear_input_set_port =
14307 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14309 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
14310 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14312 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
14313 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14314 port_id, RTE_UINT16);
14315 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
14316 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14318 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
14319 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14320 pctype_id, RTE_UINT8);
14321 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
14322 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14324 "hash_inset#fdir_inset#fdir_flx_inset");
14325 cmdline_parse_token_string_t cmd_clear_input_set_clear =
14326 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14328 cmdline_parse_token_string_t cmd_clear_input_set_all =
14329 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14332 cmdline_parse_inst_t cmd_clear_input_set = {
14333 .f = cmd_clear_input_set_parsed,
14335 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14336 "fdir_inset|fdir_flx_inset clear all",
14338 (void *)&cmd_clear_input_set_port,
14339 (void *)&cmd_clear_input_set_cfg,
14340 (void *)&cmd_clear_input_set_port_id,
14341 (void *)&cmd_clear_input_set_pctype,
14342 (void *)&cmd_clear_input_set_pctype_id,
14343 (void *)&cmd_clear_input_set_inset_type,
14344 (void *)&cmd_clear_input_set_clear,
14345 (void *)&cmd_clear_input_set_all,
14350 /* show vf stats */
14352 /* Common result structure for show vf stats */
14353 struct cmd_show_vf_stats_result {
14354 cmdline_fixed_string_t show;
14355 cmdline_fixed_string_t vf;
14356 cmdline_fixed_string_t stats;
14361 /* Common CLI fields show vf stats*/
14362 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14363 TOKEN_STRING_INITIALIZER
14364 (struct cmd_show_vf_stats_result,
14366 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14367 TOKEN_STRING_INITIALIZER
14368 (struct cmd_show_vf_stats_result,
14370 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14371 TOKEN_STRING_INITIALIZER
14372 (struct cmd_show_vf_stats_result,
14374 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14375 TOKEN_NUM_INITIALIZER
14376 (struct cmd_show_vf_stats_result,
14377 port_id, RTE_UINT16);
14378 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14379 TOKEN_NUM_INITIALIZER
14380 (struct cmd_show_vf_stats_result,
14381 vf_id, RTE_UINT16);
14384 cmd_show_vf_stats_parsed(
14385 void *parsed_result,
14386 __rte_unused struct cmdline *cl,
14387 __rte_unused void *data)
14389 struct cmd_show_vf_stats_result *res = parsed_result;
14390 struct rte_eth_stats stats;
14391 int ret = -ENOTSUP;
14392 static const char *nic_stats_border = "########################";
14394 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14397 memset(&stats, 0, sizeof(stats));
14399 #ifdef RTE_NET_I40E
14400 if (ret == -ENOTSUP)
14401 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14405 #ifdef RTE_NET_BNXT
14406 if (ret == -ENOTSUP)
14407 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14416 printf("invalid vf_id %d\n", res->vf_id);
14419 printf("invalid port_id %d\n", res->port_id);
14422 printf("function not implemented\n");
14425 printf("programming error: (%s)\n", strerror(-ret));
14428 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14429 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14431 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14433 stats.ipackets, stats.imissed, stats.ibytes);
14434 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14435 printf(" RX-nombuf: %-10"PRIu64"\n",
14437 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14439 stats.opackets, stats.oerrors, stats.obytes);
14441 printf(" %s############################%s\n",
14442 nic_stats_border, nic_stats_border);
14445 cmdline_parse_inst_t cmd_show_vf_stats = {
14446 .f = cmd_show_vf_stats_parsed,
14448 .help_str = "show vf stats <port_id> <vf_id>",
14450 (void *)&cmd_show_vf_stats_show,
14451 (void *)&cmd_show_vf_stats_vf,
14452 (void *)&cmd_show_vf_stats_stats,
14453 (void *)&cmd_show_vf_stats_port_id,
14454 (void *)&cmd_show_vf_stats_vf_id,
14459 /* clear vf stats */
14461 /* Common result structure for clear vf stats */
14462 struct cmd_clear_vf_stats_result {
14463 cmdline_fixed_string_t clear;
14464 cmdline_fixed_string_t vf;
14465 cmdline_fixed_string_t stats;
14470 /* Common CLI fields clear vf stats*/
14471 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14472 TOKEN_STRING_INITIALIZER
14473 (struct cmd_clear_vf_stats_result,
14475 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
14476 TOKEN_STRING_INITIALIZER
14477 (struct cmd_clear_vf_stats_result,
14479 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
14480 TOKEN_STRING_INITIALIZER
14481 (struct cmd_clear_vf_stats_result,
14483 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
14484 TOKEN_NUM_INITIALIZER
14485 (struct cmd_clear_vf_stats_result,
14486 port_id, RTE_UINT16);
14487 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
14488 TOKEN_NUM_INITIALIZER
14489 (struct cmd_clear_vf_stats_result,
14490 vf_id, RTE_UINT16);
14493 cmd_clear_vf_stats_parsed(
14494 void *parsed_result,
14495 __rte_unused struct cmdline *cl,
14496 __rte_unused void *data)
14498 struct cmd_clear_vf_stats_result *res = parsed_result;
14499 int ret = -ENOTSUP;
14501 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14504 #ifdef RTE_NET_I40E
14505 if (ret == -ENOTSUP)
14506 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
14509 #ifdef RTE_NET_BNXT
14510 if (ret == -ENOTSUP)
14511 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
14519 printf("invalid vf_id %d\n", res->vf_id);
14522 printf("invalid port_id %d\n", res->port_id);
14525 printf("function not implemented\n");
14528 printf("programming error: (%s)\n", strerror(-ret));
14532 cmdline_parse_inst_t cmd_clear_vf_stats = {
14533 .f = cmd_clear_vf_stats_parsed,
14535 .help_str = "clear vf stats <port_id> <vf_id>",
14537 (void *)&cmd_clear_vf_stats_clear,
14538 (void *)&cmd_clear_vf_stats_vf,
14539 (void *)&cmd_clear_vf_stats_stats,
14540 (void *)&cmd_clear_vf_stats_port_id,
14541 (void *)&cmd_clear_vf_stats_vf_id,
14546 /* port config pctype mapping reset */
14548 /* Common result structure for port config pctype mapping reset */
14549 struct cmd_pctype_mapping_reset_result {
14550 cmdline_fixed_string_t port;
14551 cmdline_fixed_string_t config;
14553 cmdline_fixed_string_t pctype;
14554 cmdline_fixed_string_t mapping;
14555 cmdline_fixed_string_t reset;
14558 /* Common CLI fields for port config pctype mapping reset*/
14559 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
14560 TOKEN_STRING_INITIALIZER
14561 (struct cmd_pctype_mapping_reset_result,
14563 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
14564 TOKEN_STRING_INITIALIZER
14565 (struct cmd_pctype_mapping_reset_result,
14567 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
14568 TOKEN_NUM_INITIALIZER
14569 (struct cmd_pctype_mapping_reset_result,
14570 port_id, RTE_UINT16);
14571 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
14572 TOKEN_STRING_INITIALIZER
14573 (struct cmd_pctype_mapping_reset_result,
14575 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
14576 TOKEN_STRING_INITIALIZER
14577 (struct cmd_pctype_mapping_reset_result,
14578 mapping, "mapping");
14579 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
14580 TOKEN_STRING_INITIALIZER
14581 (struct cmd_pctype_mapping_reset_result,
14585 cmd_pctype_mapping_reset_parsed(
14586 void *parsed_result,
14587 __rte_unused struct cmdline *cl,
14588 __rte_unused void *data)
14590 struct cmd_pctype_mapping_reset_result *res = parsed_result;
14591 int ret = -ENOTSUP;
14593 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14596 #ifdef RTE_NET_I40E
14597 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
14604 printf("invalid port_id %d\n", res->port_id);
14607 printf("function not implemented\n");
14610 printf("programming error: (%s)\n", strerror(-ret));
14614 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
14615 .f = cmd_pctype_mapping_reset_parsed,
14617 .help_str = "port config <port_id> pctype mapping reset",
14619 (void *)&cmd_pctype_mapping_reset_port,
14620 (void *)&cmd_pctype_mapping_reset_config,
14621 (void *)&cmd_pctype_mapping_reset_port_id,
14622 (void *)&cmd_pctype_mapping_reset_pctype,
14623 (void *)&cmd_pctype_mapping_reset_mapping,
14624 (void *)&cmd_pctype_mapping_reset_reset,
14629 /* show port pctype mapping */
14631 /* Common result structure for show port pctype mapping */
14632 struct cmd_pctype_mapping_get_result {
14633 cmdline_fixed_string_t show;
14634 cmdline_fixed_string_t port;
14636 cmdline_fixed_string_t pctype;
14637 cmdline_fixed_string_t mapping;
14640 /* Common CLI fields for pctype mapping get */
14641 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
14642 TOKEN_STRING_INITIALIZER
14643 (struct cmd_pctype_mapping_get_result,
14645 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
14646 TOKEN_STRING_INITIALIZER
14647 (struct cmd_pctype_mapping_get_result,
14649 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
14650 TOKEN_NUM_INITIALIZER
14651 (struct cmd_pctype_mapping_get_result,
14652 port_id, RTE_UINT16);
14653 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
14654 TOKEN_STRING_INITIALIZER
14655 (struct cmd_pctype_mapping_get_result,
14657 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
14658 TOKEN_STRING_INITIALIZER
14659 (struct cmd_pctype_mapping_get_result,
14660 mapping, "mapping");
14663 cmd_pctype_mapping_get_parsed(
14664 void *parsed_result,
14665 __rte_unused struct cmdline *cl,
14666 __rte_unused void *data)
14668 struct cmd_pctype_mapping_get_result *res = parsed_result;
14669 int ret = -ENOTSUP;
14670 #ifdef RTE_NET_I40E
14671 struct rte_pmd_i40e_flow_type_mapping
14672 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
14673 int i, j, first_pctype;
14676 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14679 #ifdef RTE_NET_I40E
14680 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
14687 printf("invalid port_id %d\n", res->port_id);
14690 printf("function not implemented\n");
14693 printf("programming error: (%s)\n", strerror(-ret));
14697 #ifdef RTE_NET_I40E
14698 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
14699 if (mapping[i].pctype != 0ULL) {
14702 printf("pctype: ");
14703 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
14704 if (mapping[i].pctype & (1ULL << j)) {
14705 printf(first_pctype ?
14706 "%02d" : ",%02d", j);
14710 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
14716 cmdline_parse_inst_t cmd_pctype_mapping_get = {
14717 .f = cmd_pctype_mapping_get_parsed,
14719 .help_str = "show port <port_id> pctype mapping",
14721 (void *)&cmd_pctype_mapping_get_show,
14722 (void *)&cmd_pctype_mapping_get_port,
14723 (void *)&cmd_pctype_mapping_get_port_id,
14724 (void *)&cmd_pctype_mapping_get_pctype,
14725 (void *)&cmd_pctype_mapping_get_mapping,
14730 /* port config pctype mapping update */
14732 /* Common result structure for port config pctype mapping update */
14733 struct cmd_pctype_mapping_update_result {
14734 cmdline_fixed_string_t port;
14735 cmdline_fixed_string_t config;
14737 cmdline_fixed_string_t pctype;
14738 cmdline_fixed_string_t mapping;
14739 cmdline_fixed_string_t update;
14740 cmdline_fixed_string_t pctype_list;
14741 uint16_t flow_type;
14744 /* Common CLI fields for pctype mapping update*/
14745 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
14746 TOKEN_STRING_INITIALIZER
14747 (struct cmd_pctype_mapping_update_result,
14749 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
14750 TOKEN_STRING_INITIALIZER
14751 (struct cmd_pctype_mapping_update_result,
14753 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
14754 TOKEN_NUM_INITIALIZER
14755 (struct cmd_pctype_mapping_update_result,
14756 port_id, RTE_UINT16);
14757 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
14758 TOKEN_STRING_INITIALIZER
14759 (struct cmd_pctype_mapping_update_result,
14761 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
14762 TOKEN_STRING_INITIALIZER
14763 (struct cmd_pctype_mapping_update_result,
14764 mapping, "mapping");
14765 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
14766 TOKEN_STRING_INITIALIZER
14767 (struct cmd_pctype_mapping_update_result,
14769 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
14770 TOKEN_STRING_INITIALIZER
14771 (struct cmd_pctype_mapping_update_result,
14772 pctype_list, NULL);
14773 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
14774 TOKEN_NUM_INITIALIZER
14775 (struct cmd_pctype_mapping_update_result,
14776 flow_type, RTE_UINT16);
14779 cmd_pctype_mapping_update_parsed(
14780 void *parsed_result,
14781 __rte_unused struct cmdline *cl,
14782 __rte_unused void *data)
14784 struct cmd_pctype_mapping_update_result *res = parsed_result;
14785 int ret = -ENOTSUP;
14786 #ifdef RTE_NET_I40E
14787 struct rte_pmd_i40e_flow_type_mapping mapping;
14789 unsigned int nb_item;
14790 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
14793 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14796 #ifdef RTE_NET_I40E
14797 nb_item = parse_item_list(res->pctype_list, "pctypes",
14798 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
14799 mapping.flow_type = res->flow_type;
14800 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
14801 mapping.pctype |= (1ULL << pctype_list[i]);
14802 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
14812 printf("invalid pctype or flow type\n");
14815 printf("invalid port_id %d\n", res->port_id);
14818 printf("function not implemented\n");
14821 printf("programming error: (%s)\n", strerror(-ret));
14825 cmdline_parse_inst_t cmd_pctype_mapping_update = {
14826 .f = cmd_pctype_mapping_update_parsed,
14828 .help_str = "port config <port_id> pctype mapping update"
14829 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
14831 (void *)&cmd_pctype_mapping_update_port,
14832 (void *)&cmd_pctype_mapping_update_config,
14833 (void *)&cmd_pctype_mapping_update_port_id,
14834 (void *)&cmd_pctype_mapping_update_pctype,
14835 (void *)&cmd_pctype_mapping_update_mapping,
14836 (void *)&cmd_pctype_mapping_update_update,
14837 (void *)&cmd_pctype_mapping_update_pc_type,
14838 (void *)&cmd_pctype_mapping_update_flow_type,
14843 /* ptype mapping get */
14845 /* Common result structure for ptype mapping get */
14846 struct cmd_ptype_mapping_get_result {
14847 cmdline_fixed_string_t ptype;
14848 cmdline_fixed_string_t mapping;
14849 cmdline_fixed_string_t get;
14851 uint8_t valid_only;
14854 /* Common CLI fields for ptype mapping get */
14855 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
14856 TOKEN_STRING_INITIALIZER
14857 (struct cmd_ptype_mapping_get_result,
14859 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
14860 TOKEN_STRING_INITIALIZER
14861 (struct cmd_ptype_mapping_get_result,
14862 mapping, "mapping");
14863 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
14864 TOKEN_STRING_INITIALIZER
14865 (struct cmd_ptype_mapping_get_result,
14867 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
14868 TOKEN_NUM_INITIALIZER
14869 (struct cmd_ptype_mapping_get_result,
14870 port_id, RTE_UINT16);
14871 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
14872 TOKEN_NUM_INITIALIZER
14873 (struct cmd_ptype_mapping_get_result,
14874 valid_only, RTE_UINT8);
14877 cmd_ptype_mapping_get_parsed(
14878 void *parsed_result,
14879 __rte_unused struct cmdline *cl,
14880 __rte_unused void *data)
14882 struct cmd_ptype_mapping_get_result *res = parsed_result;
14883 int ret = -ENOTSUP;
14884 #ifdef RTE_NET_I40E
14885 int max_ptype_num = 256;
14886 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
14891 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14894 #ifdef RTE_NET_I40E
14895 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
14906 printf("invalid port_id %d\n", res->port_id);
14909 printf("function not implemented\n");
14912 printf("programming error: (%s)\n", strerror(-ret));
14915 #ifdef RTE_NET_I40E
14917 for (i = 0; i < count; i++)
14918 printf("%3d\t0x%08x\n",
14919 mapping[i].hw_ptype, mapping[i].sw_ptype);
14924 cmdline_parse_inst_t cmd_ptype_mapping_get = {
14925 .f = cmd_ptype_mapping_get_parsed,
14927 .help_str = "ptype mapping get <port_id> <valid_only>",
14929 (void *)&cmd_ptype_mapping_get_ptype,
14930 (void *)&cmd_ptype_mapping_get_mapping,
14931 (void *)&cmd_ptype_mapping_get_get,
14932 (void *)&cmd_ptype_mapping_get_port_id,
14933 (void *)&cmd_ptype_mapping_get_valid_only,
14938 /* ptype mapping replace */
14940 /* Common result structure for ptype mapping replace */
14941 struct cmd_ptype_mapping_replace_result {
14942 cmdline_fixed_string_t ptype;
14943 cmdline_fixed_string_t mapping;
14944 cmdline_fixed_string_t replace;
14951 /* Common CLI fields for ptype mapping replace */
14952 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
14953 TOKEN_STRING_INITIALIZER
14954 (struct cmd_ptype_mapping_replace_result,
14956 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
14957 TOKEN_STRING_INITIALIZER
14958 (struct cmd_ptype_mapping_replace_result,
14959 mapping, "mapping");
14960 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
14961 TOKEN_STRING_INITIALIZER
14962 (struct cmd_ptype_mapping_replace_result,
14963 replace, "replace");
14964 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
14965 TOKEN_NUM_INITIALIZER
14966 (struct cmd_ptype_mapping_replace_result,
14967 port_id, RTE_UINT16);
14968 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
14969 TOKEN_NUM_INITIALIZER
14970 (struct cmd_ptype_mapping_replace_result,
14971 target, RTE_UINT32);
14972 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
14973 TOKEN_NUM_INITIALIZER
14974 (struct cmd_ptype_mapping_replace_result,
14976 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
14977 TOKEN_NUM_INITIALIZER
14978 (struct cmd_ptype_mapping_replace_result,
14979 pkt_type, RTE_UINT32);
14982 cmd_ptype_mapping_replace_parsed(
14983 void *parsed_result,
14984 __rte_unused struct cmdline *cl,
14985 __rte_unused void *data)
14987 struct cmd_ptype_mapping_replace_result *res = parsed_result;
14988 int ret = -ENOTSUP;
14990 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14993 #ifdef RTE_NET_I40E
14994 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15004 printf("invalid ptype 0x%8x or 0x%8x\n",
15005 res->target, res->pkt_type);
15008 printf("invalid port_id %d\n", res->port_id);
15011 printf("function not implemented\n");
15014 printf("programming error: (%s)\n", strerror(-ret));
15018 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15019 .f = cmd_ptype_mapping_replace_parsed,
15022 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15024 (void *)&cmd_ptype_mapping_replace_ptype,
15025 (void *)&cmd_ptype_mapping_replace_mapping,
15026 (void *)&cmd_ptype_mapping_replace_replace,
15027 (void *)&cmd_ptype_mapping_replace_port_id,
15028 (void *)&cmd_ptype_mapping_replace_target,
15029 (void *)&cmd_ptype_mapping_replace_mask,
15030 (void *)&cmd_ptype_mapping_replace_pkt_type,
15035 /* ptype mapping reset */
15037 /* Common result structure for ptype mapping reset */
15038 struct cmd_ptype_mapping_reset_result {
15039 cmdline_fixed_string_t ptype;
15040 cmdline_fixed_string_t mapping;
15041 cmdline_fixed_string_t reset;
15045 /* Common CLI fields for ptype mapping reset*/
15046 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15047 TOKEN_STRING_INITIALIZER
15048 (struct cmd_ptype_mapping_reset_result,
15050 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15051 TOKEN_STRING_INITIALIZER
15052 (struct cmd_ptype_mapping_reset_result,
15053 mapping, "mapping");
15054 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15055 TOKEN_STRING_INITIALIZER
15056 (struct cmd_ptype_mapping_reset_result,
15058 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15059 TOKEN_NUM_INITIALIZER
15060 (struct cmd_ptype_mapping_reset_result,
15061 port_id, RTE_UINT16);
15064 cmd_ptype_mapping_reset_parsed(
15065 void *parsed_result,
15066 __rte_unused struct cmdline *cl,
15067 __rte_unused void *data)
15069 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15070 int ret = -ENOTSUP;
15072 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15075 #ifdef RTE_NET_I40E
15076 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15083 printf("invalid port_id %d\n", res->port_id);
15086 printf("function not implemented\n");
15089 printf("programming error: (%s)\n", strerror(-ret));
15093 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15094 .f = cmd_ptype_mapping_reset_parsed,
15096 .help_str = "ptype mapping reset <port_id>",
15098 (void *)&cmd_ptype_mapping_reset_ptype,
15099 (void *)&cmd_ptype_mapping_reset_mapping,
15100 (void *)&cmd_ptype_mapping_reset_reset,
15101 (void *)&cmd_ptype_mapping_reset_port_id,
15106 /* ptype mapping update */
15108 /* Common result structure for ptype mapping update */
15109 struct cmd_ptype_mapping_update_result {
15110 cmdline_fixed_string_t ptype;
15111 cmdline_fixed_string_t mapping;
15112 cmdline_fixed_string_t reset;
15118 /* Common CLI fields for ptype mapping update*/
15119 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15120 TOKEN_STRING_INITIALIZER
15121 (struct cmd_ptype_mapping_update_result,
15123 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15124 TOKEN_STRING_INITIALIZER
15125 (struct cmd_ptype_mapping_update_result,
15126 mapping, "mapping");
15127 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15128 TOKEN_STRING_INITIALIZER
15129 (struct cmd_ptype_mapping_update_result,
15131 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15132 TOKEN_NUM_INITIALIZER
15133 (struct cmd_ptype_mapping_update_result,
15134 port_id, RTE_UINT16);
15135 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15136 TOKEN_NUM_INITIALIZER
15137 (struct cmd_ptype_mapping_update_result,
15138 hw_ptype, RTE_UINT8);
15139 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15140 TOKEN_NUM_INITIALIZER
15141 (struct cmd_ptype_mapping_update_result,
15142 sw_ptype, RTE_UINT32);
15145 cmd_ptype_mapping_update_parsed(
15146 void *parsed_result,
15147 __rte_unused struct cmdline *cl,
15148 __rte_unused void *data)
15150 struct cmd_ptype_mapping_update_result *res = parsed_result;
15151 int ret = -ENOTSUP;
15152 #ifdef RTE_NET_I40E
15153 struct rte_pmd_i40e_ptype_mapping mapping;
15155 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15158 #ifdef RTE_NET_I40E
15159 mapping.hw_ptype = res->hw_ptype;
15160 mapping.sw_ptype = res->sw_ptype;
15161 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15171 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15174 printf("invalid port_id %d\n", res->port_id);
15177 printf("function not implemented\n");
15180 printf("programming error: (%s)\n", strerror(-ret));
15184 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15185 .f = cmd_ptype_mapping_update_parsed,
15187 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15189 (void *)&cmd_ptype_mapping_update_ptype,
15190 (void *)&cmd_ptype_mapping_update_mapping,
15191 (void *)&cmd_ptype_mapping_update_update,
15192 (void *)&cmd_ptype_mapping_update_port_id,
15193 (void *)&cmd_ptype_mapping_update_hw_ptype,
15194 (void *)&cmd_ptype_mapping_update_sw_ptype,
15199 /* Common result structure for file commands */
15200 struct cmd_cmdfile_result {
15201 cmdline_fixed_string_t load;
15202 cmdline_fixed_string_t filename;
15205 /* Common CLI fields for file commands */
15206 cmdline_parse_token_string_t cmd_load_cmdfile =
15207 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15208 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15209 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15212 cmd_load_from_file_parsed(
15213 void *parsed_result,
15214 __rte_unused struct cmdline *cl,
15215 __rte_unused void *data)
15217 struct cmd_cmdfile_result *res = parsed_result;
15219 cmdline_read_from_file(res->filename);
15222 cmdline_parse_inst_t cmd_load_from_file = {
15223 .f = cmd_load_from_file_parsed,
15225 .help_str = "load <filename>",
15227 (void *)&cmd_load_cmdfile,
15228 (void *)&cmd_load_cmdfile_filename,
15233 /* Get Rx offloads capabilities */
15234 struct cmd_rx_offload_get_capa_result {
15235 cmdline_fixed_string_t show;
15236 cmdline_fixed_string_t port;
15238 cmdline_fixed_string_t rx_offload;
15239 cmdline_fixed_string_t capabilities;
15242 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
15243 TOKEN_STRING_INITIALIZER
15244 (struct cmd_rx_offload_get_capa_result,
15246 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
15247 TOKEN_STRING_INITIALIZER
15248 (struct cmd_rx_offload_get_capa_result,
15250 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
15251 TOKEN_NUM_INITIALIZER
15252 (struct cmd_rx_offload_get_capa_result,
15253 port_id, RTE_UINT16);
15254 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
15255 TOKEN_STRING_INITIALIZER
15256 (struct cmd_rx_offload_get_capa_result,
15257 rx_offload, "rx_offload");
15258 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
15259 TOKEN_STRING_INITIALIZER
15260 (struct cmd_rx_offload_get_capa_result,
15261 capabilities, "capabilities");
15264 print_rx_offloads(uint64_t offloads)
15266 uint64_t single_offload;
15274 begin = __builtin_ctzll(offloads);
15275 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15277 single_offload = 1ULL << begin;
15278 for (bit = begin; bit < end; bit++) {
15279 if (offloads & single_offload)
15281 rte_eth_dev_rx_offload_name(single_offload));
15282 single_offload <<= 1;
15287 cmd_rx_offload_get_capa_parsed(
15288 void *parsed_result,
15289 __rte_unused struct cmdline *cl,
15290 __rte_unused void *data)
15292 struct cmd_rx_offload_get_capa_result *res = parsed_result;
15293 struct rte_eth_dev_info dev_info;
15294 portid_t port_id = res->port_id;
15295 uint64_t queue_offloads;
15296 uint64_t port_offloads;
15299 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15303 queue_offloads = dev_info.rx_queue_offload_capa;
15304 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
15306 printf("Rx Offloading Capabilities of port %d :\n", port_id);
15307 printf(" Per Queue :");
15308 print_rx_offloads(queue_offloads);
15311 printf(" Per Port :");
15312 print_rx_offloads(port_offloads);
15316 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
15317 .f = cmd_rx_offload_get_capa_parsed,
15319 .help_str = "show port <port_id> rx_offload capabilities",
15321 (void *)&cmd_rx_offload_get_capa_show,
15322 (void *)&cmd_rx_offload_get_capa_port,
15323 (void *)&cmd_rx_offload_get_capa_port_id,
15324 (void *)&cmd_rx_offload_get_capa_rx_offload,
15325 (void *)&cmd_rx_offload_get_capa_capabilities,
15330 /* Get Rx offloads configuration */
15331 struct cmd_rx_offload_get_configuration_result {
15332 cmdline_fixed_string_t show;
15333 cmdline_fixed_string_t port;
15335 cmdline_fixed_string_t rx_offload;
15336 cmdline_fixed_string_t configuration;
15339 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
15340 TOKEN_STRING_INITIALIZER
15341 (struct cmd_rx_offload_get_configuration_result,
15343 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
15344 TOKEN_STRING_INITIALIZER
15345 (struct cmd_rx_offload_get_configuration_result,
15347 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
15348 TOKEN_NUM_INITIALIZER
15349 (struct cmd_rx_offload_get_configuration_result,
15350 port_id, RTE_UINT16);
15351 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
15352 TOKEN_STRING_INITIALIZER
15353 (struct cmd_rx_offload_get_configuration_result,
15354 rx_offload, "rx_offload");
15355 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
15356 TOKEN_STRING_INITIALIZER
15357 (struct cmd_rx_offload_get_configuration_result,
15358 configuration, "configuration");
15361 cmd_rx_offload_get_configuration_parsed(
15362 void *parsed_result,
15363 __rte_unused struct cmdline *cl,
15364 __rte_unused void *data)
15366 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
15367 struct rte_eth_dev_info dev_info;
15368 portid_t port_id = res->port_id;
15369 struct rte_port *port = &ports[port_id];
15370 uint64_t port_offloads;
15371 uint64_t queue_offloads;
15372 uint16_t nb_rx_queues;
15376 printf("Rx Offloading Configuration of port %d :\n", port_id);
15378 port_offloads = port->dev_conf.rxmode.offloads;
15380 print_rx_offloads(port_offloads);
15383 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15387 nb_rx_queues = dev_info.nb_rx_queues;
15388 for (q = 0; q < nb_rx_queues; q++) {
15389 queue_offloads = port->rx_conf[q].offloads;
15390 printf(" Queue[%2d] :", q);
15391 print_rx_offloads(queue_offloads);
15397 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
15398 .f = cmd_rx_offload_get_configuration_parsed,
15400 .help_str = "show port <port_id> rx_offload configuration",
15402 (void *)&cmd_rx_offload_get_configuration_show,
15403 (void *)&cmd_rx_offload_get_configuration_port,
15404 (void *)&cmd_rx_offload_get_configuration_port_id,
15405 (void *)&cmd_rx_offload_get_configuration_rx_offload,
15406 (void *)&cmd_rx_offload_get_configuration_configuration,
15411 /* Enable/Disable a per port offloading */
15412 struct cmd_config_per_port_rx_offload_result {
15413 cmdline_fixed_string_t port;
15414 cmdline_fixed_string_t config;
15416 cmdline_fixed_string_t rx_offload;
15417 cmdline_fixed_string_t offload;
15418 cmdline_fixed_string_t on_off;
15421 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
15422 TOKEN_STRING_INITIALIZER
15423 (struct cmd_config_per_port_rx_offload_result,
15425 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
15426 TOKEN_STRING_INITIALIZER
15427 (struct cmd_config_per_port_rx_offload_result,
15429 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
15430 TOKEN_NUM_INITIALIZER
15431 (struct cmd_config_per_port_rx_offload_result,
15432 port_id, RTE_UINT16);
15433 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
15434 TOKEN_STRING_INITIALIZER
15435 (struct cmd_config_per_port_rx_offload_result,
15436 rx_offload, "rx_offload");
15437 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
15438 TOKEN_STRING_INITIALIZER
15439 (struct cmd_config_per_port_rx_offload_result,
15440 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
15441 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
15442 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
15443 "scatter#buffer_split#timestamp#security#"
15444 "keep_crc#rss_hash");
15445 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
15446 TOKEN_STRING_INITIALIZER
15447 (struct cmd_config_per_port_rx_offload_result,
15451 search_rx_offload(const char *name)
15453 uint64_t single_offload;
15454 const char *single_name;
15458 single_offload = 1;
15459 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
15460 single_name = rte_eth_dev_rx_offload_name(single_offload);
15461 if (!strcasecmp(single_name, name)) {
15465 single_offload <<= 1;
15469 return single_offload;
15475 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
15476 __rte_unused struct cmdline *cl,
15477 __rte_unused void *data)
15479 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
15480 portid_t port_id = res->port_id;
15481 struct rte_eth_dev_info dev_info;
15482 struct rte_port *port = &ports[port_id];
15483 uint64_t single_offload;
15484 uint16_t nb_rx_queues;
15488 if (port->port_status != RTE_PORT_STOPPED) {
15489 printf("Error: Can't config offload when Port %d "
15490 "is not stopped\n", port_id);
15494 single_offload = search_rx_offload(res->offload);
15495 if (single_offload == 0) {
15496 printf("Unknown offload name: %s\n", res->offload);
15500 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15504 nb_rx_queues = dev_info.nb_rx_queues;
15505 if (!strcmp(res->on_off, "on")) {
15506 port->dev_conf.rxmode.offloads |= single_offload;
15507 for (q = 0; q < nb_rx_queues; q++)
15508 port->rx_conf[q].offloads |= single_offload;
15510 port->dev_conf.rxmode.offloads &= ~single_offload;
15511 for (q = 0; q < nb_rx_queues; q++)
15512 port->rx_conf[q].offloads &= ~single_offload;
15515 cmd_reconfig_device_queue(port_id, 1, 1);
15518 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
15519 .f = cmd_config_per_port_rx_offload_parsed,
15521 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
15522 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
15523 "macsec_strip|header_split|vlan_filter|vlan_extend|"
15524 "jumbo_frame|scatter|buffer_split|timestamp|security|"
15525 "keep_crc|rss_hash on|off",
15527 (void *)&cmd_config_per_port_rx_offload_result_port,
15528 (void *)&cmd_config_per_port_rx_offload_result_config,
15529 (void *)&cmd_config_per_port_rx_offload_result_port_id,
15530 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
15531 (void *)&cmd_config_per_port_rx_offload_result_offload,
15532 (void *)&cmd_config_per_port_rx_offload_result_on_off,
15537 /* Enable/Disable a per queue offloading */
15538 struct cmd_config_per_queue_rx_offload_result {
15539 cmdline_fixed_string_t port;
15541 cmdline_fixed_string_t rxq;
15543 cmdline_fixed_string_t rx_offload;
15544 cmdline_fixed_string_t offload;
15545 cmdline_fixed_string_t on_off;
15548 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
15549 TOKEN_STRING_INITIALIZER
15550 (struct cmd_config_per_queue_rx_offload_result,
15552 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
15553 TOKEN_NUM_INITIALIZER
15554 (struct cmd_config_per_queue_rx_offload_result,
15555 port_id, RTE_UINT16);
15556 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
15557 TOKEN_STRING_INITIALIZER
15558 (struct cmd_config_per_queue_rx_offload_result,
15560 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
15561 TOKEN_NUM_INITIALIZER
15562 (struct cmd_config_per_queue_rx_offload_result,
15563 queue_id, RTE_UINT16);
15564 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
15565 TOKEN_STRING_INITIALIZER
15566 (struct cmd_config_per_queue_rx_offload_result,
15567 rx_offload, "rx_offload");
15568 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
15569 TOKEN_STRING_INITIALIZER
15570 (struct cmd_config_per_queue_rx_offload_result,
15571 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
15572 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
15573 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
15574 "scatter#buffer_split#timestamp#security#keep_crc");
15575 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
15576 TOKEN_STRING_INITIALIZER
15577 (struct cmd_config_per_queue_rx_offload_result,
15581 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
15582 __rte_unused struct cmdline *cl,
15583 __rte_unused void *data)
15585 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
15586 struct rte_eth_dev_info dev_info;
15587 portid_t port_id = res->port_id;
15588 uint16_t queue_id = res->queue_id;
15589 struct rte_port *port = &ports[port_id];
15590 uint64_t single_offload;
15593 if (port->port_status != RTE_PORT_STOPPED) {
15594 printf("Error: Can't config offload when Port %d "
15595 "is not stopped\n", port_id);
15599 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15603 if (queue_id >= dev_info.nb_rx_queues) {
15604 printf("Error: input queue_id should be 0 ... "
15605 "%d\n", dev_info.nb_rx_queues - 1);
15609 single_offload = search_rx_offload(res->offload);
15610 if (single_offload == 0) {
15611 printf("Unknown offload name: %s\n", res->offload);
15615 if (!strcmp(res->on_off, "on"))
15616 port->rx_conf[queue_id].offloads |= single_offload;
15618 port->rx_conf[queue_id].offloads &= ~single_offload;
15620 cmd_reconfig_device_queue(port_id, 1, 1);
15623 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
15624 .f = cmd_config_per_queue_rx_offload_parsed,
15626 .help_str = "port <port_id> rxq <queue_id> rx_offload "
15627 "vlan_strip|ipv4_cksum|"
15628 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
15629 "macsec_strip|header_split|vlan_filter|vlan_extend|"
15630 "jumbo_frame|scatter|buffer_split|timestamp|security|"
15633 (void *)&cmd_config_per_queue_rx_offload_result_port,
15634 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
15635 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
15636 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
15637 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
15638 (void *)&cmd_config_per_queue_rx_offload_result_offload,
15639 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
15644 /* Get Tx offloads capabilities */
15645 struct cmd_tx_offload_get_capa_result {
15646 cmdline_fixed_string_t show;
15647 cmdline_fixed_string_t port;
15649 cmdline_fixed_string_t tx_offload;
15650 cmdline_fixed_string_t capabilities;
15653 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
15654 TOKEN_STRING_INITIALIZER
15655 (struct cmd_tx_offload_get_capa_result,
15657 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
15658 TOKEN_STRING_INITIALIZER
15659 (struct cmd_tx_offload_get_capa_result,
15661 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
15662 TOKEN_NUM_INITIALIZER
15663 (struct cmd_tx_offload_get_capa_result,
15664 port_id, RTE_UINT16);
15665 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
15666 TOKEN_STRING_INITIALIZER
15667 (struct cmd_tx_offload_get_capa_result,
15668 tx_offload, "tx_offload");
15669 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
15670 TOKEN_STRING_INITIALIZER
15671 (struct cmd_tx_offload_get_capa_result,
15672 capabilities, "capabilities");
15675 print_tx_offloads(uint64_t offloads)
15677 uint64_t single_offload;
15685 begin = __builtin_ctzll(offloads);
15686 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15688 single_offload = 1ULL << begin;
15689 for (bit = begin; bit < end; bit++) {
15690 if (offloads & single_offload)
15692 rte_eth_dev_tx_offload_name(single_offload));
15693 single_offload <<= 1;
15698 cmd_tx_offload_get_capa_parsed(
15699 void *parsed_result,
15700 __rte_unused struct cmdline *cl,
15701 __rte_unused void *data)
15703 struct cmd_tx_offload_get_capa_result *res = parsed_result;
15704 struct rte_eth_dev_info dev_info;
15705 portid_t port_id = res->port_id;
15706 uint64_t queue_offloads;
15707 uint64_t port_offloads;
15710 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15714 queue_offloads = dev_info.tx_queue_offload_capa;
15715 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
15717 printf("Tx Offloading Capabilities of port %d :\n", port_id);
15718 printf(" Per Queue :");
15719 print_tx_offloads(queue_offloads);
15722 printf(" Per Port :");
15723 print_tx_offloads(port_offloads);
15727 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
15728 .f = cmd_tx_offload_get_capa_parsed,
15730 .help_str = "show port <port_id> tx_offload capabilities",
15732 (void *)&cmd_tx_offload_get_capa_show,
15733 (void *)&cmd_tx_offload_get_capa_port,
15734 (void *)&cmd_tx_offload_get_capa_port_id,
15735 (void *)&cmd_tx_offload_get_capa_tx_offload,
15736 (void *)&cmd_tx_offload_get_capa_capabilities,
15741 /* Get Tx offloads configuration */
15742 struct cmd_tx_offload_get_configuration_result {
15743 cmdline_fixed_string_t show;
15744 cmdline_fixed_string_t port;
15746 cmdline_fixed_string_t tx_offload;
15747 cmdline_fixed_string_t configuration;
15750 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
15751 TOKEN_STRING_INITIALIZER
15752 (struct cmd_tx_offload_get_configuration_result,
15754 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
15755 TOKEN_STRING_INITIALIZER
15756 (struct cmd_tx_offload_get_configuration_result,
15758 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
15759 TOKEN_NUM_INITIALIZER
15760 (struct cmd_tx_offload_get_configuration_result,
15761 port_id, RTE_UINT16);
15762 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
15763 TOKEN_STRING_INITIALIZER
15764 (struct cmd_tx_offload_get_configuration_result,
15765 tx_offload, "tx_offload");
15766 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
15767 TOKEN_STRING_INITIALIZER
15768 (struct cmd_tx_offload_get_configuration_result,
15769 configuration, "configuration");
15772 cmd_tx_offload_get_configuration_parsed(
15773 void *parsed_result,
15774 __rte_unused struct cmdline *cl,
15775 __rte_unused void *data)
15777 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
15778 struct rte_eth_dev_info dev_info;
15779 portid_t port_id = res->port_id;
15780 struct rte_port *port = &ports[port_id];
15781 uint64_t port_offloads;
15782 uint64_t queue_offloads;
15783 uint16_t nb_tx_queues;
15787 printf("Tx Offloading Configuration of port %d :\n", port_id);
15789 port_offloads = port->dev_conf.txmode.offloads;
15791 print_tx_offloads(port_offloads);
15794 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15798 nb_tx_queues = dev_info.nb_tx_queues;
15799 for (q = 0; q < nb_tx_queues; q++) {
15800 queue_offloads = port->tx_conf[q].offloads;
15801 printf(" Queue[%2d] :", q);
15802 print_tx_offloads(queue_offloads);
15808 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
15809 .f = cmd_tx_offload_get_configuration_parsed,
15811 .help_str = "show port <port_id> tx_offload configuration",
15813 (void *)&cmd_tx_offload_get_configuration_show,
15814 (void *)&cmd_tx_offload_get_configuration_port,
15815 (void *)&cmd_tx_offload_get_configuration_port_id,
15816 (void *)&cmd_tx_offload_get_configuration_tx_offload,
15817 (void *)&cmd_tx_offload_get_configuration_configuration,
15822 /* Enable/Disable a per port offloading */
15823 struct cmd_config_per_port_tx_offload_result {
15824 cmdline_fixed_string_t port;
15825 cmdline_fixed_string_t config;
15827 cmdline_fixed_string_t tx_offload;
15828 cmdline_fixed_string_t offload;
15829 cmdline_fixed_string_t on_off;
15832 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
15833 TOKEN_STRING_INITIALIZER
15834 (struct cmd_config_per_port_tx_offload_result,
15836 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
15837 TOKEN_STRING_INITIALIZER
15838 (struct cmd_config_per_port_tx_offload_result,
15840 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
15841 TOKEN_NUM_INITIALIZER
15842 (struct cmd_config_per_port_tx_offload_result,
15843 port_id, RTE_UINT16);
15844 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
15845 TOKEN_STRING_INITIALIZER
15846 (struct cmd_config_per_port_tx_offload_result,
15847 tx_offload, "tx_offload");
15848 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
15849 TOKEN_STRING_INITIALIZER
15850 (struct cmd_config_per_port_tx_offload_result,
15851 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
15852 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
15853 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
15854 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
15855 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
15856 "send_on_timestamp");
15857 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
15858 TOKEN_STRING_INITIALIZER
15859 (struct cmd_config_per_port_tx_offload_result,
15863 search_tx_offload(const char *name)
15865 uint64_t single_offload;
15866 const char *single_name;
15870 single_offload = 1;
15871 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
15872 single_name = rte_eth_dev_tx_offload_name(single_offload);
15873 if (single_name == NULL)
15875 if (!strcasecmp(single_name, name)) {
15878 } else if (!strcasecmp(single_name, "UNKNOWN"))
15880 single_offload <<= 1;
15884 return single_offload;
15890 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
15891 __rte_unused struct cmdline *cl,
15892 __rte_unused void *data)
15894 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
15895 portid_t port_id = res->port_id;
15896 struct rte_eth_dev_info dev_info;
15897 struct rte_port *port = &ports[port_id];
15898 uint64_t single_offload;
15899 uint16_t nb_tx_queues;
15903 if (port->port_status != RTE_PORT_STOPPED) {
15904 printf("Error: Can't config offload when Port %d "
15905 "is not stopped\n", port_id);
15909 single_offload = search_tx_offload(res->offload);
15910 if (single_offload == 0) {
15911 printf("Unknown offload name: %s\n", res->offload);
15915 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15919 nb_tx_queues = dev_info.nb_tx_queues;
15920 if (!strcmp(res->on_off, "on")) {
15921 port->dev_conf.txmode.offloads |= single_offload;
15922 for (q = 0; q < nb_tx_queues; q++)
15923 port->tx_conf[q].offloads |= single_offload;
15925 port->dev_conf.txmode.offloads &= ~single_offload;
15926 for (q = 0; q < nb_tx_queues; q++)
15927 port->tx_conf[q].offloads &= ~single_offload;
15930 cmd_reconfig_device_queue(port_id, 1, 1);
15933 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
15934 .f = cmd_config_per_port_tx_offload_parsed,
15936 .help_str = "port config <port_id> tx_offload "
15937 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
15938 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
15939 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
15940 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
15941 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
15942 "send_on_timestamp on|off",
15944 (void *)&cmd_config_per_port_tx_offload_result_port,
15945 (void *)&cmd_config_per_port_tx_offload_result_config,
15946 (void *)&cmd_config_per_port_tx_offload_result_port_id,
15947 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
15948 (void *)&cmd_config_per_port_tx_offload_result_offload,
15949 (void *)&cmd_config_per_port_tx_offload_result_on_off,
15954 /* Enable/Disable a per queue offloading */
15955 struct cmd_config_per_queue_tx_offload_result {
15956 cmdline_fixed_string_t port;
15958 cmdline_fixed_string_t txq;
15960 cmdline_fixed_string_t tx_offload;
15961 cmdline_fixed_string_t offload;
15962 cmdline_fixed_string_t on_off;
15965 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
15966 TOKEN_STRING_INITIALIZER
15967 (struct cmd_config_per_queue_tx_offload_result,
15969 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
15970 TOKEN_NUM_INITIALIZER
15971 (struct cmd_config_per_queue_tx_offload_result,
15972 port_id, RTE_UINT16);
15973 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
15974 TOKEN_STRING_INITIALIZER
15975 (struct cmd_config_per_queue_tx_offload_result,
15977 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
15978 TOKEN_NUM_INITIALIZER
15979 (struct cmd_config_per_queue_tx_offload_result,
15980 queue_id, RTE_UINT16);
15981 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
15982 TOKEN_STRING_INITIALIZER
15983 (struct cmd_config_per_queue_tx_offload_result,
15984 tx_offload, "tx_offload");
15985 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
15986 TOKEN_STRING_INITIALIZER
15987 (struct cmd_config_per_queue_tx_offload_result,
15988 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
15989 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
15990 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
15991 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
15992 "mt_lockfree#multi_segs#mbuf_fast_free#security");
15993 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
15994 TOKEN_STRING_INITIALIZER
15995 (struct cmd_config_per_queue_tx_offload_result,
15999 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16000 __rte_unused struct cmdline *cl,
16001 __rte_unused void *data)
16003 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16004 struct rte_eth_dev_info dev_info;
16005 portid_t port_id = res->port_id;
16006 uint16_t queue_id = res->queue_id;
16007 struct rte_port *port = &ports[port_id];
16008 uint64_t single_offload;
16011 if (port->port_status != RTE_PORT_STOPPED) {
16012 printf("Error: Can't config offload when Port %d "
16013 "is not stopped\n", port_id);
16017 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16021 if (queue_id >= dev_info.nb_tx_queues) {
16022 printf("Error: input queue_id should be 0 ... "
16023 "%d\n", dev_info.nb_tx_queues - 1);
16027 single_offload = search_tx_offload(res->offload);
16028 if (single_offload == 0) {
16029 printf("Unknown offload name: %s\n", res->offload);
16033 if (!strcmp(res->on_off, "on"))
16034 port->tx_conf[queue_id].offloads |= single_offload;
16036 port->tx_conf[queue_id].offloads &= ~single_offload;
16038 cmd_reconfig_device_queue(port_id, 1, 1);
16041 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16042 .f = cmd_config_per_queue_tx_offload_parsed,
16044 .help_str = "port <port_id> txq <queue_id> tx_offload "
16045 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16046 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16047 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16048 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16049 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16052 (void *)&cmd_config_per_queue_tx_offload_result_port,
16053 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16054 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16055 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16056 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16057 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16058 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16063 /* *** configure tx_metadata for specific port *** */
16064 struct cmd_config_tx_metadata_specific_result {
16065 cmdline_fixed_string_t port;
16066 cmdline_fixed_string_t keyword;
16068 cmdline_fixed_string_t item;
16073 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16074 __rte_unused struct cmdline *cl,
16075 __rte_unused void *data)
16077 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16079 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16081 ports[res->port_id].tx_metadata = res->value;
16082 /* Add/remove callback to insert valid metadata in every Tx packet. */
16083 if (ports[res->port_id].tx_metadata)
16084 add_tx_md_callback(res->port_id);
16086 remove_tx_md_callback(res->port_id);
16087 rte_flow_dynf_metadata_register();
16090 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16091 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16093 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16094 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16095 keyword, "config");
16096 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16097 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16098 port_id, RTE_UINT16);
16099 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16100 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16101 item, "tx_metadata");
16102 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16103 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16104 value, RTE_UINT32);
16106 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16107 .f = cmd_config_tx_metadata_specific_parsed,
16109 .help_str = "port config <port_id> tx_metadata <value>",
16111 (void *)&cmd_config_tx_metadata_specific_port,
16112 (void *)&cmd_config_tx_metadata_specific_keyword,
16113 (void *)&cmd_config_tx_metadata_specific_id,
16114 (void *)&cmd_config_tx_metadata_specific_item,
16115 (void *)&cmd_config_tx_metadata_specific_value,
16120 /* *** set dynf *** */
16121 struct cmd_config_tx_dynf_specific_result {
16122 cmdline_fixed_string_t port;
16123 cmdline_fixed_string_t keyword;
16125 cmdline_fixed_string_t item;
16126 cmdline_fixed_string_t name;
16127 cmdline_fixed_string_t value;
16131 cmd_config_dynf_specific_parsed(void *parsed_result,
16132 __rte_unused struct cmdline *cl,
16133 __rte_unused void *data)
16135 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16136 struct rte_mbuf_dynflag desc_flag;
16138 uint64_t old_port_flags;
16140 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16142 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16144 if (strlcpy(desc_flag.name, res->name,
16145 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16146 printf("Flag name too long\n");
16149 desc_flag.flags = 0;
16150 flag = rte_mbuf_dynflag_register(&desc_flag);
16152 printf("Can't register flag\n");
16155 strcpy(dynf_names[flag], desc_flag.name);
16157 old_port_flags = ports[res->port_id].mbuf_dynf;
16158 if (!strcmp(res->value, "set")) {
16159 ports[res->port_id].mbuf_dynf |= 1UL << flag;
16160 if (old_port_flags == 0)
16161 add_tx_dynf_callback(res->port_id);
16163 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16164 if (ports[res->port_id].mbuf_dynf == 0)
16165 remove_tx_dynf_callback(res->port_id);
16169 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16170 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16172 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16173 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16174 keyword, "config");
16175 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
16176 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16177 port_id, RTE_UINT16);
16178 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
16179 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16181 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
16182 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16184 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
16185 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16186 value, "set#clear");
16188 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
16189 .f = cmd_config_dynf_specific_parsed,
16191 .help_str = "port config <port id> dynf <name> set|clear",
16193 (void *)&cmd_config_tx_dynf_specific_port,
16194 (void *)&cmd_config_tx_dynf_specific_keyword,
16195 (void *)&cmd_config_tx_dynf_specific_port_id,
16196 (void *)&cmd_config_tx_dynf_specific_item,
16197 (void *)&cmd_config_tx_dynf_specific_name,
16198 (void *)&cmd_config_tx_dynf_specific_value,
16203 /* *** display tx_metadata per port configuration *** */
16204 struct cmd_show_tx_metadata_result {
16205 cmdline_fixed_string_t cmd_show;
16206 cmdline_fixed_string_t cmd_port;
16207 cmdline_fixed_string_t cmd_keyword;
16212 cmd_show_tx_metadata_parsed(void *parsed_result,
16213 __rte_unused struct cmdline *cl,
16214 __rte_unused void *data)
16216 struct cmd_show_tx_metadata_result *res = parsed_result;
16218 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16219 printf("invalid port id %u\n", res->cmd_pid);
16222 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
16223 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
16224 ports[res->cmd_pid].tx_metadata);
16228 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
16229 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16231 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
16232 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16234 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
16235 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
16236 cmd_pid, RTE_UINT16);
16237 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
16238 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16239 cmd_keyword, "tx_metadata");
16241 cmdline_parse_inst_t cmd_show_tx_metadata = {
16242 .f = cmd_show_tx_metadata_parsed,
16244 .help_str = "show port <port_id> tx_metadata",
16246 (void *)&cmd_show_tx_metadata_show,
16247 (void *)&cmd_show_tx_metadata_port,
16248 (void *)&cmd_show_tx_metadata_pid,
16249 (void *)&cmd_show_tx_metadata_keyword,
16254 /* *** show fec capability per port configuration *** */
16255 struct cmd_show_fec_capability_result {
16256 cmdline_fixed_string_t cmd_show;
16257 cmdline_fixed_string_t cmd_port;
16258 cmdline_fixed_string_t cmd_fec;
16259 cmdline_fixed_string_t cmd_keyword;
16264 cmd_show_fec_capability_parsed(void *parsed_result,
16265 __rte_unused struct cmdline *cl,
16266 __rte_unused void *data)
16268 #define FEC_CAP_NUM 2
16269 struct cmd_show_fec_capability_result *res = parsed_result;
16270 struct rte_eth_fec_capa speed_fec_capa[FEC_CAP_NUM];
16271 unsigned int num = FEC_CAP_NUM;
16272 unsigned int ret_num;
16275 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16276 printf("Invalid port id %u\n", res->cmd_pid);
16280 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
16281 if (ret == -ENOTSUP) {
16282 printf("Function not implemented\n");
16284 } else if (ret < 0) {
16285 printf("Get FEC capability failed\n");
16289 ret_num = (unsigned int)ret;
16290 show_fec_capability(ret_num, speed_fec_capa);
16293 cmdline_parse_token_string_t cmd_show_fec_capability_show =
16294 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16296 cmdline_parse_token_string_t cmd_show_fec_capability_port =
16297 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16299 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
16300 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
16301 cmd_pid, RTE_UINT16);
16302 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
16303 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16305 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
16306 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16307 cmd_keyword, "capabilities");
16309 cmdline_parse_inst_t cmd_show_capability = {
16310 .f = cmd_show_fec_capability_parsed,
16312 .help_str = "show port <port_id> fec capabilities",
16314 (void *)&cmd_show_fec_capability_show,
16315 (void *)&cmd_show_fec_capability_port,
16316 (void *)&cmd_show_fec_capability_pid,
16317 (void *)&cmd_show_fec_capability_fec,
16318 (void *)&cmd_show_fec_capability_keyword,
16323 /* *** show fec mode per port configuration *** */
16324 struct cmd_show_fec_metadata_result {
16325 cmdline_fixed_string_t cmd_show;
16326 cmdline_fixed_string_t cmd_port;
16327 cmdline_fixed_string_t cmd_keyword;
16332 cmd_show_fec_mode_parsed(void *parsed_result,
16333 __rte_unused struct cmdline *cl,
16334 __rte_unused void *data)
16336 #define FEC_NAME_SIZE 16
16337 struct cmd_show_fec_metadata_result *res = parsed_result;
16339 char buf[FEC_NAME_SIZE];
16342 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16343 printf("Invalid port id %u\n", res->cmd_pid);
16346 ret = rte_eth_fec_get(res->cmd_pid, &mode);
16347 if (ret == -ENOTSUP) {
16348 printf("Function not implemented\n");
16350 } else if (ret < 0) {
16351 printf("Get FEC mode failed\n");
16356 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
16357 strlcpy(buf, "off", sizeof(buf));
16359 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
16360 strlcpy(buf, "auto", sizeof(buf));
16362 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
16363 strlcpy(buf, "baser", sizeof(buf));
16365 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
16366 strlcpy(buf, "rs", sizeof(buf));
16372 printf("%s\n", buf);
16375 cmdline_parse_token_string_t cmd_show_fec_mode_show =
16376 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16378 cmdline_parse_token_string_t cmd_show_fec_mode_port =
16379 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16381 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
16382 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
16383 cmd_pid, RTE_UINT16);
16384 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
16385 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16386 cmd_keyword, "fec_mode");
16388 cmdline_parse_inst_t cmd_show_fec_mode = {
16389 .f = cmd_show_fec_mode_parsed,
16391 .help_str = "show port <port_id> fec_mode",
16393 (void *)&cmd_show_fec_mode_show,
16394 (void *)&cmd_show_fec_mode_port,
16395 (void *)&cmd_show_fec_mode_pid,
16396 (void *)&cmd_show_fec_mode_keyword,
16401 /* *** set fec mode per port configuration *** */
16402 struct cmd_set_port_fec_mode {
16403 cmdline_fixed_string_t set;
16404 cmdline_fixed_string_t port;
16406 cmdline_fixed_string_t fec_mode;
16407 cmdline_fixed_string_t fec_value;
16410 /* Common CLI fields for set fec mode */
16411 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
16412 TOKEN_STRING_INITIALIZER
16413 (struct cmd_set_port_fec_mode,
16415 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
16416 TOKEN_STRING_INITIALIZER
16417 (struct cmd_set_port_fec_mode,
16419 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
16420 TOKEN_NUM_INITIALIZER
16421 (struct cmd_set_port_fec_mode,
16422 port_id, RTE_UINT16);
16423 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
16424 TOKEN_STRING_INITIALIZER
16425 (struct cmd_set_port_fec_mode,
16426 fec_mode, "fec_mode");
16427 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
16428 TOKEN_STRING_INITIALIZER
16429 (struct cmd_set_port_fec_mode,
16433 cmd_set_port_fec_mode_parsed(
16434 void *parsed_result,
16435 __rte_unused struct cmdline *cl,
16436 __rte_unused void *data)
16438 struct cmd_set_port_fec_mode *res = parsed_result;
16439 uint16_t port_id = res->port_id;
16443 ret = parse_fec_mode(res->fec_value, &mode);
16445 printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
16450 ret = rte_eth_fec_set(port_id, mode);
16451 if (ret == -ENOTSUP) {
16452 printf("Function not implemented\n");
16454 } else if (ret < 0) {
16455 printf("Set FEC mode failed\n");
16460 cmdline_parse_inst_t cmd_set_fec_mode = {
16461 .f = cmd_set_port_fec_mode_parsed,
16463 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
16465 (void *)&cmd_set_port_fec_mode_set,
16466 (void *)&cmd_set_port_fec_mode_port,
16467 (void *)&cmd_set_port_fec_mode_port_id,
16468 (void *)&cmd_set_port_fec_mode_str,
16469 (void *)&cmd_set_port_fec_mode_value,
16474 /* show port supported ptypes */
16476 /* Common result structure for show port ptypes */
16477 struct cmd_show_port_supported_ptypes_result {
16478 cmdline_fixed_string_t show;
16479 cmdline_fixed_string_t port;
16481 cmdline_fixed_string_t ptypes;
16484 /* Common CLI fields for show port ptypes */
16485 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
16486 TOKEN_STRING_INITIALIZER
16487 (struct cmd_show_port_supported_ptypes_result,
16489 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
16490 TOKEN_STRING_INITIALIZER
16491 (struct cmd_show_port_supported_ptypes_result,
16493 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
16494 TOKEN_NUM_INITIALIZER
16495 (struct cmd_show_port_supported_ptypes_result,
16496 port_id, RTE_UINT16);
16497 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
16498 TOKEN_STRING_INITIALIZER
16499 (struct cmd_show_port_supported_ptypes_result,
16503 cmd_show_port_supported_ptypes_parsed(
16504 void *parsed_result,
16505 __rte_unused struct cmdline *cl,
16506 __rte_unused void *data)
16508 #define RSVD_PTYPE_MASK 0xf0000000
16509 #define MAX_PTYPES_PER_LAYER 16
16510 #define LTYPE_NAMESIZE 32
16511 #define PTYPE_NAMESIZE 256
16512 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
16513 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
16514 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
16515 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
16516 uint16_t port_id = res->port_id;
16519 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
16523 while (ptype_mask != RSVD_PTYPE_MASK) {
16525 switch (ptype_mask) {
16526 case RTE_PTYPE_L2_MASK:
16527 strlcpy(ltype, "L2", sizeof(ltype));
16529 case RTE_PTYPE_L3_MASK:
16530 strlcpy(ltype, "L3", sizeof(ltype));
16532 case RTE_PTYPE_L4_MASK:
16533 strlcpy(ltype, "L4", sizeof(ltype));
16535 case RTE_PTYPE_TUNNEL_MASK:
16536 strlcpy(ltype, "Tunnel", sizeof(ltype));
16538 case RTE_PTYPE_INNER_L2_MASK:
16539 strlcpy(ltype, "Inner L2", sizeof(ltype));
16541 case RTE_PTYPE_INNER_L3_MASK:
16542 strlcpy(ltype, "Inner L3", sizeof(ltype));
16544 case RTE_PTYPE_INNER_L4_MASK:
16545 strlcpy(ltype, "Inner L4", sizeof(ltype));
16551 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
16552 ptype_mask, ptypes,
16553 MAX_PTYPES_PER_LAYER);
16556 printf("Supported %s ptypes:\n", ltype);
16558 printf("%s ptypes unsupported\n", ltype);
16560 for (i = 0; i < ret; ++i) {
16561 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
16562 printf("%s\n", buf);
16569 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
16570 .f = cmd_show_port_supported_ptypes_parsed,
16572 .help_str = "show port <port_id> ptypes",
16574 (void *)&cmd_show_port_supported_ptypes_show,
16575 (void *)&cmd_show_port_supported_ptypes_port,
16576 (void *)&cmd_show_port_supported_ptypes_port_id,
16577 (void *)&cmd_show_port_supported_ptypes_ptypes,
16582 /* *** display rx/tx descriptor status *** */
16583 struct cmd_show_rx_tx_desc_status_result {
16584 cmdline_fixed_string_t cmd_show;
16585 cmdline_fixed_string_t cmd_port;
16586 cmdline_fixed_string_t cmd_keyword;
16587 cmdline_fixed_string_t cmd_desc;
16588 cmdline_fixed_string_t cmd_status;
16595 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
16596 __rte_unused struct cmdline *cl,
16597 __rte_unused void *data)
16599 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
16602 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16603 printf("invalid port id %u\n", res->cmd_pid);
16607 if (!strcmp(res->cmd_keyword, "rxq")) {
16608 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
16611 printf("Invalid queueid = %d\n", res->cmd_qid);
16614 if (rc == RTE_ETH_RX_DESC_AVAIL)
16615 printf("Desc status = AVAILABLE\n");
16616 else if (rc == RTE_ETH_RX_DESC_DONE)
16617 printf("Desc status = DONE\n");
16619 printf("Desc status = UNAVAILABLE\n");
16620 } else if (!strcmp(res->cmd_keyword, "txq")) {
16621 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
16624 printf("Invalid queueid = %d\n", res->cmd_qid);
16627 if (rc == RTE_ETH_TX_DESC_FULL)
16628 printf("Desc status = FULL\n");
16629 else if (rc == RTE_ETH_TX_DESC_DONE)
16630 printf("Desc status = DONE\n");
16632 printf("Desc status = UNAVAILABLE\n");
16636 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
16637 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16639 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
16640 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16642 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
16643 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16644 cmd_pid, RTE_UINT16);
16645 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
16646 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16647 cmd_keyword, "rxq#txq");
16648 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
16649 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16650 cmd_qid, RTE_UINT16);
16651 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
16652 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16654 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
16655 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16656 cmd_did, RTE_UINT16);
16657 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
16658 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16659 cmd_status, "status");
16660 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
16661 .f = cmd_show_rx_tx_desc_status_parsed,
16663 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
16666 (void *)&cmd_show_rx_tx_desc_status_show,
16667 (void *)&cmd_show_rx_tx_desc_status_port,
16668 (void *)&cmd_show_rx_tx_desc_status_pid,
16669 (void *)&cmd_show_rx_tx_desc_status_keyword,
16670 (void *)&cmd_show_rx_tx_desc_status_qid,
16671 (void *)&cmd_show_rx_tx_desc_status_desc,
16672 (void *)&cmd_show_rx_tx_desc_status_did,
16673 (void *)&cmd_show_rx_tx_desc_status_status,
16678 /* Common result structure for set port ptypes */
16679 struct cmd_set_port_ptypes_result {
16680 cmdline_fixed_string_t set;
16681 cmdline_fixed_string_t port;
16683 cmdline_fixed_string_t ptype_mask;
16687 /* Common CLI fields for set port ptypes */
16688 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
16689 TOKEN_STRING_INITIALIZER
16690 (struct cmd_set_port_ptypes_result,
16692 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
16693 TOKEN_STRING_INITIALIZER
16694 (struct cmd_set_port_ptypes_result,
16696 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
16697 TOKEN_NUM_INITIALIZER
16698 (struct cmd_set_port_ptypes_result,
16699 port_id, RTE_UINT16);
16700 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
16701 TOKEN_STRING_INITIALIZER
16702 (struct cmd_set_port_ptypes_result,
16703 ptype_mask, "ptype_mask");
16704 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
16705 TOKEN_NUM_INITIALIZER
16706 (struct cmd_set_port_ptypes_result,
16710 cmd_set_port_ptypes_parsed(
16711 void *parsed_result,
16712 __rte_unused struct cmdline *cl,
16713 __rte_unused void *data)
16715 struct cmd_set_port_ptypes_result *res = parsed_result;
16716 #define PTYPE_NAMESIZE 256
16717 char ptype_name[PTYPE_NAMESIZE];
16718 uint16_t port_id = res->port_id;
16719 uint32_t ptype_mask = res->mask;
16722 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
16725 printf("Port %d doesn't support any ptypes.\n", port_id);
16729 uint32_t ptypes[ret];
16731 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
16733 printf("Unable to set requested ptypes for Port %d\n", port_id);
16737 printf("Successfully set following ptypes for Port %d\n", port_id);
16738 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
16739 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
16740 printf("%s\n", ptype_name);
16743 clear_ptypes = false;
16746 cmdline_parse_inst_t cmd_set_port_ptypes = {
16747 .f = cmd_set_port_ptypes_parsed,
16749 .help_str = "set port <port_id> ptype_mask <mask>",
16751 (void *)&cmd_set_port_ptypes_set,
16752 (void *)&cmd_set_port_ptypes_port,
16753 (void *)&cmd_set_port_ptypes_port_id,
16754 (void *)&cmd_set_port_ptypes_mask_str,
16755 (void *)&cmd_set_port_ptypes_mask_u32,
16760 /* *** display mac addresses added to a port *** */
16761 struct cmd_showport_macs_result {
16762 cmdline_fixed_string_t cmd_show;
16763 cmdline_fixed_string_t cmd_port;
16764 cmdline_fixed_string_t cmd_keyword;
16769 cmd_showport_macs_parsed(void *parsed_result,
16770 __rte_unused struct cmdline *cl,
16771 __rte_unused void *data)
16773 struct cmd_showport_macs_result *res = parsed_result;
16775 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
16778 if (!strcmp(res->cmd_keyword, "macs"))
16779 show_macs(res->cmd_pid);
16780 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
16781 show_mcast_macs(res->cmd_pid);
16784 cmdline_parse_token_string_t cmd_showport_macs_show =
16785 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
16787 cmdline_parse_token_string_t cmd_showport_macs_port =
16788 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
16790 cmdline_parse_token_num_t cmd_showport_macs_pid =
16791 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
16792 cmd_pid, RTE_UINT16);
16793 cmdline_parse_token_string_t cmd_showport_macs_keyword =
16794 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
16795 cmd_keyword, "macs#mcast_macs");
16797 cmdline_parse_inst_t cmd_showport_macs = {
16798 .f = cmd_showport_macs_parsed,
16800 .help_str = "show port <port_id> macs|mcast_macs",
16802 (void *)&cmd_showport_macs_show,
16803 (void *)&cmd_showport_macs_port,
16804 (void *)&cmd_showport_macs_pid,
16805 (void *)&cmd_showport_macs_keyword,
16810 /* ******************************************************************************** */
16812 /* list of instructions */
16813 cmdline_parse_ctx_t main_ctx[] = {
16814 (cmdline_parse_inst_t *)&cmd_help_brief,
16815 (cmdline_parse_inst_t *)&cmd_help_long,
16816 (cmdline_parse_inst_t *)&cmd_quit,
16817 (cmdline_parse_inst_t *)&cmd_load_from_file,
16818 (cmdline_parse_inst_t *)&cmd_showport,
16819 (cmdline_parse_inst_t *)&cmd_showqueue,
16820 (cmdline_parse_inst_t *)&cmd_showeeprom,
16821 (cmdline_parse_inst_t *)&cmd_showportall,
16822 (cmdline_parse_inst_t *)&cmd_showdevice,
16823 (cmdline_parse_inst_t *)&cmd_showcfg,
16824 (cmdline_parse_inst_t *)&cmd_showfwdall,
16825 (cmdline_parse_inst_t *)&cmd_start,
16826 (cmdline_parse_inst_t *)&cmd_start_tx_first,
16827 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
16828 (cmdline_parse_inst_t *)&cmd_set_link_up,
16829 (cmdline_parse_inst_t *)&cmd_set_link_down,
16830 (cmdline_parse_inst_t *)&cmd_reset,
16831 (cmdline_parse_inst_t *)&cmd_set_numbers,
16832 (cmdline_parse_inst_t *)&cmd_set_log,
16833 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
16834 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
16835 (cmdline_parse_inst_t *)&cmd_set_txpkts,
16836 (cmdline_parse_inst_t *)&cmd_set_txsplit,
16837 (cmdline_parse_inst_t *)&cmd_set_txtimes,
16838 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
16839 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
16840 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
16841 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
16842 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
16843 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
16844 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
16845 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
16846 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
16847 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
16848 (cmdline_parse_inst_t *)&cmd_set_link_check,
16849 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
16850 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
16851 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
16852 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
16853 #ifdef RTE_NET_BOND
16854 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
16855 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
16856 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
16857 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
16858 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
16859 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
16860 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
16861 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
16862 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
16863 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
16864 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
16866 (cmdline_parse_inst_t *)&cmd_vlan_offload,
16867 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
16868 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
16869 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
16870 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
16871 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
16872 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
16873 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
16874 (cmdline_parse_inst_t *)&cmd_csum_set,
16875 (cmdline_parse_inst_t *)&cmd_csum_show,
16876 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
16877 (cmdline_parse_inst_t *)&cmd_tso_set,
16878 (cmdline_parse_inst_t *)&cmd_tso_show,
16879 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
16880 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
16881 (cmdline_parse_inst_t *)&cmd_gro_enable,
16882 (cmdline_parse_inst_t *)&cmd_gro_flush,
16883 (cmdline_parse_inst_t *)&cmd_gro_show,
16884 (cmdline_parse_inst_t *)&cmd_gso_enable,
16885 (cmdline_parse_inst_t *)&cmd_gso_size,
16886 (cmdline_parse_inst_t *)&cmd_gso_show,
16887 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
16888 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
16889 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
16890 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
16891 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
16892 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
16893 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
16894 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
16895 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
16896 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
16897 (cmdline_parse_inst_t *)&cmd_config_dcb,
16898 (cmdline_parse_inst_t *)&cmd_read_reg,
16899 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
16900 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
16901 (cmdline_parse_inst_t *)&cmd_write_reg,
16902 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
16903 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
16904 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
16905 (cmdline_parse_inst_t *)&cmd_stop,
16906 (cmdline_parse_inst_t *)&cmd_mac_addr,
16907 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
16908 (cmdline_parse_inst_t *)&cmd_set_qmap,
16909 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
16910 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
16911 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
16912 (cmdline_parse_inst_t *)&cmd_operate_port,
16913 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
16914 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
16915 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
16916 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
16917 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
16918 (cmdline_parse_inst_t *)&cmd_config_speed_all,
16919 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
16920 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
16921 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
16922 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
16923 (cmdline_parse_inst_t *)&cmd_config_mtu,
16924 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
16925 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
16926 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
16927 (cmdline_parse_inst_t *)&cmd_config_rss,
16928 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
16929 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
16930 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
16931 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
16932 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
16933 (cmdline_parse_inst_t *)&cmd_showport_reta,
16934 (cmdline_parse_inst_t *)&cmd_showport_macs,
16935 (cmdline_parse_inst_t *)&cmd_config_burst,
16936 (cmdline_parse_inst_t *)&cmd_config_thresh,
16937 (cmdline_parse_inst_t *)&cmd_config_threshold,
16938 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
16939 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
16940 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
16941 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
16942 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
16943 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
16944 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
16945 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
16946 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
16947 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
16948 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
16949 (cmdline_parse_inst_t *)&cmd_dump,
16950 (cmdline_parse_inst_t *)&cmd_dump_one,
16951 #ifdef RTE_NET_I40E
16952 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
16954 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
16955 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
16956 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
16957 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
16958 (cmdline_parse_inst_t *)&cmd_flow,
16959 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
16960 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
16961 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
16962 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
16963 (cmdline_parse_inst_t *)&cmd_create_port_meter,
16964 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
16965 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
16966 (cmdline_parse_inst_t *)&cmd_del_port_meter,
16967 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
16968 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
16969 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
16970 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
16971 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
16972 (cmdline_parse_inst_t *)&cmd_mcast_addr,
16973 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
16974 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
16975 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
16976 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
16977 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
16978 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
16979 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
16980 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
16981 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
16982 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
16983 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
16984 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
16985 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
16986 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
16987 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
16988 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
16989 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
16990 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
16991 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
16992 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
16993 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
16994 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
16995 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
16996 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
16997 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
16998 (cmdline_parse_inst_t *)&cmd_set_vxlan,
16999 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
17000 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17001 (cmdline_parse_inst_t *)&cmd_set_nvgre,
17002 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17003 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
17004 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
17005 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
17006 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
17007 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
17008 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
17009 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
17010 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
17011 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
17012 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
17013 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
17014 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
17015 (cmdline_parse_inst_t *)&cmd_ddp_add,
17016 (cmdline_parse_inst_t *)&cmd_ddp_del,
17017 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
17018 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
17019 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
17020 (cmdline_parse_inst_t *)&cmd_clear_input_set,
17021 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
17022 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17023 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
17024 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
17025 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17026 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17027 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17028 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17030 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17031 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17032 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17033 (cmdline_parse_inst_t *)&cmd_queue_region,
17034 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17035 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17036 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17037 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17038 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17039 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17040 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17041 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17042 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17043 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17044 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17045 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17046 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17047 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17048 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17049 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17050 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17051 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
17052 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17053 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17054 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17055 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17056 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17057 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17058 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
17059 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
17060 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
17061 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17062 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17063 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17064 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17065 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17066 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17067 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17068 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17069 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17071 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17072 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17074 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
17075 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
17076 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
17077 (cmdline_parse_inst_t *)&cmd_set_raw,
17078 (cmdline_parse_inst_t *)&cmd_show_set_raw,
17079 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
17080 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
17081 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
17082 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
17083 (cmdline_parse_inst_t *)&cmd_show_capability,
17087 /* read cmdline commands from file */
17089 cmdline_read_from_file(const char *filename)
17091 struct cmdline *cl;
17093 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17095 printf("Failed to create file based cmdline context: %s\n",
17100 cmdline_interact(cl);
17105 printf("Read CLI commands from %s\n", filename);
17108 /* prompt function, called from main on MAIN lcore */
17112 /* initialize non-constant commands */
17113 cmd_set_fwd_mode_init();
17114 cmd_set_fwd_retry_mode_init();
17116 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17117 if (testpmd_cl == NULL)
17119 cmdline_interact(testpmd_cl);
17120 cmdline_stdin_exit(testpmd_cl);
17126 if (testpmd_cl != NULL)
17127 cmdline_quit(testpmd_cl);
17131 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17133 if (id == (portid_t)RTE_PORT_ALL) {
17136 RTE_ETH_FOREACH_DEV(pid) {
17137 /* check if need_reconfig has been set to 1 */
17138 if (ports[pid].need_reconfig == 0)
17139 ports[pid].need_reconfig = dev;
17140 /* check if need_reconfig_queues has been set to 1 */
17141 if (ports[pid].need_reconfig_queues == 0)
17142 ports[pid].need_reconfig_queues = queue;
17144 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17145 /* check if need_reconfig has been set to 1 */
17146 if (ports[id].need_reconfig == 0)
17147 ports[id].need_reconfig = dev;
17148 /* check if need_reconfig_queues has been set to 1 */
17149 if (ports[id].need_reconfig_queues == 0)
17150 ports[id].need_reconfig_queues = queue;