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|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) (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|ecpri|mpls|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|ecpri (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];
1890 if (!strcmp(res->name, "max-pkt-len")) {
1891 if (res->value < RTE_ETHER_MIN_LEN) {
1892 printf("max-pkt-len can not be less than %d\n",
1896 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1899 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1901 printf("Unknown parameter\n");
1908 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1911 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1912 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1914 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1915 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1917 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1918 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1920 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1921 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1923 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1924 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1927 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1928 .f = cmd_config_max_pkt_len_parsed,
1930 .help_str = "port config all max-pkt-len <value>",
1932 (void *)&cmd_config_max_pkt_len_port,
1933 (void *)&cmd_config_max_pkt_len_keyword,
1934 (void *)&cmd_config_max_pkt_len_all,
1935 (void *)&cmd_config_max_pkt_len_name,
1936 (void *)&cmd_config_max_pkt_len_value,
1941 /* *** config max LRO aggregated packet size *** */
1942 struct cmd_config_max_lro_pkt_size_result {
1943 cmdline_fixed_string_t port;
1944 cmdline_fixed_string_t keyword;
1945 cmdline_fixed_string_t all;
1946 cmdline_fixed_string_t name;
1951 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1952 __rte_unused struct cmdline *cl,
1953 __rte_unused void *data)
1955 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1958 if (!all_ports_stopped()) {
1959 printf("Please stop all ports first\n");
1963 RTE_ETH_FOREACH_DEV(pid) {
1964 struct rte_port *port = &ports[pid];
1966 if (!strcmp(res->name, "max-lro-pkt-size")) {
1968 port->dev_conf.rxmode.max_lro_pkt_size)
1971 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
1973 printf("Unknown parameter\n");
1980 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1983 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
1984 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1986 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
1987 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1989 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
1990 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1992 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
1993 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1994 name, "max-lro-pkt-size");
1995 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
1996 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1999 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2000 .f = cmd_config_max_lro_pkt_size_parsed,
2002 .help_str = "port config all max-lro-pkt-size <value>",
2004 (void *)&cmd_config_max_lro_pkt_size_port,
2005 (void *)&cmd_config_max_lro_pkt_size_keyword,
2006 (void *)&cmd_config_max_lro_pkt_size_all,
2007 (void *)&cmd_config_max_lro_pkt_size_name,
2008 (void *)&cmd_config_max_lro_pkt_size_value,
2013 /* *** configure port MTU *** */
2014 struct cmd_config_mtu_result {
2015 cmdline_fixed_string_t port;
2016 cmdline_fixed_string_t keyword;
2017 cmdline_fixed_string_t mtu;
2023 cmd_config_mtu_parsed(void *parsed_result,
2024 __rte_unused struct cmdline *cl,
2025 __rte_unused void *data)
2027 struct cmd_config_mtu_result *res = parsed_result;
2029 if (res->value < RTE_ETHER_MIN_LEN) {
2030 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2033 port_mtu_set(res->port_id, res->value);
2036 cmdline_parse_token_string_t cmd_config_mtu_port =
2037 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2039 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2040 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2042 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2043 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2045 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2046 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2048 cmdline_parse_token_num_t cmd_config_mtu_value =
2049 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2052 cmdline_parse_inst_t cmd_config_mtu = {
2053 .f = cmd_config_mtu_parsed,
2055 .help_str = "port config mtu <port_id> <value>",
2057 (void *)&cmd_config_mtu_port,
2058 (void *)&cmd_config_mtu_keyword,
2059 (void *)&cmd_config_mtu_mtu,
2060 (void *)&cmd_config_mtu_port_id,
2061 (void *)&cmd_config_mtu_value,
2066 /* *** configure rx mode *** */
2067 struct cmd_config_rx_mode_flag {
2068 cmdline_fixed_string_t port;
2069 cmdline_fixed_string_t keyword;
2070 cmdline_fixed_string_t all;
2071 cmdline_fixed_string_t name;
2072 cmdline_fixed_string_t value;
2076 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2077 __rte_unused struct cmdline *cl,
2078 __rte_unused void *data)
2080 struct cmd_config_rx_mode_flag *res = parsed_result;
2082 if (!all_ports_stopped()) {
2083 printf("Please stop all ports first\n");
2087 if (!strcmp(res->name, "drop-en")) {
2088 if (!strcmp(res->value, "on"))
2090 else if (!strcmp(res->value, "off"))
2093 printf("Unknown parameter\n");
2097 printf("Unknown parameter\n");
2103 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2106 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2107 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2108 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2109 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2111 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2112 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2113 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2114 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2116 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2117 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2120 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2121 .f = cmd_config_rx_mode_flag_parsed,
2123 .help_str = "port config all drop-en on|off",
2125 (void *)&cmd_config_rx_mode_flag_port,
2126 (void *)&cmd_config_rx_mode_flag_keyword,
2127 (void *)&cmd_config_rx_mode_flag_all,
2128 (void *)&cmd_config_rx_mode_flag_name,
2129 (void *)&cmd_config_rx_mode_flag_value,
2134 /* *** configure rss *** */
2135 struct cmd_config_rss {
2136 cmdline_fixed_string_t port;
2137 cmdline_fixed_string_t keyword;
2138 cmdline_fixed_string_t all;
2139 cmdline_fixed_string_t name;
2140 cmdline_fixed_string_t value;
2144 cmd_config_rss_parsed(void *parsed_result,
2145 __rte_unused struct cmdline *cl,
2146 __rte_unused void *data)
2148 struct cmd_config_rss *res = parsed_result;
2149 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2150 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2151 int use_default = 0;
2152 int all_updated = 1;
2157 if (!strcmp(res->value, "all"))
2158 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2159 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2160 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2161 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU |
2163 else if (!strcmp(res->value, "eth"))
2164 rss_conf.rss_hf = ETH_RSS_ETH;
2165 else if (!strcmp(res->value, "vlan"))
2166 rss_conf.rss_hf = ETH_RSS_VLAN;
2167 else if (!strcmp(res->value, "ip"))
2168 rss_conf.rss_hf = ETH_RSS_IP;
2169 else if (!strcmp(res->value, "udp"))
2170 rss_conf.rss_hf = ETH_RSS_UDP;
2171 else if (!strcmp(res->value, "tcp"))
2172 rss_conf.rss_hf = ETH_RSS_TCP;
2173 else if (!strcmp(res->value, "sctp"))
2174 rss_conf.rss_hf = ETH_RSS_SCTP;
2175 else if (!strcmp(res->value, "ether"))
2176 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2177 else if (!strcmp(res->value, "port"))
2178 rss_conf.rss_hf = ETH_RSS_PORT;
2179 else if (!strcmp(res->value, "vxlan"))
2180 rss_conf.rss_hf = ETH_RSS_VXLAN;
2181 else if (!strcmp(res->value, "geneve"))
2182 rss_conf.rss_hf = ETH_RSS_GENEVE;
2183 else if (!strcmp(res->value, "nvgre"))
2184 rss_conf.rss_hf = ETH_RSS_NVGRE;
2185 else if (!strcmp(res->value, "l3-pre32"))
2186 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2187 else if (!strcmp(res->value, "l3-pre40"))
2188 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2189 else if (!strcmp(res->value, "l3-pre48"))
2190 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2191 else if (!strcmp(res->value, "l3-pre56"))
2192 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2193 else if (!strcmp(res->value, "l3-pre64"))
2194 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2195 else if (!strcmp(res->value, "l3-pre96"))
2196 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2197 else if (!strcmp(res->value, "l3-src-only"))
2198 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2199 else if (!strcmp(res->value, "l3-dst-only"))
2200 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2201 else if (!strcmp(res->value, "l4-src-only"))
2202 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2203 else if (!strcmp(res->value, "l4-dst-only"))
2204 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2205 else if (!strcmp(res->value, "l2-src-only"))
2206 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2207 else if (!strcmp(res->value, "l2-dst-only"))
2208 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2209 else if (!strcmp(res->value, "l2tpv3"))
2210 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2211 else if (!strcmp(res->value, "esp"))
2212 rss_conf.rss_hf = ETH_RSS_ESP;
2213 else if (!strcmp(res->value, "ah"))
2214 rss_conf.rss_hf = ETH_RSS_AH;
2215 else if (!strcmp(res->value, "pfcp"))
2216 rss_conf.rss_hf = ETH_RSS_PFCP;
2217 else if (!strcmp(res->value, "pppoe"))
2218 rss_conf.rss_hf = ETH_RSS_PPPOE;
2219 else if (!strcmp(res->value, "gtpu"))
2220 rss_conf.rss_hf = ETH_RSS_GTPU;
2221 else if (!strcmp(res->value, "ecpri"))
2222 rss_conf.rss_hf = ETH_RSS_ECPRI;
2223 else if (!strcmp(res->value, "mpls"))
2224 rss_conf.rss_hf = ETH_RSS_MPLS;
2225 else if (!strcmp(res->value, "none"))
2226 rss_conf.rss_hf = 0;
2227 else if (!strcmp(res->value, "level-default")) {
2228 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2229 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2230 } else if (!strcmp(res->value, "level-outer")) {
2231 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2232 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2233 } else if (!strcmp(res->value, "level-inner")) {
2234 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2235 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2236 } else if (!strcmp(res->value, "default"))
2238 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2239 atoi(res->value) < 64)
2240 rss_conf.rss_hf = 1ULL << atoi(res->value);
2242 printf("Unknown parameter\n");
2245 rss_conf.rss_key = NULL;
2246 /* Update global configuration for RSS types. */
2247 RTE_ETH_FOREACH_DEV(i) {
2248 struct rte_eth_rss_conf local_rss_conf;
2250 ret = eth_dev_info_get_print_err(i, &dev_info);
2255 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2257 local_rss_conf = rss_conf;
2258 local_rss_conf.rss_hf = rss_conf.rss_hf &
2259 dev_info.flow_type_rss_offloads;
2260 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2261 printf("Port %u modified RSS hash function based on hardware support,"
2262 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2263 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2265 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2268 printf("Configuration of RSS hash at ethernet port %d "
2269 "failed with error (%d): %s.\n",
2270 i, -diag, strerror(-diag));
2273 if (all_updated && !use_default) {
2274 rss_hf = rss_conf.rss_hf;
2275 printf("rss_hf %#"PRIx64"\n", rss_hf);
2279 cmdline_parse_token_string_t cmd_config_rss_port =
2280 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2281 cmdline_parse_token_string_t cmd_config_rss_keyword =
2282 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2283 cmdline_parse_token_string_t cmd_config_rss_all =
2284 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2285 cmdline_parse_token_string_t cmd_config_rss_name =
2286 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2287 cmdline_parse_token_string_t cmd_config_rss_value =
2288 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2290 cmdline_parse_inst_t cmd_config_rss = {
2291 .f = cmd_config_rss_parsed,
2293 .help_str = "port config all rss "
2294 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2295 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none|level-default|"
2296 "level-outer|level-inner|<flowtype_id>",
2298 (void *)&cmd_config_rss_port,
2299 (void *)&cmd_config_rss_keyword,
2300 (void *)&cmd_config_rss_all,
2301 (void *)&cmd_config_rss_name,
2302 (void *)&cmd_config_rss_value,
2307 /* *** configure rss hash key *** */
2308 struct cmd_config_rss_hash_key {
2309 cmdline_fixed_string_t port;
2310 cmdline_fixed_string_t config;
2312 cmdline_fixed_string_t rss_hash_key;
2313 cmdline_fixed_string_t rss_type;
2314 cmdline_fixed_string_t key;
2318 hexa_digit_to_value(char hexa_digit)
2320 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2321 return (uint8_t) (hexa_digit - '0');
2322 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2323 return (uint8_t) ((hexa_digit - 'a') + 10);
2324 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2325 return (uint8_t) ((hexa_digit - 'A') + 10);
2326 /* Invalid hexa digit */
2331 parse_and_check_key_hexa_digit(char *key, int idx)
2335 hexa_v = hexa_digit_to_value(key[idx]);
2337 printf("invalid key: character %c at position %d is not a "
2338 "valid hexa digit\n", key[idx], idx);
2343 cmd_config_rss_hash_key_parsed(void *parsed_result,
2344 __rte_unused struct cmdline *cl,
2345 __rte_unused void *data)
2347 struct cmd_config_rss_hash_key *res = parsed_result;
2348 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2352 struct rte_eth_dev_info dev_info;
2353 uint8_t hash_key_size;
2357 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2361 if (dev_info.hash_key_size > 0 &&
2362 dev_info.hash_key_size <= sizeof(hash_key))
2363 hash_key_size = dev_info.hash_key_size;
2365 printf("dev_info did not provide a valid hash key size\n");
2368 /* Check the length of the RSS hash key */
2369 key_len = strlen(res->key);
2370 if (key_len != (hash_key_size * 2)) {
2371 printf("key length: %d invalid - key must be a string of %d"
2372 " hexa-decimal numbers\n",
2373 (int) key_len, hash_key_size * 2);
2376 /* Translate RSS hash key into binary representation */
2377 for (i = 0; i < hash_key_size; i++) {
2378 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2381 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2384 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2386 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2390 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2391 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2392 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2393 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2395 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2396 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2398 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2399 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2400 rss_hash_key, "rss-hash-key");
2401 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2402 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2403 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2404 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2405 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2406 "ipv6-tcp-ex#ipv6-udp-ex#"
2407 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2408 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2409 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri");
2410 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2411 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2413 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2414 .f = cmd_config_rss_hash_key_parsed,
2416 .help_str = "port config <port_id> rss-hash-key "
2417 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2418 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2419 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2420 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2421 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2422 "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri "
2423 "<string of hex digits (variable length, NIC dependent)>",
2425 (void *)&cmd_config_rss_hash_key_port,
2426 (void *)&cmd_config_rss_hash_key_config,
2427 (void *)&cmd_config_rss_hash_key_port_id,
2428 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2429 (void *)&cmd_config_rss_hash_key_rss_type,
2430 (void *)&cmd_config_rss_hash_key_value,
2435 /* *** configure port rxq/txq ring size *** */
2436 struct cmd_config_rxtx_ring_size {
2437 cmdline_fixed_string_t port;
2438 cmdline_fixed_string_t config;
2440 cmdline_fixed_string_t rxtxq;
2442 cmdline_fixed_string_t rsize;
2447 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2448 __rte_unused struct cmdline *cl,
2449 __rte_unused void *data)
2451 struct cmd_config_rxtx_ring_size *res = parsed_result;
2452 struct rte_port *port;
2455 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2458 if (res->portid == (portid_t)RTE_PORT_ALL) {
2459 printf("Invalid port id\n");
2463 port = &ports[res->portid];
2465 if (!strcmp(res->rxtxq, "rxq"))
2467 else if (!strcmp(res->rxtxq, "txq"))
2470 printf("Unknown parameter\n");
2474 if (isrx && rx_queue_id_is_invalid(res->qid))
2476 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2479 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2480 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2486 port->nb_rx_desc[res->qid] = res->size;
2488 port->nb_tx_desc[res->qid] = res->size;
2490 cmd_reconfig_device_queue(res->portid, 0, 1);
2493 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2494 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2496 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2497 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2499 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2500 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2501 portid, RTE_UINT16);
2502 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2503 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2505 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2506 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2508 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2509 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2510 rsize, "ring_size");
2511 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2512 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2515 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2516 .f = cmd_config_rxtx_ring_size_parsed,
2518 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2520 (void *)&cmd_config_rxtx_ring_size_port,
2521 (void *)&cmd_config_rxtx_ring_size_config,
2522 (void *)&cmd_config_rxtx_ring_size_portid,
2523 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2524 (void *)&cmd_config_rxtx_ring_size_qid,
2525 (void *)&cmd_config_rxtx_ring_size_rsize,
2526 (void *)&cmd_config_rxtx_ring_size_size,
2531 /* *** configure port rxq/txq start/stop *** */
2532 struct cmd_config_rxtx_queue {
2533 cmdline_fixed_string_t port;
2535 cmdline_fixed_string_t rxtxq;
2537 cmdline_fixed_string_t opname;
2541 cmd_config_rxtx_queue_parsed(void *parsed_result,
2542 __rte_unused struct cmdline *cl,
2543 __rte_unused void *data)
2545 struct cmd_config_rxtx_queue *res = parsed_result;
2550 if (test_done == 0) {
2551 printf("Please stop forwarding first\n");
2555 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2558 if (port_is_started(res->portid) != 1) {
2559 printf("Please start port %u first\n", res->portid);
2563 if (!strcmp(res->rxtxq, "rxq"))
2565 else if (!strcmp(res->rxtxq, "txq"))
2568 printf("Unknown parameter\n");
2572 if (isrx && rx_queue_id_is_invalid(res->qid))
2574 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2577 if (!strcmp(res->opname, "start"))
2579 else if (!strcmp(res->opname, "stop"))
2582 printf("Unknown parameter\n");
2586 if (isstart && isrx)
2587 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2588 else if (!isstart && isrx)
2589 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2590 else if (isstart && !isrx)
2591 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2593 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2595 if (ret == -ENOTSUP)
2596 printf("Function not supported in PMD driver\n");
2599 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2600 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2601 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2602 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2603 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2604 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2605 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2606 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2607 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2608 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2611 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2612 .f = cmd_config_rxtx_queue_parsed,
2614 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2616 (void *)&cmd_config_rxtx_queue_port,
2617 (void *)&cmd_config_rxtx_queue_portid,
2618 (void *)&cmd_config_rxtx_queue_rxtxq,
2619 (void *)&cmd_config_rxtx_queue_qid,
2620 (void *)&cmd_config_rxtx_queue_opname,
2625 /* *** configure port rxq/txq deferred start on/off *** */
2626 struct cmd_config_deferred_start_rxtx_queue {
2627 cmdline_fixed_string_t port;
2629 cmdline_fixed_string_t rxtxq;
2631 cmdline_fixed_string_t opname;
2632 cmdline_fixed_string_t state;
2636 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2637 __rte_unused struct cmdline *cl,
2638 __rte_unused void *data)
2640 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2641 struct rte_port *port;
2644 uint8_t needreconfig = 0;
2646 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2649 if (port_is_started(res->port_id) != 0) {
2650 printf("Please stop port %u first\n", res->port_id);
2654 port = &ports[res->port_id];
2656 isrx = !strcmp(res->rxtxq, "rxq");
2658 if (isrx && rx_queue_id_is_invalid(res->qid))
2660 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2663 ison = !strcmp(res->state, "on");
2665 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2666 port->rx_conf[res->qid].rx_deferred_start = ison;
2668 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2669 port->tx_conf[res->qid].tx_deferred_start = ison;
2674 cmd_reconfig_device_queue(res->port_id, 0, 1);
2677 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2678 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2680 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2681 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2682 port_id, RTE_UINT16);
2683 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2684 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2686 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2687 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2689 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2690 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2691 opname, "deferred_start");
2692 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2693 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2696 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2697 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2699 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2701 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2702 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2703 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2704 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2705 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2706 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2711 /* *** configure port rxq/txq setup *** */
2712 struct cmd_setup_rxtx_queue {
2713 cmdline_fixed_string_t port;
2715 cmdline_fixed_string_t rxtxq;
2717 cmdline_fixed_string_t setup;
2720 /* Common CLI fields for queue setup */
2721 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2722 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2723 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2724 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2725 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2726 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2727 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2728 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2729 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2730 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2733 cmd_setup_rxtx_queue_parsed(
2734 void *parsed_result,
2735 __rte_unused struct cmdline *cl,
2736 __rte_unused void *data)
2738 struct cmd_setup_rxtx_queue *res = parsed_result;
2739 struct rte_port *port;
2740 struct rte_mempool *mp;
2741 unsigned int socket_id;
2745 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2748 if (res->portid == (portid_t)RTE_PORT_ALL) {
2749 printf("Invalid port id\n");
2753 if (!strcmp(res->rxtxq, "rxq"))
2755 else if (!strcmp(res->rxtxq, "txq"))
2758 printf("Unknown parameter\n");
2762 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2763 printf("Invalid rx queue\n");
2765 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2766 printf("Invalid tx queue\n");
2770 port = &ports[res->portid];
2772 socket_id = rxring_numa[res->portid];
2773 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2774 socket_id = port->socket_id;
2776 mp = mbuf_pool_find(socket_id, 0);
2778 printf("Failed to setup RX queue: "
2779 "No mempool allocation"
2780 " on the socket %d\n",
2781 rxring_numa[res->portid]);
2784 ret = rx_queue_setup(res->portid,
2786 port->nb_rx_desc[res->qid],
2788 &port->rx_conf[res->qid],
2791 printf("Failed to setup RX queue\n");
2793 socket_id = txring_numa[res->portid];
2794 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2795 socket_id = port->socket_id;
2797 ret = rte_eth_tx_queue_setup(res->portid,
2799 port->nb_tx_desc[res->qid],
2801 &port->tx_conf[res->qid]);
2803 printf("Failed to setup TX queue\n");
2807 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2808 .f = cmd_setup_rxtx_queue_parsed,
2810 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2812 (void *)&cmd_setup_rxtx_queue_port,
2813 (void *)&cmd_setup_rxtx_queue_portid,
2814 (void *)&cmd_setup_rxtx_queue_rxtxq,
2815 (void *)&cmd_setup_rxtx_queue_qid,
2816 (void *)&cmd_setup_rxtx_queue_setup,
2822 /* *** Configure RSS RETA *** */
2823 struct cmd_config_rss_reta {
2824 cmdline_fixed_string_t port;
2825 cmdline_fixed_string_t keyword;
2827 cmdline_fixed_string_t name;
2828 cmdline_fixed_string_t list_name;
2829 cmdline_fixed_string_t list_of_items;
2833 parse_reta_config(const char *str,
2834 struct rte_eth_rss_reta_entry64 *reta_conf,
2835 uint16_t nb_entries)
2839 uint16_t hash_index, idx, shift;
2842 const char *p, *p0 = str;
2849 unsigned long int_fld[_NUM_FLD];
2850 char *str_fld[_NUM_FLD];
2852 while ((p = strchr(p0,'(')) != NULL) {
2854 if((p0 = strchr(p,')')) == NULL)
2858 if(size >= sizeof(s))
2861 snprintf(s, sizeof(s), "%.*s", size, p);
2862 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2864 for (i = 0; i < _NUM_FLD; i++) {
2866 int_fld[i] = strtoul(str_fld[i], &end, 0);
2867 if (errno != 0 || end == str_fld[i] ||
2872 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2873 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2875 if (hash_index >= nb_entries) {
2876 printf("Invalid RETA hash index=%d\n", hash_index);
2880 idx = hash_index / RTE_RETA_GROUP_SIZE;
2881 shift = hash_index % RTE_RETA_GROUP_SIZE;
2882 reta_conf[idx].mask |= (1ULL << shift);
2883 reta_conf[idx].reta[shift] = nb_queue;
2890 cmd_set_rss_reta_parsed(void *parsed_result,
2891 __rte_unused struct cmdline *cl,
2892 __rte_unused void *data)
2895 struct rte_eth_dev_info dev_info;
2896 struct rte_eth_rss_reta_entry64 reta_conf[8];
2897 struct cmd_config_rss_reta *res = parsed_result;
2899 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2903 if (dev_info.reta_size == 0) {
2904 printf("Redirection table size is 0 which is "
2905 "invalid for RSS\n");
2908 printf("The reta size of port %d is %u\n",
2909 res->port_id, dev_info.reta_size);
2910 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2911 printf("Currently do not support more than %u entries of "
2912 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2916 memset(reta_conf, 0, sizeof(reta_conf));
2917 if (!strcmp(res->list_name, "reta")) {
2918 if (parse_reta_config(res->list_of_items, reta_conf,
2919 dev_info.reta_size)) {
2920 printf("Invalid RSS Redirection Table "
2921 "config entered\n");
2924 ret = rte_eth_dev_rss_reta_update(res->port_id,
2925 reta_conf, dev_info.reta_size);
2927 printf("Bad redirection table parameter, "
2928 "return code = %d \n", ret);
2932 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2933 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2934 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2935 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2936 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2937 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
2938 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2939 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2940 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2941 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2942 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2943 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2945 cmdline_parse_inst_t cmd_config_rss_reta = {
2946 .f = cmd_set_rss_reta_parsed,
2948 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2950 (void *)&cmd_config_rss_reta_port,
2951 (void *)&cmd_config_rss_reta_keyword,
2952 (void *)&cmd_config_rss_reta_port_id,
2953 (void *)&cmd_config_rss_reta_name,
2954 (void *)&cmd_config_rss_reta_list_name,
2955 (void *)&cmd_config_rss_reta_list_of_items,
2960 /* *** SHOW PORT RETA INFO *** */
2961 struct cmd_showport_reta {
2962 cmdline_fixed_string_t show;
2963 cmdline_fixed_string_t port;
2965 cmdline_fixed_string_t rss;
2966 cmdline_fixed_string_t reta;
2968 cmdline_fixed_string_t list_of_items;
2972 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2973 uint16_t nb_entries,
2977 const char *p, *p0 = str;
2982 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2983 RTE_RETA_GROUP_SIZE;
2986 p = strchr(p0, '(');
2990 p0 = strchr(p, ')');
2994 if (size >= sizeof(s)) {
2995 printf("The string size exceeds the internal buffer size\n");
2998 snprintf(s, sizeof(s), "%.*s", size, p);
2999 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3000 if (ret <= 0 || ret != num) {
3001 printf("The bits of masks do not match the number of "
3002 "reta entries: %u\n", num);
3005 for (i = 0; i < ret; i++)
3006 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3012 cmd_showport_reta_parsed(void *parsed_result,
3013 __rte_unused struct cmdline *cl,
3014 __rte_unused void *data)
3016 struct cmd_showport_reta *res = parsed_result;
3017 struct rte_eth_rss_reta_entry64 reta_conf[8];
3018 struct rte_eth_dev_info dev_info;
3019 uint16_t max_reta_size;
3022 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3026 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3027 if (res->size == 0 || res->size > max_reta_size) {
3028 printf("Invalid redirection table size: %u (1-%u)\n",
3029 res->size, max_reta_size);
3033 memset(reta_conf, 0, sizeof(reta_conf));
3034 if (showport_parse_reta_config(reta_conf, res->size,
3035 res->list_of_items) < 0) {
3036 printf("Invalid string: %s for reta masks\n",
3037 res->list_of_items);
3040 port_rss_reta_info(res->port_id, reta_conf, res->size);
3043 cmdline_parse_token_string_t cmd_showport_reta_show =
3044 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3045 cmdline_parse_token_string_t cmd_showport_reta_port =
3046 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3047 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3048 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3049 cmdline_parse_token_string_t cmd_showport_reta_rss =
3050 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3051 cmdline_parse_token_string_t cmd_showport_reta_reta =
3052 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3053 cmdline_parse_token_num_t cmd_showport_reta_size =
3054 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3055 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3056 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3057 list_of_items, NULL);
3059 cmdline_parse_inst_t cmd_showport_reta = {
3060 .f = cmd_showport_reta_parsed,
3062 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3064 (void *)&cmd_showport_reta_show,
3065 (void *)&cmd_showport_reta_port,
3066 (void *)&cmd_showport_reta_port_id,
3067 (void *)&cmd_showport_reta_rss,
3068 (void *)&cmd_showport_reta_reta,
3069 (void *)&cmd_showport_reta_size,
3070 (void *)&cmd_showport_reta_list_of_items,
3075 /* *** Show RSS hash configuration *** */
3076 struct cmd_showport_rss_hash {
3077 cmdline_fixed_string_t show;
3078 cmdline_fixed_string_t port;
3080 cmdline_fixed_string_t rss_hash;
3081 cmdline_fixed_string_t rss_type;
3082 cmdline_fixed_string_t key; /* optional argument */
3085 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3086 __rte_unused struct cmdline *cl,
3089 struct cmd_showport_rss_hash *res = parsed_result;
3091 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3094 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3095 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3096 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3097 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3098 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3099 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3101 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3102 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3104 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3105 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3107 cmdline_parse_inst_t cmd_showport_rss_hash = {
3108 .f = cmd_showport_rss_hash_parsed,
3110 .help_str = "show port <port_id> rss-hash",
3112 (void *)&cmd_showport_rss_hash_show,
3113 (void *)&cmd_showport_rss_hash_port,
3114 (void *)&cmd_showport_rss_hash_port_id,
3115 (void *)&cmd_showport_rss_hash_rss_hash,
3120 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3121 .f = cmd_showport_rss_hash_parsed,
3123 .help_str = "show port <port_id> rss-hash key",
3125 (void *)&cmd_showport_rss_hash_show,
3126 (void *)&cmd_showport_rss_hash_port,
3127 (void *)&cmd_showport_rss_hash_port_id,
3128 (void *)&cmd_showport_rss_hash_rss_hash,
3129 (void *)&cmd_showport_rss_hash_rss_key,
3134 /* *** Configure DCB *** */
3135 struct cmd_config_dcb {
3136 cmdline_fixed_string_t port;
3137 cmdline_fixed_string_t config;
3139 cmdline_fixed_string_t dcb;
3140 cmdline_fixed_string_t vt;
3141 cmdline_fixed_string_t vt_en;
3143 cmdline_fixed_string_t pfc;
3144 cmdline_fixed_string_t pfc_en;
3148 cmd_config_dcb_parsed(void *parsed_result,
3149 __rte_unused struct cmdline *cl,
3150 __rte_unused void *data)
3152 struct cmd_config_dcb *res = parsed_result;
3153 portid_t port_id = res->port_id;
3154 struct rte_port *port;
3158 port = &ports[port_id];
3159 /** Check if the port is not started **/
3160 if (port->port_status != RTE_PORT_STOPPED) {
3161 printf("Please stop port %d first\n", port_id);
3165 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3166 printf("The invalid number of traffic class,"
3167 " only 4 or 8 allowed.\n");
3171 if (nb_fwd_lcores < res->num_tcs) {
3172 printf("nb_cores shouldn't be less than number of TCs.\n");
3175 if (!strncmp(res->pfc_en, "on", 2))
3180 /* DCB in VT mode */
3181 if (!strncmp(res->vt_en, "on", 2))
3182 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3183 (enum rte_eth_nb_tcs)res->num_tcs,
3186 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3187 (enum rte_eth_nb_tcs)res->num_tcs,
3192 printf("Cannot initialize network ports.\n");
3196 cmd_reconfig_device_queue(port_id, 1, 1);
3199 cmdline_parse_token_string_t cmd_config_dcb_port =
3200 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3201 cmdline_parse_token_string_t cmd_config_dcb_config =
3202 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3203 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3204 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3205 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3206 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3207 cmdline_parse_token_string_t cmd_config_dcb_vt =
3208 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3209 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3210 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3211 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3212 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3213 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3214 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3215 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3216 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3218 cmdline_parse_inst_t cmd_config_dcb = {
3219 .f = cmd_config_dcb_parsed,
3221 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3223 (void *)&cmd_config_dcb_port,
3224 (void *)&cmd_config_dcb_config,
3225 (void *)&cmd_config_dcb_port_id,
3226 (void *)&cmd_config_dcb_dcb,
3227 (void *)&cmd_config_dcb_vt,
3228 (void *)&cmd_config_dcb_vt_en,
3229 (void *)&cmd_config_dcb_num_tcs,
3230 (void *)&cmd_config_dcb_pfc,
3231 (void *)&cmd_config_dcb_pfc_en,
3236 /* *** configure number of packets per burst *** */
3237 struct cmd_config_burst {
3238 cmdline_fixed_string_t port;
3239 cmdline_fixed_string_t keyword;
3240 cmdline_fixed_string_t all;
3241 cmdline_fixed_string_t name;
3246 cmd_config_burst_parsed(void *parsed_result,
3247 __rte_unused struct cmdline *cl,
3248 __rte_unused void *data)
3250 struct cmd_config_burst *res = parsed_result;
3251 struct rte_eth_dev_info dev_info;
3252 uint16_t rec_nb_pkts;
3255 if (!all_ports_stopped()) {
3256 printf("Please stop all ports first\n");
3260 if (!strcmp(res->name, "burst")) {
3261 if (res->value == 0) {
3262 /* If user gives a value of zero, query the PMD for
3263 * its recommended Rx burst size. Testpmd uses a single
3264 * size for all ports, so assume all ports are the same
3265 * NIC model and use the values from Port 0.
3267 ret = eth_dev_info_get_print_err(0, &dev_info);
3271 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3273 if (rec_nb_pkts == 0) {
3274 printf("PMD does not recommend a burst size.\n"
3275 "User provided value must be between"
3276 " 1 and %d\n", MAX_PKT_BURST);
3278 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3279 printf("PMD recommended burst size of %d"
3280 " exceeds maximum value of %d\n",
3281 rec_nb_pkts, MAX_PKT_BURST);
3284 printf("Using PMD-provided burst value of %d\n",
3286 nb_pkt_per_burst = rec_nb_pkts;
3287 } else if (res->value > MAX_PKT_BURST) {
3288 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3291 nb_pkt_per_burst = res->value;
3293 printf("Unknown parameter\n");
3299 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3302 cmdline_parse_token_string_t cmd_config_burst_port =
3303 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3304 cmdline_parse_token_string_t cmd_config_burst_keyword =
3305 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3306 cmdline_parse_token_string_t cmd_config_burst_all =
3307 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3308 cmdline_parse_token_string_t cmd_config_burst_name =
3309 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3310 cmdline_parse_token_num_t cmd_config_burst_value =
3311 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3313 cmdline_parse_inst_t cmd_config_burst = {
3314 .f = cmd_config_burst_parsed,
3316 .help_str = "port config all burst <value>",
3318 (void *)&cmd_config_burst_port,
3319 (void *)&cmd_config_burst_keyword,
3320 (void *)&cmd_config_burst_all,
3321 (void *)&cmd_config_burst_name,
3322 (void *)&cmd_config_burst_value,
3327 /* *** configure rx/tx queues *** */
3328 struct cmd_config_thresh {
3329 cmdline_fixed_string_t port;
3330 cmdline_fixed_string_t keyword;
3331 cmdline_fixed_string_t all;
3332 cmdline_fixed_string_t name;
3337 cmd_config_thresh_parsed(void *parsed_result,
3338 __rte_unused struct cmdline *cl,
3339 __rte_unused void *data)
3341 struct cmd_config_thresh *res = parsed_result;
3343 if (!all_ports_stopped()) {
3344 printf("Please stop all ports first\n");
3348 if (!strcmp(res->name, "txpt"))
3349 tx_pthresh = res->value;
3350 else if(!strcmp(res->name, "txht"))
3351 tx_hthresh = res->value;
3352 else if(!strcmp(res->name, "txwt"))
3353 tx_wthresh = res->value;
3354 else if(!strcmp(res->name, "rxpt"))
3355 rx_pthresh = res->value;
3356 else if(!strcmp(res->name, "rxht"))
3357 rx_hthresh = res->value;
3358 else if(!strcmp(res->name, "rxwt"))
3359 rx_wthresh = res->value;
3361 printf("Unknown parameter\n");
3367 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3370 cmdline_parse_token_string_t cmd_config_thresh_port =
3371 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3372 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3373 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3374 cmdline_parse_token_string_t cmd_config_thresh_all =
3375 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3376 cmdline_parse_token_string_t cmd_config_thresh_name =
3377 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3378 "txpt#txht#txwt#rxpt#rxht#rxwt");
3379 cmdline_parse_token_num_t cmd_config_thresh_value =
3380 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3382 cmdline_parse_inst_t cmd_config_thresh = {
3383 .f = cmd_config_thresh_parsed,
3385 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3387 (void *)&cmd_config_thresh_port,
3388 (void *)&cmd_config_thresh_keyword,
3389 (void *)&cmd_config_thresh_all,
3390 (void *)&cmd_config_thresh_name,
3391 (void *)&cmd_config_thresh_value,
3396 /* *** configure free/rs threshold *** */
3397 struct cmd_config_threshold {
3398 cmdline_fixed_string_t port;
3399 cmdline_fixed_string_t keyword;
3400 cmdline_fixed_string_t all;
3401 cmdline_fixed_string_t name;
3406 cmd_config_threshold_parsed(void *parsed_result,
3407 __rte_unused struct cmdline *cl,
3408 __rte_unused void *data)
3410 struct cmd_config_threshold *res = parsed_result;
3412 if (!all_ports_stopped()) {
3413 printf("Please stop all ports first\n");
3417 if (!strcmp(res->name, "txfreet"))
3418 tx_free_thresh = res->value;
3419 else if (!strcmp(res->name, "txrst"))
3420 tx_rs_thresh = res->value;
3421 else if (!strcmp(res->name, "rxfreet"))
3422 rx_free_thresh = res->value;
3424 printf("Unknown parameter\n");
3430 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3433 cmdline_parse_token_string_t cmd_config_threshold_port =
3434 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3435 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3436 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3438 cmdline_parse_token_string_t cmd_config_threshold_all =
3439 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3440 cmdline_parse_token_string_t cmd_config_threshold_name =
3441 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3442 "txfreet#txrst#rxfreet");
3443 cmdline_parse_token_num_t cmd_config_threshold_value =
3444 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3446 cmdline_parse_inst_t cmd_config_threshold = {
3447 .f = cmd_config_threshold_parsed,
3449 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3451 (void *)&cmd_config_threshold_port,
3452 (void *)&cmd_config_threshold_keyword,
3453 (void *)&cmd_config_threshold_all,
3454 (void *)&cmd_config_threshold_name,
3455 (void *)&cmd_config_threshold_value,
3461 struct cmd_stop_result {
3462 cmdline_fixed_string_t stop;
3465 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3466 __rte_unused struct cmdline *cl,
3467 __rte_unused void *data)
3469 stop_packet_forwarding();
3472 cmdline_parse_token_string_t cmd_stop_stop =
3473 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3475 cmdline_parse_inst_t cmd_stop = {
3476 .f = cmd_stop_parsed,
3478 .help_str = "stop: Stop packet forwarding",
3480 (void *)&cmd_stop_stop,
3485 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3488 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3489 unsigned int *parsed_items, int check_unique_values)
3491 unsigned int nb_item;
3499 * First parse all items in the list and store their value.
3504 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3506 if ((c >= '0') && (c <= '9')) {
3507 value = (unsigned int) (value * 10 + (c - '0'));
3512 printf("character %c is not a decimal digit\n", c);
3516 printf("No valid value before comma\n");
3519 if (nb_item < max_items) {
3520 parsed_items[nb_item] = value;
3526 if (nb_item >= max_items) {
3527 printf("Number of %s = %u > %u (maximum items)\n",
3528 item_name, nb_item + 1, max_items);
3531 parsed_items[nb_item++] = value;
3532 if (! check_unique_values)
3536 * Then, check that all values in the list are differents.
3537 * No optimization here...
3539 for (i = 0; i < nb_item; i++) {
3540 for (j = i + 1; j < nb_item; j++) {
3541 if (parsed_items[j] == parsed_items[i]) {
3542 printf("duplicated %s %u at index %u and %u\n",
3543 item_name, parsed_items[i], i, j);
3551 struct cmd_set_list_result {
3552 cmdline_fixed_string_t cmd_keyword;
3553 cmdline_fixed_string_t list_name;
3554 cmdline_fixed_string_t list_of_items;
3557 static void cmd_set_list_parsed(void *parsed_result,
3558 __rte_unused struct cmdline *cl,
3559 __rte_unused void *data)
3561 struct cmd_set_list_result *res;
3563 unsigned int lcorelist[RTE_MAX_LCORE];
3564 unsigned int portlist[RTE_MAX_ETHPORTS];
3566 unsigned int nb_item;
3568 if (test_done == 0) {
3569 printf("Please stop forwarding first\n");
3573 res = parsed_result;
3574 if (!strcmp(res->list_name, "corelist")) {
3575 nb_item = parse_item_list(res->list_of_items, "core",
3577 parsed_items.lcorelist, 1);
3579 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3584 if (!strcmp(res->list_name, "portlist")) {
3585 nb_item = parse_item_list(res->list_of_items, "port",
3587 parsed_items.portlist, 1);
3589 set_fwd_ports_list(parsed_items.portlist, nb_item);
3595 cmdline_parse_token_string_t cmd_set_list_keyword =
3596 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3598 cmdline_parse_token_string_t cmd_set_list_name =
3599 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3600 "corelist#portlist");
3601 cmdline_parse_token_string_t cmd_set_list_of_items =
3602 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3605 cmdline_parse_inst_t cmd_set_fwd_list = {
3606 .f = cmd_set_list_parsed,
3608 .help_str = "set corelist|portlist <list0[,list1]*>",
3610 (void *)&cmd_set_list_keyword,
3611 (void *)&cmd_set_list_name,
3612 (void *)&cmd_set_list_of_items,
3617 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3619 struct cmd_setmask_result {
3620 cmdline_fixed_string_t set;
3621 cmdline_fixed_string_t mask;
3625 static void cmd_set_mask_parsed(void *parsed_result,
3626 __rte_unused struct cmdline *cl,
3627 __rte_unused void *data)
3629 struct cmd_setmask_result *res = parsed_result;
3631 if (test_done == 0) {
3632 printf("Please stop forwarding first\n");
3635 if (!strcmp(res->mask, "coremask")) {
3636 set_fwd_lcores_mask(res->hexavalue);
3638 } else if (!strcmp(res->mask, "portmask")) {
3639 set_fwd_ports_mask(res->hexavalue);
3644 cmdline_parse_token_string_t cmd_setmask_set =
3645 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3646 cmdline_parse_token_string_t cmd_setmask_mask =
3647 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3648 "coremask#portmask");
3649 cmdline_parse_token_num_t cmd_setmask_value =
3650 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3652 cmdline_parse_inst_t cmd_set_fwd_mask = {
3653 .f = cmd_set_mask_parsed,
3655 .help_str = "set coremask|portmask <hexadecimal value>",
3657 (void *)&cmd_setmask_set,
3658 (void *)&cmd_setmask_mask,
3659 (void *)&cmd_setmask_value,
3665 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3667 struct cmd_set_result {
3668 cmdline_fixed_string_t set;
3669 cmdline_fixed_string_t what;
3673 static void cmd_set_parsed(void *parsed_result,
3674 __rte_unused struct cmdline *cl,
3675 __rte_unused void *data)
3677 struct cmd_set_result *res = parsed_result;
3678 if (!strcmp(res->what, "nbport")) {
3679 set_fwd_ports_number(res->value);
3681 } else if (!strcmp(res->what, "nbcore")) {
3682 set_fwd_lcores_number(res->value);
3684 } else if (!strcmp(res->what, "burst"))
3685 set_nb_pkt_per_burst(res->value);
3686 else if (!strcmp(res->what, "verbose"))
3687 set_verbose_level(res->value);
3690 cmdline_parse_token_string_t cmd_set_set =
3691 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3692 cmdline_parse_token_string_t cmd_set_what =
3693 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3694 "nbport#nbcore#burst#verbose");
3695 cmdline_parse_token_num_t cmd_set_value =
3696 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3698 cmdline_parse_inst_t cmd_set_numbers = {
3699 .f = cmd_set_parsed,
3701 .help_str = "set nbport|nbcore|burst|verbose <value>",
3703 (void *)&cmd_set_set,
3704 (void *)&cmd_set_what,
3705 (void *)&cmd_set_value,
3710 /* *** SET LOG LEVEL CONFIGURATION *** */
3712 struct cmd_set_log_result {
3713 cmdline_fixed_string_t set;
3714 cmdline_fixed_string_t log;
3715 cmdline_fixed_string_t type;
3720 cmd_set_log_parsed(void *parsed_result,
3721 __rte_unused struct cmdline *cl,
3722 __rte_unused void *data)
3724 struct cmd_set_log_result *res;
3727 res = parsed_result;
3728 if (!strcmp(res->type, "global"))
3729 rte_log_set_global_level(res->level);
3731 ret = rte_log_set_level_regexp(res->type, res->level);
3733 printf("Unable to set log level\n");
3737 cmdline_parse_token_string_t cmd_set_log_set =
3738 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3739 cmdline_parse_token_string_t cmd_set_log_log =
3740 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3741 cmdline_parse_token_string_t cmd_set_log_type =
3742 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3743 cmdline_parse_token_num_t cmd_set_log_level =
3744 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3746 cmdline_parse_inst_t cmd_set_log = {
3747 .f = cmd_set_log_parsed,
3749 .help_str = "set log global|<type> <level>",
3751 (void *)&cmd_set_log_set,
3752 (void *)&cmd_set_log_log,
3753 (void *)&cmd_set_log_type,
3754 (void *)&cmd_set_log_level,
3759 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3761 struct cmd_set_rxoffs_result {
3762 cmdline_fixed_string_t cmd_keyword;
3763 cmdline_fixed_string_t rxoffs;
3764 cmdline_fixed_string_t seg_offsets;
3768 cmd_set_rxoffs_parsed(void *parsed_result,
3769 __rte_unused struct cmdline *cl,
3770 __rte_unused void *data)
3772 struct cmd_set_rxoffs_result *res;
3773 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3774 unsigned int nb_segs;
3776 res = parsed_result;
3777 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3778 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3780 set_rx_pkt_offsets(seg_offsets, nb_segs);
3783 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3784 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3785 cmd_keyword, "set");
3786 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3787 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3789 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3790 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3793 cmdline_parse_inst_t cmd_set_rxoffs = {
3794 .f = cmd_set_rxoffs_parsed,
3796 .help_str = "set rxoffs <len0[,len1]*>",
3798 (void *)&cmd_set_rxoffs_keyword,
3799 (void *)&cmd_set_rxoffs_name,
3800 (void *)&cmd_set_rxoffs_offsets,
3805 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3807 struct cmd_set_rxpkts_result {
3808 cmdline_fixed_string_t cmd_keyword;
3809 cmdline_fixed_string_t rxpkts;
3810 cmdline_fixed_string_t seg_lengths;
3814 cmd_set_rxpkts_parsed(void *parsed_result,
3815 __rte_unused struct cmdline *cl,
3816 __rte_unused void *data)
3818 struct cmd_set_rxpkts_result *res;
3819 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3820 unsigned int nb_segs;
3822 res = parsed_result;
3823 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3824 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3826 set_rx_pkt_segments(seg_lengths, nb_segs);
3829 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3830 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3831 cmd_keyword, "set");
3832 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3833 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3835 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3836 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3839 cmdline_parse_inst_t cmd_set_rxpkts = {
3840 .f = cmd_set_rxpkts_parsed,
3842 .help_str = "set rxpkts <len0[,len1]*>",
3844 (void *)&cmd_set_rxpkts_keyword,
3845 (void *)&cmd_set_rxpkts_name,
3846 (void *)&cmd_set_rxpkts_lengths,
3851 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3853 struct cmd_set_txpkts_result {
3854 cmdline_fixed_string_t cmd_keyword;
3855 cmdline_fixed_string_t txpkts;
3856 cmdline_fixed_string_t seg_lengths;
3860 cmd_set_txpkts_parsed(void *parsed_result,
3861 __rte_unused struct cmdline *cl,
3862 __rte_unused void *data)
3864 struct cmd_set_txpkts_result *res;
3865 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3866 unsigned int nb_segs;
3868 res = parsed_result;
3869 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3870 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3872 set_tx_pkt_segments(seg_lengths, nb_segs);
3875 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3876 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3877 cmd_keyword, "set");
3878 cmdline_parse_token_string_t cmd_set_txpkts_name =
3879 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3881 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3882 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3885 cmdline_parse_inst_t cmd_set_txpkts = {
3886 .f = cmd_set_txpkts_parsed,
3888 .help_str = "set txpkts <len0[,len1]*>",
3890 (void *)&cmd_set_txpkts_keyword,
3891 (void *)&cmd_set_txpkts_name,
3892 (void *)&cmd_set_txpkts_lengths,
3897 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3899 struct cmd_set_txsplit_result {
3900 cmdline_fixed_string_t cmd_keyword;
3901 cmdline_fixed_string_t txsplit;
3902 cmdline_fixed_string_t mode;
3906 cmd_set_txsplit_parsed(void *parsed_result,
3907 __rte_unused struct cmdline *cl,
3908 __rte_unused void *data)
3910 struct cmd_set_txsplit_result *res;
3912 res = parsed_result;
3913 set_tx_pkt_split(res->mode);
3916 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3917 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3918 cmd_keyword, "set");
3919 cmdline_parse_token_string_t cmd_set_txsplit_name =
3920 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3921 txsplit, "txsplit");
3922 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3923 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3926 cmdline_parse_inst_t cmd_set_txsplit = {
3927 .f = cmd_set_txsplit_parsed,
3929 .help_str = "set txsplit on|off|rand",
3931 (void *)&cmd_set_txsplit_keyword,
3932 (void *)&cmd_set_txsplit_name,
3933 (void *)&cmd_set_txsplit_mode,
3938 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
3940 struct cmd_set_txtimes_result {
3941 cmdline_fixed_string_t cmd_keyword;
3942 cmdline_fixed_string_t txtimes;
3943 cmdline_fixed_string_t tx_times;
3947 cmd_set_txtimes_parsed(void *parsed_result,
3948 __rte_unused struct cmdline *cl,
3949 __rte_unused void *data)
3951 struct cmd_set_txtimes_result *res;
3952 unsigned int tx_times[2] = {0, 0};
3953 unsigned int n_times;
3955 res = parsed_result;
3956 n_times = parse_item_list(res->tx_times, "tx times",
3959 set_tx_pkt_times(tx_times);
3962 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
3963 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3964 cmd_keyword, "set");
3965 cmdline_parse_token_string_t cmd_set_txtimes_name =
3966 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3967 txtimes, "txtimes");
3968 cmdline_parse_token_string_t cmd_set_txtimes_value =
3969 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3972 cmdline_parse_inst_t cmd_set_txtimes = {
3973 .f = cmd_set_txtimes_parsed,
3975 .help_str = "set txtimes <inter_burst>,<intra_burst>",
3977 (void *)&cmd_set_txtimes_keyword,
3978 (void *)&cmd_set_txtimes_name,
3979 (void *)&cmd_set_txtimes_value,
3984 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3985 struct cmd_rx_vlan_filter_all_result {
3986 cmdline_fixed_string_t rx_vlan;
3987 cmdline_fixed_string_t what;
3988 cmdline_fixed_string_t all;
3993 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3994 __rte_unused struct cmdline *cl,
3995 __rte_unused void *data)
3997 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3999 if (!strcmp(res->what, "add"))
4000 rx_vlan_all_filter_set(res->port_id, 1);
4002 rx_vlan_all_filter_set(res->port_id, 0);
4005 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4006 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4007 rx_vlan, "rx_vlan");
4008 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4009 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4011 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4012 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4014 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4015 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4016 port_id, RTE_UINT16);
4018 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4019 .f = cmd_rx_vlan_filter_all_parsed,
4021 .help_str = "rx_vlan add|rm all <port_id>: "
4022 "Add/Remove all identifiers to/from the set of VLAN "
4023 "identifiers filtered by a port",
4025 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4026 (void *)&cmd_rx_vlan_filter_all_what,
4027 (void *)&cmd_rx_vlan_filter_all_all,
4028 (void *)&cmd_rx_vlan_filter_all_portid,
4033 /* *** VLAN OFFLOAD SET ON A PORT *** */
4034 struct cmd_vlan_offload_result {
4035 cmdline_fixed_string_t vlan;
4036 cmdline_fixed_string_t set;
4037 cmdline_fixed_string_t vlan_type;
4038 cmdline_fixed_string_t what;
4039 cmdline_fixed_string_t on;
4040 cmdline_fixed_string_t port_id;
4044 cmd_vlan_offload_parsed(void *parsed_result,
4045 __rte_unused struct cmdline *cl,
4046 __rte_unused void *data)
4049 struct cmd_vlan_offload_result *res = parsed_result;
4052 portid_t port_id = 0;
4056 len = strnlen(str, STR_TOKEN_SIZE);
4058 /* Get port_id first */
4066 tmp = strtoul(str, NULL, 0);
4067 /* If port_id greater that what portid_t can represent, return */
4068 if(tmp >= RTE_MAX_ETHPORTS)
4070 port_id = (portid_t)tmp;
4072 if (!strcmp(res->on, "on"))
4077 if (!strcmp(res->what, "strip"))
4078 rx_vlan_strip_set(port_id, on);
4079 else if(!strcmp(res->what, "stripq")){
4080 uint16_t queue_id = 0;
4082 /* No queue_id, return */
4084 printf("must specify (port,queue_id)\n");
4087 tmp = strtoul(str + i + 1, NULL, 0);
4088 /* If queue_id greater that what 16-bits can represent, return */
4092 queue_id = (uint16_t)tmp;
4093 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4095 else if (!strcmp(res->what, "filter"))
4096 rx_vlan_filter_set(port_id, on);
4097 else if (!strcmp(res->what, "qinq_strip"))
4098 rx_vlan_qinq_strip_set(port_id, on);
4100 vlan_extend_set(port_id, on);
4105 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4106 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4108 cmdline_parse_token_string_t cmd_vlan_offload_set =
4109 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4111 cmdline_parse_token_string_t cmd_vlan_offload_what =
4112 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4113 what, "strip#filter#qinq_strip#extend#stripq");
4114 cmdline_parse_token_string_t cmd_vlan_offload_on =
4115 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4117 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4118 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4121 cmdline_parse_inst_t cmd_vlan_offload = {
4122 .f = cmd_vlan_offload_parsed,
4124 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4125 "<port_id[,queue_id]>: "
4126 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4128 (void *)&cmd_vlan_offload_vlan,
4129 (void *)&cmd_vlan_offload_set,
4130 (void *)&cmd_vlan_offload_what,
4131 (void *)&cmd_vlan_offload_on,
4132 (void *)&cmd_vlan_offload_portid,
4137 /* *** VLAN TPID SET ON A PORT *** */
4138 struct cmd_vlan_tpid_result {
4139 cmdline_fixed_string_t vlan;
4140 cmdline_fixed_string_t set;
4141 cmdline_fixed_string_t vlan_type;
4142 cmdline_fixed_string_t what;
4148 cmd_vlan_tpid_parsed(void *parsed_result,
4149 __rte_unused struct cmdline *cl,
4150 __rte_unused void *data)
4152 struct cmd_vlan_tpid_result *res = parsed_result;
4153 enum rte_vlan_type vlan_type;
4155 if (!strcmp(res->vlan_type, "inner"))
4156 vlan_type = ETH_VLAN_TYPE_INNER;
4157 else if (!strcmp(res->vlan_type, "outer"))
4158 vlan_type = ETH_VLAN_TYPE_OUTER;
4160 printf("Unknown vlan type\n");
4163 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4166 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4167 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4169 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4170 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4172 cmdline_parse_token_string_t cmd_vlan_type =
4173 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4174 vlan_type, "inner#outer");
4175 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4176 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4178 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4179 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4181 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4182 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4183 port_id, RTE_UINT16);
4185 cmdline_parse_inst_t cmd_vlan_tpid = {
4186 .f = cmd_vlan_tpid_parsed,
4188 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4189 "Set the VLAN Ether type",
4191 (void *)&cmd_vlan_tpid_vlan,
4192 (void *)&cmd_vlan_tpid_set,
4193 (void *)&cmd_vlan_type,
4194 (void *)&cmd_vlan_tpid_what,
4195 (void *)&cmd_vlan_tpid_tpid,
4196 (void *)&cmd_vlan_tpid_portid,
4201 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4202 struct cmd_rx_vlan_filter_result {
4203 cmdline_fixed_string_t rx_vlan;
4204 cmdline_fixed_string_t what;
4210 cmd_rx_vlan_filter_parsed(void *parsed_result,
4211 __rte_unused struct cmdline *cl,
4212 __rte_unused void *data)
4214 struct cmd_rx_vlan_filter_result *res = parsed_result;
4216 if (!strcmp(res->what, "add"))
4217 rx_vft_set(res->port_id, res->vlan_id, 1);
4219 rx_vft_set(res->port_id, res->vlan_id, 0);
4222 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4223 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4224 rx_vlan, "rx_vlan");
4225 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4226 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4228 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4229 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4230 vlan_id, RTE_UINT16);
4231 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4232 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4233 port_id, RTE_UINT16);
4235 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4236 .f = cmd_rx_vlan_filter_parsed,
4238 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4239 "Add/Remove a VLAN identifier to/from the set of VLAN "
4240 "identifiers filtered by a port",
4242 (void *)&cmd_rx_vlan_filter_rx_vlan,
4243 (void *)&cmd_rx_vlan_filter_what,
4244 (void *)&cmd_rx_vlan_filter_vlanid,
4245 (void *)&cmd_rx_vlan_filter_portid,
4250 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4251 struct cmd_tx_vlan_set_result {
4252 cmdline_fixed_string_t tx_vlan;
4253 cmdline_fixed_string_t set;
4259 cmd_tx_vlan_set_parsed(void *parsed_result,
4260 __rte_unused struct cmdline *cl,
4261 __rte_unused void *data)
4263 struct cmd_tx_vlan_set_result *res = parsed_result;
4265 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4268 if (!port_is_stopped(res->port_id)) {
4269 printf("Please stop port %d first\n", res->port_id);
4273 tx_vlan_set(res->port_id, res->vlan_id);
4275 cmd_reconfig_device_queue(res->port_id, 1, 1);
4278 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4279 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4280 tx_vlan, "tx_vlan");
4281 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4282 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4284 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4285 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4286 port_id, RTE_UINT16);
4287 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4288 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4289 vlan_id, RTE_UINT16);
4291 cmdline_parse_inst_t cmd_tx_vlan_set = {
4292 .f = cmd_tx_vlan_set_parsed,
4294 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4295 "Enable hardware insertion of a single VLAN header "
4296 "with a given TAG Identifier in packets sent on a port",
4298 (void *)&cmd_tx_vlan_set_tx_vlan,
4299 (void *)&cmd_tx_vlan_set_set,
4300 (void *)&cmd_tx_vlan_set_portid,
4301 (void *)&cmd_tx_vlan_set_vlanid,
4306 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4307 struct cmd_tx_vlan_set_qinq_result {
4308 cmdline_fixed_string_t tx_vlan;
4309 cmdline_fixed_string_t set;
4312 uint16_t vlan_id_outer;
4316 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4317 __rte_unused struct cmdline *cl,
4318 __rte_unused void *data)
4320 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4322 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4325 if (!port_is_stopped(res->port_id)) {
4326 printf("Please stop port %d first\n", res->port_id);
4330 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4332 cmd_reconfig_device_queue(res->port_id, 1, 1);
4335 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4336 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4337 tx_vlan, "tx_vlan");
4338 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4339 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4341 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4342 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4343 port_id, RTE_UINT16);
4344 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4345 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4346 vlan_id, RTE_UINT16);
4347 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4348 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4349 vlan_id_outer, RTE_UINT16);
4351 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4352 .f = cmd_tx_vlan_set_qinq_parsed,
4354 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4355 "Enable hardware insertion of double VLAN header "
4356 "with given TAG Identifiers in packets sent on a port",
4358 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4359 (void *)&cmd_tx_vlan_set_qinq_set,
4360 (void *)&cmd_tx_vlan_set_qinq_portid,
4361 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4362 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4367 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4368 struct cmd_tx_vlan_set_pvid_result {
4369 cmdline_fixed_string_t tx_vlan;
4370 cmdline_fixed_string_t set;
4371 cmdline_fixed_string_t pvid;
4374 cmdline_fixed_string_t mode;
4378 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4379 __rte_unused struct cmdline *cl,
4380 __rte_unused void *data)
4382 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4384 if (strcmp(res->mode, "on") == 0)
4385 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4387 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4390 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4391 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4392 tx_vlan, "tx_vlan");
4393 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4394 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4396 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4397 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4399 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4400 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4401 port_id, RTE_UINT16);
4402 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4403 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4404 vlan_id, RTE_UINT16);
4405 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4406 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4409 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4410 .f = cmd_tx_vlan_set_pvid_parsed,
4412 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4414 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4415 (void *)&cmd_tx_vlan_set_pvid_set,
4416 (void *)&cmd_tx_vlan_set_pvid_pvid,
4417 (void *)&cmd_tx_vlan_set_pvid_port_id,
4418 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4419 (void *)&cmd_tx_vlan_set_pvid_mode,
4424 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4425 struct cmd_tx_vlan_reset_result {
4426 cmdline_fixed_string_t tx_vlan;
4427 cmdline_fixed_string_t reset;
4432 cmd_tx_vlan_reset_parsed(void *parsed_result,
4433 __rte_unused struct cmdline *cl,
4434 __rte_unused void *data)
4436 struct cmd_tx_vlan_reset_result *res = parsed_result;
4438 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4441 if (!port_is_stopped(res->port_id)) {
4442 printf("Please stop port %d first\n", res->port_id);
4446 tx_vlan_reset(res->port_id);
4448 cmd_reconfig_device_queue(res->port_id, 1, 1);
4451 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4452 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4453 tx_vlan, "tx_vlan");
4454 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4455 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4457 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4458 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4459 port_id, RTE_UINT16);
4461 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4462 .f = cmd_tx_vlan_reset_parsed,
4464 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4465 "VLAN header in packets sent on a port",
4467 (void *)&cmd_tx_vlan_reset_tx_vlan,
4468 (void *)&cmd_tx_vlan_reset_reset,
4469 (void *)&cmd_tx_vlan_reset_portid,
4475 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4476 struct cmd_csum_result {
4477 cmdline_fixed_string_t csum;
4478 cmdline_fixed_string_t mode;
4479 cmdline_fixed_string_t proto;
4480 cmdline_fixed_string_t hwsw;
4485 csum_show(int port_id)
4487 struct rte_eth_dev_info dev_info;
4488 uint64_t tx_offloads;
4491 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4492 printf("Parse tunnel is %s\n",
4493 (ports[port_id].parse_tunnel) ? "on" : "off");
4494 printf("IP checksum offload is %s\n",
4495 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4496 printf("UDP checksum offload is %s\n",
4497 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4498 printf("TCP checksum offload is %s\n",
4499 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4500 printf("SCTP checksum offload is %s\n",
4501 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4502 printf("Outer-Ip checksum offload is %s\n",
4503 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4504 printf("Outer-Udp checksum offload is %s\n",
4505 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4507 /* display warnings if configuration is not supported by the NIC */
4508 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4512 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4513 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4514 printf("Warning: hardware IP checksum enabled but not "
4515 "supported by port %d\n", port_id);
4517 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4518 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4519 printf("Warning: hardware UDP checksum enabled but not "
4520 "supported by port %d\n", port_id);
4522 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4523 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4524 printf("Warning: hardware TCP checksum enabled but not "
4525 "supported by port %d\n", port_id);
4527 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4528 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4529 printf("Warning: hardware SCTP checksum enabled but not "
4530 "supported by port %d\n", port_id);
4532 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4533 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4534 printf("Warning: hardware outer IP checksum enabled but not "
4535 "supported by port %d\n", port_id);
4537 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4538 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4540 printf("Warning: hardware outer UDP checksum enabled but not "
4541 "supported by port %d\n", port_id);
4546 cmd_config_queue_tx_offloads(struct rte_port *port)
4550 /* Apply queue tx offloads configuration */
4551 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4552 port->tx_conf[k].offloads =
4553 port->dev_conf.txmode.offloads;
4557 cmd_csum_parsed(void *parsed_result,
4558 __rte_unused struct cmdline *cl,
4559 __rte_unused void *data)
4561 struct cmd_csum_result *res = parsed_result;
4563 uint64_t csum_offloads = 0;
4564 struct rte_eth_dev_info dev_info;
4567 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4568 printf("invalid port %d\n", res->port_id);
4571 if (!port_is_stopped(res->port_id)) {
4572 printf("Please stop port %d first\n", res->port_id);
4576 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4580 if (!strcmp(res->mode, "set")) {
4582 if (!strcmp(res->hwsw, "hw"))
4585 if (!strcmp(res->proto, "ip")) {
4586 if (hw == 0 || (dev_info.tx_offload_capa &
4587 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4588 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4590 printf("IP checksum offload is not supported "
4591 "by port %u\n", res->port_id);
4593 } else if (!strcmp(res->proto, "udp")) {
4594 if (hw == 0 || (dev_info.tx_offload_capa &
4595 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4596 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4598 printf("UDP checksum offload is not supported "
4599 "by port %u\n", res->port_id);
4601 } else if (!strcmp(res->proto, "tcp")) {
4602 if (hw == 0 || (dev_info.tx_offload_capa &
4603 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4604 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4606 printf("TCP checksum offload is not supported "
4607 "by port %u\n", res->port_id);
4609 } else if (!strcmp(res->proto, "sctp")) {
4610 if (hw == 0 || (dev_info.tx_offload_capa &
4611 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4612 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4614 printf("SCTP checksum offload is not supported "
4615 "by port %u\n", res->port_id);
4617 } else if (!strcmp(res->proto, "outer-ip")) {
4618 if (hw == 0 || (dev_info.tx_offload_capa &
4619 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4621 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4623 printf("Outer IP checksum offload is not "
4624 "supported by port %u\n", res->port_id);
4626 } else if (!strcmp(res->proto, "outer-udp")) {
4627 if (hw == 0 || (dev_info.tx_offload_capa &
4628 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4630 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4632 printf("Outer UDP checksum offload is not "
4633 "supported by port %u\n", res->port_id);
4638 ports[res->port_id].dev_conf.txmode.offloads |=
4641 ports[res->port_id].dev_conf.txmode.offloads &=
4644 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4646 csum_show(res->port_id);
4648 cmd_reconfig_device_queue(res->port_id, 1, 1);
4651 cmdline_parse_token_string_t cmd_csum_csum =
4652 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4654 cmdline_parse_token_string_t cmd_csum_mode =
4655 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4657 cmdline_parse_token_string_t cmd_csum_proto =
4658 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4659 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4660 cmdline_parse_token_string_t cmd_csum_hwsw =
4661 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4663 cmdline_parse_token_num_t cmd_csum_portid =
4664 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4665 port_id, RTE_UINT16);
4667 cmdline_parse_inst_t cmd_csum_set = {
4668 .f = cmd_csum_parsed,
4670 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4671 "Enable/Disable hardware calculation of L3/L4 checksum when "
4672 "using csum forward engine",
4674 (void *)&cmd_csum_csum,
4675 (void *)&cmd_csum_mode,
4676 (void *)&cmd_csum_proto,
4677 (void *)&cmd_csum_hwsw,
4678 (void *)&cmd_csum_portid,
4683 cmdline_parse_token_string_t cmd_csum_mode_show =
4684 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4687 cmdline_parse_inst_t cmd_csum_show = {
4688 .f = cmd_csum_parsed,
4690 .help_str = "csum show <port_id>: Show checksum offload configuration",
4692 (void *)&cmd_csum_csum,
4693 (void *)&cmd_csum_mode_show,
4694 (void *)&cmd_csum_portid,
4699 /* Enable/disable tunnel parsing */
4700 struct cmd_csum_tunnel_result {
4701 cmdline_fixed_string_t csum;
4702 cmdline_fixed_string_t parse;
4703 cmdline_fixed_string_t onoff;
4708 cmd_csum_tunnel_parsed(void *parsed_result,
4709 __rte_unused struct cmdline *cl,
4710 __rte_unused void *data)
4712 struct cmd_csum_tunnel_result *res = parsed_result;
4714 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4717 if (!strcmp(res->onoff, "on"))
4718 ports[res->port_id].parse_tunnel = 1;
4720 ports[res->port_id].parse_tunnel = 0;
4722 csum_show(res->port_id);
4725 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4726 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4728 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4729 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4730 parse, "parse-tunnel");
4731 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4732 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4734 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4735 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4736 port_id, RTE_UINT16);
4738 cmdline_parse_inst_t cmd_csum_tunnel = {
4739 .f = cmd_csum_tunnel_parsed,
4741 .help_str = "csum parse-tunnel on|off <port_id>: "
4742 "Enable/Disable parsing of tunnels for csum engine",
4744 (void *)&cmd_csum_tunnel_csum,
4745 (void *)&cmd_csum_tunnel_parse,
4746 (void *)&cmd_csum_tunnel_onoff,
4747 (void *)&cmd_csum_tunnel_portid,
4752 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4753 struct cmd_tso_set_result {
4754 cmdline_fixed_string_t tso;
4755 cmdline_fixed_string_t mode;
4761 cmd_tso_set_parsed(void *parsed_result,
4762 __rte_unused struct cmdline *cl,
4763 __rte_unused void *data)
4765 struct cmd_tso_set_result *res = parsed_result;
4766 struct rte_eth_dev_info dev_info;
4769 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4771 if (!port_is_stopped(res->port_id)) {
4772 printf("Please stop port %d first\n", res->port_id);
4776 if (!strcmp(res->mode, "set"))
4777 ports[res->port_id].tso_segsz = res->tso_segsz;
4779 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4783 if ((ports[res->port_id].tso_segsz != 0) &&
4784 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4785 printf("Error: TSO is not supported by port %d\n",
4790 if (ports[res->port_id].tso_segsz == 0) {
4791 ports[res->port_id].dev_conf.txmode.offloads &=
4792 ~DEV_TX_OFFLOAD_TCP_TSO;
4793 printf("TSO for non-tunneled packets is disabled\n");
4795 ports[res->port_id].dev_conf.txmode.offloads |=
4796 DEV_TX_OFFLOAD_TCP_TSO;
4797 printf("TSO segment size for non-tunneled packets is %d\n",
4798 ports[res->port_id].tso_segsz);
4800 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4802 /* display warnings if configuration is not supported by the NIC */
4803 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4807 if ((ports[res->port_id].tso_segsz != 0) &&
4808 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4809 printf("Warning: TSO enabled but not "
4810 "supported by port %d\n", res->port_id);
4813 cmd_reconfig_device_queue(res->port_id, 1, 1);
4816 cmdline_parse_token_string_t cmd_tso_set_tso =
4817 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4819 cmdline_parse_token_string_t cmd_tso_set_mode =
4820 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4822 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4823 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4824 tso_segsz, RTE_UINT16);
4825 cmdline_parse_token_num_t cmd_tso_set_portid =
4826 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4827 port_id, RTE_UINT16);
4829 cmdline_parse_inst_t cmd_tso_set = {
4830 .f = cmd_tso_set_parsed,
4832 .help_str = "tso set <tso_segsz> <port_id>: "
4833 "Set TSO segment size of non-tunneled packets for csum engine "
4836 (void *)&cmd_tso_set_tso,
4837 (void *)&cmd_tso_set_mode,
4838 (void *)&cmd_tso_set_tso_segsz,
4839 (void *)&cmd_tso_set_portid,
4844 cmdline_parse_token_string_t cmd_tso_show_mode =
4845 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4849 cmdline_parse_inst_t cmd_tso_show = {
4850 .f = cmd_tso_set_parsed,
4852 .help_str = "tso show <port_id>: "
4853 "Show TSO segment size of non-tunneled packets for csum engine",
4855 (void *)&cmd_tso_set_tso,
4856 (void *)&cmd_tso_show_mode,
4857 (void *)&cmd_tso_set_portid,
4862 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4863 struct cmd_tunnel_tso_set_result {
4864 cmdline_fixed_string_t tso;
4865 cmdline_fixed_string_t mode;
4870 static struct rte_eth_dev_info
4871 check_tunnel_tso_nic_support(portid_t port_id)
4873 struct rte_eth_dev_info dev_info;
4875 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4878 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4879 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4880 "not enabled for port %d\n", port_id);
4881 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4882 printf("Warning: GRE TUNNEL TSO not supported therefore "
4883 "not enabled for port %d\n", port_id);
4884 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4885 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4886 "not enabled for port %d\n", port_id);
4887 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4888 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4889 "not enabled for port %d\n", port_id);
4890 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4891 printf("Warning: IP TUNNEL TSO not supported therefore "
4892 "not enabled for port %d\n", port_id);
4893 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4894 printf("Warning: UDP TUNNEL TSO not supported therefore "
4895 "not enabled for port %d\n", port_id);
4900 cmd_tunnel_tso_set_parsed(void *parsed_result,
4901 __rte_unused struct cmdline *cl,
4902 __rte_unused void *data)
4904 struct cmd_tunnel_tso_set_result *res = parsed_result;
4905 struct rte_eth_dev_info dev_info;
4907 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4909 if (!port_is_stopped(res->port_id)) {
4910 printf("Please stop port %d first\n", res->port_id);
4914 if (!strcmp(res->mode, "set"))
4915 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4917 dev_info = check_tunnel_tso_nic_support(res->port_id);
4918 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4919 ports[res->port_id].dev_conf.txmode.offloads &=
4920 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4921 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4922 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4923 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4924 DEV_TX_OFFLOAD_IP_TNL_TSO |
4925 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4926 printf("TSO for tunneled packets is disabled\n");
4928 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4929 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4930 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4931 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4932 DEV_TX_OFFLOAD_IP_TNL_TSO |
4933 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4935 ports[res->port_id].dev_conf.txmode.offloads |=
4936 (tso_offloads & dev_info.tx_offload_capa);
4937 printf("TSO segment size for tunneled packets is %d\n",
4938 ports[res->port_id].tunnel_tso_segsz);
4940 /* Below conditions are needed to make it work:
4941 * (1) tunnel TSO is supported by the NIC;
4942 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4944 * (3) for tunneled pkts with outer L3 of IPv4,
4945 * "csum set outer-ip" must be set to hw, because after tso,
4946 * total_len of outer IP header is changed, and the checksum
4947 * of outer IP header calculated by sw should be wrong; that
4948 * is not necessary for IPv6 tunneled pkts because there's no
4949 * checksum in IP header anymore.
4952 if (!ports[res->port_id].parse_tunnel)
4953 printf("Warning: csum parse_tunnel must be set "
4954 "so that tunneled packets are recognized\n");
4955 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4956 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4957 printf("Warning: csum set outer-ip must be set to hw "
4958 "if outer L3 is IPv4; not necessary for IPv6\n");
4961 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4962 cmd_reconfig_device_queue(res->port_id, 1, 1);
4965 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4966 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4968 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4969 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4971 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4972 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4973 tso_segsz, RTE_UINT16);
4974 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4975 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4976 port_id, RTE_UINT16);
4978 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4979 .f = cmd_tunnel_tso_set_parsed,
4981 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4982 "Set TSO segment size of tunneled packets for csum engine "
4985 (void *)&cmd_tunnel_tso_set_tso,
4986 (void *)&cmd_tunnel_tso_set_mode,
4987 (void *)&cmd_tunnel_tso_set_tso_segsz,
4988 (void *)&cmd_tunnel_tso_set_portid,
4993 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4994 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4998 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4999 .f = cmd_tunnel_tso_set_parsed,
5001 .help_str = "tunnel_tso show <port_id> "
5002 "Show TSO segment size of tunneled packets for csum engine",
5004 (void *)&cmd_tunnel_tso_set_tso,
5005 (void *)&cmd_tunnel_tso_show_mode,
5006 (void *)&cmd_tunnel_tso_set_portid,
5011 /* *** SET GRO FOR A PORT *** */
5012 struct cmd_gro_enable_result {
5013 cmdline_fixed_string_t cmd_set;
5014 cmdline_fixed_string_t cmd_port;
5015 cmdline_fixed_string_t cmd_keyword;
5016 cmdline_fixed_string_t cmd_onoff;
5021 cmd_gro_enable_parsed(void *parsed_result,
5022 __rte_unused struct cmdline *cl,
5023 __rte_unused void *data)
5025 struct cmd_gro_enable_result *res;
5027 res = parsed_result;
5028 if (!strcmp(res->cmd_keyword, "gro"))
5029 setup_gro(res->cmd_onoff, res->cmd_pid);
5032 cmdline_parse_token_string_t cmd_gro_enable_set =
5033 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5035 cmdline_parse_token_string_t cmd_gro_enable_port =
5036 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5037 cmd_keyword, "port");
5038 cmdline_parse_token_num_t cmd_gro_enable_pid =
5039 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5040 cmd_pid, RTE_UINT16);
5041 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5042 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5043 cmd_keyword, "gro");
5044 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5045 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5046 cmd_onoff, "on#off");
5048 cmdline_parse_inst_t cmd_gro_enable = {
5049 .f = cmd_gro_enable_parsed,
5051 .help_str = "set port <port_id> gro on|off",
5053 (void *)&cmd_gro_enable_set,
5054 (void *)&cmd_gro_enable_port,
5055 (void *)&cmd_gro_enable_pid,
5056 (void *)&cmd_gro_enable_keyword,
5057 (void *)&cmd_gro_enable_onoff,
5062 /* *** DISPLAY GRO CONFIGURATION *** */
5063 struct cmd_gro_show_result {
5064 cmdline_fixed_string_t cmd_show;
5065 cmdline_fixed_string_t cmd_port;
5066 cmdline_fixed_string_t cmd_keyword;
5071 cmd_gro_show_parsed(void *parsed_result,
5072 __rte_unused struct cmdline *cl,
5073 __rte_unused void *data)
5075 struct cmd_gro_show_result *res;
5077 res = parsed_result;
5078 if (!strcmp(res->cmd_keyword, "gro"))
5079 show_gro(res->cmd_pid);
5082 cmdline_parse_token_string_t cmd_gro_show_show =
5083 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5085 cmdline_parse_token_string_t cmd_gro_show_port =
5086 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5088 cmdline_parse_token_num_t cmd_gro_show_pid =
5089 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5090 cmd_pid, RTE_UINT16);
5091 cmdline_parse_token_string_t cmd_gro_show_keyword =
5092 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5093 cmd_keyword, "gro");
5095 cmdline_parse_inst_t cmd_gro_show = {
5096 .f = cmd_gro_show_parsed,
5098 .help_str = "show port <port_id> gro",
5100 (void *)&cmd_gro_show_show,
5101 (void *)&cmd_gro_show_port,
5102 (void *)&cmd_gro_show_pid,
5103 (void *)&cmd_gro_show_keyword,
5108 /* *** SET FLUSH CYCLES FOR GRO *** */
5109 struct cmd_gro_flush_result {
5110 cmdline_fixed_string_t cmd_set;
5111 cmdline_fixed_string_t cmd_keyword;
5112 cmdline_fixed_string_t cmd_flush;
5117 cmd_gro_flush_parsed(void *parsed_result,
5118 __rte_unused struct cmdline *cl,
5119 __rte_unused void *data)
5121 struct cmd_gro_flush_result *res;
5123 res = parsed_result;
5124 if ((!strcmp(res->cmd_keyword, "gro")) &&
5125 (!strcmp(res->cmd_flush, "flush")))
5126 setup_gro_flush_cycles(res->cmd_cycles);
5129 cmdline_parse_token_string_t cmd_gro_flush_set =
5130 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5132 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5133 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5134 cmd_keyword, "gro");
5135 cmdline_parse_token_string_t cmd_gro_flush_flush =
5136 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5137 cmd_flush, "flush");
5138 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5139 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5140 cmd_cycles, RTE_UINT8);
5142 cmdline_parse_inst_t cmd_gro_flush = {
5143 .f = cmd_gro_flush_parsed,
5145 .help_str = "set gro flush <cycles>",
5147 (void *)&cmd_gro_flush_set,
5148 (void *)&cmd_gro_flush_keyword,
5149 (void *)&cmd_gro_flush_flush,
5150 (void *)&cmd_gro_flush_cycles,
5155 /* *** ENABLE/DISABLE GSO *** */
5156 struct cmd_gso_enable_result {
5157 cmdline_fixed_string_t cmd_set;
5158 cmdline_fixed_string_t cmd_port;
5159 cmdline_fixed_string_t cmd_keyword;
5160 cmdline_fixed_string_t cmd_mode;
5165 cmd_gso_enable_parsed(void *parsed_result,
5166 __rte_unused struct cmdline *cl,
5167 __rte_unused void *data)
5169 struct cmd_gso_enable_result *res;
5171 res = parsed_result;
5172 if (!strcmp(res->cmd_keyword, "gso"))
5173 setup_gso(res->cmd_mode, res->cmd_pid);
5176 cmdline_parse_token_string_t cmd_gso_enable_set =
5177 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5179 cmdline_parse_token_string_t cmd_gso_enable_port =
5180 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5182 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5183 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5184 cmd_keyword, "gso");
5185 cmdline_parse_token_string_t cmd_gso_enable_mode =
5186 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5187 cmd_mode, "on#off");
5188 cmdline_parse_token_num_t cmd_gso_enable_pid =
5189 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5190 cmd_pid, RTE_UINT16);
5192 cmdline_parse_inst_t cmd_gso_enable = {
5193 .f = cmd_gso_enable_parsed,
5195 .help_str = "set port <port_id> gso on|off",
5197 (void *)&cmd_gso_enable_set,
5198 (void *)&cmd_gso_enable_port,
5199 (void *)&cmd_gso_enable_pid,
5200 (void *)&cmd_gso_enable_keyword,
5201 (void *)&cmd_gso_enable_mode,
5206 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5207 struct cmd_gso_size_result {
5208 cmdline_fixed_string_t cmd_set;
5209 cmdline_fixed_string_t cmd_keyword;
5210 cmdline_fixed_string_t cmd_segsz;
5215 cmd_gso_size_parsed(void *parsed_result,
5216 __rte_unused struct cmdline *cl,
5217 __rte_unused void *data)
5219 struct cmd_gso_size_result *res = parsed_result;
5221 if (test_done == 0) {
5222 printf("Before setting GSO segsz, please first"
5223 " stop forwarding\n");
5227 if (!strcmp(res->cmd_keyword, "gso") &&
5228 !strcmp(res->cmd_segsz, "segsz")) {
5229 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5230 printf("gso_size should be larger than %zu."
5231 " Please input a legal value\n",
5232 RTE_GSO_SEG_SIZE_MIN);
5234 gso_max_segment_size = res->cmd_size;
5238 cmdline_parse_token_string_t cmd_gso_size_set =
5239 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5241 cmdline_parse_token_string_t cmd_gso_size_keyword =
5242 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5243 cmd_keyword, "gso");
5244 cmdline_parse_token_string_t cmd_gso_size_segsz =
5245 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5246 cmd_segsz, "segsz");
5247 cmdline_parse_token_num_t cmd_gso_size_size =
5248 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5249 cmd_size, RTE_UINT16);
5251 cmdline_parse_inst_t cmd_gso_size = {
5252 .f = cmd_gso_size_parsed,
5254 .help_str = "set gso segsz <length>",
5256 (void *)&cmd_gso_size_set,
5257 (void *)&cmd_gso_size_keyword,
5258 (void *)&cmd_gso_size_segsz,
5259 (void *)&cmd_gso_size_size,
5264 /* *** SHOW GSO CONFIGURATION *** */
5265 struct cmd_gso_show_result {
5266 cmdline_fixed_string_t cmd_show;
5267 cmdline_fixed_string_t cmd_port;
5268 cmdline_fixed_string_t cmd_keyword;
5273 cmd_gso_show_parsed(void *parsed_result,
5274 __rte_unused struct cmdline *cl,
5275 __rte_unused void *data)
5277 struct cmd_gso_show_result *res = parsed_result;
5279 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5280 printf("invalid port id %u\n", res->cmd_pid);
5283 if (!strcmp(res->cmd_keyword, "gso")) {
5284 if (gso_ports[res->cmd_pid].enable) {
5285 printf("Max GSO'd packet size: %uB\n"
5286 "Supported GSO types: TCP/IPv4, "
5287 "UDP/IPv4, VxLAN with inner "
5288 "TCP/IPv4 packet, GRE with inner "
5289 "TCP/IPv4 packet\n",
5290 gso_max_segment_size);
5292 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5296 cmdline_parse_token_string_t cmd_gso_show_show =
5297 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5299 cmdline_parse_token_string_t cmd_gso_show_port =
5300 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5302 cmdline_parse_token_string_t cmd_gso_show_keyword =
5303 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5304 cmd_keyword, "gso");
5305 cmdline_parse_token_num_t cmd_gso_show_pid =
5306 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5307 cmd_pid, RTE_UINT16);
5309 cmdline_parse_inst_t cmd_gso_show = {
5310 .f = cmd_gso_show_parsed,
5312 .help_str = "show port <port_id> gso",
5314 (void *)&cmd_gso_show_show,
5315 (void *)&cmd_gso_show_port,
5316 (void *)&cmd_gso_show_pid,
5317 (void *)&cmd_gso_show_keyword,
5322 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5323 struct cmd_set_flush_rx {
5324 cmdline_fixed_string_t set;
5325 cmdline_fixed_string_t flush_rx;
5326 cmdline_fixed_string_t mode;
5330 cmd_set_flush_rx_parsed(void *parsed_result,
5331 __rte_unused struct cmdline *cl,
5332 __rte_unused void *data)
5334 struct cmd_set_flush_rx *res = parsed_result;
5335 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5338 cmdline_parse_token_string_t cmd_setflushrx_set =
5339 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5341 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5342 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5343 flush_rx, "flush_rx");
5344 cmdline_parse_token_string_t cmd_setflushrx_mode =
5345 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5349 cmdline_parse_inst_t cmd_set_flush_rx = {
5350 .f = cmd_set_flush_rx_parsed,
5351 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5354 (void *)&cmd_setflushrx_set,
5355 (void *)&cmd_setflushrx_flush_rx,
5356 (void *)&cmd_setflushrx_mode,
5361 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5362 struct cmd_set_link_check {
5363 cmdline_fixed_string_t set;
5364 cmdline_fixed_string_t link_check;
5365 cmdline_fixed_string_t mode;
5369 cmd_set_link_check_parsed(void *parsed_result,
5370 __rte_unused struct cmdline *cl,
5371 __rte_unused void *data)
5373 struct cmd_set_link_check *res = parsed_result;
5374 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5377 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5378 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5380 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5381 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5382 link_check, "link_check");
5383 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5384 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5388 cmdline_parse_inst_t cmd_set_link_check = {
5389 .f = cmd_set_link_check_parsed,
5390 .help_str = "set link_check on|off: Enable/Disable link status check "
5391 "when starting/stopping a port",
5394 (void *)&cmd_setlinkcheck_set,
5395 (void *)&cmd_setlinkcheck_link_check,
5396 (void *)&cmd_setlinkcheck_mode,
5401 /* *** SET NIC BYPASS MODE *** */
5402 struct cmd_set_bypass_mode_result {
5403 cmdline_fixed_string_t set;
5404 cmdline_fixed_string_t bypass;
5405 cmdline_fixed_string_t mode;
5406 cmdline_fixed_string_t value;
5411 cmd_set_bypass_mode_parsed(void *parsed_result,
5412 __rte_unused struct cmdline *cl,
5413 __rte_unused void *data)
5415 struct cmd_set_bypass_mode_result *res = parsed_result;
5416 portid_t port_id = res->port_id;
5417 int32_t rc = -EINVAL;
5419 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5420 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5422 if (!strcmp(res->value, "bypass"))
5423 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5424 else if (!strcmp(res->value, "isolate"))
5425 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5427 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5429 /* Set the bypass mode for the relevant port. */
5430 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5433 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5436 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5437 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5439 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5440 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5442 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5443 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5445 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5446 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5447 value, "normal#bypass#isolate");
5448 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5449 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5450 port_id, RTE_UINT16);
5452 cmdline_parse_inst_t cmd_set_bypass_mode = {
5453 .f = cmd_set_bypass_mode_parsed,
5454 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5455 "Set the NIC bypass mode for port_id",
5458 (void *)&cmd_setbypass_mode_set,
5459 (void *)&cmd_setbypass_mode_bypass,
5460 (void *)&cmd_setbypass_mode_mode,
5461 (void *)&cmd_setbypass_mode_value,
5462 (void *)&cmd_setbypass_mode_port,
5467 /* *** SET NIC BYPASS EVENT *** */
5468 struct cmd_set_bypass_event_result {
5469 cmdline_fixed_string_t set;
5470 cmdline_fixed_string_t bypass;
5471 cmdline_fixed_string_t event;
5472 cmdline_fixed_string_t event_value;
5473 cmdline_fixed_string_t mode;
5474 cmdline_fixed_string_t mode_value;
5479 cmd_set_bypass_event_parsed(void *parsed_result,
5480 __rte_unused struct cmdline *cl,
5481 __rte_unused void *data)
5483 int32_t rc = -EINVAL;
5484 struct cmd_set_bypass_event_result *res = parsed_result;
5485 portid_t port_id = res->port_id;
5487 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5488 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5489 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5491 if (!strcmp(res->event_value, "timeout"))
5492 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5493 else if (!strcmp(res->event_value, "os_on"))
5494 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5495 else if (!strcmp(res->event_value, "os_off"))
5496 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5497 else if (!strcmp(res->event_value, "power_on"))
5498 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5499 else if (!strcmp(res->event_value, "power_off"))
5500 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5502 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5504 if (!strcmp(res->mode_value, "bypass"))
5505 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5506 else if (!strcmp(res->mode_value, "isolate"))
5507 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5509 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5511 /* Set the watchdog timeout. */
5512 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5515 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5516 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5520 printf("Failed to set timeout value %u "
5521 "for port %d, errto code: %d.\n",
5522 bypass_timeout, port_id, rc);
5526 /* Set the bypass event to transition to bypass mode. */
5527 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5532 printf("\t Failed to set bypass event for port = %d.\n",
5536 cmdline_parse_token_string_t cmd_setbypass_event_set =
5537 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5539 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5540 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5542 cmdline_parse_token_string_t cmd_setbypass_event_event =
5543 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5545 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5546 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5547 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5548 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5549 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5551 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5552 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5553 mode_value, "normal#bypass#isolate");
5554 cmdline_parse_token_num_t cmd_setbypass_event_port =
5555 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5556 port_id, RTE_UINT16);
5558 cmdline_parse_inst_t cmd_set_bypass_event = {
5559 .f = cmd_set_bypass_event_parsed,
5560 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5561 "power_off mode normal|bypass|isolate <port_id>: "
5562 "Set the NIC bypass event mode for port_id",
5565 (void *)&cmd_setbypass_event_set,
5566 (void *)&cmd_setbypass_event_bypass,
5567 (void *)&cmd_setbypass_event_event,
5568 (void *)&cmd_setbypass_event_event_value,
5569 (void *)&cmd_setbypass_event_mode,
5570 (void *)&cmd_setbypass_event_mode_value,
5571 (void *)&cmd_setbypass_event_port,
5577 /* *** SET NIC BYPASS TIMEOUT *** */
5578 struct cmd_set_bypass_timeout_result {
5579 cmdline_fixed_string_t set;
5580 cmdline_fixed_string_t bypass;
5581 cmdline_fixed_string_t timeout;
5582 cmdline_fixed_string_t value;
5586 cmd_set_bypass_timeout_parsed(void *parsed_result,
5587 __rte_unused struct cmdline *cl,
5588 __rte_unused void *data)
5590 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5592 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5593 if (!strcmp(res->value, "1.5"))
5594 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5595 else if (!strcmp(res->value, "2"))
5596 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5597 else if (!strcmp(res->value, "3"))
5598 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5599 else if (!strcmp(res->value, "4"))
5600 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5601 else if (!strcmp(res->value, "8"))
5602 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5603 else if (!strcmp(res->value, "16"))
5604 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5605 else if (!strcmp(res->value, "32"))
5606 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5608 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5612 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5613 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5615 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5616 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5618 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5619 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5620 timeout, "timeout");
5621 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5622 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5623 value, "0#1.5#2#3#4#8#16#32");
5625 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5626 .f = cmd_set_bypass_timeout_parsed,
5627 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5628 "Set the NIC bypass watchdog timeout in seconds",
5631 (void *)&cmd_setbypass_timeout_set,
5632 (void *)&cmd_setbypass_timeout_bypass,
5633 (void *)&cmd_setbypass_timeout_timeout,
5634 (void *)&cmd_setbypass_timeout_value,
5639 /* *** SHOW NIC BYPASS MODE *** */
5640 struct cmd_show_bypass_config_result {
5641 cmdline_fixed_string_t show;
5642 cmdline_fixed_string_t bypass;
5643 cmdline_fixed_string_t config;
5648 cmd_show_bypass_config_parsed(void *parsed_result,
5649 __rte_unused struct cmdline *cl,
5650 __rte_unused void *data)
5652 struct cmd_show_bypass_config_result *res = parsed_result;
5653 portid_t port_id = res->port_id;
5655 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5656 uint32_t event_mode;
5657 uint32_t bypass_mode;
5658 uint32_t timeout = bypass_timeout;
5661 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5662 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5663 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5664 {"UNKNOWN", "normal", "bypass", "isolate"};
5665 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5673 /* Display the bypass mode.*/
5674 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5675 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5679 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5680 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5682 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5685 /* Display the bypass timeout.*/
5686 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5687 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5689 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5691 /* Display the bypass events and associated modes. */
5692 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5694 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5695 printf("\tFailed to get bypass mode for event = %s\n",
5698 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5699 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5701 printf("\tbypass event: %-16s = %s\n", events[i],
5707 printf("\tFailed to get bypass configuration for port = %d\n",
5711 cmdline_parse_token_string_t cmd_showbypass_config_show =
5712 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5714 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5715 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5717 cmdline_parse_token_string_t cmd_showbypass_config_config =
5718 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5720 cmdline_parse_token_num_t cmd_showbypass_config_port =
5721 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5722 port_id, RTE_UINT16);
5724 cmdline_parse_inst_t cmd_show_bypass_config = {
5725 .f = cmd_show_bypass_config_parsed,
5726 .help_str = "show bypass config <port_id>: "
5727 "Show the NIC bypass config for port_id",
5730 (void *)&cmd_showbypass_config_show,
5731 (void *)&cmd_showbypass_config_bypass,
5732 (void *)&cmd_showbypass_config_config,
5733 (void *)&cmd_showbypass_config_port,
5739 /* *** SET BONDING MODE *** */
5740 struct cmd_set_bonding_mode_result {
5741 cmdline_fixed_string_t set;
5742 cmdline_fixed_string_t bonding;
5743 cmdline_fixed_string_t mode;
5748 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5749 __rte_unused struct cmdline *cl,
5750 __rte_unused void *data)
5752 struct cmd_set_bonding_mode_result *res = parsed_result;
5753 portid_t port_id = res->port_id;
5755 /* Set the bonding mode for the relevant port. */
5756 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5757 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5760 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5761 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5763 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5764 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5765 bonding, "bonding");
5766 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5767 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5769 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5770 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5772 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5773 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5774 port_id, RTE_UINT16);
5776 cmdline_parse_inst_t cmd_set_bonding_mode = {
5777 .f = cmd_set_bonding_mode_parsed,
5778 .help_str = "set bonding mode <mode_value> <port_id>: "
5779 "Set the bonding mode for port_id",
5782 (void *) &cmd_setbonding_mode_set,
5783 (void *) &cmd_setbonding_mode_bonding,
5784 (void *) &cmd_setbonding_mode_mode,
5785 (void *) &cmd_setbonding_mode_value,
5786 (void *) &cmd_setbonding_mode_port,
5791 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5792 struct cmd_set_bonding_lacp_dedicated_queues_result {
5793 cmdline_fixed_string_t set;
5794 cmdline_fixed_string_t bonding;
5795 cmdline_fixed_string_t lacp;
5796 cmdline_fixed_string_t dedicated_queues;
5798 cmdline_fixed_string_t mode;
5801 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5802 __rte_unused struct cmdline *cl,
5803 __rte_unused void *data)
5805 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5806 portid_t port_id = res->port_id;
5807 struct rte_port *port;
5809 port = &ports[port_id];
5811 /** Check if the port is not started **/
5812 if (port->port_status != RTE_PORT_STOPPED) {
5813 printf("Please stop port %d first\n", port_id);
5817 if (!strcmp(res->mode, "enable")) {
5818 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5819 printf("Dedicate queues for LACP control packets"
5822 printf("Enabling dedicate queues for LACP control "
5823 "packets on port %d failed\n", port_id);
5824 } else if (!strcmp(res->mode, "disable")) {
5825 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5826 printf("Dedicated queues for LACP control packets "
5829 printf("Disabling dedicated queues for LACP control "
5830 "traffic on port %d failed\n", port_id);
5834 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5835 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5837 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5838 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5839 bonding, "bonding");
5840 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5841 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5843 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5844 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5845 dedicated_queues, "dedicated_queues");
5846 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5847 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5848 port_id, RTE_UINT16);
5849 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5850 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5851 mode, "enable#disable");
5853 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5854 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5855 .help_str = "set bonding lacp dedicated_queues <port_id> "
5857 "Enable/disable dedicated queues for LACP control traffic for port_id",
5860 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5861 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5862 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5863 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5864 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5865 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5870 /* *** SET BALANCE XMIT POLICY *** */
5871 struct cmd_set_bonding_balance_xmit_policy_result {
5872 cmdline_fixed_string_t set;
5873 cmdline_fixed_string_t bonding;
5874 cmdline_fixed_string_t balance_xmit_policy;
5876 cmdline_fixed_string_t policy;
5879 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5880 __rte_unused struct cmdline *cl,
5881 __rte_unused void *data)
5883 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5884 portid_t port_id = res->port_id;
5887 if (!strcmp(res->policy, "l2")) {
5888 policy = BALANCE_XMIT_POLICY_LAYER2;
5889 } else if (!strcmp(res->policy, "l23")) {
5890 policy = BALANCE_XMIT_POLICY_LAYER23;
5891 } else if (!strcmp(res->policy, "l34")) {
5892 policy = BALANCE_XMIT_POLICY_LAYER34;
5894 printf("\t Invalid xmit policy selection");
5898 /* Set the bonding mode for the relevant port. */
5899 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5900 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5905 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5906 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5908 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5909 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5910 bonding, "bonding");
5911 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5912 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5913 balance_xmit_policy, "balance_xmit_policy");
5914 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5915 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5916 port_id, RTE_UINT16);
5917 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5918 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5919 policy, "l2#l23#l34");
5921 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5922 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5923 .help_str = "set bonding balance_xmit_policy <port_id> "
5925 "Set the bonding balance_xmit_policy for port_id",
5928 (void *)&cmd_setbonding_balance_xmit_policy_set,
5929 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5930 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5931 (void *)&cmd_setbonding_balance_xmit_policy_port,
5932 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5937 /* *** SHOW NIC BONDING CONFIGURATION *** */
5938 struct cmd_show_bonding_config_result {
5939 cmdline_fixed_string_t show;
5940 cmdline_fixed_string_t bonding;
5941 cmdline_fixed_string_t config;
5945 static void cmd_show_bonding_config_parsed(void *parsed_result,
5946 __rte_unused struct cmdline *cl,
5947 __rte_unused void *data)
5949 struct cmd_show_bonding_config_result *res = parsed_result;
5950 int bonding_mode, agg_mode;
5951 portid_t slaves[RTE_MAX_ETHPORTS];
5952 int num_slaves, num_active_slaves;
5955 portid_t port_id = res->port_id;
5957 /* Display the bonding mode.*/
5958 bonding_mode = rte_eth_bond_mode_get(port_id);
5959 if (bonding_mode < 0) {
5960 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5963 printf("\tBonding mode: %d\n", bonding_mode);
5965 if (bonding_mode == BONDING_MODE_BALANCE) {
5966 int balance_xmit_policy;
5968 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5969 if (balance_xmit_policy < 0) {
5970 printf("\tFailed to get balance xmit policy for port = %d\n",
5974 printf("\tBalance Xmit Policy: ");
5976 switch (balance_xmit_policy) {
5977 case BALANCE_XMIT_POLICY_LAYER2:
5978 printf("BALANCE_XMIT_POLICY_LAYER2");
5980 case BALANCE_XMIT_POLICY_LAYER23:
5981 printf("BALANCE_XMIT_POLICY_LAYER23");
5983 case BALANCE_XMIT_POLICY_LAYER34:
5984 printf("BALANCE_XMIT_POLICY_LAYER34");
5991 if (bonding_mode == BONDING_MODE_8023AD) {
5992 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5993 printf("\tIEEE802.3AD Aggregator Mode: ");
5996 printf("bandwidth");
6008 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6010 if (num_slaves < 0) {
6011 printf("\tFailed to get slave list for port = %d\n", port_id);
6014 if (num_slaves > 0) {
6015 printf("\tSlaves (%d): [", num_slaves);
6016 for (i = 0; i < num_slaves - 1; i++)
6017 printf("%d ", slaves[i]);
6019 printf("%d]\n", slaves[num_slaves - 1]);
6021 printf("\tSlaves: []\n");
6025 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6028 if (num_active_slaves < 0) {
6029 printf("\tFailed to get active slave list for port = %d\n", port_id);
6032 if (num_active_slaves > 0) {
6033 printf("\tActive Slaves (%d): [", num_active_slaves);
6034 for (i = 0; i < num_active_slaves - 1; i++)
6035 printf("%d ", slaves[i]);
6037 printf("%d]\n", slaves[num_active_slaves - 1]);
6040 printf("\tActive Slaves: []\n");
6044 primary_id = rte_eth_bond_primary_get(port_id);
6045 if (primary_id < 0) {
6046 printf("\tFailed to get primary slave for port = %d\n", port_id);
6049 printf("\tPrimary: [%d]\n", primary_id);
6053 cmdline_parse_token_string_t cmd_showbonding_config_show =
6054 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6056 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6057 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6058 bonding, "bonding");
6059 cmdline_parse_token_string_t cmd_showbonding_config_config =
6060 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6062 cmdline_parse_token_num_t cmd_showbonding_config_port =
6063 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6064 port_id, RTE_UINT16);
6066 cmdline_parse_inst_t cmd_show_bonding_config = {
6067 .f = cmd_show_bonding_config_parsed,
6068 .help_str = "show bonding config <port_id>: "
6069 "Show the bonding config for port_id",
6072 (void *)&cmd_showbonding_config_show,
6073 (void *)&cmd_showbonding_config_bonding,
6074 (void *)&cmd_showbonding_config_config,
6075 (void *)&cmd_showbonding_config_port,
6080 /* *** SET BONDING PRIMARY *** */
6081 struct cmd_set_bonding_primary_result {
6082 cmdline_fixed_string_t set;
6083 cmdline_fixed_string_t bonding;
6084 cmdline_fixed_string_t primary;
6089 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6090 __rte_unused struct cmdline *cl,
6091 __rte_unused void *data)
6093 struct cmd_set_bonding_primary_result *res = parsed_result;
6094 portid_t master_port_id = res->port_id;
6095 portid_t slave_port_id = res->slave_id;
6097 /* Set the primary slave for a bonded device. */
6098 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6099 printf("\t Failed to set primary slave for port = %d.\n",
6106 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6107 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6109 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6110 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6111 bonding, "bonding");
6112 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6113 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6114 primary, "primary");
6115 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6116 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6117 slave_id, RTE_UINT16);
6118 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6119 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6120 port_id, RTE_UINT16);
6122 cmdline_parse_inst_t cmd_set_bonding_primary = {
6123 .f = cmd_set_bonding_primary_parsed,
6124 .help_str = "set bonding primary <slave_id> <port_id>: "
6125 "Set the primary slave for port_id",
6128 (void *)&cmd_setbonding_primary_set,
6129 (void *)&cmd_setbonding_primary_bonding,
6130 (void *)&cmd_setbonding_primary_primary,
6131 (void *)&cmd_setbonding_primary_slave,
6132 (void *)&cmd_setbonding_primary_port,
6137 /* *** ADD SLAVE *** */
6138 struct cmd_add_bonding_slave_result {
6139 cmdline_fixed_string_t add;
6140 cmdline_fixed_string_t bonding;
6141 cmdline_fixed_string_t slave;
6146 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6147 __rte_unused struct cmdline *cl,
6148 __rte_unused void *data)
6150 struct cmd_add_bonding_slave_result *res = parsed_result;
6151 portid_t master_port_id = res->port_id;
6152 portid_t slave_port_id = res->slave_id;
6154 /* add the slave for a bonded device. */
6155 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6156 printf("\t Failed to add slave %d to master port = %d.\n",
6157 slave_port_id, master_port_id);
6161 set_port_slave_flag(slave_port_id);
6164 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6165 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6167 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6168 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6169 bonding, "bonding");
6170 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6171 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6173 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6174 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6175 slave_id, RTE_UINT16);
6176 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6177 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6178 port_id, RTE_UINT16);
6180 cmdline_parse_inst_t cmd_add_bonding_slave = {
6181 .f = cmd_add_bonding_slave_parsed,
6182 .help_str = "add bonding slave <slave_id> <port_id>: "
6183 "Add a slave device to a bonded device",
6186 (void *)&cmd_addbonding_slave_add,
6187 (void *)&cmd_addbonding_slave_bonding,
6188 (void *)&cmd_addbonding_slave_slave,
6189 (void *)&cmd_addbonding_slave_slaveid,
6190 (void *)&cmd_addbonding_slave_port,
6195 /* *** REMOVE SLAVE *** */
6196 struct cmd_remove_bonding_slave_result {
6197 cmdline_fixed_string_t remove;
6198 cmdline_fixed_string_t bonding;
6199 cmdline_fixed_string_t slave;
6204 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6205 __rte_unused struct cmdline *cl,
6206 __rte_unused void *data)
6208 struct cmd_remove_bonding_slave_result *res = parsed_result;
6209 portid_t master_port_id = res->port_id;
6210 portid_t slave_port_id = res->slave_id;
6212 /* remove the slave from a bonded device. */
6213 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6214 printf("\t Failed to remove slave %d from master port = %d.\n",
6215 slave_port_id, master_port_id);
6219 clear_port_slave_flag(slave_port_id);
6222 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6223 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6225 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6226 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6227 bonding, "bonding");
6228 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6229 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6231 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6232 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6233 slave_id, RTE_UINT16);
6234 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6235 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6236 port_id, RTE_UINT16);
6238 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6239 .f = cmd_remove_bonding_slave_parsed,
6240 .help_str = "remove bonding slave <slave_id> <port_id>: "
6241 "Remove a slave device from a bonded device",
6244 (void *)&cmd_removebonding_slave_remove,
6245 (void *)&cmd_removebonding_slave_bonding,
6246 (void *)&cmd_removebonding_slave_slave,
6247 (void *)&cmd_removebonding_slave_slaveid,
6248 (void *)&cmd_removebonding_slave_port,
6253 /* *** CREATE BONDED DEVICE *** */
6254 struct cmd_create_bonded_device_result {
6255 cmdline_fixed_string_t create;
6256 cmdline_fixed_string_t bonded;
6257 cmdline_fixed_string_t device;
6262 static int bond_dev_num = 0;
6264 static void cmd_create_bonded_device_parsed(void *parsed_result,
6265 __rte_unused struct cmdline *cl,
6266 __rte_unused void *data)
6268 struct cmd_create_bonded_device_result *res = parsed_result;
6269 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6273 if (test_done == 0) {
6274 printf("Please stop forwarding first\n");
6278 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6281 /* Create a new bonded device. */
6282 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6284 printf("\t Failed to create bonded device.\n");
6287 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6290 /* Update number of ports */
6291 nb_ports = rte_eth_dev_count_avail();
6292 reconfig(port_id, res->socket);
6293 ret = rte_eth_promiscuous_enable(port_id);
6295 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6296 port_id, rte_strerror(-ret));
6298 ports[port_id].need_setup = 0;
6299 ports[port_id].port_status = RTE_PORT_STOPPED;
6304 cmdline_parse_token_string_t cmd_createbonded_device_create =
6305 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6307 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6308 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6310 cmdline_parse_token_string_t cmd_createbonded_device_device =
6311 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6313 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6314 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6316 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6317 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6320 cmdline_parse_inst_t cmd_create_bonded_device = {
6321 .f = cmd_create_bonded_device_parsed,
6322 .help_str = "create bonded device <mode> <socket>: "
6323 "Create a new bonded device with specific bonding mode and socket",
6326 (void *)&cmd_createbonded_device_create,
6327 (void *)&cmd_createbonded_device_bonded,
6328 (void *)&cmd_createbonded_device_device,
6329 (void *)&cmd_createbonded_device_mode,
6330 (void *)&cmd_createbonded_device_socket,
6335 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6336 struct cmd_set_bond_mac_addr_result {
6337 cmdline_fixed_string_t set;
6338 cmdline_fixed_string_t bonding;
6339 cmdline_fixed_string_t mac_addr;
6341 struct rte_ether_addr address;
6344 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6345 __rte_unused struct cmdline *cl,
6346 __rte_unused void *data)
6348 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6351 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6354 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6356 /* check the return value and print it if is < 0 */
6358 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6361 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6362 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6363 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6364 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6366 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6367 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6369 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6370 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6371 port_num, RTE_UINT16);
6372 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6373 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6375 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6376 .f = cmd_set_bond_mac_addr_parsed,
6378 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6380 (void *)&cmd_set_bond_mac_addr_set,
6381 (void *)&cmd_set_bond_mac_addr_bonding,
6382 (void *)&cmd_set_bond_mac_addr_mac,
6383 (void *)&cmd_set_bond_mac_addr_portnum,
6384 (void *)&cmd_set_bond_mac_addr_addr,
6390 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6391 struct cmd_set_bond_mon_period_result {
6392 cmdline_fixed_string_t set;
6393 cmdline_fixed_string_t bonding;
6394 cmdline_fixed_string_t mon_period;
6399 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6400 __rte_unused struct cmdline *cl,
6401 __rte_unused void *data)
6403 struct cmd_set_bond_mon_period_result *res = parsed_result;
6406 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6408 /* check the return value and print it if is < 0 */
6410 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6413 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6414 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6416 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6417 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6418 bonding, "bonding");
6419 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6420 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6421 mon_period, "mon_period");
6422 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6423 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6424 port_num, RTE_UINT16);
6425 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6426 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6427 period_ms, RTE_UINT32);
6429 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6430 .f = cmd_set_bond_mon_period_parsed,
6432 .help_str = "set bonding mon_period <port_id> <period_ms>",
6434 (void *)&cmd_set_bond_mon_period_set,
6435 (void *)&cmd_set_bond_mon_period_bonding,
6436 (void *)&cmd_set_bond_mon_period_mon_period,
6437 (void *)&cmd_set_bond_mon_period_portnum,
6438 (void *)&cmd_set_bond_mon_period_period_ms,
6445 struct cmd_set_bonding_agg_mode_policy_result {
6446 cmdline_fixed_string_t set;
6447 cmdline_fixed_string_t bonding;
6448 cmdline_fixed_string_t agg_mode;
6450 cmdline_fixed_string_t policy;
6455 cmd_set_bonding_agg_mode(void *parsed_result,
6456 __rte_unused struct cmdline *cl,
6457 __rte_unused void *data)
6459 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6460 uint8_t policy = AGG_BANDWIDTH;
6462 if (!strcmp(res->policy, "bandwidth"))
6463 policy = AGG_BANDWIDTH;
6464 else if (!strcmp(res->policy, "stable"))
6465 policy = AGG_STABLE;
6466 else if (!strcmp(res->policy, "count"))
6469 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6473 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6474 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6476 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6477 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6478 bonding, "bonding");
6480 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6481 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6482 agg_mode, "agg_mode");
6484 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6485 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6486 port_num, RTE_UINT16);
6488 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6489 TOKEN_STRING_INITIALIZER(
6490 struct cmd_set_bonding_balance_xmit_policy_result,
6491 policy, "stable#bandwidth#count");
6493 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6494 .f = cmd_set_bonding_agg_mode,
6496 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6498 (void *)&cmd_set_bonding_agg_mode_set,
6499 (void *)&cmd_set_bonding_agg_mode_bonding,
6500 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6501 (void *)&cmd_set_bonding_agg_mode_portnum,
6502 (void *)&cmd_set_bonding_agg_mode_policy_string,
6508 #endif /* RTE_NET_BOND */
6510 /* *** SET FORWARDING MODE *** */
6511 struct cmd_set_fwd_mode_result {
6512 cmdline_fixed_string_t set;
6513 cmdline_fixed_string_t fwd;
6514 cmdline_fixed_string_t mode;
6517 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6518 __rte_unused struct cmdline *cl,
6519 __rte_unused void *data)
6521 struct cmd_set_fwd_mode_result *res = parsed_result;
6524 set_pkt_forwarding_mode(res->mode);
6527 cmdline_parse_token_string_t cmd_setfwd_set =
6528 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6529 cmdline_parse_token_string_t cmd_setfwd_fwd =
6530 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6531 cmdline_parse_token_string_t cmd_setfwd_mode =
6532 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6533 "" /* defined at init */);
6535 cmdline_parse_inst_t cmd_set_fwd_mode = {
6536 .f = cmd_set_fwd_mode_parsed,
6538 .help_str = NULL, /* defined at init */
6540 (void *)&cmd_setfwd_set,
6541 (void *)&cmd_setfwd_fwd,
6542 (void *)&cmd_setfwd_mode,
6547 static void cmd_set_fwd_mode_init(void)
6550 static char token[128];
6551 static char help[256];
6552 cmdline_parse_token_string_t *token_struct;
6554 modes = list_pkt_forwarding_modes();
6555 snprintf(help, sizeof(help), "set fwd %s: "
6556 "Set packet forwarding mode", modes);
6557 cmd_set_fwd_mode.help_str = help;
6559 /* string token separator is # */
6560 for (c = token; *modes != '\0'; modes++)
6565 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6566 token_struct->string_data.str = token;
6569 /* *** SET RETRY FORWARDING MODE *** */
6570 struct cmd_set_fwd_retry_mode_result {
6571 cmdline_fixed_string_t set;
6572 cmdline_fixed_string_t fwd;
6573 cmdline_fixed_string_t mode;
6574 cmdline_fixed_string_t retry;
6577 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6578 __rte_unused struct cmdline *cl,
6579 __rte_unused void *data)
6581 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6584 set_pkt_forwarding_mode(res->mode);
6587 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6588 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6590 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6591 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6593 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6594 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6596 "" /* defined at init */);
6597 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6598 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6601 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6602 .f = cmd_set_fwd_retry_mode_parsed,
6604 .help_str = NULL, /* defined at init */
6606 (void *)&cmd_setfwd_retry_set,
6607 (void *)&cmd_setfwd_retry_fwd,
6608 (void *)&cmd_setfwd_retry_mode,
6609 (void *)&cmd_setfwd_retry_retry,
6614 static void cmd_set_fwd_retry_mode_init(void)
6617 static char token[128];
6618 static char help[256];
6619 cmdline_parse_token_string_t *token_struct;
6621 modes = list_pkt_forwarding_retry_modes();
6622 snprintf(help, sizeof(help), "set fwd %s retry: "
6623 "Set packet forwarding mode with retry", modes);
6624 cmd_set_fwd_retry_mode.help_str = help;
6626 /* string token separator is # */
6627 for (c = token; *modes != '\0'; modes++)
6632 token_struct = (cmdline_parse_token_string_t *)
6633 cmd_set_fwd_retry_mode.tokens[2];
6634 token_struct->string_data.str = token;
6637 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6638 struct cmd_set_burst_tx_retry_result {
6639 cmdline_fixed_string_t set;
6640 cmdline_fixed_string_t burst;
6641 cmdline_fixed_string_t tx;
6642 cmdline_fixed_string_t delay;
6644 cmdline_fixed_string_t retry;
6648 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6649 __rte_unused struct cmdline *cl,
6650 __rte_unused void *data)
6652 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6654 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6655 && !strcmp(res->tx, "tx")) {
6656 if (!strcmp(res->delay, "delay"))
6657 burst_tx_delay_time = res->time;
6658 if (!strcmp(res->retry, "retry"))
6659 burst_tx_retry_num = res->retry_num;
6664 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6665 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6666 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6667 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6669 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6670 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6671 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6672 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6673 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6674 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
6676 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6677 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6678 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6679 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
6682 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6683 .f = cmd_set_burst_tx_retry_parsed,
6684 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6686 (void *)&cmd_set_burst_tx_retry_set,
6687 (void *)&cmd_set_burst_tx_retry_burst,
6688 (void *)&cmd_set_burst_tx_retry_tx,
6689 (void *)&cmd_set_burst_tx_retry_delay,
6690 (void *)&cmd_set_burst_tx_retry_time,
6691 (void *)&cmd_set_burst_tx_retry_retry,
6692 (void *)&cmd_set_burst_tx_retry_retry_num,
6697 /* *** SET PROMISC MODE *** */
6698 struct cmd_set_promisc_mode_result {
6699 cmdline_fixed_string_t set;
6700 cmdline_fixed_string_t promisc;
6701 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6702 uint16_t port_num; /* valid if "allports" argument == 0 */
6703 cmdline_fixed_string_t mode;
6706 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6707 __rte_unused struct cmdline *cl,
6710 struct cmd_set_promisc_mode_result *res = parsed_result;
6714 if (!strcmp(res->mode, "on"))
6721 RTE_ETH_FOREACH_DEV(i)
6722 eth_set_promisc_mode(i, enable);
6724 eth_set_promisc_mode(res->port_num, enable);
6728 cmdline_parse_token_string_t cmd_setpromisc_set =
6729 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6730 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6731 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6733 cmdline_parse_token_string_t cmd_setpromisc_portall =
6734 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6736 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6737 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6739 cmdline_parse_token_string_t cmd_setpromisc_mode =
6740 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6743 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6744 .f = cmd_set_promisc_mode_parsed,
6746 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6748 (void *)&cmd_setpromisc_set,
6749 (void *)&cmd_setpromisc_promisc,
6750 (void *)&cmd_setpromisc_portall,
6751 (void *)&cmd_setpromisc_mode,
6756 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6757 .f = cmd_set_promisc_mode_parsed,
6759 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6761 (void *)&cmd_setpromisc_set,
6762 (void *)&cmd_setpromisc_promisc,
6763 (void *)&cmd_setpromisc_portnum,
6764 (void *)&cmd_setpromisc_mode,
6769 /* *** SET ALLMULTI MODE *** */
6770 struct cmd_set_allmulti_mode_result {
6771 cmdline_fixed_string_t set;
6772 cmdline_fixed_string_t allmulti;
6773 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6774 uint16_t port_num; /* valid if "allports" argument == 0 */
6775 cmdline_fixed_string_t mode;
6778 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6779 __rte_unused struct cmdline *cl,
6782 struct cmd_set_allmulti_mode_result *res = parsed_result;
6786 if (!strcmp(res->mode, "on"))
6793 RTE_ETH_FOREACH_DEV(i) {
6794 eth_set_allmulticast_mode(i, enable);
6798 eth_set_allmulticast_mode(res->port_num, enable);
6802 cmdline_parse_token_string_t cmd_setallmulti_set =
6803 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6804 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6805 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6807 cmdline_parse_token_string_t cmd_setallmulti_portall =
6808 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6810 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6811 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6813 cmdline_parse_token_string_t cmd_setallmulti_mode =
6814 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6817 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6818 .f = cmd_set_allmulti_mode_parsed,
6820 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6822 (void *)&cmd_setallmulti_set,
6823 (void *)&cmd_setallmulti_allmulti,
6824 (void *)&cmd_setallmulti_portall,
6825 (void *)&cmd_setallmulti_mode,
6830 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6831 .f = cmd_set_allmulti_mode_parsed,
6833 .help_str = "set allmulti <port_id> on|off: "
6834 "Set allmulti mode on port_id",
6836 (void *)&cmd_setallmulti_set,
6837 (void *)&cmd_setallmulti_allmulti,
6838 (void *)&cmd_setallmulti_portnum,
6839 (void *)&cmd_setallmulti_mode,
6844 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6845 struct cmd_link_flow_ctrl_set_result {
6846 cmdline_fixed_string_t set;
6847 cmdline_fixed_string_t flow_ctrl;
6848 cmdline_fixed_string_t rx;
6849 cmdline_fixed_string_t rx_lfc_mode;
6850 cmdline_fixed_string_t tx;
6851 cmdline_fixed_string_t tx_lfc_mode;
6852 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6853 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6854 cmdline_fixed_string_t autoneg_str;
6855 cmdline_fixed_string_t autoneg;
6856 cmdline_fixed_string_t hw_str;
6857 uint32_t high_water;
6858 cmdline_fixed_string_t lw_str;
6860 cmdline_fixed_string_t pt_str;
6861 uint16_t pause_time;
6862 cmdline_fixed_string_t xon_str;
6867 cmdline_parse_token_string_t cmd_lfc_set_set =
6868 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6870 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6871 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6872 flow_ctrl, "flow_ctrl");
6873 cmdline_parse_token_string_t cmd_lfc_set_rx =
6874 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6876 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6877 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6878 rx_lfc_mode, "on#off");
6879 cmdline_parse_token_string_t cmd_lfc_set_tx =
6880 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6882 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6883 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6884 tx_lfc_mode, "on#off");
6885 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6886 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6887 hw_str, "high_water");
6888 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6889 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6890 high_water, RTE_UINT32);
6891 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6892 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6893 lw_str, "low_water");
6894 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6895 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6896 low_water, RTE_UINT32);
6897 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6898 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6899 pt_str, "pause_time");
6900 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6901 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6902 pause_time, RTE_UINT16);
6903 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6904 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6905 xon_str, "send_xon");
6906 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6907 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6908 send_xon, RTE_UINT16);
6909 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6910 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6911 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6912 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6913 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6914 mac_ctrl_frame_fwd_mode, "on#off");
6915 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6916 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6917 autoneg_str, "autoneg");
6918 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6919 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6921 cmdline_parse_token_num_t cmd_lfc_set_portid =
6922 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6923 port_id, RTE_UINT16);
6925 /* forward declaration */
6927 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6930 cmdline_parse_inst_t cmd_link_flow_control_set = {
6931 .f = cmd_link_flow_ctrl_set_parsed,
6933 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6934 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6935 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6937 (void *)&cmd_lfc_set_set,
6938 (void *)&cmd_lfc_set_flow_ctrl,
6939 (void *)&cmd_lfc_set_rx,
6940 (void *)&cmd_lfc_set_rx_mode,
6941 (void *)&cmd_lfc_set_tx,
6942 (void *)&cmd_lfc_set_tx_mode,
6943 (void *)&cmd_lfc_set_high_water,
6944 (void *)&cmd_lfc_set_low_water,
6945 (void *)&cmd_lfc_set_pause_time,
6946 (void *)&cmd_lfc_set_send_xon,
6947 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6948 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6949 (void *)&cmd_lfc_set_autoneg_str,
6950 (void *)&cmd_lfc_set_autoneg,
6951 (void *)&cmd_lfc_set_portid,
6956 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6957 .f = cmd_link_flow_ctrl_set_parsed,
6958 .data = (void *)&cmd_link_flow_control_set_rx,
6959 .help_str = "set flow_ctrl rx on|off <port_id>: "
6960 "Change rx flow control parameter",
6962 (void *)&cmd_lfc_set_set,
6963 (void *)&cmd_lfc_set_flow_ctrl,
6964 (void *)&cmd_lfc_set_rx,
6965 (void *)&cmd_lfc_set_rx_mode,
6966 (void *)&cmd_lfc_set_portid,
6971 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6972 .f = cmd_link_flow_ctrl_set_parsed,
6973 .data = (void *)&cmd_link_flow_control_set_tx,
6974 .help_str = "set flow_ctrl tx on|off <port_id>: "
6975 "Change tx flow control parameter",
6977 (void *)&cmd_lfc_set_set,
6978 (void *)&cmd_lfc_set_flow_ctrl,
6979 (void *)&cmd_lfc_set_tx,
6980 (void *)&cmd_lfc_set_tx_mode,
6981 (void *)&cmd_lfc_set_portid,
6986 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6987 .f = cmd_link_flow_ctrl_set_parsed,
6988 .data = (void *)&cmd_link_flow_control_set_hw,
6989 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6990 "Change high water flow control parameter",
6992 (void *)&cmd_lfc_set_set,
6993 (void *)&cmd_lfc_set_flow_ctrl,
6994 (void *)&cmd_lfc_set_high_water_str,
6995 (void *)&cmd_lfc_set_high_water,
6996 (void *)&cmd_lfc_set_portid,
7001 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7002 .f = cmd_link_flow_ctrl_set_parsed,
7003 .data = (void *)&cmd_link_flow_control_set_lw,
7004 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7005 "Change low water flow control parameter",
7007 (void *)&cmd_lfc_set_set,
7008 (void *)&cmd_lfc_set_flow_ctrl,
7009 (void *)&cmd_lfc_set_low_water_str,
7010 (void *)&cmd_lfc_set_low_water,
7011 (void *)&cmd_lfc_set_portid,
7016 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7017 .f = cmd_link_flow_ctrl_set_parsed,
7018 .data = (void *)&cmd_link_flow_control_set_pt,
7019 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7020 "Change pause time flow control parameter",
7022 (void *)&cmd_lfc_set_set,
7023 (void *)&cmd_lfc_set_flow_ctrl,
7024 (void *)&cmd_lfc_set_pause_time_str,
7025 (void *)&cmd_lfc_set_pause_time,
7026 (void *)&cmd_lfc_set_portid,
7031 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7032 .f = cmd_link_flow_ctrl_set_parsed,
7033 .data = (void *)&cmd_link_flow_control_set_xon,
7034 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7035 "Change send_xon flow control parameter",
7037 (void *)&cmd_lfc_set_set,
7038 (void *)&cmd_lfc_set_flow_ctrl,
7039 (void *)&cmd_lfc_set_send_xon_str,
7040 (void *)&cmd_lfc_set_send_xon,
7041 (void *)&cmd_lfc_set_portid,
7046 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7047 .f = cmd_link_flow_ctrl_set_parsed,
7048 .data = (void *)&cmd_link_flow_control_set_macfwd,
7049 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7050 "Change mac ctrl fwd flow control parameter",
7052 (void *)&cmd_lfc_set_set,
7053 (void *)&cmd_lfc_set_flow_ctrl,
7054 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7055 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7056 (void *)&cmd_lfc_set_portid,
7061 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7062 .f = cmd_link_flow_ctrl_set_parsed,
7063 .data = (void *)&cmd_link_flow_control_set_autoneg,
7064 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7065 "Change autoneg flow control parameter",
7067 (void *)&cmd_lfc_set_set,
7068 (void *)&cmd_lfc_set_flow_ctrl,
7069 (void *)&cmd_lfc_set_autoneg_str,
7070 (void *)&cmd_lfc_set_autoneg,
7071 (void *)&cmd_lfc_set_portid,
7077 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7078 __rte_unused struct cmdline *cl,
7081 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7082 cmdline_parse_inst_t *cmd = data;
7083 struct rte_eth_fc_conf fc_conf;
7089 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7090 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7091 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7092 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7094 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7095 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7098 /* Partial command line, retrieve current configuration */
7100 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7102 printf("cannot get current flow ctrl parameters, return"
7103 "code = %d\n", ret);
7107 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7108 (fc_conf.mode == RTE_FC_FULL))
7110 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7111 (fc_conf.mode == RTE_FC_FULL))
7115 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7116 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7118 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7119 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7121 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7123 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7124 fc_conf.high_water = res->high_water;
7126 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7127 fc_conf.low_water = res->low_water;
7129 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7130 fc_conf.pause_time = res->pause_time;
7132 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7133 fc_conf.send_xon = res->send_xon;
7135 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7136 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7137 fc_conf.mac_ctrl_frame_fwd = 1;
7139 fc_conf.mac_ctrl_frame_fwd = 0;
7142 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7143 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7145 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7147 printf("bad flow contrl parameter, return code = %d \n", ret);
7150 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7151 struct cmd_priority_flow_ctrl_set_result {
7152 cmdline_fixed_string_t set;
7153 cmdline_fixed_string_t pfc_ctrl;
7154 cmdline_fixed_string_t rx;
7155 cmdline_fixed_string_t rx_pfc_mode;
7156 cmdline_fixed_string_t tx;
7157 cmdline_fixed_string_t tx_pfc_mode;
7158 uint32_t high_water;
7160 uint16_t pause_time;
7166 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7167 __rte_unused struct cmdline *cl,
7168 __rte_unused void *data)
7170 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7171 struct rte_eth_pfc_conf pfc_conf;
7172 int rx_fc_enable, tx_fc_enable;
7176 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7177 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7178 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7179 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7181 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7182 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7185 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7186 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7187 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7188 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7189 pfc_conf.fc.high_water = res->high_water;
7190 pfc_conf.fc.low_water = res->low_water;
7191 pfc_conf.fc.pause_time = res->pause_time;
7192 pfc_conf.priority = res->priority;
7194 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7196 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7199 cmdline_parse_token_string_t cmd_pfc_set_set =
7200 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7202 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7203 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7204 pfc_ctrl, "pfc_ctrl");
7205 cmdline_parse_token_string_t cmd_pfc_set_rx =
7206 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7208 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7209 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7210 rx_pfc_mode, "on#off");
7211 cmdline_parse_token_string_t cmd_pfc_set_tx =
7212 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7214 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7215 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7216 tx_pfc_mode, "on#off");
7217 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7218 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7219 high_water, RTE_UINT32);
7220 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7221 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7222 low_water, RTE_UINT32);
7223 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7224 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7225 pause_time, RTE_UINT16);
7226 cmdline_parse_token_num_t cmd_pfc_set_priority =
7227 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7228 priority, RTE_UINT8);
7229 cmdline_parse_token_num_t cmd_pfc_set_portid =
7230 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7231 port_id, RTE_UINT16);
7233 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7234 .f = cmd_priority_flow_ctrl_set_parsed,
7236 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7237 "<pause_time> <priority> <port_id>: "
7238 "Configure the Ethernet priority flow control",
7240 (void *)&cmd_pfc_set_set,
7241 (void *)&cmd_pfc_set_flow_ctrl,
7242 (void *)&cmd_pfc_set_rx,
7243 (void *)&cmd_pfc_set_rx_mode,
7244 (void *)&cmd_pfc_set_tx,
7245 (void *)&cmd_pfc_set_tx_mode,
7246 (void *)&cmd_pfc_set_high_water,
7247 (void *)&cmd_pfc_set_low_water,
7248 (void *)&cmd_pfc_set_pause_time,
7249 (void *)&cmd_pfc_set_priority,
7250 (void *)&cmd_pfc_set_portid,
7255 /* *** RESET CONFIGURATION *** */
7256 struct cmd_reset_result {
7257 cmdline_fixed_string_t reset;
7258 cmdline_fixed_string_t def;
7261 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7263 __rte_unused void *data)
7265 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7266 set_def_fwd_config();
7269 cmdline_parse_token_string_t cmd_reset_set =
7270 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7271 cmdline_parse_token_string_t cmd_reset_def =
7272 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7275 cmdline_parse_inst_t cmd_reset = {
7276 .f = cmd_reset_parsed,
7278 .help_str = "set default: Reset default forwarding configuration",
7280 (void *)&cmd_reset_set,
7281 (void *)&cmd_reset_def,
7286 /* *** START FORWARDING *** */
7287 struct cmd_start_result {
7288 cmdline_fixed_string_t start;
7291 cmdline_parse_token_string_t cmd_start_start =
7292 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7294 static void cmd_start_parsed(__rte_unused void *parsed_result,
7295 __rte_unused struct cmdline *cl,
7296 __rte_unused void *data)
7298 start_packet_forwarding(0);
7301 cmdline_parse_inst_t cmd_start = {
7302 .f = cmd_start_parsed,
7304 .help_str = "start: Start packet forwarding",
7306 (void *)&cmd_start_start,
7311 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7312 struct cmd_start_tx_first_result {
7313 cmdline_fixed_string_t start;
7314 cmdline_fixed_string_t tx_first;
7318 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7319 __rte_unused struct cmdline *cl,
7320 __rte_unused void *data)
7322 start_packet_forwarding(1);
7325 cmdline_parse_token_string_t cmd_start_tx_first_start =
7326 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7328 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7329 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7330 tx_first, "tx_first");
7332 cmdline_parse_inst_t cmd_start_tx_first = {
7333 .f = cmd_start_tx_first_parsed,
7335 .help_str = "start tx_first: Start packet forwarding, "
7336 "after sending 1 burst of packets",
7338 (void *)&cmd_start_tx_first_start,
7339 (void *)&cmd_start_tx_first_tx_first,
7344 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7345 struct cmd_start_tx_first_n_result {
7346 cmdline_fixed_string_t start;
7347 cmdline_fixed_string_t tx_first;
7352 cmd_start_tx_first_n_parsed(void *parsed_result,
7353 __rte_unused struct cmdline *cl,
7354 __rte_unused void *data)
7356 struct cmd_start_tx_first_n_result *res = parsed_result;
7358 start_packet_forwarding(res->tx_num);
7361 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7362 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7364 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7365 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7366 tx_first, "tx_first");
7367 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7368 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7369 tx_num, RTE_UINT32);
7371 cmdline_parse_inst_t cmd_start_tx_first_n = {
7372 .f = cmd_start_tx_first_n_parsed,
7374 .help_str = "start tx_first <num>: "
7375 "packet forwarding, after sending <num> bursts of packets",
7377 (void *)&cmd_start_tx_first_n_start,
7378 (void *)&cmd_start_tx_first_n_tx_first,
7379 (void *)&cmd_start_tx_first_n_tx_num,
7384 /* *** SET LINK UP *** */
7385 struct cmd_set_link_up_result {
7386 cmdline_fixed_string_t set;
7387 cmdline_fixed_string_t link_up;
7388 cmdline_fixed_string_t port;
7392 cmdline_parse_token_string_t cmd_set_link_up_set =
7393 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7394 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7395 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7397 cmdline_parse_token_string_t cmd_set_link_up_port =
7398 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7399 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7400 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7403 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7404 __rte_unused struct cmdline *cl,
7405 __rte_unused void *data)
7407 struct cmd_set_link_up_result *res = parsed_result;
7408 dev_set_link_up(res->port_id);
7411 cmdline_parse_inst_t cmd_set_link_up = {
7412 .f = cmd_set_link_up_parsed,
7414 .help_str = "set link-up port <port id>",
7416 (void *)&cmd_set_link_up_set,
7417 (void *)&cmd_set_link_up_link_up,
7418 (void *)&cmd_set_link_up_port,
7419 (void *)&cmd_set_link_up_port_id,
7424 /* *** SET LINK DOWN *** */
7425 struct cmd_set_link_down_result {
7426 cmdline_fixed_string_t set;
7427 cmdline_fixed_string_t link_down;
7428 cmdline_fixed_string_t port;
7432 cmdline_parse_token_string_t cmd_set_link_down_set =
7433 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7434 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7435 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7437 cmdline_parse_token_string_t cmd_set_link_down_port =
7438 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7439 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7440 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7443 static void cmd_set_link_down_parsed(
7444 __rte_unused void *parsed_result,
7445 __rte_unused struct cmdline *cl,
7446 __rte_unused void *data)
7448 struct cmd_set_link_down_result *res = parsed_result;
7449 dev_set_link_down(res->port_id);
7452 cmdline_parse_inst_t cmd_set_link_down = {
7453 .f = cmd_set_link_down_parsed,
7455 .help_str = "set link-down port <port id>",
7457 (void *)&cmd_set_link_down_set,
7458 (void *)&cmd_set_link_down_link_down,
7459 (void *)&cmd_set_link_down_port,
7460 (void *)&cmd_set_link_down_port_id,
7465 /* *** SHOW CFG *** */
7466 struct cmd_showcfg_result {
7467 cmdline_fixed_string_t show;
7468 cmdline_fixed_string_t cfg;
7469 cmdline_fixed_string_t what;
7472 static void cmd_showcfg_parsed(void *parsed_result,
7473 __rte_unused struct cmdline *cl,
7474 __rte_unused void *data)
7476 struct cmd_showcfg_result *res = parsed_result;
7477 if (!strcmp(res->what, "rxtx"))
7478 rxtx_config_display();
7479 else if (!strcmp(res->what, "cores"))
7480 fwd_lcores_config_display();
7481 else if (!strcmp(res->what, "fwd"))
7482 pkt_fwd_config_display(&cur_fwd_config);
7483 else if (!strcmp(res->what, "rxoffs"))
7484 show_rx_pkt_offsets();
7485 else if (!strcmp(res->what, "rxpkts"))
7486 show_rx_pkt_segments();
7487 else if (!strcmp(res->what, "txpkts"))
7488 show_tx_pkt_segments();
7489 else if (!strcmp(res->what, "txtimes"))
7490 show_tx_pkt_times();
7493 cmdline_parse_token_string_t cmd_showcfg_show =
7494 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7495 cmdline_parse_token_string_t cmd_showcfg_port =
7496 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7497 cmdline_parse_token_string_t cmd_showcfg_what =
7498 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7499 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7501 cmdline_parse_inst_t cmd_showcfg = {
7502 .f = cmd_showcfg_parsed,
7504 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7506 (void *)&cmd_showcfg_show,
7507 (void *)&cmd_showcfg_port,
7508 (void *)&cmd_showcfg_what,
7513 /* *** SHOW ALL PORT INFO *** */
7514 struct cmd_showportall_result {
7515 cmdline_fixed_string_t show;
7516 cmdline_fixed_string_t port;
7517 cmdline_fixed_string_t what;
7518 cmdline_fixed_string_t all;
7521 static void cmd_showportall_parsed(void *parsed_result,
7522 __rte_unused struct cmdline *cl,
7523 __rte_unused void *data)
7527 struct cmd_showportall_result *res = parsed_result;
7528 if (!strcmp(res->show, "clear")) {
7529 if (!strcmp(res->what, "stats"))
7530 RTE_ETH_FOREACH_DEV(i)
7532 else if (!strcmp(res->what, "xstats"))
7533 RTE_ETH_FOREACH_DEV(i)
7534 nic_xstats_clear(i);
7535 } else if (!strcmp(res->what, "info"))
7536 RTE_ETH_FOREACH_DEV(i)
7537 port_infos_display(i);
7538 else if (!strcmp(res->what, "summary")) {
7539 port_summary_header_display();
7540 RTE_ETH_FOREACH_DEV(i)
7541 port_summary_display(i);
7543 else if (!strcmp(res->what, "stats"))
7544 RTE_ETH_FOREACH_DEV(i)
7545 nic_stats_display(i);
7546 else if (!strcmp(res->what, "xstats"))
7547 RTE_ETH_FOREACH_DEV(i)
7548 nic_xstats_display(i);
7549 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7550 else if (!strcmp(res->what, "fdir"))
7551 RTE_ETH_FOREACH_DEV(i)
7554 else if (!strcmp(res->what, "dcb_tc"))
7555 RTE_ETH_FOREACH_DEV(i)
7556 port_dcb_info_display(i);
7557 else if (!strcmp(res->what, "cap"))
7558 RTE_ETH_FOREACH_DEV(i)
7559 port_offload_cap_display(i);
7562 cmdline_parse_token_string_t cmd_showportall_show =
7563 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7565 cmdline_parse_token_string_t cmd_showportall_port =
7566 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7567 cmdline_parse_token_string_t cmd_showportall_what =
7568 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7569 "info#summary#stats#xstats#fdir#dcb_tc#cap");
7570 cmdline_parse_token_string_t cmd_showportall_all =
7571 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7572 cmdline_parse_inst_t cmd_showportall = {
7573 .f = cmd_showportall_parsed,
7575 .help_str = "show|clear port "
7576 "info|summary|stats|xstats|fdir|dcb_tc|cap all",
7578 (void *)&cmd_showportall_show,
7579 (void *)&cmd_showportall_port,
7580 (void *)&cmd_showportall_what,
7581 (void *)&cmd_showportall_all,
7586 /* *** SHOW PORT INFO *** */
7587 struct cmd_showport_result {
7588 cmdline_fixed_string_t show;
7589 cmdline_fixed_string_t port;
7590 cmdline_fixed_string_t what;
7594 static void cmd_showport_parsed(void *parsed_result,
7595 __rte_unused struct cmdline *cl,
7596 __rte_unused void *data)
7598 struct cmd_showport_result *res = parsed_result;
7599 if (!strcmp(res->show, "clear")) {
7600 if (!strcmp(res->what, "stats"))
7601 nic_stats_clear(res->portnum);
7602 else if (!strcmp(res->what, "xstats"))
7603 nic_xstats_clear(res->portnum);
7604 } else if (!strcmp(res->what, "info"))
7605 port_infos_display(res->portnum);
7606 else if (!strcmp(res->what, "summary")) {
7607 port_summary_header_display();
7608 port_summary_display(res->portnum);
7610 else if (!strcmp(res->what, "stats"))
7611 nic_stats_display(res->portnum);
7612 else if (!strcmp(res->what, "xstats"))
7613 nic_xstats_display(res->portnum);
7614 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7615 else if (!strcmp(res->what, "fdir"))
7616 fdir_get_infos(res->portnum);
7618 else if (!strcmp(res->what, "dcb_tc"))
7619 port_dcb_info_display(res->portnum);
7620 else if (!strcmp(res->what, "cap"))
7621 port_offload_cap_display(res->portnum);
7624 cmdline_parse_token_string_t cmd_showport_show =
7625 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7627 cmdline_parse_token_string_t cmd_showport_port =
7628 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7629 cmdline_parse_token_string_t cmd_showport_what =
7630 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7631 "info#summary#stats#xstats#fdir#dcb_tc#cap");
7632 cmdline_parse_token_num_t cmd_showport_portnum =
7633 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
7635 cmdline_parse_inst_t cmd_showport = {
7636 .f = cmd_showport_parsed,
7638 .help_str = "show|clear port "
7639 "info|summary|stats|xstats|fdir|dcb_tc|cap "
7642 (void *)&cmd_showport_show,
7643 (void *)&cmd_showport_port,
7644 (void *)&cmd_showport_what,
7645 (void *)&cmd_showport_portnum,
7650 /* *** SHOW DEVICE INFO *** */
7651 struct cmd_showdevice_result {
7652 cmdline_fixed_string_t show;
7653 cmdline_fixed_string_t device;
7654 cmdline_fixed_string_t what;
7655 cmdline_fixed_string_t identifier;
7658 static void cmd_showdevice_parsed(void *parsed_result,
7659 __rte_unused struct cmdline *cl,
7660 __rte_unused void *data)
7662 struct cmd_showdevice_result *res = parsed_result;
7663 if (!strcmp(res->what, "info")) {
7664 if (!strcmp(res->identifier, "all"))
7665 device_infos_display(NULL);
7667 device_infos_display(res->identifier);
7671 cmdline_parse_token_string_t cmd_showdevice_show =
7672 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7674 cmdline_parse_token_string_t cmd_showdevice_device =
7675 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7676 cmdline_parse_token_string_t cmd_showdevice_what =
7677 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7679 cmdline_parse_token_string_t cmd_showdevice_identifier =
7680 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7683 cmdline_parse_inst_t cmd_showdevice = {
7684 .f = cmd_showdevice_parsed,
7686 .help_str = "show device info <identifier>|all",
7688 (void *)&cmd_showdevice_show,
7689 (void *)&cmd_showdevice_device,
7690 (void *)&cmd_showdevice_what,
7691 (void *)&cmd_showdevice_identifier,
7696 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7697 struct cmd_showeeprom_result {
7698 cmdline_fixed_string_t show;
7699 cmdline_fixed_string_t port;
7701 cmdline_fixed_string_t type;
7704 static void cmd_showeeprom_parsed(void *parsed_result,
7705 __rte_unused struct cmdline *cl,
7706 __rte_unused void *data)
7708 struct cmd_showeeprom_result *res = parsed_result;
7710 if (!strcmp(res->type, "eeprom"))
7711 port_eeprom_display(res->portnum);
7712 else if (!strcmp(res->type, "module_eeprom"))
7713 port_module_eeprom_display(res->portnum);
7715 printf("Unknown argument\n");
7718 cmdline_parse_token_string_t cmd_showeeprom_show =
7719 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7720 cmdline_parse_token_string_t cmd_showeeprom_port =
7721 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7722 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7723 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7725 cmdline_parse_token_string_t cmd_showeeprom_type =
7726 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7728 cmdline_parse_inst_t cmd_showeeprom = {
7729 .f = cmd_showeeprom_parsed,
7731 .help_str = "show port <port_id> module_eeprom|eeprom",
7733 (void *)&cmd_showeeprom_show,
7734 (void *)&cmd_showeeprom_port,
7735 (void *)&cmd_showeeprom_portnum,
7736 (void *)&cmd_showeeprom_type,
7741 /* *** SHOW QUEUE INFO *** */
7742 struct cmd_showqueue_result {
7743 cmdline_fixed_string_t show;
7744 cmdline_fixed_string_t type;
7745 cmdline_fixed_string_t what;
7751 cmd_showqueue_parsed(void *parsed_result,
7752 __rte_unused struct cmdline *cl,
7753 __rte_unused void *data)
7755 struct cmd_showqueue_result *res = parsed_result;
7757 if (!strcmp(res->type, "rxq"))
7758 rx_queue_infos_display(res->portnum, res->queuenum);
7759 else if (!strcmp(res->type, "txq"))
7760 tx_queue_infos_display(res->portnum, res->queuenum);
7763 cmdline_parse_token_string_t cmd_showqueue_show =
7764 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7765 cmdline_parse_token_string_t cmd_showqueue_type =
7766 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7767 cmdline_parse_token_string_t cmd_showqueue_what =
7768 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7769 cmdline_parse_token_num_t cmd_showqueue_portnum =
7770 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
7772 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7773 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
7776 cmdline_parse_inst_t cmd_showqueue = {
7777 .f = cmd_showqueue_parsed,
7779 .help_str = "show rxq|txq info <port_id> <queue_id>",
7781 (void *)&cmd_showqueue_show,
7782 (void *)&cmd_showqueue_type,
7783 (void *)&cmd_showqueue_what,
7784 (void *)&cmd_showqueue_portnum,
7785 (void *)&cmd_showqueue_queuenum,
7790 /* show/clear fwd engine statistics */
7792 cmdline_fixed_string_t action;
7793 cmdline_fixed_string_t fwd;
7794 cmdline_fixed_string_t stats;
7795 cmdline_fixed_string_t all;
7798 cmdline_parse_token_string_t cmd_fwd_action =
7799 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7800 cmdline_parse_token_string_t cmd_fwd_fwd =
7801 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7802 cmdline_parse_token_string_t cmd_fwd_stats =
7803 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7804 cmdline_parse_token_string_t cmd_fwd_all =
7805 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7808 cmd_showfwdall_parsed(void *parsed_result,
7809 __rte_unused struct cmdline *cl,
7810 __rte_unused void *data)
7812 struct fwd_result *res = parsed_result;
7814 if (!strcmp(res->action, "show"))
7815 fwd_stats_display();
7820 static cmdline_parse_inst_t cmd_showfwdall = {
7821 .f = cmd_showfwdall_parsed,
7823 .help_str = "show|clear fwd stats all",
7825 (void *)&cmd_fwd_action,
7826 (void *)&cmd_fwd_fwd,
7827 (void *)&cmd_fwd_stats,
7828 (void *)&cmd_fwd_all,
7833 /* *** READ PORT REGISTER *** */
7834 struct cmd_read_reg_result {
7835 cmdline_fixed_string_t read;
7836 cmdline_fixed_string_t reg;
7842 cmd_read_reg_parsed(void *parsed_result,
7843 __rte_unused struct cmdline *cl,
7844 __rte_unused void *data)
7846 struct cmd_read_reg_result *res = parsed_result;
7847 port_reg_display(res->port_id, res->reg_off);
7850 cmdline_parse_token_string_t cmd_read_reg_read =
7851 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7852 cmdline_parse_token_string_t cmd_read_reg_reg =
7853 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7854 cmdline_parse_token_num_t cmd_read_reg_port_id =
7855 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
7856 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7857 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
7859 cmdline_parse_inst_t cmd_read_reg = {
7860 .f = cmd_read_reg_parsed,
7862 .help_str = "read reg <port_id> <reg_off>",
7864 (void *)&cmd_read_reg_read,
7865 (void *)&cmd_read_reg_reg,
7866 (void *)&cmd_read_reg_port_id,
7867 (void *)&cmd_read_reg_reg_off,
7872 /* *** READ PORT REGISTER BIT FIELD *** */
7873 struct cmd_read_reg_bit_field_result {
7874 cmdline_fixed_string_t read;
7875 cmdline_fixed_string_t regfield;
7883 cmd_read_reg_bit_field_parsed(void *parsed_result,
7884 __rte_unused struct cmdline *cl,
7885 __rte_unused void *data)
7887 struct cmd_read_reg_bit_field_result *res = parsed_result;
7888 port_reg_bit_field_display(res->port_id, res->reg_off,
7889 res->bit1_pos, res->bit2_pos);
7892 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7893 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7895 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7896 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7897 regfield, "regfield");
7898 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7899 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7901 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7902 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7904 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7905 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7907 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7908 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7911 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7912 .f = cmd_read_reg_bit_field_parsed,
7914 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7915 "Read register bit field between bit_x and bit_y included",
7917 (void *)&cmd_read_reg_bit_field_read,
7918 (void *)&cmd_read_reg_bit_field_regfield,
7919 (void *)&cmd_read_reg_bit_field_port_id,
7920 (void *)&cmd_read_reg_bit_field_reg_off,
7921 (void *)&cmd_read_reg_bit_field_bit1_pos,
7922 (void *)&cmd_read_reg_bit_field_bit2_pos,
7927 /* *** READ PORT REGISTER BIT *** */
7928 struct cmd_read_reg_bit_result {
7929 cmdline_fixed_string_t read;
7930 cmdline_fixed_string_t regbit;
7937 cmd_read_reg_bit_parsed(void *parsed_result,
7938 __rte_unused struct cmdline *cl,
7939 __rte_unused void *data)
7941 struct cmd_read_reg_bit_result *res = parsed_result;
7942 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7945 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7946 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7947 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7948 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7950 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7951 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
7953 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7954 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
7956 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7957 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
7960 cmdline_parse_inst_t cmd_read_reg_bit = {
7961 .f = cmd_read_reg_bit_parsed,
7963 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7965 (void *)&cmd_read_reg_bit_read,
7966 (void *)&cmd_read_reg_bit_regbit,
7967 (void *)&cmd_read_reg_bit_port_id,
7968 (void *)&cmd_read_reg_bit_reg_off,
7969 (void *)&cmd_read_reg_bit_bit_pos,
7974 /* *** WRITE PORT REGISTER *** */
7975 struct cmd_write_reg_result {
7976 cmdline_fixed_string_t write;
7977 cmdline_fixed_string_t reg;
7984 cmd_write_reg_parsed(void *parsed_result,
7985 __rte_unused struct cmdline *cl,
7986 __rte_unused void *data)
7988 struct cmd_write_reg_result *res = parsed_result;
7989 port_reg_set(res->port_id, res->reg_off, res->value);
7992 cmdline_parse_token_string_t cmd_write_reg_write =
7993 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7994 cmdline_parse_token_string_t cmd_write_reg_reg =
7995 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7996 cmdline_parse_token_num_t cmd_write_reg_port_id =
7997 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
7998 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7999 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8000 cmdline_parse_token_num_t cmd_write_reg_value =
8001 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8003 cmdline_parse_inst_t cmd_write_reg = {
8004 .f = cmd_write_reg_parsed,
8006 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8008 (void *)&cmd_write_reg_write,
8009 (void *)&cmd_write_reg_reg,
8010 (void *)&cmd_write_reg_port_id,
8011 (void *)&cmd_write_reg_reg_off,
8012 (void *)&cmd_write_reg_value,
8017 /* *** WRITE PORT REGISTER BIT FIELD *** */
8018 struct cmd_write_reg_bit_field_result {
8019 cmdline_fixed_string_t write;
8020 cmdline_fixed_string_t regfield;
8029 cmd_write_reg_bit_field_parsed(void *parsed_result,
8030 __rte_unused struct cmdline *cl,
8031 __rte_unused void *data)
8033 struct cmd_write_reg_bit_field_result *res = parsed_result;
8034 port_reg_bit_field_set(res->port_id, res->reg_off,
8035 res->bit1_pos, res->bit2_pos, res->value);
8038 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8039 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8041 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8042 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8043 regfield, "regfield");
8044 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8045 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8047 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8048 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8050 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8051 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8053 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8054 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8056 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8057 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8060 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8061 .f = cmd_write_reg_bit_field_parsed,
8063 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8065 "Set register bit field between bit_x and bit_y included",
8067 (void *)&cmd_write_reg_bit_field_write,
8068 (void *)&cmd_write_reg_bit_field_regfield,
8069 (void *)&cmd_write_reg_bit_field_port_id,
8070 (void *)&cmd_write_reg_bit_field_reg_off,
8071 (void *)&cmd_write_reg_bit_field_bit1_pos,
8072 (void *)&cmd_write_reg_bit_field_bit2_pos,
8073 (void *)&cmd_write_reg_bit_field_value,
8078 /* *** WRITE PORT REGISTER BIT *** */
8079 struct cmd_write_reg_bit_result {
8080 cmdline_fixed_string_t write;
8081 cmdline_fixed_string_t regbit;
8089 cmd_write_reg_bit_parsed(void *parsed_result,
8090 __rte_unused struct cmdline *cl,
8091 __rte_unused void *data)
8093 struct cmd_write_reg_bit_result *res = parsed_result;
8094 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8097 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8098 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8100 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8101 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8103 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8104 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8106 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8107 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8109 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8110 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8112 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8113 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8116 cmdline_parse_inst_t cmd_write_reg_bit = {
8117 .f = cmd_write_reg_bit_parsed,
8119 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8122 (void *)&cmd_write_reg_bit_write,
8123 (void *)&cmd_write_reg_bit_regbit,
8124 (void *)&cmd_write_reg_bit_port_id,
8125 (void *)&cmd_write_reg_bit_reg_off,
8126 (void *)&cmd_write_reg_bit_bit_pos,
8127 (void *)&cmd_write_reg_bit_value,
8132 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8133 struct cmd_read_rxd_txd_result {
8134 cmdline_fixed_string_t read;
8135 cmdline_fixed_string_t rxd_txd;
8142 cmd_read_rxd_txd_parsed(void *parsed_result,
8143 __rte_unused struct cmdline *cl,
8144 __rte_unused void *data)
8146 struct cmd_read_rxd_txd_result *res = parsed_result;
8148 if (!strcmp(res->rxd_txd, "rxd"))
8149 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8150 else if (!strcmp(res->rxd_txd, "txd"))
8151 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8154 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8155 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8156 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8157 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8159 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8160 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8162 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8163 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8165 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8166 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8169 cmdline_parse_inst_t cmd_read_rxd_txd = {
8170 .f = cmd_read_rxd_txd_parsed,
8172 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8174 (void *)&cmd_read_rxd_txd_read,
8175 (void *)&cmd_read_rxd_txd_rxd_txd,
8176 (void *)&cmd_read_rxd_txd_port_id,
8177 (void *)&cmd_read_rxd_txd_queue_id,
8178 (void *)&cmd_read_rxd_txd_desc_id,
8184 struct cmd_quit_result {
8185 cmdline_fixed_string_t quit;
8188 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8190 __rte_unused void *data)
8195 cmdline_parse_token_string_t cmd_quit_quit =
8196 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8198 cmdline_parse_inst_t cmd_quit = {
8199 .f = cmd_quit_parsed,
8201 .help_str = "quit: Exit application",
8203 (void *)&cmd_quit_quit,
8208 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8209 struct cmd_mac_addr_result {
8210 cmdline_fixed_string_t mac_addr_cmd;
8211 cmdline_fixed_string_t what;
8213 struct rte_ether_addr address;
8216 static void cmd_mac_addr_parsed(void *parsed_result,
8217 __rte_unused struct cmdline *cl,
8218 __rte_unused void *data)
8220 struct cmd_mac_addr_result *res = parsed_result;
8223 if (strcmp(res->what, "add") == 0)
8224 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8225 else if (strcmp(res->what, "set") == 0)
8226 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8229 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8231 /* check the return value and print it if is < 0 */
8233 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8237 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8238 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8240 cmdline_parse_token_string_t cmd_mac_addr_what =
8241 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8243 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8244 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8246 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8247 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8249 cmdline_parse_inst_t cmd_mac_addr = {
8250 .f = cmd_mac_addr_parsed,
8252 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8253 "Add/Remove/Set MAC address on port_id",
8255 (void *)&cmd_mac_addr_cmd,
8256 (void *)&cmd_mac_addr_what,
8257 (void *)&cmd_mac_addr_portnum,
8258 (void *)&cmd_mac_addr_addr,
8263 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8264 struct cmd_eth_peer_result {
8265 cmdline_fixed_string_t set;
8266 cmdline_fixed_string_t eth_peer;
8268 cmdline_fixed_string_t peer_addr;
8271 static void cmd_set_eth_peer_parsed(void *parsed_result,
8272 __rte_unused struct cmdline *cl,
8273 __rte_unused void *data)
8275 struct cmd_eth_peer_result *res = parsed_result;
8277 if (test_done == 0) {
8278 printf("Please stop forwarding first\n");
8281 if (!strcmp(res->eth_peer, "eth-peer")) {
8282 set_fwd_eth_peer(res->port_id, res->peer_addr);
8286 cmdline_parse_token_string_t cmd_eth_peer_set =
8287 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8288 cmdline_parse_token_string_t cmd_eth_peer =
8289 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8290 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8291 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8293 cmdline_parse_token_string_t cmd_eth_peer_addr =
8294 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8296 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8297 .f = cmd_set_eth_peer_parsed,
8299 .help_str = "set eth-peer <port_id> <peer_mac>",
8301 (void *)&cmd_eth_peer_set,
8302 (void *)&cmd_eth_peer,
8303 (void *)&cmd_eth_peer_port_id,
8304 (void *)&cmd_eth_peer_addr,
8309 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8310 struct cmd_set_qmap_result {
8311 cmdline_fixed_string_t set;
8312 cmdline_fixed_string_t qmap;
8313 cmdline_fixed_string_t what;
8320 cmd_set_qmap_parsed(void *parsed_result,
8321 __rte_unused struct cmdline *cl,
8322 __rte_unused void *data)
8324 struct cmd_set_qmap_result *res = parsed_result;
8325 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8327 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8330 cmdline_parse_token_string_t cmd_setqmap_set =
8331 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8333 cmdline_parse_token_string_t cmd_setqmap_qmap =
8334 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8336 cmdline_parse_token_string_t cmd_setqmap_what =
8337 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8339 cmdline_parse_token_num_t cmd_setqmap_portid =
8340 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8341 port_id, RTE_UINT16);
8342 cmdline_parse_token_num_t cmd_setqmap_queueid =
8343 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8344 queue_id, RTE_UINT16);
8345 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8346 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8347 map_value, RTE_UINT8);
8349 cmdline_parse_inst_t cmd_set_qmap = {
8350 .f = cmd_set_qmap_parsed,
8352 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8353 "Set statistics mapping value on tx|rx queue_id of port_id",
8355 (void *)&cmd_setqmap_set,
8356 (void *)&cmd_setqmap_qmap,
8357 (void *)&cmd_setqmap_what,
8358 (void *)&cmd_setqmap_portid,
8359 (void *)&cmd_setqmap_queueid,
8360 (void *)&cmd_setqmap_mapvalue,
8365 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8366 struct cmd_set_xstats_hide_zero_result {
8367 cmdline_fixed_string_t keyword;
8368 cmdline_fixed_string_t name;
8369 cmdline_fixed_string_t on_off;
8373 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8374 __rte_unused struct cmdline *cl,
8375 __rte_unused void *data)
8377 struct cmd_set_xstats_hide_zero_result *res;
8378 uint16_t on_off = 0;
8380 res = parsed_result;
8381 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8382 set_xstats_hide_zero(on_off);
8385 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8386 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8388 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8389 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8390 name, "xstats-hide-zero");
8391 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8392 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8395 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8396 .f = cmd_set_xstats_hide_zero_parsed,
8398 .help_str = "set xstats-hide-zero on|off",
8400 (void *)&cmd_set_xstats_hide_zero_keyword,
8401 (void *)&cmd_set_xstats_hide_zero_name,
8402 (void *)&cmd_set_xstats_hide_zero_on_off,
8407 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8408 struct cmd_set_record_core_cycles_result {
8409 cmdline_fixed_string_t keyword;
8410 cmdline_fixed_string_t name;
8411 cmdline_fixed_string_t on_off;
8415 cmd_set_record_core_cycles_parsed(void *parsed_result,
8416 __rte_unused struct cmdline *cl,
8417 __rte_unused void *data)
8419 struct cmd_set_record_core_cycles_result *res;
8420 uint16_t on_off = 0;
8422 res = parsed_result;
8423 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8424 set_record_core_cycles(on_off);
8427 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8428 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8430 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8431 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8432 name, "record-core-cycles");
8433 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8434 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8437 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8438 .f = cmd_set_record_core_cycles_parsed,
8440 .help_str = "set record-core-cycles on|off",
8442 (void *)&cmd_set_record_core_cycles_keyword,
8443 (void *)&cmd_set_record_core_cycles_name,
8444 (void *)&cmd_set_record_core_cycles_on_off,
8449 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8450 struct cmd_set_record_burst_stats_result {
8451 cmdline_fixed_string_t keyword;
8452 cmdline_fixed_string_t name;
8453 cmdline_fixed_string_t on_off;
8457 cmd_set_record_burst_stats_parsed(void *parsed_result,
8458 __rte_unused struct cmdline *cl,
8459 __rte_unused void *data)
8461 struct cmd_set_record_burst_stats_result *res;
8462 uint16_t on_off = 0;
8464 res = parsed_result;
8465 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8466 set_record_burst_stats(on_off);
8469 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8470 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8472 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8473 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8474 name, "record-burst-stats");
8475 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8476 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8479 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8480 .f = cmd_set_record_burst_stats_parsed,
8482 .help_str = "set record-burst-stats on|off",
8484 (void *)&cmd_set_record_burst_stats_keyword,
8485 (void *)&cmd_set_record_burst_stats_name,
8486 (void *)&cmd_set_record_burst_stats_on_off,
8491 /* *** CONFIGURE UNICAST HASH TABLE *** */
8492 struct cmd_set_uc_hash_table {
8493 cmdline_fixed_string_t set;
8494 cmdline_fixed_string_t port;
8496 cmdline_fixed_string_t what;
8497 struct rte_ether_addr address;
8498 cmdline_fixed_string_t mode;
8502 cmd_set_uc_hash_parsed(void *parsed_result,
8503 __rte_unused struct cmdline *cl,
8504 __rte_unused void *data)
8507 struct cmd_set_uc_hash_table *res = parsed_result;
8509 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8511 if (strcmp(res->what, "uta") == 0)
8512 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8513 &res->address,(uint8_t)is_on);
8515 printf("bad unicast hash table parameter, return code = %d \n", ret);
8519 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8520 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8522 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8523 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8525 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8526 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8527 port_id, RTE_UINT16);
8528 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8529 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8531 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8532 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8534 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8535 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8538 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8539 .f = cmd_set_uc_hash_parsed,
8541 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8543 (void *)&cmd_set_uc_hash_set,
8544 (void *)&cmd_set_uc_hash_port,
8545 (void *)&cmd_set_uc_hash_portid,
8546 (void *)&cmd_set_uc_hash_what,
8547 (void *)&cmd_set_uc_hash_mac,
8548 (void *)&cmd_set_uc_hash_mode,
8553 struct cmd_set_uc_all_hash_table {
8554 cmdline_fixed_string_t set;
8555 cmdline_fixed_string_t port;
8557 cmdline_fixed_string_t what;
8558 cmdline_fixed_string_t value;
8559 cmdline_fixed_string_t mode;
8563 cmd_set_uc_all_hash_parsed(void *parsed_result,
8564 __rte_unused struct cmdline *cl,
8565 __rte_unused void *data)
8568 struct cmd_set_uc_all_hash_table *res = parsed_result;
8570 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8572 if ((strcmp(res->what, "uta") == 0) &&
8573 (strcmp(res->value, "all") == 0))
8574 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8576 printf("bad unicast hash table parameter,"
8577 "return code = %d \n", ret);
8580 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8581 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8583 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8584 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8586 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8587 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8588 port_id, RTE_UINT16);
8589 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8590 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8592 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8593 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8595 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8596 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8599 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8600 .f = cmd_set_uc_all_hash_parsed,
8602 .help_str = "set port <port_id> uta all on|off",
8604 (void *)&cmd_set_uc_all_hash_set,
8605 (void *)&cmd_set_uc_all_hash_port,
8606 (void *)&cmd_set_uc_all_hash_portid,
8607 (void *)&cmd_set_uc_all_hash_what,
8608 (void *)&cmd_set_uc_all_hash_value,
8609 (void *)&cmd_set_uc_all_hash_mode,
8614 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8615 struct cmd_set_vf_traffic {
8616 cmdline_fixed_string_t set;
8617 cmdline_fixed_string_t port;
8619 cmdline_fixed_string_t vf;
8621 cmdline_fixed_string_t what;
8622 cmdline_fixed_string_t mode;
8626 cmd_set_vf_traffic_parsed(void *parsed_result,
8627 __rte_unused struct cmdline *cl,
8628 __rte_unused void *data)
8630 struct cmd_set_vf_traffic *res = parsed_result;
8631 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8632 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8634 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8637 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8638 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8640 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8641 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8643 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8644 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8645 port_id, RTE_UINT16);
8646 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8647 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8649 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8650 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8652 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8653 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8655 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8656 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8659 cmdline_parse_inst_t cmd_set_vf_traffic = {
8660 .f = cmd_set_vf_traffic_parsed,
8662 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8664 (void *)&cmd_setvf_traffic_set,
8665 (void *)&cmd_setvf_traffic_port,
8666 (void *)&cmd_setvf_traffic_portid,
8667 (void *)&cmd_setvf_traffic_vf,
8668 (void *)&cmd_setvf_traffic_vfid,
8669 (void *)&cmd_setvf_traffic_what,
8670 (void *)&cmd_setvf_traffic_mode,
8675 /* *** CONFIGURE VF RECEIVE MODE *** */
8676 struct cmd_set_vf_rxmode {
8677 cmdline_fixed_string_t set;
8678 cmdline_fixed_string_t port;
8680 cmdline_fixed_string_t vf;
8682 cmdline_fixed_string_t what;
8683 cmdline_fixed_string_t mode;
8684 cmdline_fixed_string_t on;
8688 cmd_set_vf_rxmode_parsed(void *parsed_result,
8689 __rte_unused struct cmdline *cl,
8690 __rte_unused void *data)
8693 uint16_t vf_rxmode = 0;
8694 struct cmd_set_vf_rxmode *res = parsed_result;
8696 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8697 if (!strcmp(res->what,"rxmode")) {
8698 if (!strcmp(res->mode, "AUPE"))
8699 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8700 else if (!strcmp(res->mode, "ROPE"))
8701 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8702 else if (!strcmp(res->mode, "BAM"))
8703 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8704 else if (!strncmp(res->mode, "MPE",3))
8705 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8708 RTE_SET_USED(is_on);
8710 #ifdef RTE_NET_IXGBE
8711 if (ret == -ENOTSUP)
8712 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8713 vf_rxmode, (uint8_t)is_on);
8716 if (ret == -ENOTSUP)
8717 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8718 vf_rxmode, (uint8_t)is_on);
8721 printf("bad VF receive mode parameter, return code = %d \n",
8725 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8726 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8728 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8729 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8731 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8732 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8733 port_id, RTE_UINT16);
8734 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8735 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8737 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8738 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8740 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8741 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8743 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8744 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8745 mode, "AUPE#ROPE#BAM#MPE");
8746 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8747 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8750 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8751 .f = cmd_set_vf_rxmode_parsed,
8753 .help_str = "set port <port_id> vf <vf_id> rxmode "
8754 "AUPE|ROPE|BAM|MPE on|off",
8756 (void *)&cmd_set_vf_rxmode_set,
8757 (void *)&cmd_set_vf_rxmode_port,
8758 (void *)&cmd_set_vf_rxmode_portid,
8759 (void *)&cmd_set_vf_rxmode_vf,
8760 (void *)&cmd_set_vf_rxmode_vfid,
8761 (void *)&cmd_set_vf_rxmode_what,
8762 (void *)&cmd_set_vf_rxmode_mode,
8763 (void *)&cmd_set_vf_rxmode_on,
8768 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8769 struct cmd_vf_mac_addr_result {
8770 cmdline_fixed_string_t mac_addr_cmd;
8771 cmdline_fixed_string_t what;
8772 cmdline_fixed_string_t port;
8774 cmdline_fixed_string_t vf;
8776 struct rte_ether_addr address;
8779 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8780 __rte_unused struct cmdline *cl,
8781 __rte_unused void *data)
8783 struct cmd_vf_mac_addr_result *res = parsed_result;
8786 if (strcmp(res->what, "add") != 0)
8790 if (ret == -ENOTSUP)
8791 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8795 if (ret == -ENOTSUP)
8796 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8801 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8805 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8806 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8807 mac_addr_cmd,"mac_addr");
8808 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8809 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8811 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8812 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8814 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8815 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8816 port_num, RTE_UINT16);
8817 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8818 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8820 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8821 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8823 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8824 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8827 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8828 .f = cmd_vf_mac_addr_parsed,
8830 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8831 "Add MAC address filtering for a VF on port_id",
8833 (void *)&cmd_vf_mac_addr_cmd,
8834 (void *)&cmd_vf_mac_addr_what,
8835 (void *)&cmd_vf_mac_addr_port,
8836 (void *)&cmd_vf_mac_addr_portnum,
8837 (void *)&cmd_vf_mac_addr_vf,
8838 (void *)&cmd_vf_mac_addr_vfnum,
8839 (void *)&cmd_vf_mac_addr_addr,
8844 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8845 struct cmd_vf_rx_vlan_filter {
8846 cmdline_fixed_string_t rx_vlan;
8847 cmdline_fixed_string_t what;
8849 cmdline_fixed_string_t port;
8851 cmdline_fixed_string_t vf;
8856 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8857 __rte_unused struct cmdline *cl,
8858 __rte_unused void *data)
8860 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8863 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8865 #ifdef RTE_NET_IXGBE
8866 if (ret == -ENOTSUP)
8867 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8868 res->vlan_id, res->vf_mask, is_add);
8871 if (ret == -ENOTSUP)
8872 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8873 res->vlan_id, res->vf_mask, is_add);
8876 if (ret == -ENOTSUP)
8877 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8878 res->vlan_id, res->vf_mask, is_add);
8885 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8886 res->vlan_id, res->vf_mask);
8889 printf("invalid port_id %d\n", res->port_id);
8892 printf("function not implemented or supported\n");
8895 printf("programming error: (%s)\n", strerror(-ret));
8899 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8900 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8901 rx_vlan, "rx_vlan");
8902 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8903 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8905 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8906 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8907 vlan_id, RTE_UINT16);
8908 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8909 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8911 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8912 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8913 port_id, RTE_UINT16);
8914 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8915 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8917 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8918 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8919 vf_mask, RTE_UINT64);
8921 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8922 .f = cmd_vf_rx_vlan_filter_parsed,
8924 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8925 "(vf_mask = hexadecimal VF mask)",
8927 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8928 (void *)&cmd_vf_rx_vlan_filter_what,
8929 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8930 (void *)&cmd_vf_rx_vlan_filter_port,
8931 (void *)&cmd_vf_rx_vlan_filter_portid,
8932 (void *)&cmd_vf_rx_vlan_filter_vf,
8933 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8938 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8939 struct cmd_queue_rate_limit_result {
8940 cmdline_fixed_string_t set;
8941 cmdline_fixed_string_t port;
8943 cmdline_fixed_string_t queue;
8945 cmdline_fixed_string_t rate;
8949 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8950 __rte_unused struct cmdline *cl,
8951 __rte_unused void *data)
8953 struct cmd_queue_rate_limit_result *res = parsed_result;
8956 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8957 && (strcmp(res->queue, "queue") == 0)
8958 && (strcmp(res->rate, "rate") == 0))
8959 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8962 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8966 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8967 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8969 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8970 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8972 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8973 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8974 port_num, RTE_UINT16);
8975 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8976 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8978 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8979 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8980 queue_num, RTE_UINT8);
8981 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8982 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8984 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8985 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8986 rate_num, RTE_UINT16);
8988 cmdline_parse_inst_t cmd_queue_rate_limit = {
8989 .f = cmd_queue_rate_limit_parsed,
8991 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8992 "Set rate limit for a queue on port_id",
8994 (void *)&cmd_queue_rate_limit_set,
8995 (void *)&cmd_queue_rate_limit_port,
8996 (void *)&cmd_queue_rate_limit_portnum,
8997 (void *)&cmd_queue_rate_limit_queue,
8998 (void *)&cmd_queue_rate_limit_queuenum,
8999 (void *)&cmd_queue_rate_limit_rate,
9000 (void *)&cmd_queue_rate_limit_ratenum,
9005 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9006 struct cmd_vf_rate_limit_result {
9007 cmdline_fixed_string_t set;
9008 cmdline_fixed_string_t port;
9010 cmdline_fixed_string_t vf;
9012 cmdline_fixed_string_t rate;
9014 cmdline_fixed_string_t q_msk;
9018 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9019 __rte_unused struct cmdline *cl,
9020 __rte_unused void *data)
9022 struct cmd_vf_rate_limit_result *res = parsed_result;
9025 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9026 && (strcmp(res->vf, "vf") == 0)
9027 && (strcmp(res->rate, "rate") == 0)
9028 && (strcmp(res->q_msk, "queue_mask") == 0))
9029 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9030 res->rate_num, res->q_msk_val);
9032 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9036 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9037 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9039 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9040 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9042 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9043 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9044 port_num, RTE_UINT16);
9045 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9046 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9048 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9049 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9051 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9052 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9054 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9055 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9056 rate_num, RTE_UINT16);
9057 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9058 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9059 q_msk, "queue_mask");
9060 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9061 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9062 q_msk_val, RTE_UINT64);
9064 cmdline_parse_inst_t cmd_vf_rate_limit = {
9065 .f = cmd_vf_rate_limit_parsed,
9067 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9068 "queue_mask <queue_mask_value>: "
9069 "Set rate limit for queues of VF on port_id",
9071 (void *)&cmd_vf_rate_limit_set,
9072 (void *)&cmd_vf_rate_limit_port,
9073 (void *)&cmd_vf_rate_limit_portnum,
9074 (void *)&cmd_vf_rate_limit_vf,
9075 (void *)&cmd_vf_rate_limit_vfnum,
9076 (void *)&cmd_vf_rate_limit_rate,
9077 (void *)&cmd_vf_rate_limit_ratenum,
9078 (void *)&cmd_vf_rate_limit_q_msk,
9079 (void *)&cmd_vf_rate_limit_q_msk_val,
9084 /* *** CONFIGURE TUNNEL UDP PORT *** */
9085 struct cmd_tunnel_udp_config {
9086 cmdline_fixed_string_t cmd;
9087 cmdline_fixed_string_t what;
9093 cmd_tunnel_udp_config_parsed(void *parsed_result,
9094 __rte_unused struct cmdline *cl,
9095 __rte_unused void *data)
9097 struct cmd_tunnel_udp_config *res = parsed_result;
9098 struct rte_eth_udp_tunnel tunnel_udp;
9101 tunnel_udp.udp_port = res->udp_port;
9103 if (!strcmp(res->cmd, "rx_vxlan_port"))
9104 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9106 if (!strcmp(res->what, "add"))
9107 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9110 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9114 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9117 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9118 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9119 cmd, "rx_vxlan_port");
9120 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9121 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9123 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9124 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9125 udp_port, RTE_UINT16);
9126 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9127 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9128 port_id, RTE_UINT16);
9130 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9131 .f = cmd_tunnel_udp_config_parsed,
9133 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9134 "Add/Remove a tunneling UDP port filter",
9136 (void *)&cmd_tunnel_udp_config_cmd,
9137 (void *)&cmd_tunnel_udp_config_what,
9138 (void *)&cmd_tunnel_udp_config_udp_port,
9139 (void *)&cmd_tunnel_udp_config_port_id,
9144 struct cmd_config_tunnel_udp_port {
9145 cmdline_fixed_string_t port;
9146 cmdline_fixed_string_t config;
9148 cmdline_fixed_string_t udp_tunnel_port;
9149 cmdline_fixed_string_t action;
9150 cmdline_fixed_string_t tunnel_type;
9155 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9156 __rte_unused struct cmdline *cl,
9157 __rte_unused void *data)
9159 struct cmd_config_tunnel_udp_port *res = parsed_result;
9160 struct rte_eth_udp_tunnel tunnel_udp;
9163 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9166 tunnel_udp.udp_port = res->udp_port;
9168 if (!strcmp(res->tunnel_type, "vxlan")) {
9169 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9170 } else if (!strcmp(res->tunnel_type, "geneve")) {
9171 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9172 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9173 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9174 } else if (!strcmp(res->tunnel_type, "ecpri")) {
9175 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_ECPRI;
9177 printf("Invalid tunnel type\n");
9181 if (!strcmp(res->action, "add"))
9182 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9185 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9189 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9192 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9193 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9195 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9196 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9198 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9199 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9201 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9202 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9205 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9206 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9208 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9209 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9210 "vxlan#geneve#vxlan-gpe#ecpri");
9211 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9212 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9215 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9216 .f = cmd_cfg_tunnel_udp_port_parsed,
9218 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9219 "geneve|vxlan-gpe|ecpri <udp_port>",
9221 (void *)&cmd_config_tunnel_udp_port_port,
9222 (void *)&cmd_config_tunnel_udp_port_config,
9223 (void *)&cmd_config_tunnel_udp_port_port_id,
9224 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9225 (void *)&cmd_config_tunnel_udp_port_action,
9226 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9227 (void *)&cmd_config_tunnel_udp_port_value,
9232 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9233 struct cmd_set_mirror_mask_result {
9234 cmdline_fixed_string_t set;
9235 cmdline_fixed_string_t port;
9237 cmdline_fixed_string_t mirror;
9239 cmdline_fixed_string_t what;
9240 cmdline_fixed_string_t value;
9241 cmdline_fixed_string_t dstpool;
9243 cmdline_fixed_string_t on;
9246 cmdline_parse_token_string_t cmd_mirror_mask_set =
9247 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9249 cmdline_parse_token_string_t cmd_mirror_mask_port =
9250 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9252 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9253 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9254 port_id, RTE_UINT16);
9255 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9256 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9257 mirror, "mirror-rule");
9258 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9259 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9260 rule_id, RTE_UINT8);
9261 cmdline_parse_token_string_t cmd_mirror_mask_what =
9262 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9263 what, "pool-mirror-up#pool-mirror-down"
9265 cmdline_parse_token_string_t cmd_mirror_mask_value =
9266 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9268 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9269 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9270 dstpool, "dst-pool");
9271 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9272 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9273 dstpool_id, RTE_UINT8);
9274 cmdline_parse_token_string_t cmd_mirror_mask_on =
9275 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9279 cmd_set_mirror_mask_parsed(void *parsed_result,
9280 __rte_unused struct cmdline *cl,
9281 __rte_unused void *data)
9284 struct cmd_set_mirror_mask_result *res = parsed_result;
9285 struct rte_eth_mirror_conf mr_conf;
9287 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9289 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9291 mr_conf.dst_pool = res->dstpool_id;
9293 if (!strcmp(res->what, "pool-mirror-up")) {
9294 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9295 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9296 } else if (!strcmp(res->what, "pool-mirror-down")) {
9297 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9298 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9299 } else if (!strcmp(res->what, "vlan-mirror")) {
9300 mr_conf.rule_type = ETH_MIRROR_VLAN;
9301 nb_item = parse_item_list(res->value, "vlan",
9302 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9306 for (i = 0; i < nb_item; i++) {
9307 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9308 printf("Invalid vlan_id: must be < 4096\n");
9312 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9313 mr_conf.vlan.vlan_mask |= 1ULL << i;
9317 if (!strcmp(res->on, "on"))
9318 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9321 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9324 printf("mirror rule add error: (%s)\n", strerror(-ret));
9327 cmdline_parse_inst_t cmd_set_mirror_mask = {
9328 .f = cmd_set_mirror_mask_parsed,
9330 .help_str = "set port <port_id> mirror-rule <rule_id> "
9331 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9332 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9334 (void *)&cmd_mirror_mask_set,
9335 (void *)&cmd_mirror_mask_port,
9336 (void *)&cmd_mirror_mask_portid,
9337 (void *)&cmd_mirror_mask_mirror,
9338 (void *)&cmd_mirror_mask_ruleid,
9339 (void *)&cmd_mirror_mask_what,
9340 (void *)&cmd_mirror_mask_value,
9341 (void *)&cmd_mirror_mask_dstpool,
9342 (void *)&cmd_mirror_mask_poolid,
9343 (void *)&cmd_mirror_mask_on,
9348 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9349 struct cmd_set_mirror_link_result {
9350 cmdline_fixed_string_t set;
9351 cmdline_fixed_string_t port;
9353 cmdline_fixed_string_t mirror;
9355 cmdline_fixed_string_t what;
9356 cmdline_fixed_string_t dstpool;
9358 cmdline_fixed_string_t on;
9361 cmdline_parse_token_string_t cmd_mirror_link_set =
9362 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9364 cmdline_parse_token_string_t cmd_mirror_link_port =
9365 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9367 cmdline_parse_token_num_t cmd_mirror_link_portid =
9368 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9369 port_id, RTE_UINT16);
9370 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9371 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9372 mirror, "mirror-rule");
9373 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9374 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9375 rule_id, RTE_UINT8);
9376 cmdline_parse_token_string_t cmd_mirror_link_what =
9377 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9378 what, "uplink-mirror#downlink-mirror");
9379 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9380 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9381 dstpool, "dst-pool");
9382 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9383 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9384 dstpool_id, RTE_UINT8);
9385 cmdline_parse_token_string_t cmd_mirror_link_on =
9386 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9390 cmd_set_mirror_link_parsed(void *parsed_result,
9391 __rte_unused struct cmdline *cl,
9392 __rte_unused void *data)
9395 struct cmd_set_mirror_link_result *res = parsed_result;
9396 struct rte_eth_mirror_conf mr_conf;
9398 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9399 if (!strcmp(res->what, "uplink-mirror"))
9400 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9402 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9404 mr_conf.dst_pool = res->dstpool_id;
9406 if (!strcmp(res->on, "on"))
9407 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9410 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9413 /* check the return value and print it if is < 0 */
9415 printf("mirror rule add error: (%s)\n", strerror(-ret));
9419 cmdline_parse_inst_t cmd_set_mirror_link = {
9420 .f = cmd_set_mirror_link_parsed,
9422 .help_str = "set port <port_id> mirror-rule <rule_id> "
9423 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9425 (void *)&cmd_mirror_link_set,
9426 (void *)&cmd_mirror_link_port,
9427 (void *)&cmd_mirror_link_portid,
9428 (void *)&cmd_mirror_link_mirror,
9429 (void *)&cmd_mirror_link_ruleid,
9430 (void *)&cmd_mirror_link_what,
9431 (void *)&cmd_mirror_link_dstpool,
9432 (void *)&cmd_mirror_link_poolid,
9433 (void *)&cmd_mirror_link_on,
9438 /* *** RESET VM MIRROR RULE *** */
9439 struct cmd_rm_mirror_rule_result {
9440 cmdline_fixed_string_t reset;
9441 cmdline_fixed_string_t port;
9443 cmdline_fixed_string_t mirror;
9447 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9448 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9450 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9451 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9453 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9454 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9455 port_id, RTE_UINT16);
9456 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9457 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9458 mirror, "mirror-rule");
9459 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9460 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9461 rule_id, RTE_UINT8);
9464 cmd_reset_mirror_rule_parsed(void *parsed_result,
9465 __rte_unused struct cmdline *cl,
9466 __rte_unused void *data)
9469 struct cmd_set_mirror_link_result *res = parsed_result;
9471 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9473 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9476 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9477 .f = cmd_reset_mirror_rule_parsed,
9479 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9481 (void *)&cmd_rm_mirror_rule_reset,
9482 (void *)&cmd_rm_mirror_rule_port,
9483 (void *)&cmd_rm_mirror_rule_portid,
9484 (void *)&cmd_rm_mirror_rule_mirror,
9485 (void *)&cmd_rm_mirror_rule_ruleid,
9490 /* ******************************************************************************** */
9492 struct cmd_dump_result {
9493 cmdline_fixed_string_t dump;
9497 dump_struct_sizes(void)
9499 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9500 DUMP_SIZE(struct rte_mbuf);
9501 DUMP_SIZE(struct rte_mempool);
9502 DUMP_SIZE(struct rte_ring);
9507 /* Dump the socket memory statistics on console */
9509 dump_socket_mem(FILE *f)
9511 struct rte_malloc_socket_stats socket_stats;
9516 unsigned int n_alloc = 0;
9517 unsigned int n_free = 0;
9518 static size_t last_allocs;
9519 static size_t last_total;
9522 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9523 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9524 !socket_stats.heap_totalsz_bytes)
9526 total += socket_stats.heap_totalsz_bytes;
9527 alloc += socket_stats.heap_allocsz_bytes;
9528 free += socket_stats.heap_freesz_bytes;
9529 n_alloc += socket_stats.alloc_count;
9530 n_free += socket_stats.free_count;
9532 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9534 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9535 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9536 (double)socket_stats.heap_allocsz_bytes * 100 /
9537 (double)socket_stats.heap_totalsz_bytes,
9538 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9539 socket_stats.alloc_count,
9540 socket_stats.free_count);
9543 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9544 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9545 (double)alloc * 100 / (double)total,
9546 (double)free / (1024 * 1024),
9549 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9550 ((double)total - (double)last_total) / (1024 * 1024),
9551 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9552 last_allocs = alloc;
9556 static void cmd_dump_parsed(void *parsed_result,
9557 __rte_unused struct cmdline *cl,
9558 __rte_unused void *data)
9560 struct cmd_dump_result *res = parsed_result;
9562 if (!strcmp(res->dump, "dump_physmem"))
9563 rte_dump_physmem_layout(stdout);
9564 else if (!strcmp(res->dump, "dump_socket_mem"))
9565 dump_socket_mem(stdout);
9566 else if (!strcmp(res->dump, "dump_memzone"))
9567 rte_memzone_dump(stdout);
9568 else if (!strcmp(res->dump, "dump_struct_sizes"))
9569 dump_struct_sizes();
9570 else if (!strcmp(res->dump, "dump_ring"))
9571 rte_ring_list_dump(stdout);
9572 else if (!strcmp(res->dump, "dump_mempool"))
9573 rte_mempool_list_dump(stdout);
9574 else if (!strcmp(res->dump, "dump_devargs"))
9575 rte_devargs_dump(stdout);
9576 else if (!strcmp(res->dump, "dump_log_types"))
9577 rte_log_dump(stdout);
9580 cmdline_parse_token_string_t cmd_dump_dump =
9581 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9585 "dump_struct_sizes#"
9591 cmdline_parse_inst_t cmd_dump = {
9592 .f = cmd_dump_parsed, /* function to call */
9593 .data = NULL, /* 2nd arg of func */
9594 .help_str = "Dump status",
9595 .tokens = { /* token list, NULL terminated */
9596 (void *)&cmd_dump_dump,
9601 /* ******************************************************************************** */
9603 struct cmd_dump_one_result {
9604 cmdline_fixed_string_t dump;
9605 cmdline_fixed_string_t name;
9608 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9609 __rte_unused void *data)
9611 struct cmd_dump_one_result *res = parsed_result;
9613 if (!strcmp(res->dump, "dump_ring")) {
9615 r = rte_ring_lookup(res->name);
9617 cmdline_printf(cl, "Cannot find ring\n");
9620 rte_ring_dump(stdout, r);
9621 } else if (!strcmp(res->dump, "dump_mempool")) {
9622 struct rte_mempool *mp;
9623 mp = rte_mempool_lookup(res->name);
9625 cmdline_printf(cl, "Cannot find mempool\n");
9628 rte_mempool_dump(stdout, mp);
9632 cmdline_parse_token_string_t cmd_dump_one_dump =
9633 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9634 "dump_ring#dump_mempool");
9636 cmdline_parse_token_string_t cmd_dump_one_name =
9637 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9639 cmdline_parse_inst_t cmd_dump_one = {
9640 .f = cmd_dump_one_parsed, /* function to call */
9641 .data = NULL, /* 2nd arg of func */
9642 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9643 .tokens = { /* token list, NULL terminated */
9644 (void *)&cmd_dump_one_dump,
9645 (void *)&cmd_dump_one_name,
9650 /* *** queue region set *** */
9651 struct cmd_queue_region_result {
9652 cmdline_fixed_string_t set;
9653 cmdline_fixed_string_t port;
9655 cmdline_fixed_string_t cmd;
9656 cmdline_fixed_string_t region;
9658 cmdline_fixed_string_t queue_start_index;
9660 cmdline_fixed_string_t queue_num;
9661 uint8_t queue_num_value;
9665 cmd_queue_region_parsed(void *parsed_result,
9666 __rte_unused struct cmdline *cl,
9667 __rte_unused void *data)
9669 struct cmd_queue_region_result *res = parsed_result;
9672 struct rte_pmd_i40e_queue_region_conf region_conf;
9673 enum rte_pmd_i40e_queue_region_op op_type;
9676 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9680 memset(®ion_conf, 0, sizeof(region_conf));
9681 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9682 region_conf.region_id = res->region_id;
9683 region_conf.queue_num = res->queue_num_value;
9684 region_conf.queue_start_index = res->queue_id;
9686 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9687 op_type, ®ion_conf);
9694 printf("function not implemented or supported\n");
9697 printf("queue region config error: (%s)\n", strerror(-ret));
9701 cmdline_parse_token_string_t cmd_queue_region_set =
9702 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9704 cmdline_parse_token_string_t cmd_queue_region_port =
9705 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9706 cmdline_parse_token_num_t cmd_queue_region_port_id =
9707 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9708 port_id, RTE_UINT16);
9709 cmdline_parse_token_string_t cmd_queue_region_cmd =
9710 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9711 cmd, "queue-region");
9712 cmdline_parse_token_string_t cmd_queue_region_id =
9713 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9714 region, "region_id");
9715 cmdline_parse_token_num_t cmd_queue_region_index =
9716 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9717 region_id, RTE_UINT8);
9718 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9719 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9720 queue_start_index, "queue_start_index");
9721 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9722 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9723 queue_id, RTE_UINT8);
9724 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9725 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9726 queue_num, "queue_num");
9727 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9728 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9729 queue_num_value, RTE_UINT8);
9731 cmdline_parse_inst_t cmd_queue_region = {
9732 .f = cmd_queue_region_parsed,
9734 .help_str = "set port <port_id> queue-region region_id <value> "
9735 "queue_start_index <value> queue_num <value>: Set a queue region",
9737 (void *)&cmd_queue_region_set,
9738 (void *)&cmd_queue_region_port,
9739 (void *)&cmd_queue_region_port_id,
9740 (void *)&cmd_queue_region_cmd,
9741 (void *)&cmd_queue_region_id,
9742 (void *)&cmd_queue_region_index,
9743 (void *)&cmd_queue_region_queue_start_index,
9744 (void *)&cmd_queue_region_queue_id,
9745 (void *)&cmd_queue_region_queue_num,
9746 (void *)&cmd_queue_region_queue_num_value,
9751 /* *** queue region and flowtype set *** */
9752 struct cmd_region_flowtype_result {
9753 cmdline_fixed_string_t set;
9754 cmdline_fixed_string_t port;
9756 cmdline_fixed_string_t cmd;
9757 cmdline_fixed_string_t region;
9759 cmdline_fixed_string_t flowtype;
9760 uint8_t flowtype_id;
9764 cmd_region_flowtype_parsed(void *parsed_result,
9765 __rte_unused struct cmdline *cl,
9766 __rte_unused void *data)
9768 struct cmd_region_flowtype_result *res = parsed_result;
9771 struct rte_pmd_i40e_queue_region_conf region_conf;
9772 enum rte_pmd_i40e_queue_region_op op_type;
9775 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9779 memset(®ion_conf, 0, sizeof(region_conf));
9781 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9782 region_conf.region_id = res->region_id;
9783 region_conf.hw_flowtype = res->flowtype_id;
9785 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9786 op_type, ®ion_conf);
9793 printf("function not implemented or supported\n");
9796 printf("region flowtype config error: (%s)\n", strerror(-ret));
9800 cmdline_parse_token_string_t cmd_region_flowtype_set =
9801 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9803 cmdline_parse_token_string_t cmd_region_flowtype_port =
9804 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9806 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9807 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9808 port_id, RTE_UINT16);
9809 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9810 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9811 cmd, "queue-region");
9812 cmdline_parse_token_string_t cmd_region_flowtype_index =
9813 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9814 region, "region_id");
9815 cmdline_parse_token_num_t cmd_region_flowtype_id =
9816 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9817 region_id, RTE_UINT8);
9818 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9819 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9820 flowtype, "flowtype");
9821 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9822 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9823 flowtype_id, RTE_UINT8);
9824 cmdline_parse_inst_t cmd_region_flowtype = {
9825 .f = cmd_region_flowtype_parsed,
9827 .help_str = "set port <port_id> queue-region region_id <value> "
9828 "flowtype <value>: Set a flowtype region index",
9830 (void *)&cmd_region_flowtype_set,
9831 (void *)&cmd_region_flowtype_port,
9832 (void *)&cmd_region_flowtype_port_index,
9833 (void *)&cmd_region_flowtype_cmd,
9834 (void *)&cmd_region_flowtype_index,
9835 (void *)&cmd_region_flowtype_id,
9836 (void *)&cmd_region_flowtype_flow_index,
9837 (void *)&cmd_region_flowtype_flow_id,
9842 /* *** User Priority (UP) to queue region (region_id) set *** */
9843 struct cmd_user_priority_region_result {
9844 cmdline_fixed_string_t set;
9845 cmdline_fixed_string_t port;
9847 cmdline_fixed_string_t cmd;
9848 cmdline_fixed_string_t user_priority;
9849 uint8_t user_priority_id;
9850 cmdline_fixed_string_t region;
9855 cmd_user_priority_region_parsed(void *parsed_result,
9856 __rte_unused struct cmdline *cl,
9857 __rte_unused void *data)
9859 struct cmd_user_priority_region_result *res = parsed_result;
9862 struct rte_pmd_i40e_queue_region_conf region_conf;
9863 enum rte_pmd_i40e_queue_region_op op_type;
9866 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9870 memset(®ion_conf, 0, sizeof(region_conf));
9871 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9872 region_conf.user_priority = res->user_priority_id;
9873 region_conf.region_id = res->region_id;
9875 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9876 op_type, ®ion_conf);
9883 printf("function not implemented or supported\n");
9886 printf("user_priority region config error: (%s)\n",
9891 cmdline_parse_token_string_t cmd_user_priority_region_set =
9892 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9894 cmdline_parse_token_string_t cmd_user_priority_region_port =
9895 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9897 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9898 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9899 port_id, RTE_UINT16);
9900 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9901 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9902 cmd, "queue-region");
9903 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9904 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9905 user_priority, "UP");
9906 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9907 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9908 user_priority_id, RTE_UINT8);
9909 cmdline_parse_token_string_t cmd_user_priority_region_region =
9910 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9911 region, "region_id");
9912 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9913 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9914 region_id, RTE_UINT8);
9916 cmdline_parse_inst_t cmd_user_priority_region = {
9917 .f = cmd_user_priority_region_parsed,
9919 .help_str = "set port <port_id> queue-region UP <value> "
9920 "region_id <value>: Set the mapping of User Priority (UP) "
9921 "to queue region (region_id) ",
9923 (void *)&cmd_user_priority_region_set,
9924 (void *)&cmd_user_priority_region_port,
9925 (void *)&cmd_user_priority_region_port_index,
9926 (void *)&cmd_user_priority_region_cmd,
9927 (void *)&cmd_user_priority_region_UP,
9928 (void *)&cmd_user_priority_region_UP_id,
9929 (void *)&cmd_user_priority_region_region,
9930 (void *)&cmd_user_priority_region_region_id,
9935 /* *** flush all queue region related configuration *** */
9936 struct cmd_flush_queue_region_result {
9937 cmdline_fixed_string_t set;
9938 cmdline_fixed_string_t port;
9940 cmdline_fixed_string_t cmd;
9941 cmdline_fixed_string_t flush;
9942 cmdline_fixed_string_t what;
9946 cmd_flush_queue_region_parsed(void *parsed_result,
9947 __rte_unused struct cmdline *cl,
9948 __rte_unused void *data)
9950 struct cmd_flush_queue_region_result *res = parsed_result;
9953 struct rte_pmd_i40e_queue_region_conf region_conf;
9954 enum rte_pmd_i40e_queue_region_op op_type;
9957 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9961 memset(®ion_conf, 0, sizeof(region_conf));
9963 if (strcmp(res->what, "on") == 0)
9964 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9966 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9968 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9969 op_type, ®ion_conf);
9976 printf("function not implemented or supported\n");
9979 printf("queue region config flush error: (%s)\n",
9984 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9985 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9987 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9988 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9990 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9991 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9992 port_id, RTE_UINT16);
9993 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9994 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9995 cmd, "queue-region");
9996 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9997 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9999 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10000 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10003 cmdline_parse_inst_t cmd_flush_queue_region = {
10004 .f = cmd_flush_queue_region_parsed,
10006 .help_str = "set port <port_id> queue-region flush on|off"
10007 ": flush all queue region related configuration",
10009 (void *)&cmd_flush_queue_region_set,
10010 (void *)&cmd_flush_queue_region_port,
10011 (void *)&cmd_flush_queue_region_port_index,
10012 (void *)&cmd_flush_queue_region_cmd,
10013 (void *)&cmd_flush_queue_region_flush,
10014 (void *)&cmd_flush_queue_region_what,
10019 /* *** get all queue region related configuration info *** */
10020 struct cmd_show_queue_region_info {
10021 cmdline_fixed_string_t show;
10022 cmdline_fixed_string_t port;
10024 cmdline_fixed_string_t cmd;
10028 cmd_show_queue_region_info_parsed(void *parsed_result,
10029 __rte_unused struct cmdline *cl,
10030 __rte_unused void *data)
10032 struct cmd_show_queue_region_info *res = parsed_result;
10033 int ret = -ENOTSUP;
10034 #ifdef RTE_NET_I40E
10035 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10036 enum rte_pmd_i40e_queue_region_op op_type;
10039 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10042 #ifdef RTE_NET_I40E
10043 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10045 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10047 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10048 op_type, &rte_pmd_regions);
10050 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10057 printf("function not implemented or supported\n");
10060 printf("queue region config info show error: (%s)\n",
10065 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10066 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10068 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10069 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10071 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10072 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10073 port_id, RTE_UINT16);
10074 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10075 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10076 cmd, "queue-region");
10078 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10079 .f = cmd_show_queue_region_info_parsed,
10081 .help_str = "show port <port_id> queue-region"
10082 ": show all queue region related configuration info",
10084 (void *)&cmd_show_queue_region_info_get,
10085 (void *)&cmd_show_queue_region_info_port,
10086 (void *)&cmd_show_queue_region_info_port_index,
10087 (void *)&cmd_show_queue_region_info_cmd,
10092 /* *** Filters Control *** */
10094 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10096 if ((ip_addr).family == AF_INET) \
10097 (ip) = (ip_addr).addr.ipv4.s_addr; \
10099 printf("invalid parameter.\n"); \
10104 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10106 if ((ip_addr).family == AF_INET6) \
10107 rte_memcpy(&(ip), \
10108 &((ip_addr).addr.ipv6), \
10109 sizeof(struct in6_addr)); \
10111 printf("invalid parameter.\n"); \
10116 #ifdef RTE_NET_I40E
10119 str2flowtype(char *string)
10122 static const struct {
10125 } flowtype_str[] = {
10126 {"raw", RTE_ETH_FLOW_RAW},
10127 {"ipv4", RTE_ETH_FLOW_IPV4},
10128 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10129 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10130 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10131 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10132 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10133 {"ipv6", RTE_ETH_FLOW_IPV6},
10134 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10135 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10136 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10137 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10138 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10139 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10142 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10143 if (!strcmp(flowtype_str[i].str, string))
10144 return flowtype_str[i].type;
10147 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10148 return (uint16_t)atoi(string);
10150 return RTE_ETH_FLOW_UNKNOWN;
10153 /* *** deal with flow director filter *** */
10154 struct cmd_flow_director_result {
10155 cmdline_fixed_string_t flow_director_filter;
10157 cmdline_fixed_string_t mode;
10158 cmdline_fixed_string_t mode_value;
10159 cmdline_fixed_string_t ops;
10160 cmdline_fixed_string_t flow;
10161 cmdline_fixed_string_t flow_type;
10162 cmdline_fixed_string_t drop;
10163 cmdline_fixed_string_t queue;
10165 cmdline_fixed_string_t fd_id;
10166 uint32_t fd_id_value;
10167 cmdline_fixed_string_t packet;
10172 cmd_flow_director_filter_parsed(void *parsed_result,
10173 __rte_unused struct cmdline *cl,
10174 __rte_unused void *data)
10176 struct cmd_flow_director_result *res = parsed_result;
10178 struct rte_pmd_i40e_flow_type_mapping
10179 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10180 struct rte_pmd_i40e_pkt_template_conf conf;
10181 uint16_t flow_type = str2flowtype(res->flow_type);
10182 uint16_t i, port = res->port_id;
10185 memset(&conf, 0, sizeof(conf));
10187 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10188 printf("Invalid flow type specified.\n");
10191 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10195 if (mapping[flow_type].pctype == 0ULL) {
10196 printf("Invalid flow type specified.\n");
10199 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10200 if (mapping[flow_type].pctype & (1ULL << i)) {
10201 conf.input.pctype = i;
10206 conf.input.packet = open_file(res->filepath,
10207 &conf.input.length);
10208 if (!conf.input.packet)
10210 if (!strcmp(res->drop, "drop"))
10211 conf.action.behavior =
10212 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10214 conf.action.behavior =
10215 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10216 conf.action.report_status =
10217 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10218 conf.action.rx_queue = res->queue_id;
10219 conf.soft_id = res->fd_id_value;
10220 add = strcmp(res->ops, "del") ? 1 : 0;
10221 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10225 printf("flow director config error: (%s)\n",
10227 close_file(conf.input.packet);
10230 cmdline_parse_token_string_t cmd_flow_director_filter =
10231 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10232 flow_director_filter, "flow_director_filter");
10233 cmdline_parse_token_num_t cmd_flow_director_port_id =
10234 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10235 port_id, RTE_UINT16);
10236 cmdline_parse_token_string_t cmd_flow_director_ops =
10237 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10238 ops, "add#del#update");
10239 cmdline_parse_token_string_t cmd_flow_director_flow =
10240 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10242 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10243 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10245 cmdline_parse_token_string_t cmd_flow_director_drop =
10246 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10248 cmdline_parse_token_string_t cmd_flow_director_queue =
10249 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10251 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10252 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10253 queue_id, RTE_UINT16);
10254 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10255 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10257 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10258 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10259 fd_id_value, RTE_UINT32);
10261 cmdline_parse_token_string_t cmd_flow_director_mode =
10262 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10264 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10265 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10266 mode_value, "raw");
10267 cmdline_parse_token_string_t cmd_flow_director_packet =
10268 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10270 cmdline_parse_token_string_t cmd_flow_director_filepath =
10271 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10274 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10275 .f = cmd_flow_director_filter_parsed,
10277 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10278 "director entry on NIC",
10280 (void *)&cmd_flow_director_filter,
10281 (void *)&cmd_flow_director_port_id,
10282 (void *)&cmd_flow_director_mode,
10283 (void *)&cmd_flow_director_mode_raw,
10284 (void *)&cmd_flow_director_ops,
10285 (void *)&cmd_flow_director_flow,
10286 (void *)&cmd_flow_director_flow_type,
10287 (void *)&cmd_flow_director_drop,
10288 (void *)&cmd_flow_director_queue,
10289 (void *)&cmd_flow_director_queue_id,
10290 (void *)&cmd_flow_director_fd_id,
10291 (void *)&cmd_flow_director_fd_id_value,
10292 (void *)&cmd_flow_director_packet,
10293 (void *)&cmd_flow_director_filepath,
10298 #endif /* RTE_NET_I40E */
10300 /* *** deal with flow director mask *** */
10301 struct cmd_flow_director_mask_result {
10302 cmdline_fixed_string_t flow_director_mask;
10304 cmdline_fixed_string_t mode;
10305 cmdline_fixed_string_t mode_value;
10306 cmdline_fixed_string_t vlan;
10307 uint16_t vlan_mask;
10308 cmdline_fixed_string_t src_mask;
10309 cmdline_ipaddr_t ipv4_src;
10310 cmdline_ipaddr_t ipv6_src;
10312 cmdline_fixed_string_t dst_mask;
10313 cmdline_ipaddr_t ipv4_dst;
10314 cmdline_ipaddr_t ipv6_dst;
10316 cmdline_fixed_string_t mac;
10317 uint8_t mac_addr_byte_mask;
10318 cmdline_fixed_string_t tunnel_id;
10319 uint32_t tunnel_id_mask;
10320 cmdline_fixed_string_t tunnel_type;
10321 uint8_t tunnel_type_mask;
10325 cmd_flow_director_mask_parsed(void *parsed_result,
10326 __rte_unused struct cmdline *cl,
10327 __rte_unused void *data)
10329 struct cmd_flow_director_mask_result *res = parsed_result;
10330 struct rte_eth_fdir_masks *mask;
10331 struct rte_port *port;
10333 port = &ports[res->port_id];
10334 /** Check if the port is not started **/
10335 if (port->port_status != RTE_PORT_STOPPED) {
10336 printf("Please stop port %d first\n", res->port_id);
10340 mask = &port->dev_conf.fdir_conf.mask;
10342 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10343 if (strcmp(res->mode_value, "MAC-VLAN")) {
10344 printf("Please set mode to MAC-VLAN.\n");
10348 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10349 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10350 if (strcmp(res->mode_value, "Tunnel")) {
10351 printf("Please set mode to Tunnel.\n");
10355 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10356 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10357 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10358 mask->tunnel_type_mask = res->tunnel_type_mask;
10360 if (strcmp(res->mode_value, "IP")) {
10361 printf("Please set mode to IP.\n");
10365 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10366 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10367 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10368 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10369 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10370 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10371 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10374 cmd_reconfig_device_queue(res->port_id, 1, 1);
10377 cmdline_parse_token_string_t cmd_flow_director_mask =
10378 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10379 flow_director_mask, "flow_director_mask");
10380 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10381 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10382 port_id, RTE_UINT16);
10383 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10384 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10386 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10387 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10388 vlan_mask, RTE_UINT16);
10389 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10390 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10391 src_mask, "src_mask");
10392 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10393 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10395 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10396 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10398 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10399 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10400 port_src, RTE_UINT16);
10401 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10402 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10403 dst_mask, "dst_mask");
10404 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10405 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10407 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10408 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10410 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10411 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10412 port_dst, RTE_UINT16);
10414 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10415 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10417 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10418 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10420 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10421 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10422 mode_value, "MAC-VLAN");
10423 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10424 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10425 mode_value, "Tunnel");
10426 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10427 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10429 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10430 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10431 mac_addr_byte_mask, RTE_UINT8);
10432 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10433 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10434 tunnel_type, "tunnel-type");
10435 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10436 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10437 tunnel_type_mask, RTE_UINT8);
10438 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10439 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10440 tunnel_id, "tunnel-id");
10441 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10442 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10443 tunnel_id_mask, RTE_UINT32);
10445 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10446 .f = cmd_flow_director_mask_parsed,
10448 .help_str = "flow_director_mask ... : "
10449 "Set IP mode flow director's mask on NIC",
10451 (void *)&cmd_flow_director_mask,
10452 (void *)&cmd_flow_director_mask_port_id,
10453 (void *)&cmd_flow_director_mask_mode,
10454 (void *)&cmd_flow_director_mask_mode_ip,
10455 (void *)&cmd_flow_director_mask_vlan,
10456 (void *)&cmd_flow_director_mask_vlan_value,
10457 (void *)&cmd_flow_director_mask_src,
10458 (void *)&cmd_flow_director_mask_ipv4_src,
10459 (void *)&cmd_flow_director_mask_ipv6_src,
10460 (void *)&cmd_flow_director_mask_port_src,
10461 (void *)&cmd_flow_director_mask_dst,
10462 (void *)&cmd_flow_director_mask_ipv4_dst,
10463 (void *)&cmd_flow_director_mask_ipv6_dst,
10464 (void *)&cmd_flow_director_mask_port_dst,
10469 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10470 .f = cmd_flow_director_mask_parsed,
10472 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10473 "flow director's mask on NIC",
10475 (void *)&cmd_flow_director_mask,
10476 (void *)&cmd_flow_director_mask_port_id,
10477 (void *)&cmd_flow_director_mask_mode,
10478 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10479 (void *)&cmd_flow_director_mask_vlan,
10480 (void *)&cmd_flow_director_mask_vlan_value,
10485 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10486 .f = cmd_flow_director_mask_parsed,
10488 .help_str = "flow_director_mask ... : Set tunnel mode "
10489 "flow director's mask on NIC",
10491 (void *)&cmd_flow_director_mask,
10492 (void *)&cmd_flow_director_mask_port_id,
10493 (void *)&cmd_flow_director_mask_mode,
10494 (void *)&cmd_flow_director_mask_mode_tunnel,
10495 (void *)&cmd_flow_director_mask_vlan,
10496 (void *)&cmd_flow_director_mask_vlan_value,
10497 (void *)&cmd_flow_director_mask_mac,
10498 (void *)&cmd_flow_director_mask_mac_value,
10499 (void *)&cmd_flow_director_mask_tunnel_type,
10500 (void *)&cmd_flow_director_mask_tunnel_type_value,
10501 (void *)&cmd_flow_director_mask_tunnel_id,
10502 (void *)&cmd_flow_director_mask_tunnel_id_value,
10507 /* *** deal with flow director flexible payload configuration *** */
10508 struct cmd_flow_director_flexpayload_result {
10509 cmdline_fixed_string_t flow_director_flexpayload;
10511 cmdline_fixed_string_t payload_layer;
10512 cmdline_fixed_string_t payload_cfg;
10516 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10519 const char *p, *p0 = q_arg;
10521 unsigned long int_fld;
10522 char *str_fld[max_num];
10527 p = strchr(p0, '(');
10531 p0 = strchr(p, ')');
10536 if (size >= sizeof(s))
10539 snprintf(s, sizeof(s), "%.*s", size, p);
10540 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10541 if (ret < 0 || ret > max_num)
10543 for (i = 0; i < ret; i++) {
10545 int_fld = strtoul(str_fld[i], &end, 0);
10546 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10548 offsets[i] = (uint16_t)int_fld;
10554 cmd_flow_director_flxpld_parsed(void *parsed_result,
10555 __rte_unused struct cmdline *cl,
10556 __rte_unused void *data)
10558 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10559 struct rte_eth_flex_payload_cfg flex_cfg;
10560 struct rte_port *port;
10563 port = &ports[res->port_id];
10564 /** Check if the port is not started **/
10565 if (port->port_status != RTE_PORT_STOPPED) {
10566 printf("Please stop port %d first\n", res->port_id);
10570 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10572 if (!strcmp(res->payload_layer, "raw"))
10573 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10574 else if (!strcmp(res->payload_layer, "l2"))
10575 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10576 else if (!strcmp(res->payload_layer, "l3"))
10577 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10578 else if (!strcmp(res->payload_layer, "l4"))
10579 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10581 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10582 RTE_ETH_FDIR_MAX_FLEXLEN);
10584 printf("error: Cannot parse flex payload input.\n");
10588 fdir_set_flex_payload(res->port_id, &flex_cfg);
10589 cmd_reconfig_device_queue(res->port_id, 1, 1);
10592 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10593 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10594 flow_director_flexpayload,
10595 "flow_director_flex_payload");
10596 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10597 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10598 port_id, RTE_UINT16);
10599 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10600 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10601 payload_layer, "raw#l2#l3#l4");
10602 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10603 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10604 payload_cfg, NULL);
10606 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10607 .f = cmd_flow_director_flxpld_parsed,
10609 .help_str = "flow_director_flexpayload ... : "
10610 "Set flow director's flex payload on NIC",
10612 (void *)&cmd_flow_director_flexpayload,
10613 (void *)&cmd_flow_director_flexpayload_port_id,
10614 (void *)&cmd_flow_director_flexpayload_payload_layer,
10615 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10620 /* Generic flow interface command. */
10621 extern cmdline_parse_inst_t cmd_flow;
10623 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10624 struct cmd_mcast_addr_result {
10625 cmdline_fixed_string_t mcast_addr_cmd;
10626 cmdline_fixed_string_t what;
10628 struct rte_ether_addr mc_addr;
10631 static void cmd_mcast_addr_parsed(void *parsed_result,
10632 __rte_unused struct cmdline *cl,
10633 __rte_unused void *data)
10635 struct cmd_mcast_addr_result *res = parsed_result;
10637 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
10638 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10639 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10640 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10641 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10644 if (strcmp(res->what, "add") == 0)
10645 mcast_addr_add(res->port_num, &res->mc_addr);
10647 mcast_addr_remove(res->port_num, &res->mc_addr);
10650 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10651 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10652 mcast_addr_cmd, "mcast_addr");
10653 cmdline_parse_token_string_t cmd_mcast_addr_what =
10654 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10656 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10657 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
10659 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10660 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10662 cmdline_parse_inst_t cmd_mcast_addr = {
10663 .f = cmd_mcast_addr_parsed,
10665 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10666 "Add/Remove multicast MAC address on port_id",
10668 (void *)&cmd_mcast_addr_cmd,
10669 (void *)&cmd_mcast_addr_what,
10670 (void *)&cmd_mcast_addr_portnum,
10671 (void *)&cmd_mcast_addr_addr,
10676 /* vf vlan anti spoof configuration */
10678 /* Common result structure for vf vlan anti spoof */
10679 struct cmd_vf_vlan_anti_spoof_result {
10680 cmdline_fixed_string_t set;
10681 cmdline_fixed_string_t vf;
10682 cmdline_fixed_string_t vlan;
10683 cmdline_fixed_string_t antispoof;
10686 cmdline_fixed_string_t on_off;
10689 /* Common CLI fields for vf vlan anti spoof enable disable */
10690 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10691 TOKEN_STRING_INITIALIZER
10692 (struct cmd_vf_vlan_anti_spoof_result,
10694 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10695 TOKEN_STRING_INITIALIZER
10696 (struct cmd_vf_vlan_anti_spoof_result,
10698 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10699 TOKEN_STRING_INITIALIZER
10700 (struct cmd_vf_vlan_anti_spoof_result,
10702 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10703 TOKEN_STRING_INITIALIZER
10704 (struct cmd_vf_vlan_anti_spoof_result,
10705 antispoof, "antispoof");
10706 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10707 TOKEN_NUM_INITIALIZER
10708 (struct cmd_vf_vlan_anti_spoof_result,
10709 port_id, RTE_UINT16);
10710 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10711 TOKEN_NUM_INITIALIZER
10712 (struct cmd_vf_vlan_anti_spoof_result,
10713 vf_id, RTE_UINT32);
10714 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10715 TOKEN_STRING_INITIALIZER
10716 (struct cmd_vf_vlan_anti_spoof_result,
10720 cmd_set_vf_vlan_anti_spoof_parsed(
10721 void *parsed_result,
10722 __rte_unused struct cmdline *cl,
10723 __rte_unused void *data)
10725 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10726 int ret = -ENOTSUP;
10728 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10730 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10733 #ifdef RTE_NET_IXGBE
10734 if (ret == -ENOTSUP)
10735 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10736 res->vf_id, is_on);
10738 #ifdef RTE_NET_I40E
10739 if (ret == -ENOTSUP)
10740 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10741 res->vf_id, is_on);
10743 #ifdef RTE_NET_BNXT
10744 if (ret == -ENOTSUP)
10745 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
10746 res->vf_id, is_on);
10753 printf("invalid vf_id %d\n", res->vf_id);
10756 printf("invalid port_id %d\n", res->port_id);
10759 printf("function not implemented\n");
10762 printf("programming error: (%s)\n", strerror(-ret));
10766 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10767 .f = cmd_set_vf_vlan_anti_spoof_parsed,
10769 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10771 (void *)&cmd_vf_vlan_anti_spoof_set,
10772 (void *)&cmd_vf_vlan_anti_spoof_vf,
10773 (void *)&cmd_vf_vlan_anti_spoof_vlan,
10774 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
10775 (void *)&cmd_vf_vlan_anti_spoof_port_id,
10776 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
10777 (void *)&cmd_vf_vlan_anti_spoof_on_off,
10782 /* vf mac anti spoof configuration */
10784 /* Common result structure for vf mac anti spoof */
10785 struct cmd_vf_mac_anti_spoof_result {
10786 cmdline_fixed_string_t set;
10787 cmdline_fixed_string_t vf;
10788 cmdline_fixed_string_t mac;
10789 cmdline_fixed_string_t antispoof;
10792 cmdline_fixed_string_t on_off;
10795 /* Common CLI fields for vf mac anti spoof enable disable */
10796 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
10797 TOKEN_STRING_INITIALIZER
10798 (struct cmd_vf_mac_anti_spoof_result,
10800 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
10801 TOKEN_STRING_INITIALIZER
10802 (struct cmd_vf_mac_anti_spoof_result,
10804 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
10805 TOKEN_STRING_INITIALIZER
10806 (struct cmd_vf_mac_anti_spoof_result,
10808 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
10809 TOKEN_STRING_INITIALIZER
10810 (struct cmd_vf_mac_anti_spoof_result,
10811 antispoof, "antispoof");
10812 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
10813 TOKEN_NUM_INITIALIZER
10814 (struct cmd_vf_mac_anti_spoof_result,
10815 port_id, RTE_UINT16);
10816 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
10817 TOKEN_NUM_INITIALIZER
10818 (struct cmd_vf_mac_anti_spoof_result,
10819 vf_id, RTE_UINT32);
10820 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
10821 TOKEN_STRING_INITIALIZER
10822 (struct cmd_vf_mac_anti_spoof_result,
10826 cmd_set_vf_mac_anti_spoof_parsed(
10827 void *parsed_result,
10828 __rte_unused struct cmdline *cl,
10829 __rte_unused void *data)
10831 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
10832 int ret = -ENOTSUP;
10834 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10836 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10839 #ifdef RTE_NET_IXGBE
10840 if (ret == -ENOTSUP)
10841 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
10842 res->vf_id, is_on);
10844 #ifdef RTE_NET_I40E
10845 if (ret == -ENOTSUP)
10846 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
10847 res->vf_id, is_on);
10849 #ifdef RTE_NET_BNXT
10850 if (ret == -ENOTSUP)
10851 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
10852 res->vf_id, is_on);
10859 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
10862 printf("invalid port_id %d\n", res->port_id);
10865 printf("function not implemented\n");
10868 printf("programming error: (%s)\n", strerror(-ret));
10872 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
10873 .f = cmd_set_vf_mac_anti_spoof_parsed,
10875 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
10877 (void *)&cmd_vf_mac_anti_spoof_set,
10878 (void *)&cmd_vf_mac_anti_spoof_vf,
10879 (void *)&cmd_vf_mac_anti_spoof_mac,
10880 (void *)&cmd_vf_mac_anti_spoof_antispoof,
10881 (void *)&cmd_vf_mac_anti_spoof_port_id,
10882 (void *)&cmd_vf_mac_anti_spoof_vf_id,
10883 (void *)&cmd_vf_mac_anti_spoof_on_off,
10888 /* vf vlan strip queue configuration */
10890 /* Common result structure for vf mac anti spoof */
10891 struct cmd_vf_vlan_stripq_result {
10892 cmdline_fixed_string_t set;
10893 cmdline_fixed_string_t vf;
10894 cmdline_fixed_string_t vlan;
10895 cmdline_fixed_string_t stripq;
10898 cmdline_fixed_string_t on_off;
10901 /* Common CLI fields for vf vlan strip enable disable */
10902 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
10903 TOKEN_STRING_INITIALIZER
10904 (struct cmd_vf_vlan_stripq_result,
10906 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
10907 TOKEN_STRING_INITIALIZER
10908 (struct cmd_vf_vlan_stripq_result,
10910 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
10911 TOKEN_STRING_INITIALIZER
10912 (struct cmd_vf_vlan_stripq_result,
10914 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
10915 TOKEN_STRING_INITIALIZER
10916 (struct cmd_vf_vlan_stripq_result,
10918 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
10919 TOKEN_NUM_INITIALIZER
10920 (struct cmd_vf_vlan_stripq_result,
10921 port_id, RTE_UINT16);
10922 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
10923 TOKEN_NUM_INITIALIZER
10924 (struct cmd_vf_vlan_stripq_result,
10925 vf_id, RTE_UINT16);
10926 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
10927 TOKEN_STRING_INITIALIZER
10928 (struct cmd_vf_vlan_stripq_result,
10932 cmd_set_vf_vlan_stripq_parsed(
10933 void *parsed_result,
10934 __rte_unused struct cmdline *cl,
10935 __rte_unused void *data)
10937 struct cmd_vf_vlan_stripq_result *res = parsed_result;
10938 int ret = -ENOTSUP;
10940 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10942 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10945 #ifdef RTE_NET_IXGBE
10946 if (ret == -ENOTSUP)
10947 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
10948 res->vf_id, is_on);
10950 #ifdef RTE_NET_I40E
10951 if (ret == -ENOTSUP)
10952 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
10953 res->vf_id, is_on);
10955 #ifdef RTE_NET_BNXT
10956 if (ret == -ENOTSUP)
10957 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
10958 res->vf_id, is_on);
10965 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
10968 printf("invalid port_id %d\n", res->port_id);
10971 printf("function not implemented\n");
10974 printf("programming error: (%s)\n", strerror(-ret));
10978 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
10979 .f = cmd_set_vf_vlan_stripq_parsed,
10981 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
10983 (void *)&cmd_vf_vlan_stripq_set,
10984 (void *)&cmd_vf_vlan_stripq_vf,
10985 (void *)&cmd_vf_vlan_stripq_vlan,
10986 (void *)&cmd_vf_vlan_stripq_stripq,
10987 (void *)&cmd_vf_vlan_stripq_port_id,
10988 (void *)&cmd_vf_vlan_stripq_vf_id,
10989 (void *)&cmd_vf_vlan_stripq_on_off,
10994 /* vf vlan insert configuration */
10996 /* Common result structure for vf vlan insert */
10997 struct cmd_vf_vlan_insert_result {
10998 cmdline_fixed_string_t set;
10999 cmdline_fixed_string_t vf;
11000 cmdline_fixed_string_t vlan;
11001 cmdline_fixed_string_t insert;
11007 /* Common CLI fields for vf vlan insert enable disable */
11008 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11009 TOKEN_STRING_INITIALIZER
11010 (struct cmd_vf_vlan_insert_result,
11012 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11013 TOKEN_STRING_INITIALIZER
11014 (struct cmd_vf_vlan_insert_result,
11016 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11017 TOKEN_STRING_INITIALIZER
11018 (struct cmd_vf_vlan_insert_result,
11020 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11021 TOKEN_STRING_INITIALIZER
11022 (struct cmd_vf_vlan_insert_result,
11024 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11025 TOKEN_NUM_INITIALIZER
11026 (struct cmd_vf_vlan_insert_result,
11027 port_id, RTE_UINT16);
11028 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11029 TOKEN_NUM_INITIALIZER
11030 (struct cmd_vf_vlan_insert_result,
11031 vf_id, RTE_UINT16);
11032 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11033 TOKEN_NUM_INITIALIZER
11034 (struct cmd_vf_vlan_insert_result,
11035 vlan_id, RTE_UINT16);
11038 cmd_set_vf_vlan_insert_parsed(
11039 void *parsed_result,
11040 __rte_unused struct cmdline *cl,
11041 __rte_unused void *data)
11043 struct cmd_vf_vlan_insert_result *res = parsed_result;
11044 int ret = -ENOTSUP;
11046 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11049 #ifdef RTE_NET_IXGBE
11050 if (ret == -ENOTSUP)
11051 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11054 #ifdef RTE_NET_I40E
11055 if (ret == -ENOTSUP)
11056 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11059 #ifdef RTE_NET_BNXT
11060 if (ret == -ENOTSUP)
11061 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11069 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11072 printf("invalid port_id %d\n", res->port_id);
11075 printf("function not implemented\n");
11078 printf("programming error: (%s)\n", strerror(-ret));
11082 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11083 .f = cmd_set_vf_vlan_insert_parsed,
11085 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11087 (void *)&cmd_vf_vlan_insert_set,
11088 (void *)&cmd_vf_vlan_insert_vf,
11089 (void *)&cmd_vf_vlan_insert_vlan,
11090 (void *)&cmd_vf_vlan_insert_insert,
11091 (void *)&cmd_vf_vlan_insert_port_id,
11092 (void *)&cmd_vf_vlan_insert_vf_id,
11093 (void *)&cmd_vf_vlan_insert_vlan_id,
11098 /* tx loopback configuration */
11100 /* Common result structure for tx loopback */
11101 struct cmd_tx_loopback_result {
11102 cmdline_fixed_string_t set;
11103 cmdline_fixed_string_t tx;
11104 cmdline_fixed_string_t loopback;
11106 cmdline_fixed_string_t on_off;
11109 /* Common CLI fields for tx loopback enable disable */
11110 cmdline_parse_token_string_t cmd_tx_loopback_set =
11111 TOKEN_STRING_INITIALIZER
11112 (struct cmd_tx_loopback_result,
11114 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11115 TOKEN_STRING_INITIALIZER
11116 (struct cmd_tx_loopback_result,
11118 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11119 TOKEN_STRING_INITIALIZER
11120 (struct cmd_tx_loopback_result,
11121 loopback, "loopback");
11122 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11123 TOKEN_NUM_INITIALIZER
11124 (struct cmd_tx_loopback_result,
11125 port_id, RTE_UINT16);
11126 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11127 TOKEN_STRING_INITIALIZER
11128 (struct cmd_tx_loopback_result,
11132 cmd_set_tx_loopback_parsed(
11133 void *parsed_result,
11134 __rte_unused struct cmdline *cl,
11135 __rte_unused void *data)
11137 struct cmd_tx_loopback_result *res = parsed_result;
11138 int ret = -ENOTSUP;
11140 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11142 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11145 #ifdef RTE_NET_IXGBE
11146 if (ret == -ENOTSUP)
11147 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11149 #ifdef RTE_NET_I40E
11150 if (ret == -ENOTSUP)
11151 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11153 #ifdef RTE_NET_BNXT
11154 if (ret == -ENOTSUP)
11155 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11157 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11158 if (ret == -ENOTSUP)
11159 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11166 printf("invalid is_on %d\n", is_on);
11169 printf("invalid port_id %d\n", res->port_id);
11172 printf("function not implemented\n");
11175 printf("programming error: (%s)\n", strerror(-ret));
11179 cmdline_parse_inst_t cmd_set_tx_loopback = {
11180 .f = cmd_set_tx_loopback_parsed,
11182 .help_str = "set tx loopback <port_id> on|off",
11184 (void *)&cmd_tx_loopback_set,
11185 (void *)&cmd_tx_loopback_tx,
11186 (void *)&cmd_tx_loopback_loopback,
11187 (void *)&cmd_tx_loopback_port_id,
11188 (void *)&cmd_tx_loopback_on_off,
11193 /* all queues drop enable configuration */
11195 /* Common result structure for all queues drop enable */
11196 struct cmd_all_queues_drop_en_result {
11197 cmdline_fixed_string_t set;
11198 cmdline_fixed_string_t all;
11199 cmdline_fixed_string_t queues;
11200 cmdline_fixed_string_t drop;
11202 cmdline_fixed_string_t on_off;
11205 /* Common CLI fields for tx loopback enable disable */
11206 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11207 TOKEN_STRING_INITIALIZER
11208 (struct cmd_all_queues_drop_en_result,
11210 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11211 TOKEN_STRING_INITIALIZER
11212 (struct cmd_all_queues_drop_en_result,
11214 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11215 TOKEN_STRING_INITIALIZER
11216 (struct cmd_all_queues_drop_en_result,
11218 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11219 TOKEN_STRING_INITIALIZER
11220 (struct cmd_all_queues_drop_en_result,
11222 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11223 TOKEN_NUM_INITIALIZER
11224 (struct cmd_all_queues_drop_en_result,
11225 port_id, RTE_UINT16);
11226 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11227 TOKEN_STRING_INITIALIZER
11228 (struct cmd_all_queues_drop_en_result,
11232 cmd_set_all_queues_drop_en_parsed(
11233 void *parsed_result,
11234 __rte_unused struct cmdline *cl,
11235 __rte_unused void *data)
11237 struct cmd_all_queues_drop_en_result *res = parsed_result;
11238 int ret = -ENOTSUP;
11239 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11241 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11244 #ifdef RTE_NET_IXGBE
11245 if (ret == -ENOTSUP)
11246 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11248 #ifdef RTE_NET_BNXT
11249 if (ret == -ENOTSUP)
11250 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11256 printf("invalid is_on %d\n", is_on);
11259 printf("invalid port_id %d\n", res->port_id);
11262 printf("function not implemented\n");
11265 printf("programming error: (%s)\n", strerror(-ret));
11269 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11270 .f = cmd_set_all_queues_drop_en_parsed,
11272 .help_str = "set all queues drop <port_id> on|off",
11274 (void *)&cmd_all_queues_drop_en_set,
11275 (void *)&cmd_all_queues_drop_en_all,
11276 (void *)&cmd_all_queues_drop_en_queues,
11277 (void *)&cmd_all_queues_drop_en_drop,
11278 (void *)&cmd_all_queues_drop_en_port_id,
11279 (void *)&cmd_all_queues_drop_en_on_off,
11284 /* vf split drop enable configuration */
11286 /* Common result structure for vf split drop enable */
11287 struct cmd_vf_split_drop_en_result {
11288 cmdline_fixed_string_t set;
11289 cmdline_fixed_string_t vf;
11290 cmdline_fixed_string_t split;
11291 cmdline_fixed_string_t drop;
11294 cmdline_fixed_string_t on_off;
11297 /* Common CLI fields for vf split drop enable disable */
11298 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11299 TOKEN_STRING_INITIALIZER
11300 (struct cmd_vf_split_drop_en_result,
11302 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11303 TOKEN_STRING_INITIALIZER
11304 (struct cmd_vf_split_drop_en_result,
11306 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11307 TOKEN_STRING_INITIALIZER
11308 (struct cmd_vf_split_drop_en_result,
11310 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11311 TOKEN_STRING_INITIALIZER
11312 (struct cmd_vf_split_drop_en_result,
11314 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11315 TOKEN_NUM_INITIALIZER
11316 (struct cmd_vf_split_drop_en_result,
11317 port_id, RTE_UINT16);
11318 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11319 TOKEN_NUM_INITIALIZER
11320 (struct cmd_vf_split_drop_en_result,
11321 vf_id, RTE_UINT16);
11322 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11323 TOKEN_STRING_INITIALIZER
11324 (struct cmd_vf_split_drop_en_result,
11328 cmd_set_vf_split_drop_en_parsed(
11329 void *parsed_result,
11330 __rte_unused struct cmdline *cl,
11331 __rte_unused void *data)
11333 struct cmd_vf_split_drop_en_result *res = parsed_result;
11334 int ret = -ENOTSUP;
11335 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11337 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11340 #ifdef RTE_NET_IXGBE
11341 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11348 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11351 printf("invalid port_id %d\n", res->port_id);
11354 printf("not supported on port %d\n", res->port_id);
11357 printf("programming error: (%s)\n", strerror(-ret));
11361 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11362 .f = cmd_set_vf_split_drop_en_parsed,
11364 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11366 (void *)&cmd_vf_split_drop_en_set,
11367 (void *)&cmd_vf_split_drop_en_vf,
11368 (void *)&cmd_vf_split_drop_en_split,
11369 (void *)&cmd_vf_split_drop_en_drop,
11370 (void *)&cmd_vf_split_drop_en_port_id,
11371 (void *)&cmd_vf_split_drop_en_vf_id,
11372 (void *)&cmd_vf_split_drop_en_on_off,
11377 /* vf mac address configuration */
11379 /* Common result structure for vf mac address */
11380 struct cmd_set_vf_mac_addr_result {
11381 cmdline_fixed_string_t set;
11382 cmdline_fixed_string_t vf;
11383 cmdline_fixed_string_t mac;
11384 cmdline_fixed_string_t addr;
11387 struct rte_ether_addr mac_addr;
11391 /* Common CLI fields for vf split drop enable disable */
11392 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11393 TOKEN_STRING_INITIALIZER
11394 (struct cmd_set_vf_mac_addr_result,
11396 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11397 TOKEN_STRING_INITIALIZER
11398 (struct cmd_set_vf_mac_addr_result,
11400 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11401 TOKEN_STRING_INITIALIZER
11402 (struct cmd_set_vf_mac_addr_result,
11404 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11405 TOKEN_STRING_INITIALIZER
11406 (struct cmd_set_vf_mac_addr_result,
11408 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11409 TOKEN_NUM_INITIALIZER
11410 (struct cmd_set_vf_mac_addr_result,
11411 port_id, RTE_UINT16);
11412 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11413 TOKEN_NUM_INITIALIZER
11414 (struct cmd_set_vf_mac_addr_result,
11415 vf_id, RTE_UINT16);
11416 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11417 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11421 cmd_set_vf_mac_addr_parsed(
11422 void *parsed_result,
11423 __rte_unused struct cmdline *cl,
11424 __rte_unused void *data)
11426 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11427 int ret = -ENOTSUP;
11429 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11432 #ifdef RTE_NET_IXGBE
11433 if (ret == -ENOTSUP)
11434 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11437 #ifdef RTE_NET_I40E
11438 if (ret == -ENOTSUP)
11439 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11442 #ifdef RTE_NET_BNXT
11443 if (ret == -ENOTSUP)
11444 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11452 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11455 printf("invalid port_id %d\n", res->port_id);
11458 printf("function not implemented\n");
11461 printf("programming error: (%s)\n", strerror(-ret));
11465 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11466 .f = cmd_set_vf_mac_addr_parsed,
11468 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11470 (void *)&cmd_set_vf_mac_addr_set,
11471 (void *)&cmd_set_vf_mac_addr_vf,
11472 (void *)&cmd_set_vf_mac_addr_mac,
11473 (void *)&cmd_set_vf_mac_addr_addr,
11474 (void *)&cmd_set_vf_mac_addr_port_id,
11475 (void *)&cmd_set_vf_mac_addr_vf_id,
11476 (void *)&cmd_set_vf_mac_addr_mac_addr,
11481 /* MACsec configuration */
11483 /* Common result structure for MACsec offload enable */
11484 struct cmd_macsec_offload_on_result {
11485 cmdline_fixed_string_t set;
11486 cmdline_fixed_string_t macsec;
11487 cmdline_fixed_string_t offload;
11489 cmdline_fixed_string_t on;
11490 cmdline_fixed_string_t encrypt;
11491 cmdline_fixed_string_t en_on_off;
11492 cmdline_fixed_string_t replay_protect;
11493 cmdline_fixed_string_t rp_on_off;
11496 /* Common CLI fields for MACsec offload disable */
11497 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11498 TOKEN_STRING_INITIALIZER
11499 (struct cmd_macsec_offload_on_result,
11501 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11502 TOKEN_STRING_INITIALIZER
11503 (struct cmd_macsec_offload_on_result,
11505 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11506 TOKEN_STRING_INITIALIZER
11507 (struct cmd_macsec_offload_on_result,
11508 offload, "offload");
11509 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11510 TOKEN_NUM_INITIALIZER
11511 (struct cmd_macsec_offload_on_result,
11512 port_id, RTE_UINT16);
11513 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11514 TOKEN_STRING_INITIALIZER
11515 (struct cmd_macsec_offload_on_result,
11517 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11518 TOKEN_STRING_INITIALIZER
11519 (struct cmd_macsec_offload_on_result,
11520 encrypt, "encrypt");
11521 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11522 TOKEN_STRING_INITIALIZER
11523 (struct cmd_macsec_offload_on_result,
11524 en_on_off, "on#off");
11525 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11526 TOKEN_STRING_INITIALIZER
11527 (struct cmd_macsec_offload_on_result,
11528 replay_protect, "replay-protect");
11529 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11530 TOKEN_STRING_INITIALIZER
11531 (struct cmd_macsec_offload_on_result,
11532 rp_on_off, "on#off");
11535 cmd_set_macsec_offload_on_parsed(
11536 void *parsed_result,
11537 __rte_unused struct cmdline *cl,
11538 __rte_unused void *data)
11540 struct cmd_macsec_offload_on_result *res = parsed_result;
11541 int ret = -ENOTSUP;
11542 portid_t port_id = res->port_id;
11543 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11544 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11545 struct rte_eth_dev_info dev_info;
11547 if (port_id_is_invalid(port_id, ENABLED_WARN))
11549 if (!port_is_stopped(port_id)) {
11550 printf("Please stop port %d first\n", port_id);
11554 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11558 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11559 #ifdef RTE_NET_IXGBE
11560 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11568 ports[port_id].dev_conf.txmode.offloads |=
11569 DEV_TX_OFFLOAD_MACSEC_INSERT;
11570 cmd_reconfig_device_queue(port_id, 1, 1);
11573 printf("invalid port_id %d\n", port_id);
11576 printf("not supported on port %d\n", port_id);
11579 printf("programming error: (%s)\n", strerror(-ret));
11583 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11584 .f = cmd_set_macsec_offload_on_parsed,
11586 .help_str = "set macsec offload <port_id> on "
11587 "encrypt on|off replay-protect on|off",
11589 (void *)&cmd_macsec_offload_on_set,
11590 (void *)&cmd_macsec_offload_on_macsec,
11591 (void *)&cmd_macsec_offload_on_offload,
11592 (void *)&cmd_macsec_offload_on_port_id,
11593 (void *)&cmd_macsec_offload_on_on,
11594 (void *)&cmd_macsec_offload_on_encrypt,
11595 (void *)&cmd_macsec_offload_on_en_on_off,
11596 (void *)&cmd_macsec_offload_on_replay_protect,
11597 (void *)&cmd_macsec_offload_on_rp_on_off,
11602 /* Common result structure for MACsec offload disable */
11603 struct cmd_macsec_offload_off_result {
11604 cmdline_fixed_string_t set;
11605 cmdline_fixed_string_t macsec;
11606 cmdline_fixed_string_t offload;
11608 cmdline_fixed_string_t off;
11611 /* Common CLI fields for MACsec offload disable */
11612 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11613 TOKEN_STRING_INITIALIZER
11614 (struct cmd_macsec_offload_off_result,
11616 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11617 TOKEN_STRING_INITIALIZER
11618 (struct cmd_macsec_offload_off_result,
11620 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11621 TOKEN_STRING_INITIALIZER
11622 (struct cmd_macsec_offload_off_result,
11623 offload, "offload");
11624 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11625 TOKEN_NUM_INITIALIZER
11626 (struct cmd_macsec_offload_off_result,
11627 port_id, RTE_UINT16);
11628 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11629 TOKEN_STRING_INITIALIZER
11630 (struct cmd_macsec_offload_off_result,
11634 cmd_set_macsec_offload_off_parsed(
11635 void *parsed_result,
11636 __rte_unused struct cmdline *cl,
11637 __rte_unused void *data)
11639 struct cmd_macsec_offload_off_result *res = parsed_result;
11640 int ret = -ENOTSUP;
11641 struct rte_eth_dev_info dev_info;
11642 portid_t port_id = res->port_id;
11644 if (port_id_is_invalid(port_id, ENABLED_WARN))
11646 if (!port_is_stopped(port_id)) {
11647 printf("Please stop port %d first\n", port_id);
11651 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11655 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11656 #ifdef RTE_NET_IXGBE
11657 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11662 ports[port_id].dev_conf.txmode.offloads &=
11663 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
11664 cmd_reconfig_device_queue(port_id, 1, 1);
11667 printf("invalid port_id %d\n", port_id);
11670 printf("not supported on port %d\n", port_id);
11673 printf("programming error: (%s)\n", strerror(-ret));
11677 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11678 .f = cmd_set_macsec_offload_off_parsed,
11680 .help_str = "set macsec offload <port_id> off",
11682 (void *)&cmd_macsec_offload_off_set,
11683 (void *)&cmd_macsec_offload_off_macsec,
11684 (void *)&cmd_macsec_offload_off_offload,
11685 (void *)&cmd_macsec_offload_off_port_id,
11686 (void *)&cmd_macsec_offload_off_off,
11691 /* Common result structure for MACsec secure connection configure */
11692 struct cmd_macsec_sc_result {
11693 cmdline_fixed_string_t set;
11694 cmdline_fixed_string_t macsec;
11695 cmdline_fixed_string_t sc;
11696 cmdline_fixed_string_t tx_rx;
11698 struct rte_ether_addr mac;
11702 /* Common CLI fields for MACsec secure connection configure */
11703 cmdline_parse_token_string_t cmd_macsec_sc_set =
11704 TOKEN_STRING_INITIALIZER
11705 (struct cmd_macsec_sc_result,
11707 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11708 TOKEN_STRING_INITIALIZER
11709 (struct cmd_macsec_sc_result,
11711 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11712 TOKEN_STRING_INITIALIZER
11713 (struct cmd_macsec_sc_result,
11715 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11716 TOKEN_STRING_INITIALIZER
11717 (struct cmd_macsec_sc_result,
11719 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11720 TOKEN_NUM_INITIALIZER
11721 (struct cmd_macsec_sc_result,
11722 port_id, RTE_UINT16);
11723 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11724 TOKEN_ETHERADDR_INITIALIZER
11725 (struct cmd_macsec_sc_result,
11727 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11728 TOKEN_NUM_INITIALIZER
11729 (struct cmd_macsec_sc_result,
11733 cmd_set_macsec_sc_parsed(
11734 void *parsed_result,
11735 __rte_unused struct cmdline *cl,
11736 __rte_unused void *data)
11738 struct cmd_macsec_sc_result *res = parsed_result;
11739 int ret = -ENOTSUP;
11740 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11742 #ifdef RTE_NET_IXGBE
11744 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11745 res->mac.addr_bytes) :
11746 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11747 res->mac.addr_bytes, res->pi);
11749 RTE_SET_USED(is_tx);
11755 printf("invalid port_id %d\n", res->port_id);
11758 printf("not supported on port %d\n", res->port_id);
11761 printf("programming error: (%s)\n", strerror(-ret));
11765 cmdline_parse_inst_t cmd_set_macsec_sc = {
11766 .f = cmd_set_macsec_sc_parsed,
11768 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11770 (void *)&cmd_macsec_sc_set,
11771 (void *)&cmd_macsec_sc_macsec,
11772 (void *)&cmd_macsec_sc_sc,
11773 (void *)&cmd_macsec_sc_tx_rx,
11774 (void *)&cmd_macsec_sc_port_id,
11775 (void *)&cmd_macsec_sc_mac,
11776 (void *)&cmd_macsec_sc_pi,
11781 /* Common result structure for MACsec secure connection configure */
11782 struct cmd_macsec_sa_result {
11783 cmdline_fixed_string_t set;
11784 cmdline_fixed_string_t macsec;
11785 cmdline_fixed_string_t sa;
11786 cmdline_fixed_string_t tx_rx;
11791 cmdline_fixed_string_t key;
11794 /* Common CLI fields for MACsec secure connection configure */
11795 cmdline_parse_token_string_t cmd_macsec_sa_set =
11796 TOKEN_STRING_INITIALIZER
11797 (struct cmd_macsec_sa_result,
11799 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11800 TOKEN_STRING_INITIALIZER
11801 (struct cmd_macsec_sa_result,
11803 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11804 TOKEN_STRING_INITIALIZER
11805 (struct cmd_macsec_sa_result,
11807 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11808 TOKEN_STRING_INITIALIZER
11809 (struct cmd_macsec_sa_result,
11811 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11812 TOKEN_NUM_INITIALIZER
11813 (struct cmd_macsec_sa_result,
11814 port_id, RTE_UINT16);
11815 cmdline_parse_token_num_t cmd_macsec_sa_idx =
11816 TOKEN_NUM_INITIALIZER
11817 (struct cmd_macsec_sa_result,
11819 cmdline_parse_token_num_t cmd_macsec_sa_an =
11820 TOKEN_NUM_INITIALIZER
11821 (struct cmd_macsec_sa_result,
11823 cmdline_parse_token_num_t cmd_macsec_sa_pn =
11824 TOKEN_NUM_INITIALIZER
11825 (struct cmd_macsec_sa_result,
11827 cmdline_parse_token_string_t cmd_macsec_sa_key =
11828 TOKEN_STRING_INITIALIZER
11829 (struct cmd_macsec_sa_result,
11833 cmd_set_macsec_sa_parsed(
11834 void *parsed_result,
11835 __rte_unused struct cmdline *cl,
11836 __rte_unused void *data)
11838 struct cmd_macsec_sa_result *res = parsed_result;
11839 int ret = -ENOTSUP;
11840 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11841 uint8_t key[16] = { 0 };
11847 key_len = strlen(res->key) / 2;
11851 for (i = 0; i < key_len; i++) {
11852 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
11855 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
11858 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
11861 #ifdef RTE_NET_IXGBE
11863 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
11864 res->idx, res->an, res->pn, key) :
11865 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
11866 res->idx, res->an, res->pn, key);
11868 RTE_SET_USED(is_tx);
11875 printf("invalid idx %d or an %d\n", res->idx, res->an);
11878 printf("invalid port_id %d\n", res->port_id);
11881 printf("not supported on port %d\n", res->port_id);
11884 printf("programming error: (%s)\n", strerror(-ret));
11888 cmdline_parse_inst_t cmd_set_macsec_sa = {
11889 .f = cmd_set_macsec_sa_parsed,
11891 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
11893 (void *)&cmd_macsec_sa_set,
11894 (void *)&cmd_macsec_sa_macsec,
11895 (void *)&cmd_macsec_sa_sa,
11896 (void *)&cmd_macsec_sa_tx_rx,
11897 (void *)&cmd_macsec_sa_port_id,
11898 (void *)&cmd_macsec_sa_idx,
11899 (void *)&cmd_macsec_sa_an,
11900 (void *)&cmd_macsec_sa_pn,
11901 (void *)&cmd_macsec_sa_key,
11906 /* VF unicast promiscuous mode configuration */
11908 /* Common result structure for VF unicast promiscuous mode */
11909 struct cmd_vf_promisc_result {
11910 cmdline_fixed_string_t set;
11911 cmdline_fixed_string_t vf;
11912 cmdline_fixed_string_t promisc;
11915 cmdline_fixed_string_t on_off;
11918 /* Common CLI fields for VF unicast promiscuous mode enable disable */
11919 cmdline_parse_token_string_t cmd_vf_promisc_set =
11920 TOKEN_STRING_INITIALIZER
11921 (struct cmd_vf_promisc_result,
11923 cmdline_parse_token_string_t cmd_vf_promisc_vf =
11924 TOKEN_STRING_INITIALIZER
11925 (struct cmd_vf_promisc_result,
11927 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
11928 TOKEN_STRING_INITIALIZER
11929 (struct cmd_vf_promisc_result,
11930 promisc, "promisc");
11931 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
11932 TOKEN_NUM_INITIALIZER
11933 (struct cmd_vf_promisc_result,
11934 port_id, RTE_UINT16);
11935 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
11936 TOKEN_NUM_INITIALIZER
11937 (struct cmd_vf_promisc_result,
11938 vf_id, RTE_UINT32);
11939 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
11940 TOKEN_STRING_INITIALIZER
11941 (struct cmd_vf_promisc_result,
11945 cmd_set_vf_promisc_parsed(
11946 void *parsed_result,
11947 __rte_unused struct cmdline *cl,
11948 __rte_unused void *data)
11950 struct cmd_vf_promisc_result *res = parsed_result;
11951 int ret = -ENOTSUP;
11953 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11955 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11958 #ifdef RTE_NET_I40E
11959 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
11960 res->vf_id, is_on);
11967 printf("invalid vf_id %d\n", res->vf_id);
11970 printf("invalid port_id %d\n", res->port_id);
11973 printf("function not implemented\n");
11976 printf("programming error: (%s)\n", strerror(-ret));
11980 cmdline_parse_inst_t cmd_set_vf_promisc = {
11981 .f = cmd_set_vf_promisc_parsed,
11983 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
11984 "Set unicast promiscuous mode for a VF from the PF",
11986 (void *)&cmd_vf_promisc_set,
11987 (void *)&cmd_vf_promisc_vf,
11988 (void *)&cmd_vf_promisc_promisc,
11989 (void *)&cmd_vf_promisc_port_id,
11990 (void *)&cmd_vf_promisc_vf_id,
11991 (void *)&cmd_vf_promisc_on_off,
11996 /* VF multicast promiscuous mode configuration */
11998 /* Common result structure for VF multicast promiscuous mode */
11999 struct cmd_vf_allmulti_result {
12000 cmdline_fixed_string_t set;
12001 cmdline_fixed_string_t vf;
12002 cmdline_fixed_string_t allmulti;
12005 cmdline_fixed_string_t on_off;
12008 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12009 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12010 TOKEN_STRING_INITIALIZER
12011 (struct cmd_vf_allmulti_result,
12013 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12014 TOKEN_STRING_INITIALIZER
12015 (struct cmd_vf_allmulti_result,
12017 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12018 TOKEN_STRING_INITIALIZER
12019 (struct cmd_vf_allmulti_result,
12020 allmulti, "allmulti");
12021 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12022 TOKEN_NUM_INITIALIZER
12023 (struct cmd_vf_allmulti_result,
12024 port_id, RTE_UINT16);
12025 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12026 TOKEN_NUM_INITIALIZER
12027 (struct cmd_vf_allmulti_result,
12028 vf_id, RTE_UINT32);
12029 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12030 TOKEN_STRING_INITIALIZER
12031 (struct cmd_vf_allmulti_result,
12035 cmd_set_vf_allmulti_parsed(
12036 void *parsed_result,
12037 __rte_unused struct cmdline *cl,
12038 __rte_unused void *data)
12040 struct cmd_vf_allmulti_result *res = parsed_result;
12041 int ret = -ENOTSUP;
12043 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12045 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12048 #ifdef RTE_NET_I40E
12049 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12050 res->vf_id, is_on);
12057 printf("invalid vf_id %d\n", res->vf_id);
12060 printf("invalid port_id %d\n", res->port_id);
12063 printf("function not implemented\n");
12066 printf("programming error: (%s)\n", strerror(-ret));
12070 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12071 .f = cmd_set_vf_allmulti_parsed,
12073 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12074 "Set multicast promiscuous mode for a VF from the PF",
12076 (void *)&cmd_vf_allmulti_set,
12077 (void *)&cmd_vf_allmulti_vf,
12078 (void *)&cmd_vf_allmulti_allmulti,
12079 (void *)&cmd_vf_allmulti_port_id,
12080 (void *)&cmd_vf_allmulti_vf_id,
12081 (void *)&cmd_vf_allmulti_on_off,
12086 /* vf broadcast mode configuration */
12088 /* Common result structure for vf broadcast */
12089 struct cmd_set_vf_broadcast_result {
12090 cmdline_fixed_string_t set;
12091 cmdline_fixed_string_t vf;
12092 cmdline_fixed_string_t broadcast;
12095 cmdline_fixed_string_t on_off;
12098 /* Common CLI fields for vf broadcast enable disable */
12099 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12100 TOKEN_STRING_INITIALIZER
12101 (struct cmd_set_vf_broadcast_result,
12103 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12104 TOKEN_STRING_INITIALIZER
12105 (struct cmd_set_vf_broadcast_result,
12107 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12108 TOKEN_STRING_INITIALIZER
12109 (struct cmd_set_vf_broadcast_result,
12110 broadcast, "broadcast");
12111 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12112 TOKEN_NUM_INITIALIZER
12113 (struct cmd_set_vf_broadcast_result,
12114 port_id, RTE_UINT16);
12115 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12116 TOKEN_NUM_INITIALIZER
12117 (struct cmd_set_vf_broadcast_result,
12118 vf_id, RTE_UINT16);
12119 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12120 TOKEN_STRING_INITIALIZER
12121 (struct cmd_set_vf_broadcast_result,
12125 cmd_set_vf_broadcast_parsed(
12126 void *parsed_result,
12127 __rte_unused struct cmdline *cl,
12128 __rte_unused void *data)
12130 struct cmd_set_vf_broadcast_result *res = parsed_result;
12131 int ret = -ENOTSUP;
12133 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12135 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12138 #ifdef RTE_NET_I40E
12139 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12140 res->vf_id, is_on);
12147 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12150 printf("invalid port_id %d\n", res->port_id);
12153 printf("function not implemented\n");
12156 printf("programming error: (%s)\n", strerror(-ret));
12160 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12161 .f = cmd_set_vf_broadcast_parsed,
12163 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12165 (void *)&cmd_set_vf_broadcast_set,
12166 (void *)&cmd_set_vf_broadcast_vf,
12167 (void *)&cmd_set_vf_broadcast_broadcast,
12168 (void *)&cmd_set_vf_broadcast_port_id,
12169 (void *)&cmd_set_vf_broadcast_vf_id,
12170 (void *)&cmd_set_vf_broadcast_on_off,
12175 /* vf vlan tag configuration */
12177 /* Common result structure for vf vlan tag */
12178 struct cmd_set_vf_vlan_tag_result {
12179 cmdline_fixed_string_t set;
12180 cmdline_fixed_string_t vf;
12181 cmdline_fixed_string_t vlan;
12182 cmdline_fixed_string_t tag;
12185 cmdline_fixed_string_t on_off;
12188 /* Common CLI fields for vf vlan tag enable disable */
12189 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12190 TOKEN_STRING_INITIALIZER
12191 (struct cmd_set_vf_vlan_tag_result,
12193 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12194 TOKEN_STRING_INITIALIZER
12195 (struct cmd_set_vf_vlan_tag_result,
12197 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12198 TOKEN_STRING_INITIALIZER
12199 (struct cmd_set_vf_vlan_tag_result,
12201 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12202 TOKEN_STRING_INITIALIZER
12203 (struct cmd_set_vf_vlan_tag_result,
12205 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12206 TOKEN_NUM_INITIALIZER
12207 (struct cmd_set_vf_vlan_tag_result,
12208 port_id, RTE_UINT16);
12209 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12210 TOKEN_NUM_INITIALIZER
12211 (struct cmd_set_vf_vlan_tag_result,
12212 vf_id, RTE_UINT16);
12213 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12214 TOKEN_STRING_INITIALIZER
12215 (struct cmd_set_vf_vlan_tag_result,
12219 cmd_set_vf_vlan_tag_parsed(
12220 void *parsed_result,
12221 __rte_unused struct cmdline *cl,
12222 __rte_unused void *data)
12224 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12225 int ret = -ENOTSUP;
12227 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12229 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12232 #ifdef RTE_NET_I40E
12233 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12234 res->vf_id, is_on);
12241 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12244 printf("invalid port_id %d\n", res->port_id);
12247 printf("function not implemented\n");
12250 printf("programming error: (%s)\n", strerror(-ret));
12254 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12255 .f = cmd_set_vf_vlan_tag_parsed,
12257 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12259 (void *)&cmd_set_vf_vlan_tag_set,
12260 (void *)&cmd_set_vf_vlan_tag_vf,
12261 (void *)&cmd_set_vf_vlan_tag_vlan,
12262 (void *)&cmd_set_vf_vlan_tag_tag,
12263 (void *)&cmd_set_vf_vlan_tag_port_id,
12264 (void *)&cmd_set_vf_vlan_tag_vf_id,
12265 (void *)&cmd_set_vf_vlan_tag_on_off,
12270 /* Common definition of VF and TC TX bandwidth configuration */
12271 struct cmd_vf_tc_bw_result {
12272 cmdline_fixed_string_t set;
12273 cmdline_fixed_string_t vf;
12274 cmdline_fixed_string_t tc;
12275 cmdline_fixed_string_t tx;
12276 cmdline_fixed_string_t min_bw;
12277 cmdline_fixed_string_t max_bw;
12278 cmdline_fixed_string_t strict_link_prio;
12283 cmdline_fixed_string_t bw_list;
12287 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12288 TOKEN_STRING_INITIALIZER
12289 (struct cmd_vf_tc_bw_result,
12291 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12292 TOKEN_STRING_INITIALIZER
12293 (struct cmd_vf_tc_bw_result,
12295 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12296 TOKEN_STRING_INITIALIZER
12297 (struct cmd_vf_tc_bw_result,
12299 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12300 TOKEN_STRING_INITIALIZER
12301 (struct cmd_vf_tc_bw_result,
12303 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12304 TOKEN_STRING_INITIALIZER
12305 (struct cmd_vf_tc_bw_result,
12306 strict_link_prio, "strict-link-priority");
12307 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12308 TOKEN_STRING_INITIALIZER
12309 (struct cmd_vf_tc_bw_result,
12310 min_bw, "min-bandwidth");
12311 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12312 TOKEN_STRING_INITIALIZER
12313 (struct cmd_vf_tc_bw_result,
12314 max_bw, "max-bandwidth");
12315 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12316 TOKEN_NUM_INITIALIZER
12317 (struct cmd_vf_tc_bw_result,
12318 port_id, RTE_UINT16);
12319 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12320 TOKEN_NUM_INITIALIZER
12321 (struct cmd_vf_tc_bw_result,
12322 vf_id, RTE_UINT16);
12323 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12324 TOKEN_NUM_INITIALIZER
12325 (struct cmd_vf_tc_bw_result,
12327 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12328 TOKEN_NUM_INITIALIZER
12329 (struct cmd_vf_tc_bw_result,
12331 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12332 TOKEN_STRING_INITIALIZER
12333 (struct cmd_vf_tc_bw_result,
12335 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12336 TOKEN_NUM_INITIALIZER
12337 (struct cmd_vf_tc_bw_result,
12338 tc_map, RTE_UINT8);
12340 /* VF max bandwidth setting */
12342 cmd_vf_max_bw_parsed(
12343 void *parsed_result,
12344 __rte_unused struct cmdline *cl,
12345 __rte_unused void *data)
12347 struct cmd_vf_tc_bw_result *res = parsed_result;
12348 int ret = -ENOTSUP;
12350 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12353 #ifdef RTE_NET_I40E
12354 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12355 res->vf_id, res->bw);
12362 printf("invalid vf_id %d or bandwidth %d\n",
12363 res->vf_id, res->bw);
12366 printf("invalid port_id %d\n", res->port_id);
12369 printf("function not implemented\n");
12372 printf("programming error: (%s)\n", strerror(-ret));
12376 cmdline_parse_inst_t cmd_vf_max_bw = {
12377 .f = cmd_vf_max_bw_parsed,
12379 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12381 (void *)&cmd_vf_tc_bw_set,
12382 (void *)&cmd_vf_tc_bw_vf,
12383 (void *)&cmd_vf_tc_bw_tx,
12384 (void *)&cmd_vf_tc_bw_max_bw,
12385 (void *)&cmd_vf_tc_bw_port_id,
12386 (void *)&cmd_vf_tc_bw_vf_id,
12387 (void *)&cmd_vf_tc_bw_bw,
12393 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12398 const char *p, *p0 = str;
12405 p = strchr(p0, '(');
12407 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12411 p0 = strchr(p, ')');
12413 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12417 if (size >= sizeof(s)) {
12418 printf("The string size exceeds the internal buffer size\n");
12421 snprintf(s, sizeof(s), "%.*s", size, p);
12422 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12424 printf("Failed to get the bandwidth list. ");
12428 for (i = 0; i < ret; i++)
12429 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12434 /* TC min bandwidth setting */
12436 cmd_vf_tc_min_bw_parsed(
12437 void *parsed_result,
12438 __rte_unused struct cmdline *cl,
12439 __rte_unused void *data)
12441 struct cmd_vf_tc_bw_result *res = parsed_result;
12444 int ret = -ENOTSUP;
12446 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12449 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12453 #ifdef RTE_NET_I40E
12454 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12462 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12465 printf("invalid port_id %d\n", res->port_id);
12468 printf("function not implemented\n");
12471 printf("programming error: (%s)\n", strerror(-ret));
12475 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12476 .f = cmd_vf_tc_min_bw_parsed,
12478 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12479 " <bw1, bw2, ...>",
12481 (void *)&cmd_vf_tc_bw_set,
12482 (void *)&cmd_vf_tc_bw_vf,
12483 (void *)&cmd_vf_tc_bw_tc,
12484 (void *)&cmd_vf_tc_bw_tx,
12485 (void *)&cmd_vf_tc_bw_min_bw,
12486 (void *)&cmd_vf_tc_bw_port_id,
12487 (void *)&cmd_vf_tc_bw_vf_id,
12488 (void *)&cmd_vf_tc_bw_bw_list,
12494 cmd_tc_min_bw_parsed(
12495 void *parsed_result,
12496 __rte_unused struct cmdline *cl,
12497 __rte_unused void *data)
12499 struct cmd_vf_tc_bw_result *res = parsed_result;
12500 struct rte_port *port;
12503 int ret = -ENOTSUP;
12505 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12508 port = &ports[res->port_id];
12509 /** Check if the port is not started **/
12510 if (port->port_status != RTE_PORT_STOPPED) {
12511 printf("Please stop port %d first\n", res->port_id);
12515 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12519 #ifdef RTE_NET_IXGBE
12520 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12527 printf("invalid bandwidth\n");
12530 printf("invalid port_id %d\n", res->port_id);
12533 printf("function not implemented\n");
12536 printf("programming error: (%s)\n", strerror(-ret));
12540 cmdline_parse_inst_t cmd_tc_min_bw = {
12541 .f = cmd_tc_min_bw_parsed,
12543 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12545 (void *)&cmd_vf_tc_bw_set,
12546 (void *)&cmd_vf_tc_bw_tc,
12547 (void *)&cmd_vf_tc_bw_tx,
12548 (void *)&cmd_vf_tc_bw_min_bw,
12549 (void *)&cmd_vf_tc_bw_port_id,
12550 (void *)&cmd_vf_tc_bw_bw_list,
12555 /* TC max bandwidth setting */
12557 cmd_vf_tc_max_bw_parsed(
12558 void *parsed_result,
12559 __rte_unused struct cmdline *cl,
12560 __rte_unused void *data)
12562 struct cmd_vf_tc_bw_result *res = parsed_result;
12563 int ret = -ENOTSUP;
12565 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12568 #ifdef RTE_NET_I40E
12569 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12570 res->tc_no, res->bw);
12577 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
12578 res->vf_id, res->tc_no, res->bw);
12581 printf("invalid port_id %d\n", res->port_id);
12584 printf("function not implemented\n");
12587 printf("programming error: (%s)\n", strerror(-ret));
12591 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12592 .f = cmd_vf_tc_max_bw_parsed,
12594 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12597 (void *)&cmd_vf_tc_bw_set,
12598 (void *)&cmd_vf_tc_bw_vf,
12599 (void *)&cmd_vf_tc_bw_tc,
12600 (void *)&cmd_vf_tc_bw_tx,
12601 (void *)&cmd_vf_tc_bw_max_bw,
12602 (void *)&cmd_vf_tc_bw_port_id,
12603 (void *)&cmd_vf_tc_bw_vf_id,
12604 (void *)&cmd_vf_tc_bw_tc_no,
12605 (void *)&cmd_vf_tc_bw_bw,
12610 /** Set VXLAN encapsulation details */
12611 struct cmd_set_vxlan_result {
12612 cmdline_fixed_string_t set;
12613 cmdline_fixed_string_t vxlan;
12614 cmdline_fixed_string_t pos_token;
12615 cmdline_fixed_string_t ip_version;
12616 uint32_t vlan_present:1;
12620 cmdline_ipaddr_t ip_src;
12621 cmdline_ipaddr_t ip_dst;
12625 struct rte_ether_addr eth_src;
12626 struct rte_ether_addr eth_dst;
12629 cmdline_parse_token_string_t cmd_set_vxlan_set =
12630 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
12631 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
12632 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
12633 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
12634 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12636 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
12637 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12638 "vxlan-with-vlan");
12639 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
12640 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12642 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
12643 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
12645 cmdline_parse_token_string_t cmd_set_vxlan_vni =
12646 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12648 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
12649 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
12650 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
12651 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12653 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
12654 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
12655 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
12656 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12658 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
12659 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
12660 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
12661 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12663 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
12664 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
12665 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
12666 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12668 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
12669 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
12670 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
12671 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12673 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
12674 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
12675 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
12676 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12678 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
12679 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
12680 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
12681 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12683 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
12684 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
12685 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
12686 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12688 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
12689 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
12690 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
12691 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12693 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
12694 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
12696 static void cmd_set_vxlan_parsed(void *parsed_result,
12697 __rte_unused struct cmdline *cl,
12698 __rte_unused void *data)
12700 struct cmd_set_vxlan_result *res = parsed_result;
12705 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
12708 vxlan_encap_conf.select_tos_ttl = 0;
12709 if (strcmp(res->vxlan, "vxlan") == 0)
12710 vxlan_encap_conf.select_vlan = 0;
12711 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
12712 vxlan_encap_conf.select_vlan = 1;
12713 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
12714 vxlan_encap_conf.select_vlan = 0;
12715 vxlan_encap_conf.select_tos_ttl = 1;
12717 if (strcmp(res->ip_version, "ipv4") == 0)
12718 vxlan_encap_conf.select_ipv4 = 1;
12719 else if (strcmp(res->ip_version, "ipv6") == 0)
12720 vxlan_encap_conf.select_ipv4 = 0;
12723 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
12724 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
12725 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
12726 vxlan_encap_conf.ip_tos = res->tos;
12727 vxlan_encap_conf.ip_ttl = res->ttl;
12728 if (vxlan_encap_conf.select_ipv4) {
12729 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
12730 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
12732 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
12733 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
12735 if (vxlan_encap_conf.select_vlan)
12736 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
12737 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
12738 RTE_ETHER_ADDR_LEN);
12739 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
12740 RTE_ETHER_ADDR_LEN);
12743 cmdline_parse_inst_t cmd_set_vxlan = {
12744 .f = cmd_set_vxlan_parsed,
12746 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
12747 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
12748 " eth-src <eth-src> eth-dst <eth-dst>",
12750 (void *)&cmd_set_vxlan_set,
12751 (void *)&cmd_set_vxlan_vxlan,
12752 (void *)&cmd_set_vxlan_ip_version,
12753 (void *)&cmd_set_vxlan_ip_version_value,
12754 (void *)&cmd_set_vxlan_vni,
12755 (void *)&cmd_set_vxlan_vni_value,
12756 (void *)&cmd_set_vxlan_udp_src,
12757 (void *)&cmd_set_vxlan_udp_src_value,
12758 (void *)&cmd_set_vxlan_udp_dst,
12759 (void *)&cmd_set_vxlan_udp_dst_value,
12760 (void *)&cmd_set_vxlan_ip_src,
12761 (void *)&cmd_set_vxlan_ip_src_value,
12762 (void *)&cmd_set_vxlan_ip_dst,
12763 (void *)&cmd_set_vxlan_ip_dst_value,
12764 (void *)&cmd_set_vxlan_eth_src,
12765 (void *)&cmd_set_vxlan_eth_src_value,
12766 (void *)&cmd_set_vxlan_eth_dst,
12767 (void *)&cmd_set_vxlan_eth_dst_value,
12772 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
12773 .f = cmd_set_vxlan_parsed,
12775 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
12776 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
12777 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
12778 " eth-dst <eth-dst>",
12780 (void *)&cmd_set_vxlan_set,
12781 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
12782 (void *)&cmd_set_vxlan_ip_version,
12783 (void *)&cmd_set_vxlan_ip_version_value,
12784 (void *)&cmd_set_vxlan_vni,
12785 (void *)&cmd_set_vxlan_vni_value,
12786 (void *)&cmd_set_vxlan_udp_src,
12787 (void *)&cmd_set_vxlan_udp_src_value,
12788 (void *)&cmd_set_vxlan_udp_dst,
12789 (void *)&cmd_set_vxlan_udp_dst_value,
12790 (void *)&cmd_set_vxlan_ip_tos,
12791 (void *)&cmd_set_vxlan_ip_tos_value,
12792 (void *)&cmd_set_vxlan_ip_ttl,
12793 (void *)&cmd_set_vxlan_ip_ttl_value,
12794 (void *)&cmd_set_vxlan_ip_src,
12795 (void *)&cmd_set_vxlan_ip_src_value,
12796 (void *)&cmd_set_vxlan_ip_dst,
12797 (void *)&cmd_set_vxlan_ip_dst_value,
12798 (void *)&cmd_set_vxlan_eth_src,
12799 (void *)&cmd_set_vxlan_eth_src_value,
12800 (void *)&cmd_set_vxlan_eth_dst,
12801 (void *)&cmd_set_vxlan_eth_dst_value,
12806 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
12807 .f = cmd_set_vxlan_parsed,
12809 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
12810 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
12811 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
12814 (void *)&cmd_set_vxlan_set,
12815 (void *)&cmd_set_vxlan_vxlan_with_vlan,
12816 (void *)&cmd_set_vxlan_ip_version,
12817 (void *)&cmd_set_vxlan_ip_version_value,
12818 (void *)&cmd_set_vxlan_vni,
12819 (void *)&cmd_set_vxlan_vni_value,
12820 (void *)&cmd_set_vxlan_udp_src,
12821 (void *)&cmd_set_vxlan_udp_src_value,
12822 (void *)&cmd_set_vxlan_udp_dst,
12823 (void *)&cmd_set_vxlan_udp_dst_value,
12824 (void *)&cmd_set_vxlan_ip_src,
12825 (void *)&cmd_set_vxlan_ip_src_value,
12826 (void *)&cmd_set_vxlan_ip_dst,
12827 (void *)&cmd_set_vxlan_ip_dst_value,
12828 (void *)&cmd_set_vxlan_vlan,
12829 (void *)&cmd_set_vxlan_vlan_value,
12830 (void *)&cmd_set_vxlan_eth_src,
12831 (void *)&cmd_set_vxlan_eth_src_value,
12832 (void *)&cmd_set_vxlan_eth_dst,
12833 (void *)&cmd_set_vxlan_eth_dst_value,
12838 /** Set NVGRE encapsulation details */
12839 struct cmd_set_nvgre_result {
12840 cmdline_fixed_string_t set;
12841 cmdline_fixed_string_t nvgre;
12842 cmdline_fixed_string_t pos_token;
12843 cmdline_fixed_string_t ip_version;
12845 cmdline_ipaddr_t ip_src;
12846 cmdline_ipaddr_t ip_dst;
12848 struct rte_ether_addr eth_src;
12849 struct rte_ether_addr eth_dst;
12852 cmdline_parse_token_string_t cmd_set_nvgre_set =
12853 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
12854 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
12855 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
12856 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
12857 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
12858 "nvgre-with-vlan");
12859 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
12860 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12862 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
12863 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
12865 cmdline_parse_token_string_t cmd_set_nvgre_tni =
12866 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12868 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
12869 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
12870 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
12871 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12873 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
12874 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
12875 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
12876 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12878 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
12879 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
12880 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
12881 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12883 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
12884 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
12885 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
12886 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12888 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
12889 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
12890 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
12891 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12893 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
12894 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
12896 static void cmd_set_nvgre_parsed(void *parsed_result,
12897 __rte_unused struct cmdline *cl,
12898 __rte_unused void *data)
12900 struct cmd_set_nvgre_result *res = parsed_result;
12902 uint32_t nvgre_tni;
12905 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
12908 if (strcmp(res->nvgre, "nvgre") == 0)
12909 nvgre_encap_conf.select_vlan = 0;
12910 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
12911 nvgre_encap_conf.select_vlan = 1;
12912 if (strcmp(res->ip_version, "ipv4") == 0)
12913 nvgre_encap_conf.select_ipv4 = 1;
12914 else if (strcmp(res->ip_version, "ipv6") == 0)
12915 nvgre_encap_conf.select_ipv4 = 0;
12918 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
12919 if (nvgre_encap_conf.select_ipv4) {
12920 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
12921 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
12923 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
12924 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
12926 if (nvgre_encap_conf.select_vlan)
12927 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
12928 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
12929 RTE_ETHER_ADDR_LEN);
12930 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
12931 RTE_ETHER_ADDR_LEN);
12934 cmdline_parse_inst_t cmd_set_nvgre = {
12935 .f = cmd_set_nvgre_parsed,
12937 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
12938 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
12939 " eth-dst <eth-dst>",
12941 (void *)&cmd_set_nvgre_set,
12942 (void *)&cmd_set_nvgre_nvgre,
12943 (void *)&cmd_set_nvgre_ip_version,
12944 (void *)&cmd_set_nvgre_ip_version_value,
12945 (void *)&cmd_set_nvgre_tni,
12946 (void *)&cmd_set_nvgre_tni_value,
12947 (void *)&cmd_set_nvgre_ip_src,
12948 (void *)&cmd_set_nvgre_ip_src_value,
12949 (void *)&cmd_set_nvgre_ip_dst,
12950 (void *)&cmd_set_nvgre_ip_dst_value,
12951 (void *)&cmd_set_nvgre_eth_src,
12952 (void *)&cmd_set_nvgre_eth_src_value,
12953 (void *)&cmd_set_nvgre_eth_dst,
12954 (void *)&cmd_set_nvgre_eth_dst_value,
12959 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
12960 .f = cmd_set_nvgre_parsed,
12962 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
12963 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
12964 " eth-src <eth-src> eth-dst <eth-dst>",
12966 (void *)&cmd_set_nvgre_set,
12967 (void *)&cmd_set_nvgre_nvgre_with_vlan,
12968 (void *)&cmd_set_nvgre_ip_version,
12969 (void *)&cmd_set_nvgre_ip_version_value,
12970 (void *)&cmd_set_nvgre_tni,
12971 (void *)&cmd_set_nvgre_tni_value,
12972 (void *)&cmd_set_nvgre_ip_src,
12973 (void *)&cmd_set_nvgre_ip_src_value,
12974 (void *)&cmd_set_nvgre_ip_dst,
12975 (void *)&cmd_set_nvgre_ip_dst_value,
12976 (void *)&cmd_set_nvgre_vlan,
12977 (void *)&cmd_set_nvgre_vlan_value,
12978 (void *)&cmd_set_nvgre_eth_src,
12979 (void *)&cmd_set_nvgre_eth_src_value,
12980 (void *)&cmd_set_nvgre_eth_dst,
12981 (void *)&cmd_set_nvgre_eth_dst_value,
12986 /** Set L2 encapsulation details */
12987 struct cmd_set_l2_encap_result {
12988 cmdline_fixed_string_t set;
12989 cmdline_fixed_string_t l2_encap;
12990 cmdline_fixed_string_t pos_token;
12991 cmdline_fixed_string_t ip_version;
12992 uint32_t vlan_present:1;
12994 struct rte_ether_addr eth_src;
12995 struct rte_ether_addr eth_dst;
12998 cmdline_parse_token_string_t cmd_set_l2_encap_set =
12999 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13000 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13001 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13002 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13003 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13004 "l2_encap-with-vlan");
13005 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13006 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13008 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13009 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13011 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13012 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13014 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13015 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13016 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13017 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13019 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13020 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13021 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13022 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13024 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13025 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13027 static void cmd_set_l2_encap_parsed(void *parsed_result,
13028 __rte_unused struct cmdline *cl,
13029 __rte_unused void *data)
13031 struct cmd_set_l2_encap_result *res = parsed_result;
13033 if (strcmp(res->l2_encap, "l2_encap") == 0)
13034 l2_encap_conf.select_vlan = 0;
13035 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13036 l2_encap_conf.select_vlan = 1;
13037 if (strcmp(res->ip_version, "ipv4") == 0)
13038 l2_encap_conf.select_ipv4 = 1;
13039 else if (strcmp(res->ip_version, "ipv6") == 0)
13040 l2_encap_conf.select_ipv4 = 0;
13043 if (l2_encap_conf.select_vlan)
13044 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13045 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13046 RTE_ETHER_ADDR_LEN);
13047 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13048 RTE_ETHER_ADDR_LEN);
13051 cmdline_parse_inst_t cmd_set_l2_encap = {
13052 .f = cmd_set_l2_encap_parsed,
13054 .help_str = "set l2_encap ip-version ipv4|ipv6"
13055 " eth-src <eth-src> eth-dst <eth-dst>",
13057 (void *)&cmd_set_l2_encap_set,
13058 (void *)&cmd_set_l2_encap_l2_encap,
13059 (void *)&cmd_set_l2_encap_ip_version,
13060 (void *)&cmd_set_l2_encap_ip_version_value,
13061 (void *)&cmd_set_l2_encap_eth_src,
13062 (void *)&cmd_set_l2_encap_eth_src_value,
13063 (void *)&cmd_set_l2_encap_eth_dst,
13064 (void *)&cmd_set_l2_encap_eth_dst_value,
13069 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13070 .f = cmd_set_l2_encap_parsed,
13072 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13073 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13075 (void *)&cmd_set_l2_encap_set,
13076 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13077 (void *)&cmd_set_l2_encap_ip_version,
13078 (void *)&cmd_set_l2_encap_ip_version_value,
13079 (void *)&cmd_set_l2_encap_vlan,
13080 (void *)&cmd_set_l2_encap_vlan_value,
13081 (void *)&cmd_set_l2_encap_eth_src,
13082 (void *)&cmd_set_l2_encap_eth_src_value,
13083 (void *)&cmd_set_l2_encap_eth_dst,
13084 (void *)&cmd_set_l2_encap_eth_dst_value,
13089 /** Set L2 decapsulation details */
13090 struct cmd_set_l2_decap_result {
13091 cmdline_fixed_string_t set;
13092 cmdline_fixed_string_t l2_decap;
13093 cmdline_fixed_string_t pos_token;
13094 uint32_t vlan_present:1;
13097 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13098 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13099 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13100 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13102 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13103 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13104 "l2_decap-with-vlan");
13106 static void cmd_set_l2_decap_parsed(void *parsed_result,
13107 __rte_unused struct cmdline *cl,
13108 __rte_unused void *data)
13110 struct cmd_set_l2_decap_result *res = parsed_result;
13112 if (strcmp(res->l2_decap, "l2_decap") == 0)
13113 l2_decap_conf.select_vlan = 0;
13114 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13115 l2_decap_conf.select_vlan = 1;
13118 cmdline_parse_inst_t cmd_set_l2_decap = {
13119 .f = cmd_set_l2_decap_parsed,
13121 .help_str = "set l2_decap",
13123 (void *)&cmd_set_l2_decap_set,
13124 (void *)&cmd_set_l2_decap_l2_decap,
13129 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13130 .f = cmd_set_l2_decap_parsed,
13132 .help_str = "set l2_decap-with-vlan",
13134 (void *)&cmd_set_l2_decap_set,
13135 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13140 /** Set MPLSoGRE encapsulation details */
13141 struct cmd_set_mplsogre_encap_result {
13142 cmdline_fixed_string_t set;
13143 cmdline_fixed_string_t mplsogre;
13144 cmdline_fixed_string_t pos_token;
13145 cmdline_fixed_string_t ip_version;
13146 uint32_t vlan_present:1;
13148 cmdline_ipaddr_t ip_src;
13149 cmdline_ipaddr_t ip_dst;
13151 struct rte_ether_addr eth_src;
13152 struct rte_ether_addr eth_dst;
13155 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13156 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13158 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13159 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13161 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13162 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13163 mplsogre, "mplsogre_encap-with-vlan");
13164 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13165 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13166 pos_token, "ip-version");
13167 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13168 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13169 ip_version, "ipv4#ipv6");
13170 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13171 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13172 pos_token, "label");
13173 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13174 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13176 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13177 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13178 pos_token, "ip-src");
13179 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13180 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13181 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13182 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13183 pos_token, "ip-dst");
13184 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13185 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13186 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13187 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13188 pos_token, "vlan-tci");
13189 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13190 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13192 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13193 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13194 pos_token, "eth-src");
13195 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13196 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13198 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13199 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13200 pos_token, "eth-dst");
13201 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13202 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13205 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13206 __rte_unused struct cmdline *cl,
13207 __rte_unused void *data)
13209 struct cmd_set_mplsogre_encap_result *res = parsed_result;
13211 uint32_t mplsogre_label;
13214 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13217 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13218 mplsogre_encap_conf.select_vlan = 0;
13219 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13220 mplsogre_encap_conf.select_vlan = 1;
13221 if (strcmp(res->ip_version, "ipv4") == 0)
13222 mplsogre_encap_conf.select_ipv4 = 1;
13223 else if (strcmp(res->ip_version, "ipv6") == 0)
13224 mplsogre_encap_conf.select_ipv4 = 0;
13227 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13228 if (mplsogre_encap_conf.select_ipv4) {
13229 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13230 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13232 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13233 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13235 if (mplsogre_encap_conf.select_vlan)
13236 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13237 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13238 RTE_ETHER_ADDR_LEN);
13239 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13240 RTE_ETHER_ADDR_LEN);
13243 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13244 .f = cmd_set_mplsogre_encap_parsed,
13246 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13247 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13248 " eth-dst <eth-dst>",
13250 (void *)&cmd_set_mplsogre_encap_set,
13251 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13252 (void *)&cmd_set_mplsogre_encap_ip_version,
13253 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13254 (void *)&cmd_set_mplsogre_encap_label,
13255 (void *)&cmd_set_mplsogre_encap_label_value,
13256 (void *)&cmd_set_mplsogre_encap_ip_src,
13257 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13258 (void *)&cmd_set_mplsogre_encap_ip_dst,
13259 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13260 (void *)&cmd_set_mplsogre_encap_eth_src,
13261 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13262 (void *)&cmd_set_mplsogre_encap_eth_dst,
13263 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13268 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13269 .f = cmd_set_mplsogre_encap_parsed,
13271 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13272 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
13273 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13275 (void *)&cmd_set_mplsogre_encap_set,
13276 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13277 (void *)&cmd_set_mplsogre_encap_ip_version,
13278 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13279 (void *)&cmd_set_mplsogre_encap_label,
13280 (void *)&cmd_set_mplsogre_encap_label_value,
13281 (void *)&cmd_set_mplsogre_encap_ip_src,
13282 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13283 (void *)&cmd_set_mplsogre_encap_ip_dst,
13284 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13285 (void *)&cmd_set_mplsogre_encap_vlan,
13286 (void *)&cmd_set_mplsogre_encap_vlan_value,
13287 (void *)&cmd_set_mplsogre_encap_eth_src,
13288 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13289 (void *)&cmd_set_mplsogre_encap_eth_dst,
13290 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13295 /** Set MPLSoGRE decapsulation details */
13296 struct cmd_set_mplsogre_decap_result {
13297 cmdline_fixed_string_t set;
13298 cmdline_fixed_string_t mplsogre;
13299 cmdline_fixed_string_t pos_token;
13300 cmdline_fixed_string_t ip_version;
13301 uint32_t vlan_present:1;
13304 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13305 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13307 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13308 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13310 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13311 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13312 mplsogre, "mplsogre_decap-with-vlan");
13313 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13314 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13315 pos_token, "ip-version");
13316 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13317 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13318 ip_version, "ipv4#ipv6");
13320 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13321 __rte_unused struct cmdline *cl,
13322 __rte_unused void *data)
13324 struct cmd_set_mplsogre_decap_result *res = parsed_result;
13326 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13327 mplsogre_decap_conf.select_vlan = 0;
13328 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13329 mplsogre_decap_conf.select_vlan = 1;
13330 if (strcmp(res->ip_version, "ipv4") == 0)
13331 mplsogre_decap_conf.select_ipv4 = 1;
13332 else if (strcmp(res->ip_version, "ipv6") == 0)
13333 mplsogre_decap_conf.select_ipv4 = 0;
13336 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13337 .f = cmd_set_mplsogre_decap_parsed,
13339 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13341 (void *)&cmd_set_mplsogre_decap_set,
13342 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13343 (void *)&cmd_set_mplsogre_decap_ip_version,
13344 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13349 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13350 .f = cmd_set_mplsogre_decap_parsed,
13352 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13354 (void *)&cmd_set_mplsogre_decap_set,
13355 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13356 (void *)&cmd_set_mplsogre_decap_ip_version,
13357 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13362 /** Set MPLSoUDP encapsulation details */
13363 struct cmd_set_mplsoudp_encap_result {
13364 cmdline_fixed_string_t set;
13365 cmdline_fixed_string_t mplsoudp;
13366 cmdline_fixed_string_t pos_token;
13367 cmdline_fixed_string_t ip_version;
13368 uint32_t vlan_present:1;
13372 cmdline_ipaddr_t ip_src;
13373 cmdline_ipaddr_t ip_dst;
13375 struct rte_ether_addr eth_src;
13376 struct rte_ether_addr eth_dst;
13379 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13380 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13382 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13383 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13385 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13386 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13387 mplsoudp, "mplsoudp_encap-with-vlan");
13388 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13389 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13390 pos_token, "ip-version");
13391 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13392 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13393 ip_version, "ipv4#ipv6");
13394 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13395 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13396 pos_token, "label");
13397 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13398 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13400 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13401 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13402 pos_token, "udp-src");
13403 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13404 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13406 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13407 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13408 pos_token, "udp-dst");
13409 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13410 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13412 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13413 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13414 pos_token, "ip-src");
13415 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13416 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13417 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13418 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13419 pos_token, "ip-dst");
13420 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13421 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13422 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13423 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13424 pos_token, "vlan-tci");
13425 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13426 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13428 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13429 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13430 pos_token, "eth-src");
13431 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13432 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13434 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13435 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13436 pos_token, "eth-dst");
13437 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13438 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13441 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13442 __rte_unused struct cmdline *cl,
13443 __rte_unused void *data)
13445 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13447 uint32_t mplsoudp_label;
13450 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13453 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13454 mplsoudp_encap_conf.select_vlan = 0;
13455 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13456 mplsoudp_encap_conf.select_vlan = 1;
13457 if (strcmp(res->ip_version, "ipv4") == 0)
13458 mplsoudp_encap_conf.select_ipv4 = 1;
13459 else if (strcmp(res->ip_version, "ipv6") == 0)
13460 mplsoudp_encap_conf.select_ipv4 = 0;
13463 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13464 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13465 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13466 if (mplsoudp_encap_conf.select_ipv4) {
13467 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13468 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13470 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13471 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13473 if (mplsoudp_encap_conf.select_vlan)
13474 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13475 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13476 RTE_ETHER_ADDR_LEN);
13477 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13478 RTE_ETHER_ADDR_LEN);
13481 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13482 .f = cmd_set_mplsoudp_encap_parsed,
13484 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13485 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13486 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13488 (void *)&cmd_set_mplsoudp_encap_set,
13489 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13490 (void *)&cmd_set_mplsoudp_encap_ip_version,
13491 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13492 (void *)&cmd_set_mplsoudp_encap_label,
13493 (void *)&cmd_set_mplsoudp_encap_label_value,
13494 (void *)&cmd_set_mplsoudp_encap_udp_src,
13495 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13496 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13497 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13498 (void *)&cmd_set_mplsoudp_encap_ip_src,
13499 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13500 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13501 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13502 (void *)&cmd_set_mplsoudp_encap_eth_src,
13503 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13504 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13505 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13510 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13511 .f = cmd_set_mplsoudp_encap_parsed,
13513 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13514 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
13515 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13516 " eth-src <eth-src> eth-dst <eth-dst>",
13518 (void *)&cmd_set_mplsoudp_encap_set,
13519 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13520 (void *)&cmd_set_mplsoudp_encap_ip_version,
13521 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13522 (void *)&cmd_set_mplsoudp_encap_label,
13523 (void *)&cmd_set_mplsoudp_encap_label_value,
13524 (void *)&cmd_set_mplsoudp_encap_udp_src,
13525 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13526 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13527 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13528 (void *)&cmd_set_mplsoudp_encap_ip_src,
13529 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13530 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13531 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13532 (void *)&cmd_set_mplsoudp_encap_vlan,
13533 (void *)&cmd_set_mplsoudp_encap_vlan_value,
13534 (void *)&cmd_set_mplsoudp_encap_eth_src,
13535 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13536 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13537 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13542 /** Set MPLSoUDP decapsulation details */
13543 struct cmd_set_mplsoudp_decap_result {
13544 cmdline_fixed_string_t set;
13545 cmdline_fixed_string_t mplsoudp;
13546 cmdline_fixed_string_t pos_token;
13547 cmdline_fixed_string_t ip_version;
13548 uint32_t vlan_present:1;
13551 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
13552 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
13554 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
13555 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
13557 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
13558 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13559 mplsoudp, "mplsoudp_decap-with-vlan");
13560 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
13561 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13562 pos_token, "ip-version");
13563 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
13564 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13565 ip_version, "ipv4#ipv6");
13567 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
13568 __rte_unused struct cmdline *cl,
13569 __rte_unused void *data)
13571 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
13573 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
13574 mplsoudp_decap_conf.select_vlan = 0;
13575 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
13576 mplsoudp_decap_conf.select_vlan = 1;
13577 if (strcmp(res->ip_version, "ipv4") == 0)
13578 mplsoudp_decap_conf.select_ipv4 = 1;
13579 else if (strcmp(res->ip_version, "ipv6") == 0)
13580 mplsoudp_decap_conf.select_ipv4 = 0;
13583 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
13584 .f = cmd_set_mplsoudp_decap_parsed,
13586 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
13588 (void *)&cmd_set_mplsoudp_decap_set,
13589 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
13590 (void *)&cmd_set_mplsoudp_decap_ip_version,
13591 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13596 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
13597 .f = cmd_set_mplsoudp_decap_parsed,
13599 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
13601 (void *)&cmd_set_mplsoudp_decap_set,
13602 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
13603 (void *)&cmd_set_mplsoudp_decap_ip_version,
13604 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13609 /* Strict link priority scheduling mode setting */
13611 cmd_strict_link_prio_parsed(
13612 void *parsed_result,
13613 __rte_unused struct cmdline *cl,
13614 __rte_unused void *data)
13616 struct cmd_vf_tc_bw_result *res = parsed_result;
13617 int ret = -ENOTSUP;
13619 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13622 #ifdef RTE_NET_I40E
13623 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
13630 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
13633 printf("invalid port_id %d\n", res->port_id);
13636 printf("function not implemented\n");
13639 printf("programming error: (%s)\n", strerror(-ret));
13643 cmdline_parse_inst_t cmd_strict_link_prio = {
13644 .f = cmd_strict_link_prio_parsed,
13646 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
13648 (void *)&cmd_vf_tc_bw_set,
13649 (void *)&cmd_vf_tc_bw_tx,
13650 (void *)&cmd_vf_tc_bw_strict_link_prio,
13651 (void *)&cmd_vf_tc_bw_port_id,
13652 (void *)&cmd_vf_tc_bw_tc_map,
13657 /* Load dynamic device personalization*/
13658 struct cmd_ddp_add_result {
13659 cmdline_fixed_string_t ddp;
13660 cmdline_fixed_string_t add;
13665 cmdline_parse_token_string_t cmd_ddp_add_ddp =
13666 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
13667 cmdline_parse_token_string_t cmd_ddp_add_add =
13668 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
13669 cmdline_parse_token_num_t cmd_ddp_add_port_id =
13670 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
13672 cmdline_parse_token_string_t cmd_ddp_add_filepath =
13673 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
13676 cmd_ddp_add_parsed(
13677 void *parsed_result,
13678 __rte_unused struct cmdline *cl,
13679 __rte_unused void *data)
13681 struct cmd_ddp_add_result *res = parsed_result;
13687 int ret = -ENOTSUP;
13689 if (!all_ports_stopped()) {
13690 printf("Please stop all ports first\n");
13694 filepath = strdup(res->filepath);
13695 if (filepath == NULL) {
13696 printf("Failed to allocate memory\n");
13699 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
13701 buff = open_file(file_fld[0], &size);
13703 free((void *)filepath);
13707 #ifdef RTE_NET_I40E
13708 if (ret == -ENOTSUP)
13709 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13711 RTE_PMD_I40E_PKG_OP_WR_ADD);
13714 if (ret == -EEXIST)
13715 printf("Profile has already existed.\n");
13717 printf("Failed to load profile.\n");
13718 else if (file_num == 2)
13719 save_file(file_fld[1], buff, size);
13722 free((void *)filepath);
13725 cmdline_parse_inst_t cmd_ddp_add = {
13726 .f = cmd_ddp_add_parsed,
13728 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
13730 (void *)&cmd_ddp_add_ddp,
13731 (void *)&cmd_ddp_add_add,
13732 (void *)&cmd_ddp_add_port_id,
13733 (void *)&cmd_ddp_add_filepath,
13738 /* Delete dynamic device personalization*/
13739 struct cmd_ddp_del_result {
13740 cmdline_fixed_string_t ddp;
13741 cmdline_fixed_string_t del;
13746 cmdline_parse_token_string_t cmd_ddp_del_ddp =
13747 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
13748 cmdline_parse_token_string_t cmd_ddp_del_del =
13749 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
13750 cmdline_parse_token_num_t cmd_ddp_del_port_id =
13751 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
13752 cmdline_parse_token_string_t cmd_ddp_del_filepath =
13753 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
13756 cmd_ddp_del_parsed(
13757 void *parsed_result,
13758 __rte_unused struct cmdline *cl,
13759 __rte_unused void *data)
13761 struct cmd_ddp_del_result *res = parsed_result;
13764 int ret = -ENOTSUP;
13766 if (!all_ports_stopped()) {
13767 printf("Please stop all ports first\n");
13771 buff = open_file(res->filepath, &size);
13775 #ifdef RTE_NET_I40E
13776 if (ret == -ENOTSUP)
13777 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13779 RTE_PMD_I40E_PKG_OP_WR_DEL);
13782 if (ret == -EACCES)
13783 printf("Profile does not exist.\n");
13785 printf("Failed to delete profile.\n");
13790 cmdline_parse_inst_t cmd_ddp_del = {
13791 .f = cmd_ddp_del_parsed,
13793 .help_str = "ddp del <port_id> <backup_profile_path>",
13795 (void *)&cmd_ddp_del_ddp,
13796 (void *)&cmd_ddp_del_del,
13797 (void *)&cmd_ddp_del_port_id,
13798 (void *)&cmd_ddp_del_filepath,
13803 /* Get dynamic device personalization profile info */
13804 struct cmd_ddp_info_result {
13805 cmdline_fixed_string_t ddp;
13806 cmdline_fixed_string_t get;
13807 cmdline_fixed_string_t info;
13811 cmdline_parse_token_string_t cmd_ddp_info_ddp =
13812 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
13813 cmdline_parse_token_string_t cmd_ddp_info_get =
13814 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
13815 cmdline_parse_token_string_t cmd_ddp_info_info =
13816 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
13817 cmdline_parse_token_string_t cmd_ddp_info_filepath =
13818 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
13821 cmd_ddp_info_parsed(
13822 void *parsed_result,
13823 __rte_unused struct cmdline *cl,
13824 __rte_unused void *data)
13826 struct cmd_ddp_info_result *res = parsed_result;
13829 int ret = -ENOTSUP;
13830 #ifdef RTE_NET_I40E
13833 uint32_t buff_size = 0;
13834 struct rte_pmd_i40e_profile_info info;
13835 uint32_t dev_num = 0;
13836 struct rte_pmd_i40e_ddp_device_id *devs;
13837 uint32_t proto_num = 0;
13838 struct rte_pmd_i40e_proto_info *proto = NULL;
13839 uint32_t pctype_num = 0;
13840 struct rte_pmd_i40e_ptype_info *pctype;
13841 uint32_t ptype_num = 0;
13842 struct rte_pmd_i40e_ptype_info *ptype;
13847 pkg = open_file(res->filepath, &pkg_size);
13851 #ifdef RTE_NET_I40E
13852 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13853 (uint8_t *)&info, sizeof(info),
13854 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
13856 printf("Global Track id: 0x%x\n", info.track_id);
13857 printf("Global Version: %d.%d.%d.%d\n",
13858 info.version.major,
13859 info.version.minor,
13860 info.version.update,
13861 info.version.draft);
13862 printf("Global Package name: %s\n\n", info.name);
13865 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13866 (uint8_t *)&info, sizeof(info),
13867 RTE_PMD_I40E_PKG_INFO_HEADER);
13869 printf("i40e Profile Track id: 0x%x\n", info.track_id);
13870 printf("i40e Profile Version: %d.%d.%d.%d\n",
13871 info.version.major,
13872 info.version.minor,
13873 info.version.update,
13874 info.version.draft);
13875 printf("i40e Profile name: %s\n\n", info.name);
13878 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13879 (uint8_t *)&buff_size, sizeof(buff_size),
13880 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
13881 if (!ret && buff_size) {
13882 buff = (uint8_t *)malloc(buff_size);
13884 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13886 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
13888 printf("Package Notes:\n%s\n\n", buff);
13893 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13894 (uint8_t *)&dev_num, sizeof(dev_num),
13895 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
13896 if (!ret && dev_num) {
13897 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
13898 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
13900 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13901 (uint8_t *)devs, buff_size,
13902 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
13904 printf("List of supported devices:\n");
13905 for (i = 0; i < dev_num; i++) {
13906 printf(" %04X:%04X %04X:%04X\n",
13907 devs[i].vendor_dev_id >> 16,
13908 devs[i].vendor_dev_id & 0xFFFF,
13909 devs[i].sub_vendor_dev_id >> 16,
13910 devs[i].sub_vendor_dev_id & 0xFFFF);
13918 /* get information about protocols and packet types */
13919 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13920 (uint8_t *)&proto_num, sizeof(proto_num),
13921 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
13922 if (ret || !proto_num)
13923 goto no_print_return;
13925 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
13926 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
13928 goto no_print_return;
13930 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
13932 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
13934 printf("List of used protocols:\n");
13935 for (i = 0; i < proto_num; i++)
13936 printf(" %2u: %s\n", proto[i].proto_id,
13940 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13941 (uint8_t *)&pctype_num, sizeof(pctype_num),
13942 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
13943 if (ret || !pctype_num)
13944 goto no_print_pctypes;
13946 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
13947 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
13949 goto no_print_pctypes;
13951 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
13953 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
13956 goto no_print_pctypes;
13959 printf("List of defined packet classification types:\n");
13960 for (i = 0; i < pctype_num; i++) {
13961 printf(" %2u:", pctype[i].ptype_id);
13962 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
13963 proto_id = pctype[i].protocols[j];
13964 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
13965 for (n = 0; n < proto_num; n++) {
13966 if (proto[n].proto_id == proto_id) {
13967 printf(" %s", proto[n].name);
13980 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
13982 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
13983 if (ret || !ptype_num)
13984 goto no_print_return;
13986 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
13987 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
13989 goto no_print_return;
13991 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
13993 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
13996 goto no_print_return;
13998 printf("List of defined packet types:\n");
13999 for (i = 0; i < ptype_num; i++) {
14000 printf(" %2u:", ptype[i].ptype_id);
14001 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14002 proto_id = ptype[i].protocols[j];
14003 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14004 for (n = 0; n < proto_num; n++) {
14005 if (proto[n].proto_id == proto_id) {
14006 printf(" %s", proto[n].name);
14022 if (ret == -ENOTSUP)
14023 printf("Function not supported in PMD driver\n");
14027 cmdline_parse_inst_t cmd_ddp_get_info = {
14028 .f = cmd_ddp_info_parsed,
14030 .help_str = "ddp get info <profile_path>",
14032 (void *)&cmd_ddp_info_ddp,
14033 (void *)&cmd_ddp_info_get,
14034 (void *)&cmd_ddp_info_info,
14035 (void *)&cmd_ddp_info_filepath,
14040 /* Get dynamic device personalization profile info list*/
14041 #define PROFILE_INFO_SIZE 48
14042 #define MAX_PROFILE_NUM 16
14044 struct cmd_ddp_get_list_result {
14045 cmdline_fixed_string_t ddp;
14046 cmdline_fixed_string_t get;
14047 cmdline_fixed_string_t list;
14051 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14052 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14053 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14054 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14055 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14056 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14057 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14058 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14062 cmd_ddp_get_list_parsed(
14063 __rte_unused void *parsed_result,
14064 __rte_unused struct cmdline *cl,
14065 __rte_unused void *data)
14067 #ifdef RTE_NET_I40E
14068 struct cmd_ddp_get_list_result *res = parsed_result;
14069 struct rte_pmd_i40e_profile_list *p_list;
14070 struct rte_pmd_i40e_profile_info *p_info;
14075 int ret = -ENOTSUP;
14077 #ifdef RTE_NET_I40E
14078 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14079 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14081 printf("%s: Failed to malloc buffer\n", __func__);
14085 if (ret == -ENOTSUP)
14086 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14087 (uint8_t *)p_list, size);
14090 p_num = p_list->p_count;
14091 printf("Profile number is: %d\n\n", p_num);
14093 for (i = 0; i < p_num; i++) {
14094 p_info = &p_list->p_info[i];
14095 printf("Profile %d:\n", i);
14096 printf("Track id: 0x%x\n", p_info->track_id);
14097 printf("Version: %d.%d.%d.%d\n",
14098 p_info->version.major,
14099 p_info->version.minor,
14100 p_info->version.update,
14101 p_info->version.draft);
14102 printf("Profile name: %s\n\n", p_info->name);
14110 printf("Failed to get ddp list\n");
14113 cmdline_parse_inst_t cmd_ddp_get_list = {
14114 .f = cmd_ddp_get_list_parsed,
14116 .help_str = "ddp get list <port_id>",
14118 (void *)&cmd_ddp_get_list_ddp,
14119 (void *)&cmd_ddp_get_list_get,
14120 (void *)&cmd_ddp_get_list_list,
14121 (void *)&cmd_ddp_get_list_port_id,
14126 /* Configure input set */
14127 struct cmd_cfg_input_set_result {
14128 cmdline_fixed_string_t port;
14129 cmdline_fixed_string_t cfg;
14131 cmdline_fixed_string_t pctype;
14133 cmdline_fixed_string_t inset_type;
14134 cmdline_fixed_string_t opt;
14135 cmdline_fixed_string_t field;
14140 cmd_cfg_input_set_parsed(
14141 __rte_unused void *parsed_result,
14142 __rte_unused struct cmdline *cl,
14143 __rte_unused void *data)
14145 #ifdef RTE_NET_I40E
14146 struct cmd_cfg_input_set_result *res = parsed_result;
14147 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14148 struct rte_pmd_i40e_inset inset;
14150 int ret = -ENOTSUP;
14152 if (!all_ports_stopped()) {
14153 printf("Please stop all ports first\n");
14157 #ifdef RTE_NET_I40E
14158 if (!strcmp(res->inset_type, "hash_inset"))
14159 inset_type = INSET_HASH;
14160 else if (!strcmp(res->inset_type, "fdir_inset"))
14161 inset_type = INSET_FDIR;
14162 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14163 inset_type = INSET_FDIR_FLX;
14164 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14165 &inset, inset_type);
14167 printf("Failed to get input set.\n");
14171 if (!strcmp(res->opt, "get")) {
14172 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14175 printf("Field index %d is enabled.\n", res->field_idx);
14177 printf("Field index %d is disabled.\n", res->field_idx);
14179 } else if (!strcmp(res->opt, "set"))
14180 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14182 else if (!strcmp(res->opt, "clear"))
14183 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14186 printf("Failed to configure input set field.\n");
14190 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14191 &inset, inset_type);
14193 printf("Failed to set input set.\n");
14198 if (ret == -ENOTSUP)
14199 printf("Function not supported\n");
14202 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14203 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14205 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14206 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14208 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14209 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14210 port_id, RTE_UINT16);
14211 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14212 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14214 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14215 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14216 pctype_id, RTE_UINT8);
14217 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14218 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14220 "hash_inset#fdir_inset#fdir_flx_inset");
14221 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14222 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14223 opt, "get#set#clear");
14224 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14225 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14227 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14228 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14229 field_idx, RTE_UINT8);
14231 cmdline_parse_inst_t cmd_cfg_input_set = {
14232 .f = cmd_cfg_input_set_parsed,
14234 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14235 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
14237 (void *)&cmd_cfg_input_set_port,
14238 (void *)&cmd_cfg_input_set_cfg,
14239 (void *)&cmd_cfg_input_set_port_id,
14240 (void *)&cmd_cfg_input_set_pctype,
14241 (void *)&cmd_cfg_input_set_pctype_id,
14242 (void *)&cmd_cfg_input_set_inset_type,
14243 (void *)&cmd_cfg_input_set_opt,
14244 (void *)&cmd_cfg_input_set_field,
14245 (void *)&cmd_cfg_input_set_field_idx,
14250 /* Clear input set */
14251 struct cmd_clear_input_set_result {
14252 cmdline_fixed_string_t port;
14253 cmdline_fixed_string_t cfg;
14255 cmdline_fixed_string_t pctype;
14257 cmdline_fixed_string_t inset_type;
14258 cmdline_fixed_string_t clear;
14259 cmdline_fixed_string_t all;
14263 cmd_clear_input_set_parsed(
14264 __rte_unused void *parsed_result,
14265 __rte_unused struct cmdline *cl,
14266 __rte_unused void *data)
14268 #ifdef RTE_NET_I40E
14269 struct cmd_clear_input_set_result *res = parsed_result;
14270 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14271 struct rte_pmd_i40e_inset inset;
14273 int ret = -ENOTSUP;
14275 if (!all_ports_stopped()) {
14276 printf("Please stop all ports first\n");
14280 #ifdef RTE_NET_I40E
14281 if (!strcmp(res->inset_type, "hash_inset"))
14282 inset_type = INSET_HASH;
14283 else if (!strcmp(res->inset_type, "fdir_inset"))
14284 inset_type = INSET_FDIR;
14285 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14286 inset_type = INSET_FDIR_FLX;
14288 memset(&inset, 0, sizeof(inset));
14290 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14291 &inset, inset_type);
14293 printf("Failed to clear input set.\n");
14299 if (ret == -ENOTSUP)
14300 printf("Function not supported\n");
14303 cmdline_parse_token_string_t cmd_clear_input_set_port =
14304 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14306 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
14307 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14309 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
14310 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14311 port_id, RTE_UINT16);
14312 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
14313 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14315 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
14316 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14317 pctype_id, RTE_UINT8);
14318 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
14319 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14321 "hash_inset#fdir_inset#fdir_flx_inset");
14322 cmdline_parse_token_string_t cmd_clear_input_set_clear =
14323 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14325 cmdline_parse_token_string_t cmd_clear_input_set_all =
14326 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14329 cmdline_parse_inst_t cmd_clear_input_set = {
14330 .f = cmd_clear_input_set_parsed,
14332 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14333 "fdir_inset|fdir_flx_inset clear all",
14335 (void *)&cmd_clear_input_set_port,
14336 (void *)&cmd_clear_input_set_cfg,
14337 (void *)&cmd_clear_input_set_port_id,
14338 (void *)&cmd_clear_input_set_pctype,
14339 (void *)&cmd_clear_input_set_pctype_id,
14340 (void *)&cmd_clear_input_set_inset_type,
14341 (void *)&cmd_clear_input_set_clear,
14342 (void *)&cmd_clear_input_set_all,
14347 /* show vf stats */
14349 /* Common result structure for show vf stats */
14350 struct cmd_show_vf_stats_result {
14351 cmdline_fixed_string_t show;
14352 cmdline_fixed_string_t vf;
14353 cmdline_fixed_string_t stats;
14358 /* Common CLI fields show vf stats*/
14359 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14360 TOKEN_STRING_INITIALIZER
14361 (struct cmd_show_vf_stats_result,
14363 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14364 TOKEN_STRING_INITIALIZER
14365 (struct cmd_show_vf_stats_result,
14367 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14368 TOKEN_STRING_INITIALIZER
14369 (struct cmd_show_vf_stats_result,
14371 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14372 TOKEN_NUM_INITIALIZER
14373 (struct cmd_show_vf_stats_result,
14374 port_id, RTE_UINT16);
14375 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14376 TOKEN_NUM_INITIALIZER
14377 (struct cmd_show_vf_stats_result,
14378 vf_id, RTE_UINT16);
14381 cmd_show_vf_stats_parsed(
14382 void *parsed_result,
14383 __rte_unused struct cmdline *cl,
14384 __rte_unused void *data)
14386 struct cmd_show_vf_stats_result *res = parsed_result;
14387 struct rte_eth_stats stats;
14388 int ret = -ENOTSUP;
14389 static const char *nic_stats_border = "########################";
14391 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14394 memset(&stats, 0, sizeof(stats));
14396 #ifdef RTE_NET_I40E
14397 if (ret == -ENOTSUP)
14398 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14402 #ifdef RTE_NET_BNXT
14403 if (ret == -ENOTSUP)
14404 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14413 printf("invalid vf_id %d\n", res->vf_id);
14416 printf("invalid port_id %d\n", res->port_id);
14419 printf("function not implemented\n");
14422 printf("programming error: (%s)\n", strerror(-ret));
14425 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14426 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14428 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14430 stats.ipackets, stats.imissed, stats.ibytes);
14431 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14432 printf(" RX-nombuf: %-10"PRIu64"\n",
14434 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14436 stats.opackets, stats.oerrors, stats.obytes);
14438 printf(" %s############################%s\n",
14439 nic_stats_border, nic_stats_border);
14442 cmdline_parse_inst_t cmd_show_vf_stats = {
14443 .f = cmd_show_vf_stats_parsed,
14445 .help_str = "show vf stats <port_id> <vf_id>",
14447 (void *)&cmd_show_vf_stats_show,
14448 (void *)&cmd_show_vf_stats_vf,
14449 (void *)&cmd_show_vf_stats_stats,
14450 (void *)&cmd_show_vf_stats_port_id,
14451 (void *)&cmd_show_vf_stats_vf_id,
14456 /* clear vf stats */
14458 /* Common result structure for clear vf stats */
14459 struct cmd_clear_vf_stats_result {
14460 cmdline_fixed_string_t clear;
14461 cmdline_fixed_string_t vf;
14462 cmdline_fixed_string_t stats;
14467 /* Common CLI fields clear vf stats*/
14468 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14469 TOKEN_STRING_INITIALIZER
14470 (struct cmd_clear_vf_stats_result,
14472 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
14473 TOKEN_STRING_INITIALIZER
14474 (struct cmd_clear_vf_stats_result,
14476 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
14477 TOKEN_STRING_INITIALIZER
14478 (struct cmd_clear_vf_stats_result,
14480 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
14481 TOKEN_NUM_INITIALIZER
14482 (struct cmd_clear_vf_stats_result,
14483 port_id, RTE_UINT16);
14484 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
14485 TOKEN_NUM_INITIALIZER
14486 (struct cmd_clear_vf_stats_result,
14487 vf_id, RTE_UINT16);
14490 cmd_clear_vf_stats_parsed(
14491 void *parsed_result,
14492 __rte_unused struct cmdline *cl,
14493 __rte_unused void *data)
14495 struct cmd_clear_vf_stats_result *res = parsed_result;
14496 int ret = -ENOTSUP;
14498 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14501 #ifdef RTE_NET_I40E
14502 if (ret == -ENOTSUP)
14503 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
14506 #ifdef RTE_NET_BNXT
14507 if (ret == -ENOTSUP)
14508 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
14516 printf("invalid vf_id %d\n", res->vf_id);
14519 printf("invalid port_id %d\n", res->port_id);
14522 printf("function not implemented\n");
14525 printf("programming error: (%s)\n", strerror(-ret));
14529 cmdline_parse_inst_t cmd_clear_vf_stats = {
14530 .f = cmd_clear_vf_stats_parsed,
14532 .help_str = "clear vf stats <port_id> <vf_id>",
14534 (void *)&cmd_clear_vf_stats_clear,
14535 (void *)&cmd_clear_vf_stats_vf,
14536 (void *)&cmd_clear_vf_stats_stats,
14537 (void *)&cmd_clear_vf_stats_port_id,
14538 (void *)&cmd_clear_vf_stats_vf_id,
14543 /* port config pctype mapping reset */
14545 /* Common result structure for port config pctype mapping reset */
14546 struct cmd_pctype_mapping_reset_result {
14547 cmdline_fixed_string_t port;
14548 cmdline_fixed_string_t config;
14550 cmdline_fixed_string_t pctype;
14551 cmdline_fixed_string_t mapping;
14552 cmdline_fixed_string_t reset;
14555 /* Common CLI fields for port config pctype mapping reset*/
14556 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
14557 TOKEN_STRING_INITIALIZER
14558 (struct cmd_pctype_mapping_reset_result,
14560 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
14561 TOKEN_STRING_INITIALIZER
14562 (struct cmd_pctype_mapping_reset_result,
14564 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
14565 TOKEN_NUM_INITIALIZER
14566 (struct cmd_pctype_mapping_reset_result,
14567 port_id, RTE_UINT16);
14568 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
14569 TOKEN_STRING_INITIALIZER
14570 (struct cmd_pctype_mapping_reset_result,
14572 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
14573 TOKEN_STRING_INITIALIZER
14574 (struct cmd_pctype_mapping_reset_result,
14575 mapping, "mapping");
14576 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
14577 TOKEN_STRING_INITIALIZER
14578 (struct cmd_pctype_mapping_reset_result,
14582 cmd_pctype_mapping_reset_parsed(
14583 void *parsed_result,
14584 __rte_unused struct cmdline *cl,
14585 __rte_unused void *data)
14587 struct cmd_pctype_mapping_reset_result *res = parsed_result;
14588 int ret = -ENOTSUP;
14590 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14593 #ifdef RTE_NET_I40E
14594 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
14601 printf("invalid port_id %d\n", res->port_id);
14604 printf("function not implemented\n");
14607 printf("programming error: (%s)\n", strerror(-ret));
14611 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
14612 .f = cmd_pctype_mapping_reset_parsed,
14614 .help_str = "port config <port_id> pctype mapping reset",
14616 (void *)&cmd_pctype_mapping_reset_port,
14617 (void *)&cmd_pctype_mapping_reset_config,
14618 (void *)&cmd_pctype_mapping_reset_port_id,
14619 (void *)&cmd_pctype_mapping_reset_pctype,
14620 (void *)&cmd_pctype_mapping_reset_mapping,
14621 (void *)&cmd_pctype_mapping_reset_reset,
14626 /* show port pctype mapping */
14628 /* Common result structure for show port pctype mapping */
14629 struct cmd_pctype_mapping_get_result {
14630 cmdline_fixed_string_t show;
14631 cmdline_fixed_string_t port;
14633 cmdline_fixed_string_t pctype;
14634 cmdline_fixed_string_t mapping;
14637 /* Common CLI fields for pctype mapping get */
14638 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
14639 TOKEN_STRING_INITIALIZER
14640 (struct cmd_pctype_mapping_get_result,
14642 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
14643 TOKEN_STRING_INITIALIZER
14644 (struct cmd_pctype_mapping_get_result,
14646 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
14647 TOKEN_NUM_INITIALIZER
14648 (struct cmd_pctype_mapping_get_result,
14649 port_id, RTE_UINT16);
14650 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
14651 TOKEN_STRING_INITIALIZER
14652 (struct cmd_pctype_mapping_get_result,
14654 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
14655 TOKEN_STRING_INITIALIZER
14656 (struct cmd_pctype_mapping_get_result,
14657 mapping, "mapping");
14660 cmd_pctype_mapping_get_parsed(
14661 void *parsed_result,
14662 __rte_unused struct cmdline *cl,
14663 __rte_unused void *data)
14665 struct cmd_pctype_mapping_get_result *res = parsed_result;
14666 int ret = -ENOTSUP;
14667 #ifdef RTE_NET_I40E
14668 struct rte_pmd_i40e_flow_type_mapping
14669 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
14670 int i, j, first_pctype;
14673 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14676 #ifdef RTE_NET_I40E
14677 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
14684 printf("invalid port_id %d\n", res->port_id);
14687 printf("function not implemented\n");
14690 printf("programming error: (%s)\n", strerror(-ret));
14694 #ifdef RTE_NET_I40E
14695 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
14696 if (mapping[i].pctype != 0ULL) {
14699 printf("pctype: ");
14700 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
14701 if (mapping[i].pctype & (1ULL << j)) {
14702 printf(first_pctype ?
14703 "%02d" : ",%02d", j);
14707 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
14713 cmdline_parse_inst_t cmd_pctype_mapping_get = {
14714 .f = cmd_pctype_mapping_get_parsed,
14716 .help_str = "show port <port_id> pctype mapping",
14718 (void *)&cmd_pctype_mapping_get_show,
14719 (void *)&cmd_pctype_mapping_get_port,
14720 (void *)&cmd_pctype_mapping_get_port_id,
14721 (void *)&cmd_pctype_mapping_get_pctype,
14722 (void *)&cmd_pctype_mapping_get_mapping,
14727 /* port config pctype mapping update */
14729 /* Common result structure for port config pctype mapping update */
14730 struct cmd_pctype_mapping_update_result {
14731 cmdline_fixed_string_t port;
14732 cmdline_fixed_string_t config;
14734 cmdline_fixed_string_t pctype;
14735 cmdline_fixed_string_t mapping;
14736 cmdline_fixed_string_t update;
14737 cmdline_fixed_string_t pctype_list;
14738 uint16_t flow_type;
14741 /* Common CLI fields for pctype mapping update*/
14742 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
14743 TOKEN_STRING_INITIALIZER
14744 (struct cmd_pctype_mapping_update_result,
14746 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
14747 TOKEN_STRING_INITIALIZER
14748 (struct cmd_pctype_mapping_update_result,
14750 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
14751 TOKEN_NUM_INITIALIZER
14752 (struct cmd_pctype_mapping_update_result,
14753 port_id, RTE_UINT16);
14754 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
14755 TOKEN_STRING_INITIALIZER
14756 (struct cmd_pctype_mapping_update_result,
14758 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
14759 TOKEN_STRING_INITIALIZER
14760 (struct cmd_pctype_mapping_update_result,
14761 mapping, "mapping");
14762 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
14763 TOKEN_STRING_INITIALIZER
14764 (struct cmd_pctype_mapping_update_result,
14766 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
14767 TOKEN_STRING_INITIALIZER
14768 (struct cmd_pctype_mapping_update_result,
14769 pctype_list, NULL);
14770 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
14771 TOKEN_NUM_INITIALIZER
14772 (struct cmd_pctype_mapping_update_result,
14773 flow_type, RTE_UINT16);
14776 cmd_pctype_mapping_update_parsed(
14777 void *parsed_result,
14778 __rte_unused struct cmdline *cl,
14779 __rte_unused void *data)
14781 struct cmd_pctype_mapping_update_result *res = parsed_result;
14782 int ret = -ENOTSUP;
14783 #ifdef RTE_NET_I40E
14784 struct rte_pmd_i40e_flow_type_mapping mapping;
14786 unsigned int nb_item;
14787 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
14790 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14793 #ifdef RTE_NET_I40E
14794 nb_item = parse_item_list(res->pctype_list, "pctypes",
14795 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
14796 mapping.flow_type = res->flow_type;
14797 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
14798 mapping.pctype |= (1ULL << pctype_list[i]);
14799 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
14809 printf("invalid pctype or flow type\n");
14812 printf("invalid port_id %d\n", res->port_id);
14815 printf("function not implemented\n");
14818 printf("programming error: (%s)\n", strerror(-ret));
14822 cmdline_parse_inst_t cmd_pctype_mapping_update = {
14823 .f = cmd_pctype_mapping_update_parsed,
14825 .help_str = "port config <port_id> pctype mapping update"
14826 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
14828 (void *)&cmd_pctype_mapping_update_port,
14829 (void *)&cmd_pctype_mapping_update_config,
14830 (void *)&cmd_pctype_mapping_update_port_id,
14831 (void *)&cmd_pctype_mapping_update_pctype,
14832 (void *)&cmd_pctype_mapping_update_mapping,
14833 (void *)&cmd_pctype_mapping_update_update,
14834 (void *)&cmd_pctype_mapping_update_pc_type,
14835 (void *)&cmd_pctype_mapping_update_flow_type,
14840 /* ptype mapping get */
14842 /* Common result structure for ptype mapping get */
14843 struct cmd_ptype_mapping_get_result {
14844 cmdline_fixed_string_t ptype;
14845 cmdline_fixed_string_t mapping;
14846 cmdline_fixed_string_t get;
14848 uint8_t valid_only;
14851 /* Common CLI fields for ptype mapping get */
14852 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
14853 TOKEN_STRING_INITIALIZER
14854 (struct cmd_ptype_mapping_get_result,
14856 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
14857 TOKEN_STRING_INITIALIZER
14858 (struct cmd_ptype_mapping_get_result,
14859 mapping, "mapping");
14860 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
14861 TOKEN_STRING_INITIALIZER
14862 (struct cmd_ptype_mapping_get_result,
14864 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
14865 TOKEN_NUM_INITIALIZER
14866 (struct cmd_ptype_mapping_get_result,
14867 port_id, RTE_UINT16);
14868 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
14869 TOKEN_NUM_INITIALIZER
14870 (struct cmd_ptype_mapping_get_result,
14871 valid_only, RTE_UINT8);
14874 cmd_ptype_mapping_get_parsed(
14875 void *parsed_result,
14876 __rte_unused struct cmdline *cl,
14877 __rte_unused void *data)
14879 struct cmd_ptype_mapping_get_result *res = parsed_result;
14880 int ret = -ENOTSUP;
14881 #ifdef RTE_NET_I40E
14882 int max_ptype_num = 256;
14883 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
14888 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14891 #ifdef RTE_NET_I40E
14892 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
14903 printf("invalid port_id %d\n", res->port_id);
14906 printf("function not implemented\n");
14909 printf("programming error: (%s)\n", strerror(-ret));
14912 #ifdef RTE_NET_I40E
14914 for (i = 0; i < count; i++)
14915 printf("%3d\t0x%08x\n",
14916 mapping[i].hw_ptype, mapping[i].sw_ptype);
14921 cmdline_parse_inst_t cmd_ptype_mapping_get = {
14922 .f = cmd_ptype_mapping_get_parsed,
14924 .help_str = "ptype mapping get <port_id> <valid_only>",
14926 (void *)&cmd_ptype_mapping_get_ptype,
14927 (void *)&cmd_ptype_mapping_get_mapping,
14928 (void *)&cmd_ptype_mapping_get_get,
14929 (void *)&cmd_ptype_mapping_get_port_id,
14930 (void *)&cmd_ptype_mapping_get_valid_only,
14935 /* ptype mapping replace */
14937 /* Common result structure for ptype mapping replace */
14938 struct cmd_ptype_mapping_replace_result {
14939 cmdline_fixed_string_t ptype;
14940 cmdline_fixed_string_t mapping;
14941 cmdline_fixed_string_t replace;
14948 /* Common CLI fields for ptype mapping replace */
14949 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
14950 TOKEN_STRING_INITIALIZER
14951 (struct cmd_ptype_mapping_replace_result,
14953 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
14954 TOKEN_STRING_INITIALIZER
14955 (struct cmd_ptype_mapping_replace_result,
14956 mapping, "mapping");
14957 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
14958 TOKEN_STRING_INITIALIZER
14959 (struct cmd_ptype_mapping_replace_result,
14960 replace, "replace");
14961 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
14962 TOKEN_NUM_INITIALIZER
14963 (struct cmd_ptype_mapping_replace_result,
14964 port_id, RTE_UINT16);
14965 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
14966 TOKEN_NUM_INITIALIZER
14967 (struct cmd_ptype_mapping_replace_result,
14968 target, RTE_UINT32);
14969 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
14970 TOKEN_NUM_INITIALIZER
14971 (struct cmd_ptype_mapping_replace_result,
14973 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
14974 TOKEN_NUM_INITIALIZER
14975 (struct cmd_ptype_mapping_replace_result,
14976 pkt_type, RTE_UINT32);
14979 cmd_ptype_mapping_replace_parsed(
14980 void *parsed_result,
14981 __rte_unused struct cmdline *cl,
14982 __rte_unused void *data)
14984 struct cmd_ptype_mapping_replace_result *res = parsed_result;
14985 int ret = -ENOTSUP;
14987 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14990 #ifdef RTE_NET_I40E
14991 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15001 printf("invalid ptype 0x%8x or 0x%8x\n",
15002 res->target, res->pkt_type);
15005 printf("invalid port_id %d\n", res->port_id);
15008 printf("function not implemented\n");
15011 printf("programming error: (%s)\n", strerror(-ret));
15015 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15016 .f = cmd_ptype_mapping_replace_parsed,
15019 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15021 (void *)&cmd_ptype_mapping_replace_ptype,
15022 (void *)&cmd_ptype_mapping_replace_mapping,
15023 (void *)&cmd_ptype_mapping_replace_replace,
15024 (void *)&cmd_ptype_mapping_replace_port_id,
15025 (void *)&cmd_ptype_mapping_replace_target,
15026 (void *)&cmd_ptype_mapping_replace_mask,
15027 (void *)&cmd_ptype_mapping_replace_pkt_type,
15032 /* ptype mapping reset */
15034 /* Common result structure for ptype mapping reset */
15035 struct cmd_ptype_mapping_reset_result {
15036 cmdline_fixed_string_t ptype;
15037 cmdline_fixed_string_t mapping;
15038 cmdline_fixed_string_t reset;
15042 /* Common CLI fields for ptype mapping reset*/
15043 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15044 TOKEN_STRING_INITIALIZER
15045 (struct cmd_ptype_mapping_reset_result,
15047 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15048 TOKEN_STRING_INITIALIZER
15049 (struct cmd_ptype_mapping_reset_result,
15050 mapping, "mapping");
15051 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15052 TOKEN_STRING_INITIALIZER
15053 (struct cmd_ptype_mapping_reset_result,
15055 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15056 TOKEN_NUM_INITIALIZER
15057 (struct cmd_ptype_mapping_reset_result,
15058 port_id, RTE_UINT16);
15061 cmd_ptype_mapping_reset_parsed(
15062 void *parsed_result,
15063 __rte_unused struct cmdline *cl,
15064 __rte_unused void *data)
15066 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15067 int ret = -ENOTSUP;
15069 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15072 #ifdef RTE_NET_I40E
15073 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15080 printf("invalid port_id %d\n", res->port_id);
15083 printf("function not implemented\n");
15086 printf("programming error: (%s)\n", strerror(-ret));
15090 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15091 .f = cmd_ptype_mapping_reset_parsed,
15093 .help_str = "ptype mapping reset <port_id>",
15095 (void *)&cmd_ptype_mapping_reset_ptype,
15096 (void *)&cmd_ptype_mapping_reset_mapping,
15097 (void *)&cmd_ptype_mapping_reset_reset,
15098 (void *)&cmd_ptype_mapping_reset_port_id,
15103 /* ptype mapping update */
15105 /* Common result structure for ptype mapping update */
15106 struct cmd_ptype_mapping_update_result {
15107 cmdline_fixed_string_t ptype;
15108 cmdline_fixed_string_t mapping;
15109 cmdline_fixed_string_t reset;
15115 /* Common CLI fields for ptype mapping update*/
15116 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15117 TOKEN_STRING_INITIALIZER
15118 (struct cmd_ptype_mapping_update_result,
15120 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15121 TOKEN_STRING_INITIALIZER
15122 (struct cmd_ptype_mapping_update_result,
15123 mapping, "mapping");
15124 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15125 TOKEN_STRING_INITIALIZER
15126 (struct cmd_ptype_mapping_update_result,
15128 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15129 TOKEN_NUM_INITIALIZER
15130 (struct cmd_ptype_mapping_update_result,
15131 port_id, RTE_UINT16);
15132 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15133 TOKEN_NUM_INITIALIZER
15134 (struct cmd_ptype_mapping_update_result,
15135 hw_ptype, RTE_UINT8);
15136 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15137 TOKEN_NUM_INITIALIZER
15138 (struct cmd_ptype_mapping_update_result,
15139 sw_ptype, RTE_UINT32);
15142 cmd_ptype_mapping_update_parsed(
15143 void *parsed_result,
15144 __rte_unused struct cmdline *cl,
15145 __rte_unused void *data)
15147 struct cmd_ptype_mapping_update_result *res = parsed_result;
15148 int ret = -ENOTSUP;
15149 #ifdef RTE_NET_I40E
15150 struct rte_pmd_i40e_ptype_mapping mapping;
15152 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15155 #ifdef RTE_NET_I40E
15156 mapping.hw_ptype = res->hw_ptype;
15157 mapping.sw_ptype = res->sw_ptype;
15158 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15168 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15171 printf("invalid port_id %d\n", res->port_id);
15174 printf("function not implemented\n");
15177 printf("programming error: (%s)\n", strerror(-ret));
15181 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15182 .f = cmd_ptype_mapping_update_parsed,
15184 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15186 (void *)&cmd_ptype_mapping_update_ptype,
15187 (void *)&cmd_ptype_mapping_update_mapping,
15188 (void *)&cmd_ptype_mapping_update_update,
15189 (void *)&cmd_ptype_mapping_update_port_id,
15190 (void *)&cmd_ptype_mapping_update_hw_ptype,
15191 (void *)&cmd_ptype_mapping_update_sw_ptype,
15196 /* Common result structure for file commands */
15197 struct cmd_cmdfile_result {
15198 cmdline_fixed_string_t load;
15199 cmdline_fixed_string_t filename;
15202 /* Common CLI fields for file commands */
15203 cmdline_parse_token_string_t cmd_load_cmdfile =
15204 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15205 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15206 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15209 cmd_load_from_file_parsed(
15210 void *parsed_result,
15211 __rte_unused struct cmdline *cl,
15212 __rte_unused void *data)
15214 struct cmd_cmdfile_result *res = parsed_result;
15216 cmdline_read_from_file(res->filename);
15219 cmdline_parse_inst_t cmd_load_from_file = {
15220 .f = cmd_load_from_file_parsed,
15222 .help_str = "load <filename>",
15224 (void *)&cmd_load_cmdfile,
15225 (void *)&cmd_load_cmdfile_filename,
15230 /* Get Rx offloads capabilities */
15231 struct cmd_rx_offload_get_capa_result {
15232 cmdline_fixed_string_t show;
15233 cmdline_fixed_string_t port;
15235 cmdline_fixed_string_t rx_offload;
15236 cmdline_fixed_string_t capabilities;
15239 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
15240 TOKEN_STRING_INITIALIZER
15241 (struct cmd_rx_offload_get_capa_result,
15243 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
15244 TOKEN_STRING_INITIALIZER
15245 (struct cmd_rx_offload_get_capa_result,
15247 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
15248 TOKEN_NUM_INITIALIZER
15249 (struct cmd_rx_offload_get_capa_result,
15250 port_id, RTE_UINT16);
15251 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
15252 TOKEN_STRING_INITIALIZER
15253 (struct cmd_rx_offload_get_capa_result,
15254 rx_offload, "rx_offload");
15255 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
15256 TOKEN_STRING_INITIALIZER
15257 (struct cmd_rx_offload_get_capa_result,
15258 capabilities, "capabilities");
15261 print_rx_offloads(uint64_t offloads)
15263 uint64_t single_offload;
15271 begin = __builtin_ctzll(offloads);
15272 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15274 single_offload = 1ULL << begin;
15275 for (bit = begin; bit < end; bit++) {
15276 if (offloads & single_offload)
15278 rte_eth_dev_rx_offload_name(single_offload));
15279 single_offload <<= 1;
15284 cmd_rx_offload_get_capa_parsed(
15285 void *parsed_result,
15286 __rte_unused struct cmdline *cl,
15287 __rte_unused void *data)
15289 struct cmd_rx_offload_get_capa_result *res = parsed_result;
15290 struct rte_eth_dev_info dev_info;
15291 portid_t port_id = res->port_id;
15292 uint64_t queue_offloads;
15293 uint64_t port_offloads;
15296 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15300 queue_offloads = dev_info.rx_queue_offload_capa;
15301 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
15303 printf("Rx Offloading Capabilities of port %d :\n", port_id);
15304 printf(" Per Queue :");
15305 print_rx_offloads(queue_offloads);
15308 printf(" Per Port :");
15309 print_rx_offloads(port_offloads);
15313 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
15314 .f = cmd_rx_offload_get_capa_parsed,
15316 .help_str = "show port <port_id> rx_offload capabilities",
15318 (void *)&cmd_rx_offload_get_capa_show,
15319 (void *)&cmd_rx_offload_get_capa_port,
15320 (void *)&cmd_rx_offload_get_capa_port_id,
15321 (void *)&cmd_rx_offload_get_capa_rx_offload,
15322 (void *)&cmd_rx_offload_get_capa_capabilities,
15327 /* Get Rx offloads configuration */
15328 struct cmd_rx_offload_get_configuration_result {
15329 cmdline_fixed_string_t show;
15330 cmdline_fixed_string_t port;
15332 cmdline_fixed_string_t rx_offload;
15333 cmdline_fixed_string_t configuration;
15336 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
15337 TOKEN_STRING_INITIALIZER
15338 (struct cmd_rx_offload_get_configuration_result,
15340 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
15341 TOKEN_STRING_INITIALIZER
15342 (struct cmd_rx_offload_get_configuration_result,
15344 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
15345 TOKEN_NUM_INITIALIZER
15346 (struct cmd_rx_offload_get_configuration_result,
15347 port_id, RTE_UINT16);
15348 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
15349 TOKEN_STRING_INITIALIZER
15350 (struct cmd_rx_offload_get_configuration_result,
15351 rx_offload, "rx_offload");
15352 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
15353 TOKEN_STRING_INITIALIZER
15354 (struct cmd_rx_offload_get_configuration_result,
15355 configuration, "configuration");
15358 cmd_rx_offload_get_configuration_parsed(
15359 void *parsed_result,
15360 __rte_unused struct cmdline *cl,
15361 __rte_unused void *data)
15363 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
15364 struct rte_eth_dev_info dev_info;
15365 portid_t port_id = res->port_id;
15366 struct rte_port *port = &ports[port_id];
15367 uint64_t port_offloads;
15368 uint64_t queue_offloads;
15369 uint16_t nb_rx_queues;
15373 printf("Rx Offloading Configuration of port %d :\n", port_id);
15375 port_offloads = port->dev_conf.rxmode.offloads;
15377 print_rx_offloads(port_offloads);
15380 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15384 nb_rx_queues = dev_info.nb_rx_queues;
15385 for (q = 0; q < nb_rx_queues; q++) {
15386 queue_offloads = port->rx_conf[q].offloads;
15387 printf(" Queue[%2d] :", q);
15388 print_rx_offloads(queue_offloads);
15394 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
15395 .f = cmd_rx_offload_get_configuration_parsed,
15397 .help_str = "show port <port_id> rx_offload configuration",
15399 (void *)&cmd_rx_offload_get_configuration_show,
15400 (void *)&cmd_rx_offload_get_configuration_port,
15401 (void *)&cmd_rx_offload_get_configuration_port_id,
15402 (void *)&cmd_rx_offload_get_configuration_rx_offload,
15403 (void *)&cmd_rx_offload_get_configuration_configuration,
15408 /* Enable/Disable a per port offloading */
15409 struct cmd_config_per_port_rx_offload_result {
15410 cmdline_fixed_string_t port;
15411 cmdline_fixed_string_t config;
15413 cmdline_fixed_string_t rx_offload;
15414 cmdline_fixed_string_t offload;
15415 cmdline_fixed_string_t on_off;
15418 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
15419 TOKEN_STRING_INITIALIZER
15420 (struct cmd_config_per_port_rx_offload_result,
15422 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
15423 TOKEN_STRING_INITIALIZER
15424 (struct cmd_config_per_port_rx_offload_result,
15426 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
15427 TOKEN_NUM_INITIALIZER
15428 (struct cmd_config_per_port_rx_offload_result,
15429 port_id, RTE_UINT16);
15430 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
15431 TOKEN_STRING_INITIALIZER
15432 (struct cmd_config_per_port_rx_offload_result,
15433 rx_offload, "rx_offload");
15434 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
15435 TOKEN_STRING_INITIALIZER
15436 (struct cmd_config_per_port_rx_offload_result,
15437 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
15438 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
15439 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
15440 "scatter#buffer_split#timestamp#security#"
15441 "keep_crc#rss_hash");
15442 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
15443 TOKEN_STRING_INITIALIZER
15444 (struct cmd_config_per_port_rx_offload_result,
15448 search_rx_offload(const char *name)
15450 uint64_t single_offload;
15451 const char *single_name;
15455 single_offload = 1;
15456 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
15457 single_name = rte_eth_dev_rx_offload_name(single_offload);
15458 if (!strcasecmp(single_name, name)) {
15462 single_offload <<= 1;
15466 return single_offload;
15472 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
15473 __rte_unused struct cmdline *cl,
15474 __rte_unused void *data)
15476 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
15477 portid_t port_id = res->port_id;
15478 struct rte_eth_dev_info dev_info;
15479 struct rte_port *port = &ports[port_id];
15480 uint64_t single_offload;
15481 uint16_t nb_rx_queues;
15485 if (port->port_status != RTE_PORT_STOPPED) {
15486 printf("Error: Can't config offload when Port %d "
15487 "is not stopped\n", port_id);
15491 single_offload = search_rx_offload(res->offload);
15492 if (single_offload == 0) {
15493 printf("Unknown offload name: %s\n", res->offload);
15497 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15501 nb_rx_queues = dev_info.nb_rx_queues;
15502 if (!strcmp(res->on_off, "on")) {
15503 port->dev_conf.rxmode.offloads |= single_offload;
15504 for (q = 0; q < nb_rx_queues; q++)
15505 port->rx_conf[q].offloads |= single_offload;
15507 port->dev_conf.rxmode.offloads &= ~single_offload;
15508 for (q = 0; q < nb_rx_queues; q++)
15509 port->rx_conf[q].offloads &= ~single_offload;
15512 cmd_reconfig_device_queue(port_id, 1, 1);
15515 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
15516 .f = cmd_config_per_port_rx_offload_parsed,
15518 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
15519 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
15520 "macsec_strip|header_split|vlan_filter|vlan_extend|"
15521 "jumbo_frame|scatter|buffer_split|timestamp|security|"
15522 "keep_crc|rss_hash on|off",
15524 (void *)&cmd_config_per_port_rx_offload_result_port,
15525 (void *)&cmd_config_per_port_rx_offload_result_config,
15526 (void *)&cmd_config_per_port_rx_offload_result_port_id,
15527 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
15528 (void *)&cmd_config_per_port_rx_offload_result_offload,
15529 (void *)&cmd_config_per_port_rx_offload_result_on_off,
15534 /* Enable/Disable a per queue offloading */
15535 struct cmd_config_per_queue_rx_offload_result {
15536 cmdline_fixed_string_t port;
15538 cmdline_fixed_string_t rxq;
15540 cmdline_fixed_string_t rx_offload;
15541 cmdline_fixed_string_t offload;
15542 cmdline_fixed_string_t on_off;
15545 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
15546 TOKEN_STRING_INITIALIZER
15547 (struct cmd_config_per_queue_rx_offload_result,
15549 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
15550 TOKEN_NUM_INITIALIZER
15551 (struct cmd_config_per_queue_rx_offload_result,
15552 port_id, RTE_UINT16);
15553 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
15554 TOKEN_STRING_INITIALIZER
15555 (struct cmd_config_per_queue_rx_offload_result,
15557 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
15558 TOKEN_NUM_INITIALIZER
15559 (struct cmd_config_per_queue_rx_offload_result,
15560 queue_id, RTE_UINT16);
15561 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
15562 TOKEN_STRING_INITIALIZER
15563 (struct cmd_config_per_queue_rx_offload_result,
15564 rx_offload, "rx_offload");
15565 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
15566 TOKEN_STRING_INITIALIZER
15567 (struct cmd_config_per_queue_rx_offload_result,
15568 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
15569 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
15570 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
15571 "scatter#buffer_split#timestamp#security#keep_crc");
15572 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
15573 TOKEN_STRING_INITIALIZER
15574 (struct cmd_config_per_queue_rx_offload_result,
15578 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
15579 __rte_unused struct cmdline *cl,
15580 __rte_unused void *data)
15582 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
15583 struct rte_eth_dev_info dev_info;
15584 portid_t port_id = res->port_id;
15585 uint16_t queue_id = res->queue_id;
15586 struct rte_port *port = &ports[port_id];
15587 uint64_t single_offload;
15590 if (port->port_status != RTE_PORT_STOPPED) {
15591 printf("Error: Can't config offload when Port %d "
15592 "is not stopped\n", port_id);
15596 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15600 if (queue_id >= dev_info.nb_rx_queues) {
15601 printf("Error: input queue_id should be 0 ... "
15602 "%d\n", dev_info.nb_rx_queues - 1);
15606 single_offload = search_rx_offload(res->offload);
15607 if (single_offload == 0) {
15608 printf("Unknown offload name: %s\n", res->offload);
15612 if (!strcmp(res->on_off, "on"))
15613 port->rx_conf[queue_id].offloads |= single_offload;
15615 port->rx_conf[queue_id].offloads &= ~single_offload;
15617 cmd_reconfig_device_queue(port_id, 1, 1);
15620 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
15621 .f = cmd_config_per_queue_rx_offload_parsed,
15623 .help_str = "port <port_id> rxq <queue_id> rx_offload "
15624 "vlan_strip|ipv4_cksum|"
15625 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
15626 "macsec_strip|header_split|vlan_filter|vlan_extend|"
15627 "jumbo_frame|scatter|buffer_split|timestamp|security|"
15630 (void *)&cmd_config_per_queue_rx_offload_result_port,
15631 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
15632 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
15633 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
15634 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
15635 (void *)&cmd_config_per_queue_rx_offload_result_offload,
15636 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
15641 /* Get Tx offloads capabilities */
15642 struct cmd_tx_offload_get_capa_result {
15643 cmdline_fixed_string_t show;
15644 cmdline_fixed_string_t port;
15646 cmdline_fixed_string_t tx_offload;
15647 cmdline_fixed_string_t capabilities;
15650 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
15651 TOKEN_STRING_INITIALIZER
15652 (struct cmd_tx_offload_get_capa_result,
15654 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
15655 TOKEN_STRING_INITIALIZER
15656 (struct cmd_tx_offload_get_capa_result,
15658 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
15659 TOKEN_NUM_INITIALIZER
15660 (struct cmd_tx_offload_get_capa_result,
15661 port_id, RTE_UINT16);
15662 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
15663 TOKEN_STRING_INITIALIZER
15664 (struct cmd_tx_offload_get_capa_result,
15665 tx_offload, "tx_offload");
15666 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
15667 TOKEN_STRING_INITIALIZER
15668 (struct cmd_tx_offload_get_capa_result,
15669 capabilities, "capabilities");
15672 print_tx_offloads(uint64_t offloads)
15674 uint64_t single_offload;
15682 begin = __builtin_ctzll(offloads);
15683 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15685 single_offload = 1ULL << begin;
15686 for (bit = begin; bit < end; bit++) {
15687 if (offloads & single_offload)
15689 rte_eth_dev_tx_offload_name(single_offload));
15690 single_offload <<= 1;
15695 cmd_tx_offload_get_capa_parsed(
15696 void *parsed_result,
15697 __rte_unused struct cmdline *cl,
15698 __rte_unused void *data)
15700 struct cmd_tx_offload_get_capa_result *res = parsed_result;
15701 struct rte_eth_dev_info dev_info;
15702 portid_t port_id = res->port_id;
15703 uint64_t queue_offloads;
15704 uint64_t port_offloads;
15707 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15711 queue_offloads = dev_info.tx_queue_offload_capa;
15712 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
15714 printf("Tx Offloading Capabilities of port %d :\n", port_id);
15715 printf(" Per Queue :");
15716 print_tx_offloads(queue_offloads);
15719 printf(" Per Port :");
15720 print_tx_offloads(port_offloads);
15724 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
15725 .f = cmd_tx_offload_get_capa_parsed,
15727 .help_str = "show port <port_id> tx_offload capabilities",
15729 (void *)&cmd_tx_offload_get_capa_show,
15730 (void *)&cmd_tx_offload_get_capa_port,
15731 (void *)&cmd_tx_offload_get_capa_port_id,
15732 (void *)&cmd_tx_offload_get_capa_tx_offload,
15733 (void *)&cmd_tx_offload_get_capa_capabilities,
15738 /* Get Tx offloads configuration */
15739 struct cmd_tx_offload_get_configuration_result {
15740 cmdline_fixed_string_t show;
15741 cmdline_fixed_string_t port;
15743 cmdline_fixed_string_t tx_offload;
15744 cmdline_fixed_string_t configuration;
15747 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
15748 TOKEN_STRING_INITIALIZER
15749 (struct cmd_tx_offload_get_configuration_result,
15751 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
15752 TOKEN_STRING_INITIALIZER
15753 (struct cmd_tx_offload_get_configuration_result,
15755 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
15756 TOKEN_NUM_INITIALIZER
15757 (struct cmd_tx_offload_get_configuration_result,
15758 port_id, RTE_UINT16);
15759 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
15760 TOKEN_STRING_INITIALIZER
15761 (struct cmd_tx_offload_get_configuration_result,
15762 tx_offload, "tx_offload");
15763 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
15764 TOKEN_STRING_INITIALIZER
15765 (struct cmd_tx_offload_get_configuration_result,
15766 configuration, "configuration");
15769 cmd_tx_offload_get_configuration_parsed(
15770 void *parsed_result,
15771 __rte_unused struct cmdline *cl,
15772 __rte_unused void *data)
15774 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
15775 struct rte_eth_dev_info dev_info;
15776 portid_t port_id = res->port_id;
15777 struct rte_port *port = &ports[port_id];
15778 uint64_t port_offloads;
15779 uint64_t queue_offloads;
15780 uint16_t nb_tx_queues;
15784 printf("Tx Offloading Configuration of port %d :\n", port_id);
15786 port_offloads = port->dev_conf.txmode.offloads;
15788 print_tx_offloads(port_offloads);
15791 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15795 nb_tx_queues = dev_info.nb_tx_queues;
15796 for (q = 0; q < nb_tx_queues; q++) {
15797 queue_offloads = port->tx_conf[q].offloads;
15798 printf(" Queue[%2d] :", q);
15799 print_tx_offloads(queue_offloads);
15805 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
15806 .f = cmd_tx_offload_get_configuration_parsed,
15808 .help_str = "show port <port_id> tx_offload configuration",
15810 (void *)&cmd_tx_offload_get_configuration_show,
15811 (void *)&cmd_tx_offload_get_configuration_port,
15812 (void *)&cmd_tx_offload_get_configuration_port_id,
15813 (void *)&cmd_tx_offload_get_configuration_tx_offload,
15814 (void *)&cmd_tx_offload_get_configuration_configuration,
15819 /* Enable/Disable a per port offloading */
15820 struct cmd_config_per_port_tx_offload_result {
15821 cmdline_fixed_string_t port;
15822 cmdline_fixed_string_t config;
15824 cmdline_fixed_string_t tx_offload;
15825 cmdline_fixed_string_t offload;
15826 cmdline_fixed_string_t on_off;
15829 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
15830 TOKEN_STRING_INITIALIZER
15831 (struct cmd_config_per_port_tx_offload_result,
15833 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
15834 TOKEN_STRING_INITIALIZER
15835 (struct cmd_config_per_port_tx_offload_result,
15837 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
15838 TOKEN_NUM_INITIALIZER
15839 (struct cmd_config_per_port_tx_offload_result,
15840 port_id, RTE_UINT16);
15841 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
15842 TOKEN_STRING_INITIALIZER
15843 (struct cmd_config_per_port_tx_offload_result,
15844 tx_offload, "tx_offload");
15845 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
15846 TOKEN_STRING_INITIALIZER
15847 (struct cmd_config_per_port_tx_offload_result,
15848 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
15849 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
15850 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
15851 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
15852 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
15853 "send_on_timestamp");
15854 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
15855 TOKEN_STRING_INITIALIZER
15856 (struct cmd_config_per_port_tx_offload_result,
15860 search_tx_offload(const char *name)
15862 uint64_t single_offload;
15863 const char *single_name;
15867 single_offload = 1;
15868 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
15869 single_name = rte_eth_dev_tx_offload_name(single_offload);
15870 if (single_name == NULL)
15872 if (!strcasecmp(single_name, name)) {
15875 } else if (!strcasecmp(single_name, "UNKNOWN"))
15877 single_offload <<= 1;
15881 return single_offload;
15887 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
15888 __rte_unused struct cmdline *cl,
15889 __rte_unused void *data)
15891 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
15892 portid_t port_id = res->port_id;
15893 struct rte_eth_dev_info dev_info;
15894 struct rte_port *port = &ports[port_id];
15895 uint64_t single_offload;
15896 uint16_t nb_tx_queues;
15900 if (port->port_status != RTE_PORT_STOPPED) {
15901 printf("Error: Can't config offload when Port %d "
15902 "is not stopped\n", port_id);
15906 single_offload = search_tx_offload(res->offload);
15907 if (single_offload == 0) {
15908 printf("Unknown offload name: %s\n", res->offload);
15912 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15916 nb_tx_queues = dev_info.nb_tx_queues;
15917 if (!strcmp(res->on_off, "on")) {
15918 port->dev_conf.txmode.offloads |= single_offload;
15919 for (q = 0; q < nb_tx_queues; q++)
15920 port->tx_conf[q].offloads |= single_offload;
15922 port->dev_conf.txmode.offloads &= ~single_offload;
15923 for (q = 0; q < nb_tx_queues; q++)
15924 port->tx_conf[q].offloads &= ~single_offload;
15927 cmd_reconfig_device_queue(port_id, 1, 1);
15930 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
15931 .f = cmd_config_per_port_tx_offload_parsed,
15933 .help_str = "port config <port_id> tx_offload "
15934 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
15935 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
15936 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
15937 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
15938 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
15939 "send_on_timestamp on|off",
15941 (void *)&cmd_config_per_port_tx_offload_result_port,
15942 (void *)&cmd_config_per_port_tx_offload_result_config,
15943 (void *)&cmd_config_per_port_tx_offload_result_port_id,
15944 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
15945 (void *)&cmd_config_per_port_tx_offload_result_offload,
15946 (void *)&cmd_config_per_port_tx_offload_result_on_off,
15951 /* Enable/Disable a per queue offloading */
15952 struct cmd_config_per_queue_tx_offload_result {
15953 cmdline_fixed_string_t port;
15955 cmdline_fixed_string_t txq;
15957 cmdline_fixed_string_t tx_offload;
15958 cmdline_fixed_string_t offload;
15959 cmdline_fixed_string_t on_off;
15962 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
15963 TOKEN_STRING_INITIALIZER
15964 (struct cmd_config_per_queue_tx_offload_result,
15966 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
15967 TOKEN_NUM_INITIALIZER
15968 (struct cmd_config_per_queue_tx_offload_result,
15969 port_id, RTE_UINT16);
15970 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
15971 TOKEN_STRING_INITIALIZER
15972 (struct cmd_config_per_queue_tx_offload_result,
15974 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
15975 TOKEN_NUM_INITIALIZER
15976 (struct cmd_config_per_queue_tx_offload_result,
15977 queue_id, RTE_UINT16);
15978 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
15979 TOKEN_STRING_INITIALIZER
15980 (struct cmd_config_per_queue_tx_offload_result,
15981 tx_offload, "tx_offload");
15982 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
15983 TOKEN_STRING_INITIALIZER
15984 (struct cmd_config_per_queue_tx_offload_result,
15985 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
15986 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
15987 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
15988 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
15989 "mt_lockfree#multi_segs#mbuf_fast_free#security");
15990 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
15991 TOKEN_STRING_INITIALIZER
15992 (struct cmd_config_per_queue_tx_offload_result,
15996 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
15997 __rte_unused struct cmdline *cl,
15998 __rte_unused void *data)
16000 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16001 struct rte_eth_dev_info dev_info;
16002 portid_t port_id = res->port_id;
16003 uint16_t queue_id = res->queue_id;
16004 struct rte_port *port = &ports[port_id];
16005 uint64_t single_offload;
16008 if (port->port_status != RTE_PORT_STOPPED) {
16009 printf("Error: Can't config offload when Port %d "
16010 "is not stopped\n", port_id);
16014 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16018 if (queue_id >= dev_info.nb_tx_queues) {
16019 printf("Error: input queue_id should be 0 ... "
16020 "%d\n", dev_info.nb_tx_queues - 1);
16024 single_offload = search_tx_offload(res->offload);
16025 if (single_offload == 0) {
16026 printf("Unknown offload name: %s\n", res->offload);
16030 if (!strcmp(res->on_off, "on"))
16031 port->tx_conf[queue_id].offloads |= single_offload;
16033 port->tx_conf[queue_id].offloads &= ~single_offload;
16035 cmd_reconfig_device_queue(port_id, 1, 1);
16038 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16039 .f = cmd_config_per_queue_tx_offload_parsed,
16041 .help_str = "port <port_id> txq <queue_id> tx_offload "
16042 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16043 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16044 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16045 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16046 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16049 (void *)&cmd_config_per_queue_tx_offload_result_port,
16050 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16051 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16052 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16053 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16054 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16055 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16060 /* *** configure tx_metadata for specific port *** */
16061 struct cmd_config_tx_metadata_specific_result {
16062 cmdline_fixed_string_t port;
16063 cmdline_fixed_string_t keyword;
16065 cmdline_fixed_string_t item;
16070 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16071 __rte_unused struct cmdline *cl,
16072 __rte_unused void *data)
16074 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16076 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16078 ports[res->port_id].tx_metadata = res->value;
16079 /* Add/remove callback to insert valid metadata in every Tx packet. */
16080 if (ports[res->port_id].tx_metadata)
16081 add_tx_md_callback(res->port_id);
16083 remove_tx_md_callback(res->port_id);
16084 rte_flow_dynf_metadata_register();
16087 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16088 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16090 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16091 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16092 keyword, "config");
16093 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16094 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16095 port_id, RTE_UINT16);
16096 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16097 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16098 item, "tx_metadata");
16099 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16100 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16101 value, RTE_UINT32);
16103 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16104 .f = cmd_config_tx_metadata_specific_parsed,
16106 .help_str = "port config <port_id> tx_metadata <value>",
16108 (void *)&cmd_config_tx_metadata_specific_port,
16109 (void *)&cmd_config_tx_metadata_specific_keyword,
16110 (void *)&cmd_config_tx_metadata_specific_id,
16111 (void *)&cmd_config_tx_metadata_specific_item,
16112 (void *)&cmd_config_tx_metadata_specific_value,
16117 /* *** set dynf *** */
16118 struct cmd_config_tx_dynf_specific_result {
16119 cmdline_fixed_string_t port;
16120 cmdline_fixed_string_t keyword;
16122 cmdline_fixed_string_t item;
16123 cmdline_fixed_string_t name;
16124 cmdline_fixed_string_t value;
16128 cmd_config_dynf_specific_parsed(void *parsed_result,
16129 __rte_unused struct cmdline *cl,
16130 __rte_unused void *data)
16132 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16133 struct rte_mbuf_dynflag desc_flag;
16135 uint64_t old_port_flags;
16137 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16139 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16141 if (strlcpy(desc_flag.name, res->name,
16142 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16143 printf("Flag name too long\n");
16146 desc_flag.flags = 0;
16147 flag = rte_mbuf_dynflag_register(&desc_flag);
16149 printf("Can't register flag\n");
16152 strcpy(dynf_names[flag], desc_flag.name);
16154 old_port_flags = ports[res->port_id].mbuf_dynf;
16155 if (!strcmp(res->value, "set")) {
16156 ports[res->port_id].mbuf_dynf |= 1UL << flag;
16157 if (old_port_flags == 0)
16158 add_tx_dynf_callback(res->port_id);
16160 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16161 if (ports[res->port_id].mbuf_dynf == 0)
16162 remove_tx_dynf_callback(res->port_id);
16166 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16167 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16169 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16170 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16171 keyword, "config");
16172 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
16173 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16174 port_id, RTE_UINT16);
16175 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
16176 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16178 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
16179 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16181 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
16182 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16183 value, "set#clear");
16185 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
16186 .f = cmd_config_dynf_specific_parsed,
16188 .help_str = "port config <port id> dynf <name> set|clear",
16190 (void *)&cmd_config_tx_dynf_specific_port,
16191 (void *)&cmd_config_tx_dynf_specific_keyword,
16192 (void *)&cmd_config_tx_dynf_specific_port_id,
16193 (void *)&cmd_config_tx_dynf_specific_item,
16194 (void *)&cmd_config_tx_dynf_specific_name,
16195 (void *)&cmd_config_tx_dynf_specific_value,
16200 /* *** display tx_metadata per port configuration *** */
16201 struct cmd_show_tx_metadata_result {
16202 cmdline_fixed_string_t cmd_show;
16203 cmdline_fixed_string_t cmd_port;
16204 cmdline_fixed_string_t cmd_keyword;
16209 cmd_show_tx_metadata_parsed(void *parsed_result,
16210 __rte_unused struct cmdline *cl,
16211 __rte_unused void *data)
16213 struct cmd_show_tx_metadata_result *res = parsed_result;
16215 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16216 printf("invalid port id %u\n", res->cmd_pid);
16219 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
16220 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
16221 ports[res->cmd_pid].tx_metadata);
16225 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
16226 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16228 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
16229 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16231 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
16232 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
16233 cmd_pid, RTE_UINT16);
16234 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
16235 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16236 cmd_keyword, "tx_metadata");
16238 cmdline_parse_inst_t cmd_show_tx_metadata = {
16239 .f = cmd_show_tx_metadata_parsed,
16241 .help_str = "show port <port_id> tx_metadata",
16243 (void *)&cmd_show_tx_metadata_show,
16244 (void *)&cmd_show_tx_metadata_port,
16245 (void *)&cmd_show_tx_metadata_pid,
16246 (void *)&cmd_show_tx_metadata_keyword,
16251 /* *** show fec capability per port configuration *** */
16252 struct cmd_show_fec_capability_result {
16253 cmdline_fixed_string_t cmd_show;
16254 cmdline_fixed_string_t cmd_port;
16255 cmdline_fixed_string_t cmd_fec;
16256 cmdline_fixed_string_t cmd_keyword;
16261 cmd_show_fec_capability_parsed(void *parsed_result,
16262 __rte_unused struct cmdline *cl,
16263 __rte_unused void *data)
16265 struct cmd_show_fec_capability_result *res = parsed_result;
16266 struct rte_eth_fec_capa *speed_fec_capa;
16270 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16271 printf("Invalid port id %u\n", res->cmd_pid);
16275 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
16276 if (ret == -ENOTSUP) {
16277 printf("Function not implemented\n");
16279 } else if (ret < 0) {
16280 printf("Get FEC capability failed: %d\n", ret);
16284 num = (unsigned int)ret;
16285 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
16286 if (speed_fec_capa == NULL) {
16287 printf("Failed to alloc FEC capability buffer\n");
16291 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
16293 printf("Error getting FEC capability: %d\n", ret);
16297 show_fec_capability(num, speed_fec_capa);
16299 free(speed_fec_capa);
16302 cmdline_parse_token_string_t cmd_show_fec_capability_show =
16303 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16305 cmdline_parse_token_string_t cmd_show_fec_capability_port =
16306 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16308 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
16309 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
16310 cmd_pid, RTE_UINT16);
16311 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
16312 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16314 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
16315 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16316 cmd_keyword, "capabilities");
16318 cmdline_parse_inst_t cmd_show_capability = {
16319 .f = cmd_show_fec_capability_parsed,
16321 .help_str = "show port <port_id> fec capabilities",
16323 (void *)&cmd_show_fec_capability_show,
16324 (void *)&cmd_show_fec_capability_port,
16325 (void *)&cmd_show_fec_capability_pid,
16326 (void *)&cmd_show_fec_capability_fec,
16327 (void *)&cmd_show_fec_capability_keyword,
16332 /* *** show fec mode per port configuration *** */
16333 struct cmd_show_fec_metadata_result {
16334 cmdline_fixed_string_t cmd_show;
16335 cmdline_fixed_string_t cmd_port;
16336 cmdline_fixed_string_t cmd_keyword;
16341 cmd_show_fec_mode_parsed(void *parsed_result,
16342 __rte_unused struct cmdline *cl,
16343 __rte_unused void *data)
16345 #define FEC_NAME_SIZE 16
16346 struct cmd_show_fec_metadata_result *res = parsed_result;
16348 char buf[FEC_NAME_SIZE];
16351 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16352 printf("Invalid port id %u\n", res->cmd_pid);
16355 ret = rte_eth_fec_get(res->cmd_pid, &mode);
16356 if (ret == -ENOTSUP) {
16357 printf("Function not implemented\n");
16359 } else if (ret < 0) {
16360 printf("Get FEC mode failed\n");
16365 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
16366 strlcpy(buf, "off", sizeof(buf));
16368 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
16369 strlcpy(buf, "auto", sizeof(buf));
16371 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
16372 strlcpy(buf, "baser", sizeof(buf));
16374 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
16375 strlcpy(buf, "rs", sizeof(buf));
16381 printf("%s\n", buf);
16384 cmdline_parse_token_string_t cmd_show_fec_mode_show =
16385 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16387 cmdline_parse_token_string_t cmd_show_fec_mode_port =
16388 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16390 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
16391 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
16392 cmd_pid, RTE_UINT16);
16393 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
16394 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16395 cmd_keyword, "fec_mode");
16397 cmdline_parse_inst_t cmd_show_fec_mode = {
16398 .f = cmd_show_fec_mode_parsed,
16400 .help_str = "show port <port_id> fec_mode",
16402 (void *)&cmd_show_fec_mode_show,
16403 (void *)&cmd_show_fec_mode_port,
16404 (void *)&cmd_show_fec_mode_pid,
16405 (void *)&cmd_show_fec_mode_keyword,
16410 /* *** set fec mode per port configuration *** */
16411 struct cmd_set_port_fec_mode {
16412 cmdline_fixed_string_t set;
16413 cmdline_fixed_string_t port;
16415 cmdline_fixed_string_t fec_mode;
16416 cmdline_fixed_string_t fec_value;
16419 /* Common CLI fields for set fec mode */
16420 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
16421 TOKEN_STRING_INITIALIZER
16422 (struct cmd_set_port_fec_mode,
16424 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
16425 TOKEN_STRING_INITIALIZER
16426 (struct cmd_set_port_fec_mode,
16428 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
16429 TOKEN_NUM_INITIALIZER
16430 (struct cmd_set_port_fec_mode,
16431 port_id, RTE_UINT16);
16432 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
16433 TOKEN_STRING_INITIALIZER
16434 (struct cmd_set_port_fec_mode,
16435 fec_mode, "fec_mode");
16436 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
16437 TOKEN_STRING_INITIALIZER
16438 (struct cmd_set_port_fec_mode,
16442 cmd_set_port_fec_mode_parsed(
16443 void *parsed_result,
16444 __rte_unused struct cmdline *cl,
16445 __rte_unused void *data)
16447 struct cmd_set_port_fec_mode *res = parsed_result;
16448 uint16_t port_id = res->port_id;
16452 ret = parse_fec_mode(res->fec_value, &mode);
16454 printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
16459 ret = rte_eth_fec_set(port_id, mode);
16460 if (ret == -ENOTSUP) {
16461 printf("Function not implemented\n");
16463 } else if (ret < 0) {
16464 printf("Set FEC mode failed\n");
16469 cmdline_parse_inst_t cmd_set_fec_mode = {
16470 .f = cmd_set_port_fec_mode_parsed,
16472 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
16474 (void *)&cmd_set_port_fec_mode_set,
16475 (void *)&cmd_set_port_fec_mode_port,
16476 (void *)&cmd_set_port_fec_mode_port_id,
16477 (void *)&cmd_set_port_fec_mode_str,
16478 (void *)&cmd_set_port_fec_mode_value,
16483 /* show port supported ptypes */
16485 /* Common result structure for show port ptypes */
16486 struct cmd_show_port_supported_ptypes_result {
16487 cmdline_fixed_string_t show;
16488 cmdline_fixed_string_t port;
16490 cmdline_fixed_string_t ptypes;
16493 /* Common CLI fields for show port ptypes */
16494 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
16495 TOKEN_STRING_INITIALIZER
16496 (struct cmd_show_port_supported_ptypes_result,
16498 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
16499 TOKEN_STRING_INITIALIZER
16500 (struct cmd_show_port_supported_ptypes_result,
16502 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
16503 TOKEN_NUM_INITIALIZER
16504 (struct cmd_show_port_supported_ptypes_result,
16505 port_id, RTE_UINT16);
16506 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
16507 TOKEN_STRING_INITIALIZER
16508 (struct cmd_show_port_supported_ptypes_result,
16512 cmd_show_port_supported_ptypes_parsed(
16513 void *parsed_result,
16514 __rte_unused struct cmdline *cl,
16515 __rte_unused void *data)
16517 #define RSVD_PTYPE_MASK 0xf0000000
16518 #define MAX_PTYPES_PER_LAYER 16
16519 #define LTYPE_NAMESIZE 32
16520 #define PTYPE_NAMESIZE 256
16521 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
16522 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
16523 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
16524 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
16525 uint16_t port_id = res->port_id;
16528 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
16532 while (ptype_mask != RSVD_PTYPE_MASK) {
16534 switch (ptype_mask) {
16535 case RTE_PTYPE_L2_MASK:
16536 strlcpy(ltype, "L2", sizeof(ltype));
16538 case RTE_PTYPE_L3_MASK:
16539 strlcpy(ltype, "L3", sizeof(ltype));
16541 case RTE_PTYPE_L4_MASK:
16542 strlcpy(ltype, "L4", sizeof(ltype));
16544 case RTE_PTYPE_TUNNEL_MASK:
16545 strlcpy(ltype, "Tunnel", sizeof(ltype));
16547 case RTE_PTYPE_INNER_L2_MASK:
16548 strlcpy(ltype, "Inner L2", sizeof(ltype));
16550 case RTE_PTYPE_INNER_L3_MASK:
16551 strlcpy(ltype, "Inner L3", sizeof(ltype));
16553 case RTE_PTYPE_INNER_L4_MASK:
16554 strlcpy(ltype, "Inner L4", sizeof(ltype));
16560 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
16561 ptype_mask, ptypes,
16562 MAX_PTYPES_PER_LAYER);
16565 printf("Supported %s ptypes:\n", ltype);
16567 printf("%s ptypes unsupported\n", ltype);
16569 for (i = 0; i < ret; ++i) {
16570 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
16571 printf("%s\n", buf);
16578 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
16579 .f = cmd_show_port_supported_ptypes_parsed,
16581 .help_str = "show port <port_id> ptypes",
16583 (void *)&cmd_show_port_supported_ptypes_show,
16584 (void *)&cmd_show_port_supported_ptypes_port,
16585 (void *)&cmd_show_port_supported_ptypes_port_id,
16586 (void *)&cmd_show_port_supported_ptypes_ptypes,
16591 /* *** display rx/tx descriptor status *** */
16592 struct cmd_show_rx_tx_desc_status_result {
16593 cmdline_fixed_string_t cmd_show;
16594 cmdline_fixed_string_t cmd_port;
16595 cmdline_fixed_string_t cmd_keyword;
16596 cmdline_fixed_string_t cmd_desc;
16597 cmdline_fixed_string_t cmd_status;
16604 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
16605 __rte_unused struct cmdline *cl,
16606 __rte_unused void *data)
16608 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
16611 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16612 printf("invalid port id %u\n", res->cmd_pid);
16616 if (!strcmp(res->cmd_keyword, "rxq")) {
16617 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
16620 printf("Invalid queueid = %d\n", res->cmd_qid);
16623 if (rc == RTE_ETH_RX_DESC_AVAIL)
16624 printf("Desc status = AVAILABLE\n");
16625 else if (rc == RTE_ETH_RX_DESC_DONE)
16626 printf("Desc status = DONE\n");
16628 printf("Desc status = UNAVAILABLE\n");
16629 } else if (!strcmp(res->cmd_keyword, "txq")) {
16630 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
16633 printf("Invalid queueid = %d\n", res->cmd_qid);
16636 if (rc == RTE_ETH_TX_DESC_FULL)
16637 printf("Desc status = FULL\n");
16638 else if (rc == RTE_ETH_TX_DESC_DONE)
16639 printf("Desc status = DONE\n");
16641 printf("Desc status = UNAVAILABLE\n");
16645 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
16646 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16648 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
16649 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16651 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
16652 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16653 cmd_pid, RTE_UINT16);
16654 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
16655 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16656 cmd_keyword, "rxq#txq");
16657 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
16658 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16659 cmd_qid, RTE_UINT16);
16660 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
16661 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16663 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
16664 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16665 cmd_did, RTE_UINT16);
16666 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
16667 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16668 cmd_status, "status");
16669 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
16670 .f = cmd_show_rx_tx_desc_status_parsed,
16672 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
16675 (void *)&cmd_show_rx_tx_desc_status_show,
16676 (void *)&cmd_show_rx_tx_desc_status_port,
16677 (void *)&cmd_show_rx_tx_desc_status_pid,
16678 (void *)&cmd_show_rx_tx_desc_status_keyword,
16679 (void *)&cmd_show_rx_tx_desc_status_qid,
16680 (void *)&cmd_show_rx_tx_desc_status_desc,
16681 (void *)&cmd_show_rx_tx_desc_status_did,
16682 (void *)&cmd_show_rx_tx_desc_status_status,
16687 /* Common result structure for set port ptypes */
16688 struct cmd_set_port_ptypes_result {
16689 cmdline_fixed_string_t set;
16690 cmdline_fixed_string_t port;
16692 cmdline_fixed_string_t ptype_mask;
16696 /* Common CLI fields for set port ptypes */
16697 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
16698 TOKEN_STRING_INITIALIZER
16699 (struct cmd_set_port_ptypes_result,
16701 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
16702 TOKEN_STRING_INITIALIZER
16703 (struct cmd_set_port_ptypes_result,
16705 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
16706 TOKEN_NUM_INITIALIZER
16707 (struct cmd_set_port_ptypes_result,
16708 port_id, RTE_UINT16);
16709 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
16710 TOKEN_STRING_INITIALIZER
16711 (struct cmd_set_port_ptypes_result,
16712 ptype_mask, "ptype_mask");
16713 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
16714 TOKEN_NUM_INITIALIZER
16715 (struct cmd_set_port_ptypes_result,
16719 cmd_set_port_ptypes_parsed(
16720 void *parsed_result,
16721 __rte_unused struct cmdline *cl,
16722 __rte_unused void *data)
16724 struct cmd_set_port_ptypes_result *res = parsed_result;
16725 #define PTYPE_NAMESIZE 256
16726 char ptype_name[PTYPE_NAMESIZE];
16727 uint16_t port_id = res->port_id;
16728 uint32_t ptype_mask = res->mask;
16731 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
16734 printf("Port %d doesn't support any ptypes.\n", port_id);
16738 uint32_t ptypes[ret];
16740 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
16742 printf("Unable to set requested ptypes for Port %d\n", port_id);
16746 printf("Successfully set following ptypes for Port %d\n", port_id);
16747 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
16748 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
16749 printf("%s\n", ptype_name);
16752 clear_ptypes = false;
16755 cmdline_parse_inst_t cmd_set_port_ptypes = {
16756 .f = cmd_set_port_ptypes_parsed,
16758 .help_str = "set port <port_id> ptype_mask <mask>",
16760 (void *)&cmd_set_port_ptypes_set,
16761 (void *)&cmd_set_port_ptypes_port,
16762 (void *)&cmd_set_port_ptypes_port_id,
16763 (void *)&cmd_set_port_ptypes_mask_str,
16764 (void *)&cmd_set_port_ptypes_mask_u32,
16769 /* *** display mac addresses added to a port *** */
16770 struct cmd_showport_macs_result {
16771 cmdline_fixed_string_t cmd_show;
16772 cmdline_fixed_string_t cmd_port;
16773 cmdline_fixed_string_t cmd_keyword;
16778 cmd_showport_macs_parsed(void *parsed_result,
16779 __rte_unused struct cmdline *cl,
16780 __rte_unused void *data)
16782 struct cmd_showport_macs_result *res = parsed_result;
16784 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
16787 if (!strcmp(res->cmd_keyword, "macs"))
16788 show_macs(res->cmd_pid);
16789 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
16790 show_mcast_macs(res->cmd_pid);
16793 cmdline_parse_token_string_t cmd_showport_macs_show =
16794 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
16796 cmdline_parse_token_string_t cmd_showport_macs_port =
16797 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
16799 cmdline_parse_token_num_t cmd_showport_macs_pid =
16800 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
16801 cmd_pid, RTE_UINT16);
16802 cmdline_parse_token_string_t cmd_showport_macs_keyword =
16803 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
16804 cmd_keyword, "macs#mcast_macs");
16806 cmdline_parse_inst_t cmd_showport_macs = {
16807 .f = cmd_showport_macs_parsed,
16809 .help_str = "show port <port_id> macs|mcast_macs",
16811 (void *)&cmd_showport_macs_show,
16812 (void *)&cmd_showport_macs_port,
16813 (void *)&cmd_showport_macs_pid,
16814 (void *)&cmd_showport_macs_keyword,
16819 /* ******************************************************************************** */
16821 /* list of instructions */
16822 cmdline_parse_ctx_t main_ctx[] = {
16823 (cmdline_parse_inst_t *)&cmd_help_brief,
16824 (cmdline_parse_inst_t *)&cmd_help_long,
16825 (cmdline_parse_inst_t *)&cmd_quit,
16826 (cmdline_parse_inst_t *)&cmd_load_from_file,
16827 (cmdline_parse_inst_t *)&cmd_showport,
16828 (cmdline_parse_inst_t *)&cmd_showqueue,
16829 (cmdline_parse_inst_t *)&cmd_showeeprom,
16830 (cmdline_parse_inst_t *)&cmd_showportall,
16831 (cmdline_parse_inst_t *)&cmd_showdevice,
16832 (cmdline_parse_inst_t *)&cmd_showcfg,
16833 (cmdline_parse_inst_t *)&cmd_showfwdall,
16834 (cmdline_parse_inst_t *)&cmd_start,
16835 (cmdline_parse_inst_t *)&cmd_start_tx_first,
16836 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
16837 (cmdline_parse_inst_t *)&cmd_set_link_up,
16838 (cmdline_parse_inst_t *)&cmd_set_link_down,
16839 (cmdline_parse_inst_t *)&cmd_reset,
16840 (cmdline_parse_inst_t *)&cmd_set_numbers,
16841 (cmdline_parse_inst_t *)&cmd_set_log,
16842 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
16843 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
16844 (cmdline_parse_inst_t *)&cmd_set_txpkts,
16845 (cmdline_parse_inst_t *)&cmd_set_txsplit,
16846 (cmdline_parse_inst_t *)&cmd_set_txtimes,
16847 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
16848 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
16849 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
16850 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
16851 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
16852 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
16853 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
16854 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
16855 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
16856 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
16857 (cmdline_parse_inst_t *)&cmd_set_link_check,
16858 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
16859 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
16860 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
16861 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
16862 #ifdef RTE_NET_BOND
16863 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
16864 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
16865 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
16866 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
16867 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
16868 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
16869 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
16870 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
16871 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
16872 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
16873 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
16875 (cmdline_parse_inst_t *)&cmd_vlan_offload,
16876 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
16877 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
16878 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
16879 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
16880 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
16881 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
16882 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
16883 (cmdline_parse_inst_t *)&cmd_csum_set,
16884 (cmdline_parse_inst_t *)&cmd_csum_show,
16885 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
16886 (cmdline_parse_inst_t *)&cmd_tso_set,
16887 (cmdline_parse_inst_t *)&cmd_tso_show,
16888 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
16889 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
16890 (cmdline_parse_inst_t *)&cmd_gro_enable,
16891 (cmdline_parse_inst_t *)&cmd_gro_flush,
16892 (cmdline_parse_inst_t *)&cmd_gro_show,
16893 (cmdline_parse_inst_t *)&cmd_gso_enable,
16894 (cmdline_parse_inst_t *)&cmd_gso_size,
16895 (cmdline_parse_inst_t *)&cmd_gso_show,
16896 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
16897 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
16898 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
16899 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
16900 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
16901 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
16902 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
16903 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
16904 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
16905 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
16906 (cmdline_parse_inst_t *)&cmd_config_dcb,
16907 (cmdline_parse_inst_t *)&cmd_read_reg,
16908 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
16909 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
16910 (cmdline_parse_inst_t *)&cmd_write_reg,
16911 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
16912 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
16913 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
16914 (cmdline_parse_inst_t *)&cmd_stop,
16915 (cmdline_parse_inst_t *)&cmd_mac_addr,
16916 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
16917 (cmdline_parse_inst_t *)&cmd_set_qmap,
16918 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
16919 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
16920 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
16921 (cmdline_parse_inst_t *)&cmd_operate_port,
16922 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
16923 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
16924 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
16925 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
16926 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
16927 (cmdline_parse_inst_t *)&cmd_config_speed_all,
16928 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
16929 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
16930 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
16931 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
16932 (cmdline_parse_inst_t *)&cmd_config_mtu,
16933 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
16934 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
16935 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
16936 (cmdline_parse_inst_t *)&cmd_config_rss,
16937 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
16938 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
16939 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
16940 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
16941 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
16942 (cmdline_parse_inst_t *)&cmd_showport_reta,
16943 (cmdline_parse_inst_t *)&cmd_showport_macs,
16944 (cmdline_parse_inst_t *)&cmd_config_burst,
16945 (cmdline_parse_inst_t *)&cmd_config_thresh,
16946 (cmdline_parse_inst_t *)&cmd_config_threshold,
16947 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
16948 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
16949 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
16950 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
16951 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
16952 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
16953 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
16954 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
16955 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
16956 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
16957 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
16958 (cmdline_parse_inst_t *)&cmd_dump,
16959 (cmdline_parse_inst_t *)&cmd_dump_one,
16960 #ifdef RTE_NET_I40E
16961 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
16963 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
16964 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
16965 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
16966 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
16967 (cmdline_parse_inst_t *)&cmd_flow,
16968 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
16969 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
16970 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
16971 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
16972 (cmdline_parse_inst_t *)&cmd_create_port_meter,
16973 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
16974 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
16975 (cmdline_parse_inst_t *)&cmd_del_port_meter,
16976 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
16977 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
16978 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
16979 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
16980 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
16981 (cmdline_parse_inst_t *)&cmd_mcast_addr,
16982 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
16983 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
16984 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
16985 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
16986 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
16987 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
16988 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
16989 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
16990 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
16991 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
16992 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
16993 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
16994 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
16995 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
16996 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
16997 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
16998 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
16999 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17000 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17001 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17002 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17003 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17004 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17005 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
17006 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
17007 (cmdline_parse_inst_t *)&cmd_set_vxlan,
17008 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
17009 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17010 (cmdline_parse_inst_t *)&cmd_set_nvgre,
17011 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17012 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
17013 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
17014 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
17015 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
17016 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
17017 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
17018 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
17019 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
17020 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
17021 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
17022 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
17023 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
17024 (cmdline_parse_inst_t *)&cmd_ddp_add,
17025 (cmdline_parse_inst_t *)&cmd_ddp_del,
17026 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
17027 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
17028 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
17029 (cmdline_parse_inst_t *)&cmd_clear_input_set,
17030 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
17031 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17032 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
17033 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
17034 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17035 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17036 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17037 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17039 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17040 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17041 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17042 (cmdline_parse_inst_t *)&cmd_queue_region,
17043 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17044 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17045 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17046 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17047 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17048 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17049 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17050 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17051 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17052 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17053 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17054 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17055 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17056 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17057 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17058 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17059 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17060 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
17061 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17062 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17063 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17064 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17065 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17066 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17067 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
17068 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
17069 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
17070 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17071 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17072 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17073 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17074 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17075 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17076 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17077 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17078 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17080 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17081 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17083 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
17084 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
17085 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
17086 (cmdline_parse_inst_t *)&cmd_set_raw,
17087 (cmdline_parse_inst_t *)&cmd_show_set_raw,
17088 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
17089 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
17090 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
17091 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
17092 (cmdline_parse_inst_t *)&cmd_show_capability,
17096 /* read cmdline commands from file */
17098 cmdline_read_from_file(const char *filename)
17100 struct cmdline *cl;
17102 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17104 printf("Failed to create file based cmdline context: %s\n",
17109 cmdline_interact(cl);
17114 printf("Read CLI commands from %s\n", filename);
17117 /* prompt function, called from main on MAIN lcore */
17121 /* initialize non-constant commands */
17122 cmd_set_fwd_mode_init();
17123 cmd_set_fwd_retry_mode_init();
17125 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17126 if (testpmd_cl == NULL)
17128 cmdline_interact(testpmd_cl);
17129 cmdline_stdin_exit(testpmd_cl);
17135 if (testpmd_cl != NULL)
17136 cmdline_quit(testpmd_cl);
17140 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17142 if (id == (portid_t)RTE_PORT_ALL) {
17145 RTE_ETH_FOREACH_DEV(pid) {
17146 /* check if need_reconfig has been set to 1 */
17147 if (ports[pid].need_reconfig == 0)
17148 ports[pid].need_reconfig = dev;
17149 /* check if need_reconfig_queues has been set to 1 */
17150 if (ports[pid].need_reconfig_queues == 0)
17151 ports[pid].need_reconfig_queues = queue;
17153 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17154 /* check if need_reconfig has been set to 1 */
17155 if (ports[id].need_reconfig == 0)
17156 ports[id].need_reconfig = dev;
17157 /* check if need_reconfig_queues has been set to 1 */
17158 if (ports[id].need_reconfig_queues == 0)
17159 ports[id].need_reconfig_queues = queue;