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|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, "none"))
2224 rss_conf.rss_hf = 0;
2225 else if (!strcmp(res->value, "level-default")) {
2226 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2227 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2228 } else if (!strcmp(res->value, "level-outer")) {
2229 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2230 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2231 } else if (!strcmp(res->value, "level-inner")) {
2232 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2233 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2234 } else if (!strcmp(res->value, "default"))
2236 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2237 atoi(res->value) < 64)
2238 rss_conf.rss_hf = 1ULL << atoi(res->value);
2240 printf("Unknown parameter\n");
2243 rss_conf.rss_key = NULL;
2244 /* Update global configuration for RSS types. */
2245 RTE_ETH_FOREACH_DEV(i) {
2246 struct rte_eth_rss_conf local_rss_conf;
2248 ret = eth_dev_info_get_print_err(i, &dev_info);
2253 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2255 local_rss_conf = rss_conf;
2256 local_rss_conf.rss_hf = rss_conf.rss_hf &
2257 dev_info.flow_type_rss_offloads;
2258 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2259 printf("Port %u modified RSS hash function based on hardware support,"
2260 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2261 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2263 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2266 printf("Configuration of RSS hash at ethernet port %d "
2267 "failed with error (%d): %s.\n",
2268 i, -diag, strerror(-diag));
2271 if (all_updated && !use_default) {
2272 rss_hf = rss_conf.rss_hf;
2273 printf("rss_hf %#"PRIx64"\n", rss_hf);
2277 cmdline_parse_token_string_t cmd_config_rss_port =
2278 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2279 cmdline_parse_token_string_t cmd_config_rss_keyword =
2280 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2281 cmdline_parse_token_string_t cmd_config_rss_all =
2282 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2283 cmdline_parse_token_string_t cmd_config_rss_name =
2284 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2285 cmdline_parse_token_string_t cmd_config_rss_value =
2286 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2288 cmdline_parse_inst_t cmd_config_rss = {
2289 .f = cmd_config_rss_parsed,
2291 .help_str = "port config all rss "
2292 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2293 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|none|level-default|"
2294 "level-outer|level-inner|<flowtype_id>",
2296 (void *)&cmd_config_rss_port,
2297 (void *)&cmd_config_rss_keyword,
2298 (void *)&cmd_config_rss_all,
2299 (void *)&cmd_config_rss_name,
2300 (void *)&cmd_config_rss_value,
2305 /* *** configure rss hash key *** */
2306 struct cmd_config_rss_hash_key {
2307 cmdline_fixed_string_t port;
2308 cmdline_fixed_string_t config;
2310 cmdline_fixed_string_t rss_hash_key;
2311 cmdline_fixed_string_t rss_type;
2312 cmdline_fixed_string_t key;
2316 hexa_digit_to_value(char hexa_digit)
2318 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2319 return (uint8_t) (hexa_digit - '0');
2320 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2321 return (uint8_t) ((hexa_digit - 'a') + 10);
2322 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2323 return (uint8_t) ((hexa_digit - 'A') + 10);
2324 /* Invalid hexa digit */
2329 parse_and_check_key_hexa_digit(char *key, int idx)
2333 hexa_v = hexa_digit_to_value(key[idx]);
2335 printf("invalid key: character %c at position %d is not a "
2336 "valid hexa digit\n", key[idx], idx);
2341 cmd_config_rss_hash_key_parsed(void *parsed_result,
2342 __rte_unused struct cmdline *cl,
2343 __rte_unused void *data)
2345 struct cmd_config_rss_hash_key *res = parsed_result;
2346 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2350 struct rte_eth_dev_info dev_info;
2351 uint8_t hash_key_size;
2355 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2359 if (dev_info.hash_key_size > 0 &&
2360 dev_info.hash_key_size <= sizeof(hash_key))
2361 hash_key_size = dev_info.hash_key_size;
2363 printf("dev_info did not provide a valid hash key size\n");
2366 /* Check the length of the RSS hash key */
2367 key_len = strlen(res->key);
2368 if (key_len != (hash_key_size * 2)) {
2369 printf("key length: %d invalid - key must be a string of %d"
2370 " hexa-decimal numbers\n",
2371 (int) key_len, hash_key_size * 2);
2374 /* Translate RSS hash key into binary representation */
2375 for (i = 0; i < hash_key_size; i++) {
2376 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2379 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2382 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2384 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2388 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2389 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2390 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2391 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2393 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2394 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2396 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2397 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2398 rss_hash_key, "rss-hash-key");
2399 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2400 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2401 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2402 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2403 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2404 "ipv6-tcp-ex#ipv6-udp-ex#"
2405 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2406 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2407 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri");
2408 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2409 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2411 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2412 .f = cmd_config_rss_hash_key_parsed,
2414 .help_str = "port config <port_id> rss-hash-key "
2415 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2416 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2417 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2418 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2419 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2420 "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri "
2421 "<string of hex digits (variable length, NIC dependent)>",
2423 (void *)&cmd_config_rss_hash_key_port,
2424 (void *)&cmd_config_rss_hash_key_config,
2425 (void *)&cmd_config_rss_hash_key_port_id,
2426 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2427 (void *)&cmd_config_rss_hash_key_rss_type,
2428 (void *)&cmd_config_rss_hash_key_value,
2433 /* *** configure port rxq/txq ring size *** */
2434 struct cmd_config_rxtx_ring_size {
2435 cmdline_fixed_string_t port;
2436 cmdline_fixed_string_t config;
2438 cmdline_fixed_string_t rxtxq;
2440 cmdline_fixed_string_t rsize;
2445 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2446 __rte_unused struct cmdline *cl,
2447 __rte_unused void *data)
2449 struct cmd_config_rxtx_ring_size *res = parsed_result;
2450 struct rte_port *port;
2453 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2456 if (res->portid == (portid_t)RTE_PORT_ALL) {
2457 printf("Invalid port id\n");
2461 port = &ports[res->portid];
2463 if (!strcmp(res->rxtxq, "rxq"))
2465 else if (!strcmp(res->rxtxq, "txq"))
2468 printf("Unknown parameter\n");
2472 if (isrx && rx_queue_id_is_invalid(res->qid))
2474 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2477 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2478 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2484 port->nb_rx_desc[res->qid] = res->size;
2486 port->nb_tx_desc[res->qid] = res->size;
2488 cmd_reconfig_device_queue(res->portid, 0, 1);
2491 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2492 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2494 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2495 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2497 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2498 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2499 portid, RTE_UINT16);
2500 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2501 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2503 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2504 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2506 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2507 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2508 rsize, "ring_size");
2509 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2510 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2513 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2514 .f = cmd_config_rxtx_ring_size_parsed,
2516 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2518 (void *)&cmd_config_rxtx_ring_size_port,
2519 (void *)&cmd_config_rxtx_ring_size_config,
2520 (void *)&cmd_config_rxtx_ring_size_portid,
2521 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2522 (void *)&cmd_config_rxtx_ring_size_qid,
2523 (void *)&cmd_config_rxtx_ring_size_rsize,
2524 (void *)&cmd_config_rxtx_ring_size_size,
2529 /* *** configure port rxq/txq start/stop *** */
2530 struct cmd_config_rxtx_queue {
2531 cmdline_fixed_string_t port;
2533 cmdline_fixed_string_t rxtxq;
2535 cmdline_fixed_string_t opname;
2539 cmd_config_rxtx_queue_parsed(void *parsed_result,
2540 __rte_unused struct cmdline *cl,
2541 __rte_unused void *data)
2543 struct cmd_config_rxtx_queue *res = parsed_result;
2548 if (test_done == 0) {
2549 printf("Please stop forwarding first\n");
2553 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2556 if (port_is_started(res->portid) != 1) {
2557 printf("Please start port %u first\n", res->portid);
2561 if (!strcmp(res->rxtxq, "rxq"))
2563 else if (!strcmp(res->rxtxq, "txq"))
2566 printf("Unknown parameter\n");
2570 if (isrx && rx_queue_id_is_invalid(res->qid))
2572 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2575 if (!strcmp(res->opname, "start"))
2577 else if (!strcmp(res->opname, "stop"))
2580 printf("Unknown parameter\n");
2584 if (isstart && isrx)
2585 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2586 else if (!isstart && isrx)
2587 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2588 else if (isstart && !isrx)
2589 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2591 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2593 if (ret == -ENOTSUP)
2594 printf("Function not supported in PMD driver\n");
2597 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2598 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2599 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2600 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2601 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2602 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2603 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2604 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2605 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2606 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2609 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2610 .f = cmd_config_rxtx_queue_parsed,
2612 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2614 (void *)&cmd_config_rxtx_queue_port,
2615 (void *)&cmd_config_rxtx_queue_portid,
2616 (void *)&cmd_config_rxtx_queue_rxtxq,
2617 (void *)&cmd_config_rxtx_queue_qid,
2618 (void *)&cmd_config_rxtx_queue_opname,
2623 /* *** configure port rxq/txq deferred start on/off *** */
2624 struct cmd_config_deferred_start_rxtx_queue {
2625 cmdline_fixed_string_t port;
2627 cmdline_fixed_string_t rxtxq;
2629 cmdline_fixed_string_t opname;
2630 cmdline_fixed_string_t state;
2634 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2635 __rte_unused struct cmdline *cl,
2636 __rte_unused void *data)
2638 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2639 struct rte_port *port;
2642 uint8_t needreconfig = 0;
2644 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2647 if (port_is_started(res->port_id) != 0) {
2648 printf("Please stop port %u first\n", res->port_id);
2652 port = &ports[res->port_id];
2654 isrx = !strcmp(res->rxtxq, "rxq");
2656 if (isrx && rx_queue_id_is_invalid(res->qid))
2658 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2661 ison = !strcmp(res->state, "on");
2663 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2664 port->rx_conf[res->qid].rx_deferred_start = ison;
2666 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2667 port->tx_conf[res->qid].tx_deferred_start = ison;
2672 cmd_reconfig_device_queue(res->port_id, 0, 1);
2675 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2676 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2678 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2679 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2680 port_id, RTE_UINT16);
2681 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2682 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2684 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2685 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2687 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2688 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2689 opname, "deferred_start");
2690 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2691 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2694 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2695 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2697 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2699 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2700 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2701 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2702 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2703 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2704 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2709 /* *** configure port rxq/txq setup *** */
2710 struct cmd_setup_rxtx_queue {
2711 cmdline_fixed_string_t port;
2713 cmdline_fixed_string_t rxtxq;
2715 cmdline_fixed_string_t setup;
2718 /* Common CLI fields for queue setup */
2719 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2720 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2721 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2722 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2723 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2724 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2725 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2726 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2727 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2728 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2731 cmd_setup_rxtx_queue_parsed(
2732 void *parsed_result,
2733 __rte_unused struct cmdline *cl,
2734 __rte_unused void *data)
2736 struct cmd_setup_rxtx_queue *res = parsed_result;
2737 struct rte_port *port;
2738 struct rte_mempool *mp;
2739 unsigned int socket_id;
2743 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2746 if (res->portid == (portid_t)RTE_PORT_ALL) {
2747 printf("Invalid port id\n");
2751 if (!strcmp(res->rxtxq, "rxq"))
2753 else if (!strcmp(res->rxtxq, "txq"))
2756 printf("Unknown parameter\n");
2760 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2761 printf("Invalid rx queue\n");
2763 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2764 printf("Invalid tx queue\n");
2768 port = &ports[res->portid];
2770 socket_id = rxring_numa[res->portid];
2771 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2772 socket_id = port->socket_id;
2774 mp = mbuf_pool_find(socket_id, 0);
2776 printf("Failed to setup RX queue: "
2777 "No mempool allocation"
2778 " on the socket %d\n",
2779 rxring_numa[res->portid]);
2782 ret = rx_queue_setup(res->portid,
2784 port->nb_rx_desc[res->qid],
2786 &port->rx_conf[res->qid],
2789 printf("Failed to setup RX queue\n");
2791 socket_id = txring_numa[res->portid];
2792 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2793 socket_id = port->socket_id;
2795 ret = rte_eth_tx_queue_setup(res->portid,
2797 port->nb_tx_desc[res->qid],
2799 &port->tx_conf[res->qid]);
2801 printf("Failed to setup TX queue\n");
2805 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2806 .f = cmd_setup_rxtx_queue_parsed,
2808 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2810 (void *)&cmd_setup_rxtx_queue_port,
2811 (void *)&cmd_setup_rxtx_queue_portid,
2812 (void *)&cmd_setup_rxtx_queue_rxtxq,
2813 (void *)&cmd_setup_rxtx_queue_qid,
2814 (void *)&cmd_setup_rxtx_queue_setup,
2820 /* *** Configure RSS RETA *** */
2821 struct cmd_config_rss_reta {
2822 cmdline_fixed_string_t port;
2823 cmdline_fixed_string_t keyword;
2825 cmdline_fixed_string_t name;
2826 cmdline_fixed_string_t list_name;
2827 cmdline_fixed_string_t list_of_items;
2831 parse_reta_config(const char *str,
2832 struct rte_eth_rss_reta_entry64 *reta_conf,
2833 uint16_t nb_entries)
2837 uint16_t hash_index, idx, shift;
2840 const char *p, *p0 = str;
2847 unsigned long int_fld[_NUM_FLD];
2848 char *str_fld[_NUM_FLD];
2850 while ((p = strchr(p0,'(')) != NULL) {
2852 if((p0 = strchr(p,')')) == NULL)
2856 if(size >= sizeof(s))
2859 snprintf(s, sizeof(s), "%.*s", size, p);
2860 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2862 for (i = 0; i < _NUM_FLD; i++) {
2864 int_fld[i] = strtoul(str_fld[i], &end, 0);
2865 if (errno != 0 || end == str_fld[i] ||
2870 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2871 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2873 if (hash_index >= nb_entries) {
2874 printf("Invalid RETA hash index=%d\n", hash_index);
2878 idx = hash_index / RTE_RETA_GROUP_SIZE;
2879 shift = hash_index % RTE_RETA_GROUP_SIZE;
2880 reta_conf[idx].mask |= (1ULL << shift);
2881 reta_conf[idx].reta[shift] = nb_queue;
2888 cmd_set_rss_reta_parsed(void *parsed_result,
2889 __rte_unused struct cmdline *cl,
2890 __rte_unused void *data)
2893 struct rte_eth_dev_info dev_info;
2894 struct rte_eth_rss_reta_entry64 reta_conf[8];
2895 struct cmd_config_rss_reta *res = parsed_result;
2897 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2901 if (dev_info.reta_size == 0) {
2902 printf("Redirection table size is 0 which is "
2903 "invalid for RSS\n");
2906 printf("The reta size of port %d is %u\n",
2907 res->port_id, dev_info.reta_size);
2908 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2909 printf("Currently do not support more than %u entries of "
2910 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2914 memset(reta_conf, 0, sizeof(reta_conf));
2915 if (!strcmp(res->list_name, "reta")) {
2916 if (parse_reta_config(res->list_of_items, reta_conf,
2917 dev_info.reta_size)) {
2918 printf("Invalid RSS Redirection Table "
2919 "config entered\n");
2922 ret = rte_eth_dev_rss_reta_update(res->port_id,
2923 reta_conf, dev_info.reta_size);
2925 printf("Bad redirection table parameter, "
2926 "return code = %d \n", ret);
2930 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2931 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2932 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2933 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2934 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2935 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
2936 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2937 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2938 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2939 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2940 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2941 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2943 cmdline_parse_inst_t cmd_config_rss_reta = {
2944 .f = cmd_set_rss_reta_parsed,
2946 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2948 (void *)&cmd_config_rss_reta_port,
2949 (void *)&cmd_config_rss_reta_keyword,
2950 (void *)&cmd_config_rss_reta_port_id,
2951 (void *)&cmd_config_rss_reta_name,
2952 (void *)&cmd_config_rss_reta_list_name,
2953 (void *)&cmd_config_rss_reta_list_of_items,
2958 /* *** SHOW PORT RETA INFO *** */
2959 struct cmd_showport_reta {
2960 cmdline_fixed_string_t show;
2961 cmdline_fixed_string_t port;
2963 cmdline_fixed_string_t rss;
2964 cmdline_fixed_string_t reta;
2966 cmdline_fixed_string_t list_of_items;
2970 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2971 uint16_t nb_entries,
2975 const char *p, *p0 = str;
2980 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2981 RTE_RETA_GROUP_SIZE;
2984 p = strchr(p0, '(');
2988 p0 = strchr(p, ')');
2992 if (size >= sizeof(s)) {
2993 printf("The string size exceeds the internal buffer size\n");
2996 snprintf(s, sizeof(s), "%.*s", size, p);
2997 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2998 if (ret <= 0 || ret != num) {
2999 printf("The bits of masks do not match the number of "
3000 "reta entries: %u\n", num);
3003 for (i = 0; i < ret; i++)
3004 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3010 cmd_showport_reta_parsed(void *parsed_result,
3011 __rte_unused struct cmdline *cl,
3012 __rte_unused void *data)
3014 struct cmd_showport_reta *res = parsed_result;
3015 struct rte_eth_rss_reta_entry64 reta_conf[8];
3016 struct rte_eth_dev_info dev_info;
3017 uint16_t max_reta_size;
3020 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3024 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3025 if (res->size == 0 || res->size > max_reta_size) {
3026 printf("Invalid redirection table size: %u (1-%u)\n",
3027 res->size, max_reta_size);
3031 memset(reta_conf, 0, sizeof(reta_conf));
3032 if (showport_parse_reta_config(reta_conf, res->size,
3033 res->list_of_items) < 0) {
3034 printf("Invalid string: %s for reta masks\n",
3035 res->list_of_items);
3038 port_rss_reta_info(res->port_id, reta_conf, res->size);
3041 cmdline_parse_token_string_t cmd_showport_reta_show =
3042 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3043 cmdline_parse_token_string_t cmd_showport_reta_port =
3044 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3045 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3046 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3047 cmdline_parse_token_string_t cmd_showport_reta_rss =
3048 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3049 cmdline_parse_token_string_t cmd_showport_reta_reta =
3050 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3051 cmdline_parse_token_num_t cmd_showport_reta_size =
3052 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3053 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3054 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3055 list_of_items, NULL);
3057 cmdline_parse_inst_t cmd_showport_reta = {
3058 .f = cmd_showport_reta_parsed,
3060 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3062 (void *)&cmd_showport_reta_show,
3063 (void *)&cmd_showport_reta_port,
3064 (void *)&cmd_showport_reta_port_id,
3065 (void *)&cmd_showport_reta_rss,
3066 (void *)&cmd_showport_reta_reta,
3067 (void *)&cmd_showport_reta_size,
3068 (void *)&cmd_showport_reta_list_of_items,
3073 /* *** Show RSS hash configuration *** */
3074 struct cmd_showport_rss_hash {
3075 cmdline_fixed_string_t show;
3076 cmdline_fixed_string_t port;
3078 cmdline_fixed_string_t rss_hash;
3079 cmdline_fixed_string_t rss_type;
3080 cmdline_fixed_string_t key; /* optional argument */
3083 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3084 __rte_unused struct cmdline *cl,
3087 struct cmd_showport_rss_hash *res = parsed_result;
3089 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3092 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3093 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3094 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3095 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3096 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3097 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3099 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3100 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3102 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3103 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3105 cmdline_parse_inst_t cmd_showport_rss_hash = {
3106 .f = cmd_showport_rss_hash_parsed,
3108 .help_str = "show port <port_id> rss-hash",
3110 (void *)&cmd_showport_rss_hash_show,
3111 (void *)&cmd_showport_rss_hash_port,
3112 (void *)&cmd_showport_rss_hash_port_id,
3113 (void *)&cmd_showport_rss_hash_rss_hash,
3118 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3119 .f = cmd_showport_rss_hash_parsed,
3121 .help_str = "show port <port_id> rss-hash key",
3123 (void *)&cmd_showport_rss_hash_show,
3124 (void *)&cmd_showport_rss_hash_port,
3125 (void *)&cmd_showport_rss_hash_port_id,
3126 (void *)&cmd_showport_rss_hash_rss_hash,
3127 (void *)&cmd_showport_rss_hash_rss_key,
3132 /* *** Configure DCB *** */
3133 struct cmd_config_dcb {
3134 cmdline_fixed_string_t port;
3135 cmdline_fixed_string_t config;
3137 cmdline_fixed_string_t dcb;
3138 cmdline_fixed_string_t vt;
3139 cmdline_fixed_string_t vt_en;
3141 cmdline_fixed_string_t pfc;
3142 cmdline_fixed_string_t pfc_en;
3146 cmd_config_dcb_parsed(void *parsed_result,
3147 __rte_unused struct cmdline *cl,
3148 __rte_unused void *data)
3150 struct cmd_config_dcb *res = parsed_result;
3151 portid_t port_id = res->port_id;
3152 struct rte_port *port;
3156 port = &ports[port_id];
3157 /** Check if the port is not started **/
3158 if (port->port_status != RTE_PORT_STOPPED) {
3159 printf("Please stop port %d first\n", port_id);
3163 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3164 printf("The invalid number of traffic class,"
3165 " only 4 or 8 allowed.\n");
3169 if (nb_fwd_lcores < res->num_tcs) {
3170 printf("nb_cores shouldn't be less than number of TCs.\n");
3173 if (!strncmp(res->pfc_en, "on", 2))
3178 /* DCB in VT mode */
3179 if (!strncmp(res->vt_en, "on", 2))
3180 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3181 (enum rte_eth_nb_tcs)res->num_tcs,
3184 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3185 (enum rte_eth_nb_tcs)res->num_tcs,
3190 printf("Cannot initialize network ports.\n");
3194 cmd_reconfig_device_queue(port_id, 1, 1);
3197 cmdline_parse_token_string_t cmd_config_dcb_port =
3198 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3199 cmdline_parse_token_string_t cmd_config_dcb_config =
3200 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3201 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3202 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3203 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3204 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3205 cmdline_parse_token_string_t cmd_config_dcb_vt =
3206 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3207 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3208 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3209 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3210 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3211 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3212 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3213 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3214 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3216 cmdline_parse_inst_t cmd_config_dcb = {
3217 .f = cmd_config_dcb_parsed,
3219 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3221 (void *)&cmd_config_dcb_port,
3222 (void *)&cmd_config_dcb_config,
3223 (void *)&cmd_config_dcb_port_id,
3224 (void *)&cmd_config_dcb_dcb,
3225 (void *)&cmd_config_dcb_vt,
3226 (void *)&cmd_config_dcb_vt_en,
3227 (void *)&cmd_config_dcb_num_tcs,
3228 (void *)&cmd_config_dcb_pfc,
3229 (void *)&cmd_config_dcb_pfc_en,
3234 /* *** configure number of packets per burst *** */
3235 struct cmd_config_burst {
3236 cmdline_fixed_string_t port;
3237 cmdline_fixed_string_t keyword;
3238 cmdline_fixed_string_t all;
3239 cmdline_fixed_string_t name;
3244 cmd_config_burst_parsed(void *parsed_result,
3245 __rte_unused struct cmdline *cl,
3246 __rte_unused void *data)
3248 struct cmd_config_burst *res = parsed_result;
3249 struct rte_eth_dev_info dev_info;
3250 uint16_t rec_nb_pkts;
3253 if (!all_ports_stopped()) {
3254 printf("Please stop all ports first\n");
3258 if (!strcmp(res->name, "burst")) {
3259 if (res->value == 0) {
3260 /* If user gives a value of zero, query the PMD for
3261 * its recommended Rx burst size. Testpmd uses a single
3262 * size for all ports, so assume all ports are the same
3263 * NIC model and use the values from Port 0.
3265 ret = eth_dev_info_get_print_err(0, &dev_info);
3269 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3271 if (rec_nb_pkts == 0) {
3272 printf("PMD does not recommend a burst size.\n"
3273 "User provided value must be between"
3274 " 1 and %d\n", MAX_PKT_BURST);
3276 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3277 printf("PMD recommended burst size of %d"
3278 " exceeds maximum value of %d\n",
3279 rec_nb_pkts, MAX_PKT_BURST);
3282 printf("Using PMD-provided burst value of %d\n",
3284 nb_pkt_per_burst = rec_nb_pkts;
3285 } else if (res->value > MAX_PKT_BURST) {
3286 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3289 nb_pkt_per_burst = res->value;
3291 printf("Unknown parameter\n");
3297 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3300 cmdline_parse_token_string_t cmd_config_burst_port =
3301 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3302 cmdline_parse_token_string_t cmd_config_burst_keyword =
3303 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3304 cmdline_parse_token_string_t cmd_config_burst_all =
3305 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3306 cmdline_parse_token_string_t cmd_config_burst_name =
3307 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3308 cmdline_parse_token_num_t cmd_config_burst_value =
3309 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3311 cmdline_parse_inst_t cmd_config_burst = {
3312 .f = cmd_config_burst_parsed,
3314 .help_str = "port config all burst <value>",
3316 (void *)&cmd_config_burst_port,
3317 (void *)&cmd_config_burst_keyword,
3318 (void *)&cmd_config_burst_all,
3319 (void *)&cmd_config_burst_name,
3320 (void *)&cmd_config_burst_value,
3325 /* *** configure rx/tx queues *** */
3326 struct cmd_config_thresh {
3327 cmdline_fixed_string_t port;
3328 cmdline_fixed_string_t keyword;
3329 cmdline_fixed_string_t all;
3330 cmdline_fixed_string_t name;
3335 cmd_config_thresh_parsed(void *parsed_result,
3336 __rte_unused struct cmdline *cl,
3337 __rte_unused void *data)
3339 struct cmd_config_thresh *res = parsed_result;
3341 if (!all_ports_stopped()) {
3342 printf("Please stop all ports first\n");
3346 if (!strcmp(res->name, "txpt"))
3347 tx_pthresh = res->value;
3348 else if(!strcmp(res->name, "txht"))
3349 tx_hthresh = res->value;
3350 else if(!strcmp(res->name, "txwt"))
3351 tx_wthresh = res->value;
3352 else if(!strcmp(res->name, "rxpt"))
3353 rx_pthresh = res->value;
3354 else if(!strcmp(res->name, "rxht"))
3355 rx_hthresh = res->value;
3356 else if(!strcmp(res->name, "rxwt"))
3357 rx_wthresh = res->value;
3359 printf("Unknown parameter\n");
3365 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3368 cmdline_parse_token_string_t cmd_config_thresh_port =
3369 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3370 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3371 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3372 cmdline_parse_token_string_t cmd_config_thresh_all =
3373 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3374 cmdline_parse_token_string_t cmd_config_thresh_name =
3375 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3376 "txpt#txht#txwt#rxpt#rxht#rxwt");
3377 cmdline_parse_token_num_t cmd_config_thresh_value =
3378 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3380 cmdline_parse_inst_t cmd_config_thresh = {
3381 .f = cmd_config_thresh_parsed,
3383 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3385 (void *)&cmd_config_thresh_port,
3386 (void *)&cmd_config_thresh_keyword,
3387 (void *)&cmd_config_thresh_all,
3388 (void *)&cmd_config_thresh_name,
3389 (void *)&cmd_config_thresh_value,
3394 /* *** configure free/rs threshold *** */
3395 struct cmd_config_threshold {
3396 cmdline_fixed_string_t port;
3397 cmdline_fixed_string_t keyword;
3398 cmdline_fixed_string_t all;
3399 cmdline_fixed_string_t name;
3404 cmd_config_threshold_parsed(void *parsed_result,
3405 __rte_unused struct cmdline *cl,
3406 __rte_unused void *data)
3408 struct cmd_config_threshold *res = parsed_result;
3410 if (!all_ports_stopped()) {
3411 printf("Please stop all ports first\n");
3415 if (!strcmp(res->name, "txfreet"))
3416 tx_free_thresh = res->value;
3417 else if (!strcmp(res->name, "txrst"))
3418 tx_rs_thresh = res->value;
3419 else if (!strcmp(res->name, "rxfreet"))
3420 rx_free_thresh = res->value;
3422 printf("Unknown parameter\n");
3428 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3431 cmdline_parse_token_string_t cmd_config_threshold_port =
3432 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3433 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3434 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3436 cmdline_parse_token_string_t cmd_config_threshold_all =
3437 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3438 cmdline_parse_token_string_t cmd_config_threshold_name =
3439 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3440 "txfreet#txrst#rxfreet");
3441 cmdline_parse_token_num_t cmd_config_threshold_value =
3442 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3444 cmdline_parse_inst_t cmd_config_threshold = {
3445 .f = cmd_config_threshold_parsed,
3447 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3449 (void *)&cmd_config_threshold_port,
3450 (void *)&cmd_config_threshold_keyword,
3451 (void *)&cmd_config_threshold_all,
3452 (void *)&cmd_config_threshold_name,
3453 (void *)&cmd_config_threshold_value,
3459 struct cmd_stop_result {
3460 cmdline_fixed_string_t stop;
3463 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3464 __rte_unused struct cmdline *cl,
3465 __rte_unused void *data)
3467 stop_packet_forwarding();
3470 cmdline_parse_token_string_t cmd_stop_stop =
3471 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3473 cmdline_parse_inst_t cmd_stop = {
3474 .f = cmd_stop_parsed,
3476 .help_str = "stop: Stop packet forwarding",
3478 (void *)&cmd_stop_stop,
3483 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3486 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3487 unsigned int *parsed_items, int check_unique_values)
3489 unsigned int nb_item;
3497 * First parse all items in the list and store their value.
3502 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3504 if ((c >= '0') && (c <= '9')) {
3505 value = (unsigned int) (value * 10 + (c - '0'));
3510 printf("character %c is not a decimal digit\n", c);
3514 printf("No valid value before comma\n");
3517 if (nb_item < max_items) {
3518 parsed_items[nb_item] = value;
3524 if (nb_item >= max_items) {
3525 printf("Number of %s = %u > %u (maximum items)\n",
3526 item_name, nb_item + 1, max_items);
3529 parsed_items[nb_item++] = value;
3530 if (! check_unique_values)
3534 * Then, check that all values in the list are differents.
3535 * No optimization here...
3537 for (i = 0; i < nb_item; i++) {
3538 for (j = i + 1; j < nb_item; j++) {
3539 if (parsed_items[j] == parsed_items[i]) {
3540 printf("duplicated %s %u at index %u and %u\n",
3541 item_name, parsed_items[i], i, j);
3549 struct cmd_set_list_result {
3550 cmdline_fixed_string_t cmd_keyword;
3551 cmdline_fixed_string_t list_name;
3552 cmdline_fixed_string_t list_of_items;
3555 static void cmd_set_list_parsed(void *parsed_result,
3556 __rte_unused struct cmdline *cl,
3557 __rte_unused void *data)
3559 struct cmd_set_list_result *res;
3561 unsigned int lcorelist[RTE_MAX_LCORE];
3562 unsigned int portlist[RTE_MAX_ETHPORTS];
3564 unsigned int nb_item;
3566 if (test_done == 0) {
3567 printf("Please stop forwarding first\n");
3571 res = parsed_result;
3572 if (!strcmp(res->list_name, "corelist")) {
3573 nb_item = parse_item_list(res->list_of_items, "core",
3575 parsed_items.lcorelist, 1);
3577 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3582 if (!strcmp(res->list_name, "portlist")) {
3583 nb_item = parse_item_list(res->list_of_items, "port",
3585 parsed_items.portlist, 1);
3587 set_fwd_ports_list(parsed_items.portlist, nb_item);
3593 cmdline_parse_token_string_t cmd_set_list_keyword =
3594 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3596 cmdline_parse_token_string_t cmd_set_list_name =
3597 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3598 "corelist#portlist");
3599 cmdline_parse_token_string_t cmd_set_list_of_items =
3600 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3603 cmdline_parse_inst_t cmd_set_fwd_list = {
3604 .f = cmd_set_list_parsed,
3606 .help_str = "set corelist|portlist <list0[,list1]*>",
3608 (void *)&cmd_set_list_keyword,
3609 (void *)&cmd_set_list_name,
3610 (void *)&cmd_set_list_of_items,
3615 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3617 struct cmd_setmask_result {
3618 cmdline_fixed_string_t set;
3619 cmdline_fixed_string_t mask;
3623 static void cmd_set_mask_parsed(void *parsed_result,
3624 __rte_unused struct cmdline *cl,
3625 __rte_unused void *data)
3627 struct cmd_setmask_result *res = parsed_result;
3629 if (test_done == 0) {
3630 printf("Please stop forwarding first\n");
3633 if (!strcmp(res->mask, "coremask")) {
3634 set_fwd_lcores_mask(res->hexavalue);
3636 } else if (!strcmp(res->mask, "portmask")) {
3637 set_fwd_ports_mask(res->hexavalue);
3642 cmdline_parse_token_string_t cmd_setmask_set =
3643 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3644 cmdline_parse_token_string_t cmd_setmask_mask =
3645 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3646 "coremask#portmask");
3647 cmdline_parse_token_num_t cmd_setmask_value =
3648 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3650 cmdline_parse_inst_t cmd_set_fwd_mask = {
3651 .f = cmd_set_mask_parsed,
3653 .help_str = "set coremask|portmask <hexadecimal value>",
3655 (void *)&cmd_setmask_set,
3656 (void *)&cmd_setmask_mask,
3657 (void *)&cmd_setmask_value,
3663 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3665 struct cmd_set_result {
3666 cmdline_fixed_string_t set;
3667 cmdline_fixed_string_t what;
3671 static void cmd_set_parsed(void *parsed_result,
3672 __rte_unused struct cmdline *cl,
3673 __rte_unused void *data)
3675 struct cmd_set_result *res = parsed_result;
3676 if (!strcmp(res->what, "nbport")) {
3677 set_fwd_ports_number(res->value);
3679 } else if (!strcmp(res->what, "nbcore")) {
3680 set_fwd_lcores_number(res->value);
3682 } else if (!strcmp(res->what, "burst"))
3683 set_nb_pkt_per_burst(res->value);
3684 else if (!strcmp(res->what, "verbose"))
3685 set_verbose_level(res->value);
3688 cmdline_parse_token_string_t cmd_set_set =
3689 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3690 cmdline_parse_token_string_t cmd_set_what =
3691 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3692 "nbport#nbcore#burst#verbose");
3693 cmdline_parse_token_num_t cmd_set_value =
3694 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3696 cmdline_parse_inst_t cmd_set_numbers = {
3697 .f = cmd_set_parsed,
3699 .help_str = "set nbport|nbcore|burst|verbose <value>",
3701 (void *)&cmd_set_set,
3702 (void *)&cmd_set_what,
3703 (void *)&cmd_set_value,
3708 /* *** SET LOG LEVEL CONFIGURATION *** */
3710 struct cmd_set_log_result {
3711 cmdline_fixed_string_t set;
3712 cmdline_fixed_string_t log;
3713 cmdline_fixed_string_t type;
3718 cmd_set_log_parsed(void *parsed_result,
3719 __rte_unused struct cmdline *cl,
3720 __rte_unused void *data)
3722 struct cmd_set_log_result *res;
3725 res = parsed_result;
3726 if (!strcmp(res->type, "global"))
3727 rte_log_set_global_level(res->level);
3729 ret = rte_log_set_level_regexp(res->type, res->level);
3731 printf("Unable to set log level\n");
3735 cmdline_parse_token_string_t cmd_set_log_set =
3736 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3737 cmdline_parse_token_string_t cmd_set_log_log =
3738 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3739 cmdline_parse_token_string_t cmd_set_log_type =
3740 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3741 cmdline_parse_token_num_t cmd_set_log_level =
3742 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3744 cmdline_parse_inst_t cmd_set_log = {
3745 .f = cmd_set_log_parsed,
3747 .help_str = "set log global|<type> <level>",
3749 (void *)&cmd_set_log_set,
3750 (void *)&cmd_set_log_log,
3751 (void *)&cmd_set_log_type,
3752 (void *)&cmd_set_log_level,
3757 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3759 struct cmd_set_rxoffs_result {
3760 cmdline_fixed_string_t cmd_keyword;
3761 cmdline_fixed_string_t rxoffs;
3762 cmdline_fixed_string_t seg_offsets;
3766 cmd_set_rxoffs_parsed(void *parsed_result,
3767 __rte_unused struct cmdline *cl,
3768 __rte_unused void *data)
3770 struct cmd_set_rxoffs_result *res;
3771 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3772 unsigned int nb_segs;
3774 res = parsed_result;
3775 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3776 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3778 set_rx_pkt_offsets(seg_offsets, nb_segs);
3781 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3782 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3783 cmd_keyword, "set");
3784 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3785 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3787 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3788 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3791 cmdline_parse_inst_t cmd_set_rxoffs = {
3792 .f = cmd_set_rxoffs_parsed,
3794 .help_str = "set rxoffs <len0[,len1]*>",
3796 (void *)&cmd_set_rxoffs_keyword,
3797 (void *)&cmd_set_rxoffs_name,
3798 (void *)&cmd_set_rxoffs_offsets,
3803 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3805 struct cmd_set_rxpkts_result {
3806 cmdline_fixed_string_t cmd_keyword;
3807 cmdline_fixed_string_t rxpkts;
3808 cmdline_fixed_string_t seg_lengths;
3812 cmd_set_rxpkts_parsed(void *parsed_result,
3813 __rte_unused struct cmdline *cl,
3814 __rte_unused void *data)
3816 struct cmd_set_rxpkts_result *res;
3817 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3818 unsigned int nb_segs;
3820 res = parsed_result;
3821 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3822 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3824 set_rx_pkt_segments(seg_lengths, nb_segs);
3827 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3828 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3829 cmd_keyword, "set");
3830 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3831 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3833 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3834 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3837 cmdline_parse_inst_t cmd_set_rxpkts = {
3838 .f = cmd_set_rxpkts_parsed,
3840 .help_str = "set rxpkts <len0[,len1]*>",
3842 (void *)&cmd_set_rxpkts_keyword,
3843 (void *)&cmd_set_rxpkts_name,
3844 (void *)&cmd_set_rxpkts_lengths,
3849 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3851 struct cmd_set_txpkts_result {
3852 cmdline_fixed_string_t cmd_keyword;
3853 cmdline_fixed_string_t txpkts;
3854 cmdline_fixed_string_t seg_lengths;
3858 cmd_set_txpkts_parsed(void *parsed_result,
3859 __rte_unused struct cmdline *cl,
3860 __rte_unused void *data)
3862 struct cmd_set_txpkts_result *res;
3863 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3864 unsigned int nb_segs;
3866 res = parsed_result;
3867 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3868 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3870 set_tx_pkt_segments(seg_lengths, nb_segs);
3873 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3874 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3875 cmd_keyword, "set");
3876 cmdline_parse_token_string_t cmd_set_txpkts_name =
3877 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3879 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3880 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3883 cmdline_parse_inst_t cmd_set_txpkts = {
3884 .f = cmd_set_txpkts_parsed,
3886 .help_str = "set txpkts <len0[,len1]*>",
3888 (void *)&cmd_set_txpkts_keyword,
3889 (void *)&cmd_set_txpkts_name,
3890 (void *)&cmd_set_txpkts_lengths,
3895 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3897 struct cmd_set_txsplit_result {
3898 cmdline_fixed_string_t cmd_keyword;
3899 cmdline_fixed_string_t txsplit;
3900 cmdline_fixed_string_t mode;
3904 cmd_set_txsplit_parsed(void *parsed_result,
3905 __rte_unused struct cmdline *cl,
3906 __rte_unused void *data)
3908 struct cmd_set_txsplit_result *res;
3910 res = parsed_result;
3911 set_tx_pkt_split(res->mode);
3914 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3915 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3916 cmd_keyword, "set");
3917 cmdline_parse_token_string_t cmd_set_txsplit_name =
3918 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3919 txsplit, "txsplit");
3920 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3921 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3924 cmdline_parse_inst_t cmd_set_txsplit = {
3925 .f = cmd_set_txsplit_parsed,
3927 .help_str = "set txsplit on|off|rand",
3929 (void *)&cmd_set_txsplit_keyword,
3930 (void *)&cmd_set_txsplit_name,
3931 (void *)&cmd_set_txsplit_mode,
3936 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
3938 struct cmd_set_txtimes_result {
3939 cmdline_fixed_string_t cmd_keyword;
3940 cmdline_fixed_string_t txtimes;
3941 cmdline_fixed_string_t tx_times;
3945 cmd_set_txtimes_parsed(void *parsed_result,
3946 __rte_unused struct cmdline *cl,
3947 __rte_unused void *data)
3949 struct cmd_set_txtimes_result *res;
3950 unsigned int tx_times[2] = {0, 0};
3951 unsigned int n_times;
3953 res = parsed_result;
3954 n_times = parse_item_list(res->tx_times, "tx times",
3957 set_tx_pkt_times(tx_times);
3960 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
3961 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3962 cmd_keyword, "set");
3963 cmdline_parse_token_string_t cmd_set_txtimes_name =
3964 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3965 txtimes, "txtimes");
3966 cmdline_parse_token_string_t cmd_set_txtimes_value =
3967 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3970 cmdline_parse_inst_t cmd_set_txtimes = {
3971 .f = cmd_set_txtimes_parsed,
3973 .help_str = "set txtimes <inter_burst>,<intra_burst>",
3975 (void *)&cmd_set_txtimes_keyword,
3976 (void *)&cmd_set_txtimes_name,
3977 (void *)&cmd_set_txtimes_value,
3982 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3983 struct cmd_rx_vlan_filter_all_result {
3984 cmdline_fixed_string_t rx_vlan;
3985 cmdline_fixed_string_t what;
3986 cmdline_fixed_string_t all;
3991 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3992 __rte_unused struct cmdline *cl,
3993 __rte_unused void *data)
3995 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3997 if (!strcmp(res->what, "add"))
3998 rx_vlan_all_filter_set(res->port_id, 1);
4000 rx_vlan_all_filter_set(res->port_id, 0);
4003 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4004 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4005 rx_vlan, "rx_vlan");
4006 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4007 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4009 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4010 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4012 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4013 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4014 port_id, RTE_UINT16);
4016 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4017 .f = cmd_rx_vlan_filter_all_parsed,
4019 .help_str = "rx_vlan add|rm all <port_id>: "
4020 "Add/Remove all identifiers to/from the set of VLAN "
4021 "identifiers filtered by a port",
4023 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4024 (void *)&cmd_rx_vlan_filter_all_what,
4025 (void *)&cmd_rx_vlan_filter_all_all,
4026 (void *)&cmd_rx_vlan_filter_all_portid,
4031 /* *** VLAN OFFLOAD SET ON A PORT *** */
4032 struct cmd_vlan_offload_result {
4033 cmdline_fixed_string_t vlan;
4034 cmdline_fixed_string_t set;
4035 cmdline_fixed_string_t vlan_type;
4036 cmdline_fixed_string_t what;
4037 cmdline_fixed_string_t on;
4038 cmdline_fixed_string_t port_id;
4042 cmd_vlan_offload_parsed(void *parsed_result,
4043 __rte_unused struct cmdline *cl,
4044 __rte_unused void *data)
4047 struct cmd_vlan_offload_result *res = parsed_result;
4050 portid_t port_id = 0;
4054 len = strnlen(str, STR_TOKEN_SIZE);
4056 /* Get port_id first */
4064 tmp = strtoul(str, NULL, 0);
4065 /* If port_id greater that what portid_t can represent, return */
4066 if(tmp >= RTE_MAX_ETHPORTS)
4068 port_id = (portid_t)tmp;
4070 if (!strcmp(res->on, "on"))
4075 if (!strcmp(res->what, "strip"))
4076 rx_vlan_strip_set(port_id, on);
4077 else if(!strcmp(res->what, "stripq")){
4078 uint16_t queue_id = 0;
4080 /* No queue_id, return */
4082 printf("must specify (port,queue_id)\n");
4085 tmp = strtoul(str + i + 1, NULL, 0);
4086 /* If queue_id greater that what 16-bits can represent, return */
4090 queue_id = (uint16_t)tmp;
4091 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4093 else if (!strcmp(res->what, "filter"))
4094 rx_vlan_filter_set(port_id, on);
4095 else if (!strcmp(res->what, "qinq_strip"))
4096 rx_vlan_qinq_strip_set(port_id, on);
4098 vlan_extend_set(port_id, on);
4103 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4104 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4106 cmdline_parse_token_string_t cmd_vlan_offload_set =
4107 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4109 cmdline_parse_token_string_t cmd_vlan_offload_what =
4110 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4111 what, "strip#filter#qinq_strip#extend#stripq");
4112 cmdline_parse_token_string_t cmd_vlan_offload_on =
4113 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4115 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4116 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4119 cmdline_parse_inst_t cmd_vlan_offload = {
4120 .f = cmd_vlan_offload_parsed,
4122 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4123 "<port_id[,queue_id]>: "
4124 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4126 (void *)&cmd_vlan_offload_vlan,
4127 (void *)&cmd_vlan_offload_set,
4128 (void *)&cmd_vlan_offload_what,
4129 (void *)&cmd_vlan_offload_on,
4130 (void *)&cmd_vlan_offload_portid,
4135 /* *** VLAN TPID SET ON A PORT *** */
4136 struct cmd_vlan_tpid_result {
4137 cmdline_fixed_string_t vlan;
4138 cmdline_fixed_string_t set;
4139 cmdline_fixed_string_t vlan_type;
4140 cmdline_fixed_string_t what;
4146 cmd_vlan_tpid_parsed(void *parsed_result,
4147 __rte_unused struct cmdline *cl,
4148 __rte_unused void *data)
4150 struct cmd_vlan_tpid_result *res = parsed_result;
4151 enum rte_vlan_type vlan_type;
4153 if (!strcmp(res->vlan_type, "inner"))
4154 vlan_type = ETH_VLAN_TYPE_INNER;
4155 else if (!strcmp(res->vlan_type, "outer"))
4156 vlan_type = ETH_VLAN_TYPE_OUTER;
4158 printf("Unknown vlan type\n");
4161 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4164 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4165 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4167 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4168 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4170 cmdline_parse_token_string_t cmd_vlan_type =
4171 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4172 vlan_type, "inner#outer");
4173 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4174 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4176 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4177 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4179 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4180 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4181 port_id, RTE_UINT16);
4183 cmdline_parse_inst_t cmd_vlan_tpid = {
4184 .f = cmd_vlan_tpid_parsed,
4186 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4187 "Set the VLAN Ether type",
4189 (void *)&cmd_vlan_tpid_vlan,
4190 (void *)&cmd_vlan_tpid_set,
4191 (void *)&cmd_vlan_type,
4192 (void *)&cmd_vlan_tpid_what,
4193 (void *)&cmd_vlan_tpid_tpid,
4194 (void *)&cmd_vlan_tpid_portid,
4199 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4200 struct cmd_rx_vlan_filter_result {
4201 cmdline_fixed_string_t rx_vlan;
4202 cmdline_fixed_string_t what;
4208 cmd_rx_vlan_filter_parsed(void *parsed_result,
4209 __rte_unused struct cmdline *cl,
4210 __rte_unused void *data)
4212 struct cmd_rx_vlan_filter_result *res = parsed_result;
4214 if (!strcmp(res->what, "add"))
4215 rx_vft_set(res->port_id, res->vlan_id, 1);
4217 rx_vft_set(res->port_id, res->vlan_id, 0);
4220 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4221 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4222 rx_vlan, "rx_vlan");
4223 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4224 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4226 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4227 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4228 vlan_id, RTE_UINT16);
4229 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4230 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4231 port_id, RTE_UINT16);
4233 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4234 .f = cmd_rx_vlan_filter_parsed,
4236 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4237 "Add/Remove a VLAN identifier to/from the set of VLAN "
4238 "identifiers filtered by a port",
4240 (void *)&cmd_rx_vlan_filter_rx_vlan,
4241 (void *)&cmd_rx_vlan_filter_what,
4242 (void *)&cmd_rx_vlan_filter_vlanid,
4243 (void *)&cmd_rx_vlan_filter_portid,
4248 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4249 struct cmd_tx_vlan_set_result {
4250 cmdline_fixed_string_t tx_vlan;
4251 cmdline_fixed_string_t set;
4257 cmd_tx_vlan_set_parsed(void *parsed_result,
4258 __rte_unused struct cmdline *cl,
4259 __rte_unused void *data)
4261 struct cmd_tx_vlan_set_result *res = parsed_result;
4263 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4266 if (!port_is_stopped(res->port_id)) {
4267 printf("Please stop port %d first\n", res->port_id);
4271 tx_vlan_set(res->port_id, res->vlan_id);
4273 cmd_reconfig_device_queue(res->port_id, 1, 1);
4276 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4277 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4278 tx_vlan, "tx_vlan");
4279 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4280 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4282 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4283 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4284 port_id, RTE_UINT16);
4285 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4286 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4287 vlan_id, RTE_UINT16);
4289 cmdline_parse_inst_t cmd_tx_vlan_set = {
4290 .f = cmd_tx_vlan_set_parsed,
4292 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4293 "Enable hardware insertion of a single VLAN header "
4294 "with a given TAG Identifier in packets sent on a port",
4296 (void *)&cmd_tx_vlan_set_tx_vlan,
4297 (void *)&cmd_tx_vlan_set_set,
4298 (void *)&cmd_tx_vlan_set_portid,
4299 (void *)&cmd_tx_vlan_set_vlanid,
4304 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4305 struct cmd_tx_vlan_set_qinq_result {
4306 cmdline_fixed_string_t tx_vlan;
4307 cmdline_fixed_string_t set;
4310 uint16_t vlan_id_outer;
4314 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4315 __rte_unused struct cmdline *cl,
4316 __rte_unused void *data)
4318 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4320 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4323 if (!port_is_stopped(res->port_id)) {
4324 printf("Please stop port %d first\n", res->port_id);
4328 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4330 cmd_reconfig_device_queue(res->port_id, 1, 1);
4333 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4334 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4335 tx_vlan, "tx_vlan");
4336 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4337 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4339 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4340 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4341 port_id, RTE_UINT16);
4342 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4343 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4344 vlan_id, RTE_UINT16);
4345 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4346 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4347 vlan_id_outer, RTE_UINT16);
4349 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4350 .f = cmd_tx_vlan_set_qinq_parsed,
4352 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4353 "Enable hardware insertion of double VLAN header "
4354 "with given TAG Identifiers in packets sent on a port",
4356 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4357 (void *)&cmd_tx_vlan_set_qinq_set,
4358 (void *)&cmd_tx_vlan_set_qinq_portid,
4359 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4360 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4365 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4366 struct cmd_tx_vlan_set_pvid_result {
4367 cmdline_fixed_string_t tx_vlan;
4368 cmdline_fixed_string_t set;
4369 cmdline_fixed_string_t pvid;
4372 cmdline_fixed_string_t mode;
4376 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4377 __rte_unused struct cmdline *cl,
4378 __rte_unused void *data)
4380 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4382 if (strcmp(res->mode, "on") == 0)
4383 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4385 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4388 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4389 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4390 tx_vlan, "tx_vlan");
4391 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4392 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4394 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4395 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4397 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4398 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4399 port_id, RTE_UINT16);
4400 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4401 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4402 vlan_id, RTE_UINT16);
4403 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4404 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4407 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4408 .f = cmd_tx_vlan_set_pvid_parsed,
4410 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4412 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4413 (void *)&cmd_tx_vlan_set_pvid_set,
4414 (void *)&cmd_tx_vlan_set_pvid_pvid,
4415 (void *)&cmd_tx_vlan_set_pvid_port_id,
4416 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4417 (void *)&cmd_tx_vlan_set_pvid_mode,
4422 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4423 struct cmd_tx_vlan_reset_result {
4424 cmdline_fixed_string_t tx_vlan;
4425 cmdline_fixed_string_t reset;
4430 cmd_tx_vlan_reset_parsed(void *parsed_result,
4431 __rte_unused struct cmdline *cl,
4432 __rte_unused void *data)
4434 struct cmd_tx_vlan_reset_result *res = parsed_result;
4436 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4439 if (!port_is_stopped(res->port_id)) {
4440 printf("Please stop port %d first\n", res->port_id);
4444 tx_vlan_reset(res->port_id);
4446 cmd_reconfig_device_queue(res->port_id, 1, 1);
4449 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4450 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4451 tx_vlan, "tx_vlan");
4452 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4453 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4455 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4456 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4457 port_id, RTE_UINT16);
4459 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4460 .f = cmd_tx_vlan_reset_parsed,
4462 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4463 "VLAN header in packets sent on a port",
4465 (void *)&cmd_tx_vlan_reset_tx_vlan,
4466 (void *)&cmd_tx_vlan_reset_reset,
4467 (void *)&cmd_tx_vlan_reset_portid,
4473 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4474 struct cmd_csum_result {
4475 cmdline_fixed_string_t csum;
4476 cmdline_fixed_string_t mode;
4477 cmdline_fixed_string_t proto;
4478 cmdline_fixed_string_t hwsw;
4483 csum_show(int port_id)
4485 struct rte_eth_dev_info dev_info;
4486 uint64_t tx_offloads;
4489 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4490 printf("Parse tunnel is %s\n",
4491 (ports[port_id].parse_tunnel) ? "on" : "off");
4492 printf("IP checksum offload is %s\n",
4493 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4494 printf("UDP checksum offload is %s\n",
4495 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4496 printf("TCP checksum offload is %s\n",
4497 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4498 printf("SCTP checksum offload is %s\n",
4499 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4500 printf("Outer-Ip checksum offload is %s\n",
4501 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4502 printf("Outer-Udp checksum offload is %s\n",
4503 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4505 /* display warnings if configuration is not supported by the NIC */
4506 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4510 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4511 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4512 printf("Warning: hardware IP checksum enabled but not "
4513 "supported by port %d\n", port_id);
4515 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4516 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4517 printf("Warning: hardware UDP checksum enabled but not "
4518 "supported by port %d\n", port_id);
4520 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4521 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4522 printf("Warning: hardware TCP checksum enabled but not "
4523 "supported by port %d\n", port_id);
4525 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4526 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4527 printf("Warning: hardware SCTP checksum enabled but not "
4528 "supported by port %d\n", port_id);
4530 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4531 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4532 printf("Warning: hardware outer IP checksum enabled but not "
4533 "supported by port %d\n", port_id);
4535 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4536 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4538 printf("Warning: hardware outer UDP checksum enabled but not "
4539 "supported by port %d\n", port_id);
4544 cmd_config_queue_tx_offloads(struct rte_port *port)
4548 /* Apply queue tx offloads configuration */
4549 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4550 port->tx_conf[k].offloads =
4551 port->dev_conf.txmode.offloads;
4555 cmd_csum_parsed(void *parsed_result,
4556 __rte_unused struct cmdline *cl,
4557 __rte_unused void *data)
4559 struct cmd_csum_result *res = parsed_result;
4561 uint64_t csum_offloads = 0;
4562 struct rte_eth_dev_info dev_info;
4565 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4566 printf("invalid port %d\n", res->port_id);
4569 if (!port_is_stopped(res->port_id)) {
4570 printf("Please stop port %d first\n", res->port_id);
4574 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4578 if (!strcmp(res->mode, "set")) {
4580 if (!strcmp(res->hwsw, "hw"))
4583 if (!strcmp(res->proto, "ip")) {
4584 if (hw == 0 || (dev_info.tx_offload_capa &
4585 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4586 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4588 printf("IP checksum offload is not supported "
4589 "by port %u\n", res->port_id);
4591 } else if (!strcmp(res->proto, "udp")) {
4592 if (hw == 0 || (dev_info.tx_offload_capa &
4593 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4594 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4596 printf("UDP checksum offload is not supported "
4597 "by port %u\n", res->port_id);
4599 } else if (!strcmp(res->proto, "tcp")) {
4600 if (hw == 0 || (dev_info.tx_offload_capa &
4601 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4602 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4604 printf("TCP checksum offload is not supported "
4605 "by port %u\n", res->port_id);
4607 } else if (!strcmp(res->proto, "sctp")) {
4608 if (hw == 0 || (dev_info.tx_offload_capa &
4609 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4610 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4612 printf("SCTP checksum offload is not supported "
4613 "by port %u\n", res->port_id);
4615 } else if (!strcmp(res->proto, "outer-ip")) {
4616 if (hw == 0 || (dev_info.tx_offload_capa &
4617 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4619 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4621 printf("Outer IP checksum offload is not "
4622 "supported by port %u\n", res->port_id);
4624 } else if (!strcmp(res->proto, "outer-udp")) {
4625 if (hw == 0 || (dev_info.tx_offload_capa &
4626 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4628 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4630 printf("Outer UDP checksum offload is not "
4631 "supported by port %u\n", res->port_id);
4636 ports[res->port_id].dev_conf.txmode.offloads |=
4639 ports[res->port_id].dev_conf.txmode.offloads &=
4642 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4644 csum_show(res->port_id);
4646 cmd_reconfig_device_queue(res->port_id, 1, 1);
4649 cmdline_parse_token_string_t cmd_csum_csum =
4650 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4652 cmdline_parse_token_string_t cmd_csum_mode =
4653 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4655 cmdline_parse_token_string_t cmd_csum_proto =
4656 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4657 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4658 cmdline_parse_token_string_t cmd_csum_hwsw =
4659 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4661 cmdline_parse_token_num_t cmd_csum_portid =
4662 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4663 port_id, RTE_UINT16);
4665 cmdline_parse_inst_t cmd_csum_set = {
4666 .f = cmd_csum_parsed,
4668 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4669 "Enable/Disable hardware calculation of L3/L4 checksum when "
4670 "using csum forward engine",
4672 (void *)&cmd_csum_csum,
4673 (void *)&cmd_csum_mode,
4674 (void *)&cmd_csum_proto,
4675 (void *)&cmd_csum_hwsw,
4676 (void *)&cmd_csum_portid,
4681 cmdline_parse_token_string_t cmd_csum_mode_show =
4682 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4685 cmdline_parse_inst_t cmd_csum_show = {
4686 .f = cmd_csum_parsed,
4688 .help_str = "csum show <port_id>: Show checksum offload configuration",
4690 (void *)&cmd_csum_csum,
4691 (void *)&cmd_csum_mode_show,
4692 (void *)&cmd_csum_portid,
4697 /* Enable/disable tunnel parsing */
4698 struct cmd_csum_tunnel_result {
4699 cmdline_fixed_string_t csum;
4700 cmdline_fixed_string_t parse;
4701 cmdline_fixed_string_t onoff;
4706 cmd_csum_tunnel_parsed(void *parsed_result,
4707 __rte_unused struct cmdline *cl,
4708 __rte_unused void *data)
4710 struct cmd_csum_tunnel_result *res = parsed_result;
4712 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4715 if (!strcmp(res->onoff, "on"))
4716 ports[res->port_id].parse_tunnel = 1;
4718 ports[res->port_id].parse_tunnel = 0;
4720 csum_show(res->port_id);
4723 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4724 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4726 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4727 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4728 parse, "parse-tunnel");
4729 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4730 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4732 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4733 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4734 port_id, RTE_UINT16);
4736 cmdline_parse_inst_t cmd_csum_tunnel = {
4737 .f = cmd_csum_tunnel_parsed,
4739 .help_str = "csum parse-tunnel on|off <port_id>: "
4740 "Enable/Disable parsing of tunnels for csum engine",
4742 (void *)&cmd_csum_tunnel_csum,
4743 (void *)&cmd_csum_tunnel_parse,
4744 (void *)&cmd_csum_tunnel_onoff,
4745 (void *)&cmd_csum_tunnel_portid,
4750 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4751 struct cmd_tso_set_result {
4752 cmdline_fixed_string_t tso;
4753 cmdline_fixed_string_t mode;
4759 cmd_tso_set_parsed(void *parsed_result,
4760 __rte_unused struct cmdline *cl,
4761 __rte_unused void *data)
4763 struct cmd_tso_set_result *res = parsed_result;
4764 struct rte_eth_dev_info dev_info;
4767 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4769 if (!port_is_stopped(res->port_id)) {
4770 printf("Please stop port %d first\n", res->port_id);
4774 if (!strcmp(res->mode, "set"))
4775 ports[res->port_id].tso_segsz = res->tso_segsz;
4777 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4781 if ((ports[res->port_id].tso_segsz != 0) &&
4782 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4783 printf("Error: TSO is not supported by port %d\n",
4788 if (ports[res->port_id].tso_segsz == 0) {
4789 ports[res->port_id].dev_conf.txmode.offloads &=
4790 ~DEV_TX_OFFLOAD_TCP_TSO;
4791 printf("TSO for non-tunneled packets is disabled\n");
4793 ports[res->port_id].dev_conf.txmode.offloads |=
4794 DEV_TX_OFFLOAD_TCP_TSO;
4795 printf("TSO segment size for non-tunneled packets is %d\n",
4796 ports[res->port_id].tso_segsz);
4798 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4800 /* display warnings if configuration is not supported by the NIC */
4801 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4805 if ((ports[res->port_id].tso_segsz != 0) &&
4806 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4807 printf("Warning: TSO enabled but not "
4808 "supported by port %d\n", res->port_id);
4811 cmd_reconfig_device_queue(res->port_id, 1, 1);
4814 cmdline_parse_token_string_t cmd_tso_set_tso =
4815 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4817 cmdline_parse_token_string_t cmd_tso_set_mode =
4818 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4820 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4821 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4822 tso_segsz, RTE_UINT16);
4823 cmdline_parse_token_num_t cmd_tso_set_portid =
4824 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4825 port_id, RTE_UINT16);
4827 cmdline_parse_inst_t cmd_tso_set = {
4828 .f = cmd_tso_set_parsed,
4830 .help_str = "tso set <tso_segsz> <port_id>: "
4831 "Set TSO segment size of non-tunneled packets for csum engine "
4834 (void *)&cmd_tso_set_tso,
4835 (void *)&cmd_tso_set_mode,
4836 (void *)&cmd_tso_set_tso_segsz,
4837 (void *)&cmd_tso_set_portid,
4842 cmdline_parse_token_string_t cmd_tso_show_mode =
4843 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4847 cmdline_parse_inst_t cmd_tso_show = {
4848 .f = cmd_tso_set_parsed,
4850 .help_str = "tso show <port_id>: "
4851 "Show TSO segment size of non-tunneled packets for csum engine",
4853 (void *)&cmd_tso_set_tso,
4854 (void *)&cmd_tso_show_mode,
4855 (void *)&cmd_tso_set_portid,
4860 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4861 struct cmd_tunnel_tso_set_result {
4862 cmdline_fixed_string_t tso;
4863 cmdline_fixed_string_t mode;
4868 static struct rte_eth_dev_info
4869 check_tunnel_tso_nic_support(portid_t port_id)
4871 struct rte_eth_dev_info dev_info;
4873 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4876 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4877 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4878 "not enabled for port %d\n", port_id);
4879 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4880 printf("Warning: GRE TUNNEL TSO not supported therefore "
4881 "not enabled for port %d\n", port_id);
4882 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4883 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4884 "not enabled for port %d\n", port_id);
4885 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4886 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4887 "not enabled for port %d\n", port_id);
4888 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4889 printf("Warning: IP TUNNEL TSO not supported therefore "
4890 "not enabled for port %d\n", port_id);
4891 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4892 printf("Warning: UDP TUNNEL TSO not supported therefore "
4893 "not enabled for port %d\n", port_id);
4898 cmd_tunnel_tso_set_parsed(void *parsed_result,
4899 __rte_unused struct cmdline *cl,
4900 __rte_unused void *data)
4902 struct cmd_tunnel_tso_set_result *res = parsed_result;
4903 struct rte_eth_dev_info dev_info;
4905 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4907 if (!port_is_stopped(res->port_id)) {
4908 printf("Please stop port %d first\n", res->port_id);
4912 if (!strcmp(res->mode, "set"))
4913 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4915 dev_info = check_tunnel_tso_nic_support(res->port_id);
4916 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4917 ports[res->port_id].dev_conf.txmode.offloads &=
4918 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4919 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4920 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4921 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4922 DEV_TX_OFFLOAD_IP_TNL_TSO |
4923 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4924 printf("TSO for tunneled packets is disabled\n");
4926 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4927 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4928 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4929 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4930 DEV_TX_OFFLOAD_IP_TNL_TSO |
4931 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4933 ports[res->port_id].dev_conf.txmode.offloads |=
4934 (tso_offloads & dev_info.tx_offload_capa);
4935 printf("TSO segment size for tunneled packets is %d\n",
4936 ports[res->port_id].tunnel_tso_segsz);
4938 /* Below conditions are needed to make it work:
4939 * (1) tunnel TSO is supported by the NIC;
4940 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4942 * (3) for tunneled pkts with outer L3 of IPv4,
4943 * "csum set outer-ip" must be set to hw, because after tso,
4944 * total_len of outer IP header is changed, and the checksum
4945 * of outer IP header calculated by sw should be wrong; that
4946 * is not necessary for IPv6 tunneled pkts because there's no
4947 * checksum in IP header anymore.
4950 if (!ports[res->port_id].parse_tunnel)
4951 printf("Warning: csum parse_tunnel must be set "
4952 "so that tunneled packets are recognized\n");
4953 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4954 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4955 printf("Warning: csum set outer-ip must be set to hw "
4956 "if outer L3 is IPv4; not necessary for IPv6\n");
4959 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4960 cmd_reconfig_device_queue(res->port_id, 1, 1);
4963 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4964 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4966 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4967 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4969 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4970 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4971 tso_segsz, RTE_UINT16);
4972 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4973 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4974 port_id, RTE_UINT16);
4976 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4977 .f = cmd_tunnel_tso_set_parsed,
4979 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4980 "Set TSO segment size of tunneled packets for csum engine "
4983 (void *)&cmd_tunnel_tso_set_tso,
4984 (void *)&cmd_tunnel_tso_set_mode,
4985 (void *)&cmd_tunnel_tso_set_tso_segsz,
4986 (void *)&cmd_tunnel_tso_set_portid,
4991 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4992 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4996 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4997 .f = cmd_tunnel_tso_set_parsed,
4999 .help_str = "tunnel_tso show <port_id> "
5000 "Show TSO segment size of tunneled packets for csum engine",
5002 (void *)&cmd_tunnel_tso_set_tso,
5003 (void *)&cmd_tunnel_tso_show_mode,
5004 (void *)&cmd_tunnel_tso_set_portid,
5009 /* *** SET GRO FOR A PORT *** */
5010 struct cmd_gro_enable_result {
5011 cmdline_fixed_string_t cmd_set;
5012 cmdline_fixed_string_t cmd_port;
5013 cmdline_fixed_string_t cmd_keyword;
5014 cmdline_fixed_string_t cmd_onoff;
5019 cmd_gro_enable_parsed(void *parsed_result,
5020 __rte_unused struct cmdline *cl,
5021 __rte_unused void *data)
5023 struct cmd_gro_enable_result *res;
5025 res = parsed_result;
5026 if (!strcmp(res->cmd_keyword, "gro"))
5027 setup_gro(res->cmd_onoff, res->cmd_pid);
5030 cmdline_parse_token_string_t cmd_gro_enable_set =
5031 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5033 cmdline_parse_token_string_t cmd_gro_enable_port =
5034 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5035 cmd_keyword, "port");
5036 cmdline_parse_token_num_t cmd_gro_enable_pid =
5037 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5038 cmd_pid, RTE_UINT16);
5039 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5040 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5041 cmd_keyword, "gro");
5042 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5043 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5044 cmd_onoff, "on#off");
5046 cmdline_parse_inst_t cmd_gro_enable = {
5047 .f = cmd_gro_enable_parsed,
5049 .help_str = "set port <port_id> gro on|off",
5051 (void *)&cmd_gro_enable_set,
5052 (void *)&cmd_gro_enable_port,
5053 (void *)&cmd_gro_enable_pid,
5054 (void *)&cmd_gro_enable_keyword,
5055 (void *)&cmd_gro_enable_onoff,
5060 /* *** DISPLAY GRO CONFIGURATION *** */
5061 struct cmd_gro_show_result {
5062 cmdline_fixed_string_t cmd_show;
5063 cmdline_fixed_string_t cmd_port;
5064 cmdline_fixed_string_t cmd_keyword;
5069 cmd_gro_show_parsed(void *parsed_result,
5070 __rte_unused struct cmdline *cl,
5071 __rte_unused void *data)
5073 struct cmd_gro_show_result *res;
5075 res = parsed_result;
5076 if (!strcmp(res->cmd_keyword, "gro"))
5077 show_gro(res->cmd_pid);
5080 cmdline_parse_token_string_t cmd_gro_show_show =
5081 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5083 cmdline_parse_token_string_t cmd_gro_show_port =
5084 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5086 cmdline_parse_token_num_t cmd_gro_show_pid =
5087 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5088 cmd_pid, RTE_UINT16);
5089 cmdline_parse_token_string_t cmd_gro_show_keyword =
5090 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5091 cmd_keyword, "gro");
5093 cmdline_parse_inst_t cmd_gro_show = {
5094 .f = cmd_gro_show_parsed,
5096 .help_str = "show port <port_id> gro",
5098 (void *)&cmd_gro_show_show,
5099 (void *)&cmd_gro_show_port,
5100 (void *)&cmd_gro_show_pid,
5101 (void *)&cmd_gro_show_keyword,
5106 /* *** SET FLUSH CYCLES FOR GRO *** */
5107 struct cmd_gro_flush_result {
5108 cmdline_fixed_string_t cmd_set;
5109 cmdline_fixed_string_t cmd_keyword;
5110 cmdline_fixed_string_t cmd_flush;
5115 cmd_gro_flush_parsed(void *parsed_result,
5116 __rte_unused struct cmdline *cl,
5117 __rte_unused void *data)
5119 struct cmd_gro_flush_result *res;
5121 res = parsed_result;
5122 if ((!strcmp(res->cmd_keyword, "gro")) &&
5123 (!strcmp(res->cmd_flush, "flush")))
5124 setup_gro_flush_cycles(res->cmd_cycles);
5127 cmdline_parse_token_string_t cmd_gro_flush_set =
5128 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5130 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5131 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5132 cmd_keyword, "gro");
5133 cmdline_parse_token_string_t cmd_gro_flush_flush =
5134 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5135 cmd_flush, "flush");
5136 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5137 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5138 cmd_cycles, RTE_UINT8);
5140 cmdline_parse_inst_t cmd_gro_flush = {
5141 .f = cmd_gro_flush_parsed,
5143 .help_str = "set gro flush <cycles>",
5145 (void *)&cmd_gro_flush_set,
5146 (void *)&cmd_gro_flush_keyword,
5147 (void *)&cmd_gro_flush_flush,
5148 (void *)&cmd_gro_flush_cycles,
5153 /* *** ENABLE/DISABLE GSO *** */
5154 struct cmd_gso_enable_result {
5155 cmdline_fixed_string_t cmd_set;
5156 cmdline_fixed_string_t cmd_port;
5157 cmdline_fixed_string_t cmd_keyword;
5158 cmdline_fixed_string_t cmd_mode;
5163 cmd_gso_enable_parsed(void *parsed_result,
5164 __rte_unused struct cmdline *cl,
5165 __rte_unused void *data)
5167 struct cmd_gso_enable_result *res;
5169 res = parsed_result;
5170 if (!strcmp(res->cmd_keyword, "gso"))
5171 setup_gso(res->cmd_mode, res->cmd_pid);
5174 cmdline_parse_token_string_t cmd_gso_enable_set =
5175 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5177 cmdline_parse_token_string_t cmd_gso_enable_port =
5178 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5180 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5181 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5182 cmd_keyword, "gso");
5183 cmdline_parse_token_string_t cmd_gso_enable_mode =
5184 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5185 cmd_mode, "on#off");
5186 cmdline_parse_token_num_t cmd_gso_enable_pid =
5187 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5188 cmd_pid, RTE_UINT16);
5190 cmdline_parse_inst_t cmd_gso_enable = {
5191 .f = cmd_gso_enable_parsed,
5193 .help_str = "set port <port_id> gso on|off",
5195 (void *)&cmd_gso_enable_set,
5196 (void *)&cmd_gso_enable_port,
5197 (void *)&cmd_gso_enable_pid,
5198 (void *)&cmd_gso_enable_keyword,
5199 (void *)&cmd_gso_enable_mode,
5204 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5205 struct cmd_gso_size_result {
5206 cmdline_fixed_string_t cmd_set;
5207 cmdline_fixed_string_t cmd_keyword;
5208 cmdline_fixed_string_t cmd_segsz;
5213 cmd_gso_size_parsed(void *parsed_result,
5214 __rte_unused struct cmdline *cl,
5215 __rte_unused void *data)
5217 struct cmd_gso_size_result *res = parsed_result;
5219 if (test_done == 0) {
5220 printf("Before setting GSO segsz, please first"
5221 " stop forwarding\n");
5225 if (!strcmp(res->cmd_keyword, "gso") &&
5226 !strcmp(res->cmd_segsz, "segsz")) {
5227 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5228 printf("gso_size should be larger than %zu."
5229 " Please input a legal value\n",
5230 RTE_GSO_SEG_SIZE_MIN);
5232 gso_max_segment_size = res->cmd_size;
5236 cmdline_parse_token_string_t cmd_gso_size_set =
5237 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5239 cmdline_parse_token_string_t cmd_gso_size_keyword =
5240 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5241 cmd_keyword, "gso");
5242 cmdline_parse_token_string_t cmd_gso_size_segsz =
5243 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5244 cmd_segsz, "segsz");
5245 cmdline_parse_token_num_t cmd_gso_size_size =
5246 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5247 cmd_size, RTE_UINT16);
5249 cmdline_parse_inst_t cmd_gso_size = {
5250 .f = cmd_gso_size_parsed,
5252 .help_str = "set gso segsz <length>",
5254 (void *)&cmd_gso_size_set,
5255 (void *)&cmd_gso_size_keyword,
5256 (void *)&cmd_gso_size_segsz,
5257 (void *)&cmd_gso_size_size,
5262 /* *** SHOW GSO CONFIGURATION *** */
5263 struct cmd_gso_show_result {
5264 cmdline_fixed_string_t cmd_show;
5265 cmdline_fixed_string_t cmd_port;
5266 cmdline_fixed_string_t cmd_keyword;
5271 cmd_gso_show_parsed(void *parsed_result,
5272 __rte_unused struct cmdline *cl,
5273 __rte_unused void *data)
5275 struct cmd_gso_show_result *res = parsed_result;
5277 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5278 printf("invalid port id %u\n", res->cmd_pid);
5281 if (!strcmp(res->cmd_keyword, "gso")) {
5282 if (gso_ports[res->cmd_pid].enable) {
5283 printf("Max GSO'd packet size: %uB\n"
5284 "Supported GSO types: TCP/IPv4, "
5285 "UDP/IPv4, VxLAN with inner "
5286 "TCP/IPv4 packet, GRE with inner "
5287 "TCP/IPv4 packet\n",
5288 gso_max_segment_size);
5290 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5294 cmdline_parse_token_string_t cmd_gso_show_show =
5295 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5297 cmdline_parse_token_string_t cmd_gso_show_port =
5298 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5300 cmdline_parse_token_string_t cmd_gso_show_keyword =
5301 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5302 cmd_keyword, "gso");
5303 cmdline_parse_token_num_t cmd_gso_show_pid =
5304 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5305 cmd_pid, RTE_UINT16);
5307 cmdline_parse_inst_t cmd_gso_show = {
5308 .f = cmd_gso_show_parsed,
5310 .help_str = "show port <port_id> gso",
5312 (void *)&cmd_gso_show_show,
5313 (void *)&cmd_gso_show_port,
5314 (void *)&cmd_gso_show_pid,
5315 (void *)&cmd_gso_show_keyword,
5320 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5321 struct cmd_set_flush_rx {
5322 cmdline_fixed_string_t set;
5323 cmdline_fixed_string_t flush_rx;
5324 cmdline_fixed_string_t mode;
5328 cmd_set_flush_rx_parsed(void *parsed_result,
5329 __rte_unused struct cmdline *cl,
5330 __rte_unused void *data)
5332 struct cmd_set_flush_rx *res = parsed_result;
5333 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5336 cmdline_parse_token_string_t cmd_setflushrx_set =
5337 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5339 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5340 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5341 flush_rx, "flush_rx");
5342 cmdline_parse_token_string_t cmd_setflushrx_mode =
5343 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5347 cmdline_parse_inst_t cmd_set_flush_rx = {
5348 .f = cmd_set_flush_rx_parsed,
5349 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5352 (void *)&cmd_setflushrx_set,
5353 (void *)&cmd_setflushrx_flush_rx,
5354 (void *)&cmd_setflushrx_mode,
5359 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5360 struct cmd_set_link_check {
5361 cmdline_fixed_string_t set;
5362 cmdline_fixed_string_t link_check;
5363 cmdline_fixed_string_t mode;
5367 cmd_set_link_check_parsed(void *parsed_result,
5368 __rte_unused struct cmdline *cl,
5369 __rte_unused void *data)
5371 struct cmd_set_link_check *res = parsed_result;
5372 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5375 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5376 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5378 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5379 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5380 link_check, "link_check");
5381 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5382 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5386 cmdline_parse_inst_t cmd_set_link_check = {
5387 .f = cmd_set_link_check_parsed,
5388 .help_str = "set link_check on|off: Enable/Disable link status check "
5389 "when starting/stopping a port",
5392 (void *)&cmd_setlinkcheck_set,
5393 (void *)&cmd_setlinkcheck_link_check,
5394 (void *)&cmd_setlinkcheck_mode,
5399 /* *** SET NIC BYPASS MODE *** */
5400 struct cmd_set_bypass_mode_result {
5401 cmdline_fixed_string_t set;
5402 cmdline_fixed_string_t bypass;
5403 cmdline_fixed_string_t mode;
5404 cmdline_fixed_string_t value;
5409 cmd_set_bypass_mode_parsed(void *parsed_result,
5410 __rte_unused struct cmdline *cl,
5411 __rte_unused void *data)
5413 struct cmd_set_bypass_mode_result *res = parsed_result;
5414 portid_t port_id = res->port_id;
5415 int32_t rc = -EINVAL;
5417 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5418 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5420 if (!strcmp(res->value, "bypass"))
5421 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5422 else if (!strcmp(res->value, "isolate"))
5423 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5425 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5427 /* Set the bypass mode for the relevant port. */
5428 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5431 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5434 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5435 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5437 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5438 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5440 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5441 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5443 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5444 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5445 value, "normal#bypass#isolate");
5446 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5447 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5448 port_id, RTE_UINT16);
5450 cmdline_parse_inst_t cmd_set_bypass_mode = {
5451 .f = cmd_set_bypass_mode_parsed,
5452 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5453 "Set the NIC bypass mode for port_id",
5456 (void *)&cmd_setbypass_mode_set,
5457 (void *)&cmd_setbypass_mode_bypass,
5458 (void *)&cmd_setbypass_mode_mode,
5459 (void *)&cmd_setbypass_mode_value,
5460 (void *)&cmd_setbypass_mode_port,
5465 /* *** SET NIC BYPASS EVENT *** */
5466 struct cmd_set_bypass_event_result {
5467 cmdline_fixed_string_t set;
5468 cmdline_fixed_string_t bypass;
5469 cmdline_fixed_string_t event;
5470 cmdline_fixed_string_t event_value;
5471 cmdline_fixed_string_t mode;
5472 cmdline_fixed_string_t mode_value;
5477 cmd_set_bypass_event_parsed(void *parsed_result,
5478 __rte_unused struct cmdline *cl,
5479 __rte_unused void *data)
5481 int32_t rc = -EINVAL;
5482 struct cmd_set_bypass_event_result *res = parsed_result;
5483 portid_t port_id = res->port_id;
5485 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5486 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5487 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5489 if (!strcmp(res->event_value, "timeout"))
5490 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5491 else if (!strcmp(res->event_value, "os_on"))
5492 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5493 else if (!strcmp(res->event_value, "os_off"))
5494 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5495 else if (!strcmp(res->event_value, "power_on"))
5496 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5497 else if (!strcmp(res->event_value, "power_off"))
5498 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5500 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5502 if (!strcmp(res->mode_value, "bypass"))
5503 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5504 else if (!strcmp(res->mode_value, "isolate"))
5505 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5507 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5509 /* Set the watchdog timeout. */
5510 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5513 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5514 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5518 printf("Failed to set timeout value %u "
5519 "for port %d, errto code: %d.\n",
5520 bypass_timeout, port_id, rc);
5524 /* Set the bypass event to transition to bypass mode. */
5525 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5530 printf("\t Failed to set bypass event for port = %d.\n",
5534 cmdline_parse_token_string_t cmd_setbypass_event_set =
5535 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5537 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5538 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5540 cmdline_parse_token_string_t cmd_setbypass_event_event =
5541 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5543 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5544 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5545 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5546 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5547 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5549 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5550 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5551 mode_value, "normal#bypass#isolate");
5552 cmdline_parse_token_num_t cmd_setbypass_event_port =
5553 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5554 port_id, RTE_UINT16);
5556 cmdline_parse_inst_t cmd_set_bypass_event = {
5557 .f = cmd_set_bypass_event_parsed,
5558 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5559 "power_off mode normal|bypass|isolate <port_id>: "
5560 "Set the NIC bypass event mode for port_id",
5563 (void *)&cmd_setbypass_event_set,
5564 (void *)&cmd_setbypass_event_bypass,
5565 (void *)&cmd_setbypass_event_event,
5566 (void *)&cmd_setbypass_event_event_value,
5567 (void *)&cmd_setbypass_event_mode,
5568 (void *)&cmd_setbypass_event_mode_value,
5569 (void *)&cmd_setbypass_event_port,
5575 /* *** SET NIC BYPASS TIMEOUT *** */
5576 struct cmd_set_bypass_timeout_result {
5577 cmdline_fixed_string_t set;
5578 cmdline_fixed_string_t bypass;
5579 cmdline_fixed_string_t timeout;
5580 cmdline_fixed_string_t value;
5584 cmd_set_bypass_timeout_parsed(void *parsed_result,
5585 __rte_unused struct cmdline *cl,
5586 __rte_unused void *data)
5588 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5590 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5591 if (!strcmp(res->value, "1.5"))
5592 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5593 else if (!strcmp(res->value, "2"))
5594 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5595 else if (!strcmp(res->value, "3"))
5596 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5597 else if (!strcmp(res->value, "4"))
5598 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5599 else if (!strcmp(res->value, "8"))
5600 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5601 else if (!strcmp(res->value, "16"))
5602 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5603 else if (!strcmp(res->value, "32"))
5604 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5606 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5610 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5611 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5613 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5614 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5616 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5617 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5618 timeout, "timeout");
5619 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5620 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5621 value, "0#1.5#2#3#4#8#16#32");
5623 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5624 .f = cmd_set_bypass_timeout_parsed,
5625 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5626 "Set the NIC bypass watchdog timeout in seconds",
5629 (void *)&cmd_setbypass_timeout_set,
5630 (void *)&cmd_setbypass_timeout_bypass,
5631 (void *)&cmd_setbypass_timeout_timeout,
5632 (void *)&cmd_setbypass_timeout_value,
5637 /* *** SHOW NIC BYPASS MODE *** */
5638 struct cmd_show_bypass_config_result {
5639 cmdline_fixed_string_t show;
5640 cmdline_fixed_string_t bypass;
5641 cmdline_fixed_string_t config;
5646 cmd_show_bypass_config_parsed(void *parsed_result,
5647 __rte_unused struct cmdline *cl,
5648 __rte_unused void *data)
5650 struct cmd_show_bypass_config_result *res = parsed_result;
5651 portid_t port_id = res->port_id;
5653 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5654 uint32_t event_mode;
5655 uint32_t bypass_mode;
5656 uint32_t timeout = bypass_timeout;
5659 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5660 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5661 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5662 {"UNKNOWN", "normal", "bypass", "isolate"};
5663 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5671 /* Display the bypass mode.*/
5672 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5673 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5677 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5678 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5680 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5683 /* Display the bypass timeout.*/
5684 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5685 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5687 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5689 /* Display the bypass events and associated modes. */
5690 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5692 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5693 printf("\tFailed to get bypass mode for event = %s\n",
5696 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5697 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5699 printf("\tbypass event: %-16s = %s\n", events[i],
5705 printf("\tFailed to get bypass configuration for port = %d\n",
5709 cmdline_parse_token_string_t cmd_showbypass_config_show =
5710 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5712 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5713 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5715 cmdline_parse_token_string_t cmd_showbypass_config_config =
5716 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5718 cmdline_parse_token_num_t cmd_showbypass_config_port =
5719 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5720 port_id, RTE_UINT16);
5722 cmdline_parse_inst_t cmd_show_bypass_config = {
5723 .f = cmd_show_bypass_config_parsed,
5724 .help_str = "show bypass config <port_id>: "
5725 "Show the NIC bypass config for port_id",
5728 (void *)&cmd_showbypass_config_show,
5729 (void *)&cmd_showbypass_config_bypass,
5730 (void *)&cmd_showbypass_config_config,
5731 (void *)&cmd_showbypass_config_port,
5737 /* *** SET BONDING MODE *** */
5738 struct cmd_set_bonding_mode_result {
5739 cmdline_fixed_string_t set;
5740 cmdline_fixed_string_t bonding;
5741 cmdline_fixed_string_t mode;
5746 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5747 __rte_unused struct cmdline *cl,
5748 __rte_unused void *data)
5750 struct cmd_set_bonding_mode_result *res = parsed_result;
5751 portid_t port_id = res->port_id;
5753 /* Set the bonding mode for the relevant port. */
5754 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5755 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5758 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5759 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5761 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5762 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5763 bonding, "bonding");
5764 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5765 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5767 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5768 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5770 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5771 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5772 port_id, RTE_UINT16);
5774 cmdline_parse_inst_t cmd_set_bonding_mode = {
5775 .f = cmd_set_bonding_mode_parsed,
5776 .help_str = "set bonding mode <mode_value> <port_id>: "
5777 "Set the bonding mode for port_id",
5780 (void *) &cmd_setbonding_mode_set,
5781 (void *) &cmd_setbonding_mode_bonding,
5782 (void *) &cmd_setbonding_mode_mode,
5783 (void *) &cmd_setbonding_mode_value,
5784 (void *) &cmd_setbonding_mode_port,
5789 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5790 struct cmd_set_bonding_lacp_dedicated_queues_result {
5791 cmdline_fixed_string_t set;
5792 cmdline_fixed_string_t bonding;
5793 cmdline_fixed_string_t lacp;
5794 cmdline_fixed_string_t dedicated_queues;
5796 cmdline_fixed_string_t mode;
5799 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5800 __rte_unused struct cmdline *cl,
5801 __rte_unused void *data)
5803 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5804 portid_t port_id = res->port_id;
5805 struct rte_port *port;
5807 port = &ports[port_id];
5809 /** Check if the port is not started **/
5810 if (port->port_status != RTE_PORT_STOPPED) {
5811 printf("Please stop port %d first\n", port_id);
5815 if (!strcmp(res->mode, "enable")) {
5816 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5817 printf("Dedicate queues for LACP control packets"
5820 printf("Enabling dedicate queues for LACP control "
5821 "packets on port %d failed\n", port_id);
5822 } else if (!strcmp(res->mode, "disable")) {
5823 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5824 printf("Dedicated queues for LACP control packets "
5827 printf("Disabling dedicated queues for LACP control "
5828 "traffic on port %d failed\n", port_id);
5832 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5833 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5835 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5836 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5837 bonding, "bonding");
5838 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5839 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5841 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5842 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5843 dedicated_queues, "dedicated_queues");
5844 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5845 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5846 port_id, RTE_UINT16);
5847 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5848 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5849 mode, "enable#disable");
5851 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5852 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5853 .help_str = "set bonding lacp dedicated_queues <port_id> "
5855 "Enable/disable dedicated queues for LACP control traffic for port_id",
5858 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5859 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5860 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5861 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5862 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5863 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5868 /* *** SET BALANCE XMIT POLICY *** */
5869 struct cmd_set_bonding_balance_xmit_policy_result {
5870 cmdline_fixed_string_t set;
5871 cmdline_fixed_string_t bonding;
5872 cmdline_fixed_string_t balance_xmit_policy;
5874 cmdline_fixed_string_t policy;
5877 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5878 __rte_unused struct cmdline *cl,
5879 __rte_unused void *data)
5881 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5882 portid_t port_id = res->port_id;
5885 if (!strcmp(res->policy, "l2")) {
5886 policy = BALANCE_XMIT_POLICY_LAYER2;
5887 } else if (!strcmp(res->policy, "l23")) {
5888 policy = BALANCE_XMIT_POLICY_LAYER23;
5889 } else if (!strcmp(res->policy, "l34")) {
5890 policy = BALANCE_XMIT_POLICY_LAYER34;
5892 printf("\t Invalid xmit policy selection");
5896 /* Set the bonding mode for the relevant port. */
5897 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5898 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5903 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5904 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5906 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5907 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5908 bonding, "bonding");
5909 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5910 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5911 balance_xmit_policy, "balance_xmit_policy");
5912 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5913 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5914 port_id, RTE_UINT16);
5915 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5916 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5917 policy, "l2#l23#l34");
5919 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5920 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5921 .help_str = "set bonding balance_xmit_policy <port_id> "
5923 "Set the bonding balance_xmit_policy for port_id",
5926 (void *)&cmd_setbonding_balance_xmit_policy_set,
5927 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5928 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5929 (void *)&cmd_setbonding_balance_xmit_policy_port,
5930 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5935 /* *** SHOW NIC BONDING CONFIGURATION *** */
5936 struct cmd_show_bonding_config_result {
5937 cmdline_fixed_string_t show;
5938 cmdline_fixed_string_t bonding;
5939 cmdline_fixed_string_t config;
5943 static void cmd_show_bonding_config_parsed(void *parsed_result,
5944 __rte_unused struct cmdline *cl,
5945 __rte_unused void *data)
5947 struct cmd_show_bonding_config_result *res = parsed_result;
5948 int bonding_mode, agg_mode;
5949 portid_t slaves[RTE_MAX_ETHPORTS];
5950 int num_slaves, num_active_slaves;
5953 portid_t port_id = res->port_id;
5955 /* Display the bonding mode.*/
5956 bonding_mode = rte_eth_bond_mode_get(port_id);
5957 if (bonding_mode < 0) {
5958 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5961 printf("\tBonding mode: %d\n", bonding_mode);
5963 if (bonding_mode == BONDING_MODE_BALANCE) {
5964 int balance_xmit_policy;
5966 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5967 if (balance_xmit_policy < 0) {
5968 printf("\tFailed to get balance xmit policy for port = %d\n",
5972 printf("\tBalance Xmit Policy: ");
5974 switch (balance_xmit_policy) {
5975 case BALANCE_XMIT_POLICY_LAYER2:
5976 printf("BALANCE_XMIT_POLICY_LAYER2");
5978 case BALANCE_XMIT_POLICY_LAYER23:
5979 printf("BALANCE_XMIT_POLICY_LAYER23");
5981 case BALANCE_XMIT_POLICY_LAYER34:
5982 printf("BALANCE_XMIT_POLICY_LAYER34");
5989 if (bonding_mode == BONDING_MODE_8023AD) {
5990 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5991 printf("\tIEEE802.3AD Aggregator Mode: ");
5994 printf("bandwidth");
6006 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6008 if (num_slaves < 0) {
6009 printf("\tFailed to get slave list for port = %d\n", port_id);
6012 if (num_slaves > 0) {
6013 printf("\tSlaves (%d): [", num_slaves);
6014 for (i = 0; i < num_slaves - 1; i++)
6015 printf("%d ", slaves[i]);
6017 printf("%d]\n", slaves[num_slaves - 1]);
6019 printf("\tSlaves: []\n");
6023 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6026 if (num_active_slaves < 0) {
6027 printf("\tFailed to get active slave list for port = %d\n", port_id);
6030 if (num_active_slaves > 0) {
6031 printf("\tActive Slaves (%d): [", num_active_slaves);
6032 for (i = 0; i < num_active_slaves - 1; i++)
6033 printf("%d ", slaves[i]);
6035 printf("%d]\n", slaves[num_active_slaves - 1]);
6038 printf("\tActive Slaves: []\n");
6042 primary_id = rte_eth_bond_primary_get(port_id);
6043 if (primary_id < 0) {
6044 printf("\tFailed to get primary slave for port = %d\n", port_id);
6047 printf("\tPrimary: [%d]\n", primary_id);
6051 cmdline_parse_token_string_t cmd_showbonding_config_show =
6052 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6054 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6055 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6056 bonding, "bonding");
6057 cmdline_parse_token_string_t cmd_showbonding_config_config =
6058 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6060 cmdline_parse_token_num_t cmd_showbonding_config_port =
6061 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6062 port_id, RTE_UINT16);
6064 cmdline_parse_inst_t cmd_show_bonding_config = {
6065 .f = cmd_show_bonding_config_parsed,
6066 .help_str = "show bonding config <port_id>: "
6067 "Show the bonding config for port_id",
6070 (void *)&cmd_showbonding_config_show,
6071 (void *)&cmd_showbonding_config_bonding,
6072 (void *)&cmd_showbonding_config_config,
6073 (void *)&cmd_showbonding_config_port,
6078 /* *** SET BONDING PRIMARY *** */
6079 struct cmd_set_bonding_primary_result {
6080 cmdline_fixed_string_t set;
6081 cmdline_fixed_string_t bonding;
6082 cmdline_fixed_string_t primary;
6087 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6088 __rte_unused struct cmdline *cl,
6089 __rte_unused void *data)
6091 struct cmd_set_bonding_primary_result *res = parsed_result;
6092 portid_t master_port_id = res->port_id;
6093 portid_t slave_port_id = res->slave_id;
6095 /* Set the primary slave for a bonded device. */
6096 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6097 printf("\t Failed to set primary slave for port = %d.\n",
6104 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6105 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6107 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6108 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6109 bonding, "bonding");
6110 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6111 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6112 primary, "primary");
6113 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6114 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6115 slave_id, RTE_UINT16);
6116 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6117 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6118 port_id, RTE_UINT16);
6120 cmdline_parse_inst_t cmd_set_bonding_primary = {
6121 .f = cmd_set_bonding_primary_parsed,
6122 .help_str = "set bonding primary <slave_id> <port_id>: "
6123 "Set the primary slave for port_id",
6126 (void *)&cmd_setbonding_primary_set,
6127 (void *)&cmd_setbonding_primary_bonding,
6128 (void *)&cmd_setbonding_primary_primary,
6129 (void *)&cmd_setbonding_primary_slave,
6130 (void *)&cmd_setbonding_primary_port,
6135 /* *** ADD SLAVE *** */
6136 struct cmd_add_bonding_slave_result {
6137 cmdline_fixed_string_t add;
6138 cmdline_fixed_string_t bonding;
6139 cmdline_fixed_string_t slave;
6144 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6145 __rte_unused struct cmdline *cl,
6146 __rte_unused void *data)
6148 struct cmd_add_bonding_slave_result *res = parsed_result;
6149 portid_t master_port_id = res->port_id;
6150 portid_t slave_port_id = res->slave_id;
6152 /* add the slave for a bonded device. */
6153 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6154 printf("\t Failed to add slave %d to master port = %d.\n",
6155 slave_port_id, master_port_id);
6159 set_port_slave_flag(slave_port_id);
6162 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6163 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6165 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6166 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6167 bonding, "bonding");
6168 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6169 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6171 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6172 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6173 slave_id, RTE_UINT16);
6174 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6175 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6176 port_id, RTE_UINT16);
6178 cmdline_parse_inst_t cmd_add_bonding_slave = {
6179 .f = cmd_add_bonding_slave_parsed,
6180 .help_str = "add bonding slave <slave_id> <port_id>: "
6181 "Add a slave device to a bonded device",
6184 (void *)&cmd_addbonding_slave_add,
6185 (void *)&cmd_addbonding_slave_bonding,
6186 (void *)&cmd_addbonding_slave_slave,
6187 (void *)&cmd_addbonding_slave_slaveid,
6188 (void *)&cmd_addbonding_slave_port,
6193 /* *** REMOVE SLAVE *** */
6194 struct cmd_remove_bonding_slave_result {
6195 cmdline_fixed_string_t remove;
6196 cmdline_fixed_string_t bonding;
6197 cmdline_fixed_string_t slave;
6202 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6203 __rte_unused struct cmdline *cl,
6204 __rte_unused void *data)
6206 struct cmd_remove_bonding_slave_result *res = parsed_result;
6207 portid_t master_port_id = res->port_id;
6208 portid_t slave_port_id = res->slave_id;
6210 /* remove the slave from a bonded device. */
6211 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6212 printf("\t Failed to remove slave %d from master port = %d.\n",
6213 slave_port_id, master_port_id);
6217 clear_port_slave_flag(slave_port_id);
6220 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6221 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6223 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6224 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6225 bonding, "bonding");
6226 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6227 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6229 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6230 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6231 slave_id, RTE_UINT16);
6232 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6233 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6234 port_id, RTE_UINT16);
6236 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6237 .f = cmd_remove_bonding_slave_parsed,
6238 .help_str = "remove bonding slave <slave_id> <port_id>: "
6239 "Remove a slave device from a bonded device",
6242 (void *)&cmd_removebonding_slave_remove,
6243 (void *)&cmd_removebonding_slave_bonding,
6244 (void *)&cmd_removebonding_slave_slave,
6245 (void *)&cmd_removebonding_slave_slaveid,
6246 (void *)&cmd_removebonding_slave_port,
6251 /* *** CREATE BONDED DEVICE *** */
6252 struct cmd_create_bonded_device_result {
6253 cmdline_fixed_string_t create;
6254 cmdline_fixed_string_t bonded;
6255 cmdline_fixed_string_t device;
6260 static int bond_dev_num = 0;
6262 static void cmd_create_bonded_device_parsed(void *parsed_result,
6263 __rte_unused struct cmdline *cl,
6264 __rte_unused void *data)
6266 struct cmd_create_bonded_device_result *res = parsed_result;
6267 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6271 if (test_done == 0) {
6272 printf("Please stop forwarding first\n");
6276 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6279 /* Create a new bonded device. */
6280 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6282 printf("\t Failed to create bonded device.\n");
6285 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6288 /* Update number of ports */
6289 nb_ports = rte_eth_dev_count_avail();
6290 reconfig(port_id, res->socket);
6291 ret = rte_eth_promiscuous_enable(port_id);
6293 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6294 port_id, rte_strerror(-ret));
6296 ports[port_id].need_setup = 0;
6297 ports[port_id].port_status = RTE_PORT_STOPPED;
6302 cmdline_parse_token_string_t cmd_createbonded_device_create =
6303 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6305 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6306 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6308 cmdline_parse_token_string_t cmd_createbonded_device_device =
6309 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6311 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6312 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6314 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6315 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6318 cmdline_parse_inst_t cmd_create_bonded_device = {
6319 .f = cmd_create_bonded_device_parsed,
6320 .help_str = "create bonded device <mode> <socket>: "
6321 "Create a new bonded device with specific bonding mode and socket",
6324 (void *)&cmd_createbonded_device_create,
6325 (void *)&cmd_createbonded_device_bonded,
6326 (void *)&cmd_createbonded_device_device,
6327 (void *)&cmd_createbonded_device_mode,
6328 (void *)&cmd_createbonded_device_socket,
6333 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6334 struct cmd_set_bond_mac_addr_result {
6335 cmdline_fixed_string_t set;
6336 cmdline_fixed_string_t bonding;
6337 cmdline_fixed_string_t mac_addr;
6339 struct rte_ether_addr address;
6342 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6343 __rte_unused struct cmdline *cl,
6344 __rte_unused void *data)
6346 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6349 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6352 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6354 /* check the return value and print it if is < 0 */
6356 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6359 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6360 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6361 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6362 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6364 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6365 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6367 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6368 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6369 port_num, RTE_UINT16);
6370 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6371 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6373 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6374 .f = cmd_set_bond_mac_addr_parsed,
6376 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6378 (void *)&cmd_set_bond_mac_addr_set,
6379 (void *)&cmd_set_bond_mac_addr_bonding,
6380 (void *)&cmd_set_bond_mac_addr_mac,
6381 (void *)&cmd_set_bond_mac_addr_portnum,
6382 (void *)&cmd_set_bond_mac_addr_addr,
6388 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6389 struct cmd_set_bond_mon_period_result {
6390 cmdline_fixed_string_t set;
6391 cmdline_fixed_string_t bonding;
6392 cmdline_fixed_string_t mon_period;
6397 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6398 __rte_unused struct cmdline *cl,
6399 __rte_unused void *data)
6401 struct cmd_set_bond_mon_period_result *res = parsed_result;
6404 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6406 /* check the return value and print it if is < 0 */
6408 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6411 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6412 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6414 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6415 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6416 bonding, "bonding");
6417 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6418 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6419 mon_period, "mon_period");
6420 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6421 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6422 port_num, RTE_UINT16);
6423 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6424 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6425 period_ms, RTE_UINT32);
6427 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6428 .f = cmd_set_bond_mon_period_parsed,
6430 .help_str = "set bonding mon_period <port_id> <period_ms>",
6432 (void *)&cmd_set_bond_mon_period_set,
6433 (void *)&cmd_set_bond_mon_period_bonding,
6434 (void *)&cmd_set_bond_mon_period_mon_period,
6435 (void *)&cmd_set_bond_mon_period_portnum,
6436 (void *)&cmd_set_bond_mon_period_period_ms,
6443 struct cmd_set_bonding_agg_mode_policy_result {
6444 cmdline_fixed_string_t set;
6445 cmdline_fixed_string_t bonding;
6446 cmdline_fixed_string_t agg_mode;
6448 cmdline_fixed_string_t policy;
6453 cmd_set_bonding_agg_mode(void *parsed_result,
6454 __rte_unused struct cmdline *cl,
6455 __rte_unused void *data)
6457 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6458 uint8_t policy = AGG_BANDWIDTH;
6460 if (!strcmp(res->policy, "bandwidth"))
6461 policy = AGG_BANDWIDTH;
6462 else if (!strcmp(res->policy, "stable"))
6463 policy = AGG_STABLE;
6464 else if (!strcmp(res->policy, "count"))
6467 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6471 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6472 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6474 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6475 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6476 bonding, "bonding");
6478 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6479 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6480 agg_mode, "agg_mode");
6482 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6483 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6484 port_num, RTE_UINT16);
6486 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6487 TOKEN_STRING_INITIALIZER(
6488 struct cmd_set_bonding_balance_xmit_policy_result,
6489 policy, "stable#bandwidth#count");
6491 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6492 .f = cmd_set_bonding_agg_mode,
6494 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6496 (void *)&cmd_set_bonding_agg_mode_set,
6497 (void *)&cmd_set_bonding_agg_mode_bonding,
6498 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6499 (void *)&cmd_set_bonding_agg_mode_portnum,
6500 (void *)&cmd_set_bonding_agg_mode_policy_string,
6506 #endif /* RTE_NET_BOND */
6508 /* *** SET FORWARDING MODE *** */
6509 struct cmd_set_fwd_mode_result {
6510 cmdline_fixed_string_t set;
6511 cmdline_fixed_string_t fwd;
6512 cmdline_fixed_string_t mode;
6515 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6516 __rte_unused struct cmdline *cl,
6517 __rte_unused void *data)
6519 struct cmd_set_fwd_mode_result *res = parsed_result;
6522 set_pkt_forwarding_mode(res->mode);
6525 cmdline_parse_token_string_t cmd_setfwd_set =
6526 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6527 cmdline_parse_token_string_t cmd_setfwd_fwd =
6528 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6529 cmdline_parse_token_string_t cmd_setfwd_mode =
6530 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6531 "" /* defined at init */);
6533 cmdline_parse_inst_t cmd_set_fwd_mode = {
6534 .f = cmd_set_fwd_mode_parsed,
6536 .help_str = NULL, /* defined at init */
6538 (void *)&cmd_setfwd_set,
6539 (void *)&cmd_setfwd_fwd,
6540 (void *)&cmd_setfwd_mode,
6545 static void cmd_set_fwd_mode_init(void)
6548 static char token[128];
6549 static char help[256];
6550 cmdline_parse_token_string_t *token_struct;
6552 modes = list_pkt_forwarding_modes();
6553 snprintf(help, sizeof(help), "set fwd %s: "
6554 "Set packet forwarding mode", modes);
6555 cmd_set_fwd_mode.help_str = help;
6557 /* string token separator is # */
6558 for (c = token; *modes != '\0'; modes++)
6563 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6564 token_struct->string_data.str = token;
6567 /* *** SET RETRY FORWARDING MODE *** */
6568 struct cmd_set_fwd_retry_mode_result {
6569 cmdline_fixed_string_t set;
6570 cmdline_fixed_string_t fwd;
6571 cmdline_fixed_string_t mode;
6572 cmdline_fixed_string_t retry;
6575 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6576 __rte_unused struct cmdline *cl,
6577 __rte_unused void *data)
6579 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6582 set_pkt_forwarding_mode(res->mode);
6585 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6586 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6588 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6589 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6591 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6592 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6594 "" /* defined at init */);
6595 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6596 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6599 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6600 .f = cmd_set_fwd_retry_mode_parsed,
6602 .help_str = NULL, /* defined at init */
6604 (void *)&cmd_setfwd_retry_set,
6605 (void *)&cmd_setfwd_retry_fwd,
6606 (void *)&cmd_setfwd_retry_mode,
6607 (void *)&cmd_setfwd_retry_retry,
6612 static void cmd_set_fwd_retry_mode_init(void)
6615 static char token[128];
6616 static char help[256];
6617 cmdline_parse_token_string_t *token_struct;
6619 modes = list_pkt_forwarding_retry_modes();
6620 snprintf(help, sizeof(help), "set fwd %s retry: "
6621 "Set packet forwarding mode with retry", modes);
6622 cmd_set_fwd_retry_mode.help_str = help;
6624 /* string token separator is # */
6625 for (c = token; *modes != '\0'; modes++)
6630 token_struct = (cmdline_parse_token_string_t *)
6631 cmd_set_fwd_retry_mode.tokens[2];
6632 token_struct->string_data.str = token;
6635 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6636 struct cmd_set_burst_tx_retry_result {
6637 cmdline_fixed_string_t set;
6638 cmdline_fixed_string_t burst;
6639 cmdline_fixed_string_t tx;
6640 cmdline_fixed_string_t delay;
6642 cmdline_fixed_string_t retry;
6646 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6647 __rte_unused struct cmdline *cl,
6648 __rte_unused void *data)
6650 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6652 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6653 && !strcmp(res->tx, "tx")) {
6654 if (!strcmp(res->delay, "delay"))
6655 burst_tx_delay_time = res->time;
6656 if (!strcmp(res->retry, "retry"))
6657 burst_tx_retry_num = res->retry_num;
6662 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6663 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6664 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6665 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6667 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6668 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6669 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6670 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6671 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6672 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
6674 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6675 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6676 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6677 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
6680 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6681 .f = cmd_set_burst_tx_retry_parsed,
6682 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6684 (void *)&cmd_set_burst_tx_retry_set,
6685 (void *)&cmd_set_burst_tx_retry_burst,
6686 (void *)&cmd_set_burst_tx_retry_tx,
6687 (void *)&cmd_set_burst_tx_retry_delay,
6688 (void *)&cmd_set_burst_tx_retry_time,
6689 (void *)&cmd_set_burst_tx_retry_retry,
6690 (void *)&cmd_set_burst_tx_retry_retry_num,
6695 /* *** SET PROMISC MODE *** */
6696 struct cmd_set_promisc_mode_result {
6697 cmdline_fixed_string_t set;
6698 cmdline_fixed_string_t promisc;
6699 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6700 uint16_t port_num; /* valid if "allports" argument == 0 */
6701 cmdline_fixed_string_t mode;
6704 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6705 __rte_unused struct cmdline *cl,
6708 struct cmd_set_promisc_mode_result *res = parsed_result;
6712 if (!strcmp(res->mode, "on"))
6719 RTE_ETH_FOREACH_DEV(i)
6720 eth_set_promisc_mode(i, enable);
6722 eth_set_promisc_mode(res->port_num, enable);
6726 cmdline_parse_token_string_t cmd_setpromisc_set =
6727 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6728 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6729 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6731 cmdline_parse_token_string_t cmd_setpromisc_portall =
6732 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6734 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6735 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6737 cmdline_parse_token_string_t cmd_setpromisc_mode =
6738 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6741 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6742 .f = cmd_set_promisc_mode_parsed,
6744 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6746 (void *)&cmd_setpromisc_set,
6747 (void *)&cmd_setpromisc_promisc,
6748 (void *)&cmd_setpromisc_portall,
6749 (void *)&cmd_setpromisc_mode,
6754 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6755 .f = cmd_set_promisc_mode_parsed,
6757 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6759 (void *)&cmd_setpromisc_set,
6760 (void *)&cmd_setpromisc_promisc,
6761 (void *)&cmd_setpromisc_portnum,
6762 (void *)&cmd_setpromisc_mode,
6767 /* *** SET ALLMULTI MODE *** */
6768 struct cmd_set_allmulti_mode_result {
6769 cmdline_fixed_string_t set;
6770 cmdline_fixed_string_t allmulti;
6771 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6772 uint16_t port_num; /* valid if "allports" argument == 0 */
6773 cmdline_fixed_string_t mode;
6776 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6777 __rte_unused struct cmdline *cl,
6780 struct cmd_set_allmulti_mode_result *res = parsed_result;
6784 if (!strcmp(res->mode, "on"))
6791 RTE_ETH_FOREACH_DEV(i) {
6792 eth_set_allmulticast_mode(i, enable);
6796 eth_set_allmulticast_mode(res->port_num, enable);
6800 cmdline_parse_token_string_t cmd_setallmulti_set =
6801 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6802 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6803 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6805 cmdline_parse_token_string_t cmd_setallmulti_portall =
6806 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6808 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6809 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6811 cmdline_parse_token_string_t cmd_setallmulti_mode =
6812 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6815 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6816 .f = cmd_set_allmulti_mode_parsed,
6818 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6820 (void *)&cmd_setallmulti_set,
6821 (void *)&cmd_setallmulti_allmulti,
6822 (void *)&cmd_setallmulti_portall,
6823 (void *)&cmd_setallmulti_mode,
6828 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6829 .f = cmd_set_allmulti_mode_parsed,
6831 .help_str = "set allmulti <port_id> on|off: "
6832 "Set allmulti mode on port_id",
6834 (void *)&cmd_setallmulti_set,
6835 (void *)&cmd_setallmulti_allmulti,
6836 (void *)&cmd_setallmulti_portnum,
6837 (void *)&cmd_setallmulti_mode,
6842 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6843 struct cmd_link_flow_ctrl_set_result {
6844 cmdline_fixed_string_t set;
6845 cmdline_fixed_string_t flow_ctrl;
6846 cmdline_fixed_string_t rx;
6847 cmdline_fixed_string_t rx_lfc_mode;
6848 cmdline_fixed_string_t tx;
6849 cmdline_fixed_string_t tx_lfc_mode;
6850 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6851 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6852 cmdline_fixed_string_t autoneg_str;
6853 cmdline_fixed_string_t autoneg;
6854 cmdline_fixed_string_t hw_str;
6855 uint32_t high_water;
6856 cmdline_fixed_string_t lw_str;
6858 cmdline_fixed_string_t pt_str;
6859 uint16_t pause_time;
6860 cmdline_fixed_string_t xon_str;
6865 cmdline_parse_token_string_t cmd_lfc_set_set =
6866 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6868 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6869 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6870 flow_ctrl, "flow_ctrl");
6871 cmdline_parse_token_string_t cmd_lfc_set_rx =
6872 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6874 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6875 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6876 rx_lfc_mode, "on#off");
6877 cmdline_parse_token_string_t cmd_lfc_set_tx =
6878 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6880 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6881 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6882 tx_lfc_mode, "on#off");
6883 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6884 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6885 hw_str, "high_water");
6886 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6887 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6888 high_water, RTE_UINT32);
6889 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6890 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6891 lw_str, "low_water");
6892 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6893 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6894 low_water, RTE_UINT32);
6895 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6896 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6897 pt_str, "pause_time");
6898 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6899 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6900 pause_time, RTE_UINT16);
6901 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6902 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6903 xon_str, "send_xon");
6904 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6905 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6906 send_xon, RTE_UINT16);
6907 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6908 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6909 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6910 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6911 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6912 mac_ctrl_frame_fwd_mode, "on#off");
6913 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6914 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6915 autoneg_str, "autoneg");
6916 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6917 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6919 cmdline_parse_token_num_t cmd_lfc_set_portid =
6920 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6921 port_id, RTE_UINT16);
6923 /* forward declaration */
6925 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6928 cmdline_parse_inst_t cmd_link_flow_control_set = {
6929 .f = cmd_link_flow_ctrl_set_parsed,
6931 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6932 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6933 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6935 (void *)&cmd_lfc_set_set,
6936 (void *)&cmd_lfc_set_flow_ctrl,
6937 (void *)&cmd_lfc_set_rx,
6938 (void *)&cmd_lfc_set_rx_mode,
6939 (void *)&cmd_lfc_set_tx,
6940 (void *)&cmd_lfc_set_tx_mode,
6941 (void *)&cmd_lfc_set_high_water,
6942 (void *)&cmd_lfc_set_low_water,
6943 (void *)&cmd_lfc_set_pause_time,
6944 (void *)&cmd_lfc_set_send_xon,
6945 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6946 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6947 (void *)&cmd_lfc_set_autoneg_str,
6948 (void *)&cmd_lfc_set_autoneg,
6949 (void *)&cmd_lfc_set_portid,
6954 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6955 .f = cmd_link_flow_ctrl_set_parsed,
6956 .data = (void *)&cmd_link_flow_control_set_rx,
6957 .help_str = "set flow_ctrl rx on|off <port_id>: "
6958 "Change rx flow control parameter",
6960 (void *)&cmd_lfc_set_set,
6961 (void *)&cmd_lfc_set_flow_ctrl,
6962 (void *)&cmd_lfc_set_rx,
6963 (void *)&cmd_lfc_set_rx_mode,
6964 (void *)&cmd_lfc_set_portid,
6969 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6970 .f = cmd_link_flow_ctrl_set_parsed,
6971 .data = (void *)&cmd_link_flow_control_set_tx,
6972 .help_str = "set flow_ctrl tx on|off <port_id>: "
6973 "Change tx flow control parameter",
6975 (void *)&cmd_lfc_set_set,
6976 (void *)&cmd_lfc_set_flow_ctrl,
6977 (void *)&cmd_lfc_set_tx,
6978 (void *)&cmd_lfc_set_tx_mode,
6979 (void *)&cmd_lfc_set_portid,
6984 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6985 .f = cmd_link_flow_ctrl_set_parsed,
6986 .data = (void *)&cmd_link_flow_control_set_hw,
6987 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6988 "Change high water flow control parameter",
6990 (void *)&cmd_lfc_set_set,
6991 (void *)&cmd_lfc_set_flow_ctrl,
6992 (void *)&cmd_lfc_set_high_water_str,
6993 (void *)&cmd_lfc_set_high_water,
6994 (void *)&cmd_lfc_set_portid,
6999 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7000 .f = cmd_link_flow_ctrl_set_parsed,
7001 .data = (void *)&cmd_link_flow_control_set_lw,
7002 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7003 "Change low water flow control parameter",
7005 (void *)&cmd_lfc_set_set,
7006 (void *)&cmd_lfc_set_flow_ctrl,
7007 (void *)&cmd_lfc_set_low_water_str,
7008 (void *)&cmd_lfc_set_low_water,
7009 (void *)&cmd_lfc_set_portid,
7014 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7015 .f = cmd_link_flow_ctrl_set_parsed,
7016 .data = (void *)&cmd_link_flow_control_set_pt,
7017 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7018 "Change pause time flow control parameter",
7020 (void *)&cmd_lfc_set_set,
7021 (void *)&cmd_lfc_set_flow_ctrl,
7022 (void *)&cmd_lfc_set_pause_time_str,
7023 (void *)&cmd_lfc_set_pause_time,
7024 (void *)&cmd_lfc_set_portid,
7029 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7030 .f = cmd_link_flow_ctrl_set_parsed,
7031 .data = (void *)&cmd_link_flow_control_set_xon,
7032 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7033 "Change send_xon flow control parameter",
7035 (void *)&cmd_lfc_set_set,
7036 (void *)&cmd_lfc_set_flow_ctrl,
7037 (void *)&cmd_lfc_set_send_xon_str,
7038 (void *)&cmd_lfc_set_send_xon,
7039 (void *)&cmd_lfc_set_portid,
7044 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7045 .f = cmd_link_flow_ctrl_set_parsed,
7046 .data = (void *)&cmd_link_flow_control_set_macfwd,
7047 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7048 "Change mac ctrl fwd flow control parameter",
7050 (void *)&cmd_lfc_set_set,
7051 (void *)&cmd_lfc_set_flow_ctrl,
7052 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7053 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7054 (void *)&cmd_lfc_set_portid,
7059 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7060 .f = cmd_link_flow_ctrl_set_parsed,
7061 .data = (void *)&cmd_link_flow_control_set_autoneg,
7062 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7063 "Change autoneg flow control parameter",
7065 (void *)&cmd_lfc_set_set,
7066 (void *)&cmd_lfc_set_flow_ctrl,
7067 (void *)&cmd_lfc_set_autoneg_str,
7068 (void *)&cmd_lfc_set_autoneg,
7069 (void *)&cmd_lfc_set_portid,
7075 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7076 __rte_unused struct cmdline *cl,
7079 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7080 cmdline_parse_inst_t *cmd = data;
7081 struct rte_eth_fc_conf fc_conf;
7087 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7088 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7089 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7090 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7092 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7093 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7096 /* Partial command line, retrieve current configuration */
7098 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7100 printf("cannot get current flow ctrl parameters, return"
7101 "code = %d\n", ret);
7105 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7106 (fc_conf.mode == RTE_FC_FULL))
7108 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7109 (fc_conf.mode == RTE_FC_FULL))
7113 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7114 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7116 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7117 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7119 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7121 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7122 fc_conf.high_water = res->high_water;
7124 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7125 fc_conf.low_water = res->low_water;
7127 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7128 fc_conf.pause_time = res->pause_time;
7130 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7131 fc_conf.send_xon = res->send_xon;
7133 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7134 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7135 fc_conf.mac_ctrl_frame_fwd = 1;
7137 fc_conf.mac_ctrl_frame_fwd = 0;
7140 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7141 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7143 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7145 printf("bad flow contrl parameter, return code = %d \n", ret);
7148 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7149 struct cmd_priority_flow_ctrl_set_result {
7150 cmdline_fixed_string_t set;
7151 cmdline_fixed_string_t pfc_ctrl;
7152 cmdline_fixed_string_t rx;
7153 cmdline_fixed_string_t rx_pfc_mode;
7154 cmdline_fixed_string_t tx;
7155 cmdline_fixed_string_t tx_pfc_mode;
7156 uint32_t high_water;
7158 uint16_t pause_time;
7164 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7165 __rte_unused struct cmdline *cl,
7166 __rte_unused void *data)
7168 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7169 struct rte_eth_pfc_conf pfc_conf;
7170 int rx_fc_enable, tx_fc_enable;
7174 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7175 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7176 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7177 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7179 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7180 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7183 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7184 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7185 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7186 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7187 pfc_conf.fc.high_water = res->high_water;
7188 pfc_conf.fc.low_water = res->low_water;
7189 pfc_conf.fc.pause_time = res->pause_time;
7190 pfc_conf.priority = res->priority;
7192 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7194 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7197 cmdline_parse_token_string_t cmd_pfc_set_set =
7198 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7200 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7201 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7202 pfc_ctrl, "pfc_ctrl");
7203 cmdline_parse_token_string_t cmd_pfc_set_rx =
7204 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7206 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7207 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7208 rx_pfc_mode, "on#off");
7209 cmdline_parse_token_string_t cmd_pfc_set_tx =
7210 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7212 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7213 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7214 tx_pfc_mode, "on#off");
7215 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7216 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7217 high_water, RTE_UINT32);
7218 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7219 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7220 low_water, RTE_UINT32);
7221 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7222 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7223 pause_time, RTE_UINT16);
7224 cmdline_parse_token_num_t cmd_pfc_set_priority =
7225 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7226 priority, RTE_UINT8);
7227 cmdline_parse_token_num_t cmd_pfc_set_portid =
7228 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7229 port_id, RTE_UINT16);
7231 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7232 .f = cmd_priority_flow_ctrl_set_parsed,
7234 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7235 "<pause_time> <priority> <port_id>: "
7236 "Configure the Ethernet priority flow control",
7238 (void *)&cmd_pfc_set_set,
7239 (void *)&cmd_pfc_set_flow_ctrl,
7240 (void *)&cmd_pfc_set_rx,
7241 (void *)&cmd_pfc_set_rx_mode,
7242 (void *)&cmd_pfc_set_tx,
7243 (void *)&cmd_pfc_set_tx_mode,
7244 (void *)&cmd_pfc_set_high_water,
7245 (void *)&cmd_pfc_set_low_water,
7246 (void *)&cmd_pfc_set_pause_time,
7247 (void *)&cmd_pfc_set_priority,
7248 (void *)&cmd_pfc_set_portid,
7253 /* *** RESET CONFIGURATION *** */
7254 struct cmd_reset_result {
7255 cmdline_fixed_string_t reset;
7256 cmdline_fixed_string_t def;
7259 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7261 __rte_unused void *data)
7263 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7264 set_def_fwd_config();
7267 cmdline_parse_token_string_t cmd_reset_set =
7268 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7269 cmdline_parse_token_string_t cmd_reset_def =
7270 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7273 cmdline_parse_inst_t cmd_reset = {
7274 .f = cmd_reset_parsed,
7276 .help_str = "set default: Reset default forwarding configuration",
7278 (void *)&cmd_reset_set,
7279 (void *)&cmd_reset_def,
7284 /* *** START FORWARDING *** */
7285 struct cmd_start_result {
7286 cmdline_fixed_string_t start;
7289 cmdline_parse_token_string_t cmd_start_start =
7290 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7292 static void cmd_start_parsed(__rte_unused void *parsed_result,
7293 __rte_unused struct cmdline *cl,
7294 __rte_unused void *data)
7296 start_packet_forwarding(0);
7299 cmdline_parse_inst_t cmd_start = {
7300 .f = cmd_start_parsed,
7302 .help_str = "start: Start packet forwarding",
7304 (void *)&cmd_start_start,
7309 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7310 struct cmd_start_tx_first_result {
7311 cmdline_fixed_string_t start;
7312 cmdline_fixed_string_t tx_first;
7316 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7317 __rte_unused struct cmdline *cl,
7318 __rte_unused void *data)
7320 start_packet_forwarding(1);
7323 cmdline_parse_token_string_t cmd_start_tx_first_start =
7324 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7326 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7327 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7328 tx_first, "tx_first");
7330 cmdline_parse_inst_t cmd_start_tx_first = {
7331 .f = cmd_start_tx_first_parsed,
7333 .help_str = "start tx_first: Start packet forwarding, "
7334 "after sending 1 burst of packets",
7336 (void *)&cmd_start_tx_first_start,
7337 (void *)&cmd_start_tx_first_tx_first,
7342 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7343 struct cmd_start_tx_first_n_result {
7344 cmdline_fixed_string_t start;
7345 cmdline_fixed_string_t tx_first;
7350 cmd_start_tx_first_n_parsed(void *parsed_result,
7351 __rte_unused struct cmdline *cl,
7352 __rte_unused void *data)
7354 struct cmd_start_tx_first_n_result *res = parsed_result;
7356 start_packet_forwarding(res->tx_num);
7359 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7360 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7362 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7363 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7364 tx_first, "tx_first");
7365 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7366 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7367 tx_num, RTE_UINT32);
7369 cmdline_parse_inst_t cmd_start_tx_first_n = {
7370 .f = cmd_start_tx_first_n_parsed,
7372 .help_str = "start tx_first <num>: "
7373 "packet forwarding, after sending <num> bursts of packets",
7375 (void *)&cmd_start_tx_first_n_start,
7376 (void *)&cmd_start_tx_first_n_tx_first,
7377 (void *)&cmd_start_tx_first_n_tx_num,
7382 /* *** SET LINK UP *** */
7383 struct cmd_set_link_up_result {
7384 cmdline_fixed_string_t set;
7385 cmdline_fixed_string_t link_up;
7386 cmdline_fixed_string_t port;
7390 cmdline_parse_token_string_t cmd_set_link_up_set =
7391 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7392 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7393 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7395 cmdline_parse_token_string_t cmd_set_link_up_port =
7396 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7397 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7398 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7401 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7402 __rte_unused struct cmdline *cl,
7403 __rte_unused void *data)
7405 struct cmd_set_link_up_result *res = parsed_result;
7406 dev_set_link_up(res->port_id);
7409 cmdline_parse_inst_t cmd_set_link_up = {
7410 .f = cmd_set_link_up_parsed,
7412 .help_str = "set link-up port <port id>",
7414 (void *)&cmd_set_link_up_set,
7415 (void *)&cmd_set_link_up_link_up,
7416 (void *)&cmd_set_link_up_port,
7417 (void *)&cmd_set_link_up_port_id,
7422 /* *** SET LINK DOWN *** */
7423 struct cmd_set_link_down_result {
7424 cmdline_fixed_string_t set;
7425 cmdline_fixed_string_t link_down;
7426 cmdline_fixed_string_t port;
7430 cmdline_parse_token_string_t cmd_set_link_down_set =
7431 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7432 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7433 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7435 cmdline_parse_token_string_t cmd_set_link_down_port =
7436 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7437 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7438 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7441 static void cmd_set_link_down_parsed(
7442 __rte_unused void *parsed_result,
7443 __rte_unused struct cmdline *cl,
7444 __rte_unused void *data)
7446 struct cmd_set_link_down_result *res = parsed_result;
7447 dev_set_link_down(res->port_id);
7450 cmdline_parse_inst_t cmd_set_link_down = {
7451 .f = cmd_set_link_down_parsed,
7453 .help_str = "set link-down port <port id>",
7455 (void *)&cmd_set_link_down_set,
7456 (void *)&cmd_set_link_down_link_down,
7457 (void *)&cmd_set_link_down_port,
7458 (void *)&cmd_set_link_down_port_id,
7463 /* *** SHOW CFG *** */
7464 struct cmd_showcfg_result {
7465 cmdline_fixed_string_t show;
7466 cmdline_fixed_string_t cfg;
7467 cmdline_fixed_string_t what;
7470 static void cmd_showcfg_parsed(void *parsed_result,
7471 __rte_unused struct cmdline *cl,
7472 __rte_unused void *data)
7474 struct cmd_showcfg_result *res = parsed_result;
7475 if (!strcmp(res->what, "rxtx"))
7476 rxtx_config_display();
7477 else if (!strcmp(res->what, "cores"))
7478 fwd_lcores_config_display();
7479 else if (!strcmp(res->what, "fwd"))
7480 pkt_fwd_config_display(&cur_fwd_config);
7481 else if (!strcmp(res->what, "rxoffs"))
7482 show_rx_pkt_offsets();
7483 else if (!strcmp(res->what, "rxpkts"))
7484 show_rx_pkt_segments();
7485 else if (!strcmp(res->what, "txpkts"))
7486 show_tx_pkt_segments();
7487 else if (!strcmp(res->what, "txtimes"))
7488 show_tx_pkt_times();
7491 cmdline_parse_token_string_t cmd_showcfg_show =
7492 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7493 cmdline_parse_token_string_t cmd_showcfg_port =
7494 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7495 cmdline_parse_token_string_t cmd_showcfg_what =
7496 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7497 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7499 cmdline_parse_inst_t cmd_showcfg = {
7500 .f = cmd_showcfg_parsed,
7502 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7504 (void *)&cmd_showcfg_show,
7505 (void *)&cmd_showcfg_port,
7506 (void *)&cmd_showcfg_what,
7511 /* *** SHOW ALL PORT INFO *** */
7512 struct cmd_showportall_result {
7513 cmdline_fixed_string_t show;
7514 cmdline_fixed_string_t port;
7515 cmdline_fixed_string_t what;
7516 cmdline_fixed_string_t all;
7519 static void cmd_showportall_parsed(void *parsed_result,
7520 __rte_unused struct cmdline *cl,
7521 __rte_unused void *data)
7525 struct cmd_showportall_result *res = parsed_result;
7526 if (!strcmp(res->show, "clear")) {
7527 if (!strcmp(res->what, "stats"))
7528 RTE_ETH_FOREACH_DEV(i)
7530 else if (!strcmp(res->what, "xstats"))
7531 RTE_ETH_FOREACH_DEV(i)
7532 nic_xstats_clear(i);
7533 } else if (!strcmp(res->what, "info"))
7534 RTE_ETH_FOREACH_DEV(i)
7535 port_infos_display(i);
7536 else if (!strcmp(res->what, "summary")) {
7537 port_summary_header_display();
7538 RTE_ETH_FOREACH_DEV(i)
7539 port_summary_display(i);
7541 else if (!strcmp(res->what, "stats"))
7542 RTE_ETH_FOREACH_DEV(i)
7543 nic_stats_display(i);
7544 else if (!strcmp(res->what, "xstats"))
7545 RTE_ETH_FOREACH_DEV(i)
7546 nic_xstats_display(i);
7547 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7548 else if (!strcmp(res->what, "fdir"))
7549 RTE_ETH_FOREACH_DEV(i)
7552 else if (!strcmp(res->what, "dcb_tc"))
7553 RTE_ETH_FOREACH_DEV(i)
7554 port_dcb_info_display(i);
7555 else if (!strcmp(res->what, "cap"))
7556 RTE_ETH_FOREACH_DEV(i)
7557 port_offload_cap_display(i);
7560 cmdline_parse_token_string_t cmd_showportall_show =
7561 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7563 cmdline_parse_token_string_t cmd_showportall_port =
7564 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7565 cmdline_parse_token_string_t cmd_showportall_what =
7566 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7567 "info#summary#stats#xstats#fdir#dcb_tc#cap");
7568 cmdline_parse_token_string_t cmd_showportall_all =
7569 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7570 cmdline_parse_inst_t cmd_showportall = {
7571 .f = cmd_showportall_parsed,
7573 .help_str = "show|clear port "
7574 "info|summary|stats|xstats|fdir|dcb_tc|cap all",
7576 (void *)&cmd_showportall_show,
7577 (void *)&cmd_showportall_port,
7578 (void *)&cmd_showportall_what,
7579 (void *)&cmd_showportall_all,
7584 /* *** SHOW PORT INFO *** */
7585 struct cmd_showport_result {
7586 cmdline_fixed_string_t show;
7587 cmdline_fixed_string_t port;
7588 cmdline_fixed_string_t what;
7592 static void cmd_showport_parsed(void *parsed_result,
7593 __rte_unused struct cmdline *cl,
7594 __rte_unused void *data)
7596 struct cmd_showport_result *res = parsed_result;
7597 if (!strcmp(res->show, "clear")) {
7598 if (!strcmp(res->what, "stats"))
7599 nic_stats_clear(res->portnum);
7600 else if (!strcmp(res->what, "xstats"))
7601 nic_xstats_clear(res->portnum);
7602 } else if (!strcmp(res->what, "info"))
7603 port_infos_display(res->portnum);
7604 else if (!strcmp(res->what, "summary")) {
7605 port_summary_header_display();
7606 port_summary_display(res->portnum);
7608 else if (!strcmp(res->what, "stats"))
7609 nic_stats_display(res->portnum);
7610 else if (!strcmp(res->what, "xstats"))
7611 nic_xstats_display(res->portnum);
7612 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7613 else if (!strcmp(res->what, "fdir"))
7614 fdir_get_infos(res->portnum);
7616 else if (!strcmp(res->what, "dcb_tc"))
7617 port_dcb_info_display(res->portnum);
7618 else if (!strcmp(res->what, "cap"))
7619 port_offload_cap_display(res->portnum);
7622 cmdline_parse_token_string_t cmd_showport_show =
7623 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7625 cmdline_parse_token_string_t cmd_showport_port =
7626 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7627 cmdline_parse_token_string_t cmd_showport_what =
7628 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7629 "info#summary#stats#xstats#fdir#dcb_tc#cap");
7630 cmdline_parse_token_num_t cmd_showport_portnum =
7631 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
7633 cmdline_parse_inst_t cmd_showport = {
7634 .f = cmd_showport_parsed,
7636 .help_str = "show|clear port "
7637 "info|summary|stats|xstats|fdir|dcb_tc|cap "
7640 (void *)&cmd_showport_show,
7641 (void *)&cmd_showport_port,
7642 (void *)&cmd_showport_what,
7643 (void *)&cmd_showport_portnum,
7648 /* *** SHOW DEVICE INFO *** */
7649 struct cmd_showdevice_result {
7650 cmdline_fixed_string_t show;
7651 cmdline_fixed_string_t device;
7652 cmdline_fixed_string_t what;
7653 cmdline_fixed_string_t identifier;
7656 static void cmd_showdevice_parsed(void *parsed_result,
7657 __rte_unused struct cmdline *cl,
7658 __rte_unused void *data)
7660 struct cmd_showdevice_result *res = parsed_result;
7661 if (!strcmp(res->what, "info")) {
7662 if (!strcmp(res->identifier, "all"))
7663 device_infos_display(NULL);
7665 device_infos_display(res->identifier);
7669 cmdline_parse_token_string_t cmd_showdevice_show =
7670 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7672 cmdline_parse_token_string_t cmd_showdevice_device =
7673 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7674 cmdline_parse_token_string_t cmd_showdevice_what =
7675 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7677 cmdline_parse_token_string_t cmd_showdevice_identifier =
7678 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7681 cmdline_parse_inst_t cmd_showdevice = {
7682 .f = cmd_showdevice_parsed,
7684 .help_str = "show device info <identifier>|all",
7686 (void *)&cmd_showdevice_show,
7687 (void *)&cmd_showdevice_device,
7688 (void *)&cmd_showdevice_what,
7689 (void *)&cmd_showdevice_identifier,
7694 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7695 struct cmd_showeeprom_result {
7696 cmdline_fixed_string_t show;
7697 cmdline_fixed_string_t port;
7699 cmdline_fixed_string_t type;
7702 static void cmd_showeeprom_parsed(void *parsed_result,
7703 __rte_unused struct cmdline *cl,
7704 __rte_unused void *data)
7706 struct cmd_showeeprom_result *res = parsed_result;
7708 if (!strcmp(res->type, "eeprom"))
7709 port_eeprom_display(res->portnum);
7710 else if (!strcmp(res->type, "module_eeprom"))
7711 port_module_eeprom_display(res->portnum);
7713 printf("Unknown argument\n");
7716 cmdline_parse_token_string_t cmd_showeeprom_show =
7717 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7718 cmdline_parse_token_string_t cmd_showeeprom_port =
7719 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7720 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7721 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7723 cmdline_parse_token_string_t cmd_showeeprom_type =
7724 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7726 cmdline_parse_inst_t cmd_showeeprom = {
7727 .f = cmd_showeeprom_parsed,
7729 .help_str = "show port <port_id> module_eeprom|eeprom",
7731 (void *)&cmd_showeeprom_show,
7732 (void *)&cmd_showeeprom_port,
7733 (void *)&cmd_showeeprom_portnum,
7734 (void *)&cmd_showeeprom_type,
7739 /* *** SHOW QUEUE INFO *** */
7740 struct cmd_showqueue_result {
7741 cmdline_fixed_string_t show;
7742 cmdline_fixed_string_t type;
7743 cmdline_fixed_string_t what;
7749 cmd_showqueue_parsed(void *parsed_result,
7750 __rte_unused struct cmdline *cl,
7751 __rte_unused void *data)
7753 struct cmd_showqueue_result *res = parsed_result;
7755 if (!strcmp(res->type, "rxq"))
7756 rx_queue_infos_display(res->portnum, res->queuenum);
7757 else if (!strcmp(res->type, "txq"))
7758 tx_queue_infos_display(res->portnum, res->queuenum);
7761 cmdline_parse_token_string_t cmd_showqueue_show =
7762 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7763 cmdline_parse_token_string_t cmd_showqueue_type =
7764 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7765 cmdline_parse_token_string_t cmd_showqueue_what =
7766 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7767 cmdline_parse_token_num_t cmd_showqueue_portnum =
7768 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
7770 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7771 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
7774 cmdline_parse_inst_t cmd_showqueue = {
7775 .f = cmd_showqueue_parsed,
7777 .help_str = "show rxq|txq info <port_id> <queue_id>",
7779 (void *)&cmd_showqueue_show,
7780 (void *)&cmd_showqueue_type,
7781 (void *)&cmd_showqueue_what,
7782 (void *)&cmd_showqueue_portnum,
7783 (void *)&cmd_showqueue_queuenum,
7788 /* show/clear fwd engine statistics */
7790 cmdline_fixed_string_t action;
7791 cmdline_fixed_string_t fwd;
7792 cmdline_fixed_string_t stats;
7793 cmdline_fixed_string_t all;
7796 cmdline_parse_token_string_t cmd_fwd_action =
7797 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7798 cmdline_parse_token_string_t cmd_fwd_fwd =
7799 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7800 cmdline_parse_token_string_t cmd_fwd_stats =
7801 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7802 cmdline_parse_token_string_t cmd_fwd_all =
7803 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7806 cmd_showfwdall_parsed(void *parsed_result,
7807 __rte_unused struct cmdline *cl,
7808 __rte_unused void *data)
7810 struct fwd_result *res = parsed_result;
7812 if (!strcmp(res->action, "show"))
7813 fwd_stats_display();
7818 static cmdline_parse_inst_t cmd_showfwdall = {
7819 .f = cmd_showfwdall_parsed,
7821 .help_str = "show|clear fwd stats all",
7823 (void *)&cmd_fwd_action,
7824 (void *)&cmd_fwd_fwd,
7825 (void *)&cmd_fwd_stats,
7826 (void *)&cmd_fwd_all,
7831 /* *** READ PORT REGISTER *** */
7832 struct cmd_read_reg_result {
7833 cmdline_fixed_string_t read;
7834 cmdline_fixed_string_t reg;
7840 cmd_read_reg_parsed(void *parsed_result,
7841 __rte_unused struct cmdline *cl,
7842 __rte_unused void *data)
7844 struct cmd_read_reg_result *res = parsed_result;
7845 port_reg_display(res->port_id, res->reg_off);
7848 cmdline_parse_token_string_t cmd_read_reg_read =
7849 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7850 cmdline_parse_token_string_t cmd_read_reg_reg =
7851 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7852 cmdline_parse_token_num_t cmd_read_reg_port_id =
7853 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
7854 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7855 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
7857 cmdline_parse_inst_t cmd_read_reg = {
7858 .f = cmd_read_reg_parsed,
7860 .help_str = "read reg <port_id> <reg_off>",
7862 (void *)&cmd_read_reg_read,
7863 (void *)&cmd_read_reg_reg,
7864 (void *)&cmd_read_reg_port_id,
7865 (void *)&cmd_read_reg_reg_off,
7870 /* *** READ PORT REGISTER BIT FIELD *** */
7871 struct cmd_read_reg_bit_field_result {
7872 cmdline_fixed_string_t read;
7873 cmdline_fixed_string_t regfield;
7881 cmd_read_reg_bit_field_parsed(void *parsed_result,
7882 __rte_unused struct cmdline *cl,
7883 __rte_unused void *data)
7885 struct cmd_read_reg_bit_field_result *res = parsed_result;
7886 port_reg_bit_field_display(res->port_id, res->reg_off,
7887 res->bit1_pos, res->bit2_pos);
7890 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7891 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7893 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7894 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7895 regfield, "regfield");
7896 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7897 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7899 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7900 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7902 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7903 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7905 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7906 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7909 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7910 .f = cmd_read_reg_bit_field_parsed,
7912 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7913 "Read register bit field between bit_x and bit_y included",
7915 (void *)&cmd_read_reg_bit_field_read,
7916 (void *)&cmd_read_reg_bit_field_regfield,
7917 (void *)&cmd_read_reg_bit_field_port_id,
7918 (void *)&cmd_read_reg_bit_field_reg_off,
7919 (void *)&cmd_read_reg_bit_field_bit1_pos,
7920 (void *)&cmd_read_reg_bit_field_bit2_pos,
7925 /* *** READ PORT REGISTER BIT *** */
7926 struct cmd_read_reg_bit_result {
7927 cmdline_fixed_string_t read;
7928 cmdline_fixed_string_t regbit;
7935 cmd_read_reg_bit_parsed(void *parsed_result,
7936 __rte_unused struct cmdline *cl,
7937 __rte_unused void *data)
7939 struct cmd_read_reg_bit_result *res = parsed_result;
7940 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7943 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7944 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7945 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7946 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7948 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7949 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
7951 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7952 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
7954 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7955 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
7958 cmdline_parse_inst_t cmd_read_reg_bit = {
7959 .f = cmd_read_reg_bit_parsed,
7961 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7963 (void *)&cmd_read_reg_bit_read,
7964 (void *)&cmd_read_reg_bit_regbit,
7965 (void *)&cmd_read_reg_bit_port_id,
7966 (void *)&cmd_read_reg_bit_reg_off,
7967 (void *)&cmd_read_reg_bit_bit_pos,
7972 /* *** WRITE PORT REGISTER *** */
7973 struct cmd_write_reg_result {
7974 cmdline_fixed_string_t write;
7975 cmdline_fixed_string_t reg;
7982 cmd_write_reg_parsed(void *parsed_result,
7983 __rte_unused struct cmdline *cl,
7984 __rte_unused void *data)
7986 struct cmd_write_reg_result *res = parsed_result;
7987 port_reg_set(res->port_id, res->reg_off, res->value);
7990 cmdline_parse_token_string_t cmd_write_reg_write =
7991 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7992 cmdline_parse_token_string_t cmd_write_reg_reg =
7993 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7994 cmdline_parse_token_num_t cmd_write_reg_port_id =
7995 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
7996 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7997 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
7998 cmdline_parse_token_num_t cmd_write_reg_value =
7999 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8001 cmdline_parse_inst_t cmd_write_reg = {
8002 .f = cmd_write_reg_parsed,
8004 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8006 (void *)&cmd_write_reg_write,
8007 (void *)&cmd_write_reg_reg,
8008 (void *)&cmd_write_reg_port_id,
8009 (void *)&cmd_write_reg_reg_off,
8010 (void *)&cmd_write_reg_value,
8015 /* *** WRITE PORT REGISTER BIT FIELD *** */
8016 struct cmd_write_reg_bit_field_result {
8017 cmdline_fixed_string_t write;
8018 cmdline_fixed_string_t regfield;
8027 cmd_write_reg_bit_field_parsed(void *parsed_result,
8028 __rte_unused struct cmdline *cl,
8029 __rte_unused void *data)
8031 struct cmd_write_reg_bit_field_result *res = parsed_result;
8032 port_reg_bit_field_set(res->port_id, res->reg_off,
8033 res->bit1_pos, res->bit2_pos, res->value);
8036 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8037 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8039 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8040 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8041 regfield, "regfield");
8042 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8043 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8045 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8046 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8048 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8049 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8051 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8052 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8054 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8055 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8058 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8059 .f = cmd_write_reg_bit_field_parsed,
8061 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8063 "Set register bit field between bit_x and bit_y included",
8065 (void *)&cmd_write_reg_bit_field_write,
8066 (void *)&cmd_write_reg_bit_field_regfield,
8067 (void *)&cmd_write_reg_bit_field_port_id,
8068 (void *)&cmd_write_reg_bit_field_reg_off,
8069 (void *)&cmd_write_reg_bit_field_bit1_pos,
8070 (void *)&cmd_write_reg_bit_field_bit2_pos,
8071 (void *)&cmd_write_reg_bit_field_value,
8076 /* *** WRITE PORT REGISTER BIT *** */
8077 struct cmd_write_reg_bit_result {
8078 cmdline_fixed_string_t write;
8079 cmdline_fixed_string_t regbit;
8087 cmd_write_reg_bit_parsed(void *parsed_result,
8088 __rte_unused struct cmdline *cl,
8089 __rte_unused void *data)
8091 struct cmd_write_reg_bit_result *res = parsed_result;
8092 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8095 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8096 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8098 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8099 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8101 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8102 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8104 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8105 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8107 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8108 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8110 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8111 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8114 cmdline_parse_inst_t cmd_write_reg_bit = {
8115 .f = cmd_write_reg_bit_parsed,
8117 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8120 (void *)&cmd_write_reg_bit_write,
8121 (void *)&cmd_write_reg_bit_regbit,
8122 (void *)&cmd_write_reg_bit_port_id,
8123 (void *)&cmd_write_reg_bit_reg_off,
8124 (void *)&cmd_write_reg_bit_bit_pos,
8125 (void *)&cmd_write_reg_bit_value,
8130 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8131 struct cmd_read_rxd_txd_result {
8132 cmdline_fixed_string_t read;
8133 cmdline_fixed_string_t rxd_txd;
8140 cmd_read_rxd_txd_parsed(void *parsed_result,
8141 __rte_unused struct cmdline *cl,
8142 __rte_unused void *data)
8144 struct cmd_read_rxd_txd_result *res = parsed_result;
8146 if (!strcmp(res->rxd_txd, "rxd"))
8147 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8148 else if (!strcmp(res->rxd_txd, "txd"))
8149 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8152 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8153 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8154 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8155 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8157 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8158 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8160 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8161 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8163 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8164 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8167 cmdline_parse_inst_t cmd_read_rxd_txd = {
8168 .f = cmd_read_rxd_txd_parsed,
8170 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8172 (void *)&cmd_read_rxd_txd_read,
8173 (void *)&cmd_read_rxd_txd_rxd_txd,
8174 (void *)&cmd_read_rxd_txd_port_id,
8175 (void *)&cmd_read_rxd_txd_queue_id,
8176 (void *)&cmd_read_rxd_txd_desc_id,
8182 struct cmd_quit_result {
8183 cmdline_fixed_string_t quit;
8186 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8188 __rte_unused void *data)
8193 cmdline_parse_token_string_t cmd_quit_quit =
8194 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8196 cmdline_parse_inst_t cmd_quit = {
8197 .f = cmd_quit_parsed,
8199 .help_str = "quit: Exit application",
8201 (void *)&cmd_quit_quit,
8206 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8207 struct cmd_mac_addr_result {
8208 cmdline_fixed_string_t mac_addr_cmd;
8209 cmdline_fixed_string_t what;
8211 struct rte_ether_addr address;
8214 static void cmd_mac_addr_parsed(void *parsed_result,
8215 __rte_unused struct cmdline *cl,
8216 __rte_unused void *data)
8218 struct cmd_mac_addr_result *res = parsed_result;
8221 if (strcmp(res->what, "add") == 0)
8222 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8223 else if (strcmp(res->what, "set") == 0)
8224 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8227 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8229 /* check the return value and print it if is < 0 */
8231 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8235 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8236 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8238 cmdline_parse_token_string_t cmd_mac_addr_what =
8239 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8241 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8242 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8244 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8245 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8247 cmdline_parse_inst_t cmd_mac_addr = {
8248 .f = cmd_mac_addr_parsed,
8250 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8251 "Add/Remove/Set MAC address on port_id",
8253 (void *)&cmd_mac_addr_cmd,
8254 (void *)&cmd_mac_addr_what,
8255 (void *)&cmd_mac_addr_portnum,
8256 (void *)&cmd_mac_addr_addr,
8261 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8262 struct cmd_eth_peer_result {
8263 cmdline_fixed_string_t set;
8264 cmdline_fixed_string_t eth_peer;
8266 cmdline_fixed_string_t peer_addr;
8269 static void cmd_set_eth_peer_parsed(void *parsed_result,
8270 __rte_unused struct cmdline *cl,
8271 __rte_unused void *data)
8273 struct cmd_eth_peer_result *res = parsed_result;
8275 if (test_done == 0) {
8276 printf("Please stop forwarding first\n");
8279 if (!strcmp(res->eth_peer, "eth-peer")) {
8280 set_fwd_eth_peer(res->port_id, res->peer_addr);
8284 cmdline_parse_token_string_t cmd_eth_peer_set =
8285 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8286 cmdline_parse_token_string_t cmd_eth_peer =
8287 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8288 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8289 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8291 cmdline_parse_token_string_t cmd_eth_peer_addr =
8292 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8294 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8295 .f = cmd_set_eth_peer_parsed,
8297 .help_str = "set eth-peer <port_id> <peer_mac>",
8299 (void *)&cmd_eth_peer_set,
8300 (void *)&cmd_eth_peer,
8301 (void *)&cmd_eth_peer_port_id,
8302 (void *)&cmd_eth_peer_addr,
8307 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8308 struct cmd_set_qmap_result {
8309 cmdline_fixed_string_t set;
8310 cmdline_fixed_string_t qmap;
8311 cmdline_fixed_string_t what;
8318 cmd_set_qmap_parsed(void *parsed_result,
8319 __rte_unused struct cmdline *cl,
8320 __rte_unused void *data)
8322 struct cmd_set_qmap_result *res = parsed_result;
8323 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8325 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8328 cmdline_parse_token_string_t cmd_setqmap_set =
8329 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8331 cmdline_parse_token_string_t cmd_setqmap_qmap =
8332 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8334 cmdline_parse_token_string_t cmd_setqmap_what =
8335 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8337 cmdline_parse_token_num_t cmd_setqmap_portid =
8338 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8339 port_id, RTE_UINT16);
8340 cmdline_parse_token_num_t cmd_setqmap_queueid =
8341 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8342 queue_id, RTE_UINT16);
8343 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8344 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8345 map_value, RTE_UINT8);
8347 cmdline_parse_inst_t cmd_set_qmap = {
8348 .f = cmd_set_qmap_parsed,
8350 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8351 "Set statistics mapping value on tx|rx queue_id of port_id",
8353 (void *)&cmd_setqmap_set,
8354 (void *)&cmd_setqmap_qmap,
8355 (void *)&cmd_setqmap_what,
8356 (void *)&cmd_setqmap_portid,
8357 (void *)&cmd_setqmap_queueid,
8358 (void *)&cmd_setqmap_mapvalue,
8363 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8364 struct cmd_set_xstats_hide_zero_result {
8365 cmdline_fixed_string_t keyword;
8366 cmdline_fixed_string_t name;
8367 cmdline_fixed_string_t on_off;
8371 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8372 __rte_unused struct cmdline *cl,
8373 __rte_unused void *data)
8375 struct cmd_set_xstats_hide_zero_result *res;
8376 uint16_t on_off = 0;
8378 res = parsed_result;
8379 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8380 set_xstats_hide_zero(on_off);
8383 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8384 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8386 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8387 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8388 name, "xstats-hide-zero");
8389 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8390 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8393 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8394 .f = cmd_set_xstats_hide_zero_parsed,
8396 .help_str = "set xstats-hide-zero on|off",
8398 (void *)&cmd_set_xstats_hide_zero_keyword,
8399 (void *)&cmd_set_xstats_hide_zero_name,
8400 (void *)&cmd_set_xstats_hide_zero_on_off,
8405 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8406 struct cmd_set_record_core_cycles_result {
8407 cmdline_fixed_string_t keyword;
8408 cmdline_fixed_string_t name;
8409 cmdline_fixed_string_t on_off;
8413 cmd_set_record_core_cycles_parsed(void *parsed_result,
8414 __rte_unused struct cmdline *cl,
8415 __rte_unused void *data)
8417 struct cmd_set_record_core_cycles_result *res;
8418 uint16_t on_off = 0;
8420 res = parsed_result;
8421 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8422 set_record_core_cycles(on_off);
8425 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8426 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8428 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8429 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8430 name, "record-core-cycles");
8431 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8432 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8435 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8436 .f = cmd_set_record_core_cycles_parsed,
8438 .help_str = "set record-core-cycles on|off",
8440 (void *)&cmd_set_record_core_cycles_keyword,
8441 (void *)&cmd_set_record_core_cycles_name,
8442 (void *)&cmd_set_record_core_cycles_on_off,
8447 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8448 struct cmd_set_record_burst_stats_result {
8449 cmdline_fixed_string_t keyword;
8450 cmdline_fixed_string_t name;
8451 cmdline_fixed_string_t on_off;
8455 cmd_set_record_burst_stats_parsed(void *parsed_result,
8456 __rte_unused struct cmdline *cl,
8457 __rte_unused void *data)
8459 struct cmd_set_record_burst_stats_result *res;
8460 uint16_t on_off = 0;
8462 res = parsed_result;
8463 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8464 set_record_burst_stats(on_off);
8467 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8468 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8470 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8471 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8472 name, "record-burst-stats");
8473 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8474 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8477 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8478 .f = cmd_set_record_burst_stats_parsed,
8480 .help_str = "set record-burst-stats on|off",
8482 (void *)&cmd_set_record_burst_stats_keyword,
8483 (void *)&cmd_set_record_burst_stats_name,
8484 (void *)&cmd_set_record_burst_stats_on_off,
8489 /* *** CONFIGURE UNICAST HASH TABLE *** */
8490 struct cmd_set_uc_hash_table {
8491 cmdline_fixed_string_t set;
8492 cmdline_fixed_string_t port;
8494 cmdline_fixed_string_t what;
8495 struct rte_ether_addr address;
8496 cmdline_fixed_string_t mode;
8500 cmd_set_uc_hash_parsed(void *parsed_result,
8501 __rte_unused struct cmdline *cl,
8502 __rte_unused void *data)
8505 struct cmd_set_uc_hash_table *res = parsed_result;
8507 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8509 if (strcmp(res->what, "uta") == 0)
8510 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8511 &res->address,(uint8_t)is_on);
8513 printf("bad unicast hash table parameter, return code = %d \n", ret);
8517 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8518 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8520 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8521 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8523 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8524 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8525 port_id, RTE_UINT16);
8526 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8527 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8529 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8530 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8532 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8533 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8536 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8537 .f = cmd_set_uc_hash_parsed,
8539 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8541 (void *)&cmd_set_uc_hash_set,
8542 (void *)&cmd_set_uc_hash_port,
8543 (void *)&cmd_set_uc_hash_portid,
8544 (void *)&cmd_set_uc_hash_what,
8545 (void *)&cmd_set_uc_hash_mac,
8546 (void *)&cmd_set_uc_hash_mode,
8551 struct cmd_set_uc_all_hash_table {
8552 cmdline_fixed_string_t set;
8553 cmdline_fixed_string_t port;
8555 cmdline_fixed_string_t what;
8556 cmdline_fixed_string_t value;
8557 cmdline_fixed_string_t mode;
8561 cmd_set_uc_all_hash_parsed(void *parsed_result,
8562 __rte_unused struct cmdline *cl,
8563 __rte_unused void *data)
8566 struct cmd_set_uc_all_hash_table *res = parsed_result;
8568 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8570 if ((strcmp(res->what, "uta") == 0) &&
8571 (strcmp(res->value, "all") == 0))
8572 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8574 printf("bad unicast hash table parameter,"
8575 "return code = %d \n", ret);
8578 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8579 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8581 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8582 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8584 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8585 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8586 port_id, RTE_UINT16);
8587 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8588 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8590 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8591 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8593 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8594 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8597 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8598 .f = cmd_set_uc_all_hash_parsed,
8600 .help_str = "set port <port_id> uta all on|off",
8602 (void *)&cmd_set_uc_all_hash_set,
8603 (void *)&cmd_set_uc_all_hash_port,
8604 (void *)&cmd_set_uc_all_hash_portid,
8605 (void *)&cmd_set_uc_all_hash_what,
8606 (void *)&cmd_set_uc_all_hash_value,
8607 (void *)&cmd_set_uc_all_hash_mode,
8612 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8613 struct cmd_set_vf_traffic {
8614 cmdline_fixed_string_t set;
8615 cmdline_fixed_string_t port;
8617 cmdline_fixed_string_t vf;
8619 cmdline_fixed_string_t what;
8620 cmdline_fixed_string_t mode;
8624 cmd_set_vf_traffic_parsed(void *parsed_result,
8625 __rte_unused struct cmdline *cl,
8626 __rte_unused void *data)
8628 struct cmd_set_vf_traffic *res = parsed_result;
8629 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8630 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8632 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8635 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8636 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8638 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8639 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8641 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8642 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8643 port_id, RTE_UINT16);
8644 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8645 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8647 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8648 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8650 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8651 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8653 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8654 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8657 cmdline_parse_inst_t cmd_set_vf_traffic = {
8658 .f = cmd_set_vf_traffic_parsed,
8660 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8662 (void *)&cmd_setvf_traffic_set,
8663 (void *)&cmd_setvf_traffic_port,
8664 (void *)&cmd_setvf_traffic_portid,
8665 (void *)&cmd_setvf_traffic_vf,
8666 (void *)&cmd_setvf_traffic_vfid,
8667 (void *)&cmd_setvf_traffic_what,
8668 (void *)&cmd_setvf_traffic_mode,
8673 /* *** CONFIGURE VF RECEIVE MODE *** */
8674 struct cmd_set_vf_rxmode {
8675 cmdline_fixed_string_t set;
8676 cmdline_fixed_string_t port;
8678 cmdline_fixed_string_t vf;
8680 cmdline_fixed_string_t what;
8681 cmdline_fixed_string_t mode;
8682 cmdline_fixed_string_t on;
8686 cmd_set_vf_rxmode_parsed(void *parsed_result,
8687 __rte_unused struct cmdline *cl,
8688 __rte_unused void *data)
8691 uint16_t vf_rxmode = 0;
8692 struct cmd_set_vf_rxmode *res = parsed_result;
8694 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8695 if (!strcmp(res->what,"rxmode")) {
8696 if (!strcmp(res->mode, "AUPE"))
8697 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8698 else if (!strcmp(res->mode, "ROPE"))
8699 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8700 else if (!strcmp(res->mode, "BAM"))
8701 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8702 else if (!strncmp(res->mode, "MPE",3))
8703 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8706 RTE_SET_USED(is_on);
8708 #ifdef RTE_NET_IXGBE
8709 if (ret == -ENOTSUP)
8710 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8711 vf_rxmode, (uint8_t)is_on);
8714 if (ret == -ENOTSUP)
8715 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8716 vf_rxmode, (uint8_t)is_on);
8719 printf("bad VF receive mode parameter, return code = %d \n",
8723 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8724 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8726 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8727 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8729 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8730 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8731 port_id, RTE_UINT16);
8732 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8733 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8735 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8736 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8738 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8739 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8741 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8742 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8743 mode, "AUPE#ROPE#BAM#MPE");
8744 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8745 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8748 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8749 .f = cmd_set_vf_rxmode_parsed,
8751 .help_str = "set port <port_id> vf <vf_id> rxmode "
8752 "AUPE|ROPE|BAM|MPE on|off",
8754 (void *)&cmd_set_vf_rxmode_set,
8755 (void *)&cmd_set_vf_rxmode_port,
8756 (void *)&cmd_set_vf_rxmode_portid,
8757 (void *)&cmd_set_vf_rxmode_vf,
8758 (void *)&cmd_set_vf_rxmode_vfid,
8759 (void *)&cmd_set_vf_rxmode_what,
8760 (void *)&cmd_set_vf_rxmode_mode,
8761 (void *)&cmd_set_vf_rxmode_on,
8766 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8767 struct cmd_vf_mac_addr_result {
8768 cmdline_fixed_string_t mac_addr_cmd;
8769 cmdline_fixed_string_t what;
8770 cmdline_fixed_string_t port;
8772 cmdline_fixed_string_t vf;
8774 struct rte_ether_addr address;
8777 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8778 __rte_unused struct cmdline *cl,
8779 __rte_unused void *data)
8781 struct cmd_vf_mac_addr_result *res = parsed_result;
8784 if (strcmp(res->what, "add") != 0)
8788 if (ret == -ENOTSUP)
8789 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8793 if (ret == -ENOTSUP)
8794 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8799 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8803 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8804 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8805 mac_addr_cmd,"mac_addr");
8806 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8807 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8809 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8810 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8812 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8813 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8814 port_num, RTE_UINT16);
8815 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8816 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8818 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8819 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8821 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8822 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8825 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8826 .f = cmd_vf_mac_addr_parsed,
8828 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8829 "Add MAC address filtering for a VF on port_id",
8831 (void *)&cmd_vf_mac_addr_cmd,
8832 (void *)&cmd_vf_mac_addr_what,
8833 (void *)&cmd_vf_mac_addr_port,
8834 (void *)&cmd_vf_mac_addr_portnum,
8835 (void *)&cmd_vf_mac_addr_vf,
8836 (void *)&cmd_vf_mac_addr_vfnum,
8837 (void *)&cmd_vf_mac_addr_addr,
8842 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8843 struct cmd_vf_rx_vlan_filter {
8844 cmdline_fixed_string_t rx_vlan;
8845 cmdline_fixed_string_t what;
8847 cmdline_fixed_string_t port;
8849 cmdline_fixed_string_t vf;
8854 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8855 __rte_unused struct cmdline *cl,
8856 __rte_unused void *data)
8858 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8861 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8863 #ifdef RTE_NET_IXGBE
8864 if (ret == -ENOTSUP)
8865 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8866 res->vlan_id, res->vf_mask, is_add);
8869 if (ret == -ENOTSUP)
8870 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8871 res->vlan_id, res->vf_mask, is_add);
8874 if (ret == -ENOTSUP)
8875 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8876 res->vlan_id, res->vf_mask, is_add);
8883 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8884 res->vlan_id, res->vf_mask);
8887 printf("invalid port_id %d\n", res->port_id);
8890 printf("function not implemented or supported\n");
8893 printf("programming error: (%s)\n", strerror(-ret));
8897 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8898 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8899 rx_vlan, "rx_vlan");
8900 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8901 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8903 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8904 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8905 vlan_id, RTE_UINT16);
8906 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8907 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8909 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8910 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8911 port_id, RTE_UINT16);
8912 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8913 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8915 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8916 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8917 vf_mask, RTE_UINT64);
8919 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8920 .f = cmd_vf_rx_vlan_filter_parsed,
8922 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8923 "(vf_mask = hexadecimal VF mask)",
8925 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8926 (void *)&cmd_vf_rx_vlan_filter_what,
8927 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8928 (void *)&cmd_vf_rx_vlan_filter_port,
8929 (void *)&cmd_vf_rx_vlan_filter_portid,
8930 (void *)&cmd_vf_rx_vlan_filter_vf,
8931 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8936 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8937 struct cmd_queue_rate_limit_result {
8938 cmdline_fixed_string_t set;
8939 cmdline_fixed_string_t port;
8941 cmdline_fixed_string_t queue;
8943 cmdline_fixed_string_t rate;
8947 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8948 __rte_unused struct cmdline *cl,
8949 __rte_unused void *data)
8951 struct cmd_queue_rate_limit_result *res = parsed_result;
8954 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8955 && (strcmp(res->queue, "queue") == 0)
8956 && (strcmp(res->rate, "rate") == 0))
8957 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8960 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8964 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8965 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8967 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8968 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8970 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8971 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8972 port_num, RTE_UINT16);
8973 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8974 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8976 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8977 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8978 queue_num, RTE_UINT8);
8979 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8980 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8982 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8983 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8984 rate_num, RTE_UINT16);
8986 cmdline_parse_inst_t cmd_queue_rate_limit = {
8987 .f = cmd_queue_rate_limit_parsed,
8989 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8990 "Set rate limit for a queue on port_id",
8992 (void *)&cmd_queue_rate_limit_set,
8993 (void *)&cmd_queue_rate_limit_port,
8994 (void *)&cmd_queue_rate_limit_portnum,
8995 (void *)&cmd_queue_rate_limit_queue,
8996 (void *)&cmd_queue_rate_limit_queuenum,
8997 (void *)&cmd_queue_rate_limit_rate,
8998 (void *)&cmd_queue_rate_limit_ratenum,
9003 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9004 struct cmd_vf_rate_limit_result {
9005 cmdline_fixed_string_t set;
9006 cmdline_fixed_string_t port;
9008 cmdline_fixed_string_t vf;
9010 cmdline_fixed_string_t rate;
9012 cmdline_fixed_string_t q_msk;
9016 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9017 __rte_unused struct cmdline *cl,
9018 __rte_unused void *data)
9020 struct cmd_vf_rate_limit_result *res = parsed_result;
9023 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9024 && (strcmp(res->vf, "vf") == 0)
9025 && (strcmp(res->rate, "rate") == 0)
9026 && (strcmp(res->q_msk, "queue_mask") == 0))
9027 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9028 res->rate_num, res->q_msk_val);
9030 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9034 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9035 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9037 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9038 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9040 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9041 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9042 port_num, RTE_UINT16);
9043 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9044 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9046 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9047 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9049 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9050 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9052 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9053 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9054 rate_num, RTE_UINT16);
9055 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9056 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9057 q_msk, "queue_mask");
9058 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9059 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9060 q_msk_val, RTE_UINT64);
9062 cmdline_parse_inst_t cmd_vf_rate_limit = {
9063 .f = cmd_vf_rate_limit_parsed,
9065 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9066 "queue_mask <queue_mask_value>: "
9067 "Set rate limit for queues of VF on port_id",
9069 (void *)&cmd_vf_rate_limit_set,
9070 (void *)&cmd_vf_rate_limit_port,
9071 (void *)&cmd_vf_rate_limit_portnum,
9072 (void *)&cmd_vf_rate_limit_vf,
9073 (void *)&cmd_vf_rate_limit_vfnum,
9074 (void *)&cmd_vf_rate_limit_rate,
9075 (void *)&cmd_vf_rate_limit_ratenum,
9076 (void *)&cmd_vf_rate_limit_q_msk,
9077 (void *)&cmd_vf_rate_limit_q_msk_val,
9082 /* *** CONFIGURE TUNNEL UDP PORT *** */
9083 struct cmd_tunnel_udp_config {
9084 cmdline_fixed_string_t cmd;
9085 cmdline_fixed_string_t what;
9091 cmd_tunnel_udp_config_parsed(void *parsed_result,
9092 __rte_unused struct cmdline *cl,
9093 __rte_unused void *data)
9095 struct cmd_tunnel_udp_config *res = parsed_result;
9096 struct rte_eth_udp_tunnel tunnel_udp;
9099 tunnel_udp.udp_port = res->udp_port;
9101 if (!strcmp(res->cmd, "rx_vxlan_port"))
9102 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9104 if (!strcmp(res->what, "add"))
9105 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9108 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9112 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9115 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9116 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9117 cmd, "rx_vxlan_port");
9118 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9119 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9121 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9122 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9123 udp_port, RTE_UINT16);
9124 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9125 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9126 port_id, RTE_UINT16);
9128 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9129 .f = cmd_tunnel_udp_config_parsed,
9131 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9132 "Add/Remove a tunneling UDP port filter",
9134 (void *)&cmd_tunnel_udp_config_cmd,
9135 (void *)&cmd_tunnel_udp_config_what,
9136 (void *)&cmd_tunnel_udp_config_udp_port,
9137 (void *)&cmd_tunnel_udp_config_port_id,
9142 struct cmd_config_tunnel_udp_port {
9143 cmdline_fixed_string_t port;
9144 cmdline_fixed_string_t config;
9146 cmdline_fixed_string_t udp_tunnel_port;
9147 cmdline_fixed_string_t action;
9148 cmdline_fixed_string_t tunnel_type;
9153 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9154 __rte_unused struct cmdline *cl,
9155 __rte_unused void *data)
9157 struct cmd_config_tunnel_udp_port *res = parsed_result;
9158 struct rte_eth_udp_tunnel tunnel_udp;
9161 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9164 tunnel_udp.udp_port = res->udp_port;
9166 if (!strcmp(res->tunnel_type, "vxlan")) {
9167 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9168 } else if (!strcmp(res->tunnel_type, "geneve")) {
9169 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9170 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9171 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9172 } else if (!strcmp(res->tunnel_type, "ecpri")) {
9173 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_ECPRI;
9175 printf("Invalid tunnel type\n");
9179 if (!strcmp(res->action, "add"))
9180 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9183 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9187 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9190 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9191 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9193 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9194 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9196 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9197 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9199 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9200 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9203 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9204 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9206 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9207 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9208 "vxlan#geneve#vxlan-gpe#ecpri");
9209 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9210 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9213 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9214 .f = cmd_cfg_tunnel_udp_port_parsed,
9216 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9217 "geneve|vxlan-gpe|ecpri <udp_port>",
9219 (void *)&cmd_config_tunnel_udp_port_port,
9220 (void *)&cmd_config_tunnel_udp_port_config,
9221 (void *)&cmd_config_tunnel_udp_port_port_id,
9222 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9223 (void *)&cmd_config_tunnel_udp_port_action,
9224 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9225 (void *)&cmd_config_tunnel_udp_port_value,
9230 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9231 struct cmd_set_mirror_mask_result {
9232 cmdline_fixed_string_t set;
9233 cmdline_fixed_string_t port;
9235 cmdline_fixed_string_t mirror;
9237 cmdline_fixed_string_t what;
9238 cmdline_fixed_string_t value;
9239 cmdline_fixed_string_t dstpool;
9241 cmdline_fixed_string_t on;
9244 cmdline_parse_token_string_t cmd_mirror_mask_set =
9245 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9247 cmdline_parse_token_string_t cmd_mirror_mask_port =
9248 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9250 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9251 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9252 port_id, RTE_UINT16);
9253 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9254 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9255 mirror, "mirror-rule");
9256 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9257 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9258 rule_id, RTE_UINT8);
9259 cmdline_parse_token_string_t cmd_mirror_mask_what =
9260 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9261 what, "pool-mirror-up#pool-mirror-down"
9263 cmdline_parse_token_string_t cmd_mirror_mask_value =
9264 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9266 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9267 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9268 dstpool, "dst-pool");
9269 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9270 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9271 dstpool_id, RTE_UINT8);
9272 cmdline_parse_token_string_t cmd_mirror_mask_on =
9273 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9277 cmd_set_mirror_mask_parsed(void *parsed_result,
9278 __rte_unused struct cmdline *cl,
9279 __rte_unused void *data)
9282 struct cmd_set_mirror_mask_result *res = parsed_result;
9283 struct rte_eth_mirror_conf mr_conf;
9285 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9287 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9289 mr_conf.dst_pool = res->dstpool_id;
9291 if (!strcmp(res->what, "pool-mirror-up")) {
9292 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9293 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9294 } else if (!strcmp(res->what, "pool-mirror-down")) {
9295 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9296 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9297 } else if (!strcmp(res->what, "vlan-mirror")) {
9298 mr_conf.rule_type = ETH_MIRROR_VLAN;
9299 nb_item = parse_item_list(res->value, "vlan",
9300 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9304 for (i = 0; i < nb_item; i++) {
9305 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9306 printf("Invalid vlan_id: must be < 4096\n");
9310 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9311 mr_conf.vlan.vlan_mask |= 1ULL << i;
9315 if (!strcmp(res->on, "on"))
9316 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9319 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9322 printf("mirror rule add error: (%s)\n", strerror(-ret));
9325 cmdline_parse_inst_t cmd_set_mirror_mask = {
9326 .f = cmd_set_mirror_mask_parsed,
9328 .help_str = "set port <port_id> mirror-rule <rule_id> "
9329 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9330 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9332 (void *)&cmd_mirror_mask_set,
9333 (void *)&cmd_mirror_mask_port,
9334 (void *)&cmd_mirror_mask_portid,
9335 (void *)&cmd_mirror_mask_mirror,
9336 (void *)&cmd_mirror_mask_ruleid,
9337 (void *)&cmd_mirror_mask_what,
9338 (void *)&cmd_mirror_mask_value,
9339 (void *)&cmd_mirror_mask_dstpool,
9340 (void *)&cmd_mirror_mask_poolid,
9341 (void *)&cmd_mirror_mask_on,
9346 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9347 struct cmd_set_mirror_link_result {
9348 cmdline_fixed_string_t set;
9349 cmdline_fixed_string_t port;
9351 cmdline_fixed_string_t mirror;
9353 cmdline_fixed_string_t what;
9354 cmdline_fixed_string_t dstpool;
9356 cmdline_fixed_string_t on;
9359 cmdline_parse_token_string_t cmd_mirror_link_set =
9360 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9362 cmdline_parse_token_string_t cmd_mirror_link_port =
9363 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9365 cmdline_parse_token_num_t cmd_mirror_link_portid =
9366 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9367 port_id, RTE_UINT16);
9368 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9369 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9370 mirror, "mirror-rule");
9371 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9372 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9373 rule_id, RTE_UINT8);
9374 cmdline_parse_token_string_t cmd_mirror_link_what =
9375 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9376 what, "uplink-mirror#downlink-mirror");
9377 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9378 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9379 dstpool, "dst-pool");
9380 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9381 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9382 dstpool_id, RTE_UINT8);
9383 cmdline_parse_token_string_t cmd_mirror_link_on =
9384 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9388 cmd_set_mirror_link_parsed(void *parsed_result,
9389 __rte_unused struct cmdline *cl,
9390 __rte_unused void *data)
9393 struct cmd_set_mirror_link_result *res = parsed_result;
9394 struct rte_eth_mirror_conf mr_conf;
9396 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9397 if (!strcmp(res->what, "uplink-mirror"))
9398 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9400 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9402 mr_conf.dst_pool = res->dstpool_id;
9404 if (!strcmp(res->on, "on"))
9405 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9408 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9411 /* check the return value and print it if is < 0 */
9413 printf("mirror rule add error: (%s)\n", strerror(-ret));
9417 cmdline_parse_inst_t cmd_set_mirror_link = {
9418 .f = cmd_set_mirror_link_parsed,
9420 .help_str = "set port <port_id> mirror-rule <rule_id> "
9421 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9423 (void *)&cmd_mirror_link_set,
9424 (void *)&cmd_mirror_link_port,
9425 (void *)&cmd_mirror_link_portid,
9426 (void *)&cmd_mirror_link_mirror,
9427 (void *)&cmd_mirror_link_ruleid,
9428 (void *)&cmd_mirror_link_what,
9429 (void *)&cmd_mirror_link_dstpool,
9430 (void *)&cmd_mirror_link_poolid,
9431 (void *)&cmd_mirror_link_on,
9436 /* *** RESET VM MIRROR RULE *** */
9437 struct cmd_rm_mirror_rule_result {
9438 cmdline_fixed_string_t reset;
9439 cmdline_fixed_string_t port;
9441 cmdline_fixed_string_t mirror;
9445 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9446 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9448 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9449 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9451 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9452 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9453 port_id, RTE_UINT16);
9454 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9455 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9456 mirror, "mirror-rule");
9457 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9458 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9459 rule_id, RTE_UINT8);
9462 cmd_reset_mirror_rule_parsed(void *parsed_result,
9463 __rte_unused struct cmdline *cl,
9464 __rte_unused void *data)
9467 struct cmd_set_mirror_link_result *res = parsed_result;
9469 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9471 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9474 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9475 .f = cmd_reset_mirror_rule_parsed,
9477 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9479 (void *)&cmd_rm_mirror_rule_reset,
9480 (void *)&cmd_rm_mirror_rule_port,
9481 (void *)&cmd_rm_mirror_rule_portid,
9482 (void *)&cmd_rm_mirror_rule_mirror,
9483 (void *)&cmd_rm_mirror_rule_ruleid,
9488 /* ******************************************************************************** */
9490 struct cmd_dump_result {
9491 cmdline_fixed_string_t dump;
9495 dump_struct_sizes(void)
9497 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9498 DUMP_SIZE(struct rte_mbuf);
9499 DUMP_SIZE(struct rte_mempool);
9500 DUMP_SIZE(struct rte_ring);
9505 /* Dump the socket memory statistics on console */
9507 dump_socket_mem(FILE *f)
9509 struct rte_malloc_socket_stats socket_stats;
9514 unsigned int n_alloc = 0;
9515 unsigned int n_free = 0;
9516 static size_t last_allocs;
9517 static size_t last_total;
9520 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9521 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9522 !socket_stats.heap_totalsz_bytes)
9524 total += socket_stats.heap_totalsz_bytes;
9525 alloc += socket_stats.heap_allocsz_bytes;
9526 free += socket_stats.heap_freesz_bytes;
9527 n_alloc += socket_stats.alloc_count;
9528 n_free += socket_stats.free_count;
9530 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9532 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9533 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9534 (double)socket_stats.heap_allocsz_bytes * 100 /
9535 (double)socket_stats.heap_totalsz_bytes,
9536 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9537 socket_stats.alloc_count,
9538 socket_stats.free_count);
9541 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9542 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9543 (double)alloc * 100 / (double)total,
9544 (double)free / (1024 * 1024),
9547 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9548 ((double)total - (double)last_total) / (1024 * 1024),
9549 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9550 last_allocs = alloc;
9554 static void cmd_dump_parsed(void *parsed_result,
9555 __rte_unused struct cmdline *cl,
9556 __rte_unused void *data)
9558 struct cmd_dump_result *res = parsed_result;
9560 if (!strcmp(res->dump, "dump_physmem"))
9561 rte_dump_physmem_layout(stdout);
9562 else if (!strcmp(res->dump, "dump_socket_mem"))
9563 dump_socket_mem(stdout);
9564 else if (!strcmp(res->dump, "dump_memzone"))
9565 rte_memzone_dump(stdout);
9566 else if (!strcmp(res->dump, "dump_struct_sizes"))
9567 dump_struct_sizes();
9568 else if (!strcmp(res->dump, "dump_ring"))
9569 rte_ring_list_dump(stdout);
9570 else if (!strcmp(res->dump, "dump_mempool"))
9571 rte_mempool_list_dump(stdout);
9572 else if (!strcmp(res->dump, "dump_devargs"))
9573 rte_devargs_dump(stdout);
9574 else if (!strcmp(res->dump, "dump_log_types"))
9575 rte_log_dump(stdout);
9578 cmdline_parse_token_string_t cmd_dump_dump =
9579 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9583 "dump_struct_sizes#"
9589 cmdline_parse_inst_t cmd_dump = {
9590 .f = cmd_dump_parsed, /* function to call */
9591 .data = NULL, /* 2nd arg of func */
9592 .help_str = "Dump status",
9593 .tokens = { /* token list, NULL terminated */
9594 (void *)&cmd_dump_dump,
9599 /* ******************************************************************************** */
9601 struct cmd_dump_one_result {
9602 cmdline_fixed_string_t dump;
9603 cmdline_fixed_string_t name;
9606 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9607 __rte_unused void *data)
9609 struct cmd_dump_one_result *res = parsed_result;
9611 if (!strcmp(res->dump, "dump_ring")) {
9613 r = rte_ring_lookup(res->name);
9615 cmdline_printf(cl, "Cannot find ring\n");
9618 rte_ring_dump(stdout, r);
9619 } else if (!strcmp(res->dump, "dump_mempool")) {
9620 struct rte_mempool *mp;
9621 mp = rte_mempool_lookup(res->name);
9623 cmdline_printf(cl, "Cannot find mempool\n");
9626 rte_mempool_dump(stdout, mp);
9630 cmdline_parse_token_string_t cmd_dump_one_dump =
9631 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9632 "dump_ring#dump_mempool");
9634 cmdline_parse_token_string_t cmd_dump_one_name =
9635 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9637 cmdline_parse_inst_t cmd_dump_one = {
9638 .f = cmd_dump_one_parsed, /* function to call */
9639 .data = NULL, /* 2nd arg of func */
9640 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9641 .tokens = { /* token list, NULL terminated */
9642 (void *)&cmd_dump_one_dump,
9643 (void *)&cmd_dump_one_name,
9648 /* *** queue region set *** */
9649 struct cmd_queue_region_result {
9650 cmdline_fixed_string_t set;
9651 cmdline_fixed_string_t port;
9653 cmdline_fixed_string_t cmd;
9654 cmdline_fixed_string_t region;
9656 cmdline_fixed_string_t queue_start_index;
9658 cmdline_fixed_string_t queue_num;
9659 uint8_t queue_num_value;
9663 cmd_queue_region_parsed(void *parsed_result,
9664 __rte_unused struct cmdline *cl,
9665 __rte_unused void *data)
9667 struct cmd_queue_region_result *res = parsed_result;
9670 struct rte_pmd_i40e_queue_region_conf region_conf;
9671 enum rte_pmd_i40e_queue_region_op op_type;
9674 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9678 memset(®ion_conf, 0, sizeof(region_conf));
9679 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9680 region_conf.region_id = res->region_id;
9681 region_conf.queue_num = res->queue_num_value;
9682 region_conf.queue_start_index = res->queue_id;
9684 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9685 op_type, ®ion_conf);
9692 printf("function not implemented or supported\n");
9695 printf("queue region config error: (%s)\n", strerror(-ret));
9699 cmdline_parse_token_string_t cmd_queue_region_set =
9700 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9702 cmdline_parse_token_string_t cmd_queue_region_port =
9703 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9704 cmdline_parse_token_num_t cmd_queue_region_port_id =
9705 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9706 port_id, RTE_UINT16);
9707 cmdline_parse_token_string_t cmd_queue_region_cmd =
9708 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9709 cmd, "queue-region");
9710 cmdline_parse_token_string_t cmd_queue_region_id =
9711 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9712 region, "region_id");
9713 cmdline_parse_token_num_t cmd_queue_region_index =
9714 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9715 region_id, RTE_UINT8);
9716 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9717 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9718 queue_start_index, "queue_start_index");
9719 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9720 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9721 queue_id, RTE_UINT8);
9722 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9723 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9724 queue_num, "queue_num");
9725 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9726 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9727 queue_num_value, RTE_UINT8);
9729 cmdline_parse_inst_t cmd_queue_region = {
9730 .f = cmd_queue_region_parsed,
9732 .help_str = "set port <port_id> queue-region region_id <value> "
9733 "queue_start_index <value> queue_num <value>: Set a queue region",
9735 (void *)&cmd_queue_region_set,
9736 (void *)&cmd_queue_region_port,
9737 (void *)&cmd_queue_region_port_id,
9738 (void *)&cmd_queue_region_cmd,
9739 (void *)&cmd_queue_region_id,
9740 (void *)&cmd_queue_region_index,
9741 (void *)&cmd_queue_region_queue_start_index,
9742 (void *)&cmd_queue_region_queue_id,
9743 (void *)&cmd_queue_region_queue_num,
9744 (void *)&cmd_queue_region_queue_num_value,
9749 /* *** queue region and flowtype set *** */
9750 struct cmd_region_flowtype_result {
9751 cmdline_fixed_string_t set;
9752 cmdline_fixed_string_t port;
9754 cmdline_fixed_string_t cmd;
9755 cmdline_fixed_string_t region;
9757 cmdline_fixed_string_t flowtype;
9758 uint8_t flowtype_id;
9762 cmd_region_flowtype_parsed(void *parsed_result,
9763 __rte_unused struct cmdline *cl,
9764 __rte_unused void *data)
9766 struct cmd_region_flowtype_result *res = parsed_result;
9769 struct rte_pmd_i40e_queue_region_conf region_conf;
9770 enum rte_pmd_i40e_queue_region_op op_type;
9773 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9777 memset(®ion_conf, 0, sizeof(region_conf));
9779 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9780 region_conf.region_id = res->region_id;
9781 region_conf.hw_flowtype = res->flowtype_id;
9783 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9784 op_type, ®ion_conf);
9791 printf("function not implemented or supported\n");
9794 printf("region flowtype config error: (%s)\n", strerror(-ret));
9798 cmdline_parse_token_string_t cmd_region_flowtype_set =
9799 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9801 cmdline_parse_token_string_t cmd_region_flowtype_port =
9802 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9804 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9805 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9806 port_id, RTE_UINT16);
9807 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9808 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9809 cmd, "queue-region");
9810 cmdline_parse_token_string_t cmd_region_flowtype_index =
9811 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9812 region, "region_id");
9813 cmdline_parse_token_num_t cmd_region_flowtype_id =
9814 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9815 region_id, RTE_UINT8);
9816 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9817 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9818 flowtype, "flowtype");
9819 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9820 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9821 flowtype_id, RTE_UINT8);
9822 cmdline_parse_inst_t cmd_region_flowtype = {
9823 .f = cmd_region_flowtype_parsed,
9825 .help_str = "set port <port_id> queue-region region_id <value> "
9826 "flowtype <value>: Set a flowtype region index",
9828 (void *)&cmd_region_flowtype_set,
9829 (void *)&cmd_region_flowtype_port,
9830 (void *)&cmd_region_flowtype_port_index,
9831 (void *)&cmd_region_flowtype_cmd,
9832 (void *)&cmd_region_flowtype_index,
9833 (void *)&cmd_region_flowtype_id,
9834 (void *)&cmd_region_flowtype_flow_index,
9835 (void *)&cmd_region_flowtype_flow_id,
9840 /* *** User Priority (UP) to queue region (region_id) set *** */
9841 struct cmd_user_priority_region_result {
9842 cmdline_fixed_string_t set;
9843 cmdline_fixed_string_t port;
9845 cmdline_fixed_string_t cmd;
9846 cmdline_fixed_string_t user_priority;
9847 uint8_t user_priority_id;
9848 cmdline_fixed_string_t region;
9853 cmd_user_priority_region_parsed(void *parsed_result,
9854 __rte_unused struct cmdline *cl,
9855 __rte_unused void *data)
9857 struct cmd_user_priority_region_result *res = parsed_result;
9860 struct rte_pmd_i40e_queue_region_conf region_conf;
9861 enum rte_pmd_i40e_queue_region_op op_type;
9864 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9868 memset(®ion_conf, 0, sizeof(region_conf));
9869 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9870 region_conf.user_priority = res->user_priority_id;
9871 region_conf.region_id = res->region_id;
9873 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9874 op_type, ®ion_conf);
9881 printf("function not implemented or supported\n");
9884 printf("user_priority region config error: (%s)\n",
9889 cmdline_parse_token_string_t cmd_user_priority_region_set =
9890 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9892 cmdline_parse_token_string_t cmd_user_priority_region_port =
9893 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9895 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9896 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9897 port_id, RTE_UINT16);
9898 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9899 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9900 cmd, "queue-region");
9901 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9902 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9903 user_priority, "UP");
9904 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9905 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9906 user_priority_id, RTE_UINT8);
9907 cmdline_parse_token_string_t cmd_user_priority_region_region =
9908 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9909 region, "region_id");
9910 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9911 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9912 region_id, RTE_UINT8);
9914 cmdline_parse_inst_t cmd_user_priority_region = {
9915 .f = cmd_user_priority_region_parsed,
9917 .help_str = "set port <port_id> queue-region UP <value> "
9918 "region_id <value>: Set the mapping of User Priority (UP) "
9919 "to queue region (region_id) ",
9921 (void *)&cmd_user_priority_region_set,
9922 (void *)&cmd_user_priority_region_port,
9923 (void *)&cmd_user_priority_region_port_index,
9924 (void *)&cmd_user_priority_region_cmd,
9925 (void *)&cmd_user_priority_region_UP,
9926 (void *)&cmd_user_priority_region_UP_id,
9927 (void *)&cmd_user_priority_region_region,
9928 (void *)&cmd_user_priority_region_region_id,
9933 /* *** flush all queue region related configuration *** */
9934 struct cmd_flush_queue_region_result {
9935 cmdline_fixed_string_t set;
9936 cmdline_fixed_string_t port;
9938 cmdline_fixed_string_t cmd;
9939 cmdline_fixed_string_t flush;
9940 cmdline_fixed_string_t what;
9944 cmd_flush_queue_region_parsed(void *parsed_result,
9945 __rte_unused struct cmdline *cl,
9946 __rte_unused void *data)
9948 struct cmd_flush_queue_region_result *res = parsed_result;
9951 struct rte_pmd_i40e_queue_region_conf region_conf;
9952 enum rte_pmd_i40e_queue_region_op op_type;
9955 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9959 memset(®ion_conf, 0, sizeof(region_conf));
9961 if (strcmp(res->what, "on") == 0)
9962 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9964 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9966 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9967 op_type, ®ion_conf);
9974 printf("function not implemented or supported\n");
9977 printf("queue region config flush error: (%s)\n",
9982 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9983 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9985 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9986 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9988 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9989 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9990 port_id, RTE_UINT16);
9991 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9992 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9993 cmd, "queue-region");
9994 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9995 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9997 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9998 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10001 cmdline_parse_inst_t cmd_flush_queue_region = {
10002 .f = cmd_flush_queue_region_parsed,
10004 .help_str = "set port <port_id> queue-region flush on|off"
10005 ": flush all queue region related configuration",
10007 (void *)&cmd_flush_queue_region_set,
10008 (void *)&cmd_flush_queue_region_port,
10009 (void *)&cmd_flush_queue_region_port_index,
10010 (void *)&cmd_flush_queue_region_cmd,
10011 (void *)&cmd_flush_queue_region_flush,
10012 (void *)&cmd_flush_queue_region_what,
10017 /* *** get all queue region related configuration info *** */
10018 struct cmd_show_queue_region_info {
10019 cmdline_fixed_string_t show;
10020 cmdline_fixed_string_t port;
10022 cmdline_fixed_string_t cmd;
10026 cmd_show_queue_region_info_parsed(void *parsed_result,
10027 __rte_unused struct cmdline *cl,
10028 __rte_unused void *data)
10030 struct cmd_show_queue_region_info *res = parsed_result;
10031 int ret = -ENOTSUP;
10032 #ifdef RTE_NET_I40E
10033 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10034 enum rte_pmd_i40e_queue_region_op op_type;
10037 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10040 #ifdef RTE_NET_I40E
10041 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10043 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10045 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10046 op_type, &rte_pmd_regions);
10048 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10055 printf("function not implemented or supported\n");
10058 printf("queue region config info show error: (%s)\n",
10063 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10064 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10066 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10067 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10069 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10070 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10071 port_id, RTE_UINT16);
10072 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10073 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10074 cmd, "queue-region");
10076 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10077 .f = cmd_show_queue_region_info_parsed,
10079 .help_str = "show port <port_id> queue-region"
10080 ": show all queue region related configuration info",
10082 (void *)&cmd_show_queue_region_info_get,
10083 (void *)&cmd_show_queue_region_info_port,
10084 (void *)&cmd_show_queue_region_info_port_index,
10085 (void *)&cmd_show_queue_region_info_cmd,
10090 /* *** Filters Control *** */
10092 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10094 if ((ip_addr).family == AF_INET) \
10095 (ip) = (ip_addr).addr.ipv4.s_addr; \
10097 printf("invalid parameter.\n"); \
10102 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10104 if ((ip_addr).family == AF_INET6) \
10105 rte_memcpy(&(ip), \
10106 &((ip_addr).addr.ipv6), \
10107 sizeof(struct in6_addr)); \
10109 printf("invalid parameter.\n"); \
10114 #ifdef RTE_NET_I40E
10117 str2flowtype(char *string)
10120 static const struct {
10123 } flowtype_str[] = {
10124 {"raw", RTE_ETH_FLOW_RAW},
10125 {"ipv4", RTE_ETH_FLOW_IPV4},
10126 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10127 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10128 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10129 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10130 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10131 {"ipv6", RTE_ETH_FLOW_IPV6},
10132 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10133 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10134 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10135 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10136 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10137 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10140 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10141 if (!strcmp(flowtype_str[i].str, string))
10142 return flowtype_str[i].type;
10145 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10146 return (uint16_t)atoi(string);
10148 return RTE_ETH_FLOW_UNKNOWN;
10151 /* *** deal with flow director filter *** */
10152 struct cmd_flow_director_result {
10153 cmdline_fixed_string_t flow_director_filter;
10155 cmdline_fixed_string_t mode;
10156 cmdline_fixed_string_t mode_value;
10157 cmdline_fixed_string_t ops;
10158 cmdline_fixed_string_t flow;
10159 cmdline_fixed_string_t flow_type;
10160 cmdline_fixed_string_t drop;
10161 cmdline_fixed_string_t queue;
10163 cmdline_fixed_string_t fd_id;
10164 uint32_t fd_id_value;
10165 cmdline_fixed_string_t packet;
10170 cmd_flow_director_filter_parsed(void *parsed_result,
10171 __rte_unused struct cmdline *cl,
10172 __rte_unused void *data)
10174 struct cmd_flow_director_result *res = parsed_result;
10176 struct rte_pmd_i40e_flow_type_mapping
10177 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10178 struct rte_pmd_i40e_pkt_template_conf conf;
10179 uint16_t flow_type = str2flowtype(res->flow_type);
10180 uint16_t i, port = res->port_id;
10183 memset(&conf, 0, sizeof(conf));
10185 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10186 printf("Invalid flow type specified.\n");
10189 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10193 if (mapping[flow_type].pctype == 0ULL) {
10194 printf("Invalid flow type specified.\n");
10197 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10198 if (mapping[flow_type].pctype & (1ULL << i)) {
10199 conf.input.pctype = i;
10204 conf.input.packet = open_file(res->filepath,
10205 &conf.input.length);
10206 if (!conf.input.packet)
10208 if (!strcmp(res->drop, "drop"))
10209 conf.action.behavior =
10210 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10212 conf.action.behavior =
10213 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10214 conf.action.report_status =
10215 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10216 conf.action.rx_queue = res->queue_id;
10217 conf.soft_id = res->fd_id_value;
10218 add = strcmp(res->ops, "del") ? 1 : 0;
10219 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10223 printf("flow director config error: (%s)\n",
10225 close_file(conf.input.packet);
10228 cmdline_parse_token_string_t cmd_flow_director_filter =
10229 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10230 flow_director_filter, "flow_director_filter");
10231 cmdline_parse_token_num_t cmd_flow_director_port_id =
10232 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10233 port_id, RTE_UINT16);
10234 cmdline_parse_token_string_t cmd_flow_director_ops =
10235 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10236 ops, "add#del#update");
10237 cmdline_parse_token_string_t cmd_flow_director_flow =
10238 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10240 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10241 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10243 cmdline_parse_token_string_t cmd_flow_director_drop =
10244 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10246 cmdline_parse_token_string_t cmd_flow_director_queue =
10247 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10249 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10250 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10251 queue_id, RTE_UINT16);
10252 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10253 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10255 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10256 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10257 fd_id_value, RTE_UINT32);
10259 cmdline_parse_token_string_t cmd_flow_director_mode =
10260 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10262 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10263 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10264 mode_value, "raw");
10265 cmdline_parse_token_string_t cmd_flow_director_packet =
10266 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10268 cmdline_parse_token_string_t cmd_flow_director_filepath =
10269 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10272 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10273 .f = cmd_flow_director_filter_parsed,
10275 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10276 "director entry on NIC",
10278 (void *)&cmd_flow_director_filter,
10279 (void *)&cmd_flow_director_port_id,
10280 (void *)&cmd_flow_director_mode,
10281 (void *)&cmd_flow_director_mode_raw,
10282 (void *)&cmd_flow_director_ops,
10283 (void *)&cmd_flow_director_flow,
10284 (void *)&cmd_flow_director_flow_type,
10285 (void *)&cmd_flow_director_drop,
10286 (void *)&cmd_flow_director_queue,
10287 (void *)&cmd_flow_director_queue_id,
10288 (void *)&cmd_flow_director_fd_id,
10289 (void *)&cmd_flow_director_fd_id_value,
10290 (void *)&cmd_flow_director_packet,
10291 (void *)&cmd_flow_director_filepath,
10296 #endif /* RTE_NET_I40E */
10298 /* *** deal with flow director mask *** */
10299 struct cmd_flow_director_mask_result {
10300 cmdline_fixed_string_t flow_director_mask;
10302 cmdline_fixed_string_t mode;
10303 cmdline_fixed_string_t mode_value;
10304 cmdline_fixed_string_t vlan;
10305 uint16_t vlan_mask;
10306 cmdline_fixed_string_t src_mask;
10307 cmdline_ipaddr_t ipv4_src;
10308 cmdline_ipaddr_t ipv6_src;
10310 cmdline_fixed_string_t dst_mask;
10311 cmdline_ipaddr_t ipv4_dst;
10312 cmdline_ipaddr_t ipv6_dst;
10314 cmdline_fixed_string_t mac;
10315 uint8_t mac_addr_byte_mask;
10316 cmdline_fixed_string_t tunnel_id;
10317 uint32_t tunnel_id_mask;
10318 cmdline_fixed_string_t tunnel_type;
10319 uint8_t tunnel_type_mask;
10323 cmd_flow_director_mask_parsed(void *parsed_result,
10324 __rte_unused struct cmdline *cl,
10325 __rte_unused void *data)
10327 struct cmd_flow_director_mask_result *res = parsed_result;
10328 struct rte_eth_fdir_masks *mask;
10329 struct rte_port *port;
10331 port = &ports[res->port_id];
10332 /** Check if the port is not started **/
10333 if (port->port_status != RTE_PORT_STOPPED) {
10334 printf("Please stop port %d first\n", res->port_id);
10338 mask = &port->dev_conf.fdir_conf.mask;
10340 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10341 if (strcmp(res->mode_value, "MAC-VLAN")) {
10342 printf("Please set mode to MAC-VLAN.\n");
10346 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10347 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10348 if (strcmp(res->mode_value, "Tunnel")) {
10349 printf("Please set mode to Tunnel.\n");
10353 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10354 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10355 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10356 mask->tunnel_type_mask = res->tunnel_type_mask;
10358 if (strcmp(res->mode_value, "IP")) {
10359 printf("Please set mode to IP.\n");
10363 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10364 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10365 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10366 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10367 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10368 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10369 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10372 cmd_reconfig_device_queue(res->port_id, 1, 1);
10375 cmdline_parse_token_string_t cmd_flow_director_mask =
10376 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10377 flow_director_mask, "flow_director_mask");
10378 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10379 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10380 port_id, RTE_UINT16);
10381 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10382 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10384 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10385 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10386 vlan_mask, RTE_UINT16);
10387 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10388 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10389 src_mask, "src_mask");
10390 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10391 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10393 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10394 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10396 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10397 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10398 port_src, RTE_UINT16);
10399 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10400 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10401 dst_mask, "dst_mask");
10402 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10403 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10405 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10406 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10408 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10409 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10410 port_dst, RTE_UINT16);
10412 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10413 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10415 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10416 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10418 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10419 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10420 mode_value, "MAC-VLAN");
10421 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10422 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10423 mode_value, "Tunnel");
10424 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10425 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10427 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10428 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10429 mac_addr_byte_mask, RTE_UINT8);
10430 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10431 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10432 tunnel_type, "tunnel-type");
10433 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10434 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10435 tunnel_type_mask, RTE_UINT8);
10436 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10437 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10438 tunnel_id, "tunnel-id");
10439 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10440 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10441 tunnel_id_mask, RTE_UINT32);
10443 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10444 .f = cmd_flow_director_mask_parsed,
10446 .help_str = "flow_director_mask ... : "
10447 "Set IP mode flow director's mask on NIC",
10449 (void *)&cmd_flow_director_mask,
10450 (void *)&cmd_flow_director_mask_port_id,
10451 (void *)&cmd_flow_director_mask_mode,
10452 (void *)&cmd_flow_director_mask_mode_ip,
10453 (void *)&cmd_flow_director_mask_vlan,
10454 (void *)&cmd_flow_director_mask_vlan_value,
10455 (void *)&cmd_flow_director_mask_src,
10456 (void *)&cmd_flow_director_mask_ipv4_src,
10457 (void *)&cmd_flow_director_mask_ipv6_src,
10458 (void *)&cmd_flow_director_mask_port_src,
10459 (void *)&cmd_flow_director_mask_dst,
10460 (void *)&cmd_flow_director_mask_ipv4_dst,
10461 (void *)&cmd_flow_director_mask_ipv6_dst,
10462 (void *)&cmd_flow_director_mask_port_dst,
10467 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10468 .f = cmd_flow_director_mask_parsed,
10470 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10471 "flow director's mask on NIC",
10473 (void *)&cmd_flow_director_mask,
10474 (void *)&cmd_flow_director_mask_port_id,
10475 (void *)&cmd_flow_director_mask_mode,
10476 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10477 (void *)&cmd_flow_director_mask_vlan,
10478 (void *)&cmd_flow_director_mask_vlan_value,
10483 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10484 .f = cmd_flow_director_mask_parsed,
10486 .help_str = "flow_director_mask ... : Set tunnel mode "
10487 "flow director's mask on NIC",
10489 (void *)&cmd_flow_director_mask,
10490 (void *)&cmd_flow_director_mask_port_id,
10491 (void *)&cmd_flow_director_mask_mode,
10492 (void *)&cmd_flow_director_mask_mode_tunnel,
10493 (void *)&cmd_flow_director_mask_vlan,
10494 (void *)&cmd_flow_director_mask_vlan_value,
10495 (void *)&cmd_flow_director_mask_mac,
10496 (void *)&cmd_flow_director_mask_mac_value,
10497 (void *)&cmd_flow_director_mask_tunnel_type,
10498 (void *)&cmd_flow_director_mask_tunnel_type_value,
10499 (void *)&cmd_flow_director_mask_tunnel_id,
10500 (void *)&cmd_flow_director_mask_tunnel_id_value,
10505 /* *** deal with flow director flexible payload configuration *** */
10506 struct cmd_flow_director_flexpayload_result {
10507 cmdline_fixed_string_t flow_director_flexpayload;
10509 cmdline_fixed_string_t payload_layer;
10510 cmdline_fixed_string_t payload_cfg;
10514 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10517 const char *p, *p0 = q_arg;
10519 unsigned long int_fld;
10520 char *str_fld[max_num];
10525 p = strchr(p0, '(');
10529 p0 = strchr(p, ')');
10534 if (size >= sizeof(s))
10537 snprintf(s, sizeof(s), "%.*s", size, p);
10538 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10539 if (ret < 0 || ret > max_num)
10541 for (i = 0; i < ret; i++) {
10543 int_fld = strtoul(str_fld[i], &end, 0);
10544 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10546 offsets[i] = (uint16_t)int_fld;
10552 cmd_flow_director_flxpld_parsed(void *parsed_result,
10553 __rte_unused struct cmdline *cl,
10554 __rte_unused void *data)
10556 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10557 struct rte_eth_flex_payload_cfg flex_cfg;
10558 struct rte_port *port;
10561 port = &ports[res->port_id];
10562 /** Check if the port is not started **/
10563 if (port->port_status != RTE_PORT_STOPPED) {
10564 printf("Please stop port %d first\n", res->port_id);
10568 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10570 if (!strcmp(res->payload_layer, "raw"))
10571 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10572 else if (!strcmp(res->payload_layer, "l2"))
10573 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10574 else if (!strcmp(res->payload_layer, "l3"))
10575 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10576 else if (!strcmp(res->payload_layer, "l4"))
10577 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10579 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10580 RTE_ETH_FDIR_MAX_FLEXLEN);
10582 printf("error: Cannot parse flex payload input.\n");
10586 fdir_set_flex_payload(res->port_id, &flex_cfg);
10587 cmd_reconfig_device_queue(res->port_id, 1, 1);
10590 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10591 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10592 flow_director_flexpayload,
10593 "flow_director_flex_payload");
10594 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10595 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10596 port_id, RTE_UINT16);
10597 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10598 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10599 payload_layer, "raw#l2#l3#l4");
10600 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10601 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10602 payload_cfg, NULL);
10604 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10605 .f = cmd_flow_director_flxpld_parsed,
10607 .help_str = "flow_director_flexpayload ... : "
10608 "Set flow director's flex payload on NIC",
10610 (void *)&cmd_flow_director_flexpayload,
10611 (void *)&cmd_flow_director_flexpayload_port_id,
10612 (void *)&cmd_flow_director_flexpayload_payload_layer,
10613 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10618 /* Generic flow interface command. */
10619 extern cmdline_parse_inst_t cmd_flow;
10621 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10622 struct cmd_mcast_addr_result {
10623 cmdline_fixed_string_t mcast_addr_cmd;
10624 cmdline_fixed_string_t what;
10626 struct rte_ether_addr mc_addr;
10629 static void cmd_mcast_addr_parsed(void *parsed_result,
10630 __rte_unused struct cmdline *cl,
10631 __rte_unused void *data)
10633 struct cmd_mcast_addr_result *res = parsed_result;
10635 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
10636 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10637 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10638 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10639 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10642 if (strcmp(res->what, "add") == 0)
10643 mcast_addr_add(res->port_num, &res->mc_addr);
10645 mcast_addr_remove(res->port_num, &res->mc_addr);
10648 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10649 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10650 mcast_addr_cmd, "mcast_addr");
10651 cmdline_parse_token_string_t cmd_mcast_addr_what =
10652 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10654 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10655 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
10657 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10658 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10660 cmdline_parse_inst_t cmd_mcast_addr = {
10661 .f = cmd_mcast_addr_parsed,
10663 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10664 "Add/Remove multicast MAC address on port_id",
10666 (void *)&cmd_mcast_addr_cmd,
10667 (void *)&cmd_mcast_addr_what,
10668 (void *)&cmd_mcast_addr_portnum,
10669 (void *)&cmd_mcast_addr_addr,
10674 /* vf vlan anti spoof configuration */
10676 /* Common result structure for vf vlan anti spoof */
10677 struct cmd_vf_vlan_anti_spoof_result {
10678 cmdline_fixed_string_t set;
10679 cmdline_fixed_string_t vf;
10680 cmdline_fixed_string_t vlan;
10681 cmdline_fixed_string_t antispoof;
10684 cmdline_fixed_string_t on_off;
10687 /* Common CLI fields for vf vlan anti spoof enable disable */
10688 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10689 TOKEN_STRING_INITIALIZER
10690 (struct cmd_vf_vlan_anti_spoof_result,
10692 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10693 TOKEN_STRING_INITIALIZER
10694 (struct cmd_vf_vlan_anti_spoof_result,
10696 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10697 TOKEN_STRING_INITIALIZER
10698 (struct cmd_vf_vlan_anti_spoof_result,
10700 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10701 TOKEN_STRING_INITIALIZER
10702 (struct cmd_vf_vlan_anti_spoof_result,
10703 antispoof, "antispoof");
10704 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10705 TOKEN_NUM_INITIALIZER
10706 (struct cmd_vf_vlan_anti_spoof_result,
10707 port_id, RTE_UINT16);
10708 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10709 TOKEN_NUM_INITIALIZER
10710 (struct cmd_vf_vlan_anti_spoof_result,
10711 vf_id, RTE_UINT32);
10712 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10713 TOKEN_STRING_INITIALIZER
10714 (struct cmd_vf_vlan_anti_spoof_result,
10718 cmd_set_vf_vlan_anti_spoof_parsed(
10719 void *parsed_result,
10720 __rte_unused struct cmdline *cl,
10721 __rte_unused void *data)
10723 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10724 int ret = -ENOTSUP;
10726 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10728 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10731 #ifdef RTE_NET_IXGBE
10732 if (ret == -ENOTSUP)
10733 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10734 res->vf_id, is_on);
10736 #ifdef RTE_NET_I40E
10737 if (ret == -ENOTSUP)
10738 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10739 res->vf_id, is_on);
10741 #ifdef RTE_NET_BNXT
10742 if (ret == -ENOTSUP)
10743 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
10744 res->vf_id, is_on);
10751 printf("invalid vf_id %d\n", res->vf_id);
10754 printf("invalid port_id %d\n", res->port_id);
10757 printf("function not implemented\n");
10760 printf("programming error: (%s)\n", strerror(-ret));
10764 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10765 .f = cmd_set_vf_vlan_anti_spoof_parsed,
10767 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10769 (void *)&cmd_vf_vlan_anti_spoof_set,
10770 (void *)&cmd_vf_vlan_anti_spoof_vf,
10771 (void *)&cmd_vf_vlan_anti_spoof_vlan,
10772 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
10773 (void *)&cmd_vf_vlan_anti_spoof_port_id,
10774 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
10775 (void *)&cmd_vf_vlan_anti_spoof_on_off,
10780 /* vf mac anti spoof configuration */
10782 /* Common result structure for vf mac anti spoof */
10783 struct cmd_vf_mac_anti_spoof_result {
10784 cmdline_fixed_string_t set;
10785 cmdline_fixed_string_t vf;
10786 cmdline_fixed_string_t mac;
10787 cmdline_fixed_string_t antispoof;
10790 cmdline_fixed_string_t on_off;
10793 /* Common CLI fields for vf mac anti spoof enable disable */
10794 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
10795 TOKEN_STRING_INITIALIZER
10796 (struct cmd_vf_mac_anti_spoof_result,
10798 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
10799 TOKEN_STRING_INITIALIZER
10800 (struct cmd_vf_mac_anti_spoof_result,
10802 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
10803 TOKEN_STRING_INITIALIZER
10804 (struct cmd_vf_mac_anti_spoof_result,
10806 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
10807 TOKEN_STRING_INITIALIZER
10808 (struct cmd_vf_mac_anti_spoof_result,
10809 antispoof, "antispoof");
10810 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
10811 TOKEN_NUM_INITIALIZER
10812 (struct cmd_vf_mac_anti_spoof_result,
10813 port_id, RTE_UINT16);
10814 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
10815 TOKEN_NUM_INITIALIZER
10816 (struct cmd_vf_mac_anti_spoof_result,
10817 vf_id, RTE_UINT32);
10818 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
10819 TOKEN_STRING_INITIALIZER
10820 (struct cmd_vf_mac_anti_spoof_result,
10824 cmd_set_vf_mac_anti_spoof_parsed(
10825 void *parsed_result,
10826 __rte_unused struct cmdline *cl,
10827 __rte_unused void *data)
10829 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
10830 int ret = -ENOTSUP;
10832 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10834 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10837 #ifdef RTE_NET_IXGBE
10838 if (ret == -ENOTSUP)
10839 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
10840 res->vf_id, is_on);
10842 #ifdef RTE_NET_I40E
10843 if (ret == -ENOTSUP)
10844 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
10845 res->vf_id, is_on);
10847 #ifdef RTE_NET_BNXT
10848 if (ret == -ENOTSUP)
10849 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
10850 res->vf_id, is_on);
10857 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
10860 printf("invalid port_id %d\n", res->port_id);
10863 printf("function not implemented\n");
10866 printf("programming error: (%s)\n", strerror(-ret));
10870 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
10871 .f = cmd_set_vf_mac_anti_spoof_parsed,
10873 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
10875 (void *)&cmd_vf_mac_anti_spoof_set,
10876 (void *)&cmd_vf_mac_anti_spoof_vf,
10877 (void *)&cmd_vf_mac_anti_spoof_mac,
10878 (void *)&cmd_vf_mac_anti_spoof_antispoof,
10879 (void *)&cmd_vf_mac_anti_spoof_port_id,
10880 (void *)&cmd_vf_mac_anti_spoof_vf_id,
10881 (void *)&cmd_vf_mac_anti_spoof_on_off,
10886 /* vf vlan strip queue configuration */
10888 /* Common result structure for vf mac anti spoof */
10889 struct cmd_vf_vlan_stripq_result {
10890 cmdline_fixed_string_t set;
10891 cmdline_fixed_string_t vf;
10892 cmdline_fixed_string_t vlan;
10893 cmdline_fixed_string_t stripq;
10896 cmdline_fixed_string_t on_off;
10899 /* Common CLI fields for vf vlan strip enable disable */
10900 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
10901 TOKEN_STRING_INITIALIZER
10902 (struct cmd_vf_vlan_stripq_result,
10904 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
10905 TOKEN_STRING_INITIALIZER
10906 (struct cmd_vf_vlan_stripq_result,
10908 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
10909 TOKEN_STRING_INITIALIZER
10910 (struct cmd_vf_vlan_stripq_result,
10912 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
10913 TOKEN_STRING_INITIALIZER
10914 (struct cmd_vf_vlan_stripq_result,
10916 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
10917 TOKEN_NUM_INITIALIZER
10918 (struct cmd_vf_vlan_stripq_result,
10919 port_id, RTE_UINT16);
10920 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
10921 TOKEN_NUM_INITIALIZER
10922 (struct cmd_vf_vlan_stripq_result,
10923 vf_id, RTE_UINT16);
10924 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
10925 TOKEN_STRING_INITIALIZER
10926 (struct cmd_vf_vlan_stripq_result,
10930 cmd_set_vf_vlan_stripq_parsed(
10931 void *parsed_result,
10932 __rte_unused struct cmdline *cl,
10933 __rte_unused void *data)
10935 struct cmd_vf_vlan_stripq_result *res = parsed_result;
10936 int ret = -ENOTSUP;
10938 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10940 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10943 #ifdef RTE_NET_IXGBE
10944 if (ret == -ENOTSUP)
10945 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
10946 res->vf_id, is_on);
10948 #ifdef RTE_NET_I40E
10949 if (ret == -ENOTSUP)
10950 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
10951 res->vf_id, is_on);
10953 #ifdef RTE_NET_BNXT
10954 if (ret == -ENOTSUP)
10955 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
10956 res->vf_id, is_on);
10963 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
10966 printf("invalid port_id %d\n", res->port_id);
10969 printf("function not implemented\n");
10972 printf("programming error: (%s)\n", strerror(-ret));
10976 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
10977 .f = cmd_set_vf_vlan_stripq_parsed,
10979 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
10981 (void *)&cmd_vf_vlan_stripq_set,
10982 (void *)&cmd_vf_vlan_stripq_vf,
10983 (void *)&cmd_vf_vlan_stripq_vlan,
10984 (void *)&cmd_vf_vlan_stripq_stripq,
10985 (void *)&cmd_vf_vlan_stripq_port_id,
10986 (void *)&cmd_vf_vlan_stripq_vf_id,
10987 (void *)&cmd_vf_vlan_stripq_on_off,
10992 /* vf vlan insert configuration */
10994 /* Common result structure for vf vlan insert */
10995 struct cmd_vf_vlan_insert_result {
10996 cmdline_fixed_string_t set;
10997 cmdline_fixed_string_t vf;
10998 cmdline_fixed_string_t vlan;
10999 cmdline_fixed_string_t insert;
11005 /* Common CLI fields for vf vlan insert enable disable */
11006 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11007 TOKEN_STRING_INITIALIZER
11008 (struct cmd_vf_vlan_insert_result,
11010 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11011 TOKEN_STRING_INITIALIZER
11012 (struct cmd_vf_vlan_insert_result,
11014 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11015 TOKEN_STRING_INITIALIZER
11016 (struct cmd_vf_vlan_insert_result,
11018 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11019 TOKEN_STRING_INITIALIZER
11020 (struct cmd_vf_vlan_insert_result,
11022 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11023 TOKEN_NUM_INITIALIZER
11024 (struct cmd_vf_vlan_insert_result,
11025 port_id, RTE_UINT16);
11026 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11027 TOKEN_NUM_INITIALIZER
11028 (struct cmd_vf_vlan_insert_result,
11029 vf_id, RTE_UINT16);
11030 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11031 TOKEN_NUM_INITIALIZER
11032 (struct cmd_vf_vlan_insert_result,
11033 vlan_id, RTE_UINT16);
11036 cmd_set_vf_vlan_insert_parsed(
11037 void *parsed_result,
11038 __rte_unused struct cmdline *cl,
11039 __rte_unused void *data)
11041 struct cmd_vf_vlan_insert_result *res = parsed_result;
11042 int ret = -ENOTSUP;
11044 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11047 #ifdef RTE_NET_IXGBE
11048 if (ret == -ENOTSUP)
11049 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11052 #ifdef RTE_NET_I40E
11053 if (ret == -ENOTSUP)
11054 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11057 #ifdef RTE_NET_BNXT
11058 if (ret == -ENOTSUP)
11059 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11067 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11070 printf("invalid port_id %d\n", res->port_id);
11073 printf("function not implemented\n");
11076 printf("programming error: (%s)\n", strerror(-ret));
11080 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11081 .f = cmd_set_vf_vlan_insert_parsed,
11083 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11085 (void *)&cmd_vf_vlan_insert_set,
11086 (void *)&cmd_vf_vlan_insert_vf,
11087 (void *)&cmd_vf_vlan_insert_vlan,
11088 (void *)&cmd_vf_vlan_insert_insert,
11089 (void *)&cmd_vf_vlan_insert_port_id,
11090 (void *)&cmd_vf_vlan_insert_vf_id,
11091 (void *)&cmd_vf_vlan_insert_vlan_id,
11096 /* tx loopback configuration */
11098 /* Common result structure for tx loopback */
11099 struct cmd_tx_loopback_result {
11100 cmdline_fixed_string_t set;
11101 cmdline_fixed_string_t tx;
11102 cmdline_fixed_string_t loopback;
11104 cmdline_fixed_string_t on_off;
11107 /* Common CLI fields for tx loopback enable disable */
11108 cmdline_parse_token_string_t cmd_tx_loopback_set =
11109 TOKEN_STRING_INITIALIZER
11110 (struct cmd_tx_loopback_result,
11112 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11113 TOKEN_STRING_INITIALIZER
11114 (struct cmd_tx_loopback_result,
11116 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11117 TOKEN_STRING_INITIALIZER
11118 (struct cmd_tx_loopback_result,
11119 loopback, "loopback");
11120 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11121 TOKEN_NUM_INITIALIZER
11122 (struct cmd_tx_loopback_result,
11123 port_id, RTE_UINT16);
11124 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11125 TOKEN_STRING_INITIALIZER
11126 (struct cmd_tx_loopback_result,
11130 cmd_set_tx_loopback_parsed(
11131 void *parsed_result,
11132 __rte_unused struct cmdline *cl,
11133 __rte_unused void *data)
11135 struct cmd_tx_loopback_result *res = parsed_result;
11136 int ret = -ENOTSUP;
11138 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11140 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11143 #ifdef RTE_NET_IXGBE
11144 if (ret == -ENOTSUP)
11145 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11147 #ifdef RTE_NET_I40E
11148 if (ret == -ENOTSUP)
11149 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11151 #ifdef RTE_NET_BNXT
11152 if (ret == -ENOTSUP)
11153 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11155 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11156 if (ret == -ENOTSUP)
11157 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11164 printf("invalid is_on %d\n", is_on);
11167 printf("invalid port_id %d\n", res->port_id);
11170 printf("function not implemented\n");
11173 printf("programming error: (%s)\n", strerror(-ret));
11177 cmdline_parse_inst_t cmd_set_tx_loopback = {
11178 .f = cmd_set_tx_loopback_parsed,
11180 .help_str = "set tx loopback <port_id> on|off",
11182 (void *)&cmd_tx_loopback_set,
11183 (void *)&cmd_tx_loopback_tx,
11184 (void *)&cmd_tx_loopback_loopback,
11185 (void *)&cmd_tx_loopback_port_id,
11186 (void *)&cmd_tx_loopback_on_off,
11191 /* all queues drop enable configuration */
11193 /* Common result structure for all queues drop enable */
11194 struct cmd_all_queues_drop_en_result {
11195 cmdline_fixed_string_t set;
11196 cmdline_fixed_string_t all;
11197 cmdline_fixed_string_t queues;
11198 cmdline_fixed_string_t drop;
11200 cmdline_fixed_string_t on_off;
11203 /* Common CLI fields for tx loopback enable disable */
11204 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11205 TOKEN_STRING_INITIALIZER
11206 (struct cmd_all_queues_drop_en_result,
11208 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11209 TOKEN_STRING_INITIALIZER
11210 (struct cmd_all_queues_drop_en_result,
11212 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11213 TOKEN_STRING_INITIALIZER
11214 (struct cmd_all_queues_drop_en_result,
11216 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11217 TOKEN_STRING_INITIALIZER
11218 (struct cmd_all_queues_drop_en_result,
11220 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11221 TOKEN_NUM_INITIALIZER
11222 (struct cmd_all_queues_drop_en_result,
11223 port_id, RTE_UINT16);
11224 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11225 TOKEN_STRING_INITIALIZER
11226 (struct cmd_all_queues_drop_en_result,
11230 cmd_set_all_queues_drop_en_parsed(
11231 void *parsed_result,
11232 __rte_unused struct cmdline *cl,
11233 __rte_unused void *data)
11235 struct cmd_all_queues_drop_en_result *res = parsed_result;
11236 int ret = -ENOTSUP;
11237 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11239 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11242 #ifdef RTE_NET_IXGBE
11243 if (ret == -ENOTSUP)
11244 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11246 #ifdef RTE_NET_BNXT
11247 if (ret == -ENOTSUP)
11248 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11254 printf("invalid is_on %d\n", is_on);
11257 printf("invalid port_id %d\n", res->port_id);
11260 printf("function not implemented\n");
11263 printf("programming error: (%s)\n", strerror(-ret));
11267 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11268 .f = cmd_set_all_queues_drop_en_parsed,
11270 .help_str = "set all queues drop <port_id> on|off",
11272 (void *)&cmd_all_queues_drop_en_set,
11273 (void *)&cmd_all_queues_drop_en_all,
11274 (void *)&cmd_all_queues_drop_en_queues,
11275 (void *)&cmd_all_queues_drop_en_drop,
11276 (void *)&cmd_all_queues_drop_en_port_id,
11277 (void *)&cmd_all_queues_drop_en_on_off,
11282 /* vf split drop enable configuration */
11284 /* Common result structure for vf split drop enable */
11285 struct cmd_vf_split_drop_en_result {
11286 cmdline_fixed_string_t set;
11287 cmdline_fixed_string_t vf;
11288 cmdline_fixed_string_t split;
11289 cmdline_fixed_string_t drop;
11292 cmdline_fixed_string_t on_off;
11295 /* Common CLI fields for vf split drop enable disable */
11296 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11297 TOKEN_STRING_INITIALIZER
11298 (struct cmd_vf_split_drop_en_result,
11300 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11301 TOKEN_STRING_INITIALIZER
11302 (struct cmd_vf_split_drop_en_result,
11304 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11305 TOKEN_STRING_INITIALIZER
11306 (struct cmd_vf_split_drop_en_result,
11308 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11309 TOKEN_STRING_INITIALIZER
11310 (struct cmd_vf_split_drop_en_result,
11312 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11313 TOKEN_NUM_INITIALIZER
11314 (struct cmd_vf_split_drop_en_result,
11315 port_id, RTE_UINT16);
11316 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11317 TOKEN_NUM_INITIALIZER
11318 (struct cmd_vf_split_drop_en_result,
11319 vf_id, RTE_UINT16);
11320 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11321 TOKEN_STRING_INITIALIZER
11322 (struct cmd_vf_split_drop_en_result,
11326 cmd_set_vf_split_drop_en_parsed(
11327 void *parsed_result,
11328 __rte_unused struct cmdline *cl,
11329 __rte_unused void *data)
11331 struct cmd_vf_split_drop_en_result *res = parsed_result;
11332 int ret = -ENOTSUP;
11333 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11335 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11338 #ifdef RTE_NET_IXGBE
11339 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11346 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11349 printf("invalid port_id %d\n", res->port_id);
11352 printf("not supported on port %d\n", res->port_id);
11355 printf("programming error: (%s)\n", strerror(-ret));
11359 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11360 .f = cmd_set_vf_split_drop_en_parsed,
11362 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11364 (void *)&cmd_vf_split_drop_en_set,
11365 (void *)&cmd_vf_split_drop_en_vf,
11366 (void *)&cmd_vf_split_drop_en_split,
11367 (void *)&cmd_vf_split_drop_en_drop,
11368 (void *)&cmd_vf_split_drop_en_port_id,
11369 (void *)&cmd_vf_split_drop_en_vf_id,
11370 (void *)&cmd_vf_split_drop_en_on_off,
11375 /* vf mac address configuration */
11377 /* Common result structure for vf mac address */
11378 struct cmd_set_vf_mac_addr_result {
11379 cmdline_fixed_string_t set;
11380 cmdline_fixed_string_t vf;
11381 cmdline_fixed_string_t mac;
11382 cmdline_fixed_string_t addr;
11385 struct rte_ether_addr mac_addr;
11389 /* Common CLI fields for vf split drop enable disable */
11390 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11391 TOKEN_STRING_INITIALIZER
11392 (struct cmd_set_vf_mac_addr_result,
11394 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11395 TOKEN_STRING_INITIALIZER
11396 (struct cmd_set_vf_mac_addr_result,
11398 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11399 TOKEN_STRING_INITIALIZER
11400 (struct cmd_set_vf_mac_addr_result,
11402 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11403 TOKEN_STRING_INITIALIZER
11404 (struct cmd_set_vf_mac_addr_result,
11406 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11407 TOKEN_NUM_INITIALIZER
11408 (struct cmd_set_vf_mac_addr_result,
11409 port_id, RTE_UINT16);
11410 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11411 TOKEN_NUM_INITIALIZER
11412 (struct cmd_set_vf_mac_addr_result,
11413 vf_id, RTE_UINT16);
11414 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11415 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11419 cmd_set_vf_mac_addr_parsed(
11420 void *parsed_result,
11421 __rte_unused struct cmdline *cl,
11422 __rte_unused void *data)
11424 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11425 int ret = -ENOTSUP;
11427 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11430 #ifdef RTE_NET_IXGBE
11431 if (ret == -ENOTSUP)
11432 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11435 #ifdef RTE_NET_I40E
11436 if (ret == -ENOTSUP)
11437 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11440 #ifdef RTE_NET_BNXT
11441 if (ret == -ENOTSUP)
11442 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11450 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11453 printf("invalid port_id %d\n", res->port_id);
11456 printf("function not implemented\n");
11459 printf("programming error: (%s)\n", strerror(-ret));
11463 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11464 .f = cmd_set_vf_mac_addr_parsed,
11466 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11468 (void *)&cmd_set_vf_mac_addr_set,
11469 (void *)&cmd_set_vf_mac_addr_vf,
11470 (void *)&cmd_set_vf_mac_addr_mac,
11471 (void *)&cmd_set_vf_mac_addr_addr,
11472 (void *)&cmd_set_vf_mac_addr_port_id,
11473 (void *)&cmd_set_vf_mac_addr_vf_id,
11474 (void *)&cmd_set_vf_mac_addr_mac_addr,
11479 /* MACsec configuration */
11481 /* Common result structure for MACsec offload enable */
11482 struct cmd_macsec_offload_on_result {
11483 cmdline_fixed_string_t set;
11484 cmdline_fixed_string_t macsec;
11485 cmdline_fixed_string_t offload;
11487 cmdline_fixed_string_t on;
11488 cmdline_fixed_string_t encrypt;
11489 cmdline_fixed_string_t en_on_off;
11490 cmdline_fixed_string_t replay_protect;
11491 cmdline_fixed_string_t rp_on_off;
11494 /* Common CLI fields for MACsec offload disable */
11495 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11496 TOKEN_STRING_INITIALIZER
11497 (struct cmd_macsec_offload_on_result,
11499 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11500 TOKEN_STRING_INITIALIZER
11501 (struct cmd_macsec_offload_on_result,
11503 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11504 TOKEN_STRING_INITIALIZER
11505 (struct cmd_macsec_offload_on_result,
11506 offload, "offload");
11507 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11508 TOKEN_NUM_INITIALIZER
11509 (struct cmd_macsec_offload_on_result,
11510 port_id, RTE_UINT16);
11511 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11512 TOKEN_STRING_INITIALIZER
11513 (struct cmd_macsec_offload_on_result,
11515 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11516 TOKEN_STRING_INITIALIZER
11517 (struct cmd_macsec_offload_on_result,
11518 encrypt, "encrypt");
11519 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11520 TOKEN_STRING_INITIALIZER
11521 (struct cmd_macsec_offload_on_result,
11522 en_on_off, "on#off");
11523 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11524 TOKEN_STRING_INITIALIZER
11525 (struct cmd_macsec_offload_on_result,
11526 replay_protect, "replay-protect");
11527 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11528 TOKEN_STRING_INITIALIZER
11529 (struct cmd_macsec_offload_on_result,
11530 rp_on_off, "on#off");
11533 cmd_set_macsec_offload_on_parsed(
11534 void *parsed_result,
11535 __rte_unused struct cmdline *cl,
11536 __rte_unused void *data)
11538 struct cmd_macsec_offload_on_result *res = parsed_result;
11539 int ret = -ENOTSUP;
11540 portid_t port_id = res->port_id;
11541 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11542 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11543 struct rte_eth_dev_info dev_info;
11545 if (port_id_is_invalid(port_id, ENABLED_WARN))
11547 if (!port_is_stopped(port_id)) {
11548 printf("Please stop port %d first\n", port_id);
11552 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11556 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11557 #ifdef RTE_NET_IXGBE
11558 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11566 ports[port_id].dev_conf.txmode.offloads |=
11567 DEV_TX_OFFLOAD_MACSEC_INSERT;
11568 cmd_reconfig_device_queue(port_id, 1, 1);
11571 printf("invalid port_id %d\n", port_id);
11574 printf("not supported on port %d\n", port_id);
11577 printf("programming error: (%s)\n", strerror(-ret));
11581 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11582 .f = cmd_set_macsec_offload_on_parsed,
11584 .help_str = "set macsec offload <port_id> on "
11585 "encrypt on|off replay-protect on|off",
11587 (void *)&cmd_macsec_offload_on_set,
11588 (void *)&cmd_macsec_offload_on_macsec,
11589 (void *)&cmd_macsec_offload_on_offload,
11590 (void *)&cmd_macsec_offload_on_port_id,
11591 (void *)&cmd_macsec_offload_on_on,
11592 (void *)&cmd_macsec_offload_on_encrypt,
11593 (void *)&cmd_macsec_offload_on_en_on_off,
11594 (void *)&cmd_macsec_offload_on_replay_protect,
11595 (void *)&cmd_macsec_offload_on_rp_on_off,
11600 /* Common result structure for MACsec offload disable */
11601 struct cmd_macsec_offload_off_result {
11602 cmdline_fixed_string_t set;
11603 cmdline_fixed_string_t macsec;
11604 cmdline_fixed_string_t offload;
11606 cmdline_fixed_string_t off;
11609 /* Common CLI fields for MACsec offload disable */
11610 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11611 TOKEN_STRING_INITIALIZER
11612 (struct cmd_macsec_offload_off_result,
11614 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11615 TOKEN_STRING_INITIALIZER
11616 (struct cmd_macsec_offload_off_result,
11618 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11619 TOKEN_STRING_INITIALIZER
11620 (struct cmd_macsec_offload_off_result,
11621 offload, "offload");
11622 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11623 TOKEN_NUM_INITIALIZER
11624 (struct cmd_macsec_offload_off_result,
11625 port_id, RTE_UINT16);
11626 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11627 TOKEN_STRING_INITIALIZER
11628 (struct cmd_macsec_offload_off_result,
11632 cmd_set_macsec_offload_off_parsed(
11633 void *parsed_result,
11634 __rte_unused struct cmdline *cl,
11635 __rte_unused void *data)
11637 struct cmd_macsec_offload_off_result *res = parsed_result;
11638 int ret = -ENOTSUP;
11639 struct rte_eth_dev_info dev_info;
11640 portid_t port_id = res->port_id;
11642 if (port_id_is_invalid(port_id, ENABLED_WARN))
11644 if (!port_is_stopped(port_id)) {
11645 printf("Please stop port %d first\n", port_id);
11649 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11653 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11654 #ifdef RTE_NET_IXGBE
11655 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11660 ports[port_id].dev_conf.txmode.offloads &=
11661 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
11662 cmd_reconfig_device_queue(port_id, 1, 1);
11665 printf("invalid port_id %d\n", port_id);
11668 printf("not supported on port %d\n", port_id);
11671 printf("programming error: (%s)\n", strerror(-ret));
11675 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11676 .f = cmd_set_macsec_offload_off_parsed,
11678 .help_str = "set macsec offload <port_id> off",
11680 (void *)&cmd_macsec_offload_off_set,
11681 (void *)&cmd_macsec_offload_off_macsec,
11682 (void *)&cmd_macsec_offload_off_offload,
11683 (void *)&cmd_macsec_offload_off_port_id,
11684 (void *)&cmd_macsec_offload_off_off,
11689 /* Common result structure for MACsec secure connection configure */
11690 struct cmd_macsec_sc_result {
11691 cmdline_fixed_string_t set;
11692 cmdline_fixed_string_t macsec;
11693 cmdline_fixed_string_t sc;
11694 cmdline_fixed_string_t tx_rx;
11696 struct rte_ether_addr mac;
11700 /* Common CLI fields for MACsec secure connection configure */
11701 cmdline_parse_token_string_t cmd_macsec_sc_set =
11702 TOKEN_STRING_INITIALIZER
11703 (struct cmd_macsec_sc_result,
11705 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11706 TOKEN_STRING_INITIALIZER
11707 (struct cmd_macsec_sc_result,
11709 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11710 TOKEN_STRING_INITIALIZER
11711 (struct cmd_macsec_sc_result,
11713 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11714 TOKEN_STRING_INITIALIZER
11715 (struct cmd_macsec_sc_result,
11717 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11718 TOKEN_NUM_INITIALIZER
11719 (struct cmd_macsec_sc_result,
11720 port_id, RTE_UINT16);
11721 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11722 TOKEN_ETHERADDR_INITIALIZER
11723 (struct cmd_macsec_sc_result,
11725 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11726 TOKEN_NUM_INITIALIZER
11727 (struct cmd_macsec_sc_result,
11731 cmd_set_macsec_sc_parsed(
11732 void *parsed_result,
11733 __rte_unused struct cmdline *cl,
11734 __rte_unused void *data)
11736 struct cmd_macsec_sc_result *res = parsed_result;
11737 int ret = -ENOTSUP;
11738 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11740 #ifdef RTE_NET_IXGBE
11742 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11743 res->mac.addr_bytes) :
11744 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11745 res->mac.addr_bytes, res->pi);
11747 RTE_SET_USED(is_tx);
11753 printf("invalid port_id %d\n", res->port_id);
11756 printf("not supported on port %d\n", res->port_id);
11759 printf("programming error: (%s)\n", strerror(-ret));
11763 cmdline_parse_inst_t cmd_set_macsec_sc = {
11764 .f = cmd_set_macsec_sc_parsed,
11766 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11768 (void *)&cmd_macsec_sc_set,
11769 (void *)&cmd_macsec_sc_macsec,
11770 (void *)&cmd_macsec_sc_sc,
11771 (void *)&cmd_macsec_sc_tx_rx,
11772 (void *)&cmd_macsec_sc_port_id,
11773 (void *)&cmd_macsec_sc_mac,
11774 (void *)&cmd_macsec_sc_pi,
11779 /* Common result structure for MACsec secure connection configure */
11780 struct cmd_macsec_sa_result {
11781 cmdline_fixed_string_t set;
11782 cmdline_fixed_string_t macsec;
11783 cmdline_fixed_string_t sa;
11784 cmdline_fixed_string_t tx_rx;
11789 cmdline_fixed_string_t key;
11792 /* Common CLI fields for MACsec secure connection configure */
11793 cmdline_parse_token_string_t cmd_macsec_sa_set =
11794 TOKEN_STRING_INITIALIZER
11795 (struct cmd_macsec_sa_result,
11797 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11798 TOKEN_STRING_INITIALIZER
11799 (struct cmd_macsec_sa_result,
11801 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11802 TOKEN_STRING_INITIALIZER
11803 (struct cmd_macsec_sa_result,
11805 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11806 TOKEN_STRING_INITIALIZER
11807 (struct cmd_macsec_sa_result,
11809 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11810 TOKEN_NUM_INITIALIZER
11811 (struct cmd_macsec_sa_result,
11812 port_id, RTE_UINT16);
11813 cmdline_parse_token_num_t cmd_macsec_sa_idx =
11814 TOKEN_NUM_INITIALIZER
11815 (struct cmd_macsec_sa_result,
11817 cmdline_parse_token_num_t cmd_macsec_sa_an =
11818 TOKEN_NUM_INITIALIZER
11819 (struct cmd_macsec_sa_result,
11821 cmdline_parse_token_num_t cmd_macsec_sa_pn =
11822 TOKEN_NUM_INITIALIZER
11823 (struct cmd_macsec_sa_result,
11825 cmdline_parse_token_string_t cmd_macsec_sa_key =
11826 TOKEN_STRING_INITIALIZER
11827 (struct cmd_macsec_sa_result,
11831 cmd_set_macsec_sa_parsed(
11832 void *parsed_result,
11833 __rte_unused struct cmdline *cl,
11834 __rte_unused void *data)
11836 struct cmd_macsec_sa_result *res = parsed_result;
11837 int ret = -ENOTSUP;
11838 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11839 uint8_t key[16] = { 0 };
11845 key_len = strlen(res->key) / 2;
11849 for (i = 0; i < key_len; i++) {
11850 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
11853 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
11856 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
11859 #ifdef RTE_NET_IXGBE
11861 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
11862 res->idx, res->an, res->pn, key) :
11863 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
11864 res->idx, res->an, res->pn, key);
11866 RTE_SET_USED(is_tx);
11873 printf("invalid idx %d or an %d\n", res->idx, res->an);
11876 printf("invalid port_id %d\n", res->port_id);
11879 printf("not supported on port %d\n", res->port_id);
11882 printf("programming error: (%s)\n", strerror(-ret));
11886 cmdline_parse_inst_t cmd_set_macsec_sa = {
11887 .f = cmd_set_macsec_sa_parsed,
11889 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
11891 (void *)&cmd_macsec_sa_set,
11892 (void *)&cmd_macsec_sa_macsec,
11893 (void *)&cmd_macsec_sa_sa,
11894 (void *)&cmd_macsec_sa_tx_rx,
11895 (void *)&cmd_macsec_sa_port_id,
11896 (void *)&cmd_macsec_sa_idx,
11897 (void *)&cmd_macsec_sa_an,
11898 (void *)&cmd_macsec_sa_pn,
11899 (void *)&cmd_macsec_sa_key,
11904 /* VF unicast promiscuous mode configuration */
11906 /* Common result structure for VF unicast promiscuous mode */
11907 struct cmd_vf_promisc_result {
11908 cmdline_fixed_string_t set;
11909 cmdline_fixed_string_t vf;
11910 cmdline_fixed_string_t promisc;
11913 cmdline_fixed_string_t on_off;
11916 /* Common CLI fields for VF unicast promiscuous mode enable disable */
11917 cmdline_parse_token_string_t cmd_vf_promisc_set =
11918 TOKEN_STRING_INITIALIZER
11919 (struct cmd_vf_promisc_result,
11921 cmdline_parse_token_string_t cmd_vf_promisc_vf =
11922 TOKEN_STRING_INITIALIZER
11923 (struct cmd_vf_promisc_result,
11925 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
11926 TOKEN_STRING_INITIALIZER
11927 (struct cmd_vf_promisc_result,
11928 promisc, "promisc");
11929 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
11930 TOKEN_NUM_INITIALIZER
11931 (struct cmd_vf_promisc_result,
11932 port_id, RTE_UINT16);
11933 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
11934 TOKEN_NUM_INITIALIZER
11935 (struct cmd_vf_promisc_result,
11936 vf_id, RTE_UINT32);
11937 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
11938 TOKEN_STRING_INITIALIZER
11939 (struct cmd_vf_promisc_result,
11943 cmd_set_vf_promisc_parsed(
11944 void *parsed_result,
11945 __rte_unused struct cmdline *cl,
11946 __rte_unused void *data)
11948 struct cmd_vf_promisc_result *res = parsed_result;
11949 int ret = -ENOTSUP;
11951 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11953 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11956 #ifdef RTE_NET_I40E
11957 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
11958 res->vf_id, is_on);
11965 printf("invalid vf_id %d\n", res->vf_id);
11968 printf("invalid port_id %d\n", res->port_id);
11971 printf("function not implemented\n");
11974 printf("programming error: (%s)\n", strerror(-ret));
11978 cmdline_parse_inst_t cmd_set_vf_promisc = {
11979 .f = cmd_set_vf_promisc_parsed,
11981 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
11982 "Set unicast promiscuous mode for a VF from the PF",
11984 (void *)&cmd_vf_promisc_set,
11985 (void *)&cmd_vf_promisc_vf,
11986 (void *)&cmd_vf_promisc_promisc,
11987 (void *)&cmd_vf_promisc_port_id,
11988 (void *)&cmd_vf_promisc_vf_id,
11989 (void *)&cmd_vf_promisc_on_off,
11994 /* VF multicast promiscuous mode configuration */
11996 /* Common result structure for VF multicast promiscuous mode */
11997 struct cmd_vf_allmulti_result {
11998 cmdline_fixed_string_t set;
11999 cmdline_fixed_string_t vf;
12000 cmdline_fixed_string_t allmulti;
12003 cmdline_fixed_string_t on_off;
12006 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12007 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12008 TOKEN_STRING_INITIALIZER
12009 (struct cmd_vf_allmulti_result,
12011 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12012 TOKEN_STRING_INITIALIZER
12013 (struct cmd_vf_allmulti_result,
12015 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12016 TOKEN_STRING_INITIALIZER
12017 (struct cmd_vf_allmulti_result,
12018 allmulti, "allmulti");
12019 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12020 TOKEN_NUM_INITIALIZER
12021 (struct cmd_vf_allmulti_result,
12022 port_id, RTE_UINT16);
12023 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12024 TOKEN_NUM_INITIALIZER
12025 (struct cmd_vf_allmulti_result,
12026 vf_id, RTE_UINT32);
12027 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12028 TOKEN_STRING_INITIALIZER
12029 (struct cmd_vf_allmulti_result,
12033 cmd_set_vf_allmulti_parsed(
12034 void *parsed_result,
12035 __rte_unused struct cmdline *cl,
12036 __rte_unused void *data)
12038 struct cmd_vf_allmulti_result *res = parsed_result;
12039 int ret = -ENOTSUP;
12041 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12043 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12046 #ifdef RTE_NET_I40E
12047 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12048 res->vf_id, is_on);
12055 printf("invalid vf_id %d\n", res->vf_id);
12058 printf("invalid port_id %d\n", res->port_id);
12061 printf("function not implemented\n");
12064 printf("programming error: (%s)\n", strerror(-ret));
12068 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12069 .f = cmd_set_vf_allmulti_parsed,
12071 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12072 "Set multicast promiscuous mode for a VF from the PF",
12074 (void *)&cmd_vf_allmulti_set,
12075 (void *)&cmd_vf_allmulti_vf,
12076 (void *)&cmd_vf_allmulti_allmulti,
12077 (void *)&cmd_vf_allmulti_port_id,
12078 (void *)&cmd_vf_allmulti_vf_id,
12079 (void *)&cmd_vf_allmulti_on_off,
12084 /* vf broadcast mode configuration */
12086 /* Common result structure for vf broadcast */
12087 struct cmd_set_vf_broadcast_result {
12088 cmdline_fixed_string_t set;
12089 cmdline_fixed_string_t vf;
12090 cmdline_fixed_string_t broadcast;
12093 cmdline_fixed_string_t on_off;
12096 /* Common CLI fields for vf broadcast enable disable */
12097 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12098 TOKEN_STRING_INITIALIZER
12099 (struct cmd_set_vf_broadcast_result,
12101 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12102 TOKEN_STRING_INITIALIZER
12103 (struct cmd_set_vf_broadcast_result,
12105 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12106 TOKEN_STRING_INITIALIZER
12107 (struct cmd_set_vf_broadcast_result,
12108 broadcast, "broadcast");
12109 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12110 TOKEN_NUM_INITIALIZER
12111 (struct cmd_set_vf_broadcast_result,
12112 port_id, RTE_UINT16);
12113 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12114 TOKEN_NUM_INITIALIZER
12115 (struct cmd_set_vf_broadcast_result,
12116 vf_id, RTE_UINT16);
12117 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12118 TOKEN_STRING_INITIALIZER
12119 (struct cmd_set_vf_broadcast_result,
12123 cmd_set_vf_broadcast_parsed(
12124 void *parsed_result,
12125 __rte_unused struct cmdline *cl,
12126 __rte_unused void *data)
12128 struct cmd_set_vf_broadcast_result *res = parsed_result;
12129 int ret = -ENOTSUP;
12131 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12133 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12136 #ifdef RTE_NET_I40E
12137 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12138 res->vf_id, is_on);
12145 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12148 printf("invalid port_id %d\n", res->port_id);
12151 printf("function not implemented\n");
12154 printf("programming error: (%s)\n", strerror(-ret));
12158 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12159 .f = cmd_set_vf_broadcast_parsed,
12161 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12163 (void *)&cmd_set_vf_broadcast_set,
12164 (void *)&cmd_set_vf_broadcast_vf,
12165 (void *)&cmd_set_vf_broadcast_broadcast,
12166 (void *)&cmd_set_vf_broadcast_port_id,
12167 (void *)&cmd_set_vf_broadcast_vf_id,
12168 (void *)&cmd_set_vf_broadcast_on_off,
12173 /* vf vlan tag configuration */
12175 /* Common result structure for vf vlan tag */
12176 struct cmd_set_vf_vlan_tag_result {
12177 cmdline_fixed_string_t set;
12178 cmdline_fixed_string_t vf;
12179 cmdline_fixed_string_t vlan;
12180 cmdline_fixed_string_t tag;
12183 cmdline_fixed_string_t on_off;
12186 /* Common CLI fields for vf vlan tag enable disable */
12187 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12188 TOKEN_STRING_INITIALIZER
12189 (struct cmd_set_vf_vlan_tag_result,
12191 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12192 TOKEN_STRING_INITIALIZER
12193 (struct cmd_set_vf_vlan_tag_result,
12195 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12196 TOKEN_STRING_INITIALIZER
12197 (struct cmd_set_vf_vlan_tag_result,
12199 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12200 TOKEN_STRING_INITIALIZER
12201 (struct cmd_set_vf_vlan_tag_result,
12203 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12204 TOKEN_NUM_INITIALIZER
12205 (struct cmd_set_vf_vlan_tag_result,
12206 port_id, RTE_UINT16);
12207 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12208 TOKEN_NUM_INITIALIZER
12209 (struct cmd_set_vf_vlan_tag_result,
12210 vf_id, RTE_UINT16);
12211 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12212 TOKEN_STRING_INITIALIZER
12213 (struct cmd_set_vf_vlan_tag_result,
12217 cmd_set_vf_vlan_tag_parsed(
12218 void *parsed_result,
12219 __rte_unused struct cmdline *cl,
12220 __rte_unused void *data)
12222 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12223 int ret = -ENOTSUP;
12225 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12227 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12230 #ifdef RTE_NET_I40E
12231 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12232 res->vf_id, is_on);
12239 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12242 printf("invalid port_id %d\n", res->port_id);
12245 printf("function not implemented\n");
12248 printf("programming error: (%s)\n", strerror(-ret));
12252 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12253 .f = cmd_set_vf_vlan_tag_parsed,
12255 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12257 (void *)&cmd_set_vf_vlan_tag_set,
12258 (void *)&cmd_set_vf_vlan_tag_vf,
12259 (void *)&cmd_set_vf_vlan_tag_vlan,
12260 (void *)&cmd_set_vf_vlan_tag_tag,
12261 (void *)&cmd_set_vf_vlan_tag_port_id,
12262 (void *)&cmd_set_vf_vlan_tag_vf_id,
12263 (void *)&cmd_set_vf_vlan_tag_on_off,
12268 /* Common definition of VF and TC TX bandwidth configuration */
12269 struct cmd_vf_tc_bw_result {
12270 cmdline_fixed_string_t set;
12271 cmdline_fixed_string_t vf;
12272 cmdline_fixed_string_t tc;
12273 cmdline_fixed_string_t tx;
12274 cmdline_fixed_string_t min_bw;
12275 cmdline_fixed_string_t max_bw;
12276 cmdline_fixed_string_t strict_link_prio;
12281 cmdline_fixed_string_t bw_list;
12285 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12286 TOKEN_STRING_INITIALIZER
12287 (struct cmd_vf_tc_bw_result,
12289 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12290 TOKEN_STRING_INITIALIZER
12291 (struct cmd_vf_tc_bw_result,
12293 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12294 TOKEN_STRING_INITIALIZER
12295 (struct cmd_vf_tc_bw_result,
12297 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12298 TOKEN_STRING_INITIALIZER
12299 (struct cmd_vf_tc_bw_result,
12301 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12302 TOKEN_STRING_INITIALIZER
12303 (struct cmd_vf_tc_bw_result,
12304 strict_link_prio, "strict-link-priority");
12305 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12306 TOKEN_STRING_INITIALIZER
12307 (struct cmd_vf_tc_bw_result,
12308 min_bw, "min-bandwidth");
12309 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12310 TOKEN_STRING_INITIALIZER
12311 (struct cmd_vf_tc_bw_result,
12312 max_bw, "max-bandwidth");
12313 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12314 TOKEN_NUM_INITIALIZER
12315 (struct cmd_vf_tc_bw_result,
12316 port_id, RTE_UINT16);
12317 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12318 TOKEN_NUM_INITIALIZER
12319 (struct cmd_vf_tc_bw_result,
12320 vf_id, RTE_UINT16);
12321 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12322 TOKEN_NUM_INITIALIZER
12323 (struct cmd_vf_tc_bw_result,
12325 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12326 TOKEN_NUM_INITIALIZER
12327 (struct cmd_vf_tc_bw_result,
12329 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12330 TOKEN_STRING_INITIALIZER
12331 (struct cmd_vf_tc_bw_result,
12333 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12334 TOKEN_NUM_INITIALIZER
12335 (struct cmd_vf_tc_bw_result,
12336 tc_map, RTE_UINT8);
12338 /* VF max bandwidth setting */
12340 cmd_vf_max_bw_parsed(
12341 void *parsed_result,
12342 __rte_unused struct cmdline *cl,
12343 __rte_unused void *data)
12345 struct cmd_vf_tc_bw_result *res = parsed_result;
12346 int ret = -ENOTSUP;
12348 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12351 #ifdef RTE_NET_I40E
12352 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12353 res->vf_id, res->bw);
12360 printf("invalid vf_id %d or bandwidth %d\n",
12361 res->vf_id, res->bw);
12364 printf("invalid port_id %d\n", res->port_id);
12367 printf("function not implemented\n");
12370 printf("programming error: (%s)\n", strerror(-ret));
12374 cmdline_parse_inst_t cmd_vf_max_bw = {
12375 .f = cmd_vf_max_bw_parsed,
12377 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12379 (void *)&cmd_vf_tc_bw_set,
12380 (void *)&cmd_vf_tc_bw_vf,
12381 (void *)&cmd_vf_tc_bw_tx,
12382 (void *)&cmd_vf_tc_bw_max_bw,
12383 (void *)&cmd_vf_tc_bw_port_id,
12384 (void *)&cmd_vf_tc_bw_vf_id,
12385 (void *)&cmd_vf_tc_bw_bw,
12391 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12396 const char *p, *p0 = str;
12403 p = strchr(p0, '(');
12405 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12409 p0 = strchr(p, ')');
12411 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12415 if (size >= sizeof(s)) {
12416 printf("The string size exceeds the internal buffer size\n");
12419 snprintf(s, sizeof(s), "%.*s", size, p);
12420 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12422 printf("Failed to get the bandwidth list. ");
12426 for (i = 0; i < ret; i++)
12427 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12432 /* TC min bandwidth setting */
12434 cmd_vf_tc_min_bw_parsed(
12435 void *parsed_result,
12436 __rte_unused struct cmdline *cl,
12437 __rte_unused void *data)
12439 struct cmd_vf_tc_bw_result *res = parsed_result;
12442 int ret = -ENOTSUP;
12444 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12447 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12451 #ifdef RTE_NET_I40E
12452 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12460 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12463 printf("invalid port_id %d\n", res->port_id);
12466 printf("function not implemented\n");
12469 printf("programming error: (%s)\n", strerror(-ret));
12473 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12474 .f = cmd_vf_tc_min_bw_parsed,
12476 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12477 " <bw1, bw2, ...>",
12479 (void *)&cmd_vf_tc_bw_set,
12480 (void *)&cmd_vf_tc_bw_vf,
12481 (void *)&cmd_vf_tc_bw_tc,
12482 (void *)&cmd_vf_tc_bw_tx,
12483 (void *)&cmd_vf_tc_bw_min_bw,
12484 (void *)&cmd_vf_tc_bw_port_id,
12485 (void *)&cmd_vf_tc_bw_vf_id,
12486 (void *)&cmd_vf_tc_bw_bw_list,
12492 cmd_tc_min_bw_parsed(
12493 void *parsed_result,
12494 __rte_unused struct cmdline *cl,
12495 __rte_unused void *data)
12497 struct cmd_vf_tc_bw_result *res = parsed_result;
12498 struct rte_port *port;
12501 int ret = -ENOTSUP;
12503 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12506 port = &ports[res->port_id];
12507 /** Check if the port is not started **/
12508 if (port->port_status != RTE_PORT_STOPPED) {
12509 printf("Please stop port %d first\n", res->port_id);
12513 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12517 #ifdef RTE_NET_IXGBE
12518 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12525 printf("invalid bandwidth\n");
12528 printf("invalid port_id %d\n", res->port_id);
12531 printf("function not implemented\n");
12534 printf("programming error: (%s)\n", strerror(-ret));
12538 cmdline_parse_inst_t cmd_tc_min_bw = {
12539 .f = cmd_tc_min_bw_parsed,
12541 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12543 (void *)&cmd_vf_tc_bw_set,
12544 (void *)&cmd_vf_tc_bw_tc,
12545 (void *)&cmd_vf_tc_bw_tx,
12546 (void *)&cmd_vf_tc_bw_min_bw,
12547 (void *)&cmd_vf_tc_bw_port_id,
12548 (void *)&cmd_vf_tc_bw_bw_list,
12553 /* TC max bandwidth setting */
12555 cmd_vf_tc_max_bw_parsed(
12556 void *parsed_result,
12557 __rte_unused struct cmdline *cl,
12558 __rte_unused void *data)
12560 struct cmd_vf_tc_bw_result *res = parsed_result;
12561 int ret = -ENOTSUP;
12563 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12566 #ifdef RTE_NET_I40E
12567 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12568 res->tc_no, res->bw);
12575 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
12576 res->vf_id, res->tc_no, res->bw);
12579 printf("invalid port_id %d\n", res->port_id);
12582 printf("function not implemented\n");
12585 printf("programming error: (%s)\n", strerror(-ret));
12589 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12590 .f = cmd_vf_tc_max_bw_parsed,
12592 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12595 (void *)&cmd_vf_tc_bw_set,
12596 (void *)&cmd_vf_tc_bw_vf,
12597 (void *)&cmd_vf_tc_bw_tc,
12598 (void *)&cmd_vf_tc_bw_tx,
12599 (void *)&cmd_vf_tc_bw_max_bw,
12600 (void *)&cmd_vf_tc_bw_port_id,
12601 (void *)&cmd_vf_tc_bw_vf_id,
12602 (void *)&cmd_vf_tc_bw_tc_no,
12603 (void *)&cmd_vf_tc_bw_bw,
12608 /** Set VXLAN encapsulation details */
12609 struct cmd_set_vxlan_result {
12610 cmdline_fixed_string_t set;
12611 cmdline_fixed_string_t vxlan;
12612 cmdline_fixed_string_t pos_token;
12613 cmdline_fixed_string_t ip_version;
12614 uint32_t vlan_present:1;
12618 cmdline_ipaddr_t ip_src;
12619 cmdline_ipaddr_t ip_dst;
12623 struct rte_ether_addr eth_src;
12624 struct rte_ether_addr eth_dst;
12627 cmdline_parse_token_string_t cmd_set_vxlan_set =
12628 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
12629 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
12630 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
12631 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
12632 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12634 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
12635 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12636 "vxlan-with-vlan");
12637 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
12638 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12640 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
12641 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
12643 cmdline_parse_token_string_t cmd_set_vxlan_vni =
12644 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12646 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
12647 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
12648 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
12649 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12651 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
12652 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
12653 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
12654 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12656 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
12657 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
12658 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
12659 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12661 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
12662 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
12663 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
12664 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12666 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
12667 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
12668 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
12669 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12671 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
12672 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
12673 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
12674 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12676 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
12677 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
12678 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
12679 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12681 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
12682 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
12683 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
12684 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12686 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
12687 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
12688 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
12689 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12691 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
12692 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
12694 static void cmd_set_vxlan_parsed(void *parsed_result,
12695 __rte_unused struct cmdline *cl,
12696 __rte_unused void *data)
12698 struct cmd_set_vxlan_result *res = parsed_result;
12703 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
12706 vxlan_encap_conf.select_tos_ttl = 0;
12707 if (strcmp(res->vxlan, "vxlan") == 0)
12708 vxlan_encap_conf.select_vlan = 0;
12709 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
12710 vxlan_encap_conf.select_vlan = 1;
12711 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
12712 vxlan_encap_conf.select_vlan = 0;
12713 vxlan_encap_conf.select_tos_ttl = 1;
12715 if (strcmp(res->ip_version, "ipv4") == 0)
12716 vxlan_encap_conf.select_ipv4 = 1;
12717 else if (strcmp(res->ip_version, "ipv6") == 0)
12718 vxlan_encap_conf.select_ipv4 = 0;
12721 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
12722 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
12723 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
12724 vxlan_encap_conf.ip_tos = res->tos;
12725 vxlan_encap_conf.ip_ttl = res->ttl;
12726 if (vxlan_encap_conf.select_ipv4) {
12727 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
12728 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
12730 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
12731 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
12733 if (vxlan_encap_conf.select_vlan)
12734 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
12735 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
12736 RTE_ETHER_ADDR_LEN);
12737 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
12738 RTE_ETHER_ADDR_LEN);
12741 cmdline_parse_inst_t cmd_set_vxlan = {
12742 .f = cmd_set_vxlan_parsed,
12744 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
12745 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
12746 " eth-src <eth-src> eth-dst <eth-dst>",
12748 (void *)&cmd_set_vxlan_set,
12749 (void *)&cmd_set_vxlan_vxlan,
12750 (void *)&cmd_set_vxlan_ip_version,
12751 (void *)&cmd_set_vxlan_ip_version_value,
12752 (void *)&cmd_set_vxlan_vni,
12753 (void *)&cmd_set_vxlan_vni_value,
12754 (void *)&cmd_set_vxlan_udp_src,
12755 (void *)&cmd_set_vxlan_udp_src_value,
12756 (void *)&cmd_set_vxlan_udp_dst,
12757 (void *)&cmd_set_vxlan_udp_dst_value,
12758 (void *)&cmd_set_vxlan_ip_src,
12759 (void *)&cmd_set_vxlan_ip_src_value,
12760 (void *)&cmd_set_vxlan_ip_dst,
12761 (void *)&cmd_set_vxlan_ip_dst_value,
12762 (void *)&cmd_set_vxlan_eth_src,
12763 (void *)&cmd_set_vxlan_eth_src_value,
12764 (void *)&cmd_set_vxlan_eth_dst,
12765 (void *)&cmd_set_vxlan_eth_dst_value,
12770 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
12771 .f = cmd_set_vxlan_parsed,
12773 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
12774 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
12775 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
12776 " eth-dst <eth-dst>",
12778 (void *)&cmd_set_vxlan_set,
12779 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
12780 (void *)&cmd_set_vxlan_ip_version,
12781 (void *)&cmd_set_vxlan_ip_version_value,
12782 (void *)&cmd_set_vxlan_vni,
12783 (void *)&cmd_set_vxlan_vni_value,
12784 (void *)&cmd_set_vxlan_udp_src,
12785 (void *)&cmd_set_vxlan_udp_src_value,
12786 (void *)&cmd_set_vxlan_udp_dst,
12787 (void *)&cmd_set_vxlan_udp_dst_value,
12788 (void *)&cmd_set_vxlan_ip_tos,
12789 (void *)&cmd_set_vxlan_ip_tos_value,
12790 (void *)&cmd_set_vxlan_ip_ttl,
12791 (void *)&cmd_set_vxlan_ip_ttl_value,
12792 (void *)&cmd_set_vxlan_ip_src,
12793 (void *)&cmd_set_vxlan_ip_src_value,
12794 (void *)&cmd_set_vxlan_ip_dst,
12795 (void *)&cmd_set_vxlan_ip_dst_value,
12796 (void *)&cmd_set_vxlan_eth_src,
12797 (void *)&cmd_set_vxlan_eth_src_value,
12798 (void *)&cmd_set_vxlan_eth_dst,
12799 (void *)&cmd_set_vxlan_eth_dst_value,
12804 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
12805 .f = cmd_set_vxlan_parsed,
12807 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
12808 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
12809 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
12812 (void *)&cmd_set_vxlan_set,
12813 (void *)&cmd_set_vxlan_vxlan_with_vlan,
12814 (void *)&cmd_set_vxlan_ip_version,
12815 (void *)&cmd_set_vxlan_ip_version_value,
12816 (void *)&cmd_set_vxlan_vni,
12817 (void *)&cmd_set_vxlan_vni_value,
12818 (void *)&cmd_set_vxlan_udp_src,
12819 (void *)&cmd_set_vxlan_udp_src_value,
12820 (void *)&cmd_set_vxlan_udp_dst,
12821 (void *)&cmd_set_vxlan_udp_dst_value,
12822 (void *)&cmd_set_vxlan_ip_src,
12823 (void *)&cmd_set_vxlan_ip_src_value,
12824 (void *)&cmd_set_vxlan_ip_dst,
12825 (void *)&cmd_set_vxlan_ip_dst_value,
12826 (void *)&cmd_set_vxlan_vlan,
12827 (void *)&cmd_set_vxlan_vlan_value,
12828 (void *)&cmd_set_vxlan_eth_src,
12829 (void *)&cmd_set_vxlan_eth_src_value,
12830 (void *)&cmd_set_vxlan_eth_dst,
12831 (void *)&cmd_set_vxlan_eth_dst_value,
12836 /** Set NVGRE encapsulation details */
12837 struct cmd_set_nvgre_result {
12838 cmdline_fixed_string_t set;
12839 cmdline_fixed_string_t nvgre;
12840 cmdline_fixed_string_t pos_token;
12841 cmdline_fixed_string_t ip_version;
12843 cmdline_ipaddr_t ip_src;
12844 cmdline_ipaddr_t ip_dst;
12846 struct rte_ether_addr eth_src;
12847 struct rte_ether_addr eth_dst;
12850 cmdline_parse_token_string_t cmd_set_nvgre_set =
12851 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
12852 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
12853 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
12854 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
12855 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
12856 "nvgre-with-vlan");
12857 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
12858 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12860 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
12861 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
12863 cmdline_parse_token_string_t cmd_set_nvgre_tni =
12864 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12866 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
12867 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
12868 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
12869 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12871 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
12872 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
12873 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
12874 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12876 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
12877 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
12878 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
12879 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12881 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
12882 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
12883 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
12884 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12886 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
12887 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
12888 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
12889 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12891 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
12892 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
12894 static void cmd_set_nvgre_parsed(void *parsed_result,
12895 __rte_unused struct cmdline *cl,
12896 __rte_unused void *data)
12898 struct cmd_set_nvgre_result *res = parsed_result;
12900 uint32_t nvgre_tni;
12903 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
12906 if (strcmp(res->nvgre, "nvgre") == 0)
12907 nvgre_encap_conf.select_vlan = 0;
12908 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
12909 nvgre_encap_conf.select_vlan = 1;
12910 if (strcmp(res->ip_version, "ipv4") == 0)
12911 nvgre_encap_conf.select_ipv4 = 1;
12912 else if (strcmp(res->ip_version, "ipv6") == 0)
12913 nvgre_encap_conf.select_ipv4 = 0;
12916 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
12917 if (nvgre_encap_conf.select_ipv4) {
12918 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
12919 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
12921 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
12922 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
12924 if (nvgre_encap_conf.select_vlan)
12925 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
12926 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
12927 RTE_ETHER_ADDR_LEN);
12928 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
12929 RTE_ETHER_ADDR_LEN);
12932 cmdline_parse_inst_t cmd_set_nvgre = {
12933 .f = cmd_set_nvgre_parsed,
12935 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
12936 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
12937 " eth-dst <eth-dst>",
12939 (void *)&cmd_set_nvgre_set,
12940 (void *)&cmd_set_nvgre_nvgre,
12941 (void *)&cmd_set_nvgre_ip_version,
12942 (void *)&cmd_set_nvgre_ip_version_value,
12943 (void *)&cmd_set_nvgre_tni,
12944 (void *)&cmd_set_nvgre_tni_value,
12945 (void *)&cmd_set_nvgre_ip_src,
12946 (void *)&cmd_set_nvgre_ip_src_value,
12947 (void *)&cmd_set_nvgre_ip_dst,
12948 (void *)&cmd_set_nvgre_ip_dst_value,
12949 (void *)&cmd_set_nvgre_eth_src,
12950 (void *)&cmd_set_nvgre_eth_src_value,
12951 (void *)&cmd_set_nvgre_eth_dst,
12952 (void *)&cmd_set_nvgre_eth_dst_value,
12957 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
12958 .f = cmd_set_nvgre_parsed,
12960 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
12961 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
12962 " eth-src <eth-src> eth-dst <eth-dst>",
12964 (void *)&cmd_set_nvgre_set,
12965 (void *)&cmd_set_nvgre_nvgre_with_vlan,
12966 (void *)&cmd_set_nvgre_ip_version,
12967 (void *)&cmd_set_nvgre_ip_version_value,
12968 (void *)&cmd_set_nvgre_tni,
12969 (void *)&cmd_set_nvgre_tni_value,
12970 (void *)&cmd_set_nvgre_ip_src,
12971 (void *)&cmd_set_nvgre_ip_src_value,
12972 (void *)&cmd_set_nvgre_ip_dst,
12973 (void *)&cmd_set_nvgre_ip_dst_value,
12974 (void *)&cmd_set_nvgre_vlan,
12975 (void *)&cmd_set_nvgre_vlan_value,
12976 (void *)&cmd_set_nvgre_eth_src,
12977 (void *)&cmd_set_nvgre_eth_src_value,
12978 (void *)&cmd_set_nvgre_eth_dst,
12979 (void *)&cmd_set_nvgre_eth_dst_value,
12984 /** Set L2 encapsulation details */
12985 struct cmd_set_l2_encap_result {
12986 cmdline_fixed_string_t set;
12987 cmdline_fixed_string_t l2_encap;
12988 cmdline_fixed_string_t pos_token;
12989 cmdline_fixed_string_t ip_version;
12990 uint32_t vlan_present:1;
12992 struct rte_ether_addr eth_src;
12993 struct rte_ether_addr eth_dst;
12996 cmdline_parse_token_string_t cmd_set_l2_encap_set =
12997 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
12998 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
12999 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13000 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13001 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13002 "l2_encap-with-vlan");
13003 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13004 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13006 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13007 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13009 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13010 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13012 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13013 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13014 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13015 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13017 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13018 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13019 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13020 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13022 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13023 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13025 static void cmd_set_l2_encap_parsed(void *parsed_result,
13026 __rte_unused struct cmdline *cl,
13027 __rte_unused void *data)
13029 struct cmd_set_l2_encap_result *res = parsed_result;
13031 if (strcmp(res->l2_encap, "l2_encap") == 0)
13032 l2_encap_conf.select_vlan = 0;
13033 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13034 l2_encap_conf.select_vlan = 1;
13035 if (strcmp(res->ip_version, "ipv4") == 0)
13036 l2_encap_conf.select_ipv4 = 1;
13037 else if (strcmp(res->ip_version, "ipv6") == 0)
13038 l2_encap_conf.select_ipv4 = 0;
13041 if (l2_encap_conf.select_vlan)
13042 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13043 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13044 RTE_ETHER_ADDR_LEN);
13045 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13046 RTE_ETHER_ADDR_LEN);
13049 cmdline_parse_inst_t cmd_set_l2_encap = {
13050 .f = cmd_set_l2_encap_parsed,
13052 .help_str = "set l2_encap ip-version ipv4|ipv6"
13053 " eth-src <eth-src> eth-dst <eth-dst>",
13055 (void *)&cmd_set_l2_encap_set,
13056 (void *)&cmd_set_l2_encap_l2_encap,
13057 (void *)&cmd_set_l2_encap_ip_version,
13058 (void *)&cmd_set_l2_encap_ip_version_value,
13059 (void *)&cmd_set_l2_encap_eth_src,
13060 (void *)&cmd_set_l2_encap_eth_src_value,
13061 (void *)&cmd_set_l2_encap_eth_dst,
13062 (void *)&cmd_set_l2_encap_eth_dst_value,
13067 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13068 .f = cmd_set_l2_encap_parsed,
13070 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13071 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13073 (void *)&cmd_set_l2_encap_set,
13074 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13075 (void *)&cmd_set_l2_encap_ip_version,
13076 (void *)&cmd_set_l2_encap_ip_version_value,
13077 (void *)&cmd_set_l2_encap_vlan,
13078 (void *)&cmd_set_l2_encap_vlan_value,
13079 (void *)&cmd_set_l2_encap_eth_src,
13080 (void *)&cmd_set_l2_encap_eth_src_value,
13081 (void *)&cmd_set_l2_encap_eth_dst,
13082 (void *)&cmd_set_l2_encap_eth_dst_value,
13087 /** Set L2 decapsulation details */
13088 struct cmd_set_l2_decap_result {
13089 cmdline_fixed_string_t set;
13090 cmdline_fixed_string_t l2_decap;
13091 cmdline_fixed_string_t pos_token;
13092 uint32_t vlan_present:1;
13095 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13096 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13097 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13098 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13100 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13101 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13102 "l2_decap-with-vlan");
13104 static void cmd_set_l2_decap_parsed(void *parsed_result,
13105 __rte_unused struct cmdline *cl,
13106 __rte_unused void *data)
13108 struct cmd_set_l2_decap_result *res = parsed_result;
13110 if (strcmp(res->l2_decap, "l2_decap") == 0)
13111 l2_decap_conf.select_vlan = 0;
13112 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13113 l2_decap_conf.select_vlan = 1;
13116 cmdline_parse_inst_t cmd_set_l2_decap = {
13117 .f = cmd_set_l2_decap_parsed,
13119 .help_str = "set l2_decap",
13121 (void *)&cmd_set_l2_decap_set,
13122 (void *)&cmd_set_l2_decap_l2_decap,
13127 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13128 .f = cmd_set_l2_decap_parsed,
13130 .help_str = "set l2_decap-with-vlan",
13132 (void *)&cmd_set_l2_decap_set,
13133 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13138 /** Set MPLSoGRE encapsulation details */
13139 struct cmd_set_mplsogre_encap_result {
13140 cmdline_fixed_string_t set;
13141 cmdline_fixed_string_t mplsogre;
13142 cmdline_fixed_string_t pos_token;
13143 cmdline_fixed_string_t ip_version;
13144 uint32_t vlan_present:1;
13146 cmdline_ipaddr_t ip_src;
13147 cmdline_ipaddr_t ip_dst;
13149 struct rte_ether_addr eth_src;
13150 struct rte_ether_addr eth_dst;
13153 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13154 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13156 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13157 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13159 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13160 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13161 mplsogre, "mplsogre_encap-with-vlan");
13162 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13163 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13164 pos_token, "ip-version");
13165 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13166 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13167 ip_version, "ipv4#ipv6");
13168 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13169 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13170 pos_token, "label");
13171 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13172 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13174 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13175 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13176 pos_token, "ip-src");
13177 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13178 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13179 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13180 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13181 pos_token, "ip-dst");
13182 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13183 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13184 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13185 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13186 pos_token, "vlan-tci");
13187 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13188 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13190 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13191 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13192 pos_token, "eth-src");
13193 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13194 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13196 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13197 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13198 pos_token, "eth-dst");
13199 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13200 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13203 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13204 __rte_unused struct cmdline *cl,
13205 __rte_unused void *data)
13207 struct cmd_set_mplsogre_encap_result *res = parsed_result;
13209 uint32_t mplsogre_label;
13212 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13215 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13216 mplsogre_encap_conf.select_vlan = 0;
13217 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13218 mplsogre_encap_conf.select_vlan = 1;
13219 if (strcmp(res->ip_version, "ipv4") == 0)
13220 mplsogre_encap_conf.select_ipv4 = 1;
13221 else if (strcmp(res->ip_version, "ipv6") == 0)
13222 mplsogre_encap_conf.select_ipv4 = 0;
13225 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13226 if (mplsogre_encap_conf.select_ipv4) {
13227 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13228 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13230 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13231 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13233 if (mplsogre_encap_conf.select_vlan)
13234 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13235 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13236 RTE_ETHER_ADDR_LEN);
13237 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13238 RTE_ETHER_ADDR_LEN);
13241 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13242 .f = cmd_set_mplsogre_encap_parsed,
13244 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13245 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13246 " eth-dst <eth-dst>",
13248 (void *)&cmd_set_mplsogre_encap_set,
13249 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13250 (void *)&cmd_set_mplsogre_encap_ip_version,
13251 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13252 (void *)&cmd_set_mplsogre_encap_label,
13253 (void *)&cmd_set_mplsogre_encap_label_value,
13254 (void *)&cmd_set_mplsogre_encap_ip_src,
13255 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13256 (void *)&cmd_set_mplsogre_encap_ip_dst,
13257 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13258 (void *)&cmd_set_mplsogre_encap_eth_src,
13259 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13260 (void *)&cmd_set_mplsogre_encap_eth_dst,
13261 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13266 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13267 .f = cmd_set_mplsogre_encap_parsed,
13269 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13270 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
13271 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13273 (void *)&cmd_set_mplsogre_encap_set,
13274 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13275 (void *)&cmd_set_mplsogre_encap_ip_version,
13276 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13277 (void *)&cmd_set_mplsogre_encap_label,
13278 (void *)&cmd_set_mplsogre_encap_label_value,
13279 (void *)&cmd_set_mplsogre_encap_ip_src,
13280 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13281 (void *)&cmd_set_mplsogre_encap_ip_dst,
13282 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13283 (void *)&cmd_set_mplsogre_encap_vlan,
13284 (void *)&cmd_set_mplsogre_encap_vlan_value,
13285 (void *)&cmd_set_mplsogre_encap_eth_src,
13286 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13287 (void *)&cmd_set_mplsogre_encap_eth_dst,
13288 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13293 /** Set MPLSoGRE decapsulation details */
13294 struct cmd_set_mplsogre_decap_result {
13295 cmdline_fixed_string_t set;
13296 cmdline_fixed_string_t mplsogre;
13297 cmdline_fixed_string_t pos_token;
13298 cmdline_fixed_string_t ip_version;
13299 uint32_t vlan_present:1;
13302 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13303 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13305 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13306 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13308 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13309 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13310 mplsogre, "mplsogre_decap-with-vlan");
13311 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13312 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13313 pos_token, "ip-version");
13314 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13315 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13316 ip_version, "ipv4#ipv6");
13318 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13319 __rte_unused struct cmdline *cl,
13320 __rte_unused void *data)
13322 struct cmd_set_mplsogre_decap_result *res = parsed_result;
13324 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13325 mplsogre_decap_conf.select_vlan = 0;
13326 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13327 mplsogre_decap_conf.select_vlan = 1;
13328 if (strcmp(res->ip_version, "ipv4") == 0)
13329 mplsogre_decap_conf.select_ipv4 = 1;
13330 else if (strcmp(res->ip_version, "ipv6") == 0)
13331 mplsogre_decap_conf.select_ipv4 = 0;
13334 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13335 .f = cmd_set_mplsogre_decap_parsed,
13337 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13339 (void *)&cmd_set_mplsogre_decap_set,
13340 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13341 (void *)&cmd_set_mplsogre_decap_ip_version,
13342 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13347 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13348 .f = cmd_set_mplsogre_decap_parsed,
13350 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13352 (void *)&cmd_set_mplsogre_decap_set,
13353 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13354 (void *)&cmd_set_mplsogre_decap_ip_version,
13355 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13360 /** Set MPLSoUDP encapsulation details */
13361 struct cmd_set_mplsoudp_encap_result {
13362 cmdline_fixed_string_t set;
13363 cmdline_fixed_string_t mplsoudp;
13364 cmdline_fixed_string_t pos_token;
13365 cmdline_fixed_string_t ip_version;
13366 uint32_t vlan_present:1;
13370 cmdline_ipaddr_t ip_src;
13371 cmdline_ipaddr_t ip_dst;
13373 struct rte_ether_addr eth_src;
13374 struct rte_ether_addr eth_dst;
13377 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13378 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13380 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13381 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13383 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13384 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13385 mplsoudp, "mplsoudp_encap-with-vlan");
13386 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13387 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13388 pos_token, "ip-version");
13389 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13390 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13391 ip_version, "ipv4#ipv6");
13392 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13393 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13394 pos_token, "label");
13395 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13396 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13398 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13399 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13400 pos_token, "udp-src");
13401 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13402 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13404 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13405 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13406 pos_token, "udp-dst");
13407 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13408 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13410 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13411 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13412 pos_token, "ip-src");
13413 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13414 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13415 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13416 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13417 pos_token, "ip-dst");
13418 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13419 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13420 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13421 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13422 pos_token, "vlan-tci");
13423 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13424 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13426 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13427 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13428 pos_token, "eth-src");
13429 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13430 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13432 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13433 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13434 pos_token, "eth-dst");
13435 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13436 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13439 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13440 __rte_unused struct cmdline *cl,
13441 __rte_unused void *data)
13443 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13445 uint32_t mplsoudp_label;
13448 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13451 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13452 mplsoudp_encap_conf.select_vlan = 0;
13453 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13454 mplsoudp_encap_conf.select_vlan = 1;
13455 if (strcmp(res->ip_version, "ipv4") == 0)
13456 mplsoudp_encap_conf.select_ipv4 = 1;
13457 else if (strcmp(res->ip_version, "ipv6") == 0)
13458 mplsoudp_encap_conf.select_ipv4 = 0;
13461 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13462 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13463 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13464 if (mplsoudp_encap_conf.select_ipv4) {
13465 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13466 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13468 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13469 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13471 if (mplsoudp_encap_conf.select_vlan)
13472 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13473 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13474 RTE_ETHER_ADDR_LEN);
13475 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13476 RTE_ETHER_ADDR_LEN);
13479 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13480 .f = cmd_set_mplsoudp_encap_parsed,
13482 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13483 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13484 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13486 (void *)&cmd_set_mplsoudp_encap_set,
13487 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13488 (void *)&cmd_set_mplsoudp_encap_ip_version,
13489 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13490 (void *)&cmd_set_mplsoudp_encap_label,
13491 (void *)&cmd_set_mplsoudp_encap_label_value,
13492 (void *)&cmd_set_mplsoudp_encap_udp_src,
13493 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13494 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13495 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13496 (void *)&cmd_set_mplsoudp_encap_ip_src,
13497 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13498 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13499 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13500 (void *)&cmd_set_mplsoudp_encap_eth_src,
13501 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13502 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13503 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13508 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13509 .f = cmd_set_mplsoudp_encap_parsed,
13511 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13512 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
13513 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13514 " eth-src <eth-src> eth-dst <eth-dst>",
13516 (void *)&cmd_set_mplsoudp_encap_set,
13517 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13518 (void *)&cmd_set_mplsoudp_encap_ip_version,
13519 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13520 (void *)&cmd_set_mplsoudp_encap_label,
13521 (void *)&cmd_set_mplsoudp_encap_label_value,
13522 (void *)&cmd_set_mplsoudp_encap_udp_src,
13523 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13524 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13525 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13526 (void *)&cmd_set_mplsoudp_encap_ip_src,
13527 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13528 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13529 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13530 (void *)&cmd_set_mplsoudp_encap_vlan,
13531 (void *)&cmd_set_mplsoudp_encap_vlan_value,
13532 (void *)&cmd_set_mplsoudp_encap_eth_src,
13533 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13534 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13535 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13540 /** Set MPLSoUDP decapsulation details */
13541 struct cmd_set_mplsoudp_decap_result {
13542 cmdline_fixed_string_t set;
13543 cmdline_fixed_string_t mplsoudp;
13544 cmdline_fixed_string_t pos_token;
13545 cmdline_fixed_string_t ip_version;
13546 uint32_t vlan_present:1;
13549 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
13550 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
13552 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
13553 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
13555 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
13556 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13557 mplsoudp, "mplsoudp_decap-with-vlan");
13558 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
13559 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13560 pos_token, "ip-version");
13561 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
13562 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13563 ip_version, "ipv4#ipv6");
13565 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
13566 __rte_unused struct cmdline *cl,
13567 __rte_unused void *data)
13569 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
13571 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
13572 mplsoudp_decap_conf.select_vlan = 0;
13573 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
13574 mplsoudp_decap_conf.select_vlan = 1;
13575 if (strcmp(res->ip_version, "ipv4") == 0)
13576 mplsoudp_decap_conf.select_ipv4 = 1;
13577 else if (strcmp(res->ip_version, "ipv6") == 0)
13578 mplsoudp_decap_conf.select_ipv4 = 0;
13581 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
13582 .f = cmd_set_mplsoudp_decap_parsed,
13584 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
13586 (void *)&cmd_set_mplsoudp_decap_set,
13587 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
13588 (void *)&cmd_set_mplsoudp_decap_ip_version,
13589 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13594 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
13595 .f = cmd_set_mplsoudp_decap_parsed,
13597 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
13599 (void *)&cmd_set_mplsoudp_decap_set,
13600 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
13601 (void *)&cmd_set_mplsoudp_decap_ip_version,
13602 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13607 /* Strict link priority scheduling mode setting */
13609 cmd_strict_link_prio_parsed(
13610 void *parsed_result,
13611 __rte_unused struct cmdline *cl,
13612 __rte_unused void *data)
13614 struct cmd_vf_tc_bw_result *res = parsed_result;
13615 int ret = -ENOTSUP;
13617 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13620 #ifdef RTE_NET_I40E
13621 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
13628 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
13631 printf("invalid port_id %d\n", res->port_id);
13634 printf("function not implemented\n");
13637 printf("programming error: (%s)\n", strerror(-ret));
13641 cmdline_parse_inst_t cmd_strict_link_prio = {
13642 .f = cmd_strict_link_prio_parsed,
13644 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
13646 (void *)&cmd_vf_tc_bw_set,
13647 (void *)&cmd_vf_tc_bw_tx,
13648 (void *)&cmd_vf_tc_bw_strict_link_prio,
13649 (void *)&cmd_vf_tc_bw_port_id,
13650 (void *)&cmd_vf_tc_bw_tc_map,
13655 /* Load dynamic device personalization*/
13656 struct cmd_ddp_add_result {
13657 cmdline_fixed_string_t ddp;
13658 cmdline_fixed_string_t add;
13663 cmdline_parse_token_string_t cmd_ddp_add_ddp =
13664 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
13665 cmdline_parse_token_string_t cmd_ddp_add_add =
13666 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
13667 cmdline_parse_token_num_t cmd_ddp_add_port_id =
13668 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
13670 cmdline_parse_token_string_t cmd_ddp_add_filepath =
13671 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
13674 cmd_ddp_add_parsed(
13675 void *parsed_result,
13676 __rte_unused struct cmdline *cl,
13677 __rte_unused void *data)
13679 struct cmd_ddp_add_result *res = parsed_result;
13685 int ret = -ENOTSUP;
13687 if (!all_ports_stopped()) {
13688 printf("Please stop all ports first\n");
13692 filepath = strdup(res->filepath);
13693 if (filepath == NULL) {
13694 printf("Failed to allocate memory\n");
13697 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
13699 buff = open_file(file_fld[0], &size);
13701 free((void *)filepath);
13705 #ifdef RTE_NET_I40E
13706 if (ret == -ENOTSUP)
13707 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13709 RTE_PMD_I40E_PKG_OP_WR_ADD);
13712 if (ret == -EEXIST)
13713 printf("Profile has already existed.\n");
13715 printf("Failed to load profile.\n");
13716 else if (file_num == 2)
13717 save_file(file_fld[1], buff, size);
13720 free((void *)filepath);
13723 cmdline_parse_inst_t cmd_ddp_add = {
13724 .f = cmd_ddp_add_parsed,
13726 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
13728 (void *)&cmd_ddp_add_ddp,
13729 (void *)&cmd_ddp_add_add,
13730 (void *)&cmd_ddp_add_port_id,
13731 (void *)&cmd_ddp_add_filepath,
13736 /* Delete dynamic device personalization*/
13737 struct cmd_ddp_del_result {
13738 cmdline_fixed_string_t ddp;
13739 cmdline_fixed_string_t del;
13744 cmdline_parse_token_string_t cmd_ddp_del_ddp =
13745 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
13746 cmdline_parse_token_string_t cmd_ddp_del_del =
13747 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
13748 cmdline_parse_token_num_t cmd_ddp_del_port_id =
13749 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
13750 cmdline_parse_token_string_t cmd_ddp_del_filepath =
13751 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
13754 cmd_ddp_del_parsed(
13755 void *parsed_result,
13756 __rte_unused struct cmdline *cl,
13757 __rte_unused void *data)
13759 struct cmd_ddp_del_result *res = parsed_result;
13762 int ret = -ENOTSUP;
13764 if (!all_ports_stopped()) {
13765 printf("Please stop all ports first\n");
13769 buff = open_file(res->filepath, &size);
13773 #ifdef RTE_NET_I40E
13774 if (ret == -ENOTSUP)
13775 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13777 RTE_PMD_I40E_PKG_OP_WR_DEL);
13780 if (ret == -EACCES)
13781 printf("Profile does not exist.\n");
13783 printf("Failed to delete profile.\n");
13788 cmdline_parse_inst_t cmd_ddp_del = {
13789 .f = cmd_ddp_del_parsed,
13791 .help_str = "ddp del <port_id> <backup_profile_path>",
13793 (void *)&cmd_ddp_del_ddp,
13794 (void *)&cmd_ddp_del_del,
13795 (void *)&cmd_ddp_del_port_id,
13796 (void *)&cmd_ddp_del_filepath,
13801 /* Get dynamic device personalization profile info */
13802 struct cmd_ddp_info_result {
13803 cmdline_fixed_string_t ddp;
13804 cmdline_fixed_string_t get;
13805 cmdline_fixed_string_t info;
13809 cmdline_parse_token_string_t cmd_ddp_info_ddp =
13810 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
13811 cmdline_parse_token_string_t cmd_ddp_info_get =
13812 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
13813 cmdline_parse_token_string_t cmd_ddp_info_info =
13814 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
13815 cmdline_parse_token_string_t cmd_ddp_info_filepath =
13816 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
13819 cmd_ddp_info_parsed(
13820 void *parsed_result,
13821 __rte_unused struct cmdline *cl,
13822 __rte_unused void *data)
13824 struct cmd_ddp_info_result *res = parsed_result;
13827 int ret = -ENOTSUP;
13828 #ifdef RTE_NET_I40E
13831 uint32_t buff_size = 0;
13832 struct rte_pmd_i40e_profile_info info;
13833 uint32_t dev_num = 0;
13834 struct rte_pmd_i40e_ddp_device_id *devs;
13835 uint32_t proto_num = 0;
13836 struct rte_pmd_i40e_proto_info *proto = NULL;
13837 uint32_t pctype_num = 0;
13838 struct rte_pmd_i40e_ptype_info *pctype;
13839 uint32_t ptype_num = 0;
13840 struct rte_pmd_i40e_ptype_info *ptype;
13845 pkg = open_file(res->filepath, &pkg_size);
13849 #ifdef RTE_NET_I40E
13850 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13851 (uint8_t *)&info, sizeof(info),
13852 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
13854 printf("Global Track id: 0x%x\n", info.track_id);
13855 printf("Global Version: %d.%d.%d.%d\n",
13856 info.version.major,
13857 info.version.minor,
13858 info.version.update,
13859 info.version.draft);
13860 printf("Global Package name: %s\n\n", info.name);
13863 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13864 (uint8_t *)&info, sizeof(info),
13865 RTE_PMD_I40E_PKG_INFO_HEADER);
13867 printf("i40e Profile Track id: 0x%x\n", info.track_id);
13868 printf("i40e Profile Version: %d.%d.%d.%d\n",
13869 info.version.major,
13870 info.version.minor,
13871 info.version.update,
13872 info.version.draft);
13873 printf("i40e Profile name: %s\n\n", info.name);
13876 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13877 (uint8_t *)&buff_size, sizeof(buff_size),
13878 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
13879 if (!ret && buff_size) {
13880 buff = (uint8_t *)malloc(buff_size);
13882 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13884 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
13886 printf("Package Notes:\n%s\n\n", buff);
13891 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13892 (uint8_t *)&dev_num, sizeof(dev_num),
13893 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
13894 if (!ret && dev_num) {
13895 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
13896 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
13898 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13899 (uint8_t *)devs, buff_size,
13900 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
13902 printf("List of supported devices:\n");
13903 for (i = 0; i < dev_num; i++) {
13904 printf(" %04X:%04X %04X:%04X\n",
13905 devs[i].vendor_dev_id >> 16,
13906 devs[i].vendor_dev_id & 0xFFFF,
13907 devs[i].sub_vendor_dev_id >> 16,
13908 devs[i].sub_vendor_dev_id & 0xFFFF);
13916 /* get information about protocols and packet types */
13917 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13918 (uint8_t *)&proto_num, sizeof(proto_num),
13919 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
13920 if (ret || !proto_num)
13921 goto no_print_return;
13923 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
13924 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
13926 goto no_print_return;
13928 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
13930 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
13932 printf("List of used protocols:\n");
13933 for (i = 0; i < proto_num; i++)
13934 printf(" %2u: %s\n", proto[i].proto_id,
13938 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13939 (uint8_t *)&pctype_num, sizeof(pctype_num),
13940 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
13941 if (ret || !pctype_num)
13942 goto no_print_pctypes;
13944 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
13945 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
13947 goto no_print_pctypes;
13949 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
13951 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
13954 goto no_print_pctypes;
13957 printf("List of defined packet classification types:\n");
13958 for (i = 0; i < pctype_num; i++) {
13959 printf(" %2u:", pctype[i].ptype_id);
13960 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
13961 proto_id = pctype[i].protocols[j];
13962 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
13963 for (n = 0; n < proto_num; n++) {
13964 if (proto[n].proto_id == proto_id) {
13965 printf(" %s", proto[n].name);
13978 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
13980 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
13981 if (ret || !ptype_num)
13982 goto no_print_return;
13984 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
13985 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
13987 goto no_print_return;
13989 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
13991 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
13994 goto no_print_return;
13996 printf("List of defined packet types:\n");
13997 for (i = 0; i < ptype_num; i++) {
13998 printf(" %2u:", ptype[i].ptype_id);
13999 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14000 proto_id = ptype[i].protocols[j];
14001 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14002 for (n = 0; n < proto_num; n++) {
14003 if (proto[n].proto_id == proto_id) {
14004 printf(" %s", proto[n].name);
14020 if (ret == -ENOTSUP)
14021 printf("Function not supported in PMD driver\n");
14025 cmdline_parse_inst_t cmd_ddp_get_info = {
14026 .f = cmd_ddp_info_parsed,
14028 .help_str = "ddp get info <profile_path>",
14030 (void *)&cmd_ddp_info_ddp,
14031 (void *)&cmd_ddp_info_get,
14032 (void *)&cmd_ddp_info_info,
14033 (void *)&cmd_ddp_info_filepath,
14038 /* Get dynamic device personalization profile info list*/
14039 #define PROFILE_INFO_SIZE 48
14040 #define MAX_PROFILE_NUM 16
14042 struct cmd_ddp_get_list_result {
14043 cmdline_fixed_string_t ddp;
14044 cmdline_fixed_string_t get;
14045 cmdline_fixed_string_t list;
14049 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14050 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14051 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14052 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14053 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14054 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14055 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14056 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14060 cmd_ddp_get_list_parsed(
14061 __rte_unused void *parsed_result,
14062 __rte_unused struct cmdline *cl,
14063 __rte_unused void *data)
14065 #ifdef RTE_NET_I40E
14066 struct cmd_ddp_get_list_result *res = parsed_result;
14067 struct rte_pmd_i40e_profile_list *p_list;
14068 struct rte_pmd_i40e_profile_info *p_info;
14073 int ret = -ENOTSUP;
14075 #ifdef RTE_NET_I40E
14076 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14077 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14079 printf("%s: Failed to malloc buffer\n", __func__);
14083 if (ret == -ENOTSUP)
14084 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14085 (uint8_t *)p_list, size);
14088 p_num = p_list->p_count;
14089 printf("Profile number is: %d\n\n", p_num);
14091 for (i = 0; i < p_num; i++) {
14092 p_info = &p_list->p_info[i];
14093 printf("Profile %d:\n", i);
14094 printf("Track id: 0x%x\n", p_info->track_id);
14095 printf("Version: %d.%d.%d.%d\n",
14096 p_info->version.major,
14097 p_info->version.minor,
14098 p_info->version.update,
14099 p_info->version.draft);
14100 printf("Profile name: %s\n\n", p_info->name);
14108 printf("Failed to get ddp list\n");
14111 cmdline_parse_inst_t cmd_ddp_get_list = {
14112 .f = cmd_ddp_get_list_parsed,
14114 .help_str = "ddp get list <port_id>",
14116 (void *)&cmd_ddp_get_list_ddp,
14117 (void *)&cmd_ddp_get_list_get,
14118 (void *)&cmd_ddp_get_list_list,
14119 (void *)&cmd_ddp_get_list_port_id,
14124 /* Configure input set */
14125 struct cmd_cfg_input_set_result {
14126 cmdline_fixed_string_t port;
14127 cmdline_fixed_string_t cfg;
14129 cmdline_fixed_string_t pctype;
14131 cmdline_fixed_string_t inset_type;
14132 cmdline_fixed_string_t opt;
14133 cmdline_fixed_string_t field;
14138 cmd_cfg_input_set_parsed(
14139 __rte_unused void *parsed_result,
14140 __rte_unused struct cmdline *cl,
14141 __rte_unused void *data)
14143 #ifdef RTE_NET_I40E
14144 struct cmd_cfg_input_set_result *res = parsed_result;
14145 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14146 struct rte_pmd_i40e_inset inset;
14148 int ret = -ENOTSUP;
14150 if (!all_ports_stopped()) {
14151 printf("Please stop all ports first\n");
14155 #ifdef RTE_NET_I40E
14156 if (!strcmp(res->inset_type, "hash_inset"))
14157 inset_type = INSET_HASH;
14158 else if (!strcmp(res->inset_type, "fdir_inset"))
14159 inset_type = INSET_FDIR;
14160 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14161 inset_type = INSET_FDIR_FLX;
14162 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14163 &inset, inset_type);
14165 printf("Failed to get input set.\n");
14169 if (!strcmp(res->opt, "get")) {
14170 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14173 printf("Field index %d is enabled.\n", res->field_idx);
14175 printf("Field index %d is disabled.\n", res->field_idx);
14177 } else if (!strcmp(res->opt, "set"))
14178 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14180 else if (!strcmp(res->opt, "clear"))
14181 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14184 printf("Failed to configure input set field.\n");
14188 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14189 &inset, inset_type);
14191 printf("Failed to set input set.\n");
14196 if (ret == -ENOTSUP)
14197 printf("Function not supported\n");
14200 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14201 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14203 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14204 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14206 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14207 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14208 port_id, RTE_UINT16);
14209 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14210 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14212 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14213 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14214 pctype_id, RTE_UINT8);
14215 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14216 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14218 "hash_inset#fdir_inset#fdir_flx_inset");
14219 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14220 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14221 opt, "get#set#clear");
14222 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14223 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14225 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14226 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14227 field_idx, RTE_UINT8);
14229 cmdline_parse_inst_t cmd_cfg_input_set = {
14230 .f = cmd_cfg_input_set_parsed,
14232 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14233 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
14235 (void *)&cmd_cfg_input_set_port,
14236 (void *)&cmd_cfg_input_set_cfg,
14237 (void *)&cmd_cfg_input_set_port_id,
14238 (void *)&cmd_cfg_input_set_pctype,
14239 (void *)&cmd_cfg_input_set_pctype_id,
14240 (void *)&cmd_cfg_input_set_inset_type,
14241 (void *)&cmd_cfg_input_set_opt,
14242 (void *)&cmd_cfg_input_set_field,
14243 (void *)&cmd_cfg_input_set_field_idx,
14248 /* Clear input set */
14249 struct cmd_clear_input_set_result {
14250 cmdline_fixed_string_t port;
14251 cmdline_fixed_string_t cfg;
14253 cmdline_fixed_string_t pctype;
14255 cmdline_fixed_string_t inset_type;
14256 cmdline_fixed_string_t clear;
14257 cmdline_fixed_string_t all;
14261 cmd_clear_input_set_parsed(
14262 __rte_unused void *parsed_result,
14263 __rte_unused struct cmdline *cl,
14264 __rte_unused void *data)
14266 #ifdef RTE_NET_I40E
14267 struct cmd_clear_input_set_result *res = parsed_result;
14268 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14269 struct rte_pmd_i40e_inset inset;
14271 int ret = -ENOTSUP;
14273 if (!all_ports_stopped()) {
14274 printf("Please stop all ports first\n");
14278 #ifdef RTE_NET_I40E
14279 if (!strcmp(res->inset_type, "hash_inset"))
14280 inset_type = INSET_HASH;
14281 else if (!strcmp(res->inset_type, "fdir_inset"))
14282 inset_type = INSET_FDIR;
14283 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14284 inset_type = INSET_FDIR_FLX;
14286 memset(&inset, 0, sizeof(inset));
14288 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14289 &inset, inset_type);
14291 printf("Failed to clear input set.\n");
14297 if (ret == -ENOTSUP)
14298 printf("Function not supported\n");
14301 cmdline_parse_token_string_t cmd_clear_input_set_port =
14302 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14304 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
14305 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14307 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
14308 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14309 port_id, RTE_UINT16);
14310 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
14311 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14313 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
14314 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14315 pctype_id, RTE_UINT8);
14316 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
14317 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14319 "hash_inset#fdir_inset#fdir_flx_inset");
14320 cmdline_parse_token_string_t cmd_clear_input_set_clear =
14321 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14323 cmdline_parse_token_string_t cmd_clear_input_set_all =
14324 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14327 cmdline_parse_inst_t cmd_clear_input_set = {
14328 .f = cmd_clear_input_set_parsed,
14330 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14331 "fdir_inset|fdir_flx_inset clear all",
14333 (void *)&cmd_clear_input_set_port,
14334 (void *)&cmd_clear_input_set_cfg,
14335 (void *)&cmd_clear_input_set_port_id,
14336 (void *)&cmd_clear_input_set_pctype,
14337 (void *)&cmd_clear_input_set_pctype_id,
14338 (void *)&cmd_clear_input_set_inset_type,
14339 (void *)&cmd_clear_input_set_clear,
14340 (void *)&cmd_clear_input_set_all,
14345 /* show vf stats */
14347 /* Common result structure for show vf stats */
14348 struct cmd_show_vf_stats_result {
14349 cmdline_fixed_string_t show;
14350 cmdline_fixed_string_t vf;
14351 cmdline_fixed_string_t stats;
14356 /* Common CLI fields show vf stats*/
14357 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14358 TOKEN_STRING_INITIALIZER
14359 (struct cmd_show_vf_stats_result,
14361 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14362 TOKEN_STRING_INITIALIZER
14363 (struct cmd_show_vf_stats_result,
14365 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14366 TOKEN_STRING_INITIALIZER
14367 (struct cmd_show_vf_stats_result,
14369 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14370 TOKEN_NUM_INITIALIZER
14371 (struct cmd_show_vf_stats_result,
14372 port_id, RTE_UINT16);
14373 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14374 TOKEN_NUM_INITIALIZER
14375 (struct cmd_show_vf_stats_result,
14376 vf_id, RTE_UINT16);
14379 cmd_show_vf_stats_parsed(
14380 void *parsed_result,
14381 __rte_unused struct cmdline *cl,
14382 __rte_unused void *data)
14384 struct cmd_show_vf_stats_result *res = parsed_result;
14385 struct rte_eth_stats stats;
14386 int ret = -ENOTSUP;
14387 static const char *nic_stats_border = "########################";
14389 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14392 memset(&stats, 0, sizeof(stats));
14394 #ifdef RTE_NET_I40E
14395 if (ret == -ENOTSUP)
14396 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14400 #ifdef RTE_NET_BNXT
14401 if (ret == -ENOTSUP)
14402 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14411 printf("invalid vf_id %d\n", res->vf_id);
14414 printf("invalid port_id %d\n", res->port_id);
14417 printf("function not implemented\n");
14420 printf("programming error: (%s)\n", strerror(-ret));
14423 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14424 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14426 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14428 stats.ipackets, stats.imissed, stats.ibytes);
14429 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14430 printf(" RX-nombuf: %-10"PRIu64"\n",
14432 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14434 stats.opackets, stats.oerrors, stats.obytes);
14436 printf(" %s############################%s\n",
14437 nic_stats_border, nic_stats_border);
14440 cmdline_parse_inst_t cmd_show_vf_stats = {
14441 .f = cmd_show_vf_stats_parsed,
14443 .help_str = "show vf stats <port_id> <vf_id>",
14445 (void *)&cmd_show_vf_stats_show,
14446 (void *)&cmd_show_vf_stats_vf,
14447 (void *)&cmd_show_vf_stats_stats,
14448 (void *)&cmd_show_vf_stats_port_id,
14449 (void *)&cmd_show_vf_stats_vf_id,
14454 /* clear vf stats */
14456 /* Common result structure for clear vf stats */
14457 struct cmd_clear_vf_stats_result {
14458 cmdline_fixed_string_t clear;
14459 cmdline_fixed_string_t vf;
14460 cmdline_fixed_string_t stats;
14465 /* Common CLI fields clear vf stats*/
14466 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14467 TOKEN_STRING_INITIALIZER
14468 (struct cmd_clear_vf_stats_result,
14470 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
14471 TOKEN_STRING_INITIALIZER
14472 (struct cmd_clear_vf_stats_result,
14474 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
14475 TOKEN_STRING_INITIALIZER
14476 (struct cmd_clear_vf_stats_result,
14478 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
14479 TOKEN_NUM_INITIALIZER
14480 (struct cmd_clear_vf_stats_result,
14481 port_id, RTE_UINT16);
14482 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
14483 TOKEN_NUM_INITIALIZER
14484 (struct cmd_clear_vf_stats_result,
14485 vf_id, RTE_UINT16);
14488 cmd_clear_vf_stats_parsed(
14489 void *parsed_result,
14490 __rte_unused struct cmdline *cl,
14491 __rte_unused void *data)
14493 struct cmd_clear_vf_stats_result *res = parsed_result;
14494 int ret = -ENOTSUP;
14496 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14499 #ifdef RTE_NET_I40E
14500 if (ret == -ENOTSUP)
14501 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
14504 #ifdef RTE_NET_BNXT
14505 if (ret == -ENOTSUP)
14506 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
14514 printf("invalid vf_id %d\n", res->vf_id);
14517 printf("invalid port_id %d\n", res->port_id);
14520 printf("function not implemented\n");
14523 printf("programming error: (%s)\n", strerror(-ret));
14527 cmdline_parse_inst_t cmd_clear_vf_stats = {
14528 .f = cmd_clear_vf_stats_parsed,
14530 .help_str = "clear vf stats <port_id> <vf_id>",
14532 (void *)&cmd_clear_vf_stats_clear,
14533 (void *)&cmd_clear_vf_stats_vf,
14534 (void *)&cmd_clear_vf_stats_stats,
14535 (void *)&cmd_clear_vf_stats_port_id,
14536 (void *)&cmd_clear_vf_stats_vf_id,
14541 /* port config pctype mapping reset */
14543 /* Common result structure for port config pctype mapping reset */
14544 struct cmd_pctype_mapping_reset_result {
14545 cmdline_fixed_string_t port;
14546 cmdline_fixed_string_t config;
14548 cmdline_fixed_string_t pctype;
14549 cmdline_fixed_string_t mapping;
14550 cmdline_fixed_string_t reset;
14553 /* Common CLI fields for port config pctype mapping reset*/
14554 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
14555 TOKEN_STRING_INITIALIZER
14556 (struct cmd_pctype_mapping_reset_result,
14558 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
14559 TOKEN_STRING_INITIALIZER
14560 (struct cmd_pctype_mapping_reset_result,
14562 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
14563 TOKEN_NUM_INITIALIZER
14564 (struct cmd_pctype_mapping_reset_result,
14565 port_id, RTE_UINT16);
14566 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
14567 TOKEN_STRING_INITIALIZER
14568 (struct cmd_pctype_mapping_reset_result,
14570 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
14571 TOKEN_STRING_INITIALIZER
14572 (struct cmd_pctype_mapping_reset_result,
14573 mapping, "mapping");
14574 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
14575 TOKEN_STRING_INITIALIZER
14576 (struct cmd_pctype_mapping_reset_result,
14580 cmd_pctype_mapping_reset_parsed(
14581 void *parsed_result,
14582 __rte_unused struct cmdline *cl,
14583 __rte_unused void *data)
14585 struct cmd_pctype_mapping_reset_result *res = parsed_result;
14586 int ret = -ENOTSUP;
14588 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14591 #ifdef RTE_NET_I40E
14592 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
14599 printf("invalid port_id %d\n", res->port_id);
14602 printf("function not implemented\n");
14605 printf("programming error: (%s)\n", strerror(-ret));
14609 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
14610 .f = cmd_pctype_mapping_reset_parsed,
14612 .help_str = "port config <port_id> pctype mapping reset",
14614 (void *)&cmd_pctype_mapping_reset_port,
14615 (void *)&cmd_pctype_mapping_reset_config,
14616 (void *)&cmd_pctype_mapping_reset_port_id,
14617 (void *)&cmd_pctype_mapping_reset_pctype,
14618 (void *)&cmd_pctype_mapping_reset_mapping,
14619 (void *)&cmd_pctype_mapping_reset_reset,
14624 /* show port pctype mapping */
14626 /* Common result structure for show port pctype mapping */
14627 struct cmd_pctype_mapping_get_result {
14628 cmdline_fixed_string_t show;
14629 cmdline_fixed_string_t port;
14631 cmdline_fixed_string_t pctype;
14632 cmdline_fixed_string_t mapping;
14635 /* Common CLI fields for pctype mapping get */
14636 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
14637 TOKEN_STRING_INITIALIZER
14638 (struct cmd_pctype_mapping_get_result,
14640 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
14641 TOKEN_STRING_INITIALIZER
14642 (struct cmd_pctype_mapping_get_result,
14644 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
14645 TOKEN_NUM_INITIALIZER
14646 (struct cmd_pctype_mapping_get_result,
14647 port_id, RTE_UINT16);
14648 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
14649 TOKEN_STRING_INITIALIZER
14650 (struct cmd_pctype_mapping_get_result,
14652 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
14653 TOKEN_STRING_INITIALIZER
14654 (struct cmd_pctype_mapping_get_result,
14655 mapping, "mapping");
14658 cmd_pctype_mapping_get_parsed(
14659 void *parsed_result,
14660 __rte_unused struct cmdline *cl,
14661 __rte_unused void *data)
14663 struct cmd_pctype_mapping_get_result *res = parsed_result;
14664 int ret = -ENOTSUP;
14665 #ifdef RTE_NET_I40E
14666 struct rte_pmd_i40e_flow_type_mapping
14667 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
14668 int i, j, first_pctype;
14671 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14674 #ifdef RTE_NET_I40E
14675 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
14682 printf("invalid port_id %d\n", res->port_id);
14685 printf("function not implemented\n");
14688 printf("programming error: (%s)\n", strerror(-ret));
14692 #ifdef RTE_NET_I40E
14693 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
14694 if (mapping[i].pctype != 0ULL) {
14697 printf("pctype: ");
14698 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
14699 if (mapping[i].pctype & (1ULL << j)) {
14700 printf(first_pctype ?
14701 "%02d" : ",%02d", j);
14705 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
14711 cmdline_parse_inst_t cmd_pctype_mapping_get = {
14712 .f = cmd_pctype_mapping_get_parsed,
14714 .help_str = "show port <port_id> pctype mapping",
14716 (void *)&cmd_pctype_mapping_get_show,
14717 (void *)&cmd_pctype_mapping_get_port,
14718 (void *)&cmd_pctype_mapping_get_port_id,
14719 (void *)&cmd_pctype_mapping_get_pctype,
14720 (void *)&cmd_pctype_mapping_get_mapping,
14725 /* port config pctype mapping update */
14727 /* Common result structure for port config pctype mapping update */
14728 struct cmd_pctype_mapping_update_result {
14729 cmdline_fixed_string_t port;
14730 cmdline_fixed_string_t config;
14732 cmdline_fixed_string_t pctype;
14733 cmdline_fixed_string_t mapping;
14734 cmdline_fixed_string_t update;
14735 cmdline_fixed_string_t pctype_list;
14736 uint16_t flow_type;
14739 /* Common CLI fields for pctype mapping update*/
14740 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
14741 TOKEN_STRING_INITIALIZER
14742 (struct cmd_pctype_mapping_update_result,
14744 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
14745 TOKEN_STRING_INITIALIZER
14746 (struct cmd_pctype_mapping_update_result,
14748 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
14749 TOKEN_NUM_INITIALIZER
14750 (struct cmd_pctype_mapping_update_result,
14751 port_id, RTE_UINT16);
14752 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
14753 TOKEN_STRING_INITIALIZER
14754 (struct cmd_pctype_mapping_update_result,
14756 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
14757 TOKEN_STRING_INITIALIZER
14758 (struct cmd_pctype_mapping_update_result,
14759 mapping, "mapping");
14760 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
14761 TOKEN_STRING_INITIALIZER
14762 (struct cmd_pctype_mapping_update_result,
14764 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
14765 TOKEN_STRING_INITIALIZER
14766 (struct cmd_pctype_mapping_update_result,
14767 pctype_list, NULL);
14768 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
14769 TOKEN_NUM_INITIALIZER
14770 (struct cmd_pctype_mapping_update_result,
14771 flow_type, RTE_UINT16);
14774 cmd_pctype_mapping_update_parsed(
14775 void *parsed_result,
14776 __rte_unused struct cmdline *cl,
14777 __rte_unused void *data)
14779 struct cmd_pctype_mapping_update_result *res = parsed_result;
14780 int ret = -ENOTSUP;
14781 #ifdef RTE_NET_I40E
14782 struct rte_pmd_i40e_flow_type_mapping mapping;
14784 unsigned int nb_item;
14785 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
14788 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14791 #ifdef RTE_NET_I40E
14792 nb_item = parse_item_list(res->pctype_list, "pctypes",
14793 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
14794 mapping.flow_type = res->flow_type;
14795 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
14796 mapping.pctype |= (1ULL << pctype_list[i]);
14797 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
14807 printf("invalid pctype or flow type\n");
14810 printf("invalid port_id %d\n", res->port_id);
14813 printf("function not implemented\n");
14816 printf("programming error: (%s)\n", strerror(-ret));
14820 cmdline_parse_inst_t cmd_pctype_mapping_update = {
14821 .f = cmd_pctype_mapping_update_parsed,
14823 .help_str = "port config <port_id> pctype mapping update"
14824 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
14826 (void *)&cmd_pctype_mapping_update_port,
14827 (void *)&cmd_pctype_mapping_update_config,
14828 (void *)&cmd_pctype_mapping_update_port_id,
14829 (void *)&cmd_pctype_mapping_update_pctype,
14830 (void *)&cmd_pctype_mapping_update_mapping,
14831 (void *)&cmd_pctype_mapping_update_update,
14832 (void *)&cmd_pctype_mapping_update_pc_type,
14833 (void *)&cmd_pctype_mapping_update_flow_type,
14838 /* ptype mapping get */
14840 /* Common result structure for ptype mapping get */
14841 struct cmd_ptype_mapping_get_result {
14842 cmdline_fixed_string_t ptype;
14843 cmdline_fixed_string_t mapping;
14844 cmdline_fixed_string_t get;
14846 uint8_t valid_only;
14849 /* Common CLI fields for ptype mapping get */
14850 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
14851 TOKEN_STRING_INITIALIZER
14852 (struct cmd_ptype_mapping_get_result,
14854 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
14855 TOKEN_STRING_INITIALIZER
14856 (struct cmd_ptype_mapping_get_result,
14857 mapping, "mapping");
14858 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
14859 TOKEN_STRING_INITIALIZER
14860 (struct cmd_ptype_mapping_get_result,
14862 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
14863 TOKEN_NUM_INITIALIZER
14864 (struct cmd_ptype_mapping_get_result,
14865 port_id, RTE_UINT16);
14866 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
14867 TOKEN_NUM_INITIALIZER
14868 (struct cmd_ptype_mapping_get_result,
14869 valid_only, RTE_UINT8);
14872 cmd_ptype_mapping_get_parsed(
14873 void *parsed_result,
14874 __rte_unused struct cmdline *cl,
14875 __rte_unused void *data)
14877 struct cmd_ptype_mapping_get_result *res = parsed_result;
14878 int ret = -ENOTSUP;
14879 #ifdef RTE_NET_I40E
14880 int max_ptype_num = 256;
14881 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
14886 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14889 #ifdef RTE_NET_I40E
14890 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
14901 printf("invalid port_id %d\n", res->port_id);
14904 printf("function not implemented\n");
14907 printf("programming error: (%s)\n", strerror(-ret));
14910 #ifdef RTE_NET_I40E
14912 for (i = 0; i < count; i++)
14913 printf("%3d\t0x%08x\n",
14914 mapping[i].hw_ptype, mapping[i].sw_ptype);
14919 cmdline_parse_inst_t cmd_ptype_mapping_get = {
14920 .f = cmd_ptype_mapping_get_parsed,
14922 .help_str = "ptype mapping get <port_id> <valid_only>",
14924 (void *)&cmd_ptype_mapping_get_ptype,
14925 (void *)&cmd_ptype_mapping_get_mapping,
14926 (void *)&cmd_ptype_mapping_get_get,
14927 (void *)&cmd_ptype_mapping_get_port_id,
14928 (void *)&cmd_ptype_mapping_get_valid_only,
14933 /* ptype mapping replace */
14935 /* Common result structure for ptype mapping replace */
14936 struct cmd_ptype_mapping_replace_result {
14937 cmdline_fixed_string_t ptype;
14938 cmdline_fixed_string_t mapping;
14939 cmdline_fixed_string_t replace;
14946 /* Common CLI fields for ptype mapping replace */
14947 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
14948 TOKEN_STRING_INITIALIZER
14949 (struct cmd_ptype_mapping_replace_result,
14951 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
14952 TOKEN_STRING_INITIALIZER
14953 (struct cmd_ptype_mapping_replace_result,
14954 mapping, "mapping");
14955 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
14956 TOKEN_STRING_INITIALIZER
14957 (struct cmd_ptype_mapping_replace_result,
14958 replace, "replace");
14959 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
14960 TOKEN_NUM_INITIALIZER
14961 (struct cmd_ptype_mapping_replace_result,
14962 port_id, RTE_UINT16);
14963 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
14964 TOKEN_NUM_INITIALIZER
14965 (struct cmd_ptype_mapping_replace_result,
14966 target, RTE_UINT32);
14967 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
14968 TOKEN_NUM_INITIALIZER
14969 (struct cmd_ptype_mapping_replace_result,
14971 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
14972 TOKEN_NUM_INITIALIZER
14973 (struct cmd_ptype_mapping_replace_result,
14974 pkt_type, RTE_UINT32);
14977 cmd_ptype_mapping_replace_parsed(
14978 void *parsed_result,
14979 __rte_unused struct cmdline *cl,
14980 __rte_unused void *data)
14982 struct cmd_ptype_mapping_replace_result *res = parsed_result;
14983 int ret = -ENOTSUP;
14985 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14988 #ifdef RTE_NET_I40E
14989 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
14999 printf("invalid ptype 0x%8x or 0x%8x\n",
15000 res->target, res->pkt_type);
15003 printf("invalid port_id %d\n", res->port_id);
15006 printf("function not implemented\n");
15009 printf("programming error: (%s)\n", strerror(-ret));
15013 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15014 .f = cmd_ptype_mapping_replace_parsed,
15017 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15019 (void *)&cmd_ptype_mapping_replace_ptype,
15020 (void *)&cmd_ptype_mapping_replace_mapping,
15021 (void *)&cmd_ptype_mapping_replace_replace,
15022 (void *)&cmd_ptype_mapping_replace_port_id,
15023 (void *)&cmd_ptype_mapping_replace_target,
15024 (void *)&cmd_ptype_mapping_replace_mask,
15025 (void *)&cmd_ptype_mapping_replace_pkt_type,
15030 /* ptype mapping reset */
15032 /* Common result structure for ptype mapping reset */
15033 struct cmd_ptype_mapping_reset_result {
15034 cmdline_fixed_string_t ptype;
15035 cmdline_fixed_string_t mapping;
15036 cmdline_fixed_string_t reset;
15040 /* Common CLI fields for ptype mapping reset*/
15041 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15042 TOKEN_STRING_INITIALIZER
15043 (struct cmd_ptype_mapping_reset_result,
15045 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15046 TOKEN_STRING_INITIALIZER
15047 (struct cmd_ptype_mapping_reset_result,
15048 mapping, "mapping");
15049 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15050 TOKEN_STRING_INITIALIZER
15051 (struct cmd_ptype_mapping_reset_result,
15053 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15054 TOKEN_NUM_INITIALIZER
15055 (struct cmd_ptype_mapping_reset_result,
15056 port_id, RTE_UINT16);
15059 cmd_ptype_mapping_reset_parsed(
15060 void *parsed_result,
15061 __rte_unused struct cmdline *cl,
15062 __rte_unused void *data)
15064 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15065 int ret = -ENOTSUP;
15067 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15070 #ifdef RTE_NET_I40E
15071 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15078 printf("invalid port_id %d\n", res->port_id);
15081 printf("function not implemented\n");
15084 printf("programming error: (%s)\n", strerror(-ret));
15088 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15089 .f = cmd_ptype_mapping_reset_parsed,
15091 .help_str = "ptype mapping reset <port_id>",
15093 (void *)&cmd_ptype_mapping_reset_ptype,
15094 (void *)&cmd_ptype_mapping_reset_mapping,
15095 (void *)&cmd_ptype_mapping_reset_reset,
15096 (void *)&cmd_ptype_mapping_reset_port_id,
15101 /* ptype mapping update */
15103 /* Common result structure for ptype mapping update */
15104 struct cmd_ptype_mapping_update_result {
15105 cmdline_fixed_string_t ptype;
15106 cmdline_fixed_string_t mapping;
15107 cmdline_fixed_string_t reset;
15113 /* Common CLI fields for ptype mapping update*/
15114 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15115 TOKEN_STRING_INITIALIZER
15116 (struct cmd_ptype_mapping_update_result,
15118 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15119 TOKEN_STRING_INITIALIZER
15120 (struct cmd_ptype_mapping_update_result,
15121 mapping, "mapping");
15122 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15123 TOKEN_STRING_INITIALIZER
15124 (struct cmd_ptype_mapping_update_result,
15126 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15127 TOKEN_NUM_INITIALIZER
15128 (struct cmd_ptype_mapping_update_result,
15129 port_id, RTE_UINT16);
15130 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15131 TOKEN_NUM_INITIALIZER
15132 (struct cmd_ptype_mapping_update_result,
15133 hw_ptype, RTE_UINT8);
15134 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15135 TOKEN_NUM_INITIALIZER
15136 (struct cmd_ptype_mapping_update_result,
15137 sw_ptype, RTE_UINT32);
15140 cmd_ptype_mapping_update_parsed(
15141 void *parsed_result,
15142 __rte_unused struct cmdline *cl,
15143 __rte_unused void *data)
15145 struct cmd_ptype_mapping_update_result *res = parsed_result;
15146 int ret = -ENOTSUP;
15147 #ifdef RTE_NET_I40E
15148 struct rte_pmd_i40e_ptype_mapping mapping;
15150 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15153 #ifdef RTE_NET_I40E
15154 mapping.hw_ptype = res->hw_ptype;
15155 mapping.sw_ptype = res->sw_ptype;
15156 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15166 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15169 printf("invalid port_id %d\n", res->port_id);
15172 printf("function not implemented\n");
15175 printf("programming error: (%s)\n", strerror(-ret));
15179 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15180 .f = cmd_ptype_mapping_update_parsed,
15182 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15184 (void *)&cmd_ptype_mapping_update_ptype,
15185 (void *)&cmd_ptype_mapping_update_mapping,
15186 (void *)&cmd_ptype_mapping_update_update,
15187 (void *)&cmd_ptype_mapping_update_port_id,
15188 (void *)&cmd_ptype_mapping_update_hw_ptype,
15189 (void *)&cmd_ptype_mapping_update_sw_ptype,
15194 /* Common result structure for file commands */
15195 struct cmd_cmdfile_result {
15196 cmdline_fixed_string_t load;
15197 cmdline_fixed_string_t filename;
15200 /* Common CLI fields for file commands */
15201 cmdline_parse_token_string_t cmd_load_cmdfile =
15202 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15203 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15204 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15207 cmd_load_from_file_parsed(
15208 void *parsed_result,
15209 __rte_unused struct cmdline *cl,
15210 __rte_unused void *data)
15212 struct cmd_cmdfile_result *res = parsed_result;
15214 cmdline_read_from_file(res->filename);
15217 cmdline_parse_inst_t cmd_load_from_file = {
15218 .f = cmd_load_from_file_parsed,
15220 .help_str = "load <filename>",
15222 (void *)&cmd_load_cmdfile,
15223 (void *)&cmd_load_cmdfile_filename,
15228 /* Get Rx offloads capabilities */
15229 struct cmd_rx_offload_get_capa_result {
15230 cmdline_fixed_string_t show;
15231 cmdline_fixed_string_t port;
15233 cmdline_fixed_string_t rx_offload;
15234 cmdline_fixed_string_t capabilities;
15237 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
15238 TOKEN_STRING_INITIALIZER
15239 (struct cmd_rx_offload_get_capa_result,
15241 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
15242 TOKEN_STRING_INITIALIZER
15243 (struct cmd_rx_offload_get_capa_result,
15245 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
15246 TOKEN_NUM_INITIALIZER
15247 (struct cmd_rx_offload_get_capa_result,
15248 port_id, RTE_UINT16);
15249 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
15250 TOKEN_STRING_INITIALIZER
15251 (struct cmd_rx_offload_get_capa_result,
15252 rx_offload, "rx_offload");
15253 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
15254 TOKEN_STRING_INITIALIZER
15255 (struct cmd_rx_offload_get_capa_result,
15256 capabilities, "capabilities");
15259 print_rx_offloads(uint64_t offloads)
15261 uint64_t single_offload;
15269 begin = __builtin_ctzll(offloads);
15270 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15272 single_offload = 1ULL << begin;
15273 for (bit = begin; bit < end; bit++) {
15274 if (offloads & single_offload)
15276 rte_eth_dev_rx_offload_name(single_offload));
15277 single_offload <<= 1;
15282 cmd_rx_offload_get_capa_parsed(
15283 void *parsed_result,
15284 __rte_unused struct cmdline *cl,
15285 __rte_unused void *data)
15287 struct cmd_rx_offload_get_capa_result *res = parsed_result;
15288 struct rte_eth_dev_info dev_info;
15289 portid_t port_id = res->port_id;
15290 uint64_t queue_offloads;
15291 uint64_t port_offloads;
15294 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15298 queue_offloads = dev_info.rx_queue_offload_capa;
15299 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
15301 printf("Rx Offloading Capabilities of port %d :\n", port_id);
15302 printf(" Per Queue :");
15303 print_rx_offloads(queue_offloads);
15306 printf(" Per Port :");
15307 print_rx_offloads(port_offloads);
15311 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
15312 .f = cmd_rx_offload_get_capa_parsed,
15314 .help_str = "show port <port_id> rx_offload capabilities",
15316 (void *)&cmd_rx_offload_get_capa_show,
15317 (void *)&cmd_rx_offload_get_capa_port,
15318 (void *)&cmd_rx_offload_get_capa_port_id,
15319 (void *)&cmd_rx_offload_get_capa_rx_offload,
15320 (void *)&cmd_rx_offload_get_capa_capabilities,
15325 /* Get Rx offloads configuration */
15326 struct cmd_rx_offload_get_configuration_result {
15327 cmdline_fixed_string_t show;
15328 cmdline_fixed_string_t port;
15330 cmdline_fixed_string_t rx_offload;
15331 cmdline_fixed_string_t configuration;
15334 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
15335 TOKEN_STRING_INITIALIZER
15336 (struct cmd_rx_offload_get_configuration_result,
15338 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
15339 TOKEN_STRING_INITIALIZER
15340 (struct cmd_rx_offload_get_configuration_result,
15342 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
15343 TOKEN_NUM_INITIALIZER
15344 (struct cmd_rx_offload_get_configuration_result,
15345 port_id, RTE_UINT16);
15346 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
15347 TOKEN_STRING_INITIALIZER
15348 (struct cmd_rx_offload_get_configuration_result,
15349 rx_offload, "rx_offload");
15350 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
15351 TOKEN_STRING_INITIALIZER
15352 (struct cmd_rx_offload_get_configuration_result,
15353 configuration, "configuration");
15356 cmd_rx_offload_get_configuration_parsed(
15357 void *parsed_result,
15358 __rte_unused struct cmdline *cl,
15359 __rte_unused void *data)
15361 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
15362 struct rte_eth_dev_info dev_info;
15363 portid_t port_id = res->port_id;
15364 struct rte_port *port = &ports[port_id];
15365 uint64_t port_offloads;
15366 uint64_t queue_offloads;
15367 uint16_t nb_rx_queues;
15371 printf("Rx Offloading Configuration of port %d :\n", port_id);
15373 port_offloads = port->dev_conf.rxmode.offloads;
15375 print_rx_offloads(port_offloads);
15378 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15382 nb_rx_queues = dev_info.nb_rx_queues;
15383 for (q = 0; q < nb_rx_queues; q++) {
15384 queue_offloads = port->rx_conf[q].offloads;
15385 printf(" Queue[%2d] :", q);
15386 print_rx_offloads(queue_offloads);
15392 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
15393 .f = cmd_rx_offload_get_configuration_parsed,
15395 .help_str = "show port <port_id> rx_offload configuration",
15397 (void *)&cmd_rx_offload_get_configuration_show,
15398 (void *)&cmd_rx_offload_get_configuration_port,
15399 (void *)&cmd_rx_offload_get_configuration_port_id,
15400 (void *)&cmd_rx_offload_get_configuration_rx_offload,
15401 (void *)&cmd_rx_offload_get_configuration_configuration,
15406 /* Enable/Disable a per port offloading */
15407 struct cmd_config_per_port_rx_offload_result {
15408 cmdline_fixed_string_t port;
15409 cmdline_fixed_string_t config;
15411 cmdline_fixed_string_t rx_offload;
15412 cmdline_fixed_string_t offload;
15413 cmdline_fixed_string_t on_off;
15416 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
15417 TOKEN_STRING_INITIALIZER
15418 (struct cmd_config_per_port_rx_offload_result,
15420 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
15421 TOKEN_STRING_INITIALIZER
15422 (struct cmd_config_per_port_rx_offload_result,
15424 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
15425 TOKEN_NUM_INITIALIZER
15426 (struct cmd_config_per_port_rx_offload_result,
15427 port_id, RTE_UINT16);
15428 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
15429 TOKEN_STRING_INITIALIZER
15430 (struct cmd_config_per_port_rx_offload_result,
15431 rx_offload, "rx_offload");
15432 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
15433 TOKEN_STRING_INITIALIZER
15434 (struct cmd_config_per_port_rx_offload_result,
15435 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
15436 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
15437 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
15438 "scatter#buffer_split#timestamp#security#"
15439 "keep_crc#rss_hash");
15440 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
15441 TOKEN_STRING_INITIALIZER
15442 (struct cmd_config_per_port_rx_offload_result,
15446 search_rx_offload(const char *name)
15448 uint64_t single_offload;
15449 const char *single_name;
15453 single_offload = 1;
15454 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
15455 single_name = rte_eth_dev_rx_offload_name(single_offload);
15456 if (!strcasecmp(single_name, name)) {
15460 single_offload <<= 1;
15464 return single_offload;
15470 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
15471 __rte_unused struct cmdline *cl,
15472 __rte_unused void *data)
15474 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
15475 portid_t port_id = res->port_id;
15476 struct rte_eth_dev_info dev_info;
15477 struct rte_port *port = &ports[port_id];
15478 uint64_t single_offload;
15479 uint16_t nb_rx_queues;
15483 if (port->port_status != RTE_PORT_STOPPED) {
15484 printf("Error: Can't config offload when Port %d "
15485 "is not stopped\n", port_id);
15489 single_offload = search_rx_offload(res->offload);
15490 if (single_offload == 0) {
15491 printf("Unknown offload name: %s\n", res->offload);
15495 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15499 nb_rx_queues = dev_info.nb_rx_queues;
15500 if (!strcmp(res->on_off, "on")) {
15501 port->dev_conf.rxmode.offloads |= single_offload;
15502 for (q = 0; q < nb_rx_queues; q++)
15503 port->rx_conf[q].offloads |= single_offload;
15505 port->dev_conf.rxmode.offloads &= ~single_offload;
15506 for (q = 0; q < nb_rx_queues; q++)
15507 port->rx_conf[q].offloads &= ~single_offload;
15510 cmd_reconfig_device_queue(port_id, 1, 1);
15513 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
15514 .f = cmd_config_per_port_rx_offload_parsed,
15516 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
15517 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
15518 "macsec_strip|header_split|vlan_filter|vlan_extend|"
15519 "jumbo_frame|scatter|buffer_split|timestamp|security|"
15520 "keep_crc|rss_hash on|off",
15522 (void *)&cmd_config_per_port_rx_offload_result_port,
15523 (void *)&cmd_config_per_port_rx_offload_result_config,
15524 (void *)&cmd_config_per_port_rx_offload_result_port_id,
15525 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
15526 (void *)&cmd_config_per_port_rx_offload_result_offload,
15527 (void *)&cmd_config_per_port_rx_offload_result_on_off,
15532 /* Enable/Disable a per queue offloading */
15533 struct cmd_config_per_queue_rx_offload_result {
15534 cmdline_fixed_string_t port;
15536 cmdline_fixed_string_t rxq;
15538 cmdline_fixed_string_t rx_offload;
15539 cmdline_fixed_string_t offload;
15540 cmdline_fixed_string_t on_off;
15543 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
15544 TOKEN_STRING_INITIALIZER
15545 (struct cmd_config_per_queue_rx_offload_result,
15547 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
15548 TOKEN_NUM_INITIALIZER
15549 (struct cmd_config_per_queue_rx_offload_result,
15550 port_id, RTE_UINT16);
15551 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
15552 TOKEN_STRING_INITIALIZER
15553 (struct cmd_config_per_queue_rx_offload_result,
15555 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
15556 TOKEN_NUM_INITIALIZER
15557 (struct cmd_config_per_queue_rx_offload_result,
15558 queue_id, RTE_UINT16);
15559 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
15560 TOKEN_STRING_INITIALIZER
15561 (struct cmd_config_per_queue_rx_offload_result,
15562 rx_offload, "rx_offload");
15563 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
15564 TOKEN_STRING_INITIALIZER
15565 (struct cmd_config_per_queue_rx_offload_result,
15566 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
15567 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
15568 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
15569 "scatter#buffer_split#timestamp#security#keep_crc");
15570 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
15571 TOKEN_STRING_INITIALIZER
15572 (struct cmd_config_per_queue_rx_offload_result,
15576 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
15577 __rte_unused struct cmdline *cl,
15578 __rte_unused void *data)
15580 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
15581 struct rte_eth_dev_info dev_info;
15582 portid_t port_id = res->port_id;
15583 uint16_t queue_id = res->queue_id;
15584 struct rte_port *port = &ports[port_id];
15585 uint64_t single_offload;
15588 if (port->port_status != RTE_PORT_STOPPED) {
15589 printf("Error: Can't config offload when Port %d "
15590 "is not stopped\n", port_id);
15594 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15598 if (queue_id >= dev_info.nb_rx_queues) {
15599 printf("Error: input queue_id should be 0 ... "
15600 "%d\n", dev_info.nb_rx_queues - 1);
15604 single_offload = search_rx_offload(res->offload);
15605 if (single_offload == 0) {
15606 printf("Unknown offload name: %s\n", res->offload);
15610 if (!strcmp(res->on_off, "on"))
15611 port->rx_conf[queue_id].offloads |= single_offload;
15613 port->rx_conf[queue_id].offloads &= ~single_offload;
15615 cmd_reconfig_device_queue(port_id, 1, 1);
15618 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
15619 .f = cmd_config_per_queue_rx_offload_parsed,
15621 .help_str = "port <port_id> rxq <queue_id> rx_offload "
15622 "vlan_strip|ipv4_cksum|"
15623 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
15624 "macsec_strip|header_split|vlan_filter|vlan_extend|"
15625 "jumbo_frame|scatter|buffer_split|timestamp|security|"
15628 (void *)&cmd_config_per_queue_rx_offload_result_port,
15629 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
15630 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
15631 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
15632 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
15633 (void *)&cmd_config_per_queue_rx_offload_result_offload,
15634 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
15639 /* Get Tx offloads capabilities */
15640 struct cmd_tx_offload_get_capa_result {
15641 cmdline_fixed_string_t show;
15642 cmdline_fixed_string_t port;
15644 cmdline_fixed_string_t tx_offload;
15645 cmdline_fixed_string_t capabilities;
15648 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
15649 TOKEN_STRING_INITIALIZER
15650 (struct cmd_tx_offload_get_capa_result,
15652 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
15653 TOKEN_STRING_INITIALIZER
15654 (struct cmd_tx_offload_get_capa_result,
15656 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
15657 TOKEN_NUM_INITIALIZER
15658 (struct cmd_tx_offload_get_capa_result,
15659 port_id, RTE_UINT16);
15660 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
15661 TOKEN_STRING_INITIALIZER
15662 (struct cmd_tx_offload_get_capa_result,
15663 tx_offload, "tx_offload");
15664 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
15665 TOKEN_STRING_INITIALIZER
15666 (struct cmd_tx_offload_get_capa_result,
15667 capabilities, "capabilities");
15670 print_tx_offloads(uint64_t offloads)
15672 uint64_t single_offload;
15680 begin = __builtin_ctzll(offloads);
15681 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15683 single_offload = 1ULL << begin;
15684 for (bit = begin; bit < end; bit++) {
15685 if (offloads & single_offload)
15687 rte_eth_dev_tx_offload_name(single_offload));
15688 single_offload <<= 1;
15693 cmd_tx_offload_get_capa_parsed(
15694 void *parsed_result,
15695 __rte_unused struct cmdline *cl,
15696 __rte_unused void *data)
15698 struct cmd_tx_offload_get_capa_result *res = parsed_result;
15699 struct rte_eth_dev_info dev_info;
15700 portid_t port_id = res->port_id;
15701 uint64_t queue_offloads;
15702 uint64_t port_offloads;
15705 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15709 queue_offloads = dev_info.tx_queue_offload_capa;
15710 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
15712 printf("Tx Offloading Capabilities of port %d :\n", port_id);
15713 printf(" Per Queue :");
15714 print_tx_offloads(queue_offloads);
15717 printf(" Per Port :");
15718 print_tx_offloads(port_offloads);
15722 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
15723 .f = cmd_tx_offload_get_capa_parsed,
15725 .help_str = "show port <port_id> tx_offload capabilities",
15727 (void *)&cmd_tx_offload_get_capa_show,
15728 (void *)&cmd_tx_offload_get_capa_port,
15729 (void *)&cmd_tx_offload_get_capa_port_id,
15730 (void *)&cmd_tx_offload_get_capa_tx_offload,
15731 (void *)&cmd_tx_offload_get_capa_capabilities,
15736 /* Get Tx offloads configuration */
15737 struct cmd_tx_offload_get_configuration_result {
15738 cmdline_fixed_string_t show;
15739 cmdline_fixed_string_t port;
15741 cmdline_fixed_string_t tx_offload;
15742 cmdline_fixed_string_t configuration;
15745 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
15746 TOKEN_STRING_INITIALIZER
15747 (struct cmd_tx_offload_get_configuration_result,
15749 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
15750 TOKEN_STRING_INITIALIZER
15751 (struct cmd_tx_offload_get_configuration_result,
15753 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
15754 TOKEN_NUM_INITIALIZER
15755 (struct cmd_tx_offload_get_configuration_result,
15756 port_id, RTE_UINT16);
15757 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
15758 TOKEN_STRING_INITIALIZER
15759 (struct cmd_tx_offload_get_configuration_result,
15760 tx_offload, "tx_offload");
15761 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
15762 TOKEN_STRING_INITIALIZER
15763 (struct cmd_tx_offload_get_configuration_result,
15764 configuration, "configuration");
15767 cmd_tx_offload_get_configuration_parsed(
15768 void *parsed_result,
15769 __rte_unused struct cmdline *cl,
15770 __rte_unused void *data)
15772 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
15773 struct rte_eth_dev_info dev_info;
15774 portid_t port_id = res->port_id;
15775 struct rte_port *port = &ports[port_id];
15776 uint64_t port_offloads;
15777 uint64_t queue_offloads;
15778 uint16_t nb_tx_queues;
15782 printf("Tx Offloading Configuration of port %d :\n", port_id);
15784 port_offloads = port->dev_conf.txmode.offloads;
15786 print_tx_offloads(port_offloads);
15789 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15793 nb_tx_queues = dev_info.nb_tx_queues;
15794 for (q = 0; q < nb_tx_queues; q++) {
15795 queue_offloads = port->tx_conf[q].offloads;
15796 printf(" Queue[%2d] :", q);
15797 print_tx_offloads(queue_offloads);
15803 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
15804 .f = cmd_tx_offload_get_configuration_parsed,
15806 .help_str = "show port <port_id> tx_offload configuration",
15808 (void *)&cmd_tx_offload_get_configuration_show,
15809 (void *)&cmd_tx_offload_get_configuration_port,
15810 (void *)&cmd_tx_offload_get_configuration_port_id,
15811 (void *)&cmd_tx_offload_get_configuration_tx_offload,
15812 (void *)&cmd_tx_offload_get_configuration_configuration,
15817 /* Enable/Disable a per port offloading */
15818 struct cmd_config_per_port_tx_offload_result {
15819 cmdline_fixed_string_t port;
15820 cmdline_fixed_string_t config;
15822 cmdline_fixed_string_t tx_offload;
15823 cmdline_fixed_string_t offload;
15824 cmdline_fixed_string_t on_off;
15827 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
15828 TOKEN_STRING_INITIALIZER
15829 (struct cmd_config_per_port_tx_offload_result,
15831 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
15832 TOKEN_STRING_INITIALIZER
15833 (struct cmd_config_per_port_tx_offload_result,
15835 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
15836 TOKEN_NUM_INITIALIZER
15837 (struct cmd_config_per_port_tx_offload_result,
15838 port_id, RTE_UINT16);
15839 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
15840 TOKEN_STRING_INITIALIZER
15841 (struct cmd_config_per_port_tx_offload_result,
15842 tx_offload, "tx_offload");
15843 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
15844 TOKEN_STRING_INITIALIZER
15845 (struct cmd_config_per_port_tx_offload_result,
15846 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
15847 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
15848 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
15849 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
15850 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
15851 "send_on_timestamp");
15852 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
15853 TOKEN_STRING_INITIALIZER
15854 (struct cmd_config_per_port_tx_offload_result,
15858 search_tx_offload(const char *name)
15860 uint64_t single_offload;
15861 const char *single_name;
15865 single_offload = 1;
15866 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
15867 single_name = rte_eth_dev_tx_offload_name(single_offload);
15868 if (single_name == NULL)
15870 if (!strcasecmp(single_name, name)) {
15873 } else if (!strcasecmp(single_name, "UNKNOWN"))
15875 single_offload <<= 1;
15879 return single_offload;
15885 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
15886 __rte_unused struct cmdline *cl,
15887 __rte_unused void *data)
15889 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
15890 portid_t port_id = res->port_id;
15891 struct rte_eth_dev_info dev_info;
15892 struct rte_port *port = &ports[port_id];
15893 uint64_t single_offload;
15894 uint16_t nb_tx_queues;
15898 if (port->port_status != RTE_PORT_STOPPED) {
15899 printf("Error: Can't config offload when Port %d "
15900 "is not stopped\n", port_id);
15904 single_offload = search_tx_offload(res->offload);
15905 if (single_offload == 0) {
15906 printf("Unknown offload name: %s\n", res->offload);
15910 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15914 nb_tx_queues = dev_info.nb_tx_queues;
15915 if (!strcmp(res->on_off, "on")) {
15916 port->dev_conf.txmode.offloads |= single_offload;
15917 for (q = 0; q < nb_tx_queues; q++)
15918 port->tx_conf[q].offloads |= single_offload;
15920 port->dev_conf.txmode.offloads &= ~single_offload;
15921 for (q = 0; q < nb_tx_queues; q++)
15922 port->tx_conf[q].offloads &= ~single_offload;
15925 cmd_reconfig_device_queue(port_id, 1, 1);
15928 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
15929 .f = cmd_config_per_port_tx_offload_parsed,
15931 .help_str = "port config <port_id> tx_offload "
15932 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
15933 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
15934 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
15935 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
15936 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
15937 "send_on_timestamp on|off",
15939 (void *)&cmd_config_per_port_tx_offload_result_port,
15940 (void *)&cmd_config_per_port_tx_offload_result_config,
15941 (void *)&cmd_config_per_port_tx_offload_result_port_id,
15942 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
15943 (void *)&cmd_config_per_port_tx_offload_result_offload,
15944 (void *)&cmd_config_per_port_tx_offload_result_on_off,
15949 /* Enable/Disable a per queue offloading */
15950 struct cmd_config_per_queue_tx_offload_result {
15951 cmdline_fixed_string_t port;
15953 cmdline_fixed_string_t txq;
15955 cmdline_fixed_string_t tx_offload;
15956 cmdline_fixed_string_t offload;
15957 cmdline_fixed_string_t on_off;
15960 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
15961 TOKEN_STRING_INITIALIZER
15962 (struct cmd_config_per_queue_tx_offload_result,
15964 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
15965 TOKEN_NUM_INITIALIZER
15966 (struct cmd_config_per_queue_tx_offload_result,
15967 port_id, RTE_UINT16);
15968 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
15969 TOKEN_STRING_INITIALIZER
15970 (struct cmd_config_per_queue_tx_offload_result,
15972 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
15973 TOKEN_NUM_INITIALIZER
15974 (struct cmd_config_per_queue_tx_offload_result,
15975 queue_id, RTE_UINT16);
15976 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
15977 TOKEN_STRING_INITIALIZER
15978 (struct cmd_config_per_queue_tx_offload_result,
15979 tx_offload, "tx_offload");
15980 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
15981 TOKEN_STRING_INITIALIZER
15982 (struct cmd_config_per_queue_tx_offload_result,
15983 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
15984 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
15985 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
15986 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
15987 "mt_lockfree#multi_segs#mbuf_fast_free#security");
15988 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
15989 TOKEN_STRING_INITIALIZER
15990 (struct cmd_config_per_queue_tx_offload_result,
15994 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
15995 __rte_unused struct cmdline *cl,
15996 __rte_unused void *data)
15998 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
15999 struct rte_eth_dev_info dev_info;
16000 portid_t port_id = res->port_id;
16001 uint16_t queue_id = res->queue_id;
16002 struct rte_port *port = &ports[port_id];
16003 uint64_t single_offload;
16006 if (port->port_status != RTE_PORT_STOPPED) {
16007 printf("Error: Can't config offload when Port %d "
16008 "is not stopped\n", port_id);
16012 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16016 if (queue_id >= dev_info.nb_tx_queues) {
16017 printf("Error: input queue_id should be 0 ... "
16018 "%d\n", dev_info.nb_tx_queues - 1);
16022 single_offload = search_tx_offload(res->offload);
16023 if (single_offload == 0) {
16024 printf("Unknown offload name: %s\n", res->offload);
16028 if (!strcmp(res->on_off, "on"))
16029 port->tx_conf[queue_id].offloads |= single_offload;
16031 port->tx_conf[queue_id].offloads &= ~single_offload;
16033 cmd_reconfig_device_queue(port_id, 1, 1);
16036 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16037 .f = cmd_config_per_queue_tx_offload_parsed,
16039 .help_str = "port <port_id> txq <queue_id> tx_offload "
16040 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16041 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16042 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16043 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16044 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16047 (void *)&cmd_config_per_queue_tx_offload_result_port,
16048 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16049 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16050 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16051 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16052 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16053 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16058 /* *** configure tx_metadata for specific port *** */
16059 struct cmd_config_tx_metadata_specific_result {
16060 cmdline_fixed_string_t port;
16061 cmdline_fixed_string_t keyword;
16063 cmdline_fixed_string_t item;
16068 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16069 __rte_unused struct cmdline *cl,
16070 __rte_unused void *data)
16072 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16074 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16076 ports[res->port_id].tx_metadata = res->value;
16077 /* Add/remove callback to insert valid metadata in every Tx packet. */
16078 if (ports[res->port_id].tx_metadata)
16079 add_tx_md_callback(res->port_id);
16081 remove_tx_md_callback(res->port_id);
16082 rte_flow_dynf_metadata_register();
16085 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16086 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16088 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16089 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16090 keyword, "config");
16091 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16092 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16093 port_id, RTE_UINT16);
16094 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16095 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16096 item, "tx_metadata");
16097 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16098 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16099 value, RTE_UINT32);
16101 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16102 .f = cmd_config_tx_metadata_specific_parsed,
16104 .help_str = "port config <port_id> tx_metadata <value>",
16106 (void *)&cmd_config_tx_metadata_specific_port,
16107 (void *)&cmd_config_tx_metadata_specific_keyword,
16108 (void *)&cmd_config_tx_metadata_specific_id,
16109 (void *)&cmd_config_tx_metadata_specific_item,
16110 (void *)&cmd_config_tx_metadata_specific_value,
16115 /* *** set dynf *** */
16116 struct cmd_config_tx_dynf_specific_result {
16117 cmdline_fixed_string_t port;
16118 cmdline_fixed_string_t keyword;
16120 cmdline_fixed_string_t item;
16121 cmdline_fixed_string_t name;
16122 cmdline_fixed_string_t value;
16126 cmd_config_dynf_specific_parsed(void *parsed_result,
16127 __rte_unused struct cmdline *cl,
16128 __rte_unused void *data)
16130 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16131 struct rte_mbuf_dynflag desc_flag;
16133 uint64_t old_port_flags;
16135 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16137 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16139 if (strlcpy(desc_flag.name, res->name,
16140 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16141 printf("Flag name too long\n");
16144 desc_flag.flags = 0;
16145 flag = rte_mbuf_dynflag_register(&desc_flag);
16147 printf("Can't register flag\n");
16150 strcpy(dynf_names[flag], desc_flag.name);
16152 old_port_flags = ports[res->port_id].mbuf_dynf;
16153 if (!strcmp(res->value, "set")) {
16154 ports[res->port_id].mbuf_dynf |= 1UL << flag;
16155 if (old_port_flags == 0)
16156 add_tx_dynf_callback(res->port_id);
16158 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16159 if (ports[res->port_id].mbuf_dynf == 0)
16160 remove_tx_dynf_callback(res->port_id);
16164 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16165 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16167 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16168 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16169 keyword, "config");
16170 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
16171 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16172 port_id, RTE_UINT16);
16173 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
16174 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16176 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
16177 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16179 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
16180 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16181 value, "set#clear");
16183 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
16184 .f = cmd_config_dynf_specific_parsed,
16186 .help_str = "port config <port id> dynf <name> set|clear",
16188 (void *)&cmd_config_tx_dynf_specific_port,
16189 (void *)&cmd_config_tx_dynf_specific_keyword,
16190 (void *)&cmd_config_tx_dynf_specific_port_id,
16191 (void *)&cmd_config_tx_dynf_specific_item,
16192 (void *)&cmd_config_tx_dynf_specific_name,
16193 (void *)&cmd_config_tx_dynf_specific_value,
16198 /* *** display tx_metadata per port configuration *** */
16199 struct cmd_show_tx_metadata_result {
16200 cmdline_fixed_string_t cmd_show;
16201 cmdline_fixed_string_t cmd_port;
16202 cmdline_fixed_string_t cmd_keyword;
16207 cmd_show_tx_metadata_parsed(void *parsed_result,
16208 __rte_unused struct cmdline *cl,
16209 __rte_unused void *data)
16211 struct cmd_show_tx_metadata_result *res = parsed_result;
16213 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16214 printf("invalid port id %u\n", res->cmd_pid);
16217 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
16218 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
16219 ports[res->cmd_pid].tx_metadata);
16223 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
16224 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16226 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
16227 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16229 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
16230 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
16231 cmd_pid, RTE_UINT16);
16232 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
16233 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16234 cmd_keyword, "tx_metadata");
16236 cmdline_parse_inst_t cmd_show_tx_metadata = {
16237 .f = cmd_show_tx_metadata_parsed,
16239 .help_str = "show port <port_id> tx_metadata",
16241 (void *)&cmd_show_tx_metadata_show,
16242 (void *)&cmd_show_tx_metadata_port,
16243 (void *)&cmd_show_tx_metadata_pid,
16244 (void *)&cmd_show_tx_metadata_keyword,
16249 /* *** show fec capability per port configuration *** */
16250 struct cmd_show_fec_capability_result {
16251 cmdline_fixed_string_t cmd_show;
16252 cmdline_fixed_string_t cmd_port;
16253 cmdline_fixed_string_t cmd_fec;
16254 cmdline_fixed_string_t cmd_keyword;
16259 cmd_show_fec_capability_parsed(void *parsed_result,
16260 __rte_unused struct cmdline *cl,
16261 __rte_unused void *data)
16263 struct cmd_show_fec_capability_result *res = parsed_result;
16264 struct rte_eth_fec_capa *speed_fec_capa;
16268 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16269 printf("Invalid port id %u\n", res->cmd_pid);
16273 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
16274 if (ret == -ENOTSUP) {
16275 printf("Function not implemented\n");
16277 } else if (ret < 0) {
16278 printf("Get FEC capability failed: %d\n", ret);
16282 num = (unsigned int)ret;
16283 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
16284 if (speed_fec_capa == NULL) {
16285 printf("Failed to alloc FEC capability buffer\n");
16289 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
16291 printf("Error getting FEC capability: %d\n", ret);
16295 show_fec_capability(num, speed_fec_capa);
16297 free(speed_fec_capa);
16300 cmdline_parse_token_string_t cmd_show_fec_capability_show =
16301 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16303 cmdline_parse_token_string_t cmd_show_fec_capability_port =
16304 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16306 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
16307 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
16308 cmd_pid, RTE_UINT16);
16309 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
16310 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16312 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
16313 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16314 cmd_keyword, "capabilities");
16316 cmdline_parse_inst_t cmd_show_capability = {
16317 .f = cmd_show_fec_capability_parsed,
16319 .help_str = "show port <port_id> fec capabilities",
16321 (void *)&cmd_show_fec_capability_show,
16322 (void *)&cmd_show_fec_capability_port,
16323 (void *)&cmd_show_fec_capability_pid,
16324 (void *)&cmd_show_fec_capability_fec,
16325 (void *)&cmd_show_fec_capability_keyword,
16330 /* *** show fec mode per port configuration *** */
16331 struct cmd_show_fec_metadata_result {
16332 cmdline_fixed_string_t cmd_show;
16333 cmdline_fixed_string_t cmd_port;
16334 cmdline_fixed_string_t cmd_keyword;
16339 cmd_show_fec_mode_parsed(void *parsed_result,
16340 __rte_unused struct cmdline *cl,
16341 __rte_unused void *data)
16343 #define FEC_NAME_SIZE 16
16344 struct cmd_show_fec_metadata_result *res = parsed_result;
16346 char buf[FEC_NAME_SIZE];
16349 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16350 printf("Invalid port id %u\n", res->cmd_pid);
16353 ret = rte_eth_fec_get(res->cmd_pid, &mode);
16354 if (ret == -ENOTSUP) {
16355 printf("Function not implemented\n");
16357 } else if (ret < 0) {
16358 printf("Get FEC mode failed\n");
16363 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
16364 strlcpy(buf, "off", sizeof(buf));
16366 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
16367 strlcpy(buf, "auto", sizeof(buf));
16369 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
16370 strlcpy(buf, "baser", sizeof(buf));
16372 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
16373 strlcpy(buf, "rs", sizeof(buf));
16379 printf("%s\n", buf);
16382 cmdline_parse_token_string_t cmd_show_fec_mode_show =
16383 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16385 cmdline_parse_token_string_t cmd_show_fec_mode_port =
16386 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16388 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
16389 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
16390 cmd_pid, RTE_UINT16);
16391 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
16392 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16393 cmd_keyword, "fec_mode");
16395 cmdline_parse_inst_t cmd_show_fec_mode = {
16396 .f = cmd_show_fec_mode_parsed,
16398 .help_str = "show port <port_id> fec_mode",
16400 (void *)&cmd_show_fec_mode_show,
16401 (void *)&cmd_show_fec_mode_port,
16402 (void *)&cmd_show_fec_mode_pid,
16403 (void *)&cmd_show_fec_mode_keyword,
16408 /* *** set fec mode per port configuration *** */
16409 struct cmd_set_port_fec_mode {
16410 cmdline_fixed_string_t set;
16411 cmdline_fixed_string_t port;
16413 cmdline_fixed_string_t fec_mode;
16414 cmdline_fixed_string_t fec_value;
16417 /* Common CLI fields for set fec mode */
16418 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
16419 TOKEN_STRING_INITIALIZER
16420 (struct cmd_set_port_fec_mode,
16422 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
16423 TOKEN_STRING_INITIALIZER
16424 (struct cmd_set_port_fec_mode,
16426 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
16427 TOKEN_NUM_INITIALIZER
16428 (struct cmd_set_port_fec_mode,
16429 port_id, RTE_UINT16);
16430 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
16431 TOKEN_STRING_INITIALIZER
16432 (struct cmd_set_port_fec_mode,
16433 fec_mode, "fec_mode");
16434 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
16435 TOKEN_STRING_INITIALIZER
16436 (struct cmd_set_port_fec_mode,
16440 cmd_set_port_fec_mode_parsed(
16441 void *parsed_result,
16442 __rte_unused struct cmdline *cl,
16443 __rte_unused void *data)
16445 struct cmd_set_port_fec_mode *res = parsed_result;
16446 uint16_t port_id = res->port_id;
16450 ret = parse_fec_mode(res->fec_value, &mode);
16452 printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
16457 ret = rte_eth_fec_set(port_id, mode);
16458 if (ret == -ENOTSUP) {
16459 printf("Function not implemented\n");
16461 } else if (ret < 0) {
16462 printf("Set FEC mode failed\n");
16467 cmdline_parse_inst_t cmd_set_fec_mode = {
16468 .f = cmd_set_port_fec_mode_parsed,
16470 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
16472 (void *)&cmd_set_port_fec_mode_set,
16473 (void *)&cmd_set_port_fec_mode_port,
16474 (void *)&cmd_set_port_fec_mode_port_id,
16475 (void *)&cmd_set_port_fec_mode_str,
16476 (void *)&cmd_set_port_fec_mode_value,
16481 /* show port supported ptypes */
16483 /* Common result structure for show port ptypes */
16484 struct cmd_show_port_supported_ptypes_result {
16485 cmdline_fixed_string_t show;
16486 cmdline_fixed_string_t port;
16488 cmdline_fixed_string_t ptypes;
16491 /* Common CLI fields for show port ptypes */
16492 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
16493 TOKEN_STRING_INITIALIZER
16494 (struct cmd_show_port_supported_ptypes_result,
16496 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
16497 TOKEN_STRING_INITIALIZER
16498 (struct cmd_show_port_supported_ptypes_result,
16500 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
16501 TOKEN_NUM_INITIALIZER
16502 (struct cmd_show_port_supported_ptypes_result,
16503 port_id, RTE_UINT16);
16504 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
16505 TOKEN_STRING_INITIALIZER
16506 (struct cmd_show_port_supported_ptypes_result,
16510 cmd_show_port_supported_ptypes_parsed(
16511 void *parsed_result,
16512 __rte_unused struct cmdline *cl,
16513 __rte_unused void *data)
16515 #define RSVD_PTYPE_MASK 0xf0000000
16516 #define MAX_PTYPES_PER_LAYER 16
16517 #define LTYPE_NAMESIZE 32
16518 #define PTYPE_NAMESIZE 256
16519 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
16520 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
16521 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
16522 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
16523 uint16_t port_id = res->port_id;
16526 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
16530 while (ptype_mask != RSVD_PTYPE_MASK) {
16532 switch (ptype_mask) {
16533 case RTE_PTYPE_L2_MASK:
16534 strlcpy(ltype, "L2", sizeof(ltype));
16536 case RTE_PTYPE_L3_MASK:
16537 strlcpy(ltype, "L3", sizeof(ltype));
16539 case RTE_PTYPE_L4_MASK:
16540 strlcpy(ltype, "L4", sizeof(ltype));
16542 case RTE_PTYPE_TUNNEL_MASK:
16543 strlcpy(ltype, "Tunnel", sizeof(ltype));
16545 case RTE_PTYPE_INNER_L2_MASK:
16546 strlcpy(ltype, "Inner L2", sizeof(ltype));
16548 case RTE_PTYPE_INNER_L3_MASK:
16549 strlcpy(ltype, "Inner L3", sizeof(ltype));
16551 case RTE_PTYPE_INNER_L4_MASK:
16552 strlcpy(ltype, "Inner L4", sizeof(ltype));
16558 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
16559 ptype_mask, ptypes,
16560 MAX_PTYPES_PER_LAYER);
16563 printf("Supported %s ptypes:\n", ltype);
16565 printf("%s ptypes unsupported\n", ltype);
16567 for (i = 0; i < ret; ++i) {
16568 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
16569 printf("%s\n", buf);
16576 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
16577 .f = cmd_show_port_supported_ptypes_parsed,
16579 .help_str = "show port <port_id> ptypes",
16581 (void *)&cmd_show_port_supported_ptypes_show,
16582 (void *)&cmd_show_port_supported_ptypes_port,
16583 (void *)&cmd_show_port_supported_ptypes_port_id,
16584 (void *)&cmd_show_port_supported_ptypes_ptypes,
16589 /* *** display rx/tx descriptor status *** */
16590 struct cmd_show_rx_tx_desc_status_result {
16591 cmdline_fixed_string_t cmd_show;
16592 cmdline_fixed_string_t cmd_port;
16593 cmdline_fixed_string_t cmd_keyword;
16594 cmdline_fixed_string_t cmd_desc;
16595 cmdline_fixed_string_t cmd_status;
16602 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
16603 __rte_unused struct cmdline *cl,
16604 __rte_unused void *data)
16606 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
16609 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16610 printf("invalid port id %u\n", res->cmd_pid);
16614 if (!strcmp(res->cmd_keyword, "rxq")) {
16615 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
16618 printf("Invalid queueid = %d\n", res->cmd_qid);
16621 if (rc == RTE_ETH_RX_DESC_AVAIL)
16622 printf("Desc status = AVAILABLE\n");
16623 else if (rc == RTE_ETH_RX_DESC_DONE)
16624 printf("Desc status = DONE\n");
16626 printf("Desc status = UNAVAILABLE\n");
16627 } else if (!strcmp(res->cmd_keyword, "txq")) {
16628 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
16631 printf("Invalid queueid = %d\n", res->cmd_qid);
16634 if (rc == RTE_ETH_TX_DESC_FULL)
16635 printf("Desc status = FULL\n");
16636 else if (rc == RTE_ETH_TX_DESC_DONE)
16637 printf("Desc status = DONE\n");
16639 printf("Desc status = UNAVAILABLE\n");
16643 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
16644 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16646 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
16647 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16649 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
16650 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16651 cmd_pid, RTE_UINT16);
16652 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
16653 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16654 cmd_keyword, "rxq#txq");
16655 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
16656 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16657 cmd_qid, RTE_UINT16);
16658 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
16659 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16661 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
16662 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16663 cmd_did, RTE_UINT16);
16664 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
16665 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16666 cmd_status, "status");
16667 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
16668 .f = cmd_show_rx_tx_desc_status_parsed,
16670 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
16673 (void *)&cmd_show_rx_tx_desc_status_show,
16674 (void *)&cmd_show_rx_tx_desc_status_port,
16675 (void *)&cmd_show_rx_tx_desc_status_pid,
16676 (void *)&cmd_show_rx_tx_desc_status_keyword,
16677 (void *)&cmd_show_rx_tx_desc_status_qid,
16678 (void *)&cmd_show_rx_tx_desc_status_desc,
16679 (void *)&cmd_show_rx_tx_desc_status_did,
16680 (void *)&cmd_show_rx_tx_desc_status_status,
16685 /* Common result structure for set port ptypes */
16686 struct cmd_set_port_ptypes_result {
16687 cmdline_fixed_string_t set;
16688 cmdline_fixed_string_t port;
16690 cmdline_fixed_string_t ptype_mask;
16694 /* Common CLI fields for set port ptypes */
16695 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
16696 TOKEN_STRING_INITIALIZER
16697 (struct cmd_set_port_ptypes_result,
16699 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
16700 TOKEN_STRING_INITIALIZER
16701 (struct cmd_set_port_ptypes_result,
16703 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
16704 TOKEN_NUM_INITIALIZER
16705 (struct cmd_set_port_ptypes_result,
16706 port_id, RTE_UINT16);
16707 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
16708 TOKEN_STRING_INITIALIZER
16709 (struct cmd_set_port_ptypes_result,
16710 ptype_mask, "ptype_mask");
16711 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
16712 TOKEN_NUM_INITIALIZER
16713 (struct cmd_set_port_ptypes_result,
16717 cmd_set_port_ptypes_parsed(
16718 void *parsed_result,
16719 __rte_unused struct cmdline *cl,
16720 __rte_unused void *data)
16722 struct cmd_set_port_ptypes_result *res = parsed_result;
16723 #define PTYPE_NAMESIZE 256
16724 char ptype_name[PTYPE_NAMESIZE];
16725 uint16_t port_id = res->port_id;
16726 uint32_t ptype_mask = res->mask;
16729 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
16732 printf("Port %d doesn't support any ptypes.\n", port_id);
16736 uint32_t ptypes[ret];
16738 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
16740 printf("Unable to set requested ptypes for Port %d\n", port_id);
16744 printf("Successfully set following ptypes for Port %d\n", port_id);
16745 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
16746 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
16747 printf("%s\n", ptype_name);
16750 clear_ptypes = false;
16753 cmdline_parse_inst_t cmd_set_port_ptypes = {
16754 .f = cmd_set_port_ptypes_parsed,
16756 .help_str = "set port <port_id> ptype_mask <mask>",
16758 (void *)&cmd_set_port_ptypes_set,
16759 (void *)&cmd_set_port_ptypes_port,
16760 (void *)&cmd_set_port_ptypes_port_id,
16761 (void *)&cmd_set_port_ptypes_mask_str,
16762 (void *)&cmd_set_port_ptypes_mask_u32,
16767 /* *** display mac addresses added to a port *** */
16768 struct cmd_showport_macs_result {
16769 cmdline_fixed_string_t cmd_show;
16770 cmdline_fixed_string_t cmd_port;
16771 cmdline_fixed_string_t cmd_keyword;
16776 cmd_showport_macs_parsed(void *parsed_result,
16777 __rte_unused struct cmdline *cl,
16778 __rte_unused void *data)
16780 struct cmd_showport_macs_result *res = parsed_result;
16782 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
16785 if (!strcmp(res->cmd_keyword, "macs"))
16786 show_macs(res->cmd_pid);
16787 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
16788 show_mcast_macs(res->cmd_pid);
16791 cmdline_parse_token_string_t cmd_showport_macs_show =
16792 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
16794 cmdline_parse_token_string_t cmd_showport_macs_port =
16795 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
16797 cmdline_parse_token_num_t cmd_showport_macs_pid =
16798 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
16799 cmd_pid, RTE_UINT16);
16800 cmdline_parse_token_string_t cmd_showport_macs_keyword =
16801 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
16802 cmd_keyword, "macs#mcast_macs");
16804 cmdline_parse_inst_t cmd_showport_macs = {
16805 .f = cmd_showport_macs_parsed,
16807 .help_str = "show port <port_id> macs|mcast_macs",
16809 (void *)&cmd_showport_macs_show,
16810 (void *)&cmd_showport_macs_port,
16811 (void *)&cmd_showport_macs_pid,
16812 (void *)&cmd_showport_macs_keyword,
16817 /* ******************************************************************************** */
16819 /* list of instructions */
16820 cmdline_parse_ctx_t main_ctx[] = {
16821 (cmdline_parse_inst_t *)&cmd_help_brief,
16822 (cmdline_parse_inst_t *)&cmd_help_long,
16823 (cmdline_parse_inst_t *)&cmd_quit,
16824 (cmdline_parse_inst_t *)&cmd_load_from_file,
16825 (cmdline_parse_inst_t *)&cmd_showport,
16826 (cmdline_parse_inst_t *)&cmd_showqueue,
16827 (cmdline_parse_inst_t *)&cmd_showeeprom,
16828 (cmdline_parse_inst_t *)&cmd_showportall,
16829 (cmdline_parse_inst_t *)&cmd_showdevice,
16830 (cmdline_parse_inst_t *)&cmd_showcfg,
16831 (cmdline_parse_inst_t *)&cmd_showfwdall,
16832 (cmdline_parse_inst_t *)&cmd_start,
16833 (cmdline_parse_inst_t *)&cmd_start_tx_first,
16834 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
16835 (cmdline_parse_inst_t *)&cmd_set_link_up,
16836 (cmdline_parse_inst_t *)&cmd_set_link_down,
16837 (cmdline_parse_inst_t *)&cmd_reset,
16838 (cmdline_parse_inst_t *)&cmd_set_numbers,
16839 (cmdline_parse_inst_t *)&cmd_set_log,
16840 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
16841 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
16842 (cmdline_parse_inst_t *)&cmd_set_txpkts,
16843 (cmdline_parse_inst_t *)&cmd_set_txsplit,
16844 (cmdline_parse_inst_t *)&cmd_set_txtimes,
16845 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
16846 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
16847 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
16848 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
16849 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
16850 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
16851 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
16852 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
16853 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
16854 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
16855 (cmdline_parse_inst_t *)&cmd_set_link_check,
16856 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
16857 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
16858 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
16859 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
16860 #ifdef RTE_NET_BOND
16861 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
16862 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
16863 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
16864 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
16865 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
16866 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
16867 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
16868 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
16869 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
16870 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
16871 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
16873 (cmdline_parse_inst_t *)&cmd_vlan_offload,
16874 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
16875 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
16876 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
16877 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
16878 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
16879 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
16880 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
16881 (cmdline_parse_inst_t *)&cmd_csum_set,
16882 (cmdline_parse_inst_t *)&cmd_csum_show,
16883 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
16884 (cmdline_parse_inst_t *)&cmd_tso_set,
16885 (cmdline_parse_inst_t *)&cmd_tso_show,
16886 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
16887 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
16888 (cmdline_parse_inst_t *)&cmd_gro_enable,
16889 (cmdline_parse_inst_t *)&cmd_gro_flush,
16890 (cmdline_parse_inst_t *)&cmd_gro_show,
16891 (cmdline_parse_inst_t *)&cmd_gso_enable,
16892 (cmdline_parse_inst_t *)&cmd_gso_size,
16893 (cmdline_parse_inst_t *)&cmd_gso_show,
16894 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
16895 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
16896 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
16897 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
16898 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
16899 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
16900 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
16901 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
16902 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
16903 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
16904 (cmdline_parse_inst_t *)&cmd_config_dcb,
16905 (cmdline_parse_inst_t *)&cmd_read_reg,
16906 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
16907 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
16908 (cmdline_parse_inst_t *)&cmd_write_reg,
16909 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
16910 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
16911 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
16912 (cmdline_parse_inst_t *)&cmd_stop,
16913 (cmdline_parse_inst_t *)&cmd_mac_addr,
16914 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
16915 (cmdline_parse_inst_t *)&cmd_set_qmap,
16916 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
16917 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
16918 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
16919 (cmdline_parse_inst_t *)&cmd_operate_port,
16920 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
16921 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
16922 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
16923 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
16924 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
16925 (cmdline_parse_inst_t *)&cmd_config_speed_all,
16926 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
16927 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
16928 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
16929 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
16930 (cmdline_parse_inst_t *)&cmd_config_mtu,
16931 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
16932 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
16933 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
16934 (cmdline_parse_inst_t *)&cmd_config_rss,
16935 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
16936 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
16937 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
16938 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
16939 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
16940 (cmdline_parse_inst_t *)&cmd_showport_reta,
16941 (cmdline_parse_inst_t *)&cmd_showport_macs,
16942 (cmdline_parse_inst_t *)&cmd_config_burst,
16943 (cmdline_parse_inst_t *)&cmd_config_thresh,
16944 (cmdline_parse_inst_t *)&cmd_config_threshold,
16945 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
16946 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
16947 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
16948 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
16949 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
16950 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
16951 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
16952 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
16953 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
16954 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
16955 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
16956 (cmdline_parse_inst_t *)&cmd_dump,
16957 (cmdline_parse_inst_t *)&cmd_dump_one,
16958 #ifdef RTE_NET_I40E
16959 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
16961 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
16962 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
16963 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
16964 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
16965 (cmdline_parse_inst_t *)&cmd_flow,
16966 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
16967 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
16968 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
16969 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
16970 (cmdline_parse_inst_t *)&cmd_create_port_meter,
16971 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
16972 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
16973 (cmdline_parse_inst_t *)&cmd_del_port_meter,
16974 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
16975 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
16976 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
16977 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
16978 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
16979 (cmdline_parse_inst_t *)&cmd_mcast_addr,
16980 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
16981 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
16982 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
16983 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
16984 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
16985 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
16986 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
16987 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
16988 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
16989 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
16990 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
16991 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
16992 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
16993 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
16994 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
16995 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
16996 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
16997 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
16998 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
16999 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17000 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17001 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17002 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17003 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
17004 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
17005 (cmdline_parse_inst_t *)&cmd_set_vxlan,
17006 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
17007 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17008 (cmdline_parse_inst_t *)&cmd_set_nvgre,
17009 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17010 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
17011 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
17012 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
17013 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
17014 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
17015 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
17016 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
17017 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
17018 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
17019 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
17020 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
17021 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
17022 (cmdline_parse_inst_t *)&cmd_ddp_add,
17023 (cmdline_parse_inst_t *)&cmd_ddp_del,
17024 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
17025 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
17026 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
17027 (cmdline_parse_inst_t *)&cmd_clear_input_set,
17028 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
17029 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17030 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
17031 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
17032 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17033 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17034 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17035 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17037 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17038 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17039 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17040 (cmdline_parse_inst_t *)&cmd_queue_region,
17041 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17042 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17043 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17044 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17045 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17046 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17047 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17048 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17049 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17050 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17051 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17052 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17053 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17054 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17055 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17056 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17057 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17058 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
17059 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17060 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17061 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17062 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17063 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17064 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17065 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
17066 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
17067 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
17068 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17069 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17070 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17071 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17072 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17073 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17074 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17075 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17076 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17078 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17079 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17081 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
17082 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
17083 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
17084 (cmdline_parse_inst_t *)&cmd_set_raw,
17085 (cmdline_parse_inst_t *)&cmd_show_set_raw,
17086 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
17087 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
17088 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
17089 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
17090 (cmdline_parse_inst_t *)&cmd_show_capability,
17094 /* read cmdline commands from file */
17096 cmdline_read_from_file(const char *filename)
17098 struct cmdline *cl;
17100 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17102 printf("Failed to create file based cmdline context: %s\n",
17107 cmdline_interact(cl);
17112 printf("Read CLI commands from %s\n", filename);
17115 /* prompt function, called from main on MAIN lcore */
17119 /* initialize non-constant commands */
17120 cmd_set_fwd_mode_init();
17121 cmd_set_fwd_retry_mode_init();
17123 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17124 if (testpmd_cl == NULL)
17126 cmdline_interact(testpmd_cl);
17127 cmdline_stdin_exit(testpmd_cl);
17133 if (testpmd_cl != NULL)
17134 cmdline_quit(testpmd_cl);
17138 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17140 if (id == (portid_t)RTE_PORT_ALL) {
17143 RTE_ETH_FOREACH_DEV(pid) {
17144 /* check if need_reconfig has been set to 1 */
17145 if (ports[pid].need_reconfig == 0)
17146 ports[pid].need_reconfig = dev;
17147 /* check if need_reconfig_queues has been set to 1 */
17148 if (ports[pid].need_reconfig_queues == 0)
17149 ports[pid].need_reconfig_queues = queue;
17151 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17152 /* check if need_reconfig has been set to 1 */
17153 if (ports[id].need_reconfig == 0)
17154 ports[id].need_reconfig = dev;
17155 /* check if need_reconfig_queues has been set to 1 */
17156 if (ports[id].need_reconfig_queues == 0)
17157 ports[id].need_reconfig_queues = queue;