1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
14 #include <sys/socket.h>
15 #include <netinet/in.h>
17 #include <sys/queue.h>
19 #include <rte_common.h>
20 #include <rte_byteorder.h>
22 #include <rte_debug.h>
23 #include <rte_cycles.h>
24 #include <rte_memory.h>
25 #include <rte_memzone.h>
26 #include <rte_malloc.h>
27 #include <rte_launch.h>
29 #include <rte_per_lcore.h>
30 #include <rte_lcore.h>
31 #include <rte_atomic.h>
32 #include <rte_branch_prediction.h>
34 #include <rte_mempool.h>
35 #include <rte_interrupts.h>
37 #include <rte_ether.h>
38 #include <rte_ethdev.h>
39 #include <rte_string_fns.h>
40 #include <rte_devargs.h>
43 #include <rte_mbuf_dyn.h>
45 #include <cmdline_rdline.h>
46 #include <cmdline_parse.h>
47 #include <cmdline_parse_num.h>
48 #include <cmdline_parse_string.h>
49 #include <cmdline_parse_ipaddr.h>
50 #include <cmdline_parse_etheraddr.h>
51 #include <cmdline_socket.h>
54 #include <rte_eth_bond.h>
55 #include <rte_eth_bond_8023ad.h>
57 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
58 #include <rte_pmd_dpaa.h>
61 #include <rte_pmd_ixgbe.h>
64 #include <rte_pmd_i40e.h>
67 #include <rte_pmd_bnxt.h>
70 #include "cmdline_mtr.h"
71 #include "cmdline_tm.h"
74 static struct cmdline *testpmd_cl;
76 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
78 /* *** Help command with introduction. *** */
79 struct cmd_help_brief_result {
80 cmdline_fixed_string_t help;
83 static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
85 __rte_unused void *data)
90 "Help is available for the following sections:\n\n"
91 " help control : Start and stop forwarding.\n"
92 " help display : Displaying port, stats and config "
94 " help config : Configuration information.\n"
95 " help ports : Configuring ports.\n"
96 " help registers : Reading and setting port registers.\n"
97 " help filters : Filters configuration help.\n"
98 " help traffic_management : Traffic Management commands.\n"
99 " help devices : Device related cmds.\n"
100 " help all : All of the above sections.\n\n"
105 cmdline_parse_token_string_t cmd_help_brief_help =
106 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
108 cmdline_parse_inst_t cmd_help_brief = {
109 .f = cmd_help_brief_parsed,
111 .help_str = "help: Show help",
113 (void *)&cmd_help_brief_help,
118 /* *** Help command with help sections. *** */
119 struct cmd_help_long_result {
120 cmdline_fixed_string_t help;
121 cmdline_fixed_string_t section;
124 static void cmd_help_long_parsed(void *parsed_result,
126 __rte_unused void *data)
129 struct cmd_help_long_result *res = parsed_result;
131 if (!strcmp(res->section, "all"))
134 if (show_all || !strcmp(res->section, "control")) {
139 "Control forwarding:\n"
140 "-------------------\n\n"
143 " Start packet forwarding with current configuration.\n\n"
146 " Start packet forwarding with current config"
147 " after sending one burst of packets.\n\n"
150 " Stop packet forwarding, and display accumulated"
154 " Quit to prompt.\n\n"
158 if (show_all || !strcmp(res->section, "display")) {
166 "show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
167 " Display information for port_id, or all.\n\n"
169 "show port port_id (module_eeprom|eeprom)\n"
170 " Display the module EEPROM or EEPROM information for port_id.\n\n"
172 "show port X rss reta (size) (mask0,mask1,...)\n"
173 " Display the rss redirection table entry indicated"
174 " by masks on port X. size is used to indicate the"
175 " hardware supported reta size\n\n"
177 "show port (port_id) rss-hash [key]\n"
178 " Display the RSS hash functions and RSS hash key of port\n\n"
180 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
181 " Clear information for port_id, or all.\n\n"
183 "show (rxq|txq) info (port_id) (queue_id)\n"
184 " Display information for configured RX/TX queue.\n\n"
186 "show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n"
187 " Display the given configuration.\n\n"
189 "read rxd (port_id) (queue_id) (rxd_id)\n"
190 " Display an RX descriptor of a port RX queue.\n\n"
192 "read txd (port_id) (queue_id) (txd_id)\n"
193 " Display a TX descriptor of a port TX queue.\n\n"
195 "ddp get list (port_id)\n"
196 " Get ddp profile info list\n\n"
198 "ddp get info (profile_path)\n"
199 " Get ddp profile information.\n\n"
201 "show vf stats (port_id) (vf_id)\n"
202 " Display a VF's statistics.\n\n"
204 "clear vf stats (port_id) (vf_id)\n"
205 " Reset a VF's statistics.\n\n"
207 "show port (port_id) pctype mapping\n"
208 " Get flow ptype to pctype mapping on a port\n\n"
210 "show port meter stats (port_id) (meter_id) (clear)\n"
211 " Get meter stats on a port\n\n"
213 "show fwd stats all\n"
214 " Display statistics for all fwd engines.\n\n"
216 "clear fwd stats all\n"
217 " Clear statistics for all fwd engines.\n\n"
219 "show port (port_id) rx_offload capabilities\n"
220 " List all per queue and per port Rx offloading"
221 " capabilities of a port\n\n"
223 "show port (port_id) rx_offload configuration\n"
224 " List port level and all queue level"
225 " Rx offloading configuration\n\n"
227 "show port (port_id) tx_offload capabilities\n"
228 " List all per queue and per port"
229 " Tx offloading capabilities of a port\n\n"
231 "show port (port_id) tx_offload configuration\n"
232 " List port level and all queue level"
233 " Tx offloading configuration\n\n"
235 "show port (port_id) tx_metadata\n"
236 " Show Tx metadata value set"
237 " for a specific port\n\n"
239 "show port (port_id) ptypes\n"
240 " Show port supported ptypes"
241 " for a specific port\n\n"
243 "show device info (<identifier>|all)"
244 " Show general information about devices probed.\n\n"
246 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
247 " Show status of rx|tx descriptor.\n\n"
249 "show port (port_id) macs|mcast_macs"
250 " Display list of mac addresses added to port.\n\n"
252 "show port (port_id) fec capabilities"
253 " Show fec capabilities of a port.\n\n"
255 "show port (port_id) fec_mode"
256 " Show fec mode of a port.\n\n"
260 if (show_all || !strcmp(res->section, "config")) {
266 "Configuration changes only become active when"
267 " forwarding is started/restarted.\n\n"
270 " Reset forwarding to the default configuration.\n\n"
272 "set verbose (level)\n"
273 " Set the debug verbosity level X.\n\n"
275 "set log global|(type) (level)\n"
276 " Set the log level.\n\n"
279 " Set number of ports.\n\n"
282 " Set number of cores.\n\n"
284 "set coremask (mask)\n"
285 " Set the forwarding cores hexadecimal mask.\n\n"
287 "set portmask (mask)\n"
288 " Set the forwarding ports hexadecimal mask.\n\n"
291 " Set number of packets per burst.\n\n"
293 "set burst tx delay (microseconds) retry (num)\n"
294 " Set the transmit delay time and number of retries,"
295 " effective when retry is enabled.\n\n"
297 "set rxoffs (x[,y]*)\n"
298 " Set the offset of each packet segment on"
299 " receiving if split feature is engaged."
300 " Affects only the queues configured with split"
303 "set rxpkts (x[,y]*)\n"
304 " Set the length of each segment to scatter"
305 " packets on receiving if split feature is engaged."
306 " Affects only the queues configured with split"
309 "set txpkts (x[,y]*)\n"
310 " Set the length of each segment of TXONLY"
311 " and optionally CSUM packets.\n\n"
313 "set txsplit (off|on|rand)\n"
314 " Set the split policy for the TX packets."
315 " Right now only applicable for CSUM and TXONLY"
318 "set txtimes (x, y)\n"
319 " Set the scheduling on timestamps"
320 " timings for the TXONLY mode\n\n"
322 "set corelist (x[,y]*)\n"
323 " Set the list of forwarding cores.\n\n"
325 "set portlist (x[,y]*)\n"
326 " Set the list of forwarding ports.\n\n"
328 "set port setup on (iterator|event)\n"
329 " Select how attached port is retrieved for setup.\n\n"
331 "set tx loopback (port_id) (on|off)\n"
332 " Enable or disable tx loopback.\n\n"
334 "set all queues drop (port_id) (on|off)\n"
335 " Set drop enable bit for all queues.\n\n"
337 "set vf split drop (port_id) (vf_id) (on|off)\n"
338 " Set split drop enable bit for a VF from the PF.\n\n"
340 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
341 " Set MAC antispoof for a VF from the PF.\n\n"
343 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
344 " Enable MACsec offload.\n\n"
346 "set macsec offload (port_id) off\n"
347 " Disable MACsec offload.\n\n"
349 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
350 " Configure MACsec secure connection (SC).\n\n"
352 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
353 " Configure MACsec secure association (SA).\n\n"
355 "set vf broadcast (port_id) (vf_id) (on|off)\n"
356 " Set VF broadcast for a VF from the PF.\n\n"
358 "vlan set stripq (on|off) (port_id,queue_id)\n"
359 " Set the VLAN strip for a queue on a port.\n\n"
361 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
362 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
364 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
365 " Set VLAN insert for a VF from the PF.\n\n"
367 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
368 " Set VLAN antispoof for a VF from the PF.\n\n"
370 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
371 " Set VLAN tag for a VF from the PF.\n\n"
373 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
374 " Set a VF's max bandwidth(Mbps).\n\n"
376 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
377 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
379 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
380 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
382 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
383 " Set some TCs' strict link priority mode on a physical port.\n\n"
385 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
386 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
388 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
389 " Set the VLAN strip or filter or qinq strip or extend\n\n"
391 "vlan set (inner|outer) tpid (value) (port_id)\n"
392 " Set the VLAN TPID for Packet Filtering on"
395 "rx_vlan add (vlan_id|all) (port_id)\n"
396 " Add a vlan_id, or all identifiers, to the set"
397 " of VLAN identifiers filtered by port_id.\n\n"
399 "rx_vlan rm (vlan_id|all) (port_id)\n"
400 " Remove a vlan_id, or all identifiers, from the set"
401 " of VLAN identifiers filtered by port_id.\n\n"
403 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
404 " Add a vlan_id, to the set of VLAN identifiers"
405 "filtered for VF(s) from port_id.\n\n"
407 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
408 " Remove a vlan_id, to the set of VLAN identifiers"
409 "filtered for VF(s) from port_id.\n\n"
411 "rx_vxlan_port add (udp_port) (port_id)\n"
412 " Add an UDP port for VXLAN packet filter on a port\n\n"
414 "rx_vxlan_port rm (udp_port) (port_id)\n"
415 " Remove an UDP port for VXLAN packet filter on a port\n\n"
417 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
418 " Set hardware insertion of VLAN IDs (single or double VLAN "
419 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
421 "tx_vlan set pvid port_id vlan_id (on|off)\n"
422 " Set port based TX VLAN insertion.\n\n"
424 "tx_vlan reset (port_id)\n"
425 " Disable hardware insertion of a VLAN header in"
426 " packets sent on a port.\n\n"
428 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
429 " Select hardware or software calculation of the"
430 " checksum when transmitting a packet using the"
431 " csum forward engine.\n"
432 " ip|udp|tcp|sctp always concern the inner layer.\n"
433 " outer-ip concerns the outer IP layer in"
434 " outer-udp concerns the outer UDP layer in"
435 " case the packet is recognized as a tunnel packet by"
436 " the forward engine (vxlan, gre and ipip are supported)\n"
437 " Please check the NIC datasheet for HW limits.\n\n"
439 "csum parse-tunnel (on|off) (tx_port_id)\n"
440 " If disabled, treat tunnel packets as non-tunneled"
441 " packets (treat inner headers as payload). The port\n"
442 " argument is the port used for TX in csum forward"
445 "csum show (port_id)\n"
446 " Display tx checksum offload configuration\n\n"
448 "tso set (segsize) (portid)\n"
449 " Enable TCP Segmentation Offload in csum forward"
451 " Please check the NIC datasheet for HW limits.\n\n"
454 " Display the status of TCP Segmentation Offload.\n\n"
456 "set port (port_id) gro on|off\n"
457 " Enable or disable Generic Receive Offload in"
458 " csum forwarding engine.\n\n"
460 "show port (port_id) gro\n"
461 " Display GRO configuration.\n\n"
463 "set gro flush (cycles)\n"
464 " Set the cycle to flush GROed packets from"
465 " reassembly tables.\n\n"
467 "set port (port_id) gso (on|off)"
468 " Enable or disable Generic Segmentation Offload in"
469 " csum forwarding engine.\n\n"
471 "set gso segsz (length)\n"
472 " Set max packet length for output GSO segments,"
473 " including packet header and payload.\n\n"
475 "show port (port_id) gso\n"
476 " Show GSO configuration.\n\n"
479 " Set packet forwarding mode.\n\n"
481 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
482 " Add a MAC address on port_id.\n\n"
484 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
485 " Remove a MAC address from port_id.\n\n"
487 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
488 " Set the default MAC address for port_id.\n\n"
490 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
491 " Add a MAC address for a VF on the port.\n\n"
493 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
494 " Set the MAC address for a VF from the PF.\n\n"
496 "set eth-peer (port_id) (peer_addr)\n"
497 " set the peer address for certain port.\n\n"
499 "set port (port_id) uta (mac_address|all) (on|off)\n"
500 " Add/Remove a or all unicast hash filter(s)"
503 "set promisc (port_id|all) (on|off)\n"
504 " Set the promiscuous mode on port_id, or all.\n\n"
506 "set allmulti (port_id|all) (on|off)\n"
507 " Set the allmulti mode on port_id, or all.\n\n"
509 "set vf promisc (port_id) (vf_id) (on|off)\n"
510 " Set unicast promiscuous mode for a VF from the PF.\n\n"
512 "set vf allmulti (port_id) (vf_id) (on|off)\n"
513 " Set multicast promiscuous mode for a VF from the PF.\n\n"
515 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
516 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
517 " (on|off) autoneg (on|off) (port_id)\n"
518 "set flow_ctrl rx (on|off) (portid)\n"
519 "set flow_ctrl tx (on|off) (portid)\n"
520 "set flow_ctrl high_water (high_water) (portid)\n"
521 "set flow_ctrl low_water (low_water) (portid)\n"
522 "set flow_ctrl pause_time (pause_time) (portid)\n"
523 "set flow_ctrl send_xon (send_xon) (portid)\n"
524 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
525 "set flow_ctrl autoneg (on|off) (port_id)\n"
526 " Set the link flow control parameter on a port.\n\n"
528 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
529 " (low_water) (pause_time) (priority) (port_id)\n"
530 " Set the priority flow control parameter on a"
533 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
534 " Set statistics mapping (qmapping 0..15) for RX/TX"
536 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
537 " on port 0 to mapping 5.\n\n"
539 "set xstats-hide-zero on|off\n"
540 " Set the option to hide the zero values"
541 " for xstats display.\n"
543 "set record-core-cycles on|off\n"
544 " Set the option to enable measurement of CPU cycles.\n"
546 "set record-burst-stats on|off\n"
547 " Set the option to enable display of RX and TX bursts.\n"
549 "set port (port_id) vf (vf_id) rx|tx on|off\n"
550 " Enable/Disable a VF receive/tranmit from a port\n\n"
552 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
554 " AUPE:accepts untagged VLAN;"
555 "ROPE:accept unicast hash\n\n"
556 " BAM:accepts broadcast packets;"
557 "MPE:accepts all multicast packets\n\n"
558 " Enable/Disable a VF receive mode of a port\n\n"
560 "set port (port_id) queue (queue_id) rate (rate_num)\n"
561 " Set rate limit for a queue of a port\n\n"
563 "set port (port_id) vf (vf_id) rate (rate_num) "
564 "queue_mask (queue_mask_value)\n"
565 " Set rate limit for queues in VF of a port\n\n"
567 "set port (port_id) mirror-rule (rule_id)"
568 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
569 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
570 " Set pool or vlan type mirror rule on a port.\n"
571 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
572 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
575 "set port (port_id) mirror-rule (rule_id)"
576 " (uplink-mirror|downlink-mirror) dst-pool"
577 " (pool_id) (on|off)\n"
578 " Set uplink or downlink type mirror rule on a port.\n"
579 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
580 " 0 on' enable mirror income traffic to pool 0.\n\n"
582 "reset port (port_id) mirror-rule (rule_id)\n"
583 " Reset a mirror rule.\n\n"
585 "set flush_rx (on|off)\n"
586 " Flush (default) or don't flush RX streams before"
587 " forwarding. Mainly used with PCAP drivers.\n\n"
589 "set bypass mode (normal|bypass|isolate) (port_id)\n"
590 " Set the bypass mode for the lowest port on bypass enabled"
593 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
594 "mode (normal|bypass|isolate) (port_id)\n"
595 " Set the event required to initiate specified bypass mode for"
596 " the lowest port on a bypass enabled NIC where:\n"
597 " timeout = enable bypass after watchdog timeout.\n"
598 " os_on = enable bypass when OS/board is powered on.\n"
599 " os_off = enable bypass when OS/board is powered off.\n"
600 " power_on = enable bypass when power supply is turned on.\n"
601 " power_off = enable bypass when power supply is turned off."
604 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
605 " Set the bypass watchdog timeout to 'n' seconds"
606 " where 0 = instant.\n\n"
608 "show bypass config (port_id)\n"
609 " Show the bypass configuration for a bypass enabled NIC"
610 " using the lowest port on the NIC.\n\n"
613 "create bonded device (mode) (socket)\n"
614 " Create a new bonded device with specific bonding mode and socket.\n\n"
616 "add bonding slave (slave_id) (port_id)\n"
617 " Add a slave device to a bonded device.\n\n"
619 "remove bonding slave (slave_id) (port_id)\n"
620 " Remove a slave device from a bonded device.\n\n"
622 "set bonding mode (value) (port_id)\n"
623 " Set the bonding mode on a bonded device.\n\n"
625 "set bonding primary (slave_id) (port_id)\n"
626 " Set the primary slave for a bonded device.\n\n"
628 "show bonding config (port_id)\n"
629 " Show the bonding config for port_id.\n\n"
631 "set bonding mac_addr (port_id) (address)\n"
632 " Set the MAC address of a bonded device.\n\n"
634 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
635 " Set Aggregation mode for IEEE802.3AD (mode 4)"
637 "set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
638 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
640 "set bonding mon_period (port_id) (value)\n"
641 " Set the bonding link status monitoring polling period in ms.\n\n"
643 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
644 " Enable/disable dedicated queues for LACP control traffic.\n\n"
647 "set link-up port (port_id)\n"
648 " Set link up for a port.\n\n"
650 "set link-down port (port_id)\n"
651 " Set link down for a port.\n\n"
653 "E-tag set insertion on port-tag-id (value)"
654 " port (port_id) vf (vf_id)\n"
655 " Enable E-tag insertion for a VF on a port\n\n"
657 "E-tag set insertion off port (port_id) vf (vf_id)\n"
658 " Disable E-tag insertion for a VF on a port\n\n"
660 "E-tag set stripping (on|off) port (port_id)\n"
661 " Enable/disable E-tag stripping on a port\n\n"
663 "E-tag set forwarding (on|off) port (port_id)\n"
664 " Enable/disable E-tag based forwarding"
667 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
668 " Load a profile package on a port\n\n"
670 "ddp del (port_id) (backup_profile_path)\n"
671 " Delete a profile package from a port\n\n"
673 "ptype mapping get (port_id) (valid_only)\n"
674 " Get ptype mapping on a port\n\n"
676 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
677 " Replace target with the pkt_type in ptype mapping\n\n"
679 "ptype mapping reset (port_id)\n"
680 " Reset ptype mapping on a port\n\n"
682 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
683 " Update a ptype mapping item on a port\n\n"
685 "set port (port_id) ptype_mask (ptype_mask)\n"
686 " set packet types classification for a specific port\n\n"
688 "set port (port_id) queue-region region_id (value) "
689 "queue_start_index (value) queue_num (value)\n"
690 " Set a queue region on a port\n\n"
692 "set port (port_id) queue-region region_id (value) "
694 " Set a flowtype region index on a port\n\n"
696 "set port (port_id) queue-region UP (value) region_id (value)\n"
697 " Set the mapping of User Priority to "
698 "queue region on a port\n\n"
700 "set port (port_id) queue-region flush (on|off)\n"
701 " flush all queue region related configuration\n\n"
703 "show port meter cap (port_id)\n"
704 " Show port meter capability information\n\n"
706 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
707 " meter profile add - srtcm rfc 2697\n\n"
709 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
710 " meter profile add - trtcm rfc 2698\n\n"
712 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
713 " meter profile add - trtcm rfc 4115\n\n"
715 "del port meter profile (port_id) (profile_id)\n"
716 " meter profile delete\n\n"
718 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
719 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
720 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
721 "(dscp_tbl_entry63)]\n"
724 "enable port meter (port_id) (mtr_id)\n"
727 "disable port meter (port_id) (mtr_id)\n"
730 "del port meter (port_id) (mtr_id)\n"
733 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
734 " meter update meter profile\n\n"
736 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
737 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
738 " update meter dscp table entries\n\n"
740 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
741 "(action0) [(action1) (action2)]\n"
742 " meter update policer action\n\n"
744 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
745 " meter update stats\n\n"
747 "show port (port_id) queue-region\n"
748 " show all queue region related configuration info\n\n"
750 "set port (port_id) fec_mode auto|off|rs|baser\n"
751 " set fec mode for a specific port\n\n"
753 , list_pkt_forwarding_modes()
757 if (show_all || !strcmp(res->section, "ports")) {
763 "----------------\n\n"
765 "port start (port_id|all)\n"
766 " Start all ports or port_id.\n\n"
768 "port stop (port_id|all)\n"
769 " Stop all ports or port_id.\n\n"
771 "port close (port_id|all)\n"
772 " Close all ports or port_id.\n\n"
774 "port reset (port_id|all)\n"
775 " Reset all ports or port_id.\n\n"
777 "port attach (ident)\n"
778 " Attach physical or virtual dev by pci address or virtual device name\n\n"
780 "port detach (port_id)\n"
781 " Detach physical or virtual dev by port_id\n\n"
783 "port config (port_id|all)"
784 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
785 " duplex (half|full|auto)\n"
786 " Set speed and duplex for all ports or port_id\n\n"
788 "port config (port_id|all) loopback (mode)\n"
789 " Set loopback mode for all ports or port_id\n\n"
791 "port config all (rxq|txq|rxd|txd) (value)\n"
792 " Set number for rxq/txq/rxd/txd.\n\n"
794 "port config all max-pkt-len (value)\n"
795 " Set the max packet length.\n\n"
797 "port config all max-lro-pkt-size (value)\n"
798 " Set the max LRO aggregated packet size.\n\n"
800 "port config all drop-en (on|off)\n"
801 " Enable or disable packet drop on all RX queues of all ports when no "
802 "receive buffers available.\n\n"
804 "port config all rss (all|default|ip|tcp|udp|sctp|"
805 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|none|level-default|"
806 "level-outer|level-inner|<flowtype_id>)\n"
807 " Set the RSS mode.\n\n"
809 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
810 " Set the RSS redirection table.\n\n"
812 "port config (port_id) dcb vt (on|off) (traffic_class)"
814 " Set the DCB mode.\n\n"
816 "port config all burst (value)\n"
817 " Set the number of packets per burst.\n\n"
819 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
821 " Set the ring prefetch/host/writeback threshold"
822 " for tx/rx queue.\n\n"
824 "port config all (txfreet|txrst|rxfreet) (value)\n"
825 " Set free threshold for rx/tx, or set"
826 " tx rs bit threshold.\n\n"
827 "port config mtu X value\n"
828 " Set the MTU of port X to a given value\n\n"
830 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
831 " Set a rx/tx queue's ring size configuration, the new"
832 " value will take effect after command that (re-)start the port"
833 " or command that setup the specific queue\n\n"
835 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
836 " Start/stop a rx/tx queue of port X. Only take effect"
837 " when port X is started\n\n"
839 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
840 " Switch on/off a deferred start of port X rx/tx queue. Only"
841 " take effect when port X is stopped.\n\n"
843 "port (port_id) (rxq|txq) (queue_id) setup\n"
844 " Setup a rx/tx queue of port X.\n\n"
846 "port config (port_id|all) l2-tunnel E-tag ether-type"
848 " Set the value of E-tag ether-type.\n\n"
850 "port config (port_id|all) l2-tunnel E-tag"
851 " (enable|disable)\n"
852 " Enable/disable the E-tag support.\n\n"
854 "port config (port_id) pctype mapping reset\n"
855 " Reset flow type to pctype mapping on a port\n\n"
857 "port config (port_id) pctype mapping update"
858 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
859 " Update a flow type to pctype mapping item on a port\n\n"
861 "port config (port_id) pctype (pctype_id) hash_inset|"
862 "fdir_inset|fdir_flx_inset get|set|clear field\n"
864 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
866 "port config (port_id) pctype (pctype_id) hash_inset|"
867 "fdir_inset|fdir_flx_inset clear all"
868 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
870 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
871 " Add/remove UDP tunnel port for tunneling offload\n\n"
873 "port config <port_id> rx_offload vlan_strip|"
874 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
875 "outer_ipv4_cksum|macsec_strip|header_split|"
876 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
877 "buffer_split|timestamp|security|keep_crc on|off\n"
878 " Enable or disable a per port Rx offloading"
879 " on all Rx queues of a port\n\n"
881 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
882 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
883 "outer_ipv4_cksum|macsec_strip|header_split|"
884 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
885 "buffer_split|timestamp|security|keep_crc on|off\n"
886 " Enable or disable a per queue Rx offloading"
887 " only on a specific Rx queue\n\n"
889 "port config (port_id) tx_offload vlan_insert|"
890 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
891 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
892 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
893 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
895 " Enable or disable a per port Tx offloading"
896 " on all Tx queues of a port\n\n"
898 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
899 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
900 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
901 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
902 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
904 " Enable or disable a per queue Tx offloading"
905 " only on a specific Tx queue\n\n"
907 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
908 " Load an eBPF program as a callback"
909 " for particular RX/TX queue\n\n"
911 "bpf-unload rx|tx (port) (queue)\n"
912 " Unload previously loaded eBPF program"
913 " for particular RX/TX queue\n\n"
915 "port config (port_id) tx_metadata (value)\n"
916 " Set Tx metadata value per port. Testpmd will add this value"
917 " to any Tx packet sent from this port\n\n"
919 "port config (port_id) dynf (name) set|clear\n"
920 " Register a dynf and Set/clear this flag on Tx. "
921 "Testpmd will set this value to any Tx packet "
922 "sent from this port\n\n"
926 if (show_all || !strcmp(res->section, "registers")) {
934 "read reg (port_id) (address)\n"
935 " Display value of a port register.\n\n"
937 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
938 " Display a port register bit field.\n\n"
940 "read regbit (port_id) (address) (bit_x)\n"
941 " Display a single port register bit.\n\n"
943 "write reg (port_id) (address) (value)\n"
944 " Set value of a port register.\n\n"
946 "write regfield (port_id) (address) (bit_x) (bit_y)"
948 " Set bit field of a port register.\n\n"
950 "write regbit (port_id) (address) (bit_x) (value)\n"
951 " Set single bit value of a port register.\n\n"
954 if (show_all || !strcmp(res->section, "filters")) {
963 "flow_director_filter (port_id) mode raw (add|del|update)"
964 " flow (flow_id) (drop|fwd) queue (queue_id)"
965 " fd_id (fd_id_value) packet (packet file name)\n"
966 " Add/Del a raw type flow director filter.\n\n"
969 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
970 " src_mask (ipv4_src) (ipv6_src) (src_port)"
971 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
972 " Set flow director IP mask.\n\n"
974 "flow_director_mask (port_id) mode MAC-VLAN"
975 " vlan (vlan_value)\n"
976 " Set flow director MAC-VLAN mask.\n\n"
978 "flow_director_mask (port_id) mode Tunnel"
979 " vlan (vlan_value) mac (mac_value)"
980 " tunnel-type (tunnel_type_value)"
981 " tunnel-id (tunnel_id_value)\n"
982 " Set flow director Tunnel mask.\n\n"
984 "flow_director_flex_payload (port_id)"
985 " (raw|l2|l3|l4) (config)\n"
986 " Configure flex payload selection.\n\n"
988 "flow validate {port_id}"
989 " [group {group_id}] [priority {level}]"
990 " [ingress] [egress]"
991 " pattern {item} [/ {item} [...]] / end"
992 " actions {action} [/ {action} [...]] / end\n"
993 " Check whether a flow rule can be created.\n\n"
995 "flow create {port_id}"
996 " [group {group_id}] [priority {level}]"
997 " [ingress] [egress]"
998 " pattern {item} [/ {item} [...]] / end"
999 " actions {action} [/ {action} [...]] / end\n"
1000 " Create a flow rule.\n\n"
1002 "flow destroy {port_id} rule {rule_id} [...]\n"
1003 " Destroy specific flow rules.\n\n"
1005 "flow flush {port_id}\n"
1006 " Destroy all flow rules.\n\n"
1008 "flow query {port_id} {rule_id} {action}\n"
1009 " Query an existing flow rule.\n\n"
1011 "flow list {port_id} [group {group_id}] [...]\n"
1012 " List existing flow rules sorted by priority,"
1013 " filtered by group identifiers.\n\n"
1015 "flow isolate {port_id} {boolean}\n"
1016 " Restrict ingress traffic to the defined"
1019 "flow aged {port_id} [destroy]\n"
1020 " List and destroy aged flows"
1023 "flow shared_action {port_id} create"
1024 " [action_id {shared_action_id}]"
1025 " [ingress] [egress]"
1026 " action {action} / end\n"
1027 " Create shared action.\n\n"
1029 "flow shared_action {port_id} update"
1030 " {shared_action_id} action {action} / end\n"
1031 " Update shared action.\n\n"
1033 "flow shared_action {port_id} destroy"
1034 " action_id {shared_action_id} [...]\n"
1035 " Destroy specific shared actions.\n\n"
1037 "flow shared_action {port_id} query"
1038 " {shared_action_id}\n"
1039 " Query an existing shared action.\n\n"
1041 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1042 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1043 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1044 " Configure the VXLAN encapsulation for flows.\n\n"
1046 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1047 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1048 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1049 " eth-dst (eth-dst)\n"
1050 " Configure the VXLAN encapsulation for flows.\n\n"
1052 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1053 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1054 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1055 " eth-dst (eth-dst)\n"
1056 " Configure the VXLAN encapsulation for flows.\n\n"
1058 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1059 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1061 " Configure the NVGRE encapsulation for flows.\n\n"
1063 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1064 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1065 " eth-src (eth-src) eth-dst (eth-dst)\n"
1066 " Configure the NVGRE encapsulation for flows.\n\n"
1068 "set raw_encap {flow items}\n"
1069 " Configure the encapsulation with raw data.\n\n"
1071 "set raw_decap {flow items}\n"
1072 " Configure the decapsulation with raw data.\n\n"
1077 if (show_all || !strcmp(res->section, "traffic_management")) {
1081 "Traffic Management:\n"
1083 "show port tm cap (port_id)\n"
1084 " Display the port TM capability.\n\n"
1086 "show port tm level cap (port_id) (level_id)\n"
1087 " Display the port TM hierarchical level capability.\n\n"
1089 "show port tm node cap (port_id) (node_id)\n"
1090 " Display the port TM node capability.\n\n"
1092 "show port tm node type (port_id) (node_id)\n"
1093 " Display the port TM node type.\n\n"
1095 "show port tm node stats (port_id) (node_id) (clear)\n"
1096 " Display the port TM node stats.\n\n"
1098 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1099 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1100 " (packet_length_adjust) (packet_mode)\n"
1101 " Add port tm node private shaper profile.\n\n"
1103 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1104 " Delete port tm node private shaper profile.\n\n"
1106 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1107 " (shaper_profile_id)\n"
1108 " Add/update port tm node shared shaper.\n\n"
1110 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1111 " Delete port tm node shared shaper.\n\n"
1113 "set port tm node shaper profile (port_id) (node_id)"
1114 " (shaper_profile_id)\n"
1115 " Set port tm node shaper profile.\n\n"
1117 "add port tm node wred profile (port_id) (wred_profile_id)"
1118 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1119 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1120 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1121 " Add port tm node wred profile.\n\n"
1123 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1124 " Delete port tm node wred profile.\n\n"
1126 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1127 " (priority) (weight) (level_id) (shaper_profile_id)"
1128 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1129 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1130 " Add port tm nonleaf node.\n\n"
1132 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1133 " (priority) (weight) (level_id) (shaper_profile_id)"
1134 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1135 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1136 " Add port tm nonleaf node with pkt mode enabled.\n\n"
1138 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1139 " (priority) (weight) (level_id) (shaper_profile_id)"
1140 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1141 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1142 " Add port tm leaf node.\n\n"
1144 "del port tm node (port_id) (node_id)\n"
1145 " Delete port tm node.\n\n"
1147 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1148 " (priority) (weight)\n"
1149 " Set port tm node parent.\n\n"
1151 "suspend port tm node (port_id) (node_id)"
1152 " Suspend tm node.\n\n"
1154 "resume port tm node (port_id) (node_id)"
1155 " Resume tm node.\n\n"
1157 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1158 " Commit tm hierarchy.\n\n"
1160 "set port tm mark ip_ecn (port) (green) (yellow)"
1162 " Enables/Disables the traffic management marking"
1163 " for IP ECN (Explicit Congestion Notification)"
1164 " packets on a given port\n\n"
1166 "set port tm mark ip_dscp (port) (green) (yellow)"
1168 " Enables/Disables the traffic management marking"
1169 " on the port for IP dscp packets\n\n"
1171 "set port tm mark vlan_dei (port) (green) (yellow)"
1173 " Enables/Disables the traffic management marking"
1174 " on the port for VLAN packets with DEI enabled\n\n"
1178 if (show_all || !strcmp(res->section, "devices")) {
1182 "Device Operations:\n"
1184 "device detach (identifier)\n"
1185 " Detach device by identifier.\n\n"
1191 cmdline_parse_token_string_t cmd_help_long_help =
1192 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1194 cmdline_parse_token_string_t cmd_help_long_section =
1195 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1196 "all#control#display#config#"
1197 "ports#registers#filters#traffic_management#devices");
1199 cmdline_parse_inst_t cmd_help_long = {
1200 .f = cmd_help_long_parsed,
1202 .help_str = "help all|control|display|config|ports|register|"
1203 "filters|traffic_management|devices: "
1206 (void *)&cmd_help_long_help,
1207 (void *)&cmd_help_long_section,
1213 /* *** start/stop/close all ports *** */
1214 struct cmd_operate_port_result {
1215 cmdline_fixed_string_t keyword;
1216 cmdline_fixed_string_t name;
1217 cmdline_fixed_string_t value;
1220 static void cmd_operate_port_parsed(void *parsed_result,
1221 __rte_unused struct cmdline *cl,
1222 __rte_unused void *data)
1224 struct cmd_operate_port_result *res = parsed_result;
1226 if (!strcmp(res->name, "start"))
1227 start_port(RTE_PORT_ALL);
1228 else if (!strcmp(res->name, "stop"))
1229 stop_port(RTE_PORT_ALL);
1230 else if (!strcmp(res->name, "close"))
1231 close_port(RTE_PORT_ALL);
1232 else if (!strcmp(res->name, "reset"))
1233 reset_port(RTE_PORT_ALL);
1235 printf("Unknown parameter\n");
1238 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1239 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1241 cmdline_parse_token_string_t cmd_operate_port_all_port =
1242 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1243 "start#stop#close#reset");
1244 cmdline_parse_token_string_t cmd_operate_port_all_all =
1245 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1247 cmdline_parse_inst_t cmd_operate_port = {
1248 .f = cmd_operate_port_parsed,
1250 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1252 (void *)&cmd_operate_port_all_cmd,
1253 (void *)&cmd_operate_port_all_port,
1254 (void *)&cmd_operate_port_all_all,
1259 /* *** start/stop/close specific port *** */
1260 struct cmd_operate_specific_port_result {
1261 cmdline_fixed_string_t keyword;
1262 cmdline_fixed_string_t name;
1266 static void cmd_operate_specific_port_parsed(void *parsed_result,
1267 __rte_unused struct cmdline *cl,
1268 __rte_unused void *data)
1270 struct cmd_operate_specific_port_result *res = parsed_result;
1272 if (!strcmp(res->name, "start"))
1273 start_port(res->value);
1274 else if (!strcmp(res->name, "stop"))
1275 stop_port(res->value);
1276 else if (!strcmp(res->name, "close"))
1277 close_port(res->value);
1278 else if (!strcmp(res->name, "reset"))
1279 reset_port(res->value);
1281 printf("Unknown parameter\n");
1284 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1285 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1287 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1288 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1289 name, "start#stop#close#reset");
1290 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1291 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1294 cmdline_parse_inst_t cmd_operate_specific_port = {
1295 .f = cmd_operate_specific_port_parsed,
1297 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1299 (void *)&cmd_operate_specific_port_cmd,
1300 (void *)&cmd_operate_specific_port_port,
1301 (void *)&cmd_operate_specific_port_id,
1306 /* *** enable port setup (after attach) via iterator or event *** */
1307 struct cmd_set_port_setup_on_result {
1308 cmdline_fixed_string_t set;
1309 cmdline_fixed_string_t port;
1310 cmdline_fixed_string_t setup;
1311 cmdline_fixed_string_t on;
1312 cmdline_fixed_string_t mode;
1315 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1316 __rte_unused struct cmdline *cl,
1317 __rte_unused void *data)
1319 struct cmd_set_port_setup_on_result *res = parsed_result;
1321 if (strcmp(res->mode, "event") == 0)
1322 setup_on_probe_event = true;
1323 else if (strcmp(res->mode, "iterator") == 0)
1324 setup_on_probe_event = false;
1326 printf("Unknown mode\n");
1329 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1330 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1332 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1333 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1335 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1336 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1338 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1339 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1341 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1342 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1343 mode, "iterator#event");
1345 cmdline_parse_inst_t cmd_set_port_setup_on = {
1346 .f = cmd_set_port_setup_on_parsed,
1348 .help_str = "set port setup on iterator|event",
1350 (void *)&cmd_set_port_setup_on_set,
1351 (void *)&cmd_set_port_setup_on_port,
1352 (void *)&cmd_set_port_setup_on_setup,
1353 (void *)&cmd_set_port_setup_on_on,
1354 (void *)&cmd_set_port_setup_on_mode,
1359 /* *** attach a specified port *** */
1360 struct cmd_operate_attach_port_result {
1361 cmdline_fixed_string_t port;
1362 cmdline_fixed_string_t keyword;
1363 cmdline_multi_string_t identifier;
1366 static void cmd_operate_attach_port_parsed(void *parsed_result,
1367 __rte_unused struct cmdline *cl,
1368 __rte_unused void *data)
1370 struct cmd_operate_attach_port_result *res = parsed_result;
1372 if (!strcmp(res->keyword, "attach"))
1373 attach_port(res->identifier);
1375 printf("Unknown parameter\n");
1378 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1379 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1381 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1382 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1384 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1385 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1386 identifier, TOKEN_STRING_MULTI);
1388 cmdline_parse_inst_t cmd_operate_attach_port = {
1389 .f = cmd_operate_attach_port_parsed,
1391 .help_str = "port attach <identifier>: "
1392 "(identifier: pci address or virtual dev name)",
1394 (void *)&cmd_operate_attach_port_port,
1395 (void *)&cmd_operate_attach_port_keyword,
1396 (void *)&cmd_operate_attach_port_identifier,
1401 /* *** detach a specified port *** */
1402 struct cmd_operate_detach_port_result {
1403 cmdline_fixed_string_t port;
1404 cmdline_fixed_string_t keyword;
1408 static void cmd_operate_detach_port_parsed(void *parsed_result,
1409 __rte_unused struct cmdline *cl,
1410 __rte_unused void *data)
1412 struct cmd_operate_detach_port_result *res = parsed_result;
1414 if (!strcmp(res->keyword, "detach")) {
1415 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1416 detach_port_device(res->port_id);
1418 printf("Unknown parameter\n");
1422 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1423 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1425 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1426 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1428 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1429 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1432 cmdline_parse_inst_t cmd_operate_detach_port = {
1433 .f = cmd_operate_detach_port_parsed,
1435 .help_str = "port detach <port_id>",
1437 (void *)&cmd_operate_detach_port_port,
1438 (void *)&cmd_operate_detach_port_keyword,
1439 (void *)&cmd_operate_detach_port_port_id,
1444 /* *** detach device by identifier *** */
1445 struct cmd_operate_detach_device_result {
1446 cmdline_fixed_string_t device;
1447 cmdline_fixed_string_t keyword;
1448 cmdline_fixed_string_t identifier;
1451 static void cmd_operate_detach_device_parsed(void *parsed_result,
1452 __rte_unused struct cmdline *cl,
1453 __rte_unused void *data)
1455 struct cmd_operate_detach_device_result *res = parsed_result;
1457 if (!strcmp(res->keyword, "detach"))
1458 detach_devargs(res->identifier);
1460 printf("Unknown parameter\n");
1463 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1464 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1466 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1467 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1469 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1470 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1473 cmdline_parse_inst_t cmd_operate_detach_device = {
1474 .f = cmd_operate_detach_device_parsed,
1476 .help_str = "device detach <identifier>:"
1477 "(identifier: pci address or virtual dev name)",
1479 (void *)&cmd_operate_detach_device_device,
1480 (void *)&cmd_operate_detach_device_keyword,
1481 (void *)&cmd_operate_detach_device_identifier,
1485 /* *** configure speed for all ports *** */
1486 struct cmd_config_speed_all {
1487 cmdline_fixed_string_t port;
1488 cmdline_fixed_string_t keyword;
1489 cmdline_fixed_string_t all;
1490 cmdline_fixed_string_t item1;
1491 cmdline_fixed_string_t item2;
1492 cmdline_fixed_string_t value1;
1493 cmdline_fixed_string_t value2;
1497 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1502 if (!strcmp(duplexstr, "half")) {
1503 duplex = ETH_LINK_HALF_DUPLEX;
1504 } else if (!strcmp(duplexstr, "full")) {
1505 duplex = ETH_LINK_FULL_DUPLEX;
1506 } else if (!strcmp(duplexstr, "auto")) {
1507 duplex = ETH_LINK_FULL_DUPLEX;
1509 printf("Unknown duplex parameter\n");
1513 if (!strcmp(speedstr, "10")) {
1514 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1515 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1516 } else if (!strcmp(speedstr, "100")) {
1517 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1518 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1520 if (duplex != ETH_LINK_FULL_DUPLEX) {
1521 printf("Invalid speed/duplex parameters\n");
1524 if (!strcmp(speedstr, "1000")) {
1525 *speed = ETH_LINK_SPEED_1G;
1526 } else if (!strcmp(speedstr, "10000")) {
1527 *speed = ETH_LINK_SPEED_10G;
1528 } else if (!strcmp(speedstr, "25000")) {
1529 *speed = ETH_LINK_SPEED_25G;
1530 } else if (!strcmp(speedstr, "40000")) {
1531 *speed = ETH_LINK_SPEED_40G;
1532 } else if (!strcmp(speedstr, "50000")) {
1533 *speed = ETH_LINK_SPEED_50G;
1534 } else if (!strcmp(speedstr, "100000")) {
1535 *speed = ETH_LINK_SPEED_100G;
1536 } else if (!strcmp(speedstr, "200000")) {
1537 *speed = ETH_LINK_SPEED_200G;
1538 } else if (!strcmp(speedstr, "auto")) {
1539 *speed = ETH_LINK_SPEED_AUTONEG;
1541 printf("Unknown speed parameter\n");
1550 cmd_config_speed_all_parsed(void *parsed_result,
1551 __rte_unused struct cmdline *cl,
1552 __rte_unused void *data)
1554 struct cmd_config_speed_all *res = parsed_result;
1555 uint32_t link_speed;
1558 if (!all_ports_stopped()) {
1559 printf("Please stop all ports first\n");
1563 if (parse_and_check_speed_duplex(res->value1, res->value2,
1567 RTE_ETH_FOREACH_DEV(pid) {
1568 ports[pid].dev_conf.link_speeds = link_speed;
1571 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1574 cmdline_parse_token_string_t cmd_config_speed_all_port =
1575 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1576 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1577 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1579 cmdline_parse_token_string_t cmd_config_speed_all_all =
1580 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1581 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1582 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1583 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1584 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1585 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1586 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1587 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1588 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1589 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1592 cmdline_parse_inst_t cmd_config_speed_all = {
1593 .f = cmd_config_speed_all_parsed,
1595 .help_str = "port config all speed "
1596 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1599 (void *)&cmd_config_speed_all_port,
1600 (void *)&cmd_config_speed_all_keyword,
1601 (void *)&cmd_config_speed_all_all,
1602 (void *)&cmd_config_speed_all_item1,
1603 (void *)&cmd_config_speed_all_value1,
1604 (void *)&cmd_config_speed_all_item2,
1605 (void *)&cmd_config_speed_all_value2,
1610 /* *** configure speed for specific port *** */
1611 struct cmd_config_speed_specific {
1612 cmdline_fixed_string_t port;
1613 cmdline_fixed_string_t keyword;
1615 cmdline_fixed_string_t item1;
1616 cmdline_fixed_string_t item2;
1617 cmdline_fixed_string_t value1;
1618 cmdline_fixed_string_t value2;
1622 cmd_config_speed_specific_parsed(void *parsed_result,
1623 __rte_unused struct cmdline *cl,
1624 __rte_unused void *data)
1626 struct cmd_config_speed_specific *res = parsed_result;
1627 uint32_t link_speed;
1629 if (!all_ports_stopped()) {
1630 printf("Please stop all ports first\n");
1634 if (port_id_is_invalid(res->id, ENABLED_WARN))
1637 if (parse_and_check_speed_duplex(res->value1, res->value2,
1641 ports[res->id].dev_conf.link_speeds = link_speed;
1643 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1647 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1648 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1650 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1651 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1653 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1654 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1655 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1656 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1658 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1659 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1660 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1661 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1662 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1664 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1665 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1668 cmdline_parse_inst_t cmd_config_speed_specific = {
1669 .f = cmd_config_speed_specific_parsed,
1671 .help_str = "port config <port_id> speed "
1672 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1675 (void *)&cmd_config_speed_specific_port,
1676 (void *)&cmd_config_speed_specific_keyword,
1677 (void *)&cmd_config_speed_specific_id,
1678 (void *)&cmd_config_speed_specific_item1,
1679 (void *)&cmd_config_speed_specific_value1,
1680 (void *)&cmd_config_speed_specific_item2,
1681 (void *)&cmd_config_speed_specific_value2,
1686 /* *** configure loopback for all ports *** */
1687 struct cmd_config_loopback_all {
1688 cmdline_fixed_string_t port;
1689 cmdline_fixed_string_t keyword;
1690 cmdline_fixed_string_t all;
1691 cmdline_fixed_string_t item;
1696 cmd_config_loopback_all_parsed(void *parsed_result,
1697 __rte_unused struct cmdline *cl,
1698 __rte_unused void *data)
1700 struct cmd_config_loopback_all *res = parsed_result;
1703 if (!all_ports_stopped()) {
1704 printf("Please stop all ports first\n");
1708 RTE_ETH_FOREACH_DEV(pid) {
1709 ports[pid].dev_conf.lpbk_mode = res->mode;
1712 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1715 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1716 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1717 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1718 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1720 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1721 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1722 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1723 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1725 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1726 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1728 cmdline_parse_inst_t cmd_config_loopback_all = {
1729 .f = cmd_config_loopback_all_parsed,
1731 .help_str = "port config all loopback <mode>",
1733 (void *)&cmd_config_loopback_all_port,
1734 (void *)&cmd_config_loopback_all_keyword,
1735 (void *)&cmd_config_loopback_all_all,
1736 (void *)&cmd_config_loopback_all_item,
1737 (void *)&cmd_config_loopback_all_mode,
1742 /* *** configure loopback for specific port *** */
1743 struct cmd_config_loopback_specific {
1744 cmdline_fixed_string_t port;
1745 cmdline_fixed_string_t keyword;
1747 cmdline_fixed_string_t item;
1752 cmd_config_loopback_specific_parsed(void *parsed_result,
1753 __rte_unused struct cmdline *cl,
1754 __rte_unused void *data)
1756 struct cmd_config_loopback_specific *res = parsed_result;
1758 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1761 if (!port_is_stopped(res->port_id)) {
1762 printf("Please stop port %u first\n", res->port_id);
1766 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1768 cmd_reconfig_device_queue(res->port_id, 1, 1);
1772 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1773 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1775 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1776 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1778 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1779 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1781 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1782 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1784 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1785 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1788 cmdline_parse_inst_t cmd_config_loopback_specific = {
1789 .f = cmd_config_loopback_specific_parsed,
1791 .help_str = "port config <port_id> loopback <mode>",
1793 (void *)&cmd_config_loopback_specific_port,
1794 (void *)&cmd_config_loopback_specific_keyword,
1795 (void *)&cmd_config_loopback_specific_id,
1796 (void *)&cmd_config_loopback_specific_item,
1797 (void *)&cmd_config_loopback_specific_mode,
1802 /* *** configure txq/rxq, txd/rxd *** */
1803 struct cmd_config_rx_tx {
1804 cmdline_fixed_string_t port;
1805 cmdline_fixed_string_t keyword;
1806 cmdline_fixed_string_t all;
1807 cmdline_fixed_string_t name;
1812 cmd_config_rx_tx_parsed(void *parsed_result,
1813 __rte_unused struct cmdline *cl,
1814 __rte_unused void *data)
1816 struct cmd_config_rx_tx *res = parsed_result;
1818 if (!all_ports_stopped()) {
1819 printf("Please stop all ports first\n");
1822 if (!strcmp(res->name, "rxq")) {
1823 if (!res->value && !nb_txq) {
1824 printf("Warning: Either rx or tx queues should be non zero\n");
1827 if (check_nb_rxq(res->value) != 0)
1829 nb_rxq = res->value;
1831 else if (!strcmp(res->name, "txq")) {
1832 if (!res->value && !nb_rxq) {
1833 printf("Warning: Either rx or tx queues should be non zero\n");
1836 if (check_nb_txq(res->value) != 0)
1838 nb_txq = res->value;
1840 else if (!strcmp(res->name, "rxd")) {
1841 if (check_nb_rxd(res->value) != 0)
1843 nb_rxd = res->value;
1844 } else if (!strcmp(res->name, "txd")) {
1845 if (check_nb_txd(res->value) != 0)
1848 nb_txd = res->value;
1850 printf("Unknown parameter\n");
1858 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1861 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1862 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1863 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1864 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1865 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1866 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1867 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1868 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1870 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1871 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1873 cmdline_parse_inst_t cmd_config_rx_tx = {
1874 .f = cmd_config_rx_tx_parsed,
1876 .help_str = "port config all rxq|txq|rxd|txd <value>",
1878 (void *)&cmd_config_rx_tx_port,
1879 (void *)&cmd_config_rx_tx_keyword,
1880 (void *)&cmd_config_rx_tx_all,
1881 (void *)&cmd_config_rx_tx_name,
1882 (void *)&cmd_config_rx_tx_value,
1887 /* *** config max packet length *** */
1888 struct cmd_config_max_pkt_len_result {
1889 cmdline_fixed_string_t port;
1890 cmdline_fixed_string_t keyword;
1891 cmdline_fixed_string_t all;
1892 cmdline_fixed_string_t name;
1897 cmd_config_max_pkt_len_parsed(void *parsed_result,
1898 __rte_unused struct cmdline *cl,
1899 __rte_unused void *data)
1901 struct cmd_config_max_pkt_len_result *res = parsed_result;
1904 if (!all_ports_stopped()) {
1905 printf("Please stop all ports first\n");
1909 RTE_ETH_FOREACH_DEV(pid) {
1910 struct rte_port *port = &ports[pid];
1911 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1913 if (!strcmp(res->name, "max-pkt-len")) {
1914 if (res->value < RTE_ETHER_MIN_LEN) {
1915 printf("max-pkt-len can not be less than %d\n",
1919 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1922 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1923 if (res->value > RTE_ETHER_MAX_LEN)
1924 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1926 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1927 port->dev_conf.rxmode.offloads = rx_offloads;
1929 printf("Unknown parameter\n");
1936 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1939 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1940 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1942 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1943 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1945 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1946 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1948 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1949 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1951 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1952 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1955 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1956 .f = cmd_config_max_pkt_len_parsed,
1958 .help_str = "port config all max-pkt-len <value>",
1960 (void *)&cmd_config_max_pkt_len_port,
1961 (void *)&cmd_config_max_pkt_len_keyword,
1962 (void *)&cmd_config_max_pkt_len_all,
1963 (void *)&cmd_config_max_pkt_len_name,
1964 (void *)&cmd_config_max_pkt_len_value,
1969 /* *** config max LRO aggregated packet size *** */
1970 struct cmd_config_max_lro_pkt_size_result {
1971 cmdline_fixed_string_t port;
1972 cmdline_fixed_string_t keyword;
1973 cmdline_fixed_string_t all;
1974 cmdline_fixed_string_t name;
1979 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1980 __rte_unused struct cmdline *cl,
1981 __rte_unused void *data)
1983 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1986 if (!all_ports_stopped()) {
1987 printf("Please stop all ports first\n");
1991 RTE_ETH_FOREACH_DEV(pid) {
1992 struct rte_port *port = &ports[pid];
1994 if (!strcmp(res->name, "max-lro-pkt-size")) {
1996 port->dev_conf.rxmode.max_lro_pkt_size)
1999 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2001 printf("Unknown parameter\n");
2008 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2011 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2012 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2014 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2015 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2017 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2018 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2020 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2021 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2022 name, "max-lro-pkt-size");
2023 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2024 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2027 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2028 .f = cmd_config_max_lro_pkt_size_parsed,
2030 .help_str = "port config all max-lro-pkt-size <value>",
2032 (void *)&cmd_config_max_lro_pkt_size_port,
2033 (void *)&cmd_config_max_lro_pkt_size_keyword,
2034 (void *)&cmd_config_max_lro_pkt_size_all,
2035 (void *)&cmd_config_max_lro_pkt_size_name,
2036 (void *)&cmd_config_max_lro_pkt_size_value,
2041 /* *** configure port MTU *** */
2042 struct cmd_config_mtu_result {
2043 cmdline_fixed_string_t port;
2044 cmdline_fixed_string_t keyword;
2045 cmdline_fixed_string_t mtu;
2051 cmd_config_mtu_parsed(void *parsed_result,
2052 __rte_unused struct cmdline *cl,
2053 __rte_unused void *data)
2055 struct cmd_config_mtu_result *res = parsed_result;
2057 if (res->value < RTE_ETHER_MIN_LEN) {
2058 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2061 port_mtu_set(res->port_id, res->value);
2064 cmdline_parse_token_string_t cmd_config_mtu_port =
2065 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2067 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2068 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2070 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2071 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2073 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2074 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2075 cmdline_parse_token_num_t cmd_config_mtu_value =
2076 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2078 cmdline_parse_inst_t cmd_config_mtu = {
2079 .f = cmd_config_mtu_parsed,
2081 .help_str = "port config mtu <port_id> <value>",
2083 (void *)&cmd_config_mtu_port,
2084 (void *)&cmd_config_mtu_keyword,
2085 (void *)&cmd_config_mtu_mtu,
2086 (void *)&cmd_config_mtu_port_id,
2087 (void *)&cmd_config_mtu_value,
2092 /* *** configure rx mode *** */
2093 struct cmd_config_rx_mode_flag {
2094 cmdline_fixed_string_t port;
2095 cmdline_fixed_string_t keyword;
2096 cmdline_fixed_string_t all;
2097 cmdline_fixed_string_t name;
2098 cmdline_fixed_string_t value;
2102 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2103 __rte_unused struct cmdline *cl,
2104 __rte_unused void *data)
2106 struct cmd_config_rx_mode_flag *res = parsed_result;
2108 if (!all_ports_stopped()) {
2109 printf("Please stop all ports first\n");
2113 if (!strcmp(res->name, "drop-en")) {
2114 if (!strcmp(res->value, "on"))
2116 else if (!strcmp(res->value, "off"))
2119 printf("Unknown parameter\n");
2123 printf("Unknown parameter\n");
2129 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2132 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2133 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2134 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2135 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2137 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2138 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2139 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2140 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2142 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2143 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2146 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2147 .f = cmd_config_rx_mode_flag_parsed,
2149 .help_str = "port config all drop-en on|off",
2151 (void *)&cmd_config_rx_mode_flag_port,
2152 (void *)&cmd_config_rx_mode_flag_keyword,
2153 (void *)&cmd_config_rx_mode_flag_all,
2154 (void *)&cmd_config_rx_mode_flag_name,
2155 (void *)&cmd_config_rx_mode_flag_value,
2160 /* *** configure rss *** */
2161 struct cmd_config_rss {
2162 cmdline_fixed_string_t port;
2163 cmdline_fixed_string_t keyword;
2164 cmdline_fixed_string_t all;
2165 cmdline_fixed_string_t name;
2166 cmdline_fixed_string_t value;
2170 cmd_config_rss_parsed(void *parsed_result,
2171 __rte_unused struct cmdline *cl,
2172 __rte_unused void *data)
2174 struct cmd_config_rss *res = parsed_result;
2175 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2176 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2177 int use_default = 0;
2178 int all_updated = 1;
2183 if (!strcmp(res->value, "all"))
2184 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2185 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2186 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2187 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU;
2188 else if (!strcmp(res->value, "eth"))
2189 rss_conf.rss_hf = ETH_RSS_ETH;
2190 else if (!strcmp(res->value, "vlan"))
2191 rss_conf.rss_hf = ETH_RSS_VLAN;
2192 else if (!strcmp(res->value, "ip"))
2193 rss_conf.rss_hf = ETH_RSS_IP;
2194 else if (!strcmp(res->value, "udp"))
2195 rss_conf.rss_hf = ETH_RSS_UDP;
2196 else if (!strcmp(res->value, "tcp"))
2197 rss_conf.rss_hf = ETH_RSS_TCP;
2198 else if (!strcmp(res->value, "sctp"))
2199 rss_conf.rss_hf = ETH_RSS_SCTP;
2200 else if (!strcmp(res->value, "ether"))
2201 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2202 else if (!strcmp(res->value, "port"))
2203 rss_conf.rss_hf = ETH_RSS_PORT;
2204 else if (!strcmp(res->value, "vxlan"))
2205 rss_conf.rss_hf = ETH_RSS_VXLAN;
2206 else if (!strcmp(res->value, "geneve"))
2207 rss_conf.rss_hf = ETH_RSS_GENEVE;
2208 else if (!strcmp(res->value, "nvgre"))
2209 rss_conf.rss_hf = ETH_RSS_NVGRE;
2210 else if (!strcmp(res->value, "l3-pre32"))
2211 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2212 else if (!strcmp(res->value, "l3-pre40"))
2213 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2214 else if (!strcmp(res->value, "l3-pre48"))
2215 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2216 else if (!strcmp(res->value, "l3-pre56"))
2217 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2218 else if (!strcmp(res->value, "l3-pre64"))
2219 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2220 else if (!strcmp(res->value, "l3-pre96"))
2221 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2222 else if (!strcmp(res->value, "l3-src-only"))
2223 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2224 else if (!strcmp(res->value, "l3-dst-only"))
2225 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2226 else if (!strcmp(res->value, "l4-src-only"))
2227 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2228 else if (!strcmp(res->value, "l4-dst-only"))
2229 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2230 else if (!strcmp(res->value, "l2-src-only"))
2231 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2232 else if (!strcmp(res->value, "l2-dst-only"))
2233 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2234 else if (!strcmp(res->value, "l2tpv3"))
2235 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2236 else if (!strcmp(res->value, "esp"))
2237 rss_conf.rss_hf = ETH_RSS_ESP;
2238 else if (!strcmp(res->value, "ah"))
2239 rss_conf.rss_hf = ETH_RSS_AH;
2240 else if (!strcmp(res->value, "pfcp"))
2241 rss_conf.rss_hf = ETH_RSS_PFCP;
2242 else if (!strcmp(res->value, "pppoe"))
2243 rss_conf.rss_hf = ETH_RSS_PPPOE;
2244 else if (!strcmp(res->value, "gtpu"))
2245 rss_conf.rss_hf = ETH_RSS_GTPU;
2246 else if (!strcmp(res->value, "none"))
2247 rss_conf.rss_hf = 0;
2248 else if (!strcmp(res->value, "level-default")) {
2249 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2250 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2251 } else if (!strcmp(res->value, "level-outer")) {
2252 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2253 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2254 } else if (!strcmp(res->value, "level-inner")) {
2255 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2256 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2257 } else if (!strcmp(res->value, "default"))
2259 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2260 atoi(res->value) < 64)
2261 rss_conf.rss_hf = 1ULL << atoi(res->value);
2263 printf("Unknown parameter\n");
2266 rss_conf.rss_key = NULL;
2267 /* Update global configuration for RSS types. */
2268 RTE_ETH_FOREACH_DEV(i) {
2269 struct rte_eth_rss_conf local_rss_conf;
2271 ret = eth_dev_info_get_print_err(i, &dev_info);
2276 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2278 local_rss_conf = rss_conf;
2279 local_rss_conf.rss_hf = rss_conf.rss_hf &
2280 dev_info.flow_type_rss_offloads;
2281 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2282 printf("Port %u modified RSS hash function based on hardware support,"
2283 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2284 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2286 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2289 printf("Configuration of RSS hash at ethernet port %d "
2290 "failed with error (%d): %s.\n",
2291 i, -diag, strerror(-diag));
2294 if (all_updated && !use_default) {
2295 rss_hf = rss_conf.rss_hf;
2296 printf("rss_hf %#"PRIx64"\n", rss_hf);
2300 cmdline_parse_token_string_t cmd_config_rss_port =
2301 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2302 cmdline_parse_token_string_t cmd_config_rss_keyword =
2303 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2304 cmdline_parse_token_string_t cmd_config_rss_all =
2305 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2306 cmdline_parse_token_string_t cmd_config_rss_name =
2307 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2308 cmdline_parse_token_string_t cmd_config_rss_value =
2309 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2311 cmdline_parse_inst_t cmd_config_rss = {
2312 .f = cmd_config_rss_parsed,
2314 .help_str = "port config all rss "
2315 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2316 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|none|level-default|"
2317 "level-outer|level-inner|<flowtype_id>",
2319 (void *)&cmd_config_rss_port,
2320 (void *)&cmd_config_rss_keyword,
2321 (void *)&cmd_config_rss_all,
2322 (void *)&cmd_config_rss_name,
2323 (void *)&cmd_config_rss_value,
2328 /* *** configure rss hash key *** */
2329 struct cmd_config_rss_hash_key {
2330 cmdline_fixed_string_t port;
2331 cmdline_fixed_string_t config;
2333 cmdline_fixed_string_t rss_hash_key;
2334 cmdline_fixed_string_t rss_type;
2335 cmdline_fixed_string_t key;
2339 hexa_digit_to_value(char hexa_digit)
2341 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2342 return (uint8_t) (hexa_digit - '0');
2343 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2344 return (uint8_t) ((hexa_digit - 'a') + 10);
2345 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2346 return (uint8_t) ((hexa_digit - 'A') + 10);
2347 /* Invalid hexa digit */
2352 parse_and_check_key_hexa_digit(char *key, int idx)
2356 hexa_v = hexa_digit_to_value(key[idx]);
2358 printf("invalid key: character %c at position %d is not a "
2359 "valid hexa digit\n", key[idx], idx);
2364 cmd_config_rss_hash_key_parsed(void *parsed_result,
2365 __rte_unused struct cmdline *cl,
2366 __rte_unused void *data)
2368 struct cmd_config_rss_hash_key *res = parsed_result;
2369 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2373 struct rte_eth_dev_info dev_info;
2374 uint8_t hash_key_size;
2378 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2382 if (dev_info.hash_key_size > 0 &&
2383 dev_info.hash_key_size <= sizeof(hash_key))
2384 hash_key_size = dev_info.hash_key_size;
2386 printf("dev_info did not provide a valid hash key size\n");
2389 /* Check the length of the RSS hash key */
2390 key_len = strlen(res->key);
2391 if (key_len != (hash_key_size * 2)) {
2392 printf("key length: %d invalid - key must be a string of %d"
2393 " hexa-decimal numbers\n",
2394 (int) key_len, hash_key_size * 2);
2397 /* Translate RSS hash key into binary representation */
2398 for (i = 0; i < hash_key_size; i++) {
2399 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2402 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2405 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2407 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2411 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2412 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2413 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2414 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2416 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2417 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2418 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2419 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2420 rss_hash_key, "rss-hash-key");
2421 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2422 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2423 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2424 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2425 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2426 "ipv6-tcp-ex#ipv6-udp-ex#"
2427 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2428 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2429 "l2tpv3#esp#ah#pfcp#pppoe#gtpu");
2430 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2431 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2433 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2434 .f = cmd_config_rss_hash_key_parsed,
2436 .help_str = "port config <port_id> rss-hash-key "
2437 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2438 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2439 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2440 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2441 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2442 "l2tpv3|esp|ah|pfcp|pppoe|gtpu "
2443 "<string of hex digits (variable length, NIC dependent)>",
2445 (void *)&cmd_config_rss_hash_key_port,
2446 (void *)&cmd_config_rss_hash_key_config,
2447 (void *)&cmd_config_rss_hash_key_port_id,
2448 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2449 (void *)&cmd_config_rss_hash_key_rss_type,
2450 (void *)&cmd_config_rss_hash_key_value,
2455 /* *** configure port rxq/txq ring size *** */
2456 struct cmd_config_rxtx_ring_size {
2457 cmdline_fixed_string_t port;
2458 cmdline_fixed_string_t config;
2460 cmdline_fixed_string_t rxtxq;
2462 cmdline_fixed_string_t rsize;
2467 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2468 __rte_unused struct cmdline *cl,
2469 __rte_unused void *data)
2471 struct cmd_config_rxtx_ring_size *res = parsed_result;
2472 struct rte_port *port;
2475 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2478 if (res->portid == (portid_t)RTE_PORT_ALL) {
2479 printf("Invalid port id\n");
2483 port = &ports[res->portid];
2485 if (!strcmp(res->rxtxq, "rxq"))
2487 else if (!strcmp(res->rxtxq, "txq"))
2490 printf("Unknown parameter\n");
2494 if (isrx && rx_queue_id_is_invalid(res->qid))
2496 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2499 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2500 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2506 port->nb_rx_desc[res->qid] = res->size;
2508 port->nb_tx_desc[res->qid] = res->size;
2510 cmd_reconfig_device_queue(res->portid, 0, 1);
2513 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2514 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2516 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2517 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2519 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2520 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2522 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2523 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2525 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2526 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2528 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2529 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2530 rsize, "ring_size");
2531 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2532 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2535 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2536 .f = cmd_config_rxtx_ring_size_parsed,
2538 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2540 (void *)&cmd_config_rxtx_ring_size_port,
2541 (void *)&cmd_config_rxtx_ring_size_config,
2542 (void *)&cmd_config_rxtx_ring_size_portid,
2543 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2544 (void *)&cmd_config_rxtx_ring_size_qid,
2545 (void *)&cmd_config_rxtx_ring_size_rsize,
2546 (void *)&cmd_config_rxtx_ring_size_size,
2551 /* *** configure port rxq/txq start/stop *** */
2552 struct cmd_config_rxtx_queue {
2553 cmdline_fixed_string_t port;
2555 cmdline_fixed_string_t rxtxq;
2557 cmdline_fixed_string_t opname;
2561 cmd_config_rxtx_queue_parsed(void *parsed_result,
2562 __rte_unused struct cmdline *cl,
2563 __rte_unused void *data)
2565 struct cmd_config_rxtx_queue *res = parsed_result;
2570 if (test_done == 0) {
2571 printf("Please stop forwarding first\n");
2575 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2578 if (port_is_started(res->portid) != 1) {
2579 printf("Please start port %u first\n", res->portid);
2583 if (!strcmp(res->rxtxq, "rxq"))
2585 else if (!strcmp(res->rxtxq, "txq"))
2588 printf("Unknown parameter\n");
2592 if (isrx && rx_queue_id_is_invalid(res->qid))
2594 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2597 if (!strcmp(res->opname, "start"))
2599 else if (!strcmp(res->opname, "stop"))
2602 printf("Unknown parameter\n");
2606 if (isstart && isrx)
2607 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2608 else if (!isstart && isrx)
2609 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2610 else if (isstart && !isrx)
2611 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2613 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2615 if (ret == -ENOTSUP)
2616 printf("Function not supported in PMD driver\n");
2619 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2620 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2621 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2622 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2623 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2624 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2625 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2626 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2627 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2628 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2631 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2632 .f = cmd_config_rxtx_queue_parsed,
2634 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2636 (void *)&cmd_config_rxtx_queue_port,
2637 (void *)&cmd_config_rxtx_queue_portid,
2638 (void *)&cmd_config_rxtx_queue_rxtxq,
2639 (void *)&cmd_config_rxtx_queue_qid,
2640 (void *)&cmd_config_rxtx_queue_opname,
2645 /* *** configure port rxq/txq deferred start on/off *** */
2646 struct cmd_config_deferred_start_rxtx_queue {
2647 cmdline_fixed_string_t port;
2649 cmdline_fixed_string_t rxtxq;
2651 cmdline_fixed_string_t opname;
2652 cmdline_fixed_string_t state;
2656 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2657 __rte_unused struct cmdline *cl,
2658 __rte_unused void *data)
2660 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2661 struct rte_port *port;
2664 uint8_t needreconfig = 0;
2666 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2669 if (port_is_started(res->port_id) != 0) {
2670 printf("Please stop port %u first\n", res->port_id);
2674 port = &ports[res->port_id];
2676 isrx = !strcmp(res->rxtxq, "rxq");
2678 if (isrx && rx_queue_id_is_invalid(res->qid))
2680 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2683 ison = !strcmp(res->state, "on");
2685 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2686 port->rx_conf[res->qid].rx_deferred_start = ison;
2688 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2689 port->tx_conf[res->qid].tx_deferred_start = ison;
2694 cmd_reconfig_device_queue(res->port_id, 0, 1);
2697 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2698 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2700 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2701 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2703 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2704 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2706 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2707 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2709 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2710 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2711 opname, "deferred_start");
2712 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2713 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2716 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2717 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2719 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2721 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2722 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2723 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2724 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2725 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2726 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2731 /* *** configure port rxq/txq setup *** */
2732 struct cmd_setup_rxtx_queue {
2733 cmdline_fixed_string_t port;
2735 cmdline_fixed_string_t rxtxq;
2737 cmdline_fixed_string_t setup;
2740 /* Common CLI fields for queue setup */
2741 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2742 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2743 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2744 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2745 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2746 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2747 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2748 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2749 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2750 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2753 cmd_setup_rxtx_queue_parsed(
2754 void *parsed_result,
2755 __rte_unused struct cmdline *cl,
2756 __rte_unused void *data)
2758 struct cmd_setup_rxtx_queue *res = parsed_result;
2759 struct rte_port *port;
2760 struct rte_mempool *mp;
2761 unsigned int socket_id;
2765 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2768 if (res->portid == (portid_t)RTE_PORT_ALL) {
2769 printf("Invalid port id\n");
2773 if (!strcmp(res->rxtxq, "rxq"))
2775 else if (!strcmp(res->rxtxq, "txq"))
2778 printf("Unknown parameter\n");
2782 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2783 printf("Invalid rx queue\n");
2785 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2786 printf("Invalid tx queue\n");
2790 port = &ports[res->portid];
2792 socket_id = rxring_numa[res->portid];
2793 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2794 socket_id = port->socket_id;
2796 mp = mbuf_pool_find(socket_id, 0);
2798 printf("Failed to setup RX queue: "
2799 "No mempool allocation"
2800 " on the socket %d\n",
2801 rxring_numa[res->portid]);
2804 ret = rx_queue_setup(res->portid,
2806 port->nb_rx_desc[res->qid],
2808 &port->rx_conf[res->qid],
2811 printf("Failed to setup RX queue\n");
2813 socket_id = txring_numa[res->portid];
2814 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2815 socket_id = port->socket_id;
2817 ret = rte_eth_tx_queue_setup(res->portid,
2819 port->nb_tx_desc[res->qid],
2821 &port->tx_conf[res->qid]);
2823 printf("Failed to setup TX queue\n");
2827 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2828 .f = cmd_setup_rxtx_queue_parsed,
2830 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2832 (void *)&cmd_setup_rxtx_queue_port,
2833 (void *)&cmd_setup_rxtx_queue_portid,
2834 (void *)&cmd_setup_rxtx_queue_rxtxq,
2835 (void *)&cmd_setup_rxtx_queue_qid,
2836 (void *)&cmd_setup_rxtx_queue_setup,
2842 /* *** Configure RSS RETA *** */
2843 struct cmd_config_rss_reta {
2844 cmdline_fixed_string_t port;
2845 cmdline_fixed_string_t keyword;
2847 cmdline_fixed_string_t name;
2848 cmdline_fixed_string_t list_name;
2849 cmdline_fixed_string_t list_of_items;
2853 parse_reta_config(const char *str,
2854 struct rte_eth_rss_reta_entry64 *reta_conf,
2855 uint16_t nb_entries)
2859 uint16_t hash_index, idx, shift;
2862 const char *p, *p0 = str;
2869 unsigned long int_fld[_NUM_FLD];
2870 char *str_fld[_NUM_FLD];
2872 while ((p = strchr(p0,'(')) != NULL) {
2874 if((p0 = strchr(p,')')) == NULL)
2878 if(size >= sizeof(s))
2881 snprintf(s, sizeof(s), "%.*s", size, p);
2882 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2884 for (i = 0; i < _NUM_FLD; i++) {
2886 int_fld[i] = strtoul(str_fld[i], &end, 0);
2887 if (errno != 0 || end == str_fld[i] ||
2892 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2893 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2895 if (hash_index >= nb_entries) {
2896 printf("Invalid RETA hash index=%d\n", hash_index);
2900 idx = hash_index / RTE_RETA_GROUP_SIZE;
2901 shift = hash_index % RTE_RETA_GROUP_SIZE;
2902 reta_conf[idx].mask |= (1ULL << shift);
2903 reta_conf[idx].reta[shift] = nb_queue;
2910 cmd_set_rss_reta_parsed(void *parsed_result,
2911 __rte_unused struct cmdline *cl,
2912 __rte_unused void *data)
2915 struct rte_eth_dev_info dev_info;
2916 struct rte_eth_rss_reta_entry64 reta_conf[8];
2917 struct cmd_config_rss_reta *res = parsed_result;
2919 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2923 if (dev_info.reta_size == 0) {
2924 printf("Redirection table size is 0 which is "
2925 "invalid for RSS\n");
2928 printf("The reta size of port %d is %u\n",
2929 res->port_id, dev_info.reta_size);
2930 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2931 printf("Currently do not support more than %u entries of "
2932 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2936 memset(reta_conf, 0, sizeof(reta_conf));
2937 if (!strcmp(res->list_name, "reta")) {
2938 if (parse_reta_config(res->list_of_items, reta_conf,
2939 dev_info.reta_size)) {
2940 printf("Invalid RSS Redirection Table "
2941 "config entered\n");
2944 ret = rte_eth_dev_rss_reta_update(res->port_id,
2945 reta_conf, dev_info.reta_size);
2947 printf("Bad redirection table parameter, "
2948 "return code = %d \n", ret);
2952 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2953 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2954 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2955 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2956 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2957 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2958 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2959 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2960 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2961 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2962 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2963 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2965 cmdline_parse_inst_t cmd_config_rss_reta = {
2966 .f = cmd_set_rss_reta_parsed,
2968 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2970 (void *)&cmd_config_rss_reta_port,
2971 (void *)&cmd_config_rss_reta_keyword,
2972 (void *)&cmd_config_rss_reta_port_id,
2973 (void *)&cmd_config_rss_reta_name,
2974 (void *)&cmd_config_rss_reta_list_name,
2975 (void *)&cmd_config_rss_reta_list_of_items,
2980 /* *** SHOW PORT RETA INFO *** */
2981 struct cmd_showport_reta {
2982 cmdline_fixed_string_t show;
2983 cmdline_fixed_string_t port;
2985 cmdline_fixed_string_t rss;
2986 cmdline_fixed_string_t reta;
2988 cmdline_fixed_string_t list_of_items;
2992 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2993 uint16_t nb_entries,
2997 const char *p, *p0 = str;
3002 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3003 RTE_RETA_GROUP_SIZE;
3006 p = strchr(p0, '(');
3010 p0 = strchr(p, ')');
3014 if (size >= sizeof(s)) {
3015 printf("The string size exceeds the internal buffer size\n");
3018 snprintf(s, sizeof(s), "%.*s", size, p);
3019 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3020 if (ret <= 0 || ret != num) {
3021 printf("The bits of masks do not match the number of "
3022 "reta entries: %u\n", num);
3025 for (i = 0; i < ret; i++)
3026 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3032 cmd_showport_reta_parsed(void *parsed_result,
3033 __rte_unused struct cmdline *cl,
3034 __rte_unused void *data)
3036 struct cmd_showport_reta *res = parsed_result;
3037 struct rte_eth_rss_reta_entry64 reta_conf[8];
3038 struct rte_eth_dev_info dev_info;
3039 uint16_t max_reta_size;
3042 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3046 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3047 if (res->size == 0 || res->size > max_reta_size) {
3048 printf("Invalid redirection table size: %u (1-%u)\n",
3049 res->size, max_reta_size);
3053 memset(reta_conf, 0, sizeof(reta_conf));
3054 if (showport_parse_reta_config(reta_conf, res->size,
3055 res->list_of_items) < 0) {
3056 printf("Invalid string: %s for reta masks\n",
3057 res->list_of_items);
3060 port_rss_reta_info(res->port_id, reta_conf, res->size);
3063 cmdline_parse_token_string_t cmd_showport_reta_show =
3064 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3065 cmdline_parse_token_string_t cmd_showport_reta_port =
3066 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3067 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3068 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3069 cmdline_parse_token_string_t cmd_showport_reta_rss =
3070 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3071 cmdline_parse_token_string_t cmd_showport_reta_reta =
3072 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3073 cmdline_parse_token_num_t cmd_showport_reta_size =
3074 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3075 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3076 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3077 list_of_items, NULL);
3079 cmdline_parse_inst_t cmd_showport_reta = {
3080 .f = cmd_showport_reta_parsed,
3082 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3084 (void *)&cmd_showport_reta_show,
3085 (void *)&cmd_showport_reta_port,
3086 (void *)&cmd_showport_reta_port_id,
3087 (void *)&cmd_showport_reta_rss,
3088 (void *)&cmd_showport_reta_reta,
3089 (void *)&cmd_showport_reta_size,
3090 (void *)&cmd_showport_reta_list_of_items,
3095 /* *** Show RSS hash configuration *** */
3096 struct cmd_showport_rss_hash {
3097 cmdline_fixed_string_t show;
3098 cmdline_fixed_string_t port;
3100 cmdline_fixed_string_t rss_hash;
3101 cmdline_fixed_string_t rss_type;
3102 cmdline_fixed_string_t key; /* optional argument */
3105 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3106 __rte_unused struct cmdline *cl,
3109 struct cmd_showport_rss_hash *res = parsed_result;
3111 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3114 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3115 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3116 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3117 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3118 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3119 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3120 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3121 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3123 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3124 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3126 cmdline_parse_inst_t cmd_showport_rss_hash = {
3127 .f = cmd_showport_rss_hash_parsed,
3129 .help_str = "show port <port_id> rss-hash",
3131 (void *)&cmd_showport_rss_hash_show,
3132 (void *)&cmd_showport_rss_hash_port,
3133 (void *)&cmd_showport_rss_hash_port_id,
3134 (void *)&cmd_showport_rss_hash_rss_hash,
3139 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3140 .f = cmd_showport_rss_hash_parsed,
3142 .help_str = "show port <port_id> rss-hash key",
3144 (void *)&cmd_showport_rss_hash_show,
3145 (void *)&cmd_showport_rss_hash_port,
3146 (void *)&cmd_showport_rss_hash_port_id,
3147 (void *)&cmd_showport_rss_hash_rss_hash,
3148 (void *)&cmd_showport_rss_hash_rss_key,
3153 /* *** Configure DCB *** */
3154 struct cmd_config_dcb {
3155 cmdline_fixed_string_t port;
3156 cmdline_fixed_string_t config;
3158 cmdline_fixed_string_t dcb;
3159 cmdline_fixed_string_t vt;
3160 cmdline_fixed_string_t vt_en;
3162 cmdline_fixed_string_t pfc;
3163 cmdline_fixed_string_t pfc_en;
3167 cmd_config_dcb_parsed(void *parsed_result,
3168 __rte_unused struct cmdline *cl,
3169 __rte_unused void *data)
3171 struct cmd_config_dcb *res = parsed_result;
3172 portid_t port_id = res->port_id;
3173 struct rte_port *port;
3177 port = &ports[port_id];
3178 /** Check if the port is not started **/
3179 if (port->port_status != RTE_PORT_STOPPED) {
3180 printf("Please stop port %d first\n", port_id);
3184 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3185 printf("The invalid number of traffic class,"
3186 " only 4 or 8 allowed.\n");
3190 if (nb_fwd_lcores < res->num_tcs) {
3191 printf("nb_cores shouldn't be less than number of TCs.\n");
3194 if (!strncmp(res->pfc_en, "on", 2))
3199 /* DCB in VT mode */
3200 if (!strncmp(res->vt_en, "on", 2))
3201 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3202 (enum rte_eth_nb_tcs)res->num_tcs,
3205 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3206 (enum rte_eth_nb_tcs)res->num_tcs,
3211 printf("Cannot initialize network ports.\n");
3215 cmd_reconfig_device_queue(port_id, 1, 1);
3218 cmdline_parse_token_string_t cmd_config_dcb_port =
3219 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3220 cmdline_parse_token_string_t cmd_config_dcb_config =
3221 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3222 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3223 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3224 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3225 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3226 cmdline_parse_token_string_t cmd_config_dcb_vt =
3227 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3228 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3229 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3230 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3231 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3232 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3233 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3234 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3235 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3237 cmdline_parse_inst_t cmd_config_dcb = {
3238 .f = cmd_config_dcb_parsed,
3240 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3242 (void *)&cmd_config_dcb_port,
3243 (void *)&cmd_config_dcb_config,
3244 (void *)&cmd_config_dcb_port_id,
3245 (void *)&cmd_config_dcb_dcb,
3246 (void *)&cmd_config_dcb_vt,
3247 (void *)&cmd_config_dcb_vt_en,
3248 (void *)&cmd_config_dcb_num_tcs,
3249 (void *)&cmd_config_dcb_pfc,
3250 (void *)&cmd_config_dcb_pfc_en,
3255 /* *** configure number of packets per burst *** */
3256 struct cmd_config_burst {
3257 cmdline_fixed_string_t port;
3258 cmdline_fixed_string_t keyword;
3259 cmdline_fixed_string_t all;
3260 cmdline_fixed_string_t name;
3265 cmd_config_burst_parsed(void *parsed_result,
3266 __rte_unused struct cmdline *cl,
3267 __rte_unused void *data)
3269 struct cmd_config_burst *res = parsed_result;
3270 struct rte_eth_dev_info dev_info;
3271 uint16_t rec_nb_pkts;
3274 if (!all_ports_stopped()) {
3275 printf("Please stop all ports first\n");
3279 if (!strcmp(res->name, "burst")) {
3280 if (res->value == 0) {
3281 /* If user gives a value of zero, query the PMD for
3282 * its recommended Rx burst size. Testpmd uses a single
3283 * size for all ports, so assume all ports are the same
3284 * NIC model and use the values from Port 0.
3286 ret = eth_dev_info_get_print_err(0, &dev_info);
3290 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3292 if (rec_nb_pkts == 0) {
3293 printf("PMD does not recommend a burst size.\n"
3294 "User provided value must be between"
3295 " 1 and %d\n", MAX_PKT_BURST);
3297 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3298 printf("PMD recommended burst size of %d"
3299 " exceeds maximum value of %d\n",
3300 rec_nb_pkts, MAX_PKT_BURST);
3303 printf("Using PMD-provided burst value of %d\n",
3305 nb_pkt_per_burst = rec_nb_pkts;
3306 } else if (res->value > MAX_PKT_BURST) {
3307 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3310 nb_pkt_per_burst = res->value;
3312 printf("Unknown parameter\n");
3318 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3321 cmdline_parse_token_string_t cmd_config_burst_port =
3322 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3323 cmdline_parse_token_string_t cmd_config_burst_keyword =
3324 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3325 cmdline_parse_token_string_t cmd_config_burst_all =
3326 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3327 cmdline_parse_token_string_t cmd_config_burst_name =
3328 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3329 cmdline_parse_token_num_t cmd_config_burst_value =
3330 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3332 cmdline_parse_inst_t cmd_config_burst = {
3333 .f = cmd_config_burst_parsed,
3335 .help_str = "port config all burst <value>",
3337 (void *)&cmd_config_burst_port,
3338 (void *)&cmd_config_burst_keyword,
3339 (void *)&cmd_config_burst_all,
3340 (void *)&cmd_config_burst_name,
3341 (void *)&cmd_config_burst_value,
3346 /* *** configure rx/tx queues *** */
3347 struct cmd_config_thresh {
3348 cmdline_fixed_string_t port;
3349 cmdline_fixed_string_t keyword;
3350 cmdline_fixed_string_t all;
3351 cmdline_fixed_string_t name;
3356 cmd_config_thresh_parsed(void *parsed_result,
3357 __rte_unused struct cmdline *cl,
3358 __rte_unused void *data)
3360 struct cmd_config_thresh *res = parsed_result;
3362 if (!all_ports_stopped()) {
3363 printf("Please stop all ports first\n");
3367 if (!strcmp(res->name, "txpt"))
3368 tx_pthresh = res->value;
3369 else if(!strcmp(res->name, "txht"))
3370 tx_hthresh = res->value;
3371 else if(!strcmp(res->name, "txwt"))
3372 tx_wthresh = res->value;
3373 else if(!strcmp(res->name, "rxpt"))
3374 rx_pthresh = res->value;
3375 else if(!strcmp(res->name, "rxht"))
3376 rx_hthresh = res->value;
3377 else if(!strcmp(res->name, "rxwt"))
3378 rx_wthresh = res->value;
3380 printf("Unknown parameter\n");
3386 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3389 cmdline_parse_token_string_t cmd_config_thresh_port =
3390 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3391 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3392 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3393 cmdline_parse_token_string_t cmd_config_thresh_all =
3394 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3395 cmdline_parse_token_string_t cmd_config_thresh_name =
3396 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3397 "txpt#txht#txwt#rxpt#rxht#rxwt");
3398 cmdline_parse_token_num_t cmd_config_thresh_value =
3399 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3401 cmdline_parse_inst_t cmd_config_thresh = {
3402 .f = cmd_config_thresh_parsed,
3404 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3406 (void *)&cmd_config_thresh_port,
3407 (void *)&cmd_config_thresh_keyword,
3408 (void *)&cmd_config_thresh_all,
3409 (void *)&cmd_config_thresh_name,
3410 (void *)&cmd_config_thresh_value,
3415 /* *** configure free/rs threshold *** */
3416 struct cmd_config_threshold {
3417 cmdline_fixed_string_t port;
3418 cmdline_fixed_string_t keyword;
3419 cmdline_fixed_string_t all;
3420 cmdline_fixed_string_t name;
3425 cmd_config_threshold_parsed(void *parsed_result,
3426 __rte_unused struct cmdline *cl,
3427 __rte_unused void *data)
3429 struct cmd_config_threshold *res = parsed_result;
3431 if (!all_ports_stopped()) {
3432 printf("Please stop all ports first\n");
3436 if (!strcmp(res->name, "txfreet"))
3437 tx_free_thresh = res->value;
3438 else if (!strcmp(res->name, "txrst"))
3439 tx_rs_thresh = res->value;
3440 else if (!strcmp(res->name, "rxfreet"))
3441 rx_free_thresh = res->value;
3443 printf("Unknown parameter\n");
3449 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3452 cmdline_parse_token_string_t cmd_config_threshold_port =
3453 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3454 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3455 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3457 cmdline_parse_token_string_t cmd_config_threshold_all =
3458 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3459 cmdline_parse_token_string_t cmd_config_threshold_name =
3460 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3461 "txfreet#txrst#rxfreet");
3462 cmdline_parse_token_num_t cmd_config_threshold_value =
3463 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3465 cmdline_parse_inst_t cmd_config_threshold = {
3466 .f = cmd_config_threshold_parsed,
3468 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3470 (void *)&cmd_config_threshold_port,
3471 (void *)&cmd_config_threshold_keyword,
3472 (void *)&cmd_config_threshold_all,
3473 (void *)&cmd_config_threshold_name,
3474 (void *)&cmd_config_threshold_value,
3480 struct cmd_stop_result {
3481 cmdline_fixed_string_t stop;
3484 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3485 __rte_unused struct cmdline *cl,
3486 __rte_unused void *data)
3488 stop_packet_forwarding();
3491 cmdline_parse_token_string_t cmd_stop_stop =
3492 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3494 cmdline_parse_inst_t cmd_stop = {
3495 .f = cmd_stop_parsed,
3497 .help_str = "stop: Stop packet forwarding",
3499 (void *)&cmd_stop_stop,
3504 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3507 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3508 unsigned int *parsed_items, int check_unique_values)
3510 unsigned int nb_item;
3518 * First parse all items in the list and store their value.
3523 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3525 if ((c >= '0') && (c <= '9')) {
3526 value = (unsigned int) (value * 10 + (c - '0'));
3531 printf("character %c is not a decimal digit\n", c);
3535 printf("No valid value before comma\n");
3538 if (nb_item < max_items) {
3539 parsed_items[nb_item] = value;
3545 if (nb_item >= max_items) {
3546 printf("Number of %s = %u > %u (maximum items)\n",
3547 item_name, nb_item + 1, max_items);
3550 parsed_items[nb_item++] = value;
3551 if (! check_unique_values)
3555 * Then, check that all values in the list are differents.
3556 * No optimization here...
3558 for (i = 0; i < nb_item; i++) {
3559 for (j = i + 1; j < nb_item; j++) {
3560 if (parsed_items[j] == parsed_items[i]) {
3561 printf("duplicated %s %u at index %u and %u\n",
3562 item_name, parsed_items[i], i, j);
3570 struct cmd_set_list_result {
3571 cmdline_fixed_string_t cmd_keyword;
3572 cmdline_fixed_string_t list_name;
3573 cmdline_fixed_string_t list_of_items;
3576 static void cmd_set_list_parsed(void *parsed_result,
3577 __rte_unused struct cmdline *cl,
3578 __rte_unused void *data)
3580 struct cmd_set_list_result *res;
3582 unsigned int lcorelist[RTE_MAX_LCORE];
3583 unsigned int portlist[RTE_MAX_ETHPORTS];
3585 unsigned int nb_item;
3587 if (test_done == 0) {
3588 printf("Please stop forwarding first\n");
3592 res = parsed_result;
3593 if (!strcmp(res->list_name, "corelist")) {
3594 nb_item = parse_item_list(res->list_of_items, "core",
3596 parsed_items.lcorelist, 1);
3598 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3603 if (!strcmp(res->list_name, "portlist")) {
3604 nb_item = parse_item_list(res->list_of_items, "port",
3606 parsed_items.portlist, 1);
3608 set_fwd_ports_list(parsed_items.portlist, nb_item);
3614 cmdline_parse_token_string_t cmd_set_list_keyword =
3615 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3617 cmdline_parse_token_string_t cmd_set_list_name =
3618 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3619 "corelist#portlist");
3620 cmdline_parse_token_string_t cmd_set_list_of_items =
3621 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3624 cmdline_parse_inst_t cmd_set_fwd_list = {
3625 .f = cmd_set_list_parsed,
3627 .help_str = "set corelist|portlist <list0[,list1]*>",
3629 (void *)&cmd_set_list_keyword,
3630 (void *)&cmd_set_list_name,
3631 (void *)&cmd_set_list_of_items,
3636 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3638 struct cmd_setmask_result {
3639 cmdline_fixed_string_t set;
3640 cmdline_fixed_string_t mask;
3644 static void cmd_set_mask_parsed(void *parsed_result,
3645 __rte_unused struct cmdline *cl,
3646 __rte_unused void *data)
3648 struct cmd_setmask_result *res = parsed_result;
3650 if (test_done == 0) {
3651 printf("Please stop forwarding first\n");
3654 if (!strcmp(res->mask, "coremask")) {
3655 set_fwd_lcores_mask(res->hexavalue);
3657 } else if (!strcmp(res->mask, "portmask")) {
3658 set_fwd_ports_mask(res->hexavalue);
3663 cmdline_parse_token_string_t cmd_setmask_set =
3664 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3665 cmdline_parse_token_string_t cmd_setmask_mask =
3666 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3667 "coremask#portmask");
3668 cmdline_parse_token_num_t cmd_setmask_value =
3669 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3671 cmdline_parse_inst_t cmd_set_fwd_mask = {
3672 .f = cmd_set_mask_parsed,
3674 .help_str = "set coremask|portmask <hexadecimal value>",
3676 (void *)&cmd_setmask_set,
3677 (void *)&cmd_setmask_mask,
3678 (void *)&cmd_setmask_value,
3684 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3686 struct cmd_set_result {
3687 cmdline_fixed_string_t set;
3688 cmdline_fixed_string_t what;
3692 static void cmd_set_parsed(void *parsed_result,
3693 __rte_unused struct cmdline *cl,
3694 __rte_unused void *data)
3696 struct cmd_set_result *res = parsed_result;
3697 if (!strcmp(res->what, "nbport")) {
3698 set_fwd_ports_number(res->value);
3700 } else if (!strcmp(res->what, "nbcore")) {
3701 set_fwd_lcores_number(res->value);
3703 } else if (!strcmp(res->what, "burst"))
3704 set_nb_pkt_per_burst(res->value);
3705 else if (!strcmp(res->what, "verbose"))
3706 set_verbose_level(res->value);
3709 cmdline_parse_token_string_t cmd_set_set =
3710 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3711 cmdline_parse_token_string_t cmd_set_what =
3712 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3713 "nbport#nbcore#burst#verbose");
3714 cmdline_parse_token_num_t cmd_set_value =
3715 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3717 cmdline_parse_inst_t cmd_set_numbers = {
3718 .f = cmd_set_parsed,
3720 .help_str = "set nbport|nbcore|burst|verbose <value>",
3722 (void *)&cmd_set_set,
3723 (void *)&cmd_set_what,
3724 (void *)&cmd_set_value,
3729 /* *** SET LOG LEVEL CONFIGURATION *** */
3731 struct cmd_set_log_result {
3732 cmdline_fixed_string_t set;
3733 cmdline_fixed_string_t log;
3734 cmdline_fixed_string_t type;
3739 cmd_set_log_parsed(void *parsed_result,
3740 __rte_unused struct cmdline *cl,
3741 __rte_unused void *data)
3743 struct cmd_set_log_result *res;
3746 res = parsed_result;
3747 if (!strcmp(res->type, "global"))
3748 rte_log_set_global_level(res->level);
3750 ret = rte_log_set_level_regexp(res->type, res->level);
3752 printf("Unable to set log level\n");
3756 cmdline_parse_token_string_t cmd_set_log_set =
3757 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3758 cmdline_parse_token_string_t cmd_set_log_log =
3759 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3760 cmdline_parse_token_string_t cmd_set_log_type =
3761 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3762 cmdline_parse_token_num_t cmd_set_log_level =
3763 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3765 cmdline_parse_inst_t cmd_set_log = {
3766 .f = cmd_set_log_parsed,
3768 .help_str = "set log global|<type> <level>",
3770 (void *)&cmd_set_log_set,
3771 (void *)&cmd_set_log_log,
3772 (void *)&cmd_set_log_type,
3773 (void *)&cmd_set_log_level,
3778 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3780 struct cmd_set_rxoffs_result {
3781 cmdline_fixed_string_t cmd_keyword;
3782 cmdline_fixed_string_t rxoffs;
3783 cmdline_fixed_string_t seg_offsets;
3787 cmd_set_rxoffs_parsed(void *parsed_result,
3788 __rte_unused struct cmdline *cl,
3789 __rte_unused void *data)
3791 struct cmd_set_rxoffs_result *res;
3792 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3793 unsigned int nb_segs;
3795 res = parsed_result;
3796 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3797 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3799 set_rx_pkt_offsets(seg_offsets, nb_segs);
3802 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3803 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3804 cmd_keyword, "set");
3805 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3806 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3808 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3809 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3812 cmdline_parse_inst_t cmd_set_rxoffs = {
3813 .f = cmd_set_rxoffs_parsed,
3815 .help_str = "set rxoffs <len0[,len1]*>",
3817 (void *)&cmd_set_rxoffs_keyword,
3818 (void *)&cmd_set_rxoffs_name,
3819 (void *)&cmd_set_rxoffs_offsets,
3824 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3826 struct cmd_set_rxpkts_result {
3827 cmdline_fixed_string_t cmd_keyword;
3828 cmdline_fixed_string_t rxpkts;
3829 cmdline_fixed_string_t seg_lengths;
3833 cmd_set_rxpkts_parsed(void *parsed_result,
3834 __rte_unused struct cmdline *cl,
3835 __rte_unused void *data)
3837 struct cmd_set_rxpkts_result *res;
3838 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3839 unsigned int nb_segs;
3841 res = parsed_result;
3842 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3843 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3845 set_rx_pkt_segments(seg_lengths, nb_segs);
3848 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3849 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3850 cmd_keyword, "set");
3851 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3852 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3854 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3855 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3858 cmdline_parse_inst_t cmd_set_rxpkts = {
3859 .f = cmd_set_rxpkts_parsed,
3861 .help_str = "set rxpkts <len0[,len1]*>",
3863 (void *)&cmd_set_rxpkts_keyword,
3864 (void *)&cmd_set_rxpkts_name,
3865 (void *)&cmd_set_rxpkts_lengths,
3870 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3872 struct cmd_set_txpkts_result {
3873 cmdline_fixed_string_t cmd_keyword;
3874 cmdline_fixed_string_t txpkts;
3875 cmdline_fixed_string_t seg_lengths;
3879 cmd_set_txpkts_parsed(void *parsed_result,
3880 __rte_unused struct cmdline *cl,
3881 __rte_unused void *data)
3883 struct cmd_set_txpkts_result *res;
3884 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3885 unsigned int nb_segs;
3887 res = parsed_result;
3888 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3889 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3891 set_tx_pkt_segments(seg_lengths, nb_segs);
3894 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3895 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3896 cmd_keyword, "set");
3897 cmdline_parse_token_string_t cmd_set_txpkts_name =
3898 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3900 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3901 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3904 cmdline_parse_inst_t cmd_set_txpkts = {
3905 .f = cmd_set_txpkts_parsed,
3907 .help_str = "set txpkts <len0[,len1]*>",
3909 (void *)&cmd_set_txpkts_keyword,
3910 (void *)&cmd_set_txpkts_name,
3911 (void *)&cmd_set_txpkts_lengths,
3916 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3918 struct cmd_set_txsplit_result {
3919 cmdline_fixed_string_t cmd_keyword;
3920 cmdline_fixed_string_t txsplit;
3921 cmdline_fixed_string_t mode;
3925 cmd_set_txsplit_parsed(void *parsed_result,
3926 __rte_unused struct cmdline *cl,
3927 __rte_unused void *data)
3929 struct cmd_set_txsplit_result *res;
3931 res = parsed_result;
3932 set_tx_pkt_split(res->mode);
3935 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3936 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3937 cmd_keyword, "set");
3938 cmdline_parse_token_string_t cmd_set_txsplit_name =
3939 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3940 txsplit, "txsplit");
3941 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3942 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3945 cmdline_parse_inst_t cmd_set_txsplit = {
3946 .f = cmd_set_txsplit_parsed,
3948 .help_str = "set txsplit on|off|rand",
3950 (void *)&cmd_set_txsplit_keyword,
3951 (void *)&cmd_set_txsplit_name,
3952 (void *)&cmd_set_txsplit_mode,
3957 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
3959 struct cmd_set_txtimes_result {
3960 cmdline_fixed_string_t cmd_keyword;
3961 cmdline_fixed_string_t txtimes;
3962 cmdline_fixed_string_t tx_times;
3966 cmd_set_txtimes_parsed(void *parsed_result,
3967 __rte_unused struct cmdline *cl,
3968 __rte_unused void *data)
3970 struct cmd_set_txtimes_result *res;
3971 unsigned int tx_times[2] = {0, 0};
3972 unsigned int n_times;
3974 res = parsed_result;
3975 n_times = parse_item_list(res->tx_times, "tx times",
3978 set_tx_pkt_times(tx_times);
3981 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
3982 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3983 cmd_keyword, "set");
3984 cmdline_parse_token_string_t cmd_set_txtimes_name =
3985 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3986 txtimes, "txtimes");
3987 cmdline_parse_token_string_t cmd_set_txtimes_value =
3988 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3991 cmdline_parse_inst_t cmd_set_txtimes = {
3992 .f = cmd_set_txtimes_parsed,
3994 .help_str = "set txtimes <inter_burst>,<intra_burst>",
3996 (void *)&cmd_set_txtimes_keyword,
3997 (void *)&cmd_set_txtimes_name,
3998 (void *)&cmd_set_txtimes_value,
4003 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4004 struct cmd_rx_vlan_filter_all_result {
4005 cmdline_fixed_string_t rx_vlan;
4006 cmdline_fixed_string_t what;
4007 cmdline_fixed_string_t all;
4012 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4013 __rte_unused struct cmdline *cl,
4014 __rte_unused void *data)
4016 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4018 if (!strcmp(res->what, "add"))
4019 rx_vlan_all_filter_set(res->port_id, 1);
4021 rx_vlan_all_filter_set(res->port_id, 0);
4024 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4025 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4026 rx_vlan, "rx_vlan");
4027 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4028 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4030 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4031 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4033 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4034 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4037 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4038 .f = cmd_rx_vlan_filter_all_parsed,
4040 .help_str = "rx_vlan add|rm all <port_id>: "
4041 "Add/Remove all identifiers to/from the set of VLAN "
4042 "identifiers filtered by a port",
4044 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4045 (void *)&cmd_rx_vlan_filter_all_what,
4046 (void *)&cmd_rx_vlan_filter_all_all,
4047 (void *)&cmd_rx_vlan_filter_all_portid,
4052 /* *** VLAN OFFLOAD SET ON A PORT *** */
4053 struct cmd_vlan_offload_result {
4054 cmdline_fixed_string_t vlan;
4055 cmdline_fixed_string_t set;
4056 cmdline_fixed_string_t vlan_type;
4057 cmdline_fixed_string_t what;
4058 cmdline_fixed_string_t on;
4059 cmdline_fixed_string_t port_id;
4063 cmd_vlan_offload_parsed(void *parsed_result,
4064 __rte_unused struct cmdline *cl,
4065 __rte_unused void *data)
4068 struct cmd_vlan_offload_result *res = parsed_result;
4071 portid_t port_id = 0;
4075 len = strnlen(str, STR_TOKEN_SIZE);
4077 /* Get port_id first */
4085 tmp = strtoul(str, NULL, 0);
4086 /* If port_id greater that what portid_t can represent, return */
4087 if(tmp >= RTE_MAX_ETHPORTS)
4089 port_id = (portid_t)tmp;
4091 if (!strcmp(res->on, "on"))
4096 if (!strcmp(res->what, "strip"))
4097 rx_vlan_strip_set(port_id, on);
4098 else if(!strcmp(res->what, "stripq")){
4099 uint16_t queue_id = 0;
4101 /* No queue_id, return */
4103 printf("must specify (port,queue_id)\n");
4106 tmp = strtoul(str + i + 1, NULL, 0);
4107 /* If queue_id greater that what 16-bits can represent, return */
4111 queue_id = (uint16_t)tmp;
4112 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4114 else if (!strcmp(res->what, "filter"))
4115 rx_vlan_filter_set(port_id, on);
4116 else if (!strcmp(res->what, "qinq_strip"))
4117 rx_vlan_qinq_strip_set(port_id, on);
4119 vlan_extend_set(port_id, on);
4124 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4125 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4127 cmdline_parse_token_string_t cmd_vlan_offload_set =
4128 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4130 cmdline_parse_token_string_t cmd_vlan_offload_what =
4131 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4132 what, "strip#filter#qinq_strip#extend#stripq");
4133 cmdline_parse_token_string_t cmd_vlan_offload_on =
4134 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4136 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4137 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4140 cmdline_parse_inst_t cmd_vlan_offload = {
4141 .f = cmd_vlan_offload_parsed,
4143 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4144 "<port_id[,queue_id]>: "
4145 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4147 (void *)&cmd_vlan_offload_vlan,
4148 (void *)&cmd_vlan_offload_set,
4149 (void *)&cmd_vlan_offload_what,
4150 (void *)&cmd_vlan_offload_on,
4151 (void *)&cmd_vlan_offload_portid,
4156 /* *** VLAN TPID SET ON A PORT *** */
4157 struct cmd_vlan_tpid_result {
4158 cmdline_fixed_string_t vlan;
4159 cmdline_fixed_string_t set;
4160 cmdline_fixed_string_t vlan_type;
4161 cmdline_fixed_string_t what;
4167 cmd_vlan_tpid_parsed(void *parsed_result,
4168 __rte_unused struct cmdline *cl,
4169 __rte_unused void *data)
4171 struct cmd_vlan_tpid_result *res = parsed_result;
4172 enum rte_vlan_type vlan_type;
4174 if (!strcmp(res->vlan_type, "inner"))
4175 vlan_type = ETH_VLAN_TYPE_INNER;
4176 else if (!strcmp(res->vlan_type, "outer"))
4177 vlan_type = ETH_VLAN_TYPE_OUTER;
4179 printf("Unknown vlan type\n");
4182 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4185 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4186 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4188 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4189 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4191 cmdline_parse_token_string_t cmd_vlan_type =
4192 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4193 vlan_type, "inner#outer");
4194 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4195 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4197 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4198 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4200 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4201 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4204 cmdline_parse_inst_t cmd_vlan_tpid = {
4205 .f = cmd_vlan_tpid_parsed,
4207 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4208 "Set the VLAN Ether type",
4210 (void *)&cmd_vlan_tpid_vlan,
4211 (void *)&cmd_vlan_tpid_set,
4212 (void *)&cmd_vlan_type,
4213 (void *)&cmd_vlan_tpid_what,
4214 (void *)&cmd_vlan_tpid_tpid,
4215 (void *)&cmd_vlan_tpid_portid,
4220 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4221 struct cmd_rx_vlan_filter_result {
4222 cmdline_fixed_string_t rx_vlan;
4223 cmdline_fixed_string_t what;
4229 cmd_rx_vlan_filter_parsed(void *parsed_result,
4230 __rte_unused struct cmdline *cl,
4231 __rte_unused void *data)
4233 struct cmd_rx_vlan_filter_result *res = parsed_result;
4235 if (!strcmp(res->what, "add"))
4236 rx_vft_set(res->port_id, res->vlan_id, 1);
4238 rx_vft_set(res->port_id, res->vlan_id, 0);
4241 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4242 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4243 rx_vlan, "rx_vlan");
4244 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4245 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4247 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4248 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4250 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4251 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4254 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4255 .f = cmd_rx_vlan_filter_parsed,
4257 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4258 "Add/Remove a VLAN identifier to/from the set of VLAN "
4259 "identifiers filtered by a port",
4261 (void *)&cmd_rx_vlan_filter_rx_vlan,
4262 (void *)&cmd_rx_vlan_filter_what,
4263 (void *)&cmd_rx_vlan_filter_vlanid,
4264 (void *)&cmd_rx_vlan_filter_portid,
4269 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4270 struct cmd_tx_vlan_set_result {
4271 cmdline_fixed_string_t tx_vlan;
4272 cmdline_fixed_string_t set;
4278 cmd_tx_vlan_set_parsed(void *parsed_result,
4279 __rte_unused struct cmdline *cl,
4280 __rte_unused void *data)
4282 struct cmd_tx_vlan_set_result *res = parsed_result;
4284 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4287 if (!port_is_stopped(res->port_id)) {
4288 printf("Please stop port %d first\n", res->port_id);
4292 tx_vlan_set(res->port_id, res->vlan_id);
4294 cmd_reconfig_device_queue(res->port_id, 1, 1);
4297 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4298 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4299 tx_vlan, "tx_vlan");
4300 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4301 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4303 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4304 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4306 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4307 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4310 cmdline_parse_inst_t cmd_tx_vlan_set = {
4311 .f = cmd_tx_vlan_set_parsed,
4313 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4314 "Enable hardware insertion of a single VLAN header "
4315 "with a given TAG Identifier in packets sent on a port",
4317 (void *)&cmd_tx_vlan_set_tx_vlan,
4318 (void *)&cmd_tx_vlan_set_set,
4319 (void *)&cmd_tx_vlan_set_portid,
4320 (void *)&cmd_tx_vlan_set_vlanid,
4325 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4326 struct cmd_tx_vlan_set_qinq_result {
4327 cmdline_fixed_string_t tx_vlan;
4328 cmdline_fixed_string_t set;
4331 uint16_t vlan_id_outer;
4335 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4336 __rte_unused struct cmdline *cl,
4337 __rte_unused void *data)
4339 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4341 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4344 if (!port_is_stopped(res->port_id)) {
4345 printf("Please stop port %d first\n", res->port_id);
4349 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4351 cmd_reconfig_device_queue(res->port_id, 1, 1);
4354 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4355 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4356 tx_vlan, "tx_vlan");
4357 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4358 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4360 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4361 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4363 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4364 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4366 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4367 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4368 vlan_id_outer, UINT16);
4370 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4371 .f = cmd_tx_vlan_set_qinq_parsed,
4373 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4374 "Enable hardware insertion of double VLAN header "
4375 "with given TAG Identifiers in packets sent on a port",
4377 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4378 (void *)&cmd_tx_vlan_set_qinq_set,
4379 (void *)&cmd_tx_vlan_set_qinq_portid,
4380 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4381 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4386 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4387 struct cmd_tx_vlan_set_pvid_result {
4388 cmdline_fixed_string_t tx_vlan;
4389 cmdline_fixed_string_t set;
4390 cmdline_fixed_string_t pvid;
4393 cmdline_fixed_string_t mode;
4397 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4398 __rte_unused struct cmdline *cl,
4399 __rte_unused void *data)
4401 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4403 if (strcmp(res->mode, "on") == 0)
4404 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4406 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4409 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4410 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4411 tx_vlan, "tx_vlan");
4412 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4413 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4415 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4416 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4418 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4419 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4421 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4422 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4424 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4425 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4428 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4429 .f = cmd_tx_vlan_set_pvid_parsed,
4431 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4433 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4434 (void *)&cmd_tx_vlan_set_pvid_set,
4435 (void *)&cmd_tx_vlan_set_pvid_pvid,
4436 (void *)&cmd_tx_vlan_set_pvid_port_id,
4437 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4438 (void *)&cmd_tx_vlan_set_pvid_mode,
4443 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4444 struct cmd_tx_vlan_reset_result {
4445 cmdline_fixed_string_t tx_vlan;
4446 cmdline_fixed_string_t reset;
4451 cmd_tx_vlan_reset_parsed(void *parsed_result,
4452 __rte_unused struct cmdline *cl,
4453 __rte_unused void *data)
4455 struct cmd_tx_vlan_reset_result *res = parsed_result;
4457 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4460 if (!port_is_stopped(res->port_id)) {
4461 printf("Please stop port %d first\n", res->port_id);
4465 tx_vlan_reset(res->port_id);
4467 cmd_reconfig_device_queue(res->port_id, 1, 1);
4470 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4471 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4472 tx_vlan, "tx_vlan");
4473 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4474 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4476 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4477 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4480 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4481 .f = cmd_tx_vlan_reset_parsed,
4483 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4484 "VLAN header in packets sent on a port",
4486 (void *)&cmd_tx_vlan_reset_tx_vlan,
4487 (void *)&cmd_tx_vlan_reset_reset,
4488 (void *)&cmd_tx_vlan_reset_portid,
4494 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4495 struct cmd_csum_result {
4496 cmdline_fixed_string_t csum;
4497 cmdline_fixed_string_t mode;
4498 cmdline_fixed_string_t proto;
4499 cmdline_fixed_string_t hwsw;
4504 csum_show(int port_id)
4506 struct rte_eth_dev_info dev_info;
4507 uint64_t tx_offloads;
4510 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4511 printf("Parse tunnel is %s\n",
4512 (ports[port_id].parse_tunnel) ? "on" : "off");
4513 printf("IP checksum offload is %s\n",
4514 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4515 printf("UDP checksum offload is %s\n",
4516 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4517 printf("TCP checksum offload is %s\n",
4518 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4519 printf("SCTP checksum offload is %s\n",
4520 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4521 printf("Outer-Ip checksum offload is %s\n",
4522 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4523 printf("Outer-Udp checksum offload is %s\n",
4524 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4526 /* display warnings if configuration is not supported by the NIC */
4527 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4531 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4532 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4533 printf("Warning: hardware IP checksum enabled but not "
4534 "supported by port %d\n", port_id);
4536 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4537 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4538 printf("Warning: hardware UDP checksum enabled but not "
4539 "supported by port %d\n", port_id);
4541 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4542 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4543 printf("Warning: hardware TCP checksum enabled but not "
4544 "supported by port %d\n", port_id);
4546 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4547 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4548 printf("Warning: hardware SCTP checksum enabled but not "
4549 "supported by port %d\n", port_id);
4551 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4552 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4553 printf("Warning: hardware outer IP checksum enabled but not "
4554 "supported by port %d\n", port_id);
4556 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4557 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4559 printf("Warning: hardware outer UDP checksum enabled but not "
4560 "supported by port %d\n", port_id);
4565 cmd_config_queue_tx_offloads(struct rte_port *port)
4569 /* Apply queue tx offloads configuration */
4570 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4571 port->tx_conf[k].offloads =
4572 port->dev_conf.txmode.offloads;
4576 cmd_csum_parsed(void *parsed_result,
4577 __rte_unused struct cmdline *cl,
4578 __rte_unused void *data)
4580 struct cmd_csum_result *res = parsed_result;
4582 uint64_t csum_offloads = 0;
4583 struct rte_eth_dev_info dev_info;
4586 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4587 printf("invalid port %d\n", res->port_id);
4590 if (!port_is_stopped(res->port_id)) {
4591 printf("Please stop port %d first\n", res->port_id);
4595 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4599 if (!strcmp(res->mode, "set")) {
4601 if (!strcmp(res->hwsw, "hw"))
4604 if (!strcmp(res->proto, "ip")) {
4605 if (hw == 0 || (dev_info.tx_offload_capa &
4606 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4607 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4609 printf("IP checksum offload is not supported "
4610 "by port %u\n", res->port_id);
4612 } else if (!strcmp(res->proto, "udp")) {
4613 if (hw == 0 || (dev_info.tx_offload_capa &
4614 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4615 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4617 printf("UDP checksum offload is not supported "
4618 "by port %u\n", res->port_id);
4620 } else if (!strcmp(res->proto, "tcp")) {
4621 if (hw == 0 || (dev_info.tx_offload_capa &
4622 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4623 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4625 printf("TCP checksum offload is not supported "
4626 "by port %u\n", res->port_id);
4628 } else if (!strcmp(res->proto, "sctp")) {
4629 if (hw == 0 || (dev_info.tx_offload_capa &
4630 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4631 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4633 printf("SCTP checksum offload is not supported "
4634 "by port %u\n", res->port_id);
4636 } else if (!strcmp(res->proto, "outer-ip")) {
4637 if (hw == 0 || (dev_info.tx_offload_capa &
4638 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4640 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4642 printf("Outer IP checksum offload is not "
4643 "supported by port %u\n", res->port_id);
4645 } else if (!strcmp(res->proto, "outer-udp")) {
4646 if (hw == 0 || (dev_info.tx_offload_capa &
4647 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4649 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4651 printf("Outer UDP checksum offload is not "
4652 "supported by port %u\n", res->port_id);
4657 ports[res->port_id].dev_conf.txmode.offloads |=
4660 ports[res->port_id].dev_conf.txmode.offloads &=
4663 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4665 csum_show(res->port_id);
4667 cmd_reconfig_device_queue(res->port_id, 1, 1);
4670 cmdline_parse_token_string_t cmd_csum_csum =
4671 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4673 cmdline_parse_token_string_t cmd_csum_mode =
4674 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4676 cmdline_parse_token_string_t cmd_csum_proto =
4677 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4678 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4679 cmdline_parse_token_string_t cmd_csum_hwsw =
4680 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4682 cmdline_parse_token_num_t cmd_csum_portid =
4683 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4686 cmdline_parse_inst_t cmd_csum_set = {
4687 .f = cmd_csum_parsed,
4689 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4690 "Enable/Disable hardware calculation of L3/L4 checksum when "
4691 "using csum forward engine",
4693 (void *)&cmd_csum_csum,
4694 (void *)&cmd_csum_mode,
4695 (void *)&cmd_csum_proto,
4696 (void *)&cmd_csum_hwsw,
4697 (void *)&cmd_csum_portid,
4702 cmdline_parse_token_string_t cmd_csum_mode_show =
4703 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4706 cmdline_parse_inst_t cmd_csum_show = {
4707 .f = cmd_csum_parsed,
4709 .help_str = "csum show <port_id>: Show checksum offload configuration",
4711 (void *)&cmd_csum_csum,
4712 (void *)&cmd_csum_mode_show,
4713 (void *)&cmd_csum_portid,
4718 /* Enable/disable tunnel parsing */
4719 struct cmd_csum_tunnel_result {
4720 cmdline_fixed_string_t csum;
4721 cmdline_fixed_string_t parse;
4722 cmdline_fixed_string_t onoff;
4727 cmd_csum_tunnel_parsed(void *parsed_result,
4728 __rte_unused struct cmdline *cl,
4729 __rte_unused void *data)
4731 struct cmd_csum_tunnel_result *res = parsed_result;
4733 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4736 if (!strcmp(res->onoff, "on"))
4737 ports[res->port_id].parse_tunnel = 1;
4739 ports[res->port_id].parse_tunnel = 0;
4741 csum_show(res->port_id);
4744 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4745 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4747 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4748 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4749 parse, "parse-tunnel");
4750 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4751 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4753 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4754 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4757 cmdline_parse_inst_t cmd_csum_tunnel = {
4758 .f = cmd_csum_tunnel_parsed,
4760 .help_str = "csum parse-tunnel on|off <port_id>: "
4761 "Enable/Disable parsing of tunnels for csum engine",
4763 (void *)&cmd_csum_tunnel_csum,
4764 (void *)&cmd_csum_tunnel_parse,
4765 (void *)&cmd_csum_tunnel_onoff,
4766 (void *)&cmd_csum_tunnel_portid,
4771 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4772 struct cmd_tso_set_result {
4773 cmdline_fixed_string_t tso;
4774 cmdline_fixed_string_t mode;
4780 cmd_tso_set_parsed(void *parsed_result,
4781 __rte_unused struct cmdline *cl,
4782 __rte_unused void *data)
4784 struct cmd_tso_set_result *res = parsed_result;
4785 struct rte_eth_dev_info dev_info;
4788 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4790 if (!port_is_stopped(res->port_id)) {
4791 printf("Please stop port %d first\n", res->port_id);
4795 if (!strcmp(res->mode, "set"))
4796 ports[res->port_id].tso_segsz = res->tso_segsz;
4798 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4802 if ((ports[res->port_id].tso_segsz != 0) &&
4803 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4804 printf("Error: TSO is not supported by port %d\n",
4809 if (ports[res->port_id].tso_segsz == 0) {
4810 ports[res->port_id].dev_conf.txmode.offloads &=
4811 ~DEV_TX_OFFLOAD_TCP_TSO;
4812 printf("TSO for non-tunneled packets is disabled\n");
4814 ports[res->port_id].dev_conf.txmode.offloads |=
4815 DEV_TX_OFFLOAD_TCP_TSO;
4816 printf("TSO segment size for non-tunneled packets is %d\n",
4817 ports[res->port_id].tso_segsz);
4819 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4821 /* display warnings if configuration is not supported by the NIC */
4822 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4826 if ((ports[res->port_id].tso_segsz != 0) &&
4827 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4828 printf("Warning: TSO enabled but not "
4829 "supported by port %d\n", res->port_id);
4832 cmd_reconfig_device_queue(res->port_id, 1, 1);
4835 cmdline_parse_token_string_t cmd_tso_set_tso =
4836 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4838 cmdline_parse_token_string_t cmd_tso_set_mode =
4839 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4841 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4842 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4844 cmdline_parse_token_num_t cmd_tso_set_portid =
4845 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4848 cmdline_parse_inst_t cmd_tso_set = {
4849 .f = cmd_tso_set_parsed,
4851 .help_str = "tso set <tso_segsz> <port_id>: "
4852 "Set TSO segment size of non-tunneled packets for csum engine "
4855 (void *)&cmd_tso_set_tso,
4856 (void *)&cmd_tso_set_mode,
4857 (void *)&cmd_tso_set_tso_segsz,
4858 (void *)&cmd_tso_set_portid,
4863 cmdline_parse_token_string_t cmd_tso_show_mode =
4864 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4868 cmdline_parse_inst_t cmd_tso_show = {
4869 .f = cmd_tso_set_parsed,
4871 .help_str = "tso show <port_id>: "
4872 "Show TSO segment size of non-tunneled packets for csum engine",
4874 (void *)&cmd_tso_set_tso,
4875 (void *)&cmd_tso_show_mode,
4876 (void *)&cmd_tso_set_portid,
4881 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4882 struct cmd_tunnel_tso_set_result {
4883 cmdline_fixed_string_t tso;
4884 cmdline_fixed_string_t mode;
4889 static struct rte_eth_dev_info
4890 check_tunnel_tso_nic_support(portid_t port_id)
4892 struct rte_eth_dev_info dev_info;
4894 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4897 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4898 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4899 "not enabled for port %d\n", port_id);
4900 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4901 printf("Warning: GRE TUNNEL TSO not supported therefore "
4902 "not enabled for port %d\n", port_id);
4903 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4904 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4905 "not enabled for port %d\n", port_id);
4906 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4907 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4908 "not enabled for port %d\n", port_id);
4909 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4910 printf("Warning: IP TUNNEL TSO not supported therefore "
4911 "not enabled for port %d\n", port_id);
4912 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4913 printf("Warning: UDP TUNNEL TSO not supported therefore "
4914 "not enabled for port %d\n", port_id);
4919 cmd_tunnel_tso_set_parsed(void *parsed_result,
4920 __rte_unused struct cmdline *cl,
4921 __rte_unused void *data)
4923 struct cmd_tunnel_tso_set_result *res = parsed_result;
4924 struct rte_eth_dev_info dev_info;
4926 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4928 if (!port_is_stopped(res->port_id)) {
4929 printf("Please stop port %d first\n", res->port_id);
4933 if (!strcmp(res->mode, "set"))
4934 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4936 dev_info = check_tunnel_tso_nic_support(res->port_id);
4937 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4938 ports[res->port_id].dev_conf.txmode.offloads &=
4939 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4940 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4941 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4942 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4943 DEV_TX_OFFLOAD_IP_TNL_TSO |
4944 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4945 printf("TSO for tunneled packets is disabled\n");
4947 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4948 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4949 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4950 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4951 DEV_TX_OFFLOAD_IP_TNL_TSO |
4952 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4954 ports[res->port_id].dev_conf.txmode.offloads |=
4955 (tso_offloads & dev_info.tx_offload_capa);
4956 printf("TSO segment size for tunneled packets is %d\n",
4957 ports[res->port_id].tunnel_tso_segsz);
4959 /* Below conditions are needed to make it work:
4960 * (1) tunnel TSO is supported by the NIC;
4961 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4963 * (3) for tunneled pkts with outer L3 of IPv4,
4964 * "csum set outer-ip" must be set to hw, because after tso,
4965 * total_len of outer IP header is changed, and the checksum
4966 * of outer IP header calculated by sw should be wrong; that
4967 * is not necessary for IPv6 tunneled pkts because there's no
4968 * checksum in IP header anymore.
4971 if (!ports[res->port_id].parse_tunnel)
4972 printf("Warning: csum parse_tunnel must be set "
4973 "so that tunneled packets are recognized\n");
4974 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4975 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4976 printf("Warning: csum set outer-ip must be set to hw "
4977 "if outer L3 is IPv4; not necessary for IPv6\n");
4980 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4981 cmd_reconfig_device_queue(res->port_id, 1, 1);
4984 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4985 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4987 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4988 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4990 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4991 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4993 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4994 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4997 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4998 .f = cmd_tunnel_tso_set_parsed,
5000 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5001 "Set TSO segment size of tunneled packets for csum engine "
5004 (void *)&cmd_tunnel_tso_set_tso,
5005 (void *)&cmd_tunnel_tso_set_mode,
5006 (void *)&cmd_tunnel_tso_set_tso_segsz,
5007 (void *)&cmd_tunnel_tso_set_portid,
5012 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5013 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5017 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5018 .f = cmd_tunnel_tso_set_parsed,
5020 .help_str = "tunnel_tso show <port_id> "
5021 "Show TSO segment size of tunneled packets for csum engine",
5023 (void *)&cmd_tunnel_tso_set_tso,
5024 (void *)&cmd_tunnel_tso_show_mode,
5025 (void *)&cmd_tunnel_tso_set_portid,
5030 /* *** SET GRO FOR A PORT *** */
5031 struct cmd_gro_enable_result {
5032 cmdline_fixed_string_t cmd_set;
5033 cmdline_fixed_string_t cmd_port;
5034 cmdline_fixed_string_t cmd_keyword;
5035 cmdline_fixed_string_t cmd_onoff;
5040 cmd_gro_enable_parsed(void *parsed_result,
5041 __rte_unused struct cmdline *cl,
5042 __rte_unused void *data)
5044 struct cmd_gro_enable_result *res;
5046 res = parsed_result;
5047 if (!strcmp(res->cmd_keyword, "gro"))
5048 setup_gro(res->cmd_onoff, res->cmd_pid);
5051 cmdline_parse_token_string_t cmd_gro_enable_set =
5052 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5054 cmdline_parse_token_string_t cmd_gro_enable_port =
5055 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5056 cmd_keyword, "port");
5057 cmdline_parse_token_num_t cmd_gro_enable_pid =
5058 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5060 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5061 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5062 cmd_keyword, "gro");
5063 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5064 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5065 cmd_onoff, "on#off");
5067 cmdline_parse_inst_t cmd_gro_enable = {
5068 .f = cmd_gro_enable_parsed,
5070 .help_str = "set port <port_id> gro on|off",
5072 (void *)&cmd_gro_enable_set,
5073 (void *)&cmd_gro_enable_port,
5074 (void *)&cmd_gro_enable_pid,
5075 (void *)&cmd_gro_enable_keyword,
5076 (void *)&cmd_gro_enable_onoff,
5081 /* *** DISPLAY GRO CONFIGURATION *** */
5082 struct cmd_gro_show_result {
5083 cmdline_fixed_string_t cmd_show;
5084 cmdline_fixed_string_t cmd_port;
5085 cmdline_fixed_string_t cmd_keyword;
5090 cmd_gro_show_parsed(void *parsed_result,
5091 __rte_unused struct cmdline *cl,
5092 __rte_unused void *data)
5094 struct cmd_gro_show_result *res;
5096 res = parsed_result;
5097 if (!strcmp(res->cmd_keyword, "gro"))
5098 show_gro(res->cmd_pid);
5101 cmdline_parse_token_string_t cmd_gro_show_show =
5102 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5104 cmdline_parse_token_string_t cmd_gro_show_port =
5105 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5107 cmdline_parse_token_num_t cmd_gro_show_pid =
5108 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5110 cmdline_parse_token_string_t cmd_gro_show_keyword =
5111 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5112 cmd_keyword, "gro");
5114 cmdline_parse_inst_t cmd_gro_show = {
5115 .f = cmd_gro_show_parsed,
5117 .help_str = "show port <port_id> gro",
5119 (void *)&cmd_gro_show_show,
5120 (void *)&cmd_gro_show_port,
5121 (void *)&cmd_gro_show_pid,
5122 (void *)&cmd_gro_show_keyword,
5127 /* *** SET FLUSH CYCLES FOR GRO *** */
5128 struct cmd_gro_flush_result {
5129 cmdline_fixed_string_t cmd_set;
5130 cmdline_fixed_string_t cmd_keyword;
5131 cmdline_fixed_string_t cmd_flush;
5136 cmd_gro_flush_parsed(void *parsed_result,
5137 __rte_unused struct cmdline *cl,
5138 __rte_unused void *data)
5140 struct cmd_gro_flush_result *res;
5142 res = parsed_result;
5143 if ((!strcmp(res->cmd_keyword, "gro")) &&
5144 (!strcmp(res->cmd_flush, "flush")))
5145 setup_gro_flush_cycles(res->cmd_cycles);
5148 cmdline_parse_token_string_t cmd_gro_flush_set =
5149 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5151 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5152 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5153 cmd_keyword, "gro");
5154 cmdline_parse_token_string_t cmd_gro_flush_flush =
5155 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5156 cmd_flush, "flush");
5157 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5158 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5161 cmdline_parse_inst_t cmd_gro_flush = {
5162 .f = cmd_gro_flush_parsed,
5164 .help_str = "set gro flush <cycles>",
5166 (void *)&cmd_gro_flush_set,
5167 (void *)&cmd_gro_flush_keyword,
5168 (void *)&cmd_gro_flush_flush,
5169 (void *)&cmd_gro_flush_cycles,
5174 /* *** ENABLE/DISABLE GSO *** */
5175 struct cmd_gso_enable_result {
5176 cmdline_fixed_string_t cmd_set;
5177 cmdline_fixed_string_t cmd_port;
5178 cmdline_fixed_string_t cmd_keyword;
5179 cmdline_fixed_string_t cmd_mode;
5184 cmd_gso_enable_parsed(void *parsed_result,
5185 __rte_unused struct cmdline *cl,
5186 __rte_unused void *data)
5188 struct cmd_gso_enable_result *res;
5190 res = parsed_result;
5191 if (!strcmp(res->cmd_keyword, "gso"))
5192 setup_gso(res->cmd_mode, res->cmd_pid);
5195 cmdline_parse_token_string_t cmd_gso_enable_set =
5196 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5198 cmdline_parse_token_string_t cmd_gso_enable_port =
5199 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5201 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5202 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5203 cmd_keyword, "gso");
5204 cmdline_parse_token_string_t cmd_gso_enable_mode =
5205 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5206 cmd_mode, "on#off");
5207 cmdline_parse_token_num_t cmd_gso_enable_pid =
5208 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5211 cmdline_parse_inst_t cmd_gso_enable = {
5212 .f = cmd_gso_enable_parsed,
5214 .help_str = "set port <port_id> gso on|off",
5216 (void *)&cmd_gso_enable_set,
5217 (void *)&cmd_gso_enable_port,
5218 (void *)&cmd_gso_enable_pid,
5219 (void *)&cmd_gso_enable_keyword,
5220 (void *)&cmd_gso_enable_mode,
5225 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5226 struct cmd_gso_size_result {
5227 cmdline_fixed_string_t cmd_set;
5228 cmdline_fixed_string_t cmd_keyword;
5229 cmdline_fixed_string_t cmd_segsz;
5234 cmd_gso_size_parsed(void *parsed_result,
5235 __rte_unused struct cmdline *cl,
5236 __rte_unused void *data)
5238 struct cmd_gso_size_result *res = parsed_result;
5240 if (test_done == 0) {
5241 printf("Before setting GSO segsz, please first"
5242 " stop forwarding\n");
5246 if (!strcmp(res->cmd_keyword, "gso") &&
5247 !strcmp(res->cmd_segsz, "segsz")) {
5248 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5249 printf("gso_size should be larger than %zu."
5250 " Please input a legal value\n",
5251 RTE_GSO_SEG_SIZE_MIN);
5253 gso_max_segment_size = res->cmd_size;
5257 cmdline_parse_token_string_t cmd_gso_size_set =
5258 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5260 cmdline_parse_token_string_t cmd_gso_size_keyword =
5261 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5262 cmd_keyword, "gso");
5263 cmdline_parse_token_string_t cmd_gso_size_segsz =
5264 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5265 cmd_segsz, "segsz");
5266 cmdline_parse_token_num_t cmd_gso_size_size =
5267 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5270 cmdline_parse_inst_t cmd_gso_size = {
5271 .f = cmd_gso_size_parsed,
5273 .help_str = "set gso segsz <length>",
5275 (void *)&cmd_gso_size_set,
5276 (void *)&cmd_gso_size_keyword,
5277 (void *)&cmd_gso_size_segsz,
5278 (void *)&cmd_gso_size_size,
5283 /* *** SHOW GSO CONFIGURATION *** */
5284 struct cmd_gso_show_result {
5285 cmdline_fixed_string_t cmd_show;
5286 cmdline_fixed_string_t cmd_port;
5287 cmdline_fixed_string_t cmd_keyword;
5292 cmd_gso_show_parsed(void *parsed_result,
5293 __rte_unused struct cmdline *cl,
5294 __rte_unused void *data)
5296 struct cmd_gso_show_result *res = parsed_result;
5298 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5299 printf("invalid port id %u\n", res->cmd_pid);
5302 if (!strcmp(res->cmd_keyword, "gso")) {
5303 if (gso_ports[res->cmd_pid].enable) {
5304 printf("Max GSO'd packet size: %uB\n"
5305 "Supported GSO types: TCP/IPv4, "
5306 "UDP/IPv4, VxLAN with inner "
5307 "TCP/IPv4 packet, GRE with inner "
5308 "TCP/IPv4 packet\n",
5309 gso_max_segment_size);
5311 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5315 cmdline_parse_token_string_t cmd_gso_show_show =
5316 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5318 cmdline_parse_token_string_t cmd_gso_show_port =
5319 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5321 cmdline_parse_token_string_t cmd_gso_show_keyword =
5322 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5323 cmd_keyword, "gso");
5324 cmdline_parse_token_num_t cmd_gso_show_pid =
5325 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5328 cmdline_parse_inst_t cmd_gso_show = {
5329 .f = cmd_gso_show_parsed,
5331 .help_str = "show port <port_id> gso",
5333 (void *)&cmd_gso_show_show,
5334 (void *)&cmd_gso_show_port,
5335 (void *)&cmd_gso_show_pid,
5336 (void *)&cmd_gso_show_keyword,
5341 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5342 struct cmd_set_flush_rx {
5343 cmdline_fixed_string_t set;
5344 cmdline_fixed_string_t flush_rx;
5345 cmdline_fixed_string_t mode;
5349 cmd_set_flush_rx_parsed(void *parsed_result,
5350 __rte_unused struct cmdline *cl,
5351 __rte_unused void *data)
5353 struct cmd_set_flush_rx *res = parsed_result;
5354 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5357 cmdline_parse_token_string_t cmd_setflushrx_set =
5358 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5360 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5361 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5362 flush_rx, "flush_rx");
5363 cmdline_parse_token_string_t cmd_setflushrx_mode =
5364 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5368 cmdline_parse_inst_t cmd_set_flush_rx = {
5369 .f = cmd_set_flush_rx_parsed,
5370 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5373 (void *)&cmd_setflushrx_set,
5374 (void *)&cmd_setflushrx_flush_rx,
5375 (void *)&cmd_setflushrx_mode,
5380 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5381 struct cmd_set_link_check {
5382 cmdline_fixed_string_t set;
5383 cmdline_fixed_string_t link_check;
5384 cmdline_fixed_string_t mode;
5388 cmd_set_link_check_parsed(void *parsed_result,
5389 __rte_unused struct cmdline *cl,
5390 __rte_unused void *data)
5392 struct cmd_set_link_check *res = parsed_result;
5393 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5396 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5397 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5399 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5400 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5401 link_check, "link_check");
5402 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5403 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5407 cmdline_parse_inst_t cmd_set_link_check = {
5408 .f = cmd_set_link_check_parsed,
5409 .help_str = "set link_check on|off: Enable/Disable link status check "
5410 "when starting/stopping a port",
5413 (void *)&cmd_setlinkcheck_set,
5414 (void *)&cmd_setlinkcheck_link_check,
5415 (void *)&cmd_setlinkcheck_mode,
5420 /* *** SET NIC BYPASS MODE *** */
5421 struct cmd_set_bypass_mode_result {
5422 cmdline_fixed_string_t set;
5423 cmdline_fixed_string_t bypass;
5424 cmdline_fixed_string_t mode;
5425 cmdline_fixed_string_t value;
5430 cmd_set_bypass_mode_parsed(void *parsed_result,
5431 __rte_unused struct cmdline *cl,
5432 __rte_unused void *data)
5434 struct cmd_set_bypass_mode_result *res = parsed_result;
5435 portid_t port_id = res->port_id;
5436 int32_t rc = -EINVAL;
5438 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5439 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5441 if (!strcmp(res->value, "bypass"))
5442 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5443 else if (!strcmp(res->value, "isolate"))
5444 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5446 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5448 /* Set the bypass mode for the relevant port. */
5449 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5452 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5455 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5456 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5458 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5459 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5461 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5462 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5464 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5465 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5466 value, "normal#bypass#isolate");
5467 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5468 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5471 cmdline_parse_inst_t cmd_set_bypass_mode = {
5472 .f = cmd_set_bypass_mode_parsed,
5473 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5474 "Set the NIC bypass mode for port_id",
5477 (void *)&cmd_setbypass_mode_set,
5478 (void *)&cmd_setbypass_mode_bypass,
5479 (void *)&cmd_setbypass_mode_mode,
5480 (void *)&cmd_setbypass_mode_value,
5481 (void *)&cmd_setbypass_mode_port,
5486 /* *** SET NIC BYPASS EVENT *** */
5487 struct cmd_set_bypass_event_result {
5488 cmdline_fixed_string_t set;
5489 cmdline_fixed_string_t bypass;
5490 cmdline_fixed_string_t event;
5491 cmdline_fixed_string_t event_value;
5492 cmdline_fixed_string_t mode;
5493 cmdline_fixed_string_t mode_value;
5498 cmd_set_bypass_event_parsed(void *parsed_result,
5499 __rte_unused struct cmdline *cl,
5500 __rte_unused void *data)
5502 int32_t rc = -EINVAL;
5503 struct cmd_set_bypass_event_result *res = parsed_result;
5504 portid_t port_id = res->port_id;
5506 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5507 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5508 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5510 if (!strcmp(res->event_value, "timeout"))
5511 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5512 else if (!strcmp(res->event_value, "os_on"))
5513 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5514 else if (!strcmp(res->event_value, "os_off"))
5515 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5516 else if (!strcmp(res->event_value, "power_on"))
5517 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5518 else if (!strcmp(res->event_value, "power_off"))
5519 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5521 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5523 if (!strcmp(res->mode_value, "bypass"))
5524 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5525 else if (!strcmp(res->mode_value, "isolate"))
5526 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5528 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5530 /* Set the watchdog timeout. */
5531 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5534 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5535 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5539 printf("Failed to set timeout value %u "
5540 "for port %d, errto code: %d.\n",
5541 bypass_timeout, port_id, rc);
5545 /* Set the bypass event to transition to bypass mode. */
5546 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5551 printf("\t Failed to set bypass event for port = %d.\n",
5555 cmdline_parse_token_string_t cmd_setbypass_event_set =
5556 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5558 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5559 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5561 cmdline_parse_token_string_t cmd_setbypass_event_event =
5562 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5564 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5565 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5566 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5567 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5568 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5570 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5571 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5572 mode_value, "normal#bypass#isolate");
5573 cmdline_parse_token_num_t cmd_setbypass_event_port =
5574 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5577 cmdline_parse_inst_t cmd_set_bypass_event = {
5578 .f = cmd_set_bypass_event_parsed,
5579 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5580 "power_off mode normal|bypass|isolate <port_id>: "
5581 "Set the NIC bypass event mode for port_id",
5584 (void *)&cmd_setbypass_event_set,
5585 (void *)&cmd_setbypass_event_bypass,
5586 (void *)&cmd_setbypass_event_event,
5587 (void *)&cmd_setbypass_event_event_value,
5588 (void *)&cmd_setbypass_event_mode,
5589 (void *)&cmd_setbypass_event_mode_value,
5590 (void *)&cmd_setbypass_event_port,
5596 /* *** SET NIC BYPASS TIMEOUT *** */
5597 struct cmd_set_bypass_timeout_result {
5598 cmdline_fixed_string_t set;
5599 cmdline_fixed_string_t bypass;
5600 cmdline_fixed_string_t timeout;
5601 cmdline_fixed_string_t value;
5605 cmd_set_bypass_timeout_parsed(void *parsed_result,
5606 __rte_unused struct cmdline *cl,
5607 __rte_unused void *data)
5609 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5611 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5612 if (!strcmp(res->value, "1.5"))
5613 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5614 else if (!strcmp(res->value, "2"))
5615 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5616 else if (!strcmp(res->value, "3"))
5617 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5618 else if (!strcmp(res->value, "4"))
5619 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5620 else if (!strcmp(res->value, "8"))
5621 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5622 else if (!strcmp(res->value, "16"))
5623 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5624 else if (!strcmp(res->value, "32"))
5625 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5627 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5631 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5632 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5634 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5635 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5637 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5638 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5639 timeout, "timeout");
5640 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5641 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5642 value, "0#1.5#2#3#4#8#16#32");
5644 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5645 .f = cmd_set_bypass_timeout_parsed,
5646 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5647 "Set the NIC bypass watchdog timeout in seconds",
5650 (void *)&cmd_setbypass_timeout_set,
5651 (void *)&cmd_setbypass_timeout_bypass,
5652 (void *)&cmd_setbypass_timeout_timeout,
5653 (void *)&cmd_setbypass_timeout_value,
5658 /* *** SHOW NIC BYPASS MODE *** */
5659 struct cmd_show_bypass_config_result {
5660 cmdline_fixed_string_t show;
5661 cmdline_fixed_string_t bypass;
5662 cmdline_fixed_string_t config;
5667 cmd_show_bypass_config_parsed(void *parsed_result,
5668 __rte_unused struct cmdline *cl,
5669 __rte_unused void *data)
5671 struct cmd_show_bypass_config_result *res = parsed_result;
5672 portid_t port_id = res->port_id;
5674 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5675 uint32_t event_mode;
5676 uint32_t bypass_mode;
5677 uint32_t timeout = bypass_timeout;
5680 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5681 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5682 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5683 {"UNKNOWN", "normal", "bypass", "isolate"};
5684 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5692 /* Display the bypass mode.*/
5693 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5694 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5698 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5699 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5701 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5704 /* Display the bypass timeout.*/
5705 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5706 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5708 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5710 /* Display the bypass events and associated modes. */
5711 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5713 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5714 printf("\tFailed to get bypass mode for event = %s\n",
5717 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5718 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5720 printf("\tbypass event: %-16s = %s\n", events[i],
5726 printf("\tFailed to get bypass configuration for port = %d\n",
5730 cmdline_parse_token_string_t cmd_showbypass_config_show =
5731 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5733 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5734 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5736 cmdline_parse_token_string_t cmd_showbypass_config_config =
5737 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5739 cmdline_parse_token_num_t cmd_showbypass_config_port =
5740 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5743 cmdline_parse_inst_t cmd_show_bypass_config = {
5744 .f = cmd_show_bypass_config_parsed,
5745 .help_str = "show bypass config <port_id>: "
5746 "Show the NIC bypass config for port_id",
5749 (void *)&cmd_showbypass_config_show,
5750 (void *)&cmd_showbypass_config_bypass,
5751 (void *)&cmd_showbypass_config_config,
5752 (void *)&cmd_showbypass_config_port,
5758 /* *** SET BONDING MODE *** */
5759 struct cmd_set_bonding_mode_result {
5760 cmdline_fixed_string_t set;
5761 cmdline_fixed_string_t bonding;
5762 cmdline_fixed_string_t mode;
5767 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5768 __rte_unused struct cmdline *cl,
5769 __rte_unused void *data)
5771 struct cmd_set_bonding_mode_result *res = parsed_result;
5772 portid_t port_id = res->port_id;
5774 /* Set the bonding mode for the relevant port. */
5775 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5776 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5779 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5780 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5782 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5783 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5784 bonding, "bonding");
5785 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5786 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5788 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5789 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5791 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5792 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5795 cmdline_parse_inst_t cmd_set_bonding_mode = {
5796 .f = cmd_set_bonding_mode_parsed,
5797 .help_str = "set bonding mode <mode_value> <port_id>: "
5798 "Set the bonding mode for port_id",
5801 (void *) &cmd_setbonding_mode_set,
5802 (void *) &cmd_setbonding_mode_bonding,
5803 (void *) &cmd_setbonding_mode_mode,
5804 (void *) &cmd_setbonding_mode_value,
5805 (void *) &cmd_setbonding_mode_port,
5810 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5811 struct cmd_set_bonding_lacp_dedicated_queues_result {
5812 cmdline_fixed_string_t set;
5813 cmdline_fixed_string_t bonding;
5814 cmdline_fixed_string_t lacp;
5815 cmdline_fixed_string_t dedicated_queues;
5817 cmdline_fixed_string_t mode;
5820 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5821 __rte_unused struct cmdline *cl,
5822 __rte_unused void *data)
5824 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5825 portid_t port_id = res->port_id;
5826 struct rte_port *port;
5828 port = &ports[port_id];
5830 /** Check if the port is not started **/
5831 if (port->port_status != RTE_PORT_STOPPED) {
5832 printf("Please stop port %d first\n", port_id);
5836 if (!strcmp(res->mode, "enable")) {
5837 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5838 printf("Dedicate queues for LACP control packets"
5841 printf("Enabling dedicate queues for LACP control "
5842 "packets on port %d failed\n", port_id);
5843 } else if (!strcmp(res->mode, "disable")) {
5844 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5845 printf("Dedicated queues for LACP control packets "
5848 printf("Disabling dedicated queues for LACP control "
5849 "traffic on port %d failed\n", port_id);
5853 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5854 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5856 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5857 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5858 bonding, "bonding");
5859 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5860 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5862 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5863 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5864 dedicated_queues, "dedicated_queues");
5865 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5866 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5868 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5869 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5870 mode, "enable#disable");
5872 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5873 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5874 .help_str = "set bonding lacp dedicated_queues <port_id> "
5876 "Enable/disable dedicated queues for LACP control traffic for port_id",
5879 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5880 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5881 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5882 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5883 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5884 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5889 /* *** SET BALANCE XMIT POLICY *** */
5890 struct cmd_set_bonding_balance_xmit_policy_result {
5891 cmdline_fixed_string_t set;
5892 cmdline_fixed_string_t bonding;
5893 cmdline_fixed_string_t balance_xmit_policy;
5895 cmdline_fixed_string_t policy;
5898 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5899 __rte_unused struct cmdline *cl,
5900 __rte_unused void *data)
5902 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5903 portid_t port_id = res->port_id;
5906 if (!strcmp(res->policy, "l2")) {
5907 policy = BALANCE_XMIT_POLICY_LAYER2;
5908 } else if (!strcmp(res->policy, "l23")) {
5909 policy = BALANCE_XMIT_POLICY_LAYER23;
5910 } else if (!strcmp(res->policy, "l34")) {
5911 policy = BALANCE_XMIT_POLICY_LAYER34;
5913 printf("\t Invalid xmit policy selection");
5917 /* Set the bonding mode for the relevant port. */
5918 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5919 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5924 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5925 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5927 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5928 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5929 bonding, "bonding");
5930 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5931 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5932 balance_xmit_policy, "balance_xmit_policy");
5933 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5934 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5936 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5937 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5938 policy, "l2#l23#l34");
5940 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5941 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5942 .help_str = "set bonding balance_xmit_policy <port_id> "
5944 "Set the bonding balance_xmit_policy for port_id",
5947 (void *)&cmd_setbonding_balance_xmit_policy_set,
5948 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5949 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5950 (void *)&cmd_setbonding_balance_xmit_policy_port,
5951 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5956 /* *** SHOW NIC BONDING CONFIGURATION *** */
5957 struct cmd_show_bonding_config_result {
5958 cmdline_fixed_string_t show;
5959 cmdline_fixed_string_t bonding;
5960 cmdline_fixed_string_t config;
5964 static void cmd_show_bonding_config_parsed(void *parsed_result,
5965 __rte_unused struct cmdline *cl,
5966 __rte_unused void *data)
5968 struct cmd_show_bonding_config_result *res = parsed_result;
5969 int bonding_mode, agg_mode;
5970 portid_t slaves[RTE_MAX_ETHPORTS];
5971 int num_slaves, num_active_slaves;
5974 portid_t port_id = res->port_id;
5976 /* Display the bonding mode.*/
5977 bonding_mode = rte_eth_bond_mode_get(port_id);
5978 if (bonding_mode < 0) {
5979 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5982 printf("\tBonding mode: %d\n", bonding_mode);
5984 if (bonding_mode == BONDING_MODE_BALANCE) {
5985 int balance_xmit_policy;
5987 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5988 if (balance_xmit_policy < 0) {
5989 printf("\tFailed to get balance xmit policy for port = %d\n",
5993 printf("\tBalance Xmit Policy: ");
5995 switch (balance_xmit_policy) {
5996 case BALANCE_XMIT_POLICY_LAYER2:
5997 printf("BALANCE_XMIT_POLICY_LAYER2");
5999 case BALANCE_XMIT_POLICY_LAYER23:
6000 printf("BALANCE_XMIT_POLICY_LAYER23");
6002 case BALANCE_XMIT_POLICY_LAYER34:
6003 printf("BALANCE_XMIT_POLICY_LAYER34");
6010 if (bonding_mode == BONDING_MODE_8023AD) {
6011 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6012 printf("\tIEEE802.3AD Aggregator Mode: ");
6015 printf("bandwidth");
6027 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6029 if (num_slaves < 0) {
6030 printf("\tFailed to get slave list for port = %d\n", port_id);
6033 if (num_slaves > 0) {
6034 printf("\tSlaves (%d): [", num_slaves);
6035 for (i = 0; i < num_slaves - 1; i++)
6036 printf("%d ", slaves[i]);
6038 printf("%d]\n", slaves[num_slaves - 1]);
6040 printf("\tSlaves: []\n");
6044 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6047 if (num_active_slaves < 0) {
6048 printf("\tFailed to get active slave list for port = %d\n", port_id);
6051 if (num_active_slaves > 0) {
6052 printf("\tActive Slaves (%d): [", num_active_slaves);
6053 for (i = 0; i < num_active_slaves - 1; i++)
6054 printf("%d ", slaves[i]);
6056 printf("%d]\n", slaves[num_active_slaves - 1]);
6059 printf("\tActive Slaves: []\n");
6063 primary_id = rte_eth_bond_primary_get(port_id);
6064 if (primary_id < 0) {
6065 printf("\tFailed to get primary slave for port = %d\n", port_id);
6068 printf("\tPrimary: [%d]\n", primary_id);
6072 cmdline_parse_token_string_t cmd_showbonding_config_show =
6073 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6075 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6076 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6077 bonding, "bonding");
6078 cmdline_parse_token_string_t cmd_showbonding_config_config =
6079 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6081 cmdline_parse_token_num_t cmd_showbonding_config_port =
6082 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6085 cmdline_parse_inst_t cmd_show_bonding_config = {
6086 .f = cmd_show_bonding_config_parsed,
6087 .help_str = "show bonding config <port_id>: "
6088 "Show the bonding config for port_id",
6091 (void *)&cmd_showbonding_config_show,
6092 (void *)&cmd_showbonding_config_bonding,
6093 (void *)&cmd_showbonding_config_config,
6094 (void *)&cmd_showbonding_config_port,
6099 /* *** SET BONDING PRIMARY *** */
6100 struct cmd_set_bonding_primary_result {
6101 cmdline_fixed_string_t set;
6102 cmdline_fixed_string_t bonding;
6103 cmdline_fixed_string_t primary;
6108 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6109 __rte_unused struct cmdline *cl,
6110 __rte_unused void *data)
6112 struct cmd_set_bonding_primary_result *res = parsed_result;
6113 portid_t master_port_id = res->port_id;
6114 portid_t slave_port_id = res->slave_id;
6116 /* Set the primary slave for a bonded device. */
6117 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6118 printf("\t Failed to set primary slave for port = %d.\n",
6125 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6126 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6128 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6129 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6130 bonding, "bonding");
6131 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6132 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6133 primary, "primary");
6134 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6135 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6137 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6138 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6141 cmdline_parse_inst_t cmd_set_bonding_primary = {
6142 .f = cmd_set_bonding_primary_parsed,
6143 .help_str = "set bonding primary <slave_id> <port_id>: "
6144 "Set the primary slave for port_id",
6147 (void *)&cmd_setbonding_primary_set,
6148 (void *)&cmd_setbonding_primary_bonding,
6149 (void *)&cmd_setbonding_primary_primary,
6150 (void *)&cmd_setbonding_primary_slave,
6151 (void *)&cmd_setbonding_primary_port,
6156 /* *** ADD SLAVE *** */
6157 struct cmd_add_bonding_slave_result {
6158 cmdline_fixed_string_t add;
6159 cmdline_fixed_string_t bonding;
6160 cmdline_fixed_string_t slave;
6165 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6166 __rte_unused struct cmdline *cl,
6167 __rte_unused void *data)
6169 struct cmd_add_bonding_slave_result *res = parsed_result;
6170 portid_t master_port_id = res->port_id;
6171 portid_t slave_port_id = res->slave_id;
6173 /* add the slave for a bonded device. */
6174 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6175 printf("\t Failed to add slave %d to master port = %d.\n",
6176 slave_port_id, master_port_id);
6180 set_port_slave_flag(slave_port_id);
6183 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6184 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6186 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6187 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6188 bonding, "bonding");
6189 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6190 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6192 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6193 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6195 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6196 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6199 cmdline_parse_inst_t cmd_add_bonding_slave = {
6200 .f = cmd_add_bonding_slave_parsed,
6201 .help_str = "add bonding slave <slave_id> <port_id>: "
6202 "Add a slave device to a bonded device",
6205 (void *)&cmd_addbonding_slave_add,
6206 (void *)&cmd_addbonding_slave_bonding,
6207 (void *)&cmd_addbonding_slave_slave,
6208 (void *)&cmd_addbonding_slave_slaveid,
6209 (void *)&cmd_addbonding_slave_port,
6214 /* *** REMOVE SLAVE *** */
6215 struct cmd_remove_bonding_slave_result {
6216 cmdline_fixed_string_t remove;
6217 cmdline_fixed_string_t bonding;
6218 cmdline_fixed_string_t slave;
6223 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6224 __rte_unused struct cmdline *cl,
6225 __rte_unused void *data)
6227 struct cmd_remove_bonding_slave_result *res = parsed_result;
6228 portid_t master_port_id = res->port_id;
6229 portid_t slave_port_id = res->slave_id;
6231 /* remove the slave from a bonded device. */
6232 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6233 printf("\t Failed to remove slave %d from master port = %d.\n",
6234 slave_port_id, master_port_id);
6238 clear_port_slave_flag(slave_port_id);
6241 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6242 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6244 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6245 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6246 bonding, "bonding");
6247 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6248 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6250 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6251 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6253 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6254 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6257 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6258 .f = cmd_remove_bonding_slave_parsed,
6259 .help_str = "remove bonding slave <slave_id> <port_id>: "
6260 "Remove a slave device from a bonded device",
6263 (void *)&cmd_removebonding_slave_remove,
6264 (void *)&cmd_removebonding_slave_bonding,
6265 (void *)&cmd_removebonding_slave_slave,
6266 (void *)&cmd_removebonding_slave_slaveid,
6267 (void *)&cmd_removebonding_slave_port,
6272 /* *** CREATE BONDED DEVICE *** */
6273 struct cmd_create_bonded_device_result {
6274 cmdline_fixed_string_t create;
6275 cmdline_fixed_string_t bonded;
6276 cmdline_fixed_string_t device;
6281 static int bond_dev_num = 0;
6283 static void cmd_create_bonded_device_parsed(void *parsed_result,
6284 __rte_unused struct cmdline *cl,
6285 __rte_unused void *data)
6287 struct cmd_create_bonded_device_result *res = parsed_result;
6288 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6292 if (test_done == 0) {
6293 printf("Please stop forwarding first\n");
6297 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6300 /* Create a new bonded device. */
6301 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6303 printf("\t Failed to create bonded device.\n");
6306 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6309 /* Update number of ports */
6310 nb_ports = rte_eth_dev_count_avail();
6311 reconfig(port_id, res->socket);
6312 ret = rte_eth_promiscuous_enable(port_id);
6314 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6315 port_id, rte_strerror(-ret));
6317 ports[port_id].need_setup = 0;
6318 ports[port_id].port_status = RTE_PORT_STOPPED;
6323 cmdline_parse_token_string_t cmd_createbonded_device_create =
6324 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6326 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6327 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6329 cmdline_parse_token_string_t cmd_createbonded_device_device =
6330 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6332 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6333 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6335 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6336 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6339 cmdline_parse_inst_t cmd_create_bonded_device = {
6340 .f = cmd_create_bonded_device_parsed,
6341 .help_str = "create bonded device <mode> <socket>: "
6342 "Create a new bonded device with specific bonding mode and socket",
6345 (void *)&cmd_createbonded_device_create,
6346 (void *)&cmd_createbonded_device_bonded,
6347 (void *)&cmd_createbonded_device_device,
6348 (void *)&cmd_createbonded_device_mode,
6349 (void *)&cmd_createbonded_device_socket,
6354 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6355 struct cmd_set_bond_mac_addr_result {
6356 cmdline_fixed_string_t set;
6357 cmdline_fixed_string_t bonding;
6358 cmdline_fixed_string_t mac_addr;
6360 struct rte_ether_addr address;
6363 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6364 __rte_unused struct cmdline *cl,
6365 __rte_unused void *data)
6367 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6370 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6373 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6375 /* check the return value and print it if is < 0 */
6377 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6380 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6381 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6382 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6383 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6385 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6386 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6388 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6389 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6391 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6392 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6394 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6395 .f = cmd_set_bond_mac_addr_parsed,
6397 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6399 (void *)&cmd_set_bond_mac_addr_set,
6400 (void *)&cmd_set_bond_mac_addr_bonding,
6401 (void *)&cmd_set_bond_mac_addr_mac,
6402 (void *)&cmd_set_bond_mac_addr_portnum,
6403 (void *)&cmd_set_bond_mac_addr_addr,
6409 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6410 struct cmd_set_bond_mon_period_result {
6411 cmdline_fixed_string_t set;
6412 cmdline_fixed_string_t bonding;
6413 cmdline_fixed_string_t mon_period;
6418 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6419 __rte_unused struct cmdline *cl,
6420 __rte_unused void *data)
6422 struct cmd_set_bond_mon_period_result *res = parsed_result;
6425 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6427 /* check the return value and print it if is < 0 */
6429 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6432 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6433 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6435 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6436 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6437 bonding, "bonding");
6438 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6439 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6440 mon_period, "mon_period");
6441 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6442 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6444 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6445 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6448 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6449 .f = cmd_set_bond_mon_period_parsed,
6451 .help_str = "set bonding mon_period <port_id> <period_ms>",
6453 (void *)&cmd_set_bond_mon_period_set,
6454 (void *)&cmd_set_bond_mon_period_bonding,
6455 (void *)&cmd_set_bond_mon_period_mon_period,
6456 (void *)&cmd_set_bond_mon_period_portnum,
6457 (void *)&cmd_set_bond_mon_period_period_ms,
6464 struct cmd_set_bonding_agg_mode_policy_result {
6465 cmdline_fixed_string_t set;
6466 cmdline_fixed_string_t bonding;
6467 cmdline_fixed_string_t agg_mode;
6469 cmdline_fixed_string_t policy;
6474 cmd_set_bonding_agg_mode(void *parsed_result,
6475 __rte_unused struct cmdline *cl,
6476 __rte_unused void *data)
6478 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6479 uint8_t policy = AGG_BANDWIDTH;
6481 if (!strcmp(res->policy, "bandwidth"))
6482 policy = AGG_BANDWIDTH;
6483 else if (!strcmp(res->policy, "stable"))
6484 policy = AGG_STABLE;
6485 else if (!strcmp(res->policy, "count"))
6488 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6492 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6493 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6495 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6496 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6497 bonding, "bonding");
6499 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6500 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6501 agg_mode, "agg_mode");
6503 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6504 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6507 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6508 TOKEN_STRING_INITIALIZER(
6509 struct cmd_set_bonding_balance_xmit_policy_result,
6510 policy, "stable#bandwidth#count");
6512 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6513 .f = cmd_set_bonding_agg_mode,
6515 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6517 (void *)&cmd_set_bonding_agg_mode_set,
6518 (void *)&cmd_set_bonding_agg_mode_bonding,
6519 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6520 (void *)&cmd_set_bonding_agg_mode_portnum,
6521 (void *)&cmd_set_bonding_agg_mode_policy_string,
6527 #endif /* RTE_NET_BOND */
6529 /* *** SET FORWARDING MODE *** */
6530 struct cmd_set_fwd_mode_result {
6531 cmdline_fixed_string_t set;
6532 cmdline_fixed_string_t fwd;
6533 cmdline_fixed_string_t mode;
6536 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6537 __rte_unused struct cmdline *cl,
6538 __rte_unused void *data)
6540 struct cmd_set_fwd_mode_result *res = parsed_result;
6543 set_pkt_forwarding_mode(res->mode);
6546 cmdline_parse_token_string_t cmd_setfwd_set =
6547 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6548 cmdline_parse_token_string_t cmd_setfwd_fwd =
6549 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6550 cmdline_parse_token_string_t cmd_setfwd_mode =
6551 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6552 "" /* defined at init */);
6554 cmdline_parse_inst_t cmd_set_fwd_mode = {
6555 .f = cmd_set_fwd_mode_parsed,
6557 .help_str = NULL, /* defined at init */
6559 (void *)&cmd_setfwd_set,
6560 (void *)&cmd_setfwd_fwd,
6561 (void *)&cmd_setfwd_mode,
6566 static void cmd_set_fwd_mode_init(void)
6569 static char token[128];
6570 static char help[256];
6571 cmdline_parse_token_string_t *token_struct;
6573 modes = list_pkt_forwarding_modes();
6574 snprintf(help, sizeof(help), "set fwd %s: "
6575 "Set packet forwarding mode", modes);
6576 cmd_set_fwd_mode.help_str = help;
6578 /* string token separator is # */
6579 for (c = token; *modes != '\0'; modes++)
6584 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6585 token_struct->string_data.str = token;
6588 /* *** SET RETRY FORWARDING MODE *** */
6589 struct cmd_set_fwd_retry_mode_result {
6590 cmdline_fixed_string_t set;
6591 cmdline_fixed_string_t fwd;
6592 cmdline_fixed_string_t mode;
6593 cmdline_fixed_string_t retry;
6596 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6597 __rte_unused struct cmdline *cl,
6598 __rte_unused void *data)
6600 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6603 set_pkt_forwarding_mode(res->mode);
6606 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6607 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6609 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6610 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6612 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6613 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6615 "" /* defined at init */);
6616 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6617 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6620 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6621 .f = cmd_set_fwd_retry_mode_parsed,
6623 .help_str = NULL, /* defined at init */
6625 (void *)&cmd_setfwd_retry_set,
6626 (void *)&cmd_setfwd_retry_fwd,
6627 (void *)&cmd_setfwd_retry_mode,
6628 (void *)&cmd_setfwd_retry_retry,
6633 static void cmd_set_fwd_retry_mode_init(void)
6636 static char token[128];
6637 static char help[256];
6638 cmdline_parse_token_string_t *token_struct;
6640 modes = list_pkt_forwarding_retry_modes();
6641 snprintf(help, sizeof(help), "set fwd %s retry: "
6642 "Set packet forwarding mode with retry", modes);
6643 cmd_set_fwd_retry_mode.help_str = help;
6645 /* string token separator is # */
6646 for (c = token; *modes != '\0'; modes++)
6651 token_struct = (cmdline_parse_token_string_t *)
6652 cmd_set_fwd_retry_mode.tokens[2];
6653 token_struct->string_data.str = token;
6656 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6657 struct cmd_set_burst_tx_retry_result {
6658 cmdline_fixed_string_t set;
6659 cmdline_fixed_string_t burst;
6660 cmdline_fixed_string_t tx;
6661 cmdline_fixed_string_t delay;
6663 cmdline_fixed_string_t retry;
6667 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6668 __rte_unused struct cmdline *cl,
6669 __rte_unused void *data)
6671 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6673 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6674 && !strcmp(res->tx, "tx")) {
6675 if (!strcmp(res->delay, "delay"))
6676 burst_tx_delay_time = res->time;
6677 if (!strcmp(res->retry, "retry"))
6678 burst_tx_retry_num = res->retry_num;
6683 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6684 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6685 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6686 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6688 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6689 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6690 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6691 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6692 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6693 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6694 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6695 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6696 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6697 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6699 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6700 .f = cmd_set_burst_tx_retry_parsed,
6701 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6703 (void *)&cmd_set_burst_tx_retry_set,
6704 (void *)&cmd_set_burst_tx_retry_burst,
6705 (void *)&cmd_set_burst_tx_retry_tx,
6706 (void *)&cmd_set_burst_tx_retry_delay,
6707 (void *)&cmd_set_burst_tx_retry_time,
6708 (void *)&cmd_set_burst_tx_retry_retry,
6709 (void *)&cmd_set_burst_tx_retry_retry_num,
6714 /* *** SET PROMISC MODE *** */
6715 struct cmd_set_promisc_mode_result {
6716 cmdline_fixed_string_t set;
6717 cmdline_fixed_string_t promisc;
6718 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6719 uint16_t port_num; /* valid if "allports" argument == 0 */
6720 cmdline_fixed_string_t mode;
6723 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6724 __rte_unused struct cmdline *cl,
6727 struct cmd_set_promisc_mode_result *res = parsed_result;
6731 if (!strcmp(res->mode, "on"))
6738 RTE_ETH_FOREACH_DEV(i)
6739 eth_set_promisc_mode(i, enable);
6741 eth_set_promisc_mode(res->port_num, enable);
6745 cmdline_parse_token_string_t cmd_setpromisc_set =
6746 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6747 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6748 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6750 cmdline_parse_token_string_t cmd_setpromisc_portall =
6751 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6753 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6754 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6756 cmdline_parse_token_string_t cmd_setpromisc_mode =
6757 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6760 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6761 .f = cmd_set_promisc_mode_parsed,
6763 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6765 (void *)&cmd_setpromisc_set,
6766 (void *)&cmd_setpromisc_promisc,
6767 (void *)&cmd_setpromisc_portall,
6768 (void *)&cmd_setpromisc_mode,
6773 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6774 .f = cmd_set_promisc_mode_parsed,
6776 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6778 (void *)&cmd_setpromisc_set,
6779 (void *)&cmd_setpromisc_promisc,
6780 (void *)&cmd_setpromisc_portnum,
6781 (void *)&cmd_setpromisc_mode,
6786 /* *** SET ALLMULTI MODE *** */
6787 struct cmd_set_allmulti_mode_result {
6788 cmdline_fixed_string_t set;
6789 cmdline_fixed_string_t allmulti;
6790 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6791 uint16_t port_num; /* valid if "allports" argument == 0 */
6792 cmdline_fixed_string_t mode;
6795 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6796 __rte_unused struct cmdline *cl,
6799 struct cmd_set_allmulti_mode_result *res = parsed_result;
6803 if (!strcmp(res->mode, "on"))
6810 RTE_ETH_FOREACH_DEV(i) {
6811 eth_set_allmulticast_mode(i, enable);
6815 eth_set_allmulticast_mode(res->port_num, enable);
6819 cmdline_parse_token_string_t cmd_setallmulti_set =
6820 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6821 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6822 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6824 cmdline_parse_token_string_t cmd_setallmulti_portall =
6825 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6827 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6828 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6830 cmdline_parse_token_string_t cmd_setallmulti_mode =
6831 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6834 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6835 .f = cmd_set_allmulti_mode_parsed,
6837 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6839 (void *)&cmd_setallmulti_set,
6840 (void *)&cmd_setallmulti_allmulti,
6841 (void *)&cmd_setallmulti_portall,
6842 (void *)&cmd_setallmulti_mode,
6847 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6848 .f = cmd_set_allmulti_mode_parsed,
6850 .help_str = "set allmulti <port_id> on|off: "
6851 "Set allmulti mode on port_id",
6853 (void *)&cmd_setallmulti_set,
6854 (void *)&cmd_setallmulti_allmulti,
6855 (void *)&cmd_setallmulti_portnum,
6856 (void *)&cmd_setallmulti_mode,
6861 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6862 struct cmd_link_flow_ctrl_set_result {
6863 cmdline_fixed_string_t set;
6864 cmdline_fixed_string_t flow_ctrl;
6865 cmdline_fixed_string_t rx;
6866 cmdline_fixed_string_t rx_lfc_mode;
6867 cmdline_fixed_string_t tx;
6868 cmdline_fixed_string_t tx_lfc_mode;
6869 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6870 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6871 cmdline_fixed_string_t autoneg_str;
6872 cmdline_fixed_string_t autoneg;
6873 cmdline_fixed_string_t hw_str;
6874 uint32_t high_water;
6875 cmdline_fixed_string_t lw_str;
6877 cmdline_fixed_string_t pt_str;
6878 uint16_t pause_time;
6879 cmdline_fixed_string_t xon_str;
6884 cmdline_parse_token_string_t cmd_lfc_set_set =
6885 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6887 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6888 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6889 flow_ctrl, "flow_ctrl");
6890 cmdline_parse_token_string_t cmd_lfc_set_rx =
6891 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6893 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6894 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6895 rx_lfc_mode, "on#off");
6896 cmdline_parse_token_string_t cmd_lfc_set_tx =
6897 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6899 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6900 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6901 tx_lfc_mode, "on#off");
6902 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6903 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6904 hw_str, "high_water");
6905 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6906 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6907 high_water, UINT32);
6908 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6909 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6910 lw_str, "low_water");
6911 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6912 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6914 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6915 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6916 pt_str, "pause_time");
6917 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6918 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6919 pause_time, UINT16);
6920 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6921 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6922 xon_str, "send_xon");
6923 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6924 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6926 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6927 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6928 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6929 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6930 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6931 mac_ctrl_frame_fwd_mode, "on#off");
6932 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6933 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6934 autoneg_str, "autoneg");
6935 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6936 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6938 cmdline_parse_token_num_t cmd_lfc_set_portid =
6939 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6942 /* forward declaration */
6944 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6947 cmdline_parse_inst_t cmd_link_flow_control_set = {
6948 .f = cmd_link_flow_ctrl_set_parsed,
6950 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6951 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6952 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6954 (void *)&cmd_lfc_set_set,
6955 (void *)&cmd_lfc_set_flow_ctrl,
6956 (void *)&cmd_lfc_set_rx,
6957 (void *)&cmd_lfc_set_rx_mode,
6958 (void *)&cmd_lfc_set_tx,
6959 (void *)&cmd_lfc_set_tx_mode,
6960 (void *)&cmd_lfc_set_high_water,
6961 (void *)&cmd_lfc_set_low_water,
6962 (void *)&cmd_lfc_set_pause_time,
6963 (void *)&cmd_lfc_set_send_xon,
6964 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6965 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6966 (void *)&cmd_lfc_set_autoneg_str,
6967 (void *)&cmd_lfc_set_autoneg,
6968 (void *)&cmd_lfc_set_portid,
6973 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6974 .f = cmd_link_flow_ctrl_set_parsed,
6975 .data = (void *)&cmd_link_flow_control_set_rx,
6976 .help_str = "set flow_ctrl rx on|off <port_id>: "
6977 "Change rx flow control parameter",
6979 (void *)&cmd_lfc_set_set,
6980 (void *)&cmd_lfc_set_flow_ctrl,
6981 (void *)&cmd_lfc_set_rx,
6982 (void *)&cmd_lfc_set_rx_mode,
6983 (void *)&cmd_lfc_set_portid,
6988 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6989 .f = cmd_link_flow_ctrl_set_parsed,
6990 .data = (void *)&cmd_link_flow_control_set_tx,
6991 .help_str = "set flow_ctrl tx on|off <port_id>: "
6992 "Change tx flow control parameter",
6994 (void *)&cmd_lfc_set_set,
6995 (void *)&cmd_lfc_set_flow_ctrl,
6996 (void *)&cmd_lfc_set_tx,
6997 (void *)&cmd_lfc_set_tx_mode,
6998 (void *)&cmd_lfc_set_portid,
7003 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7004 .f = cmd_link_flow_ctrl_set_parsed,
7005 .data = (void *)&cmd_link_flow_control_set_hw,
7006 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7007 "Change high water flow control parameter",
7009 (void *)&cmd_lfc_set_set,
7010 (void *)&cmd_lfc_set_flow_ctrl,
7011 (void *)&cmd_lfc_set_high_water_str,
7012 (void *)&cmd_lfc_set_high_water,
7013 (void *)&cmd_lfc_set_portid,
7018 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7019 .f = cmd_link_flow_ctrl_set_parsed,
7020 .data = (void *)&cmd_link_flow_control_set_lw,
7021 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7022 "Change low water flow control parameter",
7024 (void *)&cmd_lfc_set_set,
7025 (void *)&cmd_lfc_set_flow_ctrl,
7026 (void *)&cmd_lfc_set_low_water_str,
7027 (void *)&cmd_lfc_set_low_water,
7028 (void *)&cmd_lfc_set_portid,
7033 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7034 .f = cmd_link_flow_ctrl_set_parsed,
7035 .data = (void *)&cmd_link_flow_control_set_pt,
7036 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7037 "Change pause time flow control parameter",
7039 (void *)&cmd_lfc_set_set,
7040 (void *)&cmd_lfc_set_flow_ctrl,
7041 (void *)&cmd_lfc_set_pause_time_str,
7042 (void *)&cmd_lfc_set_pause_time,
7043 (void *)&cmd_lfc_set_portid,
7048 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7049 .f = cmd_link_flow_ctrl_set_parsed,
7050 .data = (void *)&cmd_link_flow_control_set_xon,
7051 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7052 "Change send_xon flow control parameter",
7054 (void *)&cmd_lfc_set_set,
7055 (void *)&cmd_lfc_set_flow_ctrl,
7056 (void *)&cmd_lfc_set_send_xon_str,
7057 (void *)&cmd_lfc_set_send_xon,
7058 (void *)&cmd_lfc_set_portid,
7063 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7064 .f = cmd_link_flow_ctrl_set_parsed,
7065 .data = (void *)&cmd_link_flow_control_set_macfwd,
7066 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7067 "Change mac ctrl fwd flow control parameter",
7069 (void *)&cmd_lfc_set_set,
7070 (void *)&cmd_lfc_set_flow_ctrl,
7071 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7072 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7073 (void *)&cmd_lfc_set_portid,
7078 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7079 .f = cmd_link_flow_ctrl_set_parsed,
7080 .data = (void *)&cmd_link_flow_control_set_autoneg,
7081 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7082 "Change autoneg flow control parameter",
7084 (void *)&cmd_lfc_set_set,
7085 (void *)&cmd_lfc_set_flow_ctrl,
7086 (void *)&cmd_lfc_set_autoneg_str,
7087 (void *)&cmd_lfc_set_autoneg,
7088 (void *)&cmd_lfc_set_portid,
7094 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7095 __rte_unused struct cmdline *cl,
7098 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7099 cmdline_parse_inst_t *cmd = data;
7100 struct rte_eth_fc_conf fc_conf;
7106 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7107 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7108 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7109 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7111 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7112 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7115 /* Partial command line, retrieve current configuration */
7117 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7119 printf("cannot get current flow ctrl parameters, return"
7120 "code = %d\n", ret);
7124 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7125 (fc_conf.mode == RTE_FC_FULL))
7127 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7128 (fc_conf.mode == RTE_FC_FULL))
7132 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7133 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7135 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7136 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7138 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7140 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7141 fc_conf.high_water = res->high_water;
7143 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7144 fc_conf.low_water = res->low_water;
7146 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7147 fc_conf.pause_time = res->pause_time;
7149 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7150 fc_conf.send_xon = res->send_xon;
7152 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7153 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7154 fc_conf.mac_ctrl_frame_fwd = 1;
7156 fc_conf.mac_ctrl_frame_fwd = 0;
7159 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7160 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7162 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7164 printf("bad flow contrl parameter, return code = %d \n", ret);
7167 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7168 struct cmd_priority_flow_ctrl_set_result {
7169 cmdline_fixed_string_t set;
7170 cmdline_fixed_string_t pfc_ctrl;
7171 cmdline_fixed_string_t rx;
7172 cmdline_fixed_string_t rx_pfc_mode;
7173 cmdline_fixed_string_t tx;
7174 cmdline_fixed_string_t tx_pfc_mode;
7175 uint32_t high_water;
7177 uint16_t pause_time;
7183 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7184 __rte_unused struct cmdline *cl,
7185 __rte_unused void *data)
7187 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7188 struct rte_eth_pfc_conf pfc_conf;
7189 int rx_fc_enable, tx_fc_enable;
7193 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7194 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7195 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7196 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7198 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7199 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7202 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7203 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7204 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7205 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7206 pfc_conf.fc.high_water = res->high_water;
7207 pfc_conf.fc.low_water = res->low_water;
7208 pfc_conf.fc.pause_time = res->pause_time;
7209 pfc_conf.priority = res->priority;
7211 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7213 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7216 cmdline_parse_token_string_t cmd_pfc_set_set =
7217 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7219 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7220 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7221 pfc_ctrl, "pfc_ctrl");
7222 cmdline_parse_token_string_t cmd_pfc_set_rx =
7223 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7225 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7226 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7227 rx_pfc_mode, "on#off");
7228 cmdline_parse_token_string_t cmd_pfc_set_tx =
7229 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7231 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7232 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7233 tx_pfc_mode, "on#off");
7234 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7235 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7236 high_water, UINT32);
7237 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7238 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7240 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7241 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7242 pause_time, UINT16);
7243 cmdline_parse_token_num_t cmd_pfc_set_priority =
7244 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7246 cmdline_parse_token_num_t cmd_pfc_set_portid =
7247 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7250 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7251 .f = cmd_priority_flow_ctrl_set_parsed,
7253 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7254 "<pause_time> <priority> <port_id>: "
7255 "Configure the Ethernet priority flow control",
7257 (void *)&cmd_pfc_set_set,
7258 (void *)&cmd_pfc_set_flow_ctrl,
7259 (void *)&cmd_pfc_set_rx,
7260 (void *)&cmd_pfc_set_rx_mode,
7261 (void *)&cmd_pfc_set_tx,
7262 (void *)&cmd_pfc_set_tx_mode,
7263 (void *)&cmd_pfc_set_high_water,
7264 (void *)&cmd_pfc_set_low_water,
7265 (void *)&cmd_pfc_set_pause_time,
7266 (void *)&cmd_pfc_set_priority,
7267 (void *)&cmd_pfc_set_portid,
7272 /* *** RESET CONFIGURATION *** */
7273 struct cmd_reset_result {
7274 cmdline_fixed_string_t reset;
7275 cmdline_fixed_string_t def;
7278 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7280 __rte_unused void *data)
7282 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7283 set_def_fwd_config();
7286 cmdline_parse_token_string_t cmd_reset_set =
7287 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7288 cmdline_parse_token_string_t cmd_reset_def =
7289 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7292 cmdline_parse_inst_t cmd_reset = {
7293 .f = cmd_reset_parsed,
7295 .help_str = "set default: Reset default forwarding configuration",
7297 (void *)&cmd_reset_set,
7298 (void *)&cmd_reset_def,
7303 /* *** START FORWARDING *** */
7304 struct cmd_start_result {
7305 cmdline_fixed_string_t start;
7308 cmdline_parse_token_string_t cmd_start_start =
7309 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7311 static void cmd_start_parsed(__rte_unused void *parsed_result,
7312 __rte_unused struct cmdline *cl,
7313 __rte_unused void *data)
7315 start_packet_forwarding(0);
7318 cmdline_parse_inst_t cmd_start = {
7319 .f = cmd_start_parsed,
7321 .help_str = "start: Start packet forwarding",
7323 (void *)&cmd_start_start,
7328 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7329 struct cmd_start_tx_first_result {
7330 cmdline_fixed_string_t start;
7331 cmdline_fixed_string_t tx_first;
7335 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7336 __rte_unused struct cmdline *cl,
7337 __rte_unused void *data)
7339 start_packet_forwarding(1);
7342 cmdline_parse_token_string_t cmd_start_tx_first_start =
7343 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7345 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7346 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7347 tx_first, "tx_first");
7349 cmdline_parse_inst_t cmd_start_tx_first = {
7350 .f = cmd_start_tx_first_parsed,
7352 .help_str = "start tx_first: Start packet forwarding, "
7353 "after sending 1 burst of packets",
7355 (void *)&cmd_start_tx_first_start,
7356 (void *)&cmd_start_tx_first_tx_first,
7361 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7362 struct cmd_start_tx_first_n_result {
7363 cmdline_fixed_string_t start;
7364 cmdline_fixed_string_t tx_first;
7369 cmd_start_tx_first_n_parsed(void *parsed_result,
7370 __rte_unused struct cmdline *cl,
7371 __rte_unused void *data)
7373 struct cmd_start_tx_first_n_result *res = parsed_result;
7375 start_packet_forwarding(res->tx_num);
7378 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7379 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7381 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7382 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7383 tx_first, "tx_first");
7384 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7385 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7388 cmdline_parse_inst_t cmd_start_tx_first_n = {
7389 .f = cmd_start_tx_first_n_parsed,
7391 .help_str = "start tx_first <num>: "
7392 "packet forwarding, after sending <num> bursts of packets",
7394 (void *)&cmd_start_tx_first_n_start,
7395 (void *)&cmd_start_tx_first_n_tx_first,
7396 (void *)&cmd_start_tx_first_n_tx_num,
7401 /* *** SET LINK UP *** */
7402 struct cmd_set_link_up_result {
7403 cmdline_fixed_string_t set;
7404 cmdline_fixed_string_t link_up;
7405 cmdline_fixed_string_t port;
7409 cmdline_parse_token_string_t cmd_set_link_up_set =
7410 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7411 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7412 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7414 cmdline_parse_token_string_t cmd_set_link_up_port =
7415 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7416 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7417 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7419 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7420 __rte_unused struct cmdline *cl,
7421 __rte_unused void *data)
7423 struct cmd_set_link_up_result *res = parsed_result;
7424 dev_set_link_up(res->port_id);
7427 cmdline_parse_inst_t cmd_set_link_up = {
7428 .f = cmd_set_link_up_parsed,
7430 .help_str = "set link-up port <port id>",
7432 (void *)&cmd_set_link_up_set,
7433 (void *)&cmd_set_link_up_link_up,
7434 (void *)&cmd_set_link_up_port,
7435 (void *)&cmd_set_link_up_port_id,
7440 /* *** SET LINK DOWN *** */
7441 struct cmd_set_link_down_result {
7442 cmdline_fixed_string_t set;
7443 cmdline_fixed_string_t link_down;
7444 cmdline_fixed_string_t port;
7448 cmdline_parse_token_string_t cmd_set_link_down_set =
7449 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7450 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7451 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7453 cmdline_parse_token_string_t cmd_set_link_down_port =
7454 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7455 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7456 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7458 static void cmd_set_link_down_parsed(
7459 __rte_unused void *parsed_result,
7460 __rte_unused struct cmdline *cl,
7461 __rte_unused void *data)
7463 struct cmd_set_link_down_result *res = parsed_result;
7464 dev_set_link_down(res->port_id);
7467 cmdline_parse_inst_t cmd_set_link_down = {
7468 .f = cmd_set_link_down_parsed,
7470 .help_str = "set link-down port <port id>",
7472 (void *)&cmd_set_link_down_set,
7473 (void *)&cmd_set_link_down_link_down,
7474 (void *)&cmd_set_link_down_port,
7475 (void *)&cmd_set_link_down_port_id,
7480 /* *** SHOW CFG *** */
7481 struct cmd_showcfg_result {
7482 cmdline_fixed_string_t show;
7483 cmdline_fixed_string_t cfg;
7484 cmdline_fixed_string_t what;
7487 static void cmd_showcfg_parsed(void *parsed_result,
7488 __rte_unused struct cmdline *cl,
7489 __rte_unused void *data)
7491 struct cmd_showcfg_result *res = parsed_result;
7492 if (!strcmp(res->what, "rxtx"))
7493 rxtx_config_display();
7494 else if (!strcmp(res->what, "cores"))
7495 fwd_lcores_config_display();
7496 else if (!strcmp(res->what, "fwd"))
7497 pkt_fwd_config_display(&cur_fwd_config);
7498 else if (!strcmp(res->what, "rxoffs"))
7499 show_rx_pkt_offsets();
7500 else if (!strcmp(res->what, "rxpkts"))
7501 show_rx_pkt_segments();
7502 else if (!strcmp(res->what, "txpkts"))
7503 show_tx_pkt_segments();
7504 else if (!strcmp(res->what, "txtimes"))
7505 show_tx_pkt_times();
7508 cmdline_parse_token_string_t cmd_showcfg_show =
7509 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7510 cmdline_parse_token_string_t cmd_showcfg_port =
7511 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7512 cmdline_parse_token_string_t cmd_showcfg_what =
7513 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7514 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7516 cmdline_parse_inst_t cmd_showcfg = {
7517 .f = cmd_showcfg_parsed,
7519 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7521 (void *)&cmd_showcfg_show,
7522 (void *)&cmd_showcfg_port,
7523 (void *)&cmd_showcfg_what,
7528 /* *** SHOW ALL PORT INFO *** */
7529 struct cmd_showportall_result {
7530 cmdline_fixed_string_t show;
7531 cmdline_fixed_string_t port;
7532 cmdline_fixed_string_t what;
7533 cmdline_fixed_string_t all;
7536 static void cmd_showportall_parsed(void *parsed_result,
7537 __rte_unused struct cmdline *cl,
7538 __rte_unused void *data)
7542 struct cmd_showportall_result *res = parsed_result;
7543 if (!strcmp(res->show, "clear")) {
7544 if (!strcmp(res->what, "stats"))
7545 RTE_ETH_FOREACH_DEV(i)
7547 else if (!strcmp(res->what, "xstats"))
7548 RTE_ETH_FOREACH_DEV(i)
7549 nic_xstats_clear(i);
7550 } else if (!strcmp(res->what, "info"))
7551 RTE_ETH_FOREACH_DEV(i)
7552 port_infos_display(i);
7553 else if (!strcmp(res->what, "summary")) {
7554 port_summary_header_display();
7555 RTE_ETH_FOREACH_DEV(i)
7556 port_summary_display(i);
7558 else if (!strcmp(res->what, "stats"))
7559 RTE_ETH_FOREACH_DEV(i)
7560 nic_stats_display(i);
7561 else if (!strcmp(res->what, "xstats"))
7562 RTE_ETH_FOREACH_DEV(i)
7563 nic_xstats_display(i);
7564 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7565 else if (!strcmp(res->what, "fdir"))
7566 RTE_ETH_FOREACH_DEV(i)
7569 else if (!strcmp(res->what, "stat_qmap"))
7570 RTE_ETH_FOREACH_DEV(i)
7571 nic_stats_mapping_display(i);
7572 else if (!strcmp(res->what, "dcb_tc"))
7573 RTE_ETH_FOREACH_DEV(i)
7574 port_dcb_info_display(i);
7575 else if (!strcmp(res->what, "cap"))
7576 RTE_ETH_FOREACH_DEV(i)
7577 port_offload_cap_display(i);
7580 cmdline_parse_token_string_t cmd_showportall_show =
7581 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7583 cmdline_parse_token_string_t cmd_showportall_port =
7584 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7585 cmdline_parse_token_string_t cmd_showportall_what =
7586 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7587 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7588 cmdline_parse_token_string_t cmd_showportall_all =
7589 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7590 cmdline_parse_inst_t cmd_showportall = {
7591 .f = cmd_showportall_parsed,
7593 .help_str = "show|clear port "
7594 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7596 (void *)&cmd_showportall_show,
7597 (void *)&cmd_showportall_port,
7598 (void *)&cmd_showportall_what,
7599 (void *)&cmd_showportall_all,
7604 /* *** SHOW PORT INFO *** */
7605 struct cmd_showport_result {
7606 cmdline_fixed_string_t show;
7607 cmdline_fixed_string_t port;
7608 cmdline_fixed_string_t what;
7612 static void cmd_showport_parsed(void *parsed_result,
7613 __rte_unused struct cmdline *cl,
7614 __rte_unused void *data)
7616 struct cmd_showport_result *res = parsed_result;
7617 if (!strcmp(res->show, "clear")) {
7618 if (!strcmp(res->what, "stats"))
7619 nic_stats_clear(res->portnum);
7620 else if (!strcmp(res->what, "xstats"))
7621 nic_xstats_clear(res->portnum);
7622 } else if (!strcmp(res->what, "info"))
7623 port_infos_display(res->portnum);
7624 else if (!strcmp(res->what, "summary")) {
7625 port_summary_header_display();
7626 port_summary_display(res->portnum);
7628 else if (!strcmp(res->what, "stats"))
7629 nic_stats_display(res->portnum);
7630 else if (!strcmp(res->what, "xstats"))
7631 nic_xstats_display(res->portnum);
7632 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7633 else if (!strcmp(res->what, "fdir"))
7634 fdir_get_infos(res->portnum);
7636 else if (!strcmp(res->what, "stat_qmap"))
7637 nic_stats_mapping_display(res->portnum);
7638 else if (!strcmp(res->what, "dcb_tc"))
7639 port_dcb_info_display(res->portnum);
7640 else if (!strcmp(res->what, "cap"))
7641 port_offload_cap_display(res->portnum);
7644 cmdline_parse_token_string_t cmd_showport_show =
7645 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7647 cmdline_parse_token_string_t cmd_showport_port =
7648 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7649 cmdline_parse_token_string_t cmd_showport_what =
7650 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7651 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7652 cmdline_parse_token_num_t cmd_showport_portnum =
7653 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7655 cmdline_parse_inst_t cmd_showport = {
7656 .f = cmd_showport_parsed,
7658 .help_str = "show|clear port "
7659 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7662 (void *)&cmd_showport_show,
7663 (void *)&cmd_showport_port,
7664 (void *)&cmd_showport_what,
7665 (void *)&cmd_showport_portnum,
7670 /* *** SHOW DEVICE INFO *** */
7671 struct cmd_showdevice_result {
7672 cmdline_fixed_string_t show;
7673 cmdline_fixed_string_t device;
7674 cmdline_fixed_string_t what;
7675 cmdline_fixed_string_t identifier;
7678 static void cmd_showdevice_parsed(void *parsed_result,
7679 __rte_unused struct cmdline *cl,
7680 __rte_unused void *data)
7682 struct cmd_showdevice_result *res = parsed_result;
7683 if (!strcmp(res->what, "info")) {
7684 if (!strcmp(res->identifier, "all"))
7685 device_infos_display(NULL);
7687 device_infos_display(res->identifier);
7691 cmdline_parse_token_string_t cmd_showdevice_show =
7692 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7694 cmdline_parse_token_string_t cmd_showdevice_device =
7695 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7696 cmdline_parse_token_string_t cmd_showdevice_what =
7697 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7699 cmdline_parse_token_string_t cmd_showdevice_identifier =
7700 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7703 cmdline_parse_inst_t cmd_showdevice = {
7704 .f = cmd_showdevice_parsed,
7706 .help_str = "show device info <identifier>|all",
7708 (void *)&cmd_showdevice_show,
7709 (void *)&cmd_showdevice_device,
7710 (void *)&cmd_showdevice_what,
7711 (void *)&cmd_showdevice_identifier,
7716 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7717 struct cmd_showeeprom_result {
7718 cmdline_fixed_string_t show;
7719 cmdline_fixed_string_t port;
7721 cmdline_fixed_string_t type;
7724 static void cmd_showeeprom_parsed(void *parsed_result,
7725 __rte_unused struct cmdline *cl,
7726 __rte_unused void *data)
7728 struct cmd_showeeprom_result *res = parsed_result;
7730 if (!strcmp(res->type, "eeprom"))
7731 port_eeprom_display(res->portnum);
7732 else if (!strcmp(res->type, "module_eeprom"))
7733 port_module_eeprom_display(res->portnum);
7735 printf("Unknown argument\n");
7738 cmdline_parse_token_string_t cmd_showeeprom_show =
7739 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7740 cmdline_parse_token_string_t cmd_showeeprom_port =
7741 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7742 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7743 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum, UINT16);
7744 cmdline_parse_token_string_t cmd_showeeprom_type =
7745 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7747 cmdline_parse_inst_t cmd_showeeprom = {
7748 .f = cmd_showeeprom_parsed,
7750 .help_str = "show port <port_id> module_eeprom|eeprom",
7752 (void *)&cmd_showeeprom_show,
7753 (void *)&cmd_showeeprom_port,
7754 (void *)&cmd_showeeprom_portnum,
7755 (void *)&cmd_showeeprom_type,
7760 /* *** SHOW QUEUE INFO *** */
7761 struct cmd_showqueue_result {
7762 cmdline_fixed_string_t show;
7763 cmdline_fixed_string_t type;
7764 cmdline_fixed_string_t what;
7770 cmd_showqueue_parsed(void *parsed_result,
7771 __rte_unused struct cmdline *cl,
7772 __rte_unused void *data)
7774 struct cmd_showqueue_result *res = parsed_result;
7776 if (!strcmp(res->type, "rxq"))
7777 rx_queue_infos_display(res->portnum, res->queuenum);
7778 else if (!strcmp(res->type, "txq"))
7779 tx_queue_infos_display(res->portnum, res->queuenum);
7782 cmdline_parse_token_string_t cmd_showqueue_show =
7783 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7784 cmdline_parse_token_string_t cmd_showqueue_type =
7785 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7786 cmdline_parse_token_string_t cmd_showqueue_what =
7787 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7788 cmdline_parse_token_num_t cmd_showqueue_portnum =
7789 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7790 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7791 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7793 cmdline_parse_inst_t cmd_showqueue = {
7794 .f = cmd_showqueue_parsed,
7796 .help_str = "show rxq|txq info <port_id> <queue_id>",
7798 (void *)&cmd_showqueue_show,
7799 (void *)&cmd_showqueue_type,
7800 (void *)&cmd_showqueue_what,
7801 (void *)&cmd_showqueue_portnum,
7802 (void *)&cmd_showqueue_queuenum,
7807 /* show/clear fwd engine statistics */
7809 cmdline_fixed_string_t action;
7810 cmdline_fixed_string_t fwd;
7811 cmdline_fixed_string_t stats;
7812 cmdline_fixed_string_t all;
7815 cmdline_parse_token_string_t cmd_fwd_action =
7816 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7817 cmdline_parse_token_string_t cmd_fwd_fwd =
7818 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7819 cmdline_parse_token_string_t cmd_fwd_stats =
7820 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7821 cmdline_parse_token_string_t cmd_fwd_all =
7822 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7825 cmd_showfwdall_parsed(void *parsed_result,
7826 __rte_unused struct cmdline *cl,
7827 __rte_unused void *data)
7829 struct fwd_result *res = parsed_result;
7831 if (!strcmp(res->action, "show"))
7832 fwd_stats_display();
7837 static cmdline_parse_inst_t cmd_showfwdall = {
7838 .f = cmd_showfwdall_parsed,
7840 .help_str = "show|clear fwd stats all",
7842 (void *)&cmd_fwd_action,
7843 (void *)&cmd_fwd_fwd,
7844 (void *)&cmd_fwd_stats,
7845 (void *)&cmd_fwd_all,
7850 /* *** READ PORT REGISTER *** */
7851 struct cmd_read_reg_result {
7852 cmdline_fixed_string_t read;
7853 cmdline_fixed_string_t reg;
7859 cmd_read_reg_parsed(void *parsed_result,
7860 __rte_unused struct cmdline *cl,
7861 __rte_unused void *data)
7863 struct cmd_read_reg_result *res = parsed_result;
7864 port_reg_display(res->port_id, res->reg_off);
7867 cmdline_parse_token_string_t cmd_read_reg_read =
7868 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7869 cmdline_parse_token_string_t cmd_read_reg_reg =
7870 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7871 cmdline_parse_token_num_t cmd_read_reg_port_id =
7872 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7873 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7874 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7876 cmdline_parse_inst_t cmd_read_reg = {
7877 .f = cmd_read_reg_parsed,
7879 .help_str = "read reg <port_id> <reg_off>",
7881 (void *)&cmd_read_reg_read,
7882 (void *)&cmd_read_reg_reg,
7883 (void *)&cmd_read_reg_port_id,
7884 (void *)&cmd_read_reg_reg_off,
7889 /* *** READ PORT REGISTER BIT FIELD *** */
7890 struct cmd_read_reg_bit_field_result {
7891 cmdline_fixed_string_t read;
7892 cmdline_fixed_string_t regfield;
7900 cmd_read_reg_bit_field_parsed(void *parsed_result,
7901 __rte_unused struct cmdline *cl,
7902 __rte_unused void *data)
7904 struct cmd_read_reg_bit_field_result *res = parsed_result;
7905 port_reg_bit_field_display(res->port_id, res->reg_off,
7906 res->bit1_pos, res->bit2_pos);
7909 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7910 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7912 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7913 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7914 regfield, "regfield");
7915 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7916 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7918 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7919 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7921 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7922 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7924 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7925 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7928 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7929 .f = cmd_read_reg_bit_field_parsed,
7931 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7932 "Read register bit field between bit_x and bit_y included",
7934 (void *)&cmd_read_reg_bit_field_read,
7935 (void *)&cmd_read_reg_bit_field_regfield,
7936 (void *)&cmd_read_reg_bit_field_port_id,
7937 (void *)&cmd_read_reg_bit_field_reg_off,
7938 (void *)&cmd_read_reg_bit_field_bit1_pos,
7939 (void *)&cmd_read_reg_bit_field_bit2_pos,
7944 /* *** READ PORT REGISTER BIT *** */
7945 struct cmd_read_reg_bit_result {
7946 cmdline_fixed_string_t read;
7947 cmdline_fixed_string_t regbit;
7954 cmd_read_reg_bit_parsed(void *parsed_result,
7955 __rte_unused struct cmdline *cl,
7956 __rte_unused void *data)
7958 struct cmd_read_reg_bit_result *res = parsed_result;
7959 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7962 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7963 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7964 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7965 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7967 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7968 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7969 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7970 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7971 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7972 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7974 cmdline_parse_inst_t cmd_read_reg_bit = {
7975 .f = cmd_read_reg_bit_parsed,
7977 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7979 (void *)&cmd_read_reg_bit_read,
7980 (void *)&cmd_read_reg_bit_regbit,
7981 (void *)&cmd_read_reg_bit_port_id,
7982 (void *)&cmd_read_reg_bit_reg_off,
7983 (void *)&cmd_read_reg_bit_bit_pos,
7988 /* *** WRITE PORT REGISTER *** */
7989 struct cmd_write_reg_result {
7990 cmdline_fixed_string_t write;
7991 cmdline_fixed_string_t reg;
7998 cmd_write_reg_parsed(void *parsed_result,
7999 __rte_unused struct cmdline *cl,
8000 __rte_unused void *data)
8002 struct cmd_write_reg_result *res = parsed_result;
8003 port_reg_set(res->port_id, res->reg_off, res->value);
8006 cmdline_parse_token_string_t cmd_write_reg_write =
8007 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8008 cmdline_parse_token_string_t cmd_write_reg_reg =
8009 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8010 cmdline_parse_token_num_t cmd_write_reg_port_id =
8011 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
8012 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8013 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
8014 cmdline_parse_token_num_t cmd_write_reg_value =
8015 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
8017 cmdline_parse_inst_t cmd_write_reg = {
8018 .f = cmd_write_reg_parsed,
8020 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8022 (void *)&cmd_write_reg_write,
8023 (void *)&cmd_write_reg_reg,
8024 (void *)&cmd_write_reg_port_id,
8025 (void *)&cmd_write_reg_reg_off,
8026 (void *)&cmd_write_reg_value,
8031 /* *** WRITE PORT REGISTER BIT FIELD *** */
8032 struct cmd_write_reg_bit_field_result {
8033 cmdline_fixed_string_t write;
8034 cmdline_fixed_string_t regfield;
8043 cmd_write_reg_bit_field_parsed(void *parsed_result,
8044 __rte_unused struct cmdline *cl,
8045 __rte_unused void *data)
8047 struct cmd_write_reg_bit_field_result *res = parsed_result;
8048 port_reg_bit_field_set(res->port_id, res->reg_off,
8049 res->bit1_pos, res->bit2_pos, res->value);
8052 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8053 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8055 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8056 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8057 regfield, "regfield");
8058 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8059 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8061 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8062 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8064 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8065 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8067 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8068 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8070 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8071 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8074 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8075 .f = cmd_write_reg_bit_field_parsed,
8077 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8079 "Set register bit field between bit_x and bit_y included",
8081 (void *)&cmd_write_reg_bit_field_write,
8082 (void *)&cmd_write_reg_bit_field_regfield,
8083 (void *)&cmd_write_reg_bit_field_port_id,
8084 (void *)&cmd_write_reg_bit_field_reg_off,
8085 (void *)&cmd_write_reg_bit_field_bit1_pos,
8086 (void *)&cmd_write_reg_bit_field_bit2_pos,
8087 (void *)&cmd_write_reg_bit_field_value,
8092 /* *** WRITE PORT REGISTER BIT *** */
8093 struct cmd_write_reg_bit_result {
8094 cmdline_fixed_string_t write;
8095 cmdline_fixed_string_t regbit;
8103 cmd_write_reg_bit_parsed(void *parsed_result,
8104 __rte_unused struct cmdline *cl,
8105 __rte_unused void *data)
8107 struct cmd_write_reg_bit_result *res = parsed_result;
8108 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8111 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8112 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8114 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8115 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8117 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8118 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
8119 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8120 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
8121 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8122 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
8123 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8124 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
8126 cmdline_parse_inst_t cmd_write_reg_bit = {
8127 .f = cmd_write_reg_bit_parsed,
8129 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8132 (void *)&cmd_write_reg_bit_write,
8133 (void *)&cmd_write_reg_bit_regbit,
8134 (void *)&cmd_write_reg_bit_port_id,
8135 (void *)&cmd_write_reg_bit_reg_off,
8136 (void *)&cmd_write_reg_bit_bit_pos,
8137 (void *)&cmd_write_reg_bit_value,
8142 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8143 struct cmd_read_rxd_txd_result {
8144 cmdline_fixed_string_t read;
8145 cmdline_fixed_string_t rxd_txd;
8152 cmd_read_rxd_txd_parsed(void *parsed_result,
8153 __rte_unused struct cmdline *cl,
8154 __rte_unused void *data)
8156 struct cmd_read_rxd_txd_result *res = parsed_result;
8158 if (!strcmp(res->rxd_txd, "rxd"))
8159 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8160 else if (!strcmp(res->rxd_txd, "txd"))
8161 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8164 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8165 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8166 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8167 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8169 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8170 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
8171 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8172 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8173 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8174 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8176 cmdline_parse_inst_t cmd_read_rxd_txd = {
8177 .f = cmd_read_rxd_txd_parsed,
8179 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8181 (void *)&cmd_read_rxd_txd_read,
8182 (void *)&cmd_read_rxd_txd_rxd_txd,
8183 (void *)&cmd_read_rxd_txd_port_id,
8184 (void *)&cmd_read_rxd_txd_queue_id,
8185 (void *)&cmd_read_rxd_txd_desc_id,
8191 struct cmd_quit_result {
8192 cmdline_fixed_string_t quit;
8195 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8197 __rte_unused void *data)
8202 cmdline_parse_token_string_t cmd_quit_quit =
8203 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8205 cmdline_parse_inst_t cmd_quit = {
8206 .f = cmd_quit_parsed,
8208 .help_str = "quit: Exit application",
8210 (void *)&cmd_quit_quit,
8215 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8216 struct cmd_mac_addr_result {
8217 cmdline_fixed_string_t mac_addr_cmd;
8218 cmdline_fixed_string_t what;
8220 struct rte_ether_addr address;
8223 static void cmd_mac_addr_parsed(void *parsed_result,
8224 __rte_unused struct cmdline *cl,
8225 __rte_unused void *data)
8227 struct cmd_mac_addr_result *res = parsed_result;
8230 if (strcmp(res->what, "add") == 0)
8231 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8232 else if (strcmp(res->what, "set") == 0)
8233 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8236 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8238 /* check the return value and print it if is < 0 */
8240 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8244 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8245 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8247 cmdline_parse_token_string_t cmd_mac_addr_what =
8248 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8250 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8251 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8253 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8254 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8256 cmdline_parse_inst_t cmd_mac_addr = {
8257 .f = cmd_mac_addr_parsed,
8259 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8260 "Add/Remove/Set MAC address on port_id",
8262 (void *)&cmd_mac_addr_cmd,
8263 (void *)&cmd_mac_addr_what,
8264 (void *)&cmd_mac_addr_portnum,
8265 (void *)&cmd_mac_addr_addr,
8270 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8271 struct cmd_eth_peer_result {
8272 cmdline_fixed_string_t set;
8273 cmdline_fixed_string_t eth_peer;
8275 cmdline_fixed_string_t peer_addr;
8278 static void cmd_set_eth_peer_parsed(void *parsed_result,
8279 __rte_unused struct cmdline *cl,
8280 __rte_unused void *data)
8282 struct cmd_eth_peer_result *res = parsed_result;
8284 if (test_done == 0) {
8285 printf("Please stop forwarding first\n");
8288 if (!strcmp(res->eth_peer, "eth-peer")) {
8289 set_fwd_eth_peer(res->port_id, res->peer_addr);
8293 cmdline_parse_token_string_t cmd_eth_peer_set =
8294 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8295 cmdline_parse_token_string_t cmd_eth_peer =
8296 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8297 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8298 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8299 cmdline_parse_token_string_t cmd_eth_peer_addr =
8300 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8302 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8303 .f = cmd_set_eth_peer_parsed,
8305 .help_str = "set eth-peer <port_id> <peer_mac>",
8307 (void *)&cmd_eth_peer_set,
8308 (void *)&cmd_eth_peer,
8309 (void *)&cmd_eth_peer_port_id,
8310 (void *)&cmd_eth_peer_addr,
8315 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8316 struct cmd_set_qmap_result {
8317 cmdline_fixed_string_t set;
8318 cmdline_fixed_string_t qmap;
8319 cmdline_fixed_string_t what;
8326 cmd_set_qmap_parsed(void *parsed_result,
8327 __rte_unused struct cmdline *cl,
8328 __rte_unused void *data)
8330 struct cmd_set_qmap_result *res = parsed_result;
8331 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8333 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8336 cmdline_parse_token_string_t cmd_setqmap_set =
8337 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8339 cmdline_parse_token_string_t cmd_setqmap_qmap =
8340 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8342 cmdline_parse_token_string_t cmd_setqmap_what =
8343 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8345 cmdline_parse_token_num_t cmd_setqmap_portid =
8346 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8348 cmdline_parse_token_num_t cmd_setqmap_queueid =
8349 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8351 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8352 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8355 cmdline_parse_inst_t cmd_set_qmap = {
8356 .f = cmd_set_qmap_parsed,
8358 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8359 "Set statistics mapping value on tx|rx queue_id of port_id",
8361 (void *)&cmd_setqmap_set,
8362 (void *)&cmd_setqmap_qmap,
8363 (void *)&cmd_setqmap_what,
8364 (void *)&cmd_setqmap_portid,
8365 (void *)&cmd_setqmap_queueid,
8366 (void *)&cmd_setqmap_mapvalue,
8371 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8372 struct cmd_set_xstats_hide_zero_result {
8373 cmdline_fixed_string_t keyword;
8374 cmdline_fixed_string_t name;
8375 cmdline_fixed_string_t on_off;
8379 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8380 __rte_unused struct cmdline *cl,
8381 __rte_unused void *data)
8383 struct cmd_set_xstats_hide_zero_result *res;
8384 uint16_t on_off = 0;
8386 res = parsed_result;
8387 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8388 set_xstats_hide_zero(on_off);
8391 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8392 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8394 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8395 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8396 name, "xstats-hide-zero");
8397 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8398 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8401 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8402 .f = cmd_set_xstats_hide_zero_parsed,
8404 .help_str = "set xstats-hide-zero on|off",
8406 (void *)&cmd_set_xstats_hide_zero_keyword,
8407 (void *)&cmd_set_xstats_hide_zero_name,
8408 (void *)&cmd_set_xstats_hide_zero_on_off,
8413 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8414 struct cmd_set_record_core_cycles_result {
8415 cmdline_fixed_string_t keyword;
8416 cmdline_fixed_string_t name;
8417 cmdline_fixed_string_t on_off;
8421 cmd_set_record_core_cycles_parsed(void *parsed_result,
8422 __rte_unused struct cmdline *cl,
8423 __rte_unused void *data)
8425 struct cmd_set_record_core_cycles_result *res;
8426 uint16_t on_off = 0;
8428 res = parsed_result;
8429 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8430 set_record_core_cycles(on_off);
8433 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8434 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8436 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8437 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8438 name, "record-core-cycles");
8439 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8440 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8443 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8444 .f = cmd_set_record_core_cycles_parsed,
8446 .help_str = "set record-core-cycles on|off",
8448 (void *)&cmd_set_record_core_cycles_keyword,
8449 (void *)&cmd_set_record_core_cycles_name,
8450 (void *)&cmd_set_record_core_cycles_on_off,
8455 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8456 struct cmd_set_record_burst_stats_result {
8457 cmdline_fixed_string_t keyword;
8458 cmdline_fixed_string_t name;
8459 cmdline_fixed_string_t on_off;
8463 cmd_set_record_burst_stats_parsed(void *parsed_result,
8464 __rte_unused struct cmdline *cl,
8465 __rte_unused void *data)
8467 struct cmd_set_record_burst_stats_result *res;
8468 uint16_t on_off = 0;
8470 res = parsed_result;
8471 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8472 set_record_burst_stats(on_off);
8475 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8476 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8478 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8479 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8480 name, "record-burst-stats");
8481 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8482 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8485 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8486 .f = cmd_set_record_burst_stats_parsed,
8488 .help_str = "set record-burst-stats on|off",
8490 (void *)&cmd_set_record_burst_stats_keyword,
8491 (void *)&cmd_set_record_burst_stats_name,
8492 (void *)&cmd_set_record_burst_stats_on_off,
8497 /* *** CONFIGURE UNICAST HASH TABLE *** */
8498 struct cmd_set_uc_hash_table {
8499 cmdline_fixed_string_t set;
8500 cmdline_fixed_string_t port;
8502 cmdline_fixed_string_t what;
8503 struct rte_ether_addr address;
8504 cmdline_fixed_string_t mode;
8508 cmd_set_uc_hash_parsed(void *parsed_result,
8509 __rte_unused struct cmdline *cl,
8510 __rte_unused void *data)
8513 struct cmd_set_uc_hash_table *res = parsed_result;
8515 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8517 if (strcmp(res->what, "uta") == 0)
8518 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8519 &res->address,(uint8_t)is_on);
8521 printf("bad unicast hash table parameter, return code = %d \n", ret);
8525 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8526 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8528 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8529 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8531 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8532 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8534 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8535 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8537 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8538 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8540 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8541 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8544 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8545 .f = cmd_set_uc_hash_parsed,
8547 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8549 (void *)&cmd_set_uc_hash_set,
8550 (void *)&cmd_set_uc_hash_port,
8551 (void *)&cmd_set_uc_hash_portid,
8552 (void *)&cmd_set_uc_hash_what,
8553 (void *)&cmd_set_uc_hash_mac,
8554 (void *)&cmd_set_uc_hash_mode,
8559 struct cmd_set_uc_all_hash_table {
8560 cmdline_fixed_string_t set;
8561 cmdline_fixed_string_t port;
8563 cmdline_fixed_string_t what;
8564 cmdline_fixed_string_t value;
8565 cmdline_fixed_string_t mode;
8569 cmd_set_uc_all_hash_parsed(void *parsed_result,
8570 __rte_unused struct cmdline *cl,
8571 __rte_unused void *data)
8574 struct cmd_set_uc_all_hash_table *res = parsed_result;
8576 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8578 if ((strcmp(res->what, "uta") == 0) &&
8579 (strcmp(res->value, "all") == 0))
8580 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8582 printf("bad unicast hash table parameter,"
8583 "return code = %d \n", ret);
8586 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8587 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8589 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8590 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8592 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8593 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8595 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8596 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8598 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8599 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8601 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8602 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8605 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8606 .f = cmd_set_uc_all_hash_parsed,
8608 .help_str = "set port <port_id> uta all on|off",
8610 (void *)&cmd_set_uc_all_hash_set,
8611 (void *)&cmd_set_uc_all_hash_port,
8612 (void *)&cmd_set_uc_all_hash_portid,
8613 (void *)&cmd_set_uc_all_hash_what,
8614 (void *)&cmd_set_uc_all_hash_value,
8615 (void *)&cmd_set_uc_all_hash_mode,
8620 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8621 struct cmd_set_vf_traffic {
8622 cmdline_fixed_string_t set;
8623 cmdline_fixed_string_t port;
8625 cmdline_fixed_string_t vf;
8627 cmdline_fixed_string_t what;
8628 cmdline_fixed_string_t mode;
8632 cmd_set_vf_traffic_parsed(void *parsed_result,
8633 __rte_unused struct cmdline *cl,
8634 __rte_unused void *data)
8636 struct cmd_set_vf_traffic *res = parsed_result;
8637 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8638 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8640 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8643 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8644 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8646 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8647 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8649 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8650 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8652 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8653 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8655 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8656 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8658 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8659 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8661 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8662 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8665 cmdline_parse_inst_t cmd_set_vf_traffic = {
8666 .f = cmd_set_vf_traffic_parsed,
8668 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8670 (void *)&cmd_setvf_traffic_set,
8671 (void *)&cmd_setvf_traffic_port,
8672 (void *)&cmd_setvf_traffic_portid,
8673 (void *)&cmd_setvf_traffic_vf,
8674 (void *)&cmd_setvf_traffic_vfid,
8675 (void *)&cmd_setvf_traffic_what,
8676 (void *)&cmd_setvf_traffic_mode,
8681 /* *** CONFIGURE VF RECEIVE MODE *** */
8682 struct cmd_set_vf_rxmode {
8683 cmdline_fixed_string_t set;
8684 cmdline_fixed_string_t port;
8686 cmdline_fixed_string_t vf;
8688 cmdline_fixed_string_t what;
8689 cmdline_fixed_string_t mode;
8690 cmdline_fixed_string_t on;
8694 cmd_set_vf_rxmode_parsed(void *parsed_result,
8695 __rte_unused struct cmdline *cl,
8696 __rte_unused void *data)
8699 uint16_t vf_rxmode = 0;
8700 struct cmd_set_vf_rxmode *res = parsed_result;
8702 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8703 if (!strcmp(res->what,"rxmode")) {
8704 if (!strcmp(res->mode, "AUPE"))
8705 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8706 else if (!strcmp(res->mode, "ROPE"))
8707 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8708 else if (!strcmp(res->mode, "BAM"))
8709 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8710 else if (!strncmp(res->mode, "MPE",3))
8711 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8714 RTE_SET_USED(is_on);
8716 #ifdef RTE_NET_IXGBE
8717 if (ret == -ENOTSUP)
8718 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8719 vf_rxmode, (uint8_t)is_on);
8722 if (ret == -ENOTSUP)
8723 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8724 vf_rxmode, (uint8_t)is_on);
8727 printf("bad VF receive mode parameter, return code = %d \n",
8731 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8732 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8734 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8735 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8737 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8738 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8740 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8741 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8743 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8744 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8746 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8747 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8749 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8750 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8751 mode, "AUPE#ROPE#BAM#MPE");
8752 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8753 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8756 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8757 .f = cmd_set_vf_rxmode_parsed,
8759 .help_str = "set port <port_id> vf <vf_id> rxmode "
8760 "AUPE|ROPE|BAM|MPE on|off",
8762 (void *)&cmd_set_vf_rxmode_set,
8763 (void *)&cmd_set_vf_rxmode_port,
8764 (void *)&cmd_set_vf_rxmode_portid,
8765 (void *)&cmd_set_vf_rxmode_vf,
8766 (void *)&cmd_set_vf_rxmode_vfid,
8767 (void *)&cmd_set_vf_rxmode_what,
8768 (void *)&cmd_set_vf_rxmode_mode,
8769 (void *)&cmd_set_vf_rxmode_on,
8774 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8775 struct cmd_vf_mac_addr_result {
8776 cmdline_fixed_string_t mac_addr_cmd;
8777 cmdline_fixed_string_t what;
8778 cmdline_fixed_string_t port;
8780 cmdline_fixed_string_t vf;
8782 struct rte_ether_addr address;
8785 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8786 __rte_unused struct cmdline *cl,
8787 __rte_unused void *data)
8789 struct cmd_vf_mac_addr_result *res = parsed_result;
8792 if (strcmp(res->what, "add") != 0)
8796 if (ret == -ENOTSUP)
8797 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8801 if (ret == -ENOTSUP)
8802 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8807 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8811 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8812 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8813 mac_addr_cmd,"mac_addr");
8814 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8815 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8817 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8818 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8820 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8821 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8823 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8824 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8826 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8827 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8829 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8830 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8833 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8834 .f = cmd_vf_mac_addr_parsed,
8836 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8837 "Add MAC address filtering for a VF on port_id",
8839 (void *)&cmd_vf_mac_addr_cmd,
8840 (void *)&cmd_vf_mac_addr_what,
8841 (void *)&cmd_vf_mac_addr_port,
8842 (void *)&cmd_vf_mac_addr_portnum,
8843 (void *)&cmd_vf_mac_addr_vf,
8844 (void *)&cmd_vf_mac_addr_vfnum,
8845 (void *)&cmd_vf_mac_addr_addr,
8850 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8851 struct cmd_vf_rx_vlan_filter {
8852 cmdline_fixed_string_t rx_vlan;
8853 cmdline_fixed_string_t what;
8855 cmdline_fixed_string_t port;
8857 cmdline_fixed_string_t vf;
8862 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8863 __rte_unused struct cmdline *cl,
8864 __rte_unused void *data)
8866 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8869 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8871 #ifdef RTE_NET_IXGBE
8872 if (ret == -ENOTSUP)
8873 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8874 res->vlan_id, res->vf_mask, is_add);
8877 if (ret == -ENOTSUP)
8878 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8879 res->vlan_id, res->vf_mask, is_add);
8882 if (ret == -ENOTSUP)
8883 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8884 res->vlan_id, res->vf_mask, is_add);
8891 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8892 res->vlan_id, res->vf_mask);
8895 printf("invalid port_id %d\n", res->port_id);
8898 printf("function not implemented or supported\n");
8901 printf("programming error: (%s)\n", strerror(-ret));
8905 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8906 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8907 rx_vlan, "rx_vlan");
8908 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8909 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8911 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8912 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8914 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8915 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8917 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8918 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8920 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8921 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8923 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8924 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8927 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8928 .f = cmd_vf_rx_vlan_filter_parsed,
8930 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8931 "(vf_mask = hexadecimal VF mask)",
8933 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8934 (void *)&cmd_vf_rx_vlan_filter_what,
8935 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8936 (void *)&cmd_vf_rx_vlan_filter_port,
8937 (void *)&cmd_vf_rx_vlan_filter_portid,
8938 (void *)&cmd_vf_rx_vlan_filter_vf,
8939 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8944 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8945 struct cmd_queue_rate_limit_result {
8946 cmdline_fixed_string_t set;
8947 cmdline_fixed_string_t port;
8949 cmdline_fixed_string_t queue;
8951 cmdline_fixed_string_t rate;
8955 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8956 __rte_unused struct cmdline *cl,
8957 __rte_unused void *data)
8959 struct cmd_queue_rate_limit_result *res = parsed_result;
8962 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8963 && (strcmp(res->queue, "queue") == 0)
8964 && (strcmp(res->rate, "rate") == 0))
8965 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8968 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8972 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8973 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8975 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8976 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8978 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8979 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8981 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8982 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8984 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8985 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8987 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8988 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8990 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8991 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8994 cmdline_parse_inst_t cmd_queue_rate_limit = {
8995 .f = cmd_queue_rate_limit_parsed,
8997 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8998 "Set rate limit for a queue on port_id",
9000 (void *)&cmd_queue_rate_limit_set,
9001 (void *)&cmd_queue_rate_limit_port,
9002 (void *)&cmd_queue_rate_limit_portnum,
9003 (void *)&cmd_queue_rate_limit_queue,
9004 (void *)&cmd_queue_rate_limit_queuenum,
9005 (void *)&cmd_queue_rate_limit_rate,
9006 (void *)&cmd_queue_rate_limit_ratenum,
9011 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9012 struct cmd_vf_rate_limit_result {
9013 cmdline_fixed_string_t set;
9014 cmdline_fixed_string_t port;
9016 cmdline_fixed_string_t vf;
9018 cmdline_fixed_string_t rate;
9020 cmdline_fixed_string_t q_msk;
9024 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9025 __rte_unused struct cmdline *cl,
9026 __rte_unused void *data)
9028 struct cmd_vf_rate_limit_result *res = parsed_result;
9031 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9032 && (strcmp(res->vf, "vf") == 0)
9033 && (strcmp(res->rate, "rate") == 0)
9034 && (strcmp(res->q_msk, "queue_mask") == 0))
9035 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9036 res->rate_num, res->q_msk_val);
9038 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9042 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9043 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9045 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9046 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9048 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9049 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9051 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9052 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9054 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9055 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9057 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9058 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9060 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9061 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9063 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9064 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9065 q_msk, "queue_mask");
9066 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9067 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9070 cmdline_parse_inst_t cmd_vf_rate_limit = {
9071 .f = cmd_vf_rate_limit_parsed,
9073 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9074 "queue_mask <queue_mask_value>: "
9075 "Set rate limit for queues of VF on port_id",
9077 (void *)&cmd_vf_rate_limit_set,
9078 (void *)&cmd_vf_rate_limit_port,
9079 (void *)&cmd_vf_rate_limit_portnum,
9080 (void *)&cmd_vf_rate_limit_vf,
9081 (void *)&cmd_vf_rate_limit_vfnum,
9082 (void *)&cmd_vf_rate_limit_rate,
9083 (void *)&cmd_vf_rate_limit_ratenum,
9084 (void *)&cmd_vf_rate_limit_q_msk,
9085 (void *)&cmd_vf_rate_limit_q_msk_val,
9090 /* *** CONFIGURE TUNNEL UDP PORT *** */
9091 struct cmd_tunnel_udp_config {
9092 cmdline_fixed_string_t cmd;
9093 cmdline_fixed_string_t what;
9099 cmd_tunnel_udp_config_parsed(void *parsed_result,
9100 __rte_unused struct cmdline *cl,
9101 __rte_unused void *data)
9103 struct cmd_tunnel_udp_config *res = parsed_result;
9104 struct rte_eth_udp_tunnel tunnel_udp;
9107 tunnel_udp.udp_port = res->udp_port;
9109 if (!strcmp(res->cmd, "rx_vxlan_port"))
9110 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9112 if (!strcmp(res->what, "add"))
9113 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9116 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9120 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9123 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9124 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9125 cmd, "rx_vxlan_port");
9126 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9127 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9129 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9130 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9132 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9133 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9136 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9137 .f = cmd_tunnel_udp_config_parsed,
9139 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9140 "Add/Remove a tunneling UDP port filter",
9142 (void *)&cmd_tunnel_udp_config_cmd,
9143 (void *)&cmd_tunnel_udp_config_what,
9144 (void *)&cmd_tunnel_udp_config_udp_port,
9145 (void *)&cmd_tunnel_udp_config_port_id,
9150 struct cmd_config_tunnel_udp_port {
9151 cmdline_fixed_string_t port;
9152 cmdline_fixed_string_t config;
9154 cmdline_fixed_string_t udp_tunnel_port;
9155 cmdline_fixed_string_t action;
9156 cmdline_fixed_string_t tunnel_type;
9161 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9162 __rte_unused struct cmdline *cl,
9163 __rte_unused void *data)
9165 struct cmd_config_tunnel_udp_port *res = parsed_result;
9166 struct rte_eth_udp_tunnel tunnel_udp;
9169 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9172 tunnel_udp.udp_port = res->udp_port;
9174 if (!strcmp(res->tunnel_type, "vxlan")) {
9175 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9176 } else if (!strcmp(res->tunnel_type, "geneve")) {
9177 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9178 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9179 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9181 printf("Invalid tunnel type\n");
9185 if (!strcmp(res->action, "add"))
9186 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9189 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9193 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9196 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9197 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9199 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9200 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9202 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9203 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9205 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9206 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9209 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9210 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9212 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9213 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9214 "vxlan#geneve#vxlan-gpe");
9215 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9216 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9219 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9220 .f = cmd_cfg_tunnel_udp_port_parsed,
9222 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9224 (void *)&cmd_config_tunnel_udp_port_port,
9225 (void *)&cmd_config_tunnel_udp_port_config,
9226 (void *)&cmd_config_tunnel_udp_port_port_id,
9227 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9228 (void *)&cmd_config_tunnel_udp_port_action,
9229 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9230 (void *)&cmd_config_tunnel_udp_port_value,
9235 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9236 struct cmd_set_mirror_mask_result {
9237 cmdline_fixed_string_t set;
9238 cmdline_fixed_string_t port;
9240 cmdline_fixed_string_t mirror;
9242 cmdline_fixed_string_t what;
9243 cmdline_fixed_string_t value;
9244 cmdline_fixed_string_t dstpool;
9246 cmdline_fixed_string_t on;
9249 cmdline_parse_token_string_t cmd_mirror_mask_set =
9250 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9252 cmdline_parse_token_string_t cmd_mirror_mask_port =
9253 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9255 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9256 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9258 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9259 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9260 mirror, "mirror-rule");
9261 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9262 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9264 cmdline_parse_token_string_t cmd_mirror_mask_what =
9265 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9266 what, "pool-mirror-up#pool-mirror-down"
9268 cmdline_parse_token_string_t cmd_mirror_mask_value =
9269 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9271 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9272 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9273 dstpool, "dst-pool");
9274 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9275 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9277 cmdline_parse_token_string_t cmd_mirror_mask_on =
9278 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9282 cmd_set_mirror_mask_parsed(void *parsed_result,
9283 __rte_unused struct cmdline *cl,
9284 __rte_unused void *data)
9287 struct cmd_set_mirror_mask_result *res = parsed_result;
9288 struct rte_eth_mirror_conf mr_conf;
9290 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9292 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9294 mr_conf.dst_pool = res->dstpool_id;
9296 if (!strcmp(res->what, "pool-mirror-up")) {
9297 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9298 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9299 } else if (!strcmp(res->what, "pool-mirror-down")) {
9300 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9301 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9302 } else if (!strcmp(res->what, "vlan-mirror")) {
9303 mr_conf.rule_type = ETH_MIRROR_VLAN;
9304 nb_item = parse_item_list(res->value, "vlan",
9305 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9309 for (i = 0; i < nb_item; i++) {
9310 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9311 printf("Invalid vlan_id: must be < 4096\n");
9315 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9316 mr_conf.vlan.vlan_mask |= 1ULL << i;
9320 if (!strcmp(res->on, "on"))
9321 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9324 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9327 printf("mirror rule add error: (%s)\n", strerror(-ret));
9330 cmdline_parse_inst_t cmd_set_mirror_mask = {
9331 .f = cmd_set_mirror_mask_parsed,
9333 .help_str = "set port <port_id> mirror-rule <rule_id> "
9334 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9335 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9337 (void *)&cmd_mirror_mask_set,
9338 (void *)&cmd_mirror_mask_port,
9339 (void *)&cmd_mirror_mask_portid,
9340 (void *)&cmd_mirror_mask_mirror,
9341 (void *)&cmd_mirror_mask_ruleid,
9342 (void *)&cmd_mirror_mask_what,
9343 (void *)&cmd_mirror_mask_value,
9344 (void *)&cmd_mirror_mask_dstpool,
9345 (void *)&cmd_mirror_mask_poolid,
9346 (void *)&cmd_mirror_mask_on,
9351 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9352 struct cmd_set_mirror_link_result {
9353 cmdline_fixed_string_t set;
9354 cmdline_fixed_string_t port;
9356 cmdline_fixed_string_t mirror;
9358 cmdline_fixed_string_t what;
9359 cmdline_fixed_string_t dstpool;
9361 cmdline_fixed_string_t on;
9364 cmdline_parse_token_string_t cmd_mirror_link_set =
9365 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9367 cmdline_parse_token_string_t cmd_mirror_link_port =
9368 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9370 cmdline_parse_token_num_t cmd_mirror_link_portid =
9371 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9373 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9374 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9375 mirror, "mirror-rule");
9376 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9377 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9379 cmdline_parse_token_string_t cmd_mirror_link_what =
9380 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9381 what, "uplink-mirror#downlink-mirror");
9382 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9383 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9384 dstpool, "dst-pool");
9385 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9386 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9388 cmdline_parse_token_string_t cmd_mirror_link_on =
9389 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9393 cmd_set_mirror_link_parsed(void *parsed_result,
9394 __rte_unused struct cmdline *cl,
9395 __rte_unused void *data)
9398 struct cmd_set_mirror_link_result *res = parsed_result;
9399 struct rte_eth_mirror_conf mr_conf;
9401 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9402 if (!strcmp(res->what, "uplink-mirror"))
9403 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9405 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9407 mr_conf.dst_pool = res->dstpool_id;
9409 if (!strcmp(res->on, "on"))
9410 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9413 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9416 /* check the return value and print it if is < 0 */
9418 printf("mirror rule add error: (%s)\n", strerror(-ret));
9422 cmdline_parse_inst_t cmd_set_mirror_link = {
9423 .f = cmd_set_mirror_link_parsed,
9425 .help_str = "set port <port_id> mirror-rule <rule_id> "
9426 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9428 (void *)&cmd_mirror_link_set,
9429 (void *)&cmd_mirror_link_port,
9430 (void *)&cmd_mirror_link_portid,
9431 (void *)&cmd_mirror_link_mirror,
9432 (void *)&cmd_mirror_link_ruleid,
9433 (void *)&cmd_mirror_link_what,
9434 (void *)&cmd_mirror_link_dstpool,
9435 (void *)&cmd_mirror_link_poolid,
9436 (void *)&cmd_mirror_link_on,
9441 /* *** RESET VM MIRROR RULE *** */
9442 struct cmd_rm_mirror_rule_result {
9443 cmdline_fixed_string_t reset;
9444 cmdline_fixed_string_t port;
9446 cmdline_fixed_string_t mirror;
9450 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9451 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9453 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9454 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9456 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9457 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9459 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9460 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9461 mirror, "mirror-rule");
9462 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9463 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9467 cmd_reset_mirror_rule_parsed(void *parsed_result,
9468 __rte_unused struct cmdline *cl,
9469 __rte_unused void *data)
9472 struct cmd_set_mirror_link_result *res = parsed_result;
9474 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9476 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9479 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9480 .f = cmd_reset_mirror_rule_parsed,
9482 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9484 (void *)&cmd_rm_mirror_rule_reset,
9485 (void *)&cmd_rm_mirror_rule_port,
9486 (void *)&cmd_rm_mirror_rule_portid,
9487 (void *)&cmd_rm_mirror_rule_mirror,
9488 (void *)&cmd_rm_mirror_rule_ruleid,
9493 /* ******************************************************************************** */
9495 struct cmd_dump_result {
9496 cmdline_fixed_string_t dump;
9500 dump_struct_sizes(void)
9502 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9503 DUMP_SIZE(struct rte_mbuf);
9504 DUMP_SIZE(struct rte_mempool);
9505 DUMP_SIZE(struct rte_ring);
9510 /* Dump the socket memory statistics on console */
9512 dump_socket_mem(FILE *f)
9514 struct rte_malloc_socket_stats socket_stats;
9519 unsigned int n_alloc = 0;
9520 unsigned int n_free = 0;
9521 static size_t last_allocs;
9522 static size_t last_total;
9525 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9526 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9527 !socket_stats.heap_totalsz_bytes)
9529 total += socket_stats.heap_totalsz_bytes;
9530 alloc += socket_stats.heap_allocsz_bytes;
9531 free += socket_stats.heap_freesz_bytes;
9532 n_alloc += socket_stats.alloc_count;
9533 n_free += socket_stats.free_count;
9535 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9537 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9538 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9539 (double)socket_stats.heap_allocsz_bytes * 100 /
9540 (double)socket_stats.heap_totalsz_bytes,
9541 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9542 socket_stats.alloc_count,
9543 socket_stats.free_count);
9546 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9547 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9548 (double)alloc * 100 / (double)total,
9549 (double)free / (1024 * 1024),
9552 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9553 ((double)total - (double)last_total) / (1024 * 1024),
9554 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9555 last_allocs = alloc;
9559 static void cmd_dump_parsed(void *parsed_result,
9560 __rte_unused struct cmdline *cl,
9561 __rte_unused void *data)
9563 struct cmd_dump_result *res = parsed_result;
9565 if (!strcmp(res->dump, "dump_physmem"))
9566 rte_dump_physmem_layout(stdout);
9567 else if (!strcmp(res->dump, "dump_socket_mem"))
9568 dump_socket_mem(stdout);
9569 else if (!strcmp(res->dump, "dump_memzone"))
9570 rte_memzone_dump(stdout);
9571 else if (!strcmp(res->dump, "dump_struct_sizes"))
9572 dump_struct_sizes();
9573 else if (!strcmp(res->dump, "dump_ring"))
9574 rte_ring_list_dump(stdout);
9575 else if (!strcmp(res->dump, "dump_mempool"))
9576 rte_mempool_list_dump(stdout);
9577 else if (!strcmp(res->dump, "dump_devargs"))
9578 rte_devargs_dump(stdout);
9579 else if (!strcmp(res->dump, "dump_log_types"))
9580 rte_log_dump(stdout);
9583 cmdline_parse_token_string_t cmd_dump_dump =
9584 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9588 "dump_struct_sizes#"
9594 cmdline_parse_inst_t cmd_dump = {
9595 .f = cmd_dump_parsed, /* function to call */
9596 .data = NULL, /* 2nd arg of func */
9597 .help_str = "Dump status",
9598 .tokens = { /* token list, NULL terminated */
9599 (void *)&cmd_dump_dump,
9604 /* ******************************************************************************** */
9606 struct cmd_dump_one_result {
9607 cmdline_fixed_string_t dump;
9608 cmdline_fixed_string_t name;
9611 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9612 __rte_unused void *data)
9614 struct cmd_dump_one_result *res = parsed_result;
9616 if (!strcmp(res->dump, "dump_ring")) {
9618 r = rte_ring_lookup(res->name);
9620 cmdline_printf(cl, "Cannot find ring\n");
9623 rte_ring_dump(stdout, r);
9624 } else if (!strcmp(res->dump, "dump_mempool")) {
9625 struct rte_mempool *mp;
9626 mp = rte_mempool_lookup(res->name);
9628 cmdline_printf(cl, "Cannot find mempool\n");
9631 rte_mempool_dump(stdout, mp);
9635 cmdline_parse_token_string_t cmd_dump_one_dump =
9636 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9637 "dump_ring#dump_mempool");
9639 cmdline_parse_token_string_t cmd_dump_one_name =
9640 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9642 cmdline_parse_inst_t cmd_dump_one = {
9643 .f = cmd_dump_one_parsed, /* function to call */
9644 .data = NULL, /* 2nd arg of func */
9645 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9646 .tokens = { /* token list, NULL terminated */
9647 (void *)&cmd_dump_one_dump,
9648 (void *)&cmd_dump_one_name,
9653 /* *** queue region set *** */
9654 struct cmd_queue_region_result {
9655 cmdline_fixed_string_t set;
9656 cmdline_fixed_string_t port;
9658 cmdline_fixed_string_t cmd;
9659 cmdline_fixed_string_t region;
9661 cmdline_fixed_string_t queue_start_index;
9663 cmdline_fixed_string_t queue_num;
9664 uint8_t queue_num_value;
9668 cmd_queue_region_parsed(void *parsed_result,
9669 __rte_unused struct cmdline *cl,
9670 __rte_unused void *data)
9672 struct cmd_queue_region_result *res = parsed_result;
9675 struct rte_pmd_i40e_queue_region_conf region_conf;
9676 enum rte_pmd_i40e_queue_region_op op_type;
9679 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9683 memset(®ion_conf, 0, sizeof(region_conf));
9684 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9685 region_conf.region_id = res->region_id;
9686 region_conf.queue_num = res->queue_num_value;
9687 region_conf.queue_start_index = res->queue_id;
9689 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9690 op_type, ®ion_conf);
9697 printf("function not implemented or supported\n");
9700 printf("queue region config error: (%s)\n", strerror(-ret));
9704 cmdline_parse_token_string_t cmd_queue_region_set =
9705 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9707 cmdline_parse_token_string_t cmd_queue_region_port =
9708 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9709 cmdline_parse_token_num_t cmd_queue_region_port_id =
9710 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9712 cmdline_parse_token_string_t cmd_queue_region_cmd =
9713 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9714 cmd, "queue-region");
9715 cmdline_parse_token_string_t cmd_queue_region_id =
9716 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9717 region, "region_id");
9718 cmdline_parse_token_num_t cmd_queue_region_index =
9719 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9721 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9722 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9723 queue_start_index, "queue_start_index");
9724 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9725 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9727 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9728 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9729 queue_num, "queue_num");
9730 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9731 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9732 queue_num_value, UINT8);
9734 cmdline_parse_inst_t cmd_queue_region = {
9735 .f = cmd_queue_region_parsed,
9737 .help_str = "set port <port_id> queue-region region_id <value> "
9738 "queue_start_index <value> queue_num <value>: Set a queue region",
9740 (void *)&cmd_queue_region_set,
9741 (void *)&cmd_queue_region_port,
9742 (void *)&cmd_queue_region_port_id,
9743 (void *)&cmd_queue_region_cmd,
9744 (void *)&cmd_queue_region_id,
9745 (void *)&cmd_queue_region_index,
9746 (void *)&cmd_queue_region_queue_start_index,
9747 (void *)&cmd_queue_region_queue_id,
9748 (void *)&cmd_queue_region_queue_num,
9749 (void *)&cmd_queue_region_queue_num_value,
9754 /* *** queue region and flowtype set *** */
9755 struct cmd_region_flowtype_result {
9756 cmdline_fixed_string_t set;
9757 cmdline_fixed_string_t port;
9759 cmdline_fixed_string_t cmd;
9760 cmdline_fixed_string_t region;
9762 cmdline_fixed_string_t flowtype;
9763 uint8_t flowtype_id;
9767 cmd_region_flowtype_parsed(void *parsed_result,
9768 __rte_unused struct cmdline *cl,
9769 __rte_unused void *data)
9771 struct cmd_region_flowtype_result *res = parsed_result;
9774 struct rte_pmd_i40e_queue_region_conf region_conf;
9775 enum rte_pmd_i40e_queue_region_op op_type;
9778 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9782 memset(®ion_conf, 0, sizeof(region_conf));
9784 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9785 region_conf.region_id = res->region_id;
9786 region_conf.hw_flowtype = res->flowtype_id;
9788 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9789 op_type, ®ion_conf);
9796 printf("function not implemented or supported\n");
9799 printf("region flowtype config error: (%s)\n", strerror(-ret));
9803 cmdline_parse_token_string_t cmd_region_flowtype_set =
9804 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9806 cmdline_parse_token_string_t cmd_region_flowtype_port =
9807 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9809 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9810 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9812 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9813 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9814 cmd, "queue-region");
9815 cmdline_parse_token_string_t cmd_region_flowtype_index =
9816 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9817 region, "region_id");
9818 cmdline_parse_token_num_t cmd_region_flowtype_id =
9819 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9821 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9822 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9823 flowtype, "flowtype");
9824 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9825 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9826 flowtype_id, UINT8);
9827 cmdline_parse_inst_t cmd_region_flowtype = {
9828 .f = cmd_region_flowtype_parsed,
9830 .help_str = "set port <port_id> queue-region region_id <value> "
9831 "flowtype <value>: Set a flowtype region index",
9833 (void *)&cmd_region_flowtype_set,
9834 (void *)&cmd_region_flowtype_port,
9835 (void *)&cmd_region_flowtype_port_index,
9836 (void *)&cmd_region_flowtype_cmd,
9837 (void *)&cmd_region_flowtype_index,
9838 (void *)&cmd_region_flowtype_id,
9839 (void *)&cmd_region_flowtype_flow_index,
9840 (void *)&cmd_region_flowtype_flow_id,
9845 /* *** User Priority (UP) to queue region (region_id) set *** */
9846 struct cmd_user_priority_region_result {
9847 cmdline_fixed_string_t set;
9848 cmdline_fixed_string_t port;
9850 cmdline_fixed_string_t cmd;
9851 cmdline_fixed_string_t user_priority;
9852 uint8_t user_priority_id;
9853 cmdline_fixed_string_t region;
9858 cmd_user_priority_region_parsed(void *parsed_result,
9859 __rte_unused struct cmdline *cl,
9860 __rte_unused void *data)
9862 struct cmd_user_priority_region_result *res = parsed_result;
9865 struct rte_pmd_i40e_queue_region_conf region_conf;
9866 enum rte_pmd_i40e_queue_region_op op_type;
9869 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9873 memset(®ion_conf, 0, sizeof(region_conf));
9874 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9875 region_conf.user_priority = res->user_priority_id;
9876 region_conf.region_id = res->region_id;
9878 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9879 op_type, ®ion_conf);
9886 printf("function not implemented or supported\n");
9889 printf("user_priority region config error: (%s)\n",
9894 cmdline_parse_token_string_t cmd_user_priority_region_set =
9895 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9897 cmdline_parse_token_string_t cmd_user_priority_region_port =
9898 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9900 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9901 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9903 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9904 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9905 cmd, "queue-region");
9906 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9907 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9908 user_priority, "UP");
9909 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9910 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9911 user_priority_id, UINT8);
9912 cmdline_parse_token_string_t cmd_user_priority_region_region =
9913 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9914 region, "region_id");
9915 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9916 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9919 cmdline_parse_inst_t cmd_user_priority_region = {
9920 .f = cmd_user_priority_region_parsed,
9922 .help_str = "set port <port_id> queue-region UP <value> "
9923 "region_id <value>: Set the mapping of User Priority (UP) "
9924 "to queue region (region_id) ",
9926 (void *)&cmd_user_priority_region_set,
9927 (void *)&cmd_user_priority_region_port,
9928 (void *)&cmd_user_priority_region_port_index,
9929 (void *)&cmd_user_priority_region_cmd,
9930 (void *)&cmd_user_priority_region_UP,
9931 (void *)&cmd_user_priority_region_UP_id,
9932 (void *)&cmd_user_priority_region_region,
9933 (void *)&cmd_user_priority_region_region_id,
9938 /* *** flush all queue region related configuration *** */
9939 struct cmd_flush_queue_region_result {
9940 cmdline_fixed_string_t set;
9941 cmdline_fixed_string_t port;
9943 cmdline_fixed_string_t cmd;
9944 cmdline_fixed_string_t flush;
9945 cmdline_fixed_string_t what;
9949 cmd_flush_queue_region_parsed(void *parsed_result,
9950 __rte_unused struct cmdline *cl,
9951 __rte_unused void *data)
9953 struct cmd_flush_queue_region_result *res = parsed_result;
9956 struct rte_pmd_i40e_queue_region_conf region_conf;
9957 enum rte_pmd_i40e_queue_region_op op_type;
9960 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9964 memset(®ion_conf, 0, sizeof(region_conf));
9966 if (strcmp(res->what, "on") == 0)
9967 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9969 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9971 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9972 op_type, ®ion_conf);
9979 printf("function not implemented or supported\n");
9982 printf("queue region config flush error: (%s)\n",
9987 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9988 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9990 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9991 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9993 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9994 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9996 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9997 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9998 cmd, "queue-region");
9999 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10000 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10002 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10003 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10006 cmdline_parse_inst_t cmd_flush_queue_region = {
10007 .f = cmd_flush_queue_region_parsed,
10009 .help_str = "set port <port_id> queue-region flush on|off"
10010 ": flush all queue region related configuration",
10012 (void *)&cmd_flush_queue_region_set,
10013 (void *)&cmd_flush_queue_region_port,
10014 (void *)&cmd_flush_queue_region_port_index,
10015 (void *)&cmd_flush_queue_region_cmd,
10016 (void *)&cmd_flush_queue_region_flush,
10017 (void *)&cmd_flush_queue_region_what,
10022 /* *** get all queue region related configuration info *** */
10023 struct cmd_show_queue_region_info {
10024 cmdline_fixed_string_t show;
10025 cmdline_fixed_string_t port;
10027 cmdline_fixed_string_t cmd;
10031 cmd_show_queue_region_info_parsed(void *parsed_result,
10032 __rte_unused struct cmdline *cl,
10033 __rte_unused void *data)
10035 struct cmd_show_queue_region_info *res = parsed_result;
10036 int ret = -ENOTSUP;
10037 #ifdef RTE_NET_I40E
10038 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10039 enum rte_pmd_i40e_queue_region_op op_type;
10042 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10045 #ifdef RTE_NET_I40E
10046 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10048 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10050 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10051 op_type, &rte_pmd_regions);
10053 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10060 printf("function not implemented or supported\n");
10063 printf("queue region config info show error: (%s)\n",
10068 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10069 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10071 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10072 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10074 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10075 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10077 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10078 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10079 cmd, "queue-region");
10081 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10082 .f = cmd_show_queue_region_info_parsed,
10084 .help_str = "show port <port_id> queue-region"
10085 ": show all queue region related configuration info",
10087 (void *)&cmd_show_queue_region_info_get,
10088 (void *)&cmd_show_queue_region_info_port,
10089 (void *)&cmd_show_queue_region_info_port_index,
10090 (void *)&cmd_show_queue_region_info_cmd,
10095 /* *** Filters Control *** */
10098 str2flowtype(char *string)
10101 static const struct {
10104 } flowtype_str[] = {
10105 {"raw", RTE_ETH_FLOW_RAW},
10106 {"ipv4", RTE_ETH_FLOW_IPV4},
10107 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10108 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10109 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10110 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10111 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10112 {"ipv6", RTE_ETH_FLOW_IPV6},
10113 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10114 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10115 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10116 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10117 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10118 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10121 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10122 if (!strcmp(flowtype_str[i].str, string))
10123 return flowtype_str[i].type;
10126 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10127 return (uint16_t)atoi(string);
10129 return RTE_ETH_FLOW_UNKNOWN;
10132 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10134 if ((ip_addr).family == AF_INET) \
10135 (ip) = (ip_addr).addr.ipv4.s_addr; \
10137 printf("invalid parameter.\n"); \
10142 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10144 if ((ip_addr).family == AF_INET6) \
10145 rte_memcpy(&(ip), \
10146 &((ip_addr).addr.ipv6), \
10147 sizeof(struct in6_addr)); \
10149 printf("invalid parameter.\n"); \
10154 #ifdef RTE_NET_I40E
10156 /* *** deal with flow director filter *** */
10157 struct cmd_flow_director_result {
10158 cmdline_fixed_string_t flow_director_filter;
10160 cmdline_fixed_string_t mode;
10161 cmdline_fixed_string_t mode_value;
10162 cmdline_fixed_string_t ops;
10163 cmdline_fixed_string_t flow;
10164 cmdline_fixed_string_t flow_type;
10165 cmdline_fixed_string_t drop;
10166 cmdline_fixed_string_t queue;
10168 cmdline_fixed_string_t fd_id;
10169 uint32_t fd_id_value;
10170 cmdline_fixed_string_t packet;
10175 cmd_flow_director_filter_parsed(void *parsed_result,
10176 __rte_unused struct cmdline *cl,
10177 __rte_unused void *data)
10179 struct cmd_flow_director_result *res = parsed_result;
10181 struct rte_pmd_i40e_flow_type_mapping
10182 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10183 struct rte_pmd_i40e_pkt_template_conf conf;
10184 uint16_t flow_type = str2flowtype(res->flow_type);
10185 uint16_t i, port = res->port_id;
10188 memset(&conf, 0, sizeof(conf));
10190 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10191 printf("Invalid flow type specified.\n");
10194 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10198 if (mapping[flow_type].pctype == 0ULL) {
10199 printf("Invalid flow type specified.\n");
10202 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10203 if (mapping[flow_type].pctype & (1ULL << i)) {
10204 conf.input.pctype = i;
10209 conf.input.packet = open_file(res->filepath,
10210 &conf.input.length);
10211 if (!conf.input.packet)
10213 if (!strcmp(res->drop, "drop"))
10214 conf.action.behavior =
10215 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10217 conf.action.behavior =
10218 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10219 conf.action.report_status =
10220 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10221 conf.action.rx_queue = res->queue_id;
10222 conf.soft_id = res->fd_id_value;
10223 add = strcmp(res->ops, "del") ? 1 : 0;
10224 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10228 printf("flow director config error: (%s)\n",
10230 close_file(conf.input.packet);
10233 cmdline_parse_token_string_t cmd_flow_director_filter =
10234 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10235 flow_director_filter, "flow_director_filter");
10236 cmdline_parse_token_num_t cmd_flow_director_port_id =
10237 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10239 cmdline_parse_token_string_t cmd_flow_director_ops =
10240 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10241 ops, "add#del#update");
10242 cmdline_parse_token_string_t cmd_flow_director_flow =
10243 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10245 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10246 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10248 cmdline_parse_token_string_t cmd_flow_director_drop =
10249 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10251 cmdline_parse_token_string_t cmd_flow_director_queue =
10252 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10254 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10255 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10257 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10258 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10260 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10261 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10262 fd_id_value, UINT32);
10264 cmdline_parse_token_string_t cmd_flow_director_mode =
10265 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10267 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10268 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10269 mode_value, "raw");
10270 cmdline_parse_token_string_t cmd_flow_director_packet =
10271 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10273 cmdline_parse_token_string_t cmd_flow_director_filepath =
10274 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10277 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10278 .f = cmd_flow_director_filter_parsed,
10280 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10281 "director entry on NIC",
10283 (void *)&cmd_flow_director_filter,
10284 (void *)&cmd_flow_director_port_id,
10285 (void *)&cmd_flow_director_mode,
10286 (void *)&cmd_flow_director_mode_raw,
10287 (void *)&cmd_flow_director_ops,
10288 (void *)&cmd_flow_director_flow,
10289 (void *)&cmd_flow_director_flow_type,
10290 (void *)&cmd_flow_director_drop,
10291 (void *)&cmd_flow_director_queue,
10292 (void *)&cmd_flow_director_queue_id,
10293 (void *)&cmd_flow_director_fd_id,
10294 (void *)&cmd_flow_director_fd_id_value,
10295 (void *)&cmd_flow_director_packet,
10296 (void *)&cmd_flow_director_filepath,
10301 #endif /* RTE_NET_I40E */
10303 /* *** deal with flow director mask *** */
10304 struct cmd_flow_director_mask_result {
10305 cmdline_fixed_string_t flow_director_mask;
10307 cmdline_fixed_string_t mode;
10308 cmdline_fixed_string_t mode_value;
10309 cmdline_fixed_string_t vlan;
10310 uint16_t vlan_mask;
10311 cmdline_fixed_string_t src_mask;
10312 cmdline_ipaddr_t ipv4_src;
10313 cmdline_ipaddr_t ipv6_src;
10315 cmdline_fixed_string_t dst_mask;
10316 cmdline_ipaddr_t ipv4_dst;
10317 cmdline_ipaddr_t ipv6_dst;
10319 cmdline_fixed_string_t mac;
10320 uint8_t mac_addr_byte_mask;
10321 cmdline_fixed_string_t tunnel_id;
10322 uint32_t tunnel_id_mask;
10323 cmdline_fixed_string_t tunnel_type;
10324 uint8_t tunnel_type_mask;
10328 cmd_flow_director_mask_parsed(void *parsed_result,
10329 __rte_unused struct cmdline *cl,
10330 __rte_unused void *data)
10332 struct cmd_flow_director_mask_result *res = parsed_result;
10333 struct rte_eth_fdir_masks *mask;
10334 struct rte_port *port;
10336 port = &ports[res->port_id];
10337 /** Check if the port is not started **/
10338 if (port->port_status != RTE_PORT_STOPPED) {
10339 printf("Please stop port %d first\n", res->port_id);
10343 mask = &port->dev_conf.fdir_conf.mask;
10345 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10346 if (strcmp(res->mode_value, "MAC-VLAN")) {
10347 printf("Please set mode to MAC-VLAN.\n");
10351 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10352 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10353 if (strcmp(res->mode_value, "Tunnel")) {
10354 printf("Please set mode to Tunnel.\n");
10358 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10359 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10360 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10361 mask->tunnel_type_mask = res->tunnel_type_mask;
10363 if (strcmp(res->mode_value, "IP")) {
10364 printf("Please set mode to IP.\n");
10368 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10369 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10370 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10371 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10372 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10373 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10374 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10377 cmd_reconfig_device_queue(res->port_id, 1, 1);
10380 cmdline_parse_token_string_t cmd_flow_director_mask =
10381 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10382 flow_director_mask, "flow_director_mask");
10383 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10384 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10386 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10387 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10389 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10390 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10391 vlan_mask, UINT16);
10392 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10393 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10394 src_mask, "src_mask");
10395 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10396 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10398 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10399 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10401 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10402 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10404 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10405 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10406 dst_mask, "dst_mask");
10407 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10408 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10410 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10411 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10413 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10414 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10417 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10418 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10420 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10421 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10423 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10424 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10425 mode_value, "MAC-VLAN");
10426 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10427 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10428 mode_value, "Tunnel");
10429 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10430 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10432 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10433 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10434 mac_addr_byte_mask, UINT8);
10435 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10436 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10437 tunnel_type, "tunnel-type");
10438 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10439 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10440 tunnel_type_mask, UINT8);
10441 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10442 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10443 tunnel_id, "tunnel-id");
10444 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10445 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10446 tunnel_id_mask, UINT32);
10448 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10449 .f = cmd_flow_director_mask_parsed,
10451 .help_str = "flow_director_mask ... : "
10452 "Set IP mode flow director's mask on NIC",
10454 (void *)&cmd_flow_director_mask,
10455 (void *)&cmd_flow_director_mask_port_id,
10456 (void *)&cmd_flow_director_mask_mode,
10457 (void *)&cmd_flow_director_mask_mode_ip,
10458 (void *)&cmd_flow_director_mask_vlan,
10459 (void *)&cmd_flow_director_mask_vlan_value,
10460 (void *)&cmd_flow_director_mask_src,
10461 (void *)&cmd_flow_director_mask_ipv4_src,
10462 (void *)&cmd_flow_director_mask_ipv6_src,
10463 (void *)&cmd_flow_director_mask_port_src,
10464 (void *)&cmd_flow_director_mask_dst,
10465 (void *)&cmd_flow_director_mask_ipv4_dst,
10466 (void *)&cmd_flow_director_mask_ipv6_dst,
10467 (void *)&cmd_flow_director_mask_port_dst,
10472 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10473 .f = cmd_flow_director_mask_parsed,
10475 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10476 "flow director's mask on NIC",
10478 (void *)&cmd_flow_director_mask,
10479 (void *)&cmd_flow_director_mask_port_id,
10480 (void *)&cmd_flow_director_mask_mode,
10481 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10482 (void *)&cmd_flow_director_mask_vlan,
10483 (void *)&cmd_flow_director_mask_vlan_value,
10488 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10489 .f = cmd_flow_director_mask_parsed,
10491 .help_str = "flow_director_mask ... : Set tunnel mode "
10492 "flow director's mask on NIC",
10494 (void *)&cmd_flow_director_mask,
10495 (void *)&cmd_flow_director_mask_port_id,
10496 (void *)&cmd_flow_director_mask_mode,
10497 (void *)&cmd_flow_director_mask_mode_tunnel,
10498 (void *)&cmd_flow_director_mask_vlan,
10499 (void *)&cmd_flow_director_mask_vlan_value,
10500 (void *)&cmd_flow_director_mask_mac,
10501 (void *)&cmd_flow_director_mask_mac_value,
10502 (void *)&cmd_flow_director_mask_tunnel_type,
10503 (void *)&cmd_flow_director_mask_tunnel_type_value,
10504 (void *)&cmd_flow_director_mask_tunnel_id,
10505 (void *)&cmd_flow_director_mask_tunnel_id_value,
10510 /* *** deal with flow director flexible payload configuration *** */
10511 struct cmd_flow_director_flexpayload_result {
10512 cmdline_fixed_string_t flow_director_flexpayload;
10514 cmdline_fixed_string_t payload_layer;
10515 cmdline_fixed_string_t payload_cfg;
10519 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10522 const char *p, *p0 = q_arg;
10524 unsigned long int_fld;
10525 char *str_fld[max_num];
10530 p = strchr(p0, '(');
10534 p0 = strchr(p, ')');
10539 if (size >= sizeof(s))
10542 snprintf(s, sizeof(s), "%.*s", size, p);
10543 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10544 if (ret < 0 || ret > max_num)
10546 for (i = 0; i < ret; i++) {
10548 int_fld = strtoul(str_fld[i], &end, 0);
10549 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10551 offsets[i] = (uint16_t)int_fld;
10557 cmd_flow_director_flxpld_parsed(void *parsed_result,
10558 __rte_unused struct cmdline *cl,
10559 __rte_unused void *data)
10561 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10562 struct rte_eth_flex_payload_cfg flex_cfg;
10563 struct rte_port *port;
10566 port = &ports[res->port_id];
10567 /** Check if the port is not started **/
10568 if (port->port_status != RTE_PORT_STOPPED) {
10569 printf("Please stop port %d first\n", res->port_id);
10573 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10575 if (!strcmp(res->payload_layer, "raw"))
10576 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10577 else if (!strcmp(res->payload_layer, "l2"))
10578 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10579 else if (!strcmp(res->payload_layer, "l3"))
10580 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10581 else if (!strcmp(res->payload_layer, "l4"))
10582 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10584 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10585 RTE_ETH_FDIR_MAX_FLEXLEN);
10587 printf("error: Cannot parse flex payload input.\n");
10591 fdir_set_flex_payload(res->port_id, &flex_cfg);
10592 cmd_reconfig_device_queue(res->port_id, 1, 1);
10595 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10596 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10597 flow_director_flexpayload,
10598 "flow_director_flex_payload");
10599 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10600 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10602 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10603 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10604 payload_layer, "raw#l2#l3#l4");
10605 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10606 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10607 payload_cfg, NULL);
10609 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10610 .f = cmd_flow_director_flxpld_parsed,
10612 .help_str = "flow_director_flexpayload ... : "
10613 "Set flow director's flex payload on NIC",
10615 (void *)&cmd_flow_director_flexpayload,
10616 (void *)&cmd_flow_director_flexpayload_port_id,
10617 (void *)&cmd_flow_director_flexpayload_payload_layer,
10618 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10623 /* Generic flow interface command. */
10624 extern cmdline_parse_inst_t cmd_flow;
10626 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10627 struct cmd_mcast_addr_result {
10628 cmdline_fixed_string_t mcast_addr_cmd;
10629 cmdline_fixed_string_t what;
10631 struct rte_ether_addr mc_addr;
10634 static void cmd_mcast_addr_parsed(void *parsed_result,
10635 __rte_unused struct cmdline *cl,
10636 __rte_unused void *data)
10638 struct cmd_mcast_addr_result *res = parsed_result;
10640 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
10641 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10642 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10643 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10644 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10647 if (strcmp(res->what, "add") == 0)
10648 mcast_addr_add(res->port_num, &res->mc_addr);
10650 mcast_addr_remove(res->port_num, &res->mc_addr);
10653 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10654 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10655 mcast_addr_cmd, "mcast_addr");
10656 cmdline_parse_token_string_t cmd_mcast_addr_what =
10657 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10659 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10660 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
10661 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10662 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10664 cmdline_parse_inst_t cmd_mcast_addr = {
10665 .f = cmd_mcast_addr_parsed,
10667 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10668 "Add/Remove multicast MAC address on port_id",
10670 (void *)&cmd_mcast_addr_cmd,
10671 (void *)&cmd_mcast_addr_what,
10672 (void *)&cmd_mcast_addr_portnum,
10673 (void *)&cmd_mcast_addr_addr,
10678 /* l2 tunnel config
10679 * only support E-tag now.
10682 /* Ether type config */
10683 struct cmd_config_l2_tunnel_eth_type_result {
10684 cmdline_fixed_string_t port;
10685 cmdline_fixed_string_t config;
10686 cmdline_fixed_string_t all;
10688 cmdline_fixed_string_t l2_tunnel;
10689 cmdline_fixed_string_t l2_tunnel_type;
10690 cmdline_fixed_string_t eth_type;
10691 uint16_t eth_type_val;
10694 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
10695 TOKEN_STRING_INITIALIZER
10696 (struct cmd_config_l2_tunnel_eth_type_result,
10698 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
10699 TOKEN_STRING_INITIALIZER
10700 (struct cmd_config_l2_tunnel_eth_type_result,
10702 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
10703 TOKEN_STRING_INITIALIZER
10704 (struct cmd_config_l2_tunnel_eth_type_result,
10706 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
10707 TOKEN_NUM_INITIALIZER
10708 (struct cmd_config_l2_tunnel_eth_type_result,
10710 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
10711 TOKEN_STRING_INITIALIZER
10712 (struct cmd_config_l2_tunnel_eth_type_result,
10713 l2_tunnel, "l2-tunnel");
10714 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
10715 TOKEN_STRING_INITIALIZER
10716 (struct cmd_config_l2_tunnel_eth_type_result,
10717 l2_tunnel_type, "E-tag");
10718 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
10719 TOKEN_STRING_INITIALIZER
10720 (struct cmd_config_l2_tunnel_eth_type_result,
10721 eth_type, "ether-type");
10722 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
10723 TOKEN_NUM_INITIALIZER
10724 (struct cmd_config_l2_tunnel_eth_type_result,
10725 eth_type_val, UINT16);
10727 static enum rte_eth_tunnel_type
10728 str2fdir_l2_tunnel_type(char *string)
10732 static const struct {
10734 enum rte_eth_tunnel_type type;
10735 } l2_tunnel_type_str[] = {
10736 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10739 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10740 if (!strcmp(l2_tunnel_type_str[i].str, string))
10741 return l2_tunnel_type_str[i].type;
10743 return RTE_TUNNEL_TYPE_NONE;
10746 /* ether type config for all ports */
10748 cmd_config_l2_tunnel_eth_type_all_parsed
10749 (void *parsed_result,
10750 __rte_unused struct cmdline *cl,
10751 __rte_unused void *data)
10753 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
10754 struct rte_eth_l2_tunnel_conf entry;
10757 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10758 entry.ether_type = res->eth_type_val;
10760 RTE_ETH_FOREACH_DEV(pid) {
10761 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
10765 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
10766 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
10768 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
10770 (void *)&cmd_config_l2_tunnel_eth_type_port,
10771 (void *)&cmd_config_l2_tunnel_eth_type_config,
10772 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
10773 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10774 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10775 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10776 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10781 /* ether type config for a specific port */
10783 cmd_config_l2_tunnel_eth_type_specific_parsed(
10784 void *parsed_result,
10785 __rte_unused struct cmdline *cl,
10786 __rte_unused void *data)
10788 struct cmd_config_l2_tunnel_eth_type_result *res =
10790 struct rte_eth_l2_tunnel_conf entry;
10792 if (port_id_is_invalid(res->id, ENABLED_WARN))
10795 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10796 entry.ether_type = res->eth_type_val;
10798 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
10801 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
10802 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
10804 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
10806 (void *)&cmd_config_l2_tunnel_eth_type_port,
10807 (void *)&cmd_config_l2_tunnel_eth_type_config,
10808 (void *)&cmd_config_l2_tunnel_eth_type_id,
10809 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
10810 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
10811 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
10812 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
10817 /* Enable/disable l2 tunnel */
10818 struct cmd_config_l2_tunnel_en_dis_result {
10819 cmdline_fixed_string_t port;
10820 cmdline_fixed_string_t config;
10821 cmdline_fixed_string_t all;
10823 cmdline_fixed_string_t l2_tunnel;
10824 cmdline_fixed_string_t l2_tunnel_type;
10825 cmdline_fixed_string_t en_dis;
10828 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10829 TOKEN_STRING_INITIALIZER
10830 (struct cmd_config_l2_tunnel_en_dis_result,
10832 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10833 TOKEN_STRING_INITIALIZER
10834 (struct cmd_config_l2_tunnel_en_dis_result,
10836 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10837 TOKEN_STRING_INITIALIZER
10838 (struct cmd_config_l2_tunnel_en_dis_result,
10840 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10841 TOKEN_NUM_INITIALIZER
10842 (struct cmd_config_l2_tunnel_en_dis_result,
10844 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10845 TOKEN_STRING_INITIALIZER
10846 (struct cmd_config_l2_tunnel_en_dis_result,
10847 l2_tunnel, "l2-tunnel");
10848 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10849 TOKEN_STRING_INITIALIZER
10850 (struct cmd_config_l2_tunnel_en_dis_result,
10851 l2_tunnel_type, "E-tag");
10852 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10853 TOKEN_STRING_INITIALIZER
10854 (struct cmd_config_l2_tunnel_en_dis_result,
10855 en_dis, "enable#disable");
10857 /* enable/disable l2 tunnel for all ports */
10859 cmd_config_l2_tunnel_en_dis_all_parsed(
10860 void *parsed_result,
10861 __rte_unused struct cmdline *cl,
10862 __rte_unused void *data)
10864 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10865 struct rte_eth_l2_tunnel_conf entry;
10869 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10871 if (!strcmp("enable", res->en_dis))
10876 RTE_ETH_FOREACH_DEV(pid) {
10877 rte_eth_dev_l2_tunnel_offload_set(pid,
10879 ETH_L2_TUNNEL_ENABLE_MASK,
10884 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10885 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10887 .help_str = "port config all l2-tunnel E-tag enable|disable",
10889 (void *)&cmd_config_l2_tunnel_en_dis_port,
10890 (void *)&cmd_config_l2_tunnel_en_dis_config,
10891 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10892 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10893 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10894 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10899 /* enable/disable l2 tunnel for a port */
10901 cmd_config_l2_tunnel_en_dis_specific_parsed(
10902 void *parsed_result,
10903 __rte_unused struct cmdline *cl,
10904 __rte_unused void *data)
10906 struct cmd_config_l2_tunnel_en_dis_result *res =
10908 struct rte_eth_l2_tunnel_conf entry;
10910 if (port_id_is_invalid(res->id, ENABLED_WARN))
10913 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10915 if (!strcmp("enable", res->en_dis))
10916 rte_eth_dev_l2_tunnel_offload_set(res->id,
10918 ETH_L2_TUNNEL_ENABLE_MASK,
10921 rte_eth_dev_l2_tunnel_offload_set(res->id,
10923 ETH_L2_TUNNEL_ENABLE_MASK,
10927 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10928 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10930 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10932 (void *)&cmd_config_l2_tunnel_en_dis_port,
10933 (void *)&cmd_config_l2_tunnel_en_dis_config,
10934 (void *)&cmd_config_l2_tunnel_en_dis_id,
10935 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10936 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10937 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10942 /* E-tag configuration */
10944 /* Common result structure for all E-tag configuration */
10945 struct cmd_config_e_tag_result {
10946 cmdline_fixed_string_t e_tag;
10947 cmdline_fixed_string_t set;
10948 cmdline_fixed_string_t insertion;
10949 cmdline_fixed_string_t stripping;
10950 cmdline_fixed_string_t forwarding;
10951 cmdline_fixed_string_t filter;
10952 cmdline_fixed_string_t add;
10953 cmdline_fixed_string_t del;
10954 cmdline_fixed_string_t on;
10955 cmdline_fixed_string_t off;
10956 cmdline_fixed_string_t on_off;
10957 cmdline_fixed_string_t port_tag_id;
10958 uint32_t port_tag_id_val;
10959 cmdline_fixed_string_t e_tag_id;
10960 uint16_t e_tag_id_val;
10961 cmdline_fixed_string_t dst_pool;
10962 uint8_t dst_pool_val;
10963 cmdline_fixed_string_t port;
10965 cmdline_fixed_string_t vf;
10969 /* Common CLI fields for all E-tag configuration */
10970 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10971 TOKEN_STRING_INITIALIZER
10972 (struct cmd_config_e_tag_result,
10974 cmdline_parse_token_string_t cmd_config_e_tag_set =
10975 TOKEN_STRING_INITIALIZER
10976 (struct cmd_config_e_tag_result,
10978 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10979 TOKEN_STRING_INITIALIZER
10980 (struct cmd_config_e_tag_result,
10981 insertion, "insertion");
10982 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10983 TOKEN_STRING_INITIALIZER
10984 (struct cmd_config_e_tag_result,
10985 stripping, "stripping");
10986 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10987 TOKEN_STRING_INITIALIZER
10988 (struct cmd_config_e_tag_result,
10989 forwarding, "forwarding");
10990 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10991 TOKEN_STRING_INITIALIZER
10992 (struct cmd_config_e_tag_result,
10994 cmdline_parse_token_string_t cmd_config_e_tag_add =
10995 TOKEN_STRING_INITIALIZER
10996 (struct cmd_config_e_tag_result,
10998 cmdline_parse_token_string_t cmd_config_e_tag_del =
10999 TOKEN_STRING_INITIALIZER
11000 (struct cmd_config_e_tag_result,
11002 cmdline_parse_token_string_t cmd_config_e_tag_on =
11003 TOKEN_STRING_INITIALIZER
11004 (struct cmd_config_e_tag_result,
11006 cmdline_parse_token_string_t cmd_config_e_tag_off =
11007 TOKEN_STRING_INITIALIZER
11008 (struct cmd_config_e_tag_result,
11010 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
11011 TOKEN_STRING_INITIALIZER
11012 (struct cmd_config_e_tag_result,
11014 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
11015 TOKEN_STRING_INITIALIZER
11016 (struct cmd_config_e_tag_result,
11017 port_tag_id, "port-tag-id");
11018 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
11019 TOKEN_NUM_INITIALIZER
11020 (struct cmd_config_e_tag_result,
11021 port_tag_id_val, UINT32);
11022 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
11023 TOKEN_STRING_INITIALIZER
11024 (struct cmd_config_e_tag_result,
11025 e_tag_id, "e-tag-id");
11026 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
11027 TOKEN_NUM_INITIALIZER
11028 (struct cmd_config_e_tag_result,
11029 e_tag_id_val, UINT16);
11030 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
11031 TOKEN_STRING_INITIALIZER
11032 (struct cmd_config_e_tag_result,
11033 dst_pool, "dst-pool");
11034 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
11035 TOKEN_NUM_INITIALIZER
11036 (struct cmd_config_e_tag_result,
11037 dst_pool_val, UINT8);
11038 cmdline_parse_token_string_t cmd_config_e_tag_port =
11039 TOKEN_STRING_INITIALIZER
11040 (struct cmd_config_e_tag_result,
11042 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
11043 TOKEN_NUM_INITIALIZER
11044 (struct cmd_config_e_tag_result,
11046 cmdline_parse_token_string_t cmd_config_e_tag_vf =
11047 TOKEN_STRING_INITIALIZER
11048 (struct cmd_config_e_tag_result,
11050 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
11051 TOKEN_NUM_INITIALIZER
11052 (struct cmd_config_e_tag_result,
11055 /* E-tag insertion configuration */
11057 cmd_config_e_tag_insertion_en_parsed(
11058 void *parsed_result,
11059 __rte_unused struct cmdline *cl,
11060 __rte_unused void *data)
11062 struct cmd_config_e_tag_result *res =
11064 struct rte_eth_l2_tunnel_conf entry;
11066 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11069 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11070 entry.tunnel_id = res->port_tag_id_val;
11071 entry.vf_id = res->vf_id;
11072 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11074 ETH_L2_TUNNEL_INSERTION_MASK,
11079 cmd_config_e_tag_insertion_dis_parsed(
11080 void *parsed_result,
11081 __rte_unused struct cmdline *cl,
11082 __rte_unused void *data)
11084 struct cmd_config_e_tag_result *res =
11086 struct rte_eth_l2_tunnel_conf entry;
11088 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11091 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11092 entry.vf_id = res->vf_id;
11094 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
11096 ETH_L2_TUNNEL_INSERTION_MASK,
11100 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
11101 .f = cmd_config_e_tag_insertion_en_parsed,
11103 .help_str = "E-tag ... : E-tag insertion enable",
11105 (void *)&cmd_config_e_tag_e_tag,
11106 (void *)&cmd_config_e_tag_set,
11107 (void *)&cmd_config_e_tag_insertion,
11108 (void *)&cmd_config_e_tag_on,
11109 (void *)&cmd_config_e_tag_port_tag_id,
11110 (void *)&cmd_config_e_tag_port_tag_id_val,
11111 (void *)&cmd_config_e_tag_port,
11112 (void *)&cmd_config_e_tag_port_id,
11113 (void *)&cmd_config_e_tag_vf,
11114 (void *)&cmd_config_e_tag_vf_id,
11119 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
11120 .f = cmd_config_e_tag_insertion_dis_parsed,
11122 .help_str = "E-tag ... : E-tag insertion disable",
11124 (void *)&cmd_config_e_tag_e_tag,
11125 (void *)&cmd_config_e_tag_set,
11126 (void *)&cmd_config_e_tag_insertion,
11127 (void *)&cmd_config_e_tag_off,
11128 (void *)&cmd_config_e_tag_port,
11129 (void *)&cmd_config_e_tag_port_id,
11130 (void *)&cmd_config_e_tag_vf,
11131 (void *)&cmd_config_e_tag_vf_id,
11136 /* E-tag stripping configuration */
11138 cmd_config_e_tag_stripping_parsed(
11139 void *parsed_result,
11140 __rte_unused struct cmdline *cl,
11141 __rte_unused void *data)
11143 struct cmd_config_e_tag_result *res =
11145 struct rte_eth_l2_tunnel_conf entry;
11147 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11150 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11152 if (!strcmp(res->on_off, "on"))
11153 rte_eth_dev_l2_tunnel_offload_set
11156 ETH_L2_TUNNEL_STRIPPING_MASK,
11159 rte_eth_dev_l2_tunnel_offload_set
11162 ETH_L2_TUNNEL_STRIPPING_MASK,
11166 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
11167 .f = cmd_config_e_tag_stripping_parsed,
11169 .help_str = "E-tag ... : E-tag stripping enable/disable",
11171 (void *)&cmd_config_e_tag_e_tag,
11172 (void *)&cmd_config_e_tag_set,
11173 (void *)&cmd_config_e_tag_stripping,
11174 (void *)&cmd_config_e_tag_on_off,
11175 (void *)&cmd_config_e_tag_port,
11176 (void *)&cmd_config_e_tag_port_id,
11181 /* E-tag forwarding configuration */
11183 cmd_config_e_tag_forwarding_parsed(
11184 void *parsed_result,
11185 __rte_unused struct cmdline *cl,
11186 __rte_unused void *data)
11188 struct cmd_config_e_tag_result *res = parsed_result;
11189 struct rte_eth_l2_tunnel_conf entry;
11191 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11194 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11196 if (!strcmp(res->on_off, "on"))
11197 rte_eth_dev_l2_tunnel_offload_set
11200 ETH_L2_TUNNEL_FORWARDING_MASK,
11203 rte_eth_dev_l2_tunnel_offload_set
11206 ETH_L2_TUNNEL_FORWARDING_MASK,
11210 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
11211 .f = cmd_config_e_tag_forwarding_parsed,
11213 .help_str = "E-tag ... : E-tag forwarding enable/disable",
11215 (void *)&cmd_config_e_tag_e_tag,
11216 (void *)&cmd_config_e_tag_set,
11217 (void *)&cmd_config_e_tag_forwarding,
11218 (void *)&cmd_config_e_tag_on_off,
11219 (void *)&cmd_config_e_tag_port,
11220 (void *)&cmd_config_e_tag_port_id,
11225 /* vf vlan anti spoof configuration */
11227 /* Common result structure for vf vlan anti spoof */
11228 struct cmd_vf_vlan_anti_spoof_result {
11229 cmdline_fixed_string_t set;
11230 cmdline_fixed_string_t vf;
11231 cmdline_fixed_string_t vlan;
11232 cmdline_fixed_string_t antispoof;
11235 cmdline_fixed_string_t on_off;
11238 /* Common CLI fields for vf vlan anti spoof enable disable */
11239 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
11240 TOKEN_STRING_INITIALIZER
11241 (struct cmd_vf_vlan_anti_spoof_result,
11243 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
11244 TOKEN_STRING_INITIALIZER
11245 (struct cmd_vf_vlan_anti_spoof_result,
11247 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
11248 TOKEN_STRING_INITIALIZER
11249 (struct cmd_vf_vlan_anti_spoof_result,
11251 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
11252 TOKEN_STRING_INITIALIZER
11253 (struct cmd_vf_vlan_anti_spoof_result,
11254 antispoof, "antispoof");
11255 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
11256 TOKEN_NUM_INITIALIZER
11257 (struct cmd_vf_vlan_anti_spoof_result,
11259 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
11260 TOKEN_NUM_INITIALIZER
11261 (struct cmd_vf_vlan_anti_spoof_result,
11263 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11264 TOKEN_STRING_INITIALIZER
11265 (struct cmd_vf_vlan_anti_spoof_result,
11269 cmd_set_vf_vlan_anti_spoof_parsed(
11270 void *parsed_result,
11271 __rte_unused struct cmdline *cl,
11272 __rte_unused void *data)
11274 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
11275 int ret = -ENOTSUP;
11277 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11279 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11282 #ifdef RTE_NET_IXGBE
11283 if (ret == -ENOTSUP)
11284 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11285 res->vf_id, is_on);
11287 #ifdef RTE_NET_I40E
11288 if (ret == -ENOTSUP)
11289 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11290 res->vf_id, is_on);
11292 #ifdef RTE_NET_BNXT
11293 if (ret == -ENOTSUP)
11294 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11295 res->vf_id, is_on);
11302 printf("invalid vf_id %d\n", res->vf_id);
11305 printf("invalid port_id %d\n", res->port_id);
11308 printf("function not implemented\n");
11311 printf("programming error: (%s)\n", strerror(-ret));
11315 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11316 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11318 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11320 (void *)&cmd_vf_vlan_anti_spoof_set,
11321 (void *)&cmd_vf_vlan_anti_spoof_vf,
11322 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11323 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11324 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11325 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11326 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11331 /* vf mac anti spoof configuration */
11333 /* Common result structure for vf mac anti spoof */
11334 struct cmd_vf_mac_anti_spoof_result {
11335 cmdline_fixed_string_t set;
11336 cmdline_fixed_string_t vf;
11337 cmdline_fixed_string_t mac;
11338 cmdline_fixed_string_t antispoof;
11341 cmdline_fixed_string_t on_off;
11344 /* Common CLI fields for vf mac anti spoof enable disable */
11345 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11346 TOKEN_STRING_INITIALIZER
11347 (struct cmd_vf_mac_anti_spoof_result,
11349 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11350 TOKEN_STRING_INITIALIZER
11351 (struct cmd_vf_mac_anti_spoof_result,
11353 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11354 TOKEN_STRING_INITIALIZER
11355 (struct cmd_vf_mac_anti_spoof_result,
11357 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11358 TOKEN_STRING_INITIALIZER
11359 (struct cmd_vf_mac_anti_spoof_result,
11360 antispoof, "antispoof");
11361 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11362 TOKEN_NUM_INITIALIZER
11363 (struct cmd_vf_mac_anti_spoof_result,
11365 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11366 TOKEN_NUM_INITIALIZER
11367 (struct cmd_vf_mac_anti_spoof_result,
11369 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11370 TOKEN_STRING_INITIALIZER
11371 (struct cmd_vf_mac_anti_spoof_result,
11375 cmd_set_vf_mac_anti_spoof_parsed(
11376 void *parsed_result,
11377 __rte_unused struct cmdline *cl,
11378 __rte_unused void *data)
11380 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11381 int ret = -ENOTSUP;
11383 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11385 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11388 #ifdef RTE_NET_IXGBE
11389 if (ret == -ENOTSUP)
11390 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11391 res->vf_id, is_on);
11393 #ifdef RTE_NET_I40E
11394 if (ret == -ENOTSUP)
11395 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11396 res->vf_id, is_on);
11398 #ifdef RTE_NET_BNXT
11399 if (ret == -ENOTSUP)
11400 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11401 res->vf_id, is_on);
11408 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11411 printf("invalid port_id %d\n", res->port_id);
11414 printf("function not implemented\n");
11417 printf("programming error: (%s)\n", strerror(-ret));
11421 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11422 .f = cmd_set_vf_mac_anti_spoof_parsed,
11424 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11426 (void *)&cmd_vf_mac_anti_spoof_set,
11427 (void *)&cmd_vf_mac_anti_spoof_vf,
11428 (void *)&cmd_vf_mac_anti_spoof_mac,
11429 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11430 (void *)&cmd_vf_mac_anti_spoof_port_id,
11431 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11432 (void *)&cmd_vf_mac_anti_spoof_on_off,
11437 /* vf vlan strip queue configuration */
11439 /* Common result structure for vf mac anti spoof */
11440 struct cmd_vf_vlan_stripq_result {
11441 cmdline_fixed_string_t set;
11442 cmdline_fixed_string_t vf;
11443 cmdline_fixed_string_t vlan;
11444 cmdline_fixed_string_t stripq;
11447 cmdline_fixed_string_t on_off;
11450 /* Common CLI fields for vf vlan strip enable disable */
11451 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11452 TOKEN_STRING_INITIALIZER
11453 (struct cmd_vf_vlan_stripq_result,
11455 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11456 TOKEN_STRING_INITIALIZER
11457 (struct cmd_vf_vlan_stripq_result,
11459 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11460 TOKEN_STRING_INITIALIZER
11461 (struct cmd_vf_vlan_stripq_result,
11463 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11464 TOKEN_STRING_INITIALIZER
11465 (struct cmd_vf_vlan_stripq_result,
11467 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11468 TOKEN_NUM_INITIALIZER
11469 (struct cmd_vf_vlan_stripq_result,
11471 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11472 TOKEN_NUM_INITIALIZER
11473 (struct cmd_vf_vlan_stripq_result,
11475 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11476 TOKEN_STRING_INITIALIZER
11477 (struct cmd_vf_vlan_stripq_result,
11481 cmd_set_vf_vlan_stripq_parsed(
11482 void *parsed_result,
11483 __rte_unused struct cmdline *cl,
11484 __rte_unused void *data)
11486 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11487 int ret = -ENOTSUP;
11489 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11491 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11494 #ifdef RTE_NET_IXGBE
11495 if (ret == -ENOTSUP)
11496 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11497 res->vf_id, is_on);
11499 #ifdef RTE_NET_I40E
11500 if (ret == -ENOTSUP)
11501 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11502 res->vf_id, is_on);
11504 #ifdef RTE_NET_BNXT
11505 if (ret == -ENOTSUP)
11506 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11507 res->vf_id, is_on);
11514 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11517 printf("invalid port_id %d\n", res->port_id);
11520 printf("function not implemented\n");
11523 printf("programming error: (%s)\n", strerror(-ret));
11527 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11528 .f = cmd_set_vf_vlan_stripq_parsed,
11530 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11532 (void *)&cmd_vf_vlan_stripq_set,
11533 (void *)&cmd_vf_vlan_stripq_vf,
11534 (void *)&cmd_vf_vlan_stripq_vlan,
11535 (void *)&cmd_vf_vlan_stripq_stripq,
11536 (void *)&cmd_vf_vlan_stripq_port_id,
11537 (void *)&cmd_vf_vlan_stripq_vf_id,
11538 (void *)&cmd_vf_vlan_stripq_on_off,
11543 /* vf vlan insert configuration */
11545 /* Common result structure for vf vlan insert */
11546 struct cmd_vf_vlan_insert_result {
11547 cmdline_fixed_string_t set;
11548 cmdline_fixed_string_t vf;
11549 cmdline_fixed_string_t vlan;
11550 cmdline_fixed_string_t insert;
11556 /* Common CLI fields for vf vlan insert enable disable */
11557 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11558 TOKEN_STRING_INITIALIZER
11559 (struct cmd_vf_vlan_insert_result,
11561 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11562 TOKEN_STRING_INITIALIZER
11563 (struct cmd_vf_vlan_insert_result,
11565 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11566 TOKEN_STRING_INITIALIZER
11567 (struct cmd_vf_vlan_insert_result,
11569 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11570 TOKEN_STRING_INITIALIZER
11571 (struct cmd_vf_vlan_insert_result,
11573 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11574 TOKEN_NUM_INITIALIZER
11575 (struct cmd_vf_vlan_insert_result,
11577 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11578 TOKEN_NUM_INITIALIZER
11579 (struct cmd_vf_vlan_insert_result,
11581 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11582 TOKEN_NUM_INITIALIZER
11583 (struct cmd_vf_vlan_insert_result,
11587 cmd_set_vf_vlan_insert_parsed(
11588 void *parsed_result,
11589 __rte_unused struct cmdline *cl,
11590 __rte_unused void *data)
11592 struct cmd_vf_vlan_insert_result *res = parsed_result;
11593 int ret = -ENOTSUP;
11595 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11598 #ifdef RTE_NET_IXGBE
11599 if (ret == -ENOTSUP)
11600 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11603 #ifdef RTE_NET_I40E
11604 if (ret == -ENOTSUP)
11605 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11608 #ifdef RTE_NET_BNXT
11609 if (ret == -ENOTSUP)
11610 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11618 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11621 printf("invalid port_id %d\n", res->port_id);
11624 printf("function not implemented\n");
11627 printf("programming error: (%s)\n", strerror(-ret));
11631 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11632 .f = cmd_set_vf_vlan_insert_parsed,
11634 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11636 (void *)&cmd_vf_vlan_insert_set,
11637 (void *)&cmd_vf_vlan_insert_vf,
11638 (void *)&cmd_vf_vlan_insert_vlan,
11639 (void *)&cmd_vf_vlan_insert_insert,
11640 (void *)&cmd_vf_vlan_insert_port_id,
11641 (void *)&cmd_vf_vlan_insert_vf_id,
11642 (void *)&cmd_vf_vlan_insert_vlan_id,
11647 /* tx loopback configuration */
11649 /* Common result structure for tx loopback */
11650 struct cmd_tx_loopback_result {
11651 cmdline_fixed_string_t set;
11652 cmdline_fixed_string_t tx;
11653 cmdline_fixed_string_t loopback;
11655 cmdline_fixed_string_t on_off;
11658 /* Common CLI fields for tx loopback enable disable */
11659 cmdline_parse_token_string_t cmd_tx_loopback_set =
11660 TOKEN_STRING_INITIALIZER
11661 (struct cmd_tx_loopback_result,
11663 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11664 TOKEN_STRING_INITIALIZER
11665 (struct cmd_tx_loopback_result,
11667 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11668 TOKEN_STRING_INITIALIZER
11669 (struct cmd_tx_loopback_result,
11670 loopback, "loopback");
11671 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11672 TOKEN_NUM_INITIALIZER
11673 (struct cmd_tx_loopback_result,
11675 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11676 TOKEN_STRING_INITIALIZER
11677 (struct cmd_tx_loopback_result,
11681 cmd_set_tx_loopback_parsed(
11682 void *parsed_result,
11683 __rte_unused struct cmdline *cl,
11684 __rte_unused void *data)
11686 struct cmd_tx_loopback_result *res = parsed_result;
11687 int ret = -ENOTSUP;
11689 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11691 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11694 #ifdef RTE_NET_IXGBE
11695 if (ret == -ENOTSUP)
11696 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11698 #ifdef RTE_NET_I40E
11699 if (ret == -ENOTSUP)
11700 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11702 #ifdef RTE_NET_BNXT
11703 if (ret == -ENOTSUP)
11704 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11706 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11707 if (ret == -ENOTSUP)
11708 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11715 printf("invalid is_on %d\n", is_on);
11718 printf("invalid port_id %d\n", res->port_id);
11721 printf("function not implemented\n");
11724 printf("programming error: (%s)\n", strerror(-ret));
11728 cmdline_parse_inst_t cmd_set_tx_loopback = {
11729 .f = cmd_set_tx_loopback_parsed,
11731 .help_str = "set tx loopback <port_id> on|off",
11733 (void *)&cmd_tx_loopback_set,
11734 (void *)&cmd_tx_loopback_tx,
11735 (void *)&cmd_tx_loopback_loopback,
11736 (void *)&cmd_tx_loopback_port_id,
11737 (void *)&cmd_tx_loopback_on_off,
11742 /* all queues drop enable configuration */
11744 /* Common result structure for all queues drop enable */
11745 struct cmd_all_queues_drop_en_result {
11746 cmdline_fixed_string_t set;
11747 cmdline_fixed_string_t all;
11748 cmdline_fixed_string_t queues;
11749 cmdline_fixed_string_t drop;
11751 cmdline_fixed_string_t on_off;
11754 /* Common CLI fields for tx loopback enable disable */
11755 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11756 TOKEN_STRING_INITIALIZER
11757 (struct cmd_all_queues_drop_en_result,
11759 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11760 TOKEN_STRING_INITIALIZER
11761 (struct cmd_all_queues_drop_en_result,
11763 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11764 TOKEN_STRING_INITIALIZER
11765 (struct cmd_all_queues_drop_en_result,
11767 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11768 TOKEN_STRING_INITIALIZER
11769 (struct cmd_all_queues_drop_en_result,
11771 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11772 TOKEN_NUM_INITIALIZER
11773 (struct cmd_all_queues_drop_en_result,
11775 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11776 TOKEN_STRING_INITIALIZER
11777 (struct cmd_all_queues_drop_en_result,
11781 cmd_set_all_queues_drop_en_parsed(
11782 void *parsed_result,
11783 __rte_unused struct cmdline *cl,
11784 __rte_unused void *data)
11786 struct cmd_all_queues_drop_en_result *res = parsed_result;
11787 int ret = -ENOTSUP;
11788 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11790 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11793 #ifdef RTE_NET_IXGBE
11794 if (ret == -ENOTSUP)
11795 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11797 #ifdef RTE_NET_BNXT
11798 if (ret == -ENOTSUP)
11799 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11805 printf("invalid is_on %d\n", is_on);
11808 printf("invalid port_id %d\n", res->port_id);
11811 printf("function not implemented\n");
11814 printf("programming error: (%s)\n", strerror(-ret));
11818 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11819 .f = cmd_set_all_queues_drop_en_parsed,
11821 .help_str = "set all queues drop <port_id> on|off",
11823 (void *)&cmd_all_queues_drop_en_set,
11824 (void *)&cmd_all_queues_drop_en_all,
11825 (void *)&cmd_all_queues_drop_en_queues,
11826 (void *)&cmd_all_queues_drop_en_drop,
11827 (void *)&cmd_all_queues_drop_en_port_id,
11828 (void *)&cmd_all_queues_drop_en_on_off,
11833 /* vf split drop enable configuration */
11835 /* Common result structure for vf split drop enable */
11836 struct cmd_vf_split_drop_en_result {
11837 cmdline_fixed_string_t set;
11838 cmdline_fixed_string_t vf;
11839 cmdline_fixed_string_t split;
11840 cmdline_fixed_string_t drop;
11843 cmdline_fixed_string_t on_off;
11846 /* Common CLI fields for vf split drop enable disable */
11847 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11848 TOKEN_STRING_INITIALIZER
11849 (struct cmd_vf_split_drop_en_result,
11851 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11852 TOKEN_STRING_INITIALIZER
11853 (struct cmd_vf_split_drop_en_result,
11855 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11856 TOKEN_STRING_INITIALIZER
11857 (struct cmd_vf_split_drop_en_result,
11859 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11860 TOKEN_STRING_INITIALIZER
11861 (struct cmd_vf_split_drop_en_result,
11863 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11864 TOKEN_NUM_INITIALIZER
11865 (struct cmd_vf_split_drop_en_result,
11867 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11868 TOKEN_NUM_INITIALIZER
11869 (struct cmd_vf_split_drop_en_result,
11871 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11872 TOKEN_STRING_INITIALIZER
11873 (struct cmd_vf_split_drop_en_result,
11877 cmd_set_vf_split_drop_en_parsed(
11878 void *parsed_result,
11879 __rte_unused struct cmdline *cl,
11880 __rte_unused void *data)
11882 struct cmd_vf_split_drop_en_result *res = parsed_result;
11883 int ret = -ENOTSUP;
11884 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11886 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11889 #ifdef RTE_NET_IXGBE
11890 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11897 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11900 printf("invalid port_id %d\n", res->port_id);
11903 printf("not supported on port %d\n", res->port_id);
11906 printf("programming error: (%s)\n", strerror(-ret));
11910 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11911 .f = cmd_set_vf_split_drop_en_parsed,
11913 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11915 (void *)&cmd_vf_split_drop_en_set,
11916 (void *)&cmd_vf_split_drop_en_vf,
11917 (void *)&cmd_vf_split_drop_en_split,
11918 (void *)&cmd_vf_split_drop_en_drop,
11919 (void *)&cmd_vf_split_drop_en_port_id,
11920 (void *)&cmd_vf_split_drop_en_vf_id,
11921 (void *)&cmd_vf_split_drop_en_on_off,
11926 /* vf mac address configuration */
11928 /* Common result structure for vf mac address */
11929 struct cmd_set_vf_mac_addr_result {
11930 cmdline_fixed_string_t set;
11931 cmdline_fixed_string_t vf;
11932 cmdline_fixed_string_t mac;
11933 cmdline_fixed_string_t addr;
11936 struct rte_ether_addr mac_addr;
11940 /* Common CLI fields for vf split drop enable disable */
11941 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11942 TOKEN_STRING_INITIALIZER
11943 (struct cmd_set_vf_mac_addr_result,
11945 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11946 TOKEN_STRING_INITIALIZER
11947 (struct cmd_set_vf_mac_addr_result,
11949 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11950 TOKEN_STRING_INITIALIZER
11951 (struct cmd_set_vf_mac_addr_result,
11953 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11954 TOKEN_STRING_INITIALIZER
11955 (struct cmd_set_vf_mac_addr_result,
11957 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11958 TOKEN_NUM_INITIALIZER
11959 (struct cmd_set_vf_mac_addr_result,
11961 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11962 TOKEN_NUM_INITIALIZER
11963 (struct cmd_set_vf_mac_addr_result,
11965 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11966 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11970 cmd_set_vf_mac_addr_parsed(
11971 void *parsed_result,
11972 __rte_unused struct cmdline *cl,
11973 __rte_unused void *data)
11975 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11976 int ret = -ENOTSUP;
11978 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11981 #ifdef RTE_NET_IXGBE
11982 if (ret == -ENOTSUP)
11983 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11986 #ifdef RTE_NET_I40E
11987 if (ret == -ENOTSUP)
11988 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11991 #ifdef RTE_NET_BNXT
11992 if (ret == -ENOTSUP)
11993 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
12001 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
12004 printf("invalid port_id %d\n", res->port_id);
12007 printf("function not implemented\n");
12010 printf("programming error: (%s)\n", strerror(-ret));
12014 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
12015 .f = cmd_set_vf_mac_addr_parsed,
12017 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
12019 (void *)&cmd_set_vf_mac_addr_set,
12020 (void *)&cmd_set_vf_mac_addr_vf,
12021 (void *)&cmd_set_vf_mac_addr_mac,
12022 (void *)&cmd_set_vf_mac_addr_addr,
12023 (void *)&cmd_set_vf_mac_addr_port_id,
12024 (void *)&cmd_set_vf_mac_addr_vf_id,
12025 (void *)&cmd_set_vf_mac_addr_mac_addr,
12030 /* MACsec configuration */
12032 /* Common result structure for MACsec offload enable */
12033 struct cmd_macsec_offload_on_result {
12034 cmdline_fixed_string_t set;
12035 cmdline_fixed_string_t macsec;
12036 cmdline_fixed_string_t offload;
12038 cmdline_fixed_string_t on;
12039 cmdline_fixed_string_t encrypt;
12040 cmdline_fixed_string_t en_on_off;
12041 cmdline_fixed_string_t replay_protect;
12042 cmdline_fixed_string_t rp_on_off;
12045 /* Common CLI fields for MACsec offload disable */
12046 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
12047 TOKEN_STRING_INITIALIZER
12048 (struct cmd_macsec_offload_on_result,
12050 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
12051 TOKEN_STRING_INITIALIZER
12052 (struct cmd_macsec_offload_on_result,
12054 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
12055 TOKEN_STRING_INITIALIZER
12056 (struct cmd_macsec_offload_on_result,
12057 offload, "offload");
12058 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
12059 TOKEN_NUM_INITIALIZER
12060 (struct cmd_macsec_offload_on_result,
12062 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
12063 TOKEN_STRING_INITIALIZER
12064 (struct cmd_macsec_offload_on_result,
12066 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
12067 TOKEN_STRING_INITIALIZER
12068 (struct cmd_macsec_offload_on_result,
12069 encrypt, "encrypt");
12070 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
12071 TOKEN_STRING_INITIALIZER
12072 (struct cmd_macsec_offload_on_result,
12073 en_on_off, "on#off");
12074 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
12075 TOKEN_STRING_INITIALIZER
12076 (struct cmd_macsec_offload_on_result,
12077 replay_protect, "replay-protect");
12078 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
12079 TOKEN_STRING_INITIALIZER
12080 (struct cmd_macsec_offload_on_result,
12081 rp_on_off, "on#off");
12084 cmd_set_macsec_offload_on_parsed(
12085 void *parsed_result,
12086 __rte_unused struct cmdline *cl,
12087 __rte_unused void *data)
12089 struct cmd_macsec_offload_on_result *res = parsed_result;
12090 int ret = -ENOTSUP;
12091 portid_t port_id = res->port_id;
12092 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
12093 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
12094 struct rte_eth_dev_info dev_info;
12096 if (port_id_is_invalid(port_id, ENABLED_WARN))
12098 if (!port_is_stopped(port_id)) {
12099 printf("Please stop port %d first\n", port_id);
12103 ret = eth_dev_info_get_print_err(port_id, &dev_info);
12107 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
12108 #ifdef RTE_NET_IXGBE
12109 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
12117 ports[port_id].dev_conf.txmode.offloads |=
12118 DEV_TX_OFFLOAD_MACSEC_INSERT;
12119 cmd_reconfig_device_queue(port_id, 1, 1);
12122 printf("invalid port_id %d\n", port_id);
12125 printf("not supported on port %d\n", port_id);
12128 printf("programming error: (%s)\n", strerror(-ret));
12132 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
12133 .f = cmd_set_macsec_offload_on_parsed,
12135 .help_str = "set macsec offload <port_id> on "
12136 "encrypt on|off replay-protect on|off",
12138 (void *)&cmd_macsec_offload_on_set,
12139 (void *)&cmd_macsec_offload_on_macsec,
12140 (void *)&cmd_macsec_offload_on_offload,
12141 (void *)&cmd_macsec_offload_on_port_id,
12142 (void *)&cmd_macsec_offload_on_on,
12143 (void *)&cmd_macsec_offload_on_encrypt,
12144 (void *)&cmd_macsec_offload_on_en_on_off,
12145 (void *)&cmd_macsec_offload_on_replay_protect,
12146 (void *)&cmd_macsec_offload_on_rp_on_off,
12151 /* Common result structure for MACsec offload disable */
12152 struct cmd_macsec_offload_off_result {
12153 cmdline_fixed_string_t set;
12154 cmdline_fixed_string_t macsec;
12155 cmdline_fixed_string_t offload;
12157 cmdline_fixed_string_t off;
12160 /* Common CLI fields for MACsec offload disable */
12161 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
12162 TOKEN_STRING_INITIALIZER
12163 (struct cmd_macsec_offload_off_result,
12165 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
12166 TOKEN_STRING_INITIALIZER
12167 (struct cmd_macsec_offload_off_result,
12169 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
12170 TOKEN_STRING_INITIALIZER
12171 (struct cmd_macsec_offload_off_result,
12172 offload, "offload");
12173 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
12174 TOKEN_NUM_INITIALIZER
12175 (struct cmd_macsec_offload_off_result,
12177 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
12178 TOKEN_STRING_INITIALIZER
12179 (struct cmd_macsec_offload_off_result,
12183 cmd_set_macsec_offload_off_parsed(
12184 void *parsed_result,
12185 __rte_unused struct cmdline *cl,
12186 __rte_unused void *data)
12188 struct cmd_macsec_offload_off_result *res = parsed_result;
12189 int ret = -ENOTSUP;
12190 struct rte_eth_dev_info dev_info;
12191 portid_t port_id = res->port_id;
12193 if (port_id_is_invalid(port_id, ENABLED_WARN))
12195 if (!port_is_stopped(port_id)) {
12196 printf("Please stop port %d first\n", port_id);
12200 ret = eth_dev_info_get_print_err(port_id, &dev_info);
12204 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
12205 #ifdef RTE_NET_IXGBE
12206 ret = rte_pmd_ixgbe_macsec_disable(port_id);
12211 ports[port_id].dev_conf.txmode.offloads &=
12212 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
12213 cmd_reconfig_device_queue(port_id, 1, 1);
12216 printf("invalid port_id %d\n", port_id);
12219 printf("not supported on port %d\n", port_id);
12222 printf("programming error: (%s)\n", strerror(-ret));
12226 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
12227 .f = cmd_set_macsec_offload_off_parsed,
12229 .help_str = "set macsec offload <port_id> off",
12231 (void *)&cmd_macsec_offload_off_set,
12232 (void *)&cmd_macsec_offload_off_macsec,
12233 (void *)&cmd_macsec_offload_off_offload,
12234 (void *)&cmd_macsec_offload_off_port_id,
12235 (void *)&cmd_macsec_offload_off_off,
12240 /* Common result structure for MACsec secure connection configure */
12241 struct cmd_macsec_sc_result {
12242 cmdline_fixed_string_t set;
12243 cmdline_fixed_string_t macsec;
12244 cmdline_fixed_string_t sc;
12245 cmdline_fixed_string_t tx_rx;
12247 struct rte_ether_addr mac;
12251 /* Common CLI fields for MACsec secure connection configure */
12252 cmdline_parse_token_string_t cmd_macsec_sc_set =
12253 TOKEN_STRING_INITIALIZER
12254 (struct cmd_macsec_sc_result,
12256 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
12257 TOKEN_STRING_INITIALIZER
12258 (struct cmd_macsec_sc_result,
12260 cmdline_parse_token_string_t cmd_macsec_sc_sc =
12261 TOKEN_STRING_INITIALIZER
12262 (struct cmd_macsec_sc_result,
12264 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
12265 TOKEN_STRING_INITIALIZER
12266 (struct cmd_macsec_sc_result,
12268 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
12269 TOKEN_NUM_INITIALIZER
12270 (struct cmd_macsec_sc_result,
12272 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
12273 TOKEN_ETHERADDR_INITIALIZER
12274 (struct cmd_macsec_sc_result,
12276 cmdline_parse_token_num_t cmd_macsec_sc_pi =
12277 TOKEN_NUM_INITIALIZER
12278 (struct cmd_macsec_sc_result,
12282 cmd_set_macsec_sc_parsed(
12283 void *parsed_result,
12284 __rte_unused struct cmdline *cl,
12285 __rte_unused void *data)
12287 struct cmd_macsec_sc_result *res = parsed_result;
12288 int ret = -ENOTSUP;
12289 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12291 #ifdef RTE_NET_IXGBE
12293 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12294 res->mac.addr_bytes) :
12295 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12296 res->mac.addr_bytes, res->pi);
12298 RTE_SET_USED(is_tx);
12304 printf("invalid port_id %d\n", res->port_id);
12307 printf("not supported on port %d\n", res->port_id);
12310 printf("programming error: (%s)\n", strerror(-ret));
12314 cmdline_parse_inst_t cmd_set_macsec_sc = {
12315 .f = cmd_set_macsec_sc_parsed,
12317 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12319 (void *)&cmd_macsec_sc_set,
12320 (void *)&cmd_macsec_sc_macsec,
12321 (void *)&cmd_macsec_sc_sc,
12322 (void *)&cmd_macsec_sc_tx_rx,
12323 (void *)&cmd_macsec_sc_port_id,
12324 (void *)&cmd_macsec_sc_mac,
12325 (void *)&cmd_macsec_sc_pi,
12330 /* Common result structure for MACsec secure connection configure */
12331 struct cmd_macsec_sa_result {
12332 cmdline_fixed_string_t set;
12333 cmdline_fixed_string_t macsec;
12334 cmdline_fixed_string_t sa;
12335 cmdline_fixed_string_t tx_rx;
12340 cmdline_fixed_string_t key;
12343 /* Common CLI fields for MACsec secure connection configure */
12344 cmdline_parse_token_string_t cmd_macsec_sa_set =
12345 TOKEN_STRING_INITIALIZER
12346 (struct cmd_macsec_sa_result,
12348 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12349 TOKEN_STRING_INITIALIZER
12350 (struct cmd_macsec_sa_result,
12352 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12353 TOKEN_STRING_INITIALIZER
12354 (struct cmd_macsec_sa_result,
12356 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12357 TOKEN_STRING_INITIALIZER
12358 (struct cmd_macsec_sa_result,
12360 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12361 TOKEN_NUM_INITIALIZER
12362 (struct cmd_macsec_sa_result,
12364 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12365 TOKEN_NUM_INITIALIZER
12366 (struct cmd_macsec_sa_result,
12368 cmdline_parse_token_num_t cmd_macsec_sa_an =
12369 TOKEN_NUM_INITIALIZER
12370 (struct cmd_macsec_sa_result,
12372 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12373 TOKEN_NUM_INITIALIZER
12374 (struct cmd_macsec_sa_result,
12376 cmdline_parse_token_string_t cmd_macsec_sa_key =
12377 TOKEN_STRING_INITIALIZER
12378 (struct cmd_macsec_sa_result,
12382 cmd_set_macsec_sa_parsed(
12383 void *parsed_result,
12384 __rte_unused struct cmdline *cl,
12385 __rte_unused void *data)
12387 struct cmd_macsec_sa_result *res = parsed_result;
12388 int ret = -ENOTSUP;
12389 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12390 uint8_t key[16] = { 0 };
12396 key_len = strlen(res->key) / 2;
12400 for (i = 0; i < key_len; i++) {
12401 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12404 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12407 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12410 #ifdef RTE_NET_IXGBE
12412 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12413 res->idx, res->an, res->pn, key) :
12414 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12415 res->idx, res->an, res->pn, key);
12417 RTE_SET_USED(is_tx);
12424 printf("invalid idx %d or an %d\n", res->idx, res->an);
12427 printf("invalid port_id %d\n", res->port_id);
12430 printf("not supported on port %d\n", res->port_id);
12433 printf("programming error: (%s)\n", strerror(-ret));
12437 cmdline_parse_inst_t cmd_set_macsec_sa = {
12438 .f = cmd_set_macsec_sa_parsed,
12440 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12442 (void *)&cmd_macsec_sa_set,
12443 (void *)&cmd_macsec_sa_macsec,
12444 (void *)&cmd_macsec_sa_sa,
12445 (void *)&cmd_macsec_sa_tx_rx,
12446 (void *)&cmd_macsec_sa_port_id,
12447 (void *)&cmd_macsec_sa_idx,
12448 (void *)&cmd_macsec_sa_an,
12449 (void *)&cmd_macsec_sa_pn,
12450 (void *)&cmd_macsec_sa_key,
12455 /* VF unicast promiscuous mode configuration */
12457 /* Common result structure for VF unicast promiscuous mode */
12458 struct cmd_vf_promisc_result {
12459 cmdline_fixed_string_t set;
12460 cmdline_fixed_string_t vf;
12461 cmdline_fixed_string_t promisc;
12464 cmdline_fixed_string_t on_off;
12467 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12468 cmdline_parse_token_string_t cmd_vf_promisc_set =
12469 TOKEN_STRING_INITIALIZER
12470 (struct cmd_vf_promisc_result,
12472 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12473 TOKEN_STRING_INITIALIZER
12474 (struct cmd_vf_promisc_result,
12476 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12477 TOKEN_STRING_INITIALIZER
12478 (struct cmd_vf_promisc_result,
12479 promisc, "promisc");
12480 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12481 TOKEN_NUM_INITIALIZER
12482 (struct cmd_vf_promisc_result,
12484 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12485 TOKEN_NUM_INITIALIZER
12486 (struct cmd_vf_promisc_result,
12488 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12489 TOKEN_STRING_INITIALIZER
12490 (struct cmd_vf_promisc_result,
12494 cmd_set_vf_promisc_parsed(
12495 void *parsed_result,
12496 __rte_unused struct cmdline *cl,
12497 __rte_unused void *data)
12499 struct cmd_vf_promisc_result *res = parsed_result;
12500 int ret = -ENOTSUP;
12502 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12504 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12507 #ifdef RTE_NET_I40E
12508 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12509 res->vf_id, is_on);
12516 printf("invalid vf_id %d\n", res->vf_id);
12519 printf("invalid port_id %d\n", res->port_id);
12522 printf("function not implemented\n");
12525 printf("programming error: (%s)\n", strerror(-ret));
12529 cmdline_parse_inst_t cmd_set_vf_promisc = {
12530 .f = cmd_set_vf_promisc_parsed,
12532 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12533 "Set unicast promiscuous mode for a VF from the PF",
12535 (void *)&cmd_vf_promisc_set,
12536 (void *)&cmd_vf_promisc_vf,
12537 (void *)&cmd_vf_promisc_promisc,
12538 (void *)&cmd_vf_promisc_port_id,
12539 (void *)&cmd_vf_promisc_vf_id,
12540 (void *)&cmd_vf_promisc_on_off,
12545 /* VF multicast promiscuous mode configuration */
12547 /* Common result structure for VF multicast promiscuous mode */
12548 struct cmd_vf_allmulti_result {
12549 cmdline_fixed_string_t set;
12550 cmdline_fixed_string_t vf;
12551 cmdline_fixed_string_t allmulti;
12554 cmdline_fixed_string_t on_off;
12557 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12558 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12559 TOKEN_STRING_INITIALIZER
12560 (struct cmd_vf_allmulti_result,
12562 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12563 TOKEN_STRING_INITIALIZER
12564 (struct cmd_vf_allmulti_result,
12566 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12567 TOKEN_STRING_INITIALIZER
12568 (struct cmd_vf_allmulti_result,
12569 allmulti, "allmulti");
12570 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12571 TOKEN_NUM_INITIALIZER
12572 (struct cmd_vf_allmulti_result,
12574 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12575 TOKEN_NUM_INITIALIZER
12576 (struct cmd_vf_allmulti_result,
12578 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12579 TOKEN_STRING_INITIALIZER
12580 (struct cmd_vf_allmulti_result,
12584 cmd_set_vf_allmulti_parsed(
12585 void *parsed_result,
12586 __rte_unused struct cmdline *cl,
12587 __rte_unused void *data)
12589 struct cmd_vf_allmulti_result *res = parsed_result;
12590 int ret = -ENOTSUP;
12592 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12594 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12597 #ifdef RTE_NET_I40E
12598 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12599 res->vf_id, is_on);
12606 printf("invalid vf_id %d\n", res->vf_id);
12609 printf("invalid port_id %d\n", res->port_id);
12612 printf("function not implemented\n");
12615 printf("programming error: (%s)\n", strerror(-ret));
12619 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12620 .f = cmd_set_vf_allmulti_parsed,
12622 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12623 "Set multicast promiscuous mode for a VF from the PF",
12625 (void *)&cmd_vf_allmulti_set,
12626 (void *)&cmd_vf_allmulti_vf,
12627 (void *)&cmd_vf_allmulti_allmulti,
12628 (void *)&cmd_vf_allmulti_port_id,
12629 (void *)&cmd_vf_allmulti_vf_id,
12630 (void *)&cmd_vf_allmulti_on_off,
12635 /* vf broadcast mode configuration */
12637 /* Common result structure for vf broadcast */
12638 struct cmd_set_vf_broadcast_result {
12639 cmdline_fixed_string_t set;
12640 cmdline_fixed_string_t vf;
12641 cmdline_fixed_string_t broadcast;
12644 cmdline_fixed_string_t on_off;
12647 /* Common CLI fields for vf broadcast enable disable */
12648 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12649 TOKEN_STRING_INITIALIZER
12650 (struct cmd_set_vf_broadcast_result,
12652 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12653 TOKEN_STRING_INITIALIZER
12654 (struct cmd_set_vf_broadcast_result,
12656 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12657 TOKEN_STRING_INITIALIZER
12658 (struct cmd_set_vf_broadcast_result,
12659 broadcast, "broadcast");
12660 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12661 TOKEN_NUM_INITIALIZER
12662 (struct cmd_set_vf_broadcast_result,
12664 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12665 TOKEN_NUM_INITIALIZER
12666 (struct cmd_set_vf_broadcast_result,
12668 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12669 TOKEN_STRING_INITIALIZER
12670 (struct cmd_set_vf_broadcast_result,
12674 cmd_set_vf_broadcast_parsed(
12675 void *parsed_result,
12676 __rte_unused struct cmdline *cl,
12677 __rte_unused void *data)
12679 struct cmd_set_vf_broadcast_result *res = parsed_result;
12680 int ret = -ENOTSUP;
12682 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12684 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12687 #ifdef RTE_NET_I40E
12688 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12689 res->vf_id, is_on);
12696 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12699 printf("invalid port_id %d\n", res->port_id);
12702 printf("function not implemented\n");
12705 printf("programming error: (%s)\n", strerror(-ret));
12709 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12710 .f = cmd_set_vf_broadcast_parsed,
12712 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12714 (void *)&cmd_set_vf_broadcast_set,
12715 (void *)&cmd_set_vf_broadcast_vf,
12716 (void *)&cmd_set_vf_broadcast_broadcast,
12717 (void *)&cmd_set_vf_broadcast_port_id,
12718 (void *)&cmd_set_vf_broadcast_vf_id,
12719 (void *)&cmd_set_vf_broadcast_on_off,
12724 /* vf vlan tag configuration */
12726 /* Common result structure for vf vlan tag */
12727 struct cmd_set_vf_vlan_tag_result {
12728 cmdline_fixed_string_t set;
12729 cmdline_fixed_string_t vf;
12730 cmdline_fixed_string_t vlan;
12731 cmdline_fixed_string_t tag;
12734 cmdline_fixed_string_t on_off;
12737 /* Common CLI fields for vf vlan tag enable disable */
12738 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12739 TOKEN_STRING_INITIALIZER
12740 (struct cmd_set_vf_vlan_tag_result,
12742 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12743 TOKEN_STRING_INITIALIZER
12744 (struct cmd_set_vf_vlan_tag_result,
12746 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12747 TOKEN_STRING_INITIALIZER
12748 (struct cmd_set_vf_vlan_tag_result,
12750 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12751 TOKEN_STRING_INITIALIZER
12752 (struct cmd_set_vf_vlan_tag_result,
12754 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12755 TOKEN_NUM_INITIALIZER
12756 (struct cmd_set_vf_vlan_tag_result,
12758 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12759 TOKEN_NUM_INITIALIZER
12760 (struct cmd_set_vf_vlan_tag_result,
12762 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12763 TOKEN_STRING_INITIALIZER
12764 (struct cmd_set_vf_vlan_tag_result,
12768 cmd_set_vf_vlan_tag_parsed(
12769 void *parsed_result,
12770 __rte_unused struct cmdline *cl,
12771 __rte_unused void *data)
12773 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12774 int ret = -ENOTSUP;
12776 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12778 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12781 #ifdef RTE_NET_I40E
12782 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12783 res->vf_id, is_on);
12790 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12793 printf("invalid port_id %d\n", res->port_id);
12796 printf("function not implemented\n");
12799 printf("programming error: (%s)\n", strerror(-ret));
12803 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12804 .f = cmd_set_vf_vlan_tag_parsed,
12806 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12808 (void *)&cmd_set_vf_vlan_tag_set,
12809 (void *)&cmd_set_vf_vlan_tag_vf,
12810 (void *)&cmd_set_vf_vlan_tag_vlan,
12811 (void *)&cmd_set_vf_vlan_tag_tag,
12812 (void *)&cmd_set_vf_vlan_tag_port_id,
12813 (void *)&cmd_set_vf_vlan_tag_vf_id,
12814 (void *)&cmd_set_vf_vlan_tag_on_off,
12819 /* Common definition of VF and TC TX bandwidth configuration */
12820 struct cmd_vf_tc_bw_result {
12821 cmdline_fixed_string_t set;
12822 cmdline_fixed_string_t vf;
12823 cmdline_fixed_string_t tc;
12824 cmdline_fixed_string_t tx;
12825 cmdline_fixed_string_t min_bw;
12826 cmdline_fixed_string_t max_bw;
12827 cmdline_fixed_string_t strict_link_prio;
12832 cmdline_fixed_string_t bw_list;
12836 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12837 TOKEN_STRING_INITIALIZER
12838 (struct cmd_vf_tc_bw_result,
12840 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12841 TOKEN_STRING_INITIALIZER
12842 (struct cmd_vf_tc_bw_result,
12844 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12845 TOKEN_STRING_INITIALIZER
12846 (struct cmd_vf_tc_bw_result,
12848 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12849 TOKEN_STRING_INITIALIZER
12850 (struct cmd_vf_tc_bw_result,
12852 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12853 TOKEN_STRING_INITIALIZER
12854 (struct cmd_vf_tc_bw_result,
12855 strict_link_prio, "strict-link-priority");
12856 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12857 TOKEN_STRING_INITIALIZER
12858 (struct cmd_vf_tc_bw_result,
12859 min_bw, "min-bandwidth");
12860 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12861 TOKEN_STRING_INITIALIZER
12862 (struct cmd_vf_tc_bw_result,
12863 max_bw, "max-bandwidth");
12864 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12865 TOKEN_NUM_INITIALIZER
12866 (struct cmd_vf_tc_bw_result,
12868 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12869 TOKEN_NUM_INITIALIZER
12870 (struct cmd_vf_tc_bw_result,
12872 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12873 TOKEN_NUM_INITIALIZER
12874 (struct cmd_vf_tc_bw_result,
12876 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12877 TOKEN_NUM_INITIALIZER
12878 (struct cmd_vf_tc_bw_result,
12880 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12881 TOKEN_STRING_INITIALIZER
12882 (struct cmd_vf_tc_bw_result,
12884 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12885 TOKEN_NUM_INITIALIZER
12886 (struct cmd_vf_tc_bw_result,
12889 /* VF max bandwidth setting */
12891 cmd_vf_max_bw_parsed(
12892 void *parsed_result,
12893 __rte_unused struct cmdline *cl,
12894 __rte_unused void *data)
12896 struct cmd_vf_tc_bw_result *res = parsed_result;
12897 int ret = -ENOTSUP;
12899 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12902 #ifdef RTE_NET_I40E
12903 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12904 res->vf_id, res->bw);
12911 printf("invalid vf_id %d or bandwidth %d\n",
12912 res->vf_id, res->bw);
12915 printf("invalid port_id %d\n", res->port_id);
12918 printf("function not implemented\n");
12921 printf("programming error: (%s)\n", strerror(-ret));
12925 cmdline_parse_inst_t cmd_vf_max_bw = {
12926 .f = cmd_vf_max_bw_parsed,
12928 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12930 (void *)&cmd_vf_tc_bw_set,
12931 (void *)&cmd_vf_tc_bw_vf,
12932 (void *)&cmd_vf_tc_bw_tx,
12933 (void *)&cmd_vf_tc_bw_max_bw,
12934 (void *)&cmd_vf_tc_bw_port_id,
12935 (void *)&cmd_vf_tc_bw_vf_id,
12936 (void *)&cmd_vf_tc_bw_bw,
12942 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12947 const char *p, *p0 = str;
12954 p = strchr(p0, '(');
12956 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12960 p0 = strchr(p, ')');
12962 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12966 if (size >= sizeof(s)) {
12967 printf("The string size exceeds the internal buffer size\n");
12970 snprintf(s, sizeof(s), "%.*s", size, p);
12971 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12973 printf("Failed to get the bandwidth list. ");
12977 for (i = 0; i < ret; i++)
12978 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12983 /* TC min bandwidth setting */
12985 cmd_vf_tc_min_bw_parsed(
12986 void *parsed_result,
12987 __rte_unused struct cmdline *cl,
12988 __rte_unused void *data)
12990 struct cmd_vf_tc_bw_result *res = parsed_result;
12993 int ret = -ENOTSUP;
12995 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12998 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13002 #ifdef RTE_NET_I40E
13003 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
13011 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
13014 printf("invalid port_id %d\n", res->port_id);
13017 printf("function not implemented\n");
13020 printf("programming error: (%s)\n", strerror(-ret));
13024 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
13025 .f = cmd_vf_tc_min_bw_parsed,
13027 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
13028 " <bw1, bw2, ...>",
13030 (void *)&cmd_vf_tc_bw_set,
13031 (void *)&cmd_vf_tc_bw_vf,
13032 (void *)&cmd_vf_tc_bw_tc,
13033 (void *)&cmd_vf_tc_bw_tx,
13034 (void *)&cmd_vf_tc_bw_min_bw,
13035 (void *)&cmd_vf_tc_bw_port_id,
13036 (void *)&cmd_vf_tc_bw_vf_id,
13037 (void *)&cmd_vf_tc_bw_bw_list,
13043 cmd_tc_min_bw_parsed(
13044 void *parsed_result,
13045 __rte_unused struct cmdline *cl,
13046 __rte_unused void *data)
13048 struct cmd_vf_tc_bw_result *res = parsed_result;
13049 struct rte_port *port;
13052 int ret = -ENOTSUP;
13054 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13057 port = &ports[res->port_id];
13058 /** Check if the port is not started **/
13059 if (port->port_status != RTE_PORT_STOPPED) {
13060 printf("Please stop port %d first\n", res->port_id);
13064 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
13068 #ifdef RTE_NET_IXGBE
13069 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
13076 printf("invalid bandwidth\n");
13079 printf("invalid port_id %d\n", res->port_id);
13082 printf("function not implemented\n");
13085 printf("programming error: (%s)\n", strerror(-ret));
13089 cmdline_parse_inst_t cmd_tc_min_bw = {
13090 .f = cmd_tc_min_bw_parsed,
13092 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
13094 (void *)&cmd_vf_tc_bw_set,
13095 (void *)&cmd_vf_tc_bw_tc,
13096 (void *)&cmd_vf_tc_bw_tx,
13097 (void *)&cmd_vf_tc_bw_min_bw,
13098 (void *)&cmd_vf_tc_bw_port_id,
13099 (void *)&cmd_vf_tc_bw_bw_list,
13104 /* TC max bandwidth setting */
13106 cmd_vf_tc_max_bw_parsed(
13107 void *parsed_result,
13108 __rte_unused struct cmdline *cl,
13109 __rte_unused void *data)
13111 struct cmd_vf_tc_bw_result *res = parsed_result;
13112 int ret = -ENOTSUP;
13114 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13117 #ifdef RTE_NET_I40E
13118 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
13119 res->tc_no, res->bw);
13126 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
13127 res->vf_id, res->tc_no, res->bw);
13130 printf("invalid port_id %d\n", res->port_id);
13133 printf("function not implemented\n");
13136 printf("programming error: (%s)\n", strerror(-ret));
13140 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
13141 .f = cmd_vf_tc_max_bw_parsed,
13143 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
13146 (void *)&cmd_vf_tc_bw_set,
13147 (void *)&cmd_vf_tc_bw_vf,
13148 (void *)&cmd_vf_tc_bw_tc,
13149 (void *)&cmd_vf_tc_bw_tx,
13150 (void *)&cmd_vf_tc_bw_max_bw,
13151 (void *)&cmd_vf_tc_bw_port_id,
13152 (void *)&cmd_vf_tc_bw_vf_id,
13153 (void *)&cmd_vf_tc_bw_tc_no,
13154 (void *)&cmd_vf_tc_bw_bw,
13159 /** Set VXLAN encapsulation details */
13160 struct cmd_set_vxlan_result {
13161 cmdline_fixed_string_t set;
13162 cmdline_fixed_string_t vxlan;
13163 cmdline_fixed_string_t pos_token;
13164 cmdline_fixed_string_t ip_version;
13165 uint32_t vlan_present:1;
13169 cmdline_ipaddr_t ip_src;
13170 cmdline_ipaddr_t ip_dst;
13174 struct rte_ether_addr eth_src;
13175 struct rte_ether_addr eth_dst;
13178 cmdline_parse_token_string_t cmd_set_vxlan_set =
13179 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
13180 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
13181 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
13182 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
13183 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
13185 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
13186 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
13187 "vxlan-with-vlan");
13188 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
13189 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13191 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
13192 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
13194 cmdline_parse_token_string_t cmd_set_vxlan_vni =
13195 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13197 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
13198 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
13199 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
13200 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13202 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
13203 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
13204 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
13205 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13207 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
13208 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
13209 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
13210 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13212 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
13213 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
13214 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
13215 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13217 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
13218 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
13219 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
13220 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13222 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
13223 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
13224 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
13225 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13227 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
13228 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
13229 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
13230 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13232 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
13233 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
13234 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
13235 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13237 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
13238 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
13239 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
13240 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13242 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
13243 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
13245 static void cmd_set_vxlan_parsed(void *parsed_result,
13246 __rte_unused struct cmdline *cl,
13247 __rte_unused void *data)
13249 struct cmd_set_vxlan_result *res = parsed_result;
13254 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
13257 vxlan_encap_conf.select_tos_ttl = 0;
13258 if (strcmp(res->vxlan, "vxlan") == 0)
13259 vxlan_encap_conf.select_vlan = 0;
13260 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
13261 vxlan_encap_conf.select_vlan = 1;
13262 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
13263 vxlan_encap_conf.select_vlan = 0;
13264 vxlan_encap_conf.select_tos_ttl = 1;
13266 if (strcmp(res->ip_version, "ipv4") == 0)
13267 vxlan_encap_conf.select_ipv4 = 1;
13268 else if (strcmp(res->ip_version, "ipv6") == 0)
13269 vxlan_encap_conf.select_ipv4 = 0;
13272 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
13273 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13274 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13275 vxlan_encap_conf.ip_tos = res->tos;
13276 vxlan_encap_conf.ip_ttl = res->ttl;
13277 if (vxlan_encap_conf.select_ipv4) {
13278 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
13279 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
13281 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
13282 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
13284 if (vxlan_encap_conf.select_vlan)
13285 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13286 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
13287 RTE_ETHER_ADDR_LEN);
13288 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13289 RTE_ETHER_ADDR_LEN);
13292 cmdline_parse_inst_t cmd_set_vxlan = {
13293 .f = cmd_set_vxlan_parsed,
13295 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
13296 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
13297 " eth-src <eth-src> eth-dst <eth-dst>",
13299 (void *)&cmd_set_vxlan_set,
13300 (void *)&cmd_set_vxlan_vxlan,
13301 (void *)&cmd_set_vxlan_ip_version,
13302 (void *)&cmd_set_vxlan_ip_version_value,
13303 (void *)&cmd_set_vxlan_vni,
13304 (void *)&cmd_set_vxlan_vni_value,
13305 (void *)&cmd_set_vxlan_udp_src,
13306 (void *)&cmd_set_vxlan_udp_src_value,
13307 (void *)&cmd_set_vxlan_udp_dst,
13308 (void *)&cmd_set_vxlan_udp_dst_value,
13309 (void *)&cmd_set_vxlan_ip_src,
13310 (void *)&cmd_set_vxlan_ip_src_value,
13311 (void *)&cmd_set_vxlan_ip_dst,
13312 (void *)&cmd_set_vxlan_ip_dst_value,
13313 (void *)&cmd_set_vxlan_eth_src,
13314 (void *)&cmd_set_vxlan_eth_src_value,
13315 (void *)&cmd_set_vxlan_eth_dst,
13316 (void *)&cmd_set_vxlan_eth_dst_value,
13321 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
13322 .f = cmd_set_vxlan_parsed,
13324 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
13325 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
13326 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13327 " eth-dst <eth-dst>",
13329 (void *)&cmd_set_vxlan_set,
13330 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
13331 (void *)&cmd_set_vxlan_ip_version,
13332 (void *)&cmd_set_vxlan_ip_version_value,
13333 (void *)&cmd_set_vxlan_vni,
13334 (void *)&cmd_set_vxlan_vni_value,
13335 (void *)&cmd_set_vxlan_udp_src,
13336 (void *)&cmd_set_vxlan_udp_src_value,
13337 (void *)&cmd_set_vxlan_udp_dst,
13338 (void *)&cmd_set_vxlan_udp_dst_value,
13339 (void *)&cmd_set_vxlan_ip_tos,
13340 (void *)&cmd_set_vxlan_ip_tos_value,
13341 (void *)&cmd_set_vxlan_ip_ttl,
13342 (void *)&cmd_set_vxlan_ip_ttl_value,
13343 (void *)&cmd_set_vxlan_ip_src,
13344 (void *)&cmd_set_vxlan_ip_src_value,
13345 (void *)&cmd_set_vxlan_ip_dst,
13346 (void *)&cmd_set_vxlan_ip_dst_value,
13347 (void *)&cmd_set_vxlan_eth_src,
13348 (void *)&cmd_set_vxlan_eth_src_value,
13349 (void *)&cmd_set_vxlan_eth_dst,
13350 (void *)&cmd_set_vxlan_eth_dst_value,
13355 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
13356 .f = cmd_set_vxlan_parsed,
13358 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
13359 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
13360 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
13363 (void *)&cmd_set_vxlan_set,
13364 (void *)&cmd_set_vxlan_vxlan_with_vlan,
13365 (void *)&cmd_set_vxlan_ip_version,
13366 (void *)&cmd_set_vxlan_ip_version_value,
13367 (void *)&cmd_set_vxlan_vni,
13368 (void *)&cmd_set_vxlan_vni_value,
13369 (void *)&cmd_set_vxlan_udp_src,
13370 (void *)&cmd_set_vxlan_udp_src_value,
13371 (void *)&cmd_set_vxlan_udp_dst,
13372 (void *)&cmd_set_vxlan_udp_dst_value,
13373 (void *)&cmd_set_vxlan_ip_src,
13374 (void *)&cmd_set_vxlan_ip_src_value,
13375 (void *)&cmd_set_vxlan_ip_dst,
13376 (void *)&cmd_set_vxlan_ip_dst_value,
13377 (void *)&cmd_set_vxlan_vlan,
13378 (void *)&cmd_set_vxlan_vlan_value,
13379 (void *)&cmd_set_vxlan_eth_src,
13380 (void *)&cmd_set_vxlan_eth_src_value,
13381 (void *)&cmd_set_vxlan_eth_dst,
13382 (void *)&cmd_set_vxlan_eth_dst_value,
13387 /** Set NVGRE encapsulation details */
13388 struct cmd_set_nvgre_result {
13389 cmdline_fixed_string_t set;
13390 cmdline_fixed_string_t nvgre;
13391 cmdline_fixed_string_t pos_token;
13392 cmdline_fixed_string_t ip_version;
13394 cmdline_ipaddr_t ip_src;
13395 cmdline_ipaddr_t ip_dst;
13397 struct rte_ether_addr eth_src;
13398 struct rte_ether_addr eth_dst;
13401 cmdline_parse_token_string_t cmd_set_nvgre_set =
13402 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
13403 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
13404 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
13405 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
13406 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
13407 "nvgre-with-vlan");
13408 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
13409 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13411 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
13412 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
13414 cmdline_parse_token_string_t cmd_set_nvgre_tni =
13415 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13417 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
13418 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
13419 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
13420 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13422 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
13423 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
13424 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
13425 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13427 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
13428 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
13429 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
13430 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13432 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
13433 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
13434 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
13435 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13437 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
13438 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
13439 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
13440 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13442 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
13443 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
13445 static void cmd_set_nvgre_parsed(void *parsed_result,
13446 __rte_unused struct cmdline *cl,
13447 __rte_unused void *data)
13449 struct cmd_set_nvgre_result *res = parsed_result;
13451 uint32_t nvgre_tni;
13454 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
13457 if (strcmp(res->nvgre, "nvgre") == 0)
13458 nvgre_encap_conf.select_vlan = 0;
13459 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
13460 nvgre_encap_conf.select_vlan = 1;
13461 if (strcmp(res->ip_version, "ipv4") == 0)
13462 nvgre_encap_conf.select_ipv4 = 1;
13463 else if (strcmp(res->ip_version, "ipv6") == 0)
13464 nvgre_encap_conf.select_ipv4 = 0;
13467 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
13468 if (nvgre_encap_conf.select_ipv4) {
13469 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
13470 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
13472 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
13473 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
13475 if (nvgre_encap_conf.select_vlan)
13476 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13477 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
13478 RTE_ETHER_ADDR_LEN);
13479 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13480 RTE_ETHER_ADDR_LEN);
13483 cmdline_parse_inst_t cmd_set_nvgre = {
13484 .f = cmd_set_nvgre_parsed,
13486 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
13487 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13488 " eth-dst <eth-dst>",
13490 (void *)&cmd_set_nvgre_set,
13491 (void *)&cmd_set_nvgre_nvgre,
13492 (void *)&cmd_set_nvgre_ip_version,
13493 (void *)&cmd_set_nvgre_ip_version_value,
13494 (void *)&cmd_set_nvgre_tni,
13495 (void *)&cmd_set_nvgre_tni_value,
13496 (void *)&cmd_set_nvgre_ip_src,
13497 (void *)&cmd_set_nvgre_ip_src_value,
13498 (void *)&cmd_set_nvgre_ip_dst,
13499 (void *)&cmd_set_nvgre_ip_dst_value,
13500 (void *)&cmd_set_nvgre_eth_src,
13501 (void *)&cmd_set_nvgre_eth_src_value,
13502 (void *)&cmd_set_nvgre_eth_dst,
13503 (void *)&cmd_set_nvgre_eth_dst_value,
13508 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
13509 .f = cmd_set_nvgre_parsed,
13511 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
13512 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13513 " eth-src <eth-src> eth-dst <eth-dst>",
13515 (void *)&cmd_set_nvgre_set,
13516 (void *)&cmd_set_nvgre_nvgre_with_vlan,
13517 (void *)&cmd_set_nvgre_ip_version,
13518 (void *)&cmd_set_nvgre_ip_version_value,
13519 (void *)&cmd_set_nvgre_tni,
13520 (void *)&cmd_set_nvgre_tni_value,
13521 (void *)&cmd_set_nvgre_ip_src,
13522 (void *)&cmd_set_nvgre_ip_src_value,
13523 (void *)&cmd_set_nvgre_ip_dst,
13524 (void *)&cmd_set_nvgre_ip_dst_value,
13525 (void *)&cmd_set_nvgre_vlan,
13526 (void *)&cmd_set_nvgre_vlan_value,
13527 (void *)&cmd_set_nvgre_eth_src,
13528 (void *)&cmd_set_nvgre_eth_src_value,
13529 (void *)&cmd_set_nvgre_eth_dst,
13530 (void *)&cmd_set_nvgre_eth_dst_value,
13535 /** Set L2 encapsulation details */
13536 struct cmd_set_l2_encap_result {
13537 cmdline_fixed_string_t set;
13538 cmdline_fixed_string_t l2_encap;
13539 cmdline_fixed_string_t pos_token;
13540 cmdline_fixed_string_t ip_version;
13541 uint32_t vlan_present:1;
13543 struct rte_ether_addr eth_src;
13544 struct rte_ether_addr eth_dst;
13547 cmdline_parse_token_string_t cmd_set_l2_encap_set =
13548 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13549 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13550 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13551 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13552 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13553 "l2_encap-with-vlan");
13554 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13555 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13557 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13558 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13560 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13561 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13563 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13564 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
13565 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13566 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13568 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13569 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13570 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13571 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13573 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13574 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13576 static void cmd_set_l2_encap_parsed(void *parsed_result,
13577 __rte_unused struct cmdline *cl,
13578 __rte_unused void *data)
13580 struct cmd_set_l2_encap_result *res = parsed_result;
13582 if (strcmp(res->l2_encap, "l2_encap") == 0)
13583 l2_encap_conf.select_vlan = 0;
13584 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13585 l2_encap_conf.select_vlan = 1;
13586 if (strcmp(res->ip_version, "ipv4") == 0)
13587 l2_encap_conf.select_ipv4 = 1;
13588 else if (strcmp(res->ip_version, "ipv6") == 0)
13589 l2_encap_conf.select_ipv4 = 0;
13592 if (l2_encap_conf.select_vlan)
13593 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13594 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13595 RTE_ETHER_ADDR_LEN);
13596 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13597 RTE_ETHER_ADDR_LEN);
13600 cmdline_parse_inst_t cmd_set_l2_encap = {
13601 .f = cmd_set_l2_encap_parsed,
13603 .help_str = "set l2_encap ip-version ipv4|ipv6"
13604 " eth-src <eth-src> eth-dst <eth-dst>",
13606 (void *)&cmd_set_l2_encap_set,
13607 (void *)&cmd_set_l2_encap_l2_encap,
13608 (void *)&cmd_set_l2_encap_ip_version,
13609 (void *)&cmd_set_l2_encap_ip_version_value,
13610 (void *)&cmd_set_l2_encap_eth_src,
13611 (void *)&cmd_set_l2_encap_eth_src_value,
13612 (void *)&cmd_set_l2_encap_eth_dst,
13613 (void *)&cmd_set_l2_encap_eth_dst_value,
13618 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13619 .f = cmd_set_l2_encap_parsed,
13621 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13622 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13624 (void *)&cmd_set_l2_encap_set,
13625 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13626 (void *)&cmd_set_l2_encap_ip_version,
13627 (void *)&cmd_set_l2_encap_ip_version_value,
13628 (void *)&cmd_set_l2_encap_vlan,
13629 (void *)&cmd_set_l2_encap_vlan_value,
13630 (void *)&cmd_set_l2_encap_eth_src,
13631 (void *)&cmd_set_l2_encap_eth_src_value,
13632 (void *)&cmd_set_l2_encap_eth_dst,
13633 (void *)&cmd_set_l2_encap_eth_dst_value,
13638 /** Set L2 decapsulation details */
13639 struct cmd_set_l2_decap_result {
13640 cmdline_fixed_string_t set;
13641 cmdline_fixed_string_t l2_decap;
13642 cmdline_fixed_string_t pos_token;
13643 uint32_t vlan_present:1;
13646 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13647 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13648 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13649 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13651 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13652 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13653 "l2_decap-with-vlan");
13655 static void cmd_set_l2_decap_parsed(void *parsed_result,
13656 __rte_unused struct cmdline *cl,
13657 __rte_unused void *data)
13659 struct cmd_set_l2_decap_result *res = parsed_result;
13661 if (strcmp(res->l2_decap, "l2_decap") == 0)
13662 l2_decap_conf.select_vlan = 0;
13663 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13664 l2_decap_conf.select_vlan = 1;
13667 cmdline_parse_inst_t cmd_set_l2_decap = {
13668 .f = cmd_set_l2_decap_parsed,
13670 .help_str = "set l2_decap",
13672 (void *)&cmd_set_l2_decap_set,
13673 (void *)&cmd_set_l2_decap_l2_decap,
13678 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13679 .f = cmd_set_l2_decap_parsed,
13681 .help_str = "set l2_decap-with-vlan",
13683 (void *)&cmd_set_l2_decap_set,
13684 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13689 /** Set MPLSoGRE encapsulation details */
13690 struct cmd_set_mplsogre_encap_result {
13691 cmdline_fixed_string_t set;
13692 cmdline_fixed_string_t mplsogre;
13693 cmdline_fixed_string_t pos_token;
13694 cmdline_fixed_string_t ip_version;
13695 uint32_t vlan_present:1;
13697 cmdline_ipaddr_t ip_src;
13698 cmdline_ipaddr_t ip_dst;
13700 struct rte_ether_addr eth_src;
13701 struct rte_ether_addr eth_dst;
13704 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13705 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13707 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13708 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13710 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13711 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13712 mplsogre, "mplsogre_encap-with-vlan");
13713 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13714 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13715 pos_token, "ip-version");
13716 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13717 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13718 ip_version, "ipv4#ipv6");
13719 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13720 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13721 pos_token, "label");
13722 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13723 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13725 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13726 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13727 pos_token, "ip-src");
13728 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13729 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13730 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13731 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13732 pos_token, "ip-dst");
13733 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13734 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13735 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13736 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13737 pos_token, "vlan-tci");
13738 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13739 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13741 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13742 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13743 pos_token, "eth-src");
13744 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13745 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13747 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13748 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13749 pos_token, "eth-dst");
13750 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13751 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13754 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13755 __rte_unused struct cmdline *cl,
13756 __rte_unused void *data)
13758 struct cmd_set_mplsogre_encap_result *res = parsed_result;
13760 uint32_t mplsogre_label;
13763 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13766 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13767 mplsogre_encap_conf.select_vlan = 0;
13768 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13769 mplsogre_encap_conf.select_vlan = 1;
13770 if (strcmp(res->ip_version, "ipv4") == 0)
13771 mplsogre_encap_conf.select_ipv4 = 1;
13772 else if (strcmp(res->ip_version, "ipv6") == 0)
13773 mplsogre_encap_conf.select_ipv4 = 0;
13776 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13777 if (mplsogre_encap_conf.select_ipv4) {
13778 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13779 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13781 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13782 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13784 if (mplsogre_encap_conf.select_vlan)
13785 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13786 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13787 RTE_ETHER_ADDR_LEN);
13788 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13789 RTE_ETHER_ADDR_LEN);
13792 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13793 .f = cmd_set_mplsogre_encap_parsed,
13795 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13796 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13797 " eth-dst <eth-dst>",
13799 (void *)&cmd_set_mplsogre_encap_set,
13800 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13801 (void *)&cmd_set_mplsogre_encap_ip_version,
13802 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13803 (void *)&cmd_set_mplsogre_encap_label,
13804 (void *)&cmd_set_mplsogre_encap_label_value,
13805 (void *)&cmd_set_mplsogre_encap_ip_src,
13806 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13807 (void *)&cmd_set_mplsogre_encap_ip_dst,
13808 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13809 (void *)&cmd_set_mplsogre_encap_eth_src,
13810 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13811 (void *)&cmd_set_mplsogre_encap_eth_dst,
13812 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13817 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13818 .f = cmd_set_mplsogre_encap_parsed,
13820 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13821 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
13822 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13824 (void *)&cmd_set_mplsogre_encap_set,
13825 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13826 (void *)&cmd_set_mplsogre_encap_ip_version,
13827 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13828 (void *)&cmd_set_mplsogre_encap_label,
13829 (void *)&cmd_set_mplsogre_encap_label_value,
13830 (void *)&cmd_set_mplsogre_encap_ip_src,
13831 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13832 (void *)&cmd_set_mplsogre_encap_ip_dst,
13833 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13834 (void *)&cmd_set_mplsogre_encap_vlan,
13835 (void *)&cmd_set_mplsogre_encap_vlan_value,
13836 (void *)&cmd_set_mplsogre_encap_eth_src,
13837 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13838 (void *)&cmd_set_mplsogre_encap_eth_dst,
13839 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13844 /** Set MPLSoGRE decapsulation details */
13845 struct cmd_set_mplsogre_decap_result {
13846 cmdline_fixed_string_t set;
13847 cmdline_fixed_string_t mplsogre;
13848 cmdline_fixed_string_t pos_token;
13849 cmdline_fixed_string_t ip_version;
13850 uint32_t vlan_present:1;
13853 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13854 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13856 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13857 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13859 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13860 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13861 mplsogre, "mplsogre_decap-with-vlan");
13862 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13863 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13864 pos_token, "ip-version");
13865 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13866 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13867 ip_version, "ipv4#ipv6");
13869 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13870 __rte_unused struct cmdline *cl,
13871 __rte_unused void *data)
13873 struct cmd_set_mplsogre_decap_result *res = parsed_result;
13875 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13876 mplsogre_decap_conf.select_vlan = 0;
13877 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13878 mplsogre_decap_conf.select_vlan = 1;
13879 if (strcmp(res->ip_version, "ipv4") == 0)
13880 mplsogre_decap_conf.select_ipv4 = 1;
13881 else if (strcmp(res->ip_version, "ipv6") == 0)
13882 mplsogre_decap_conf.select_ipv4 = 0;
13885 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13886 .f = cmd_set_mplsogre_decap_parsed,
13888 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13890 (void *)&cmd_set_mplsogre_decap_set,
13891 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13892 (void *)&cmd_set_mplsogre_decap_ip_version,
13893 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13898 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13899 .f = cmd_set_mplsogre_decap_parsed,
13901 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13903 (void *)&cmd_set_mplsogre_decap_set,
13904 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13905 (void *)&cmd_set_mplsogre_decap_ip_version,
13906 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13911 /** Set MPLSoUDP encapsulation details */
13912 struct cmd_set_mplsoudp_encap_result {
13913 cmdline_fixed_string_t set;
13914 cmdline_fixed_string_t mplsoudp;
13915 cmdline_fixed_string_t pos_token;
13916 cmdline_fixed_string_t ip_version;
13917 uint32_t vlan_present:1;
13921 cmdline_ipaddr_t ip_src;
13922 cmdline_ipaddr_t ip_dst;
13924 struct rte_ether_addr eth_src;
13925 struct rte_ether_addr eth_dst;
13928 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13929 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13931 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13932 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13934 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13935 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13936 mplsoudp, "mplsoudp_encap-with-vlan");
13937 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13938 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13939 pos_token, "ip-version");
13940 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13941 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13942 ip_version, "ipv4#ipv6");
13943 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13944 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13945 pos_token, "label");
13946 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13947 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13949 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13950 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13951 pos_token, "udp-src");
13952 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13953 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13955 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13956 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13957 pos_token, "udp-dst");
13958 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13959 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13961 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13962 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13963 pos_token, "ip-src");
13964 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13965 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13966 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13967 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13968 pos_token, "ip-dst");
13969 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13970 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13971 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13972 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13973 pos_token, "vlan-tci");
13974 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13975 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13977 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13978 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13979 pos_token, "eth-src");
13980 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13981 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13983 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13984 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13985 pos_token, "eth-dst");
13986 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13987 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13990 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13991 __rte_unused struct cmdline *cl,
13992 __rte_unused void *data)
13994 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13996 uint32_t mplsoudp_label;
13999 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
14002 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
14003 mplsoudp_encap_conf.select_vlan = 0;
14004 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
14005 mplsoudp_encap_conf.select_vlan = 1;
14006 if (strcmp(res->ip_version, "ipv4") == 0)
14007 mplsoudp_encap_conf.select_ipv4 = 1;
14008 else if (strcmp(res->ip_version, "ipv6") == 0)
14009 mplsoudp_encap_conf.select_ipv4 = 0;
14012 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
14013 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
14014 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
14015 if (mplsoudp_encap_conf.select_ipv4) {
14016 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
14017 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
14019 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
14020 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
14022 if (mplsoudp_encap_conf.select_vlan)
14023 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
14024 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
14025 RTE_ETHER_ADDR_LEN);
14026 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
14027 RTE_ETHER_ADDR_LEN);
14030 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
14031 .f = cmd_set_mplsoudp_encap_parsed,
14033 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
14034 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
14035 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
14037 (void *)&cmd_set_mplsoudp_encap_set,
14038 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
14039 (void *)&cmd_set_mplsoudp_encap_ip_version,
14040 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
14041 (void *)&cmd_set_mplsoudp_encap_label,
14042 (void *)&cmd_set_mplsoudp_encap_label_value,
14043 (void *)&cmd_set_mplsoudp_encap_udp_src,
14044 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
14045 (void *)&cmd_set_mplsoudp_encap_udp_dst,
14046 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
14047 (void *)&cmd_set_mplsoudp_encap_ip_src,
14048 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
14049 (void *)&cmd_set_mplsoudp_encap_ip_dst,
14050 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
14051 (void *)&cmd_set_mplsoudp_encap_eth_src,
14052 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
14053 (void *)&cmd_set_mplsoudp_encap_eth_dst,
14054 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
14059 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
14060 .f = cmd_set_mplsoudp_encap_parsed,
14062 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
14063 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
14064 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
14065 " eth-src <eth-src> eth-dst <eth-dst>",
14067 (void *)&cmd_set_mplsoudp_encap_set,
14068 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
14069 (void *)&cmd_set_mplsoudp_encap_ip_version,
14070 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
14071 (void *)&cmd_set_mplsoudp_encap_label,
14072 (void *)&cmd_set_mplsoudp_encap_label_value,
14073 (void *)&cmd_set_mplsoudp_encap_udp_src,
14074 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
14075 (void *)&cmd_set_mplsoudp_encap_udp_dst,
14076 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
14077 (void *)&cmd_set_mplsoudp_encap_ip_src,
14078 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
14079 (void *)&cmd_set_mplsoudp_encap_ip_dst,
14080 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
14081 (void *)&cmd_set_mplsoudp_encap_vlan,
14082 (void *)&cmd_set_mplsoudp_encap_vlan_value,
14083 (void *)&cmd_set_mplsoudp_encap_eth_src,
14084 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
14085 (void *)&cmd_set_mplsoudp_encap_eth_dst,
14086 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
14091 /** Set MPLSoUDP decapsulation details */
14092 struct cmd_set_mplsoudp_decap_result {
14093 cmdline_fixed_string_t set;
14094 cmdline_fixed_string_t mplsoudp;
14095 cmdline_fixed_string_t pos_token;
14096 cmdline_fixed_string_t ip_version;
14097 uint32_t vlan_present:1;
14100 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
14101 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
14103 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
14104 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
14106 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
14107 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
14108 mplsoudp, "mplsoudp_decap-with-vlan");
14109 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
14110 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
14111 pos_token, "ip-version");
14112 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
14113 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
14114 ip_version, "ipv4#ipv6");
14116 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
14117 __rte_unused struct cmdline *cl,
14118 __rte_unused void *data)
14120 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
14122 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
14123 mplsoudp_decap_conf.select_vlan = 0;
14124 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
14125 mplsoudp_decap_conf.select_vlan = 1;
14126 if (strcmp(res->ip_version, "ipv4") == 0)
14127 mplsoudp_decap_conf.select_ipv4 = 1;
14128 else if (strcmp(res->ip_version, "ipv6") == 0)
14129 mplsoudp_decap_conf.select_ipv4 = 0;
14132 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
14133 .f = cmd_set_mplsoudp_decap_parsed,
14135 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
14137 (void *)&cmd_set_mplsoudp_decap_set,
14138 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
14139 (void *)&cmd_set_mplsoudp_decap_ip_version,
14140 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
14145 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
14146 .f = cmd_set_mplsoudp_decap_parsed,
14148 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
14150 (void *)&cmd_set_mplsoudp_decap_set,
14151 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
14152 (void *)&cmd_set_mplsoudp_decap_ip_version,
14153 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
14158 /* Strict link priority scheduling mode setting */
14160 cmd_strict_link_prio_parsed(
14161 void *parsed_result,
14162 __rte_unused struct cmdline *cl,
14163 __rte_unused void *data)
14165 struct cmd_vf_tc_bw_result *res = parsed_result;
14166 int ret = -ENOTSUP;
14168 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14171 #ifdef RTE_NET_I40E
14172 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14179 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14182 printf("invalid port_id %d\n", res->port_id);
14185 printf("function not implemented\n");
14188 printf("programming error: (%s)\n", strerror(-ret));
14192 cmdline_parse_inst_t cmd_strict_link_prio = {
14193 .f = cmd_strict_link_prio_parsed,
14195 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14197 (void *)&cmd_vf_tc_bw_set,
14198 (void *)&cmd_vf_tc_bw_tx,
14199 (void *)&cmd_vf_tc_bw_strict_link_prio,
14200 (void *)&cmd_vf_tc_bw_port_id,
14201 (void *)&cmd_vf_tc_bw_tc_map,
14206 /* Load dynamic device personalization*/
14207 struct cmd_ddp_add_result {
14208 cmdline_fixed_string_t ddp;
14209 cmdline_fixed_string_t add;
14214 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14215 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14216 cmdline_parse_token_string_t cmd_ddp_add_add =
14217 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14218 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14219 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14220 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14221 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14224 cmd_ddp_add_parsed(
14225 void *parsed_result,
14226 __rte_unused struct cmdline *cl,
14227 __rte_unused void *data)
14229 struct cmd_ddp_add_result *res = parsed_result;
14235 int ret = -ENOTSUP;
14237 if (!all_ports_stopped()) {
14238 printf("Please stop all ports first\n");
14242 filepath = strdup(res->filepath);
14243 if (filepath == NULL) {
14244 printf("Failed to allocate memory\n");
14247 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14249 buff = open_file(file_fld[0], &size);
14251 free((void *)filepath);
14255 #ifdef RTE_NET_I40E
14256 if (ret == -ENOTSUP)
14257 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14259 RTE_PMD_I40E_PKG_OP_WR_ADD);
14262 if (ret == -EEXIST)
14263 printf("Profile has already existed.\n");
14265 printf("Failed to load profile.\n");
14266 else if (file_num == 2)
14267 save_file(file_fld[1], buff, size);
14270 free((void *)filepath);
14273 cmdline_parse_inst_t cmd_ddp_add = {
14274 .f = cmd_ddp_add_parsed,
14276 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14278 (void *)&cmd_ddp_add_ddp,
14279 (void *)&cmd_ddp_add_add,
14280 (void *)&cmd_ddp_add_port_id,
14281 (void *)&cmd_ddp_add_filepath,
14286 /* Delete dynamic device personalization*/
14287 struct cmd_ddp_del_result {
14288 cmdline_fixed_string_t ddp;
14289 cmdline_fixed_string_t del;
14294 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14295 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14296 cmdline_parse_token_string_t cmd_ddp_del_del =
14297 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14298 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14299 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14300 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14301 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14304 cmd_ddp_del_parsed(
14305 void *parsed_result,
14306 __rte_unused struct cmdline *cl,
14307 __rte_unused void *data)
14309 struct cmd_ddp_del_result *res = parsed_result;
14312 int ret = -ENOTSUP;
14314 if (!all_ports_stopped()) {
14315 printf("Please stop all ports first\n");
14319 buff = open_file(res->filepath, &size);
14323 #ifdef RTE_NET_I40E
14324 if (ret == -ENOTSUP)
14325 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14327 RTE_PMD_I40E_PKG_OP_WR_DEL);
14330 if (ret == -EACCES)
14331 printf("Profile does not exist.\n");
14333 printf("Failed to delete profile.\n");
14338 cmdline_parse_inst_t cmd_ddp_del = {
14339 .f = cmd_ddp_del_parsed,
14341 .help_str = "ddp del <port_id> <backup_profile_path>",
14343 (void *)&cmd_ddp_del_ddp,
14344 (void *)&cmd_ddp_del_del,
14345 (void *)&cmd_ddp_del_port_id,
14346 (void *)&cmd_ddp_del_filepath,
14351 /* Get dynamic device personalization profile info */
14352 struct cmd_ddp_info_result {
14353 cmdline_fixed_string_t ddp;
14354 cmdline_fixed_string_t get;
14355 cmdline_fixed_string_t info;
14359 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14360 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14361 cmdline_parse_token_string_t cmd_ddp_info_get =
14362 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14363 cmdline_parse_token_string_t cmd_ddp_info_info =
14364 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14365 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14366 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14369 cmd_ddp_info_parsed(
14370 void *parsed_result,
14371 __rte_unused struct cmdline *cl,
14372 __rte_unused void *data)
14374 struct cmd_ddp_info_result *res = parsed_result;
14377 int ret = -ENOTSUP;
14378 #ifdef RTE_NET_I40E
14381 uint32_t buff_size = 0;
14382 struct rte_pmd_i40e_profile_info info;
14383 uint32_t dev_num = 0;
14384 struct rte_pmd_i40e_ddp_device_id *devs;
14385 uint32_t proto_num = 0;
14386 struct rte_pmd_i40e_proto_info *proto = NULL;
14387 uint32_t pctype_num = 0;
14388 struct rte_pmd_i40e_ptype_info *pctype;
14389 uint32_t ptype_num = 0;
14390 struct rte_pmd_i40e_ptype_info *ptype;
14395 pkg = open_file(res->filepath, &pkg_size);
14399 #ifdef RTE_NET_I40E
14400 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14401 (uint8_t *)&info, sizeof(info),
14402 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14404 printf("Global Track id: 0x%x\n", info.track_id);
14405 printf("Global Version: %d.%d.%d.%d\n",
14406 info.version.major,
14407 info.version.minor,
14408 info.version.update,
14409 info.version.draft);
14410 printf("Global Package name: %s\n\n", info.name);
14413 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14414 (uint8_t *)&info, sizeof(info),
14415 RTE_PMD_I40E_PKG_INFO_HEADER);
14417 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14418 printf("i40e Profile Version: %d.%d.%d.%d\n",
14419 info.version.major,
14420 info.version.minor,
14421 info.version.update,
14422 info.version.draft);
14423 printf("i40e Profile name: %s\n\n", info.name);
14426 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14427 (uint8_t *)&buff_size, sizeof(buff_size),
14428 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14429 if (!ret && buff_size) {
14430 buff = (uint8_t *)malloc(buff_size);
14432 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14434 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14436 printf("Package Notes:\n%s\n\n", buff);
14441 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14442 (uint8_t *)&dev_num, sizeof(dev_num),
14443 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14444 if (!ret && dev_num) {
14445 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14446 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14448 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14449 (uint8_t *)devs, buff_size,
14450 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14452 printf("List of supported devices:\n");
14453 for (i = 0; i < dev_num; i++) {
14454 printf(" %04X:%04X %04X:%04X\n",
14455 devs[i].vendor_dev_id >> 16,
14456 devs[i].vendor_dev_id & 0xFFFF,
14457 devs[i].sub_vendor_dev_id >> 16,
14458 devs[i].sub_vendor_dev_id & 0xFFFF);
14466 /* get information about protocols and packet types */
14467 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14468 (uint8_t *)&proto_num, sizeof(proto_num),
14469 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14470 if (ret || !proto_num)
14471 goto no_print_return;
14473 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14474 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14476 goto no_print_return;
14478 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14480 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14482 printf("List of used protocols:\n");
14483 for (i = 0; i < proto_num; i++)
14484 printf(" %2u: %s\n", proto[i].proto_id,
14488 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14489 (uint8_t *)&pctype_num, sizeof(pctype_num),
14490 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14491 if (ret || !pctype_num)
14492 goto no_print_pctypes;
14494 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14495 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14497 goto no_print_pctypes;
14499 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14501 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14504 goto no_print_pctypes;
14507 printf("List of defined packet classification types:\n");
14508 for (i = 0; i < pctype_num; i++) {
14509 printf(" %2u:", pctype[i].ptype_id);
14510 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14511 proto_id = pctype[i].protocols[j];
14512 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14513 for (n = 0; n < proto_num; n++) {
14514 if (proto[n].proto_id == proto_id) {
14515 printf(" %s", proto[n].name);
14528 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14530 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14531 if (ret || !ptype_num)
14532 goto no_print_return;
14534 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14535 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14537 goto no_print_return;
14539 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14541 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14544 goto no_print_return;
14546 printf("List of defined packet types:\n");
14547 for (i = 0; i < ptype_num; i++) {
14548 printf(" %2u:", ptype[i].ptype_id);
14549 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14550 proto_id = ptype[i].protocols[j];
14551 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14552 for (n = 0; n < proto_num; n++) {
14553 if (proto[n].proto_id == proto_id) {
14554 printf(" %s", proto[n].name);
14570 if (ret == -ENOTSUP)
14571 printf("Function not supported in PMD driver\n");
14575 cmdline_parse_inst_t cmd_ddp_get_info = {
14576 .f = cmd_ddp_info_parsed,
14578 .help_str = "ddp get info <profile_path>",
14580 (void *)&cmd_ddp_info_ddp,
14581 (void *)&cmd_ddp_info_get,
14582 (void *)&cmd_ddp_info_info,
14583 (void *)&cmd_ddp_info_filepath,
14588 /* Get dynamic device personalization profile info list*/
14589 #define PROFILE_INFO_SIZE 48
14590 #define MAX_PROFILE_NUM 16
14592 struct cmd_ddp_get_list_result {
14593 cmdline_fixed_string_t ddp;
14594 cmdline_fixed_string_t get;
14595 cmdline_fixed_string_t list;
14599 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14600 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14601 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14602 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14603 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14604 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14605 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14606 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
14609 cmd_ddp_get_list_parsed(
14610 __rte_unused void *parsed_result,
14611 __rte_unused struct cmdline *cl,
14612 __rte_unused void *data)
14614 #ifdef RTE_NET_I40E
14615 struct cmd_ddp_get_list_result *res = parsed_result;
14616 struct rte_pmd_i40e_profile_list *p_list;
14617 struct rte_pmd_i40e_profile_info *p_info;
14622 int ret = -ENOTSUP;
14624 #ifdef RTE_NET_I40E
14625 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14626 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14628 printf("%s: Failed to malloc buffer\n", __func__);
14632 if (ret == -ENOTSUP)
14633 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14634 (uint8_t *)p_list, size);
14637 p_num = p_list->p_count;
14638 printf("Profile number is: %d\n\n", p_num);
14640 for (i = 0; i < p_num; i++) {
14641 p_info = &p_list->p_info[i];
14642 printf("Profile %d:\n", i);
14643 printf("Track id: 0x%x\n", p_info->track_id);
14644 printf("Version: %d.%d.%d.%d\n",
14645 p_info->version.major,
14646 p_info->version.minor,
14647 p_info->version.update,
14648 p_info->version.draft);
14649 printf("Profile name: %s\n\n", p_info->name);
14657 printf("Failed to get ddp list\n");
14660 cmdline_parse_inst_t cmd_ddp_get_list = {
14661 .f = cmd_ddp_get_list_parsed,
14663 .help_str = "ddp get list <port_id>",
14665 (void *)&cmd_ddp_get_list_ddp,
14666 (void *)&cmd_ddp_get_list_get,
14667 (void *)&cmd_ddp_get_list_list,
14668 (void *)&cmd_ddp_get_list_port_id,
14673 /* Configure input set */
14674 struct cmd_cfg_input_set_result {
14675 cmdline_fixed_string_t port;
14676 cmdline_fixed_string_t cfg;
14678 cmdline_fixed_string_t pctype;
14680 cmdline_fixed_string_t inset_type;
14681 cmdline_fixed_string_t opt;
14682 cmdline_fixed_string_t field;
14687 cmd_cfg_input_set_parsed(
14688 __rte_unused void *parsed_result,
14689 __rte_unused struct cmdline *cl,
14690 __rte_unused void *data)
14692 #ifdef RTE_NET_I40E
14693 struct cmd_cfg_input_set_result *res = parsed_result;
14694 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14695 struct rte_pmd_i40e_inset inset;
14697 int ret = -ENOTSUP;
14699 if (!all_ports_stopped()) {
14700 printf("Please stop all ports first\n");
14704 #ifdef RTE_NET_I40E
14705 if (!strcmp(res->inset_type, "hash_inset"))
14706 inset_type = INSET_HASH;
14707 else if (!strcmp(res->inset_type, "fdir_inset"))
14708 inset_type = INSET_FDIR;
14709 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14710 inset_type = INSET_FDIR_FLX;
14711 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14712 &inset, inset_type);
14714 printf("Failed to get input set.\n");
14718 if (!strcmp(res->opt, "get")) {
14719 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14722 printf("Field index %d is enabled.\n", res->field_idx);
14724 printf("Field index %d is disabled.\n", res->field_idx);
14726 } else if (!strcmp(res->opt, "set"))
14727 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14729 else if (!strcmp(res->opt, "clear"))
14730 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14733 printf("Failed to configure input set field.\n");
14737 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14738 &inset, inset_type);
14740 printf("Failed to set input set.\n");
14745 if (ret == -ENOTSUP)
14746 printf("Function not supported\n");
14749 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14750 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14752 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14753 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14755 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14756 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14758 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14759 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14761 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14762 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14764 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14765 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14767 "hash_inset#fdir_inset#fdir_flx_inset");
14768 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14769 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14770 opt, "get#set#clear");
14771 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14772 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14774 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14775 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14778 cmdline_parse_inst_t cmd_cfg_input_set = {
14779 .f = cmd_cfg_input_set_parsed,
14781 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14782 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
14784 (void *)&cmd_cfg_input_set_port,
14785 (void *)&cmd_cfg_input_set_cfg,
14786 (void *)&cmd_cfg_input_set_port_id,
14787 (void *)&cmd_cfg_input_set_pctype,
14788 (void *)&cmd_cfg_input_set_pctype_id,
14789 (void *)&cmd_cfg_input_set_inset_type,
14790 (void *)&cmd_cfg_input_set_opt,
14791 (void *)&cmd_cfg_input_set_field,
14792 (void *)&cmd_cfg_input_set_field_idx,
14797 /* Clear input set */
14798 struct cmd_clear_input_set_result {
14799 cmdline_fixed_string_t port;
14800 cmdline_fixed_string_t cfg;
14802 cmdline_fixed_string_t pctype;
14804 cmdline_fixed_string_t inset_type;
14805 cmdline_fixed_string_t clear;
14806 cmdline_fixed_string_t all;
14810 cmd_clear_input_set_parsed(
14811 __rte_unused void *parsed_result,
14812 __rte_unused struct cmdline *cl,
14813 __rte_unused void *data)
14815 #ifdef RTE_NET_I40E
14816 struct cmd_clear_input_set_result *res = parsed_result;
14817 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14818 struct rte_pmd_i40e_inset inset;
14820 int ret = -ENOTSUP;
14822 if (!all_ports_stopped()) {
14823 printf("Please stop all ports first\n");
14827 #ifdef RTE_NET_I40E
14828 if (!strcmp(res->inset_type, "hash_inset"))
14829 inset_type = INSET_HASH;
14830 else if (!strcmp(res->inset_type, "fdir_inset"))
14831 inset_type = INSET_FDIR;
14832 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14833 inset_type = INSET_FDIR_FLX;
14835 memset(&inset, 0, sizeof(inset));
14837 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14838 &inset, inset_type);
14840 printf("Failed to clear input set.\n");
14846 if (ret == -ENOTSUP)
14847 printf("Function not supported\n");
14850 cmdline_parse_token_string_t cmd_clear_input_set_port =
14851 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14853 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
14854 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14856 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
14857 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14859 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
14860 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14862 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
14863 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14865 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
14866 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14868 "hash_inset#fdir_inset#fdir_flx_inset");
14869 cmdline_parse_token_string_t cmd_clear_input_set_clear =
14870 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14872 cmdline_parse_token_string_t cmd_clear_input_set_all =
14873 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14876 cmdline_parse_inst_t cmd_clear_input_set = {
14877 .f = cmd_clear_input_set_parsed,
14879 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14880 "fdir_inset|fdir_flx_inset clear all",
14882 (void *)&cmd_clear_input_set_port,
14883 (void *)&cmd_clear_input_set_cfg,
14884 (void *)&cmd_clear_input_set_port_id,
14885 (void *)&cmd_clear_input_set_pctype,
14886 (void *)&cmd_clear_input_set_pctype_id,
14887 (void *)&cmd_clear_input_set_inset_type,
14888 (void *)&cmd_clear_input_set_clear,
14889 (void *)&cmd_clear_input_set_all,
14894 /* show vf stats */
14896 /* Common result structure for show vf stats */
14897 struct cmd_show_vf_stats_result {
14898 cmdline_fixed_string_t show;
14899 cmdline_fixed_string_t vf;
14900 cmdline_fixed_string_t stats;
14905 /* Common CLI fields show vf stats*/
14906 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14907 TOKEN_STRING_INITIALIZER
14908 (struct cmd_show_vf_stats_result,
14910 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14911 TOKEN_STRING_INITIALIZER
14912 (struct cmd_show_vf_stats_result,
14914 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14915 TOKEN_STRING_INITIALIZER
14916 (struct cmd_show_vf_stats_result,
14918 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14919 TOKEN_NUM_INITIALIZER
14920 (struct cmd_show_vf_stats_result,
14922 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14923 TOKEN_NUM_INITIALIZER
14924 (struct cmd_show_vf_stats_result,
14928 cmd_show_vf_stats_parsed(
14929 void *parsed_result,
14930 __rte_unused struct cmdline *cl,
14931 __rte_unused void *data)
14933 struct cmd_show_vf_stats_result *res = parsed_result;
14934 struct rte_eth_stats stats;
14935 int ret = -ENOTSUP;
14936 static const char *nic_stats_border = "########################";
14938 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14941 memset(&stats, 0, sizeof(stats));
14943 #ifdef RTE_NET_I40E
14944 if (ret == -ENOTSUP)
14945 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14949 #ifdef RTE_NET_BNXT
14950 if (ret == -ENOTSUP)
14951 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14960 printf("invalid vf_id %d\n", res->vf_id);
14963 printf("invalid port_id %d\n", res->port_id);
14966 printf("function not implemented\n");
14969 printf("programming error: (%s)\n", strerror(-ret));
14972 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14973 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14975 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14977 stats.ipackets, stats.imissed, stats.ibytes);
14978 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14979 printf(" RX-nombuf: %-10"PRIu64"\n",
14981 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14983 stats.opackets, stats.oerrors, stats.obytes);
14985 printf(" %s############################%s\n",
14986 nic_stats_border, nic_stats_border);
14989 cmdline_parse_inst_t cmd_show_vf_stats = {
14990 .f = cmd_show_vf_stats_parsed,
14992 .help_str = "show vf stats <port_id> <vf_id>",
14994 (void *)&cmd_show_vf_stats_show,
14995 (void *)&cmd_show_vf_stats_vf,
14996 (void *)&cmd_show_vf_stats_stats,
14997 (void *)&cmd_show_vf_stats_port_id,
14998 (void *)&cmd_show_vf_stats_vf_id,
15003 /* clear vf stats */
15005 /* Common result structure for clear vf stats */
15006 struct cmd_clear_vf_stats_result {
15007 cmdline_fixed_string_t clear;
15008 cmdline_fixed_string_t vf;
15009 cmdline_fixed_string_t stats;
15014 /* Common CLI fields clear vf stats*/
15015 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15016 TOKEN_STRING_INITIALIZER
15017 (struct cmd_clear_vf_stats_result,
15019 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15020 TOKEN_STRING_INITIALIZER
15021 (struct cmd_clear_vf_stats_result,
15023 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15024 TOKEN_STRING_INITIALIZER
15025 (struct cmd_clear_vf_stats_result,
15027 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15028 TOKEN_NUM_INITIALIZER
15029 (struct cmd_clear_vf_stats_result,
15031 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15032 TOKEN_NUM_INITIALIZER
15033 (struct cmd_clear_vf_stats_result,
15037 cmd_clear_vf_stats_parsed(
15038 void *parsed_result,
15039 __rte_unused struct cmdline *cl,
15040 __rte_unused void *data)
15042 struct cmd_clear_vf_stats_result *res = parsed_result;
15043 int ret = -ENOTSUP;
15045 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15048 #ifdef RTE_NET_I40E
15049 if (ret == -ENOTSUP)
15050 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15053 #ifdef RTE_NET_BNXT
15054 if (ret == -ENOTSUP)
15055 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15063 printf("invalid vf_id %d\n", res->vf_id);
15066 printf("invalid port_id %d\n", res->port_id);
15069 printf("function not implemented\n");
15072 printf("programming error: (%s)\n", strerror(-ret));
15076 cmdline_parse_inst_t cmd_clear_vf_stats = {
15077 .f = cmd_clear_vf_stats_parsed,
15079 .help_str = "clear vf stats <port_id> <vf_id>",
15081 (void *)&cmd_clear_vf_stats_clear,
15082 (void *)&cmd_clear_vf_stats_vf,
15083 (void *)&cmd_clear_vf_stats_stats,
15084 (void *)&cmd_clear_vf_stats_port_id,
15085 (void *)&cmd_clear_vf_stats_vf_id,
15090 /* port config pctype mapping reset */
15092 /* Common result structure for port config pctype mapping reset */
15093 struct cmd_pctype_mapping_reset_result {
15094 cmdline_fixed_string_t port;
15095 cmdline_fixed_string_t config;
15097 cmdline_fixed_string_t pctype;
15098 cmdline_fixed_string_t mapping;
15099 cmdline_fixed_string_t reset;
15102 /* Common CLI fields for port config pctype mapping reset*/
15103 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15104 TOKEN_STRING_INITIALIZER
15105 (struct cmd_pctype_mapping_reset_result,
15107 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15108 TOKEN_STRING_INITIALIZER
15109 (struct cmd_pctype_mapping_reset_result,
15111 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15112 TOKEN_NUM_INITIALIZER
15113 (struct cmd_pctype_mapping_reset_result,
15115 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15116 TOKEN_STRING_INITIALIZER
15117 (struct cmd_pctype_mapping_reset_result,
15119 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15120 TOKEN_STRING_INITIALIZER
15121 (struct cmd_pctype_mapping_reset_result,
15122 mapping, "mapping");
15123 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15124 TOKEN_STRING_INITIALIZER
15125 (struct cmd_pctype_mapping_reset_result,
15129 cmd_pctype_mapping_reset_parsed(
15130 void *parsed_result,
15131 __rte_unused struct cmdline *cl,
15132 __rte_unused void *data)
15134 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15135 int ret = -ENOTSUP;
15137 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15140 #ifdef RTE_NET_I40E
15141 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15148 printf("invalid port_id %d\n", res->port_id);
15151 printf("function not implemented\n");
15154 printf("programming error: (%s)\n", strerror(-ret));
15158 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15159 .f = cmd_pctype_mapping_reset_parsed,
15161 .help_str = "port config <port_id> pctype mapping reset",
15163 (void *)&cmd_pctype_mapping_reset_port,
15164 (void *)&cmd_pctype_mapping_reset_config,
15165 (void *)&cmd_pctype_mapping_reset_port_id,
15166 (void *)&cmd_pctype_mapping_reset_pctype,
15167 (void *)&cmd_pctype_mapping_reset_mapping,
15168 (void *)&cmd_pctype_mapping_reset_reset,
15173 /* show port pctype mapping */
15175 /* Common result structure for show port pctype mapping */
15176 struct cmd_pctype_mapping_get_result {
15177 cmdline_fixed_string_t show;
15178 cmdline_fixed_string_t port;
15180 cmdline_fixed_string_t pctype;
15181 cmdline_fixed_string_t mapping;
15184 /* Common CLI fields for pctype mapping get */
15185 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15186 TOKEN_STRING_INITIALIZER
15187 (struct cmd_pctype_mapping_get_result,
15189 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15190 TOKEN_STRING_INITIALIZER
15191 (struct cmd_pctype_mapping_get_result,
15193 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15194 TOKEN_NUM_INITIALIZER
15195 (struct cmd_pctype_mapping_get_result,
15197 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15198 TOKEN_STRING_INITIALIZER
15199 (struct cmd_pctype_mapping_get_result,
15201 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15202 TOKEN_STRING_INITIALIZER
15203 (struct cmd_pctype_mapping_get_result,
15204 mapping, "mapping");
15207 cmd_pctype_mapping_get_parsed(
15208 void *parsed_result,
15209 __rte_unused struct cmdline *cl,
15210 __rte_unused void *data)
15212 struct cmd_pctype_mapping_get_result *res = parsed_result;
15213 int ret = -ENOTSUP;
15214 #ifdef RTE_NET_I40E
15215 struct rte_pmd_i40e_flow_type_mapping
15216 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15217 int i, j, first_pctype;
15220 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15223 #ifdef RTE_NET_I40E
15224 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15231 printf("invalid port_id %d\n", res->port_id);
15234 printf("function not implemented\n");
15237 printf("programming error: (%s)\n", strerror(-ret));
15241 #ifdef RTE_NET_I40E
15242 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15243 if (mapping[i].pctype != 0ULL) {
15246 printf("pctype: ");
15247 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15248 if (mapping[i].pctype & (1ULL << j)) {
15249 printf(first_pctype ?
15250 "%02d" : ",%02d", j);
15254 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15260 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15261 .f = cmd_pctype_mapping_get_parsed,
15263 .help_str = "show port <port_id> pctype mapping",
15265 (void *)&cmd_pctype_mapping_get_show,
15266 (void *)&cmd_pctype_mapping_get_port,
15267 (void *)&cmd_pctype_mapping_get_port_id,
15268 (void *)&cmd_pctype_mapping_get_pctype,
15269 (void *)&cmd_pctype_mapping_get_mapping,
15274 /* port config pctype mapping update */
15276 /* Common result structure for port config pctype mapping update */
15277 struct cmd_pctype_mapping_update_result {
15278 cmdline_fixed_string_t port;
15279 cmdline_fixed_string_t config;
15281 cmdline_fixed_string_t pctype;
15282 cmdline_fixed_string_t mapping;
15283 cmdline_fixed_string_t update;
15284 cmdline_fixed_string_t pctype_list;
15285 uint16_t flow_type;
15288 /* Common CLI fields for pctype mapping update*/
15289 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15290 TOKEN_STRING_INITIALIZER
15291 (struct cmd_pctype_mapping_update_result,
15293 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15294 TOKEN_STRING_INITIALIZER
15295 (struct cmd_pctype_mapping_update_result,
15297 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15298 TOKEN_NUM_INITIALIZER
15299 (struct cmd_pctype_mapping_update_result,
15301 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15302 TOKEN_STRING_INITIALIZER
15303 (struct cmd_pctype_mapping_update_result,
15305 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15306 TOKEN_STRING_INITIALIZER
15307 (struct cmd_pctype_mapping_update_result,
15308 mapping, "mapping");
15309 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15310 TOKEN_STRING_INITIALIZER
15311 (struct cmd_pctype_mapping_update_result,
15313 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15314 TOKEN_STRING_INITIALIZER
15315 (struct cmd_pctype_mapping_update_result,
15316 pctype_list, NULL);
15317 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15318 TOKEN_NUM_INITIALIZER
15319 (struct cmd_pctype_mapping_update_result,
15320 flow_type, UINT16);
15323 cmd_pctype_mapping_update_parsed(
15324 void *parsed_result,
15325 __rte_unused struct cmdline *cl,
15326 __rte_unused void *data)
15328 struct cmd_pctype_mapping_update_result *res = parsed_result;
15329 int ret = -ENOTSUP;
15330 #ifdef RTE_NET_I40E
15331 struct rte_pmd_i40e_flow_type_mapping mapping;
15333 unsigned int nb_item;
15334 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15337 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15340 #ifdef RTE_NET_I40E
15341 nb_item = parse_item_list(res->pctype_list, "pctypes",
15342 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15343 mapping.flow_type = res->flow_type;
15344 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15345 mapping.pctype |= (1ULL << pctype_list[i]);
15346 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15356 printf("invalid pctype or flow type\n");
15359 printf("invalid port_id %d\n", res->port_id);
15362 printf("function not implemented\n");
15365 printf("programming error: (%s)\n", strerror(-ret));
15369 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15370 .f = cmd_pctype_mapping_update_parsed,
15372 .help_str = "port config <port_id> pctype mapping update"
15373 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15375 (void *)&cmd_pctype_mapping_update_port,
15376 (void *)&cmd_pctype_mapping_update_config,
15377 (void *)&cmd_pctype_mapping_update_port_id,
15378 (void *)&cmd_pctype_mapping_update_pctype,
15379 (void *)&cmd_pctype_mapping_update_mapping,
15380 (void *)&cmd_pctype_mapping_update_update,
15381 (void *)&cmd_pctype_mapping_update_pc_type,
15382 (void *)&cmd_pctype_mapping_update_flow_type,
15387 /* ptype mapping get */
15389 /* Common result structure for ptype mapping get */
15390 struct cmd_ptype_mapping_get_result {
15391 cmdline_fixed_string_t ptype;
15392 cmdline_fixed_string_t mapping;
15393 cmdline_fixed_string_t get;
15395 uint8_t valid_only;
15398 /* Common CLI fields for ptype mapping get */
15399 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15400 TOKEN_STRING_INITIALIZER
15401 (struct cmd_ptype_mapping_get_result,
15403 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15404 TOKEN_STRING_INITIALIZER
15405 (struct cmd_ptype_mapping_get_result,
15406 mapping, "mapping");
15407 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15408 TOKEN_STRING_INITIALIZER
15409 (struct cmd_ptype_mapping_get_result,
15411 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15412 TOKEN_NUM_INITIALIZER
15413 (struct cmd_ptype_mapping_get_result,
15415 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15416 TOKEN_NUM_INITIALIZER
15417 (struct cmd_ptype_mapping_get_result,
15418 valid_only, UINT8);
15421 cmd_ptype_mapping_get_parsed(
15422 void *parsed_result,
15423 __rte_unused struct cmdline *cl,
15424 __rte_unused void *data)
15426 struct cmd_ptype_mapping_get_result *res = parsed_result;
15427 int ret = -ENOTSUP;
15428 #ifdef RTE_NET_I40E
15429 int max_ptype_num = 256;
15430 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15435 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15438 #ifdef RTE_NET_I40E
15439 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15450 printf("invalid port_id %d\n", res->port_id);
15453 printf("function not implemented\n");
15456 printf("programming error: (%s)\n", strerror(-ret));
15459 #ifdef RTE_NET_I40E
15461 for (i = 0; i < count; i++)
15462 printf("%3d\t0x%08x\n",
15463 mapping[i].hw_ptype, mapping[i].sw_ptype);
15468 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15469 .f = cmd_ptype_mapping_get_parsed,
15471 .help_str = "ptype mapping get <port_id> <valid_only>",
15473 (void *)&cmd_ptype_mapping_get_ptype,
15474 (void *)&cmd_ptype_mapping_get_mapping,
15475 (void *)&cmd_ptype_mapping_get_get,
15476 (void *)&cmd_ptype_mapping_get_port_id,
15477 (void *)&cmd_ptype_mapping_get_valid_only,
15482 /* ptype mapping replace */
15484 /* Common result structure for ptype mapping replace */
15485 struct cmd_ptype_mapping_replace_result {
15486 cmdline_fixed_string_t ptype;
15487 cmdline_fixed_string_t mapping;
15488 cmdline_fixed_string_t replace;
15495 /* Common CLI fields for ptype mapping replace */
15496 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15497 TOKEN_STRING_INITIALIZER
15498 (struct cmd_ptype_mapping_replace_result,
15500 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15501 TOKEN_STRING_INITIALIZER
15502 (struct cmd_ptype_mapping_replace_result,
15503 mapping, "mapping");
15504 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15505 TOKEN_STRING_INITIALIZER
15506 (struct cmd_ptype_mapping_replace_result,
15507 replace, "replace");
15508 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15509 TOKEN_NUM_INITIALIZER
15510 (struct cmd_ptype_mapping_replace_result,
15512 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15513 TOKEN_NUM_INITIALIZER
15514 (struct cmd_ptype_mapping_replace_result,
15516 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15517 TOKEN_NUM_INITIALIZER
15518 (struct cmd_ptype_mapping_replace_result,
15520 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15521 TOKEN_NUM_INITIALIZER
15522 (struct cmd_ptype_mapping_replace_result,
15526 cmd_ptype_mapping_replace_parsed(
15527 void *parsed_result,
15528 __rte_unused struct cmdline *cl,
15529 __rte_unused void *data)
15531 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15532 int ret = -ENOTSUP;
15534 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15537 #ifdef RTE_NET_I40E
15538 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15548 printf("invalid ptype 0x%8x or 0x%8x\n",
15549 res->target, res->pkt_type);
15552 printf("invalid port_id %d\n", res->port_id);
15555 printf("function not implemented\n");
15558 printf("programming error: (%s)\n", strerror(-ret));
15562 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15563 .f = cmd_ptype_mapping_replace_parsed,
15566 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15568 (void *)&cmd_ptype_mapping_replace_ptype,
15569 (void *)&cmd_ptype_mapping_replace_mapping,
15570 (void *)&cmd_ptype_mapping_replace_replace,
15571 (void *)&cmd_ptype_mapping_replace_port_id,
15572 (void *)&cmd_ptype_mapping_replace_target,
15573 (void *)&cmd_ptype_mapping_replace_mask,
15574 (void *)&cmd_ptype_mapping_replace_pkt_type,
15579 /* ptype mapping reset */
15581 /* Common result structure for ptype mapping reset */
15582 struct cmd_ptype_mapping_reset_result {
15583 cmdline_fixed_string_t ptype;
15584 cmdline_fixed_string_t mapping;
15585 cmdline_fixed_string_t reset;
15589 /* Common CLI fields for ptype mapping reset*/
15590 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15591 TOKEN_STRING_INITIALIZER
15592 (struct cmd_ptype_mapping_reset_result,
15594 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15595 TOKEN_STRING_INITIALIZER
15596 (struct cmd_ptype_mapping_reset_result,
15597 mapping, "mapping");
15598 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15599 TOKEN_STRING_INITIALIZER
15600 (struct cmd_ptype_mapping_reset_result,
15602 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15603 TOKEN_NUM_INITIALIZER
15604 (struct cmd_ptype_mapping_reset_result,
15608 cmd_ptype_mapping_reset_parsed(
15609 void *parsed_result,
15610 __rte_unused struct cmdline *cl,
15611 __rte_unused void *data)
15613 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15614 int ret = -ENOTSUP;
15616 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15619 #ifdef RTE_NET_I40E
15620 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15627 printf("invalid port_id %d\n", res->port_id);
15630 printf("function not implemented\n");
15633 printf("programming error: (%s)\n", strerror(-ret));
15637 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15638 .f = cmd_ptype_mapping_reset_parsed,
15640 .help_str = "ptype mapping reset <port_id>",
15642 (void *)&cmd_ptype_mapping_reset_ptype,
15643 (void *)&cmd_ptype_mapping_reset_mapping,
15644 (void *)&cmd_ptype_mapping_reset_reset,
15645 (void *)&cmd_ptype_mapping_reset_port_id,
15650 /* ptype mapping update */
15652 /* Common result structure for ptype mapping update */
15653 struct cmd_ptype_mapping_update_result {
15654 cmdline_fixed_string_t ptype;
15655 cmdline_fixed_string_t mapping;
15656 cmdline_fixed_string_t reset;
15662 /* Common CLI fields for ptype mapping update*/
15663 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15664 TOKEN_STRING_INITIALIZER
15665 (struct cmd_ptype_mapping_update_result,
15667 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15668 TOKEN_STRING_INITIALIZER
15669 (struct cmd_ptype_mapping_update_result,
15670 mapping, "mapping");
15671 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15672 TOKEN_STRING_INITIALIZER
15673 (struct cmd_ptype_mapping_update_result,
15675 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15676 TOKEN_NUM_INITIALIZER
15677 (struct cmd_ptype_mapping_update_result,
15679 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15680 TOKEN_NUM_INITIALIZER
15681 (struct cmd_ptype_mapping_update_result,
15683 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15684 TOKEN_NUM_INITIALIZER
15685 (struct cmd_ptype_mapping_update_result,
15689 cmd_ptype_mapping_update_parsed(
15690 void *parsed_result,
15691 __rte_unused struct cmdline *cl,
15692 __rte_unused void *data)
15694 struct cmd_ptype_mapping_update_result *res = parsed_result;
15695 int ret = -ENOTSUP;
15696 #ifdef RTE_NET_I40E
15697 struct rte_pmd_i40e_ptype_mapping mapping;
15699 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15702 #ifdef RTE_NET_I40E
15703 mapping.hw_ptype = res->hw_ptype;
15704 mapping.sw_ptype = res->sw_ptype;
15705 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15715 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15718 printf("invalid port_id %d\n", res->port_id);
15721 printf("function not implemented\n");
15724 printf("programming error: (%s)\n", strerror(-ret));
15728 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15729 .f = cmd_ptype_mapping_update_parsed,
15731 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15733 (void *)&cmd_ptype_mapping_update_ptype,
15734 (void *)&cmd_ptype_mapping_update_mapping,
15735 (void *)&cmd_ptype_mapping_update_update,
15736 (void *)&cmd_ptype_mapping_update_port_id,
15737 (void *)&cmd_ptype_mapping_update_hw_ptype,
15738 (void *)&cmd_ptype_mapping_update_sw_ptype,
15743 /* Common result structure for file commands */
15744 struct cmd_cmdfile_result {
15745 cmdline_fixed_string_t load;
15746 cmdline_fixed_string_t filename;
15749 /* Common CLI fields for file commands */
15750 cmdline_parse_token_string_t cmd_load_cmdfile =
15751 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15752 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15753 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15756 cmd_load_from_file_parsed(
15757 void *parsed_result,
15758 __rte_unused struct cmdline *cl,
15759 __rte_unused void *data)
15761 struct cmd_cmdfile_result *res = parsed_result;
15763 cmdline_read_from_file(res->filename);
15766 cmdline_parse_inst_t cmd_load_from_file = {
15767 .f = cmd_load_from_file_parsed,
15769 .help_str = "load <filename>",
15771 (void *)&cmd_load_cmdfile,
15772 (void *)&cmd_load_cmdfile_filename,
15777 /* Get Rx offloads capabilities */
15778 struct cmd_rx_offload_get_capa_result {
15779 cmdline_fixed_string_t show;
15780 cmdline_fixed_string_t port;
15782 cmdline_fixed_string_t rx_offload;
15783 cmdline_fixed_string_t capabilities;
15786 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
15787 TOKEN_STRING_INITIALIZER
15788 (struct cmd_rx_offload_get_capa_result,
15790 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
15791 TOKEN_STRING_INITIALIZER
15792 (struct cmd_rx_offload_get_capa_result,
15794 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
15795 TOKEN_NUM_INITIALIZER
15796 (struct cmd_rx_offload_get_capa_result,
15798 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
15799 TOKEN_STRING_INITIALIZER
15800 (struct cmd_rx_offload_get_capa_result,
15801 rx_offload, "rx_offload");
15802 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
15803 TOKEN_STRING_INITIALIZER
15804 (struct cmd_rx_offload_get_capa_result,
15805 capabilities, "capabilities");
15808 print_rx_offloads(uint64_t offloads)
15810 uint64_t single_offload;
15818 begin = __builtin_ctzll(offloads);
15819 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15821 single_offload = 1ULL << begin;
15822 for (bit = begin; bit < end; bit++) {
15823 if (offloads & single_offload)
15825 rte_eth_dev_rx_offload_name(single_offload));
15826 single_offload <<= 1;
15831 cmd_rx_offload_get_capa_parsed(
15832 void *parsed_result,
15833 __rte_unused struct cmdline *cl,
15834 __rte_unused void *data)
15836 struct cmd_rx_offload_get_capa_result *res = parsed_result;
15837 struct rte_eth_dev_info dev_info;
15838 portid_t port_id = res->port_id;
15839 uint64_t queue_offloads;
15840 uint64_t port_offloads;
15843 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15847 queue_offloads = dev_info.rx_queue_offload_capa;
15848 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
15850 printf("Rx Offloading Capabilities of port %d :\n", port_id);
15851 printf(" Per Queue :");
15852 print_rx_offloads(queue_offloads);
15855 printf(" Per Port :");
15856 print_rx_offloads(port_offloads);
15860 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
15861 .f = cmd_rx_offload_get_capa_parsed,
15863 .help_str = "show port <port_id> rx_offload capabilities",
15865 (void *)&cmd_rx_offload_get_capa_show,
15866 (void *)&cmd_rx_offload_get_capa_port,
15867 (void *)&cmd_rx_offload_get_capa_port_id,
15868 (void *)&cmd_rx_offload_get_capa_rx_offload,
15869 (void *)&cmd_rx_offload_get_capa_capabilities,
15874 /* Get Rx offloads configuration */
15875 struct cmd_rx_offload_get_configuration_result {
15876 cmdline_fixed_string_t show;
15877 cmdline_fixed_string_t port;
15879 cmdline_fixed_string_t rx_offload;
15880 cmdline_fixed_string_t configuration;
15883 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
15884 TOKEN_STRING_INITIALIZER
15885 (struct cmd_rx_offload_get_configuration_result,
15887 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
15888 TOKEN_STRING_INITIALIZER
15889 (struct cmd_rx_offload_get_configuration_result,
15891 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
15892 TOKEN_NUM_INITIALIZER
15893 (struct cmd_rx_offload_get_configuration_result,
15895 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
15896 TOKEN_STRING_INITIALIZER
15897 (struct cmd_rx_offload_get_configuration_result,
15898 rx_offload, "rx_offload");
15899 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
15900 TOKEN_STRING_INITIALIZER
15901 (struct cmd_rx_offload_get_configuration_result,
15902 configuration, "configuration");
15905 cmd_rx_offload_get_configuration_parsed(
15906 void *parsed_result,
15907 __rte_unused struct cmdline *cl,
15908 __rte_unused void *data)
15910 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
15911 struct rte_eth_dev_info dev_info;
15912 portid_t port_id = res->port_id;
15913 struct rte_port *port = &ports[port_id];
15914 uint64_t port_offloads;
15915 uint64_t queue_offloads;
15916 uint16_t nb_rx_queues;
15920 printf("Rx Offloading Configuration of port %d :\n", port_id);
15922 port_offloads = port->dev_conf.rxmode.offloads;
15924 print_rx_offloads(port_offloads);
15927 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15931 nb_rx_queues = dev_info.nb_rx_queues;
15932 for (q = 0; q < nb_rx_queues; q++) {
15933 queue_offloads = port->rx_conf[q].offloads;
15934 printf(" Queue[%2d] :", q);
15935 print_rx_offloads(queue_offloads);
15941 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
15942 .f = cmd_rx_offload_get_configuration_parsed,
15944 .help_str = "show port <port_id> rx_offload configuration",
15946 (void *)&cmd_rx_offload_get_configuration_show,
15947 (void *)&cmd_rx_offload_get_configuration_port,
15948 (void *)&cmd_rx_offload_get_configuration_port_id,
15949 (void *)&cmd_rx_offload_get_configuration_rx_offload,
15950 (void *)&cmd_rx_offload_get_configuration_configuration,
15955 /* Enable/Disable a per port offloading */
15956 struct cmd_config_per_port_rx_offload_result {
15957 cmdline_fixed_string_t port;
15958 cmdline_fixed_string_t config;
15960 cmdline_fixed_string_t rx_offload;
15961 cmdline_fixed_string_t offload;
15962 cmdline_fixed_string_t on_off;
15965 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
15966 TOKEN_STRING_INITIALIZER
15967 (struct cmd_config_per_port_rx_offload_result,
15969 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
15970 TOKEN_STRING_INITIALIZER
15971 (struct cmd_config_per_port_rx_offload_result,
15973 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
15974 TOKEN_NUM_INITIALIZER
15975 (struct cmd_config_per_port_rx_offload_result,
15977 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
15978 TOKEN_STRING_INITIALIZER
15979 (struct cmd_config_per_port_rx_offload_result,
15980 rx_offload, "rx_offload");
15981 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
15982 TOKEN_STRING_INITIALIZER
15983 (struct cmd_config_per_port_rx_offload_result,
15984 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
15985 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
15986 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
15987 "scatter#buffer_split#timestamp#security#"
15988 "keep_crc#rss_hash");
15989 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
15990 TOKEN_STRING_INITIALIZER
15991 (struct cmd_config_per_port_rx_offload_result,
15995 search_rx_offload(const char *name)
15997 uint64_t single_offload;
15998 const char *single_name;
16002 single_offload = 1;
16003 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16004 single_name = rte_eth_dev_rx_offload_name(single_offload);
16005 if (!strcasecmp(single_name, name)) {
16009 single_offload <<= 1;
16013 return single_offload;
16019 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16020 __rte_unused struct cmdline *cl,
16021 __rte_unused void *data)
16023 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16024 portid_t port_id = res->port_id;
16025 struct rte_eth_dev_info dev_info;
16026 struct rte_port *port = &ports[port_id];
16027 uint64_t single_offload;
16028 uint16_t nb_rx_queues;
16032 if (port->port_status != RTE_PORT_STOPPED) {
16033 printf("Error: Can't config offload when Port %d "
16034 "is not stopped\n", port_id);
16038 single_offload = search_rx_offload(res->offload);
16039 if (single_offload == 0) {
16040 printf("Unknown offload name: %s\n", res->offload);
16044 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16048 nb_rx_queues = dev_info.nb_rx_queues;
16049 if (!strcmp(res->on_off, "on")) {
16050 port->dev_conf.rxmode.offloads |= single_offload;
16051 for (q = 0; q < nb_rx_queues; q++)
16052 port->rx_conf[q].offloads |= single_offload;
16054 port->dev_conf.rxmode.offloads &= ~single_offload;
16055 for (q = 0; q < nb_rx_queues; q++)
16056 port->rx_conf[q].offloads &= ~single_offload;
16059 cmd_reconfig_device_queue(port_id, 1, 1);
16062 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16063 .f = cmd_config_per_port_rx_offload_parsed,
16065 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16066 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16067 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16068 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16069 "keep_crc|rss_hash on|off",
16071 (void *)&cmd_config_per_port_rx_offload_result_port,
16072 (void *)&cmd_config_per_port_rx_offload_result_config,
16073 (void *)&cmd_config_per_port_rx_offload_result_port_id,
16074 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16075 (void *)&cmd_config_per_port_rx_offload_result_offload,
16076 (void *)&cmd_config_per_port_rx_offload_result_on_off,
16081 /* Enable/Disable a per queue offloading */
16082 struct cmd_config_per_queue_rx_offload_result {
16083 cmdline_fixed_string_t port;
16085 cmdline_fixed_string_t rxq;
16087 cmdline_fixed_string_t rx_offload;
16088 cmdline_fixed_string_t offload;
16089 cmdline_fixed_string_t on_off;
16092 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16093 TOKEN_STRING_INITIALIZER
16094 (struct cmd_config_per_queue_rx_offload_result,
16096 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16097 TOKEN_NUM_INITIALIZER
16098 (struct cmd_config_per_queue_rx_offload_result,
16100 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16101 TOKEN_STRING_INITIALIZER
16102 (struct cmd_config_per_queue_rx_offload_result,
16104 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16105 TOKEN_NUM_INITIALIZER
16106 (struct cmd_config_per_queue_rx_offload_result,
16108 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16109 TOKEN_STRING_INITIALIZER
16110 (struct cmd_config_per_queue_rx_offload_result,
16111 rx_offload, "rx_offload");
16112 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16113 TOKEN_STRING_INITIALIZER
16114 (struct cmd_config_per_queue_rx_offload_result,
16115 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16116 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16117 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16118 "scatter#buffer_split#timestamp#security#keep_crc");
16119 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16120 TOKEN_STRING_INITIALIZER
16121 (struct cmd_config_per_queue_rx_offload_result,
16125 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16126 __rte_unused struct cmdline *cl,
16127 __rte_unused void *data)
16129 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16130 struct rte_eth_dev_info dev_info;
16131 portid_t port_id = res->port_id;
16132 uint16_t queue_id = res->queue_id;
16133 struct rte_port *port = &ports[port_id];
16134 uint64_t single_offload;
16137 if (port->port_status != RTE_PORT_STOPPED) {
16138 printf("Error: Can't config offload when Port %d "
16139 "is not stopped\n", port_id);
16143 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16147 if (queue_id >= dev_info.nb_rx_queues) {
16148 printf("Error: input queue_id should be 0 ... "
16149 "%d\n", dev_info.nb_rx_queues - 1);
16153 single_offload = search_rx_offload(res->offload);
16154 if (single_offload == 0) {
16155 printf("Unknown offload name: %s\n", res->offload);
16159 if (!strcmp(res->on_off, "on"))
16160 port->rx_conf[queue_id].offloads |= single_offload;
16162 port->rx_conf[queue_id].offloads &= ~single_offload;
16164 cmd_reconfig_device_queue(port_id, 1, 1);
16167 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16168 .f = cmd_config_per_queue_rx_offload_parsed,
16170 .help_str = "port <port_id> rxq <queue_id> rx_offload "
16171 "vlan_strip|ipv4_cksum|"
16172 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16173 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16174 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16177 (void *)&cmd_config_per_queue_rx_offload_result_port,
16178 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
16179 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
16180 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16181 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16182 (void *)&cmd_config_per_queue_rx_offload_result_offload,
16183 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
16188 /* Get Tx offloads capabilities */
16189 struct cmd_tx_offload_get_capa_result {
16190 cmdline_fixed_string_t show;
16191 cmdline_fixed_string_t port;
16193 cmdline_fixed_string_t tx_offload;
16194 cmdline_fixed_string_t capabilities;
16197 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16198 TOKEN_STRING_INITIALIZER
16199 (struct cmd_tx_offload_get_capa_result,
16201 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16202 TOKEN_STRING_INITIALIZER
16203 (struct cmd_tx_offload_get_capa_result,
16205 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16206 TOKEN_NUM_INITIALIZER
16207 (struct cmd_tx_offload_get_capa_result,
16209 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16210 TOKEN_STRING_INITIALIZER
16211 (struct cmd_tx_offload_get_capa_result,
16212 tx_offload, "tx_offload");
16213 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16214 TOKEN_STRING_INITIALIZER
16215 (struct cmd_tx_offload_get_capa_result,
16216 capabilities, "capabilities");
16219 print_tx_offloads(uint64_t offloads)
16221 uint64_t single_offload;
16229 begin = __builtin_ctzll(offloads);
16230 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16232 single_offload = 1ULL << begin;
16233 for (bit = begin; bit < end; bit++) {
16234 if (offloads & single_offload)
16236 rte_eth_dev_tx_offload_name(single_offload));
16237 single_offload <<= 1;
16242 cmd_tx_offload_get_capa_parsed(
16243 void *parsed_result,
16244 __rte_unused struct cmdline *cl,
16245 __rte_unused void *data)
16247 struct cmd_tx_offload_get_capa_result *res = parsed_result;
16248 struct rte_eth_dev_info dev_info;
16249 portid_t port_id = res->port_id;
16250 uint64_t queue_offloads;
16251 uint64_t port_offloads;
16254 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16258 queue_offloads = dev_info.tx_queue_offload_capa;
16259 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16261 printf("Tx Offloading Capabilities of port %d :\n", port_id);
16262 printf(" Per Queue :");
16263 print_tx_offloads(queue_offloads);
16266 printf(" Per Port :");
16267 print_tx_offloads(port_offloads);
16271 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16272 .f = cmd_tx_offload_get_capa_parsed,
16274 .help_str = "show port <port_id> tx_offload capabilities",
16276 (void *)&cmd_tx_offload_get_capa_show,
16277 (void *)&cmd_tx_offload_get_capa_port,
16278 (void *)&cmd_tx_offload_get_capa_port_id,
16279 (void *)&cmd_tx_offload_get_capa_tx_offload,
16280 (void *)&cmd_tx_offload_get_capa_capabilities,
16285 /* Get Tx offloads configuration */
16286 struct cmd_tx_offload_get_configuration_result {
16287 cmdline_fixed_string_t show;
16288 cmdline_fixed_string_t port;
16290 cmdline_fixed_string_t tx_offload;
16291 cmdline_fixed_string_t configuration;
16294 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16295 TOKEN_STRING_INITIALIZER
16296 (struct cmd_tx_offload_get_configuration_result,
16298 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16299 TOKEN_STRING_INITIALIZER
16300 (struct cmd_tx_offload_get_configuration_result,
16302 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16303 TOKEN_NUM_INITIALIZER
16304 (struct cmd_tx_offload_get_configuration_result,
16306 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16307 TOKEN_STRING_INITIALIZER
16308 (struct cmd_tx_offload_get_configuration_result,
16309 tx_offload, "tx_offload");
16310 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16311 TOKEN_STRING_INITIALIZER
16312 (struct cmd_tx_offload_get_configuration_result,
16313 configuration, "configuration");
16316 cmd_tx_offload_get_configuration_parsed(
16317 void *parsed_result,
16318 __rte_unused struct cmdline *cl,
16319 __rte_unused void *data)
16321 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16322 struct rte_eth_dev_info dev_info;
16323 portid_t port_id = res->port_id;
16324 struct rte_port *port = &ports[port_id];
16325 uint64_t port_offloads;
16326 uint64_t queue_offloads;
16327 uint16_t nb_tx_queues;
16331 printf("Tx Offloading Configuration of port %d :\n", port_id);
16333 port_offloads = port->dev_conf.txmode.offloads;
16335 print_tx_offloads(port_offloads);
16338 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16342 nb_tx_queues = dev_info.nb_tx_queues;
16343 for (q = 0; q < nb_tx_queues; q++) {
16344 queue_offloads = port->tx_conf[q].offloads;
16345 printf(" Queue[%2d] :", q);
16346 print_tx_offloads(queue_offloads);
16352 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16353 .f = cmd_tx_offload_get_configuration_parsed,
16355 .help_str = "show port <port_id> tx_offload configuration",
16357 (void *)&cmd_tx_offload_get_configuration_show,
16358 (void *)&cmd_tx_offload_get_configuration_port,
16359 (void *)&cmd_tx_offload_get_configuration_port_id,
16360 (void *)&cmd_tx_offload_get_configuration_tx_offload,
16361 (void *)&cmd_tx_offload_get_configuration_configuration,
16366 /* Enable/Disable a per port offloading */
16367 struct cmd_config_per_port_tx_offload_result {
16368 cmdline_fixed_string_t port;
16369 cmdline_fixed_string_t config;
16371 cmdline_fixed_string_t tx_offload;
16372 cmdline_fixed_string_t offload;
16373 cmdline_fixed_string_t on_off;
16376 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16377 TOKEN_STRING_INITIALIZER
16378 (struct cmd_config_per_port_tx_offload_result,
16380 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16381 TOKEN_STRING_INITIALIZER
16382 (struct cmd_config_per_port_tx_offload_result,
16384 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16385 TOKEN_NUM_INITIALIZER
16386 (struct cmd_config_per_port_tx_offload_result,
16388 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16389 TOKEN_STRING_INITIALIZER
16390 (struct cmd_config_per_port_tx_offload_result,
16391 tx_offload, "tx_offload");
16392 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16393 TOKEN_STRING_INITIALIZER
16394 (struct cmd_config_per_port_tx_offload_result,
16395 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16396 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16397 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16398 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16399 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16400 "send_on_timestamp");
16401 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16402 TOKEN_STRING_INITIALIZER
16403 (struct cmd_config_per_port_tx_offload_result,
16407 search_tx_offload(const char *name)
16409 uint64_t single_offload;
16410 const char *single_name;
16414 single_offload = 1;
16415 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16416 single_name = rte_eth_dev_tx_offload_name(single_offload);
16417 if (single_name == NULL)
16419 if (!strcasecmp(single_name, name)) {
16422 } else if (!strcasecmp(single_name, "UNKNOWN"))
16424 single_offload <<= 1;
16428 return single_offload;
16434 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16435 __rte_unused struct cmdline *cl,
16436 __rte_unused void *data)
16438 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16439 portid_t port_id = res->port_id;
16440 struct rte_eth_dev_info dev_info;
16441 struct rte_port *port = &ports[port_id];
16442 uint64_t single_offload;
16443 uint16_t nb_tx_queues;
16447 if (port->port_status != RTE_PORT_STOPPED) {
16448 printf("Error: Can't config offload when Port %d "
16449 "is not stopped\n", port_id);
16453 single_offload = search_tx_offload(res->offload);
16454 if (single_offload == 0) {
16455 printf("Unknown offload name: %s\n", res->offload);
16459 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16463 nb_tx_queues = dev_info.nb_tx_queues;
16464 if (!strcmp(res->on_off, "on")) {
16465 port->dev_conf.txmode.offloads |= single_offload;
16466 for (q = 0; q < nb_tx_queues; q++)
16467 port->tx_conf[q].offloads |= single_offload;
16469 port->dev_conf.txmode.offloads &= ~single_offload;
16470 for (q = 0; q < nb_tx_queues; q++)
16471 port->tx_conf[q].offloads &= ~single_offload;
16474 cmd_reconfig_device_queue(port_id, 1, 1);
16477 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16478 .f = cmd_config_per_port_tx_offload_parsed,
16480 .help_str = "port config <port_id> tx_offload "
16481 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16482 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16483 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16484 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16485 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16486 "send_on_timestamp on|off",
16488 (void *)&cmd_config_per_port_tx_offload_result_port,
16489 (void *)&cmd_config_per_port_tx_offload_result_config,
16490 (void *)&cmd_config_per_port_tx_offload_result_port_id,
16491 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16492 (void *)&cmd_config_per_port_tx_offload_result_offload,
16493 (void *)&cmd_config_per_port_tx_offload_result_on_off,
16498 /* Enable/Disable a per queue offloading */
16499 struct cmd_config_per_queue_tx_offload_result {
16500 cmdline_fixed_string_t port;
16502 cmdline_fixed_string_t txq;
16504 cmdline_fixed_string_t tx_offload;
16505 cmdline_fixed_string_t offload;
16506 cmdline_fixed_string_t on_off;
16509 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16510 TOKEN_STRING_INITIALIZER
16511 (struct cmd_config_per_queue_tx_offload_result,
16513 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16514 TOKEN_NUM_INITIALIZER
16515 (struct cmd_config_per_queue_tx_offload_result,
16517 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16518 TOKEN_STRING_INITIALIZER
16519 (struct cmd_config_per_queue_tx_offload_result,
16521 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16522 TOKEN_NUM_INITIALIZER
16523 (struct cmd_config_per_queue_tx_offload_result,
16525 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16526 TOKEN_STRING_INITIALIZER
16527 (struct cmd_config_per_queue_tx_offload_result,
16528 tx_offload, "tx_offload");
16529 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16530 TOKEN_STRING_INITIALIZER
16531 (struct cmd_config_per_queue_tx_offload_result,
16532 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16533 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16534 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16535 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16536 "mt_lockfree#multi_segs#mbuf_fast_free#security");
16537 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16538 TOKEN_STRING_INITIALIZER
16539 (struct cmd_config_per_queue_tx_offload_result,
16543 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16544 __rte_unused struct cmdline *cl,
16545 __rte_unused void *data)
16547 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16548 struct rte_eth_dev_info dev_info;
16549 portid_t port_id = res->port_id;
16550 uint16_t queue_id = res->queue_id;
16551 struct rte_port *port = &ports[port_id];
16552 uint64_t single_offload;
16555 if (port->port_status != RTE_PORT_STOPPED) {
16556 printf("Error: Can't config offload when Port %d "
16557 "is not stopped\n", port_id);
16561 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16565 if (queue_id >= dev_info.nb_tx_queues) {
16566 printf("Error: input queue_id should be 0 ... "
16567 "%d\n", dev_info.nb_tx_queues - 1);
16571 single_offload = search_tx_offload(res->offload);
16572 if (single_offload == 0) {
16573 printf("Unknown offload name: %s\n", res->offload);
16577 if (!strcmp(res->on_off, "on"))
16578 port->tx_conf[queue_id].offloads |= single_offload;
16580 port->tx_conf[queue_id].offloads &= ~single_offload;
16582 cmd_reconfig_device_queue(port_id, 1, 1);
16585 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16586 .f = cmd_config_per_queue_tx_offload_parsed,
16588 .help_str = "port <port_id> txq <queue_id> tx_offload "
16589 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16590 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16591 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16592 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16593 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16596 (void *)&cmd_config_per_queue_tx_offload_result_port,
16597 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16598 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16599 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16600 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16601 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16602 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16607 /* *** configure tx_metadata for specific port *** */
16608 struct cmd_config_tx_metadata_specific_result {
16609 cmdline_fixed_string_t port;
16610 cmdline_fixed_string_t keyword;
16612 cmdline_fixed_string_t item;
16617 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16618 __rte_unused struct cmdline *cl,
16619 __rte_unused void *data)
16621 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16623 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16625 ports[res->port_id].tx_metadata = res->value;
16626 /* Add/remove callback to insert valid metadata in every Tx packet. */
16627 if (ports[res->port_id].tx_metadata)
16628 add_tx_md_callback(res->port_id);
16630 remove_tx_md_callback(res->port_id);
16631 rte_flow_dynf_metadata_register();
16634 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16635 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16637 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16638 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16639 keyword, "config");
16640 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16641 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16643 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16644 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16645 item, "tx_metadata");
16646 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16647 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16650 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16651 .f = cmd_config_tx_metadata_specific_parsed,
16653 .help_str = "port config <port_id> tx_metadata <value>",
16655 (void *)&cmd_config_tx_metadata_specific_port,
16656 (void *)&cmd_config_tx_metadata_specific_keyword,
16657 (void *)&cmd_config_tx_metadata_specific_id,
16658 (void *)&cmd_config_tx_metadata_specific_item,
16659 (void *)&cmd_config_tx_metadata_specific_value,
16664 /* *** set dynf *** */
16665 struct cmd_config_tx_dynf_specific_result {
16666 cmdline_fixed_string_t port;
16667 cmdline_fixed_string_t keyword;
16669 cmdline_fixed_string_t item;
16670 cmdline_fixed_string_t name;
16671 cmdline_fixed_string_t value;
16675 cmd_config_dynf_specific_parsed(void *parsed_result,
16676 __rte_unused struct cmdline *cl,
16677 __rte_unused void *data)
16679 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16680 struct rte_mbuf_dynflag desc_flag;
16682 uint64_t old_port_flags;
16684 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16686 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16688 if (strlcpy(desc_flag.name, res->name,
16689 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16690 printf("Flag name too long\n");
16693 desc_flag.flags = 0;
16694 flag = rte_mbuf_dynflag_register(&desc_flag);
16696 printf("Can't register flag\n");
16699 strcpy(dynf_names[flag], desc_flag.name);
16701 old_port_flags = ports[res->port_id].mbuf_dynf;
16702 if (!strcmp(res->value, "set")) {
16703 ports[res->port_id].mbuf_dynf |= 1UL << flag;
16704 if (old_port_flags == 0)
16705 add_tx_dynf_callback(res->port_id);
16707 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16708 if (ports[res->port_id].mbuf_dynf == 0)
16709 remove_tx_dynf_callback(res->port_id);
16713 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16714 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16716 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16717 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16718 keyword, "config");
16719 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
16720 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16722 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
16723 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16725 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
16726 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16728 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
16729 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16730 value, "set#clear");
16732 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
16733 .f = cmd_config_dynf_specific_parsed,
16735 .help_str = "port config <port id> dynf <name> set|clear",
16737 (void *)&cmd_config_tx_dynf_specific_port,
16738 (void *)&cmd_config_tx_dynf_specific_keyword,
16739 (void *)&cmd_config_tx_dynf_specific_port_id,
16740 (void *)&cmd_config_tx_dynf_specific_item,
16741 (void *)&cmd_config_tx_dynf_specific_name,
16742 (void *)&cmd_config_tx_dynf_specific_value,
16747 /* *** display tx_metadata per port configuration *** */
16748 struct cmd_show_tx_metadata_result {
16749 cmdline_fixed_string_t cmd_show;
16750 cmdline_fixed_string_t cmd_port;
16751 cmdline_fixed_string_t cmd_keyword;
16756 cmd_show_tx_metadata_parsed(void *parsed_result,
16757 __rte_unused struct cmdline *cl,
16758 __rte_unused void *data)
16760 struct cmd_show_tx_metadata_result *res = parsed_result;
16762 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16763 printf("invalid port id %u\n", res->cmd_pid);
16766 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
16767 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
16768 ports[res->cmd_pid].tx_metadata);
16772 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
16773 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16775 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
16776 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16778 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
16779 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
16781 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
16782 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16783 cmd_keyword, "tx_metadata");
16785 cmdline_parse_inst_t cmd_show_tx_metadata = {
16786 .f = cmd_show_tx_metadata_parsed,
16788 .help_str = "show port <port_id> tx_metadata",
16790 (void *)&cmd_show_tx_metadata_show,
16791 (void *)&cmd_show_tx_metadata_port,
16792 (void *)&cmd_show_tx_metadata_pid,
16793 (void *)&cmd_show_tx_metadata_keyword,
16798 /* *** show fec capability per port configuration *** */
16799 struct cmd_show_fec_capability_result {
16800 cmdline_fixed_string_t cmd_show;
16801 cmdline_fixed_string_t cmd_port;
16802 cmdline_fixed_string_t cmd_fec;
16803 cmdline_fixed_string_t cmd_keyword;
16808 cmd_show_fec_capability_parsed(void *parsed_result,
16809 __rte_unused struct cmdline *cl,
16810 __rte_unused void *data)
16812 #define FEC_CAP_NUM 2
16813 struct cmd_show_fec_capability_result *res = parsed_result;
16814 struct rte_eth_fec_capa speed_fec_capa[FEC_CAP_NUM];
16815 unsigned int num = FEC_CAP_NUM;
16816 unsigned int ret_num;
16819 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16820 printf("Invalid port id %u\n", res->cmd_pid);
16824 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
16825 if (ret == -ENOTSUP) {
16826 printf("Function not implemented\n");
16828 } else if (ret < 0) {
16829 printf("Get FEC capability failed\n");
16833 ret_num = (unsigned int)ret;
16834 show_fec_capability(ret_num, speed_fec_capa);
16837 cmdline_parse_token_string_t cmd_show_fec_capability_show =
16838 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16840 cmdline_parse_token_string_t cmd_show_fec_capability_port =
16841 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16843 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
16844 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
16846 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
16847 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16849 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
16850 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16851 cmd_keyword, "capabilities");
16853 cmdline_parse_inst_t cmd_show_capability = {
16854 .f = cmd_show_fec_capability_parsed,
16856 .help_str = "show port <port_id> fec capabilities",
16858 (void *)&cmd_show_fec_capability_show,
16859 (void *)&cmd_show_fec_capability_port,
16860 (void *)&cmd_show_fec_capability_pid,
16861 (void *)&cmd_show_fec_capability_fec,
16862 (void *)&cmd_show_fec_capability_keyword,
16867 /* *** show fec mode per port configuration *** */
16868 struct cmd_show_fec_metadata_result {
16869 cmdline_fixed_string_t cmd_show;
16870 cmdline_fixed_string_t cmd_port;
16871 cmdline_fixed_string_t cmd_keyword;
16876 cmd_show_fec_mode_parsed(void *parsed_result,
16877 __rte_unused struct cmdline *cl,
16878 __rte_unused void *data)
16880 #define FEC_NAME_SIZE 16
16881 struct cmd_show_fec_metadata_result *res = parsed_result;
16883 char buf[FEC_NAME_SIZE];
16886 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16887 printf("Invalid port id %u\n", res->cmd_pid);
16890 ret = rte_eth_fec_get(res->cmd_pid, &mode);
16891 if (ret == -ENOTSUP) {
16892 printf("Function not implemented\n");
16894 } else if (ret < 0) {
16895 printf("Get FEC mode failed\n");
16900 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
16901 strlcpy(buf, "off", sizeof(buf));
16903 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
16904 strlcpy(buf, "auto", sizeof(buf));
16906 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
16907 strlcpy(buf, "baser", sizeof(buf));
16909 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
16910 strlcpy(buf, "rs", sizeof(buf));
16916 printf("%s\n", buf);
16919 cmdline_parse_token_string_t cmd_show_fec_mode_show =
16920 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16922 cmdline_parse_token_string_t cmd_show_fec_mode_port =
16923 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16925 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
16926 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
16928 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
16929 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16930 cmd_keyword, "fec_mode");
16932 cmdline_parse_inst_t cmd_show_fec_mode = {
16933 .f = cmd_show_fec_mode_parsed,
16935 .help_str = "show port <port_id> fec_mode",
16937 (void *)&cmd_show_fec_mode_show,
16938 (void *)&cmd_show_fec_mode_port,
16939 (void *)&cmd_show_fec_mode_pid,
16940 (void *)&cmd_show_fec_mode_keyword,
16945 /* *** set fec mode per port configuration *** */
16946 struct cmd_set_port_fec_mode {
16947 cmdline_fixed_string_t set;
16948 cmdline_fixed_string_t port;
16950 cmdline_fixed_string_t fec_mode;
16951 cmdline_fixed_string_t fec_value;
16954 /* Common CLI fields for set fec mode */
16955 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
16956 TOKEN_STRING_INITIALIZER
16957 (struct cmd_set_port_fec_mode,
16959 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
16960 TOKEN_STRING_INITIALIZER
16961 (struct cmd_set_port_fec_mode,
16963 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
16964 TOKEN_NUM_INITIALIZER
16965 (struct cmd_set_port_fec_mode,
16967 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
16968 TOKEN_STRING_INITIALIZER
16969 (struct cmd_set_port_fec_mode,
16970 fec_mode, "fec_mode");
16971 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
16972 TOKEN_STRING_INITIALIZER
16973 (struct cmd_set_port_fec_mode,
16977 cmd_set_port_fec_mode_parsed(
16978 void *parsed_result,
16979 __rte_unused struct cmdline *cl,
16980 __rte_unused void *data)
16982 struct cmd_set_port_fec_mode *res = parsed_result;
16983 uint16_t port_id = res->port_id;
16987 ret = parse_fec_mode(res->fec_value, &mode);
16989 printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
16994 ret = rte_eth_fec_set(port_id, mode);
16995 if (ret == -ENOTSUP) {
16996 printf("Function not implemented\n");
16998 } else if (ret < 0) {
16999 printf("Set FEC mode failed\n");
17004 cmdline_parse_inst_t cmd_set_fec_mode = {
17005 .f = cmd_set_port_fec_mode_parsed,
17007 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
17009 (void *)&cmd_set_port_fec_mode_set,
17010 (void *)&cmd_set_port_fec_mode_port,
17011 (void *)&cmd_set_port_fec_mode_port_id,
17012 (void *)&cmd_set_port_fec_mode_str,
17013 (void *)&cmd_set_port_fec_mode_value,
17018 /* show port supported ptypes */
17020 /* Common result structure for show port ptypes */
17021 struct cmd_show_port_supported_ptypes_result {
17022 cmdline_fixed_string_t show;
17023 cmdline_fixed_string_t port;
17025 cmdline_fixed_string_t ptypes;
17028 /* Common CLI fields for show port ptypes */
17029 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
17030 TOKEN_STRING_INITIALIZER
17031 (struct cmd_show_port_supported_ptypes_result,
17033 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
17034 TOKEN_STRING_INITIALIZER
17035 (struct cmd_show_port_supported_ptypes_result,
17037 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
17038 TOKEN_NUM_INITIALIZER
17039 (struct cmd_show_port_supported_ptypes_result,
17041 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
17042 TOKEN_STRING_INITIALIZER
17043 (struct cmd_show_port_supported_ptypes_result,
17047 cmd_show_port_supported_ptypes_parsed(
17048 void *parsed_result,
17049 __rte_unused struct cmdline *cl,
17050 __rte_unused void *data)
17052 #define RSVD_PTYPE_MASK 0xf0000000
17053 #define MAX_PTYPES_PER_LAYER 16
17054 #define LTYPE_NAMESIZE 32
17055 #define PTYPE_NAMESIZE 256
17056 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
17057 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
17058 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
17059 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
17060 uint16_t port_id = res->port_id;
17063 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
17067 while (ptype_mask != RSVD_PTYPE_MASK) {
17069 switch (ptype_mask) {
17070 case RTE_PTYPE_L2_MASK:
17071 strlcpy(ltype, "L2", sizeof(ltype));
17073 case RTE_PTYPE_L3_MASK:
17074 strlcpy(ltype, "L3", sizeof(ltype));
17076 case RTE_PTYPE_L4_MASK:
17077 strlcpy(ltype, "L4", sizeof(ltype));
17079 case RTE_PTYPE_TUNNEL_MASK:
17080 strlcpy(ltype, "Tunnel", sizeof(ltype));
17082 case RTE_PTYPE_INNER_L2_MASK:
17083 strlcpy(ltype, "Inner L2", sizeof(ltype));
17085 case RTE_PTYPE_INNER_L3_MASK:
17086 strlcpy(ltype, "Inner L3", sizeof(ltype));
17088 case RTE_PTYPE_INNER_L4_MASK:
17089 strlcpy(ltype, "Inner L4", sizeof(ltype));
17095 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
17096 ptype_mask, ptypes,
17097 MAX_PTYPES_PER_LAYER);
17100 printf("Supported %s ptypes:\n", ltype);
17102 printf("%s ptypes unsupported\n", ltype);
17104 for (i = 0; i < ret; ++i) {
17105 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
17106 printf("%s\n", buf);
17113 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
17114 .f = cmd_show_port_supported_ptypes_parsed,
17116 .help_str = "show port <port_id> ptypes",
17118 (void *)&cmd_show_port_supported_ptypes_show,
17119 (void *)&cmd_show_port_supported_ptypes_port,
17120 (void *)&cmd_show_port_supported_ptypes_port_id,
17121 (void *)&cmd_show_port_supported_ptypes_ptypes,
17126 /* *** display rx/tx descriptor status *** */
17127 struct cmd_show_rx_tx_desc_status_result {
17128 cmdline_fixed_string_t cmd_show;
17129 cmdline_fixed_string_t cmd_port;
17130 cmdline_fixed_string_t cmd_keyword;
17131 cmdline_fixed_string_t cmd_desc;
17132 cmdline_fixed_string_t cmd_status;
17139 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
17140 __rte_unused struct cmdline *cl,
17141 __rte_unused void *data)
17143 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
17146 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17147 printf("invalid port id %u\n", res->cmd_pid);
17151 if (!strcmp(res->cmd_keyword, "rxq")) {
17152 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
17155 printf("Invalid queueid = %d\n", res->cmd_qid);
17158 if (rc == RTE_ETH_RX_DESC_AVAIL)
17159 printf("Desc status = AVAILABLE\n");
17160 else if (rc == RTE_ETH_RX_DESC_DONE)
17161 printf("Desc status = DONE\n");
17163 printf("Desc status = UNAVAILABLE\n");
17164 } else if (!strcmp(res->cmd_keyword, "txq")) {
17165 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17168 printf("Invalid queueid = %d\n", res->cmd_qid);
17171 if (rc == RTE_ETH_TX_DESC_FULL)
17172 printf("Desc status = FULL\n");
17173 else if (rc == RTE_ETH_TX_DESC_DONE)
17174 printf("Desc status = DONE\n");
17176 printf("Desc status = UNAVAILABLE\n");
17180 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17181 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17183 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17184 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17186 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17187 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17189 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17190 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17191 cmd_keyword, "rxq#txq");
17192 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17193 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17195 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17196 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17198 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17199 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17201 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17202 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17203 cmd_status, "status");
17204 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17205 .f = cmd_show_rx_tx_desc_status_parsed,
17207 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17210 (void *)&cmd_show_rx_tx_desc_status_show,
17211 (void *)&cmd_show_rx_tx_desc_status_port,
17212 (void *)&cmd_show_rx_tx_desc_status_pid,
17213 (void *)&cmd_show_rx_tx_desc_status_keyword,
17214 (void *)&cmd_show_rx_tx_desc_status_qid,
17215 (void *)&cmd_show_rx_tx_desc_status_desc,
17216 (void *)&cmd_show_rx_tx_desc_status_did,
17217 (void *)&cmd_show_rx_tx_desc_status_status,
17222 /* Common result structure for set port ptypes */
17223 struct cmd_set_port_ptypes_result {
17224 cmdline_fixed_string_t set;
17225 cmdline_fixed_string_t port;
17227 cmdline_fixed_string_t ptype_mask;
17231 /* Common CLI fields for set port ptypes */
17232 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17233 TOKEN_STRING_INITIALIZER
17234 (struct cmd_set_port_ptypes_result,
17236 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17237 TOKEN_STRING_INITIALIZER
17238 (struct cmd_set_port_ptypes_result,
17240 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17241 TOKEN_NUM_INITIALIZER
17242 (struct cmd_set_port_ptypes_result,
17244 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17245 TOKEN_STRING_INITIALIZER
17246 (struct cmd_set_port_ptypes_result,
17247 ptype_mask, "ptype_mask");
17248 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17249 TOKEN_NUM_INITIALIZER
17250 (struct cmd_set_port_ptypes_result,
17254 cmd_set_port_ptypes_parsed(
17255 void *parsed_result,
17256 __rte_unused struct cmdline *cl,
17257 __rte_unused void *data)
17259 struct cmd_set_port_ptypes_result *res = parsed_result;
17260 #define PTYPE_NAMESIZE 256
17261 char ptype_name[PTYPE_NAMESIZE];
17262 uint16_t port_id = res->port_id;
17263 uint32_t ptype_mask = res->mask;
17266 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17269 printf("Port %d doesn't support any ptypes.\n", port_id);
17273 uint32_t ptypes[ret];
17275 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17277 printf("Unable to set requested ptypes for Port %d\n", port_id);
17281 printf("Successfully set following ptypes for Port %d\n", port_id);
17282 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17283 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17284 printf("%s\n", ptype_name);
17287 clear_ptypes = false;
17290 cmdline_parse_inst_t cmd_set_port_ptypes = {
17291 .f = cmd_set_port_ptypes_parsed,
17293 .help_str = "set port <port_id> ptype_mask <mask>",
17295 (void *)&cmd_set_port_ptypes_set,
17296 (void *)&cmd_set_port_ptypes_port,
17297 (void *)&cmd_set_port_ptypes_port_id,
17298 (void *)&cmd_set_port_ptypes_mask_str,
17299 (void *)&cmd_set_port_ptypes_mask_u32,
17304 /* *** display mac addresses added to a port *** */
17305 struct cmd_showport_macs_result {
17306 cmdline_fixed_string_t cmd_show;
17307 cmdline_fixed_string_t cmd_port;
17308 cmdline_fixed_string_t cmd_keyword;
17313 cmd_showport_macs_parsed(void *parsed_result,
17314 __rte_unused struct cmdline *cl,
17315 __rte_unused void *data)
17317 struct cmd_showport_macs_result *res = parsed_result;
17319 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17322 if (!strcmp(res->cmd_keyword, "macs"))
17323 show_macs(res->cmd_pid);
17324 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17325 show_mcast_macs(res->cmd_pid);
17328 cmdline_parse_token_string_t cmd_showport_macs_show =
17329 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17331 cmdline_parse_token_string_t cmd_showport_macs_port =
17332 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17334 cmdline_parse_token_num_t cmd_showport_macs_pid =
17335 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17337 cmdline_parse_token_string_t cmd_showport_macs_keyword =
17338 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17339 cmd_keyword, "macs#mcast_macs");
17341 cmdline_parse_inst_t cmd_showport_macs = {
17342 .f = cmd_showport_macs_parsed,
17344 .help_str = "show port <port_id> macs|mcast_macs",
17346 (void *)&cmd_showport_macs_show,
17347 (void *)&cmd_showport_macs_port,
17348 (void *)&cmd_showport_macs_pid,
17349 (void *)&cmd_showport_macs_keyword,
17354 /* ******************************************************************************** */
17356 /* list of instructions */
17357 cmdline_parse_ctx_t main_ctx[] = {
17358 (cmdline_parse_inst_t *)&cmd_help_brief,
17359 (cmdline_parse_inst_t *)&cmd_help_long,
17360 (cmdline_parse_inst_t *)&cmd_quit,
17361 (cmdline_parse_inst_t *)&cmd_load_from_file,
17362 (cmdline_parse_inst_t *)&cmd_showport,
17363 (cmdline_parse_inst_t *)&cmd_showqueue,
17364 (cmdline_parse_inst_t *)&cmd_showeeprom,
17365 (cmdline_parse_inst_t *)&cmd_showportall,
17366 (cmdline_parse_inst_t *)&cmd_showdevice,
17367 (cmdline_parse_inst_t *)&cmd_showcfg,
17368 (cmdline_parse_inst_t *)&cmd_showfwdall,
17369 (cmdline_parse_inst_t *)&cmd_start,
17370 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17371 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17372 (cmdline_parse_inst_t *)&cmd_set_link_up,
17373 (cmdline_parse_inst_t *)&cmd_set_link_down,
17374 (cmdline_parse_inst_t *)&cmd_reset,
17375 (cmdline_parse_inst_t *)&cmd_set_numbers,
17376 (cmdline_parse_inst_t *)&cmd_set_log,
17377 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
17378 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
17379 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17380 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17381 (cmdline_parse_inst_t *)&cmd_set_txtimes,
17382 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17383 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17384 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17385 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17386 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17387 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17388 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17389 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17390 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17391 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17392 (cmdline_parse_inst_t *)&cmd_set_link_check,
17393 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17394 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17395 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17396 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17397 #ifdef RTE_NET_BOND
17398 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17399 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17400 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17401 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17402 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17403 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17404 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17405 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17406 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17407 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17408 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17410 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17411 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17412 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17413 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17414 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17415 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17416 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17417 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17418 (cmdline_parse_inst_t *)&cmd_csum_set,
17419 (cmdline_parse_inst_t *)&cmd_csum_show,
17420 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17421 (cmdline_parse_inst_t *)&cmd_tso_set,
17422 (cmdline_parse_inst_t *)&cmd_tso_show,
17423 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17424 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17425 (cmdline_parse_inst_t *)&cmd_gro_enable,
17426 (cmdline_parse_inst_t *)&cmd_gro_flush,
17427 (cmdline_parse_inst_t *)&cmd_gro_show,
17428 (cmdline_parse_inst_t *)&cmd_gso_enable,
17429 (cmdline_parse_inst_t *)&cmd_gso_size,
17430 (cmdline_parse_inst_t *)&cmd_gso_show,
17431 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17432 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17433 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17434 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17435 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17436 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17437 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17438 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17439 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17440 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17441 (cmdline_parse_inst_t *)&cmd_config_dcb,
17442 (cmdline_parse_inst_t *)&cmd_read_reg,
17443 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17444 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17445 (cmdline_parse_inst_t *)&cmd_write_reg,
17446 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17447 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17448 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17449 (cmdline_parse_inst_t *)&cmd_stop,
17450 (cmdline_parse_inst_t *)&cmd_mac_addr,
17451 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17452 (cmdline_parse_inst_t *)&cmd_set_qmap,
17453 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17454 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17455 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17456 (cmdline_parse_inst_t *)&cmd_operate_port,
17457 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17458 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17459 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17460 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
17461 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17462 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17463 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17464 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17465 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17466 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17467 (cmdline_parse_inst_t *)&cmd_config_mtu,
17468 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17469 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17470 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17471 (cmdline_parse_inst_t *)&cmd_config_rss,
17472 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17473 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17474 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17475 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17476 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17477 (cmdline_parse_inst_t *)&cmd_showport_reta,
17478 (cmdline_parse_inst_t *)&cmd_showport_macs,
17479 (cmdline_parse_inst_t *)&cmd_config_burst,
17480 (cmdline_parse_inst_t *)&cmd_config_thresh,
17481 (cmdline_parse_inst_t *)&cmd_config_threshold,
17482 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17483 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17484 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17485 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17486 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17487 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
17488 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
17489 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
17490 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17491 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17492 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17493 (cmdline_parse_inst_t *)&cmd_dump,
17494 (cmdline_parse_inst_t *)&cmd_dump_one,
17495 #ifdef RTE_NET_I40E
17496 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17498 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17499 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17500 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17501 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17502 (cmdline_parse_inst_t *)&cmd_flow,
17503 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17504 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17505 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17506 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17507 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17508 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17509 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17510 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17511 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17512 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17513 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
17514 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17515 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17516 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17517 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
17518 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
17519 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
17520 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
17521 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
17522 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
17523 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
17524 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
17525 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17526 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17527 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17528 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17529 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17530 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17531 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17532 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17533 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17534 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17535 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17536 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17537 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17538 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17539 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17540 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17541 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17542 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17543 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17544 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17545 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17546 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17547 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17548 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
17549 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
17550 (cmdline_parse_inst_t *)&cmd_set_vxlan,
17551 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
17552 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17553 (cmdline_parse_inst_t *)&cmd_set_nvgre,
17554 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17555 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
17556 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
17557 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
17558 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
17559 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
17560 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
17561 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
17562 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
17563 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
17564 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
17565 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
17566 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
17567 (cmdline_parse_inst_t *)&cmd_ddp_add,
17568 (cmdline_parse_inst_t *)&cmd_ddp_del,
17569 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
17570 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
17571 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
17572 (cmdline_parse_inst_t *)&cmd_clear_input_set,
17573 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
17574 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17575 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
17576 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
17577 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17578 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17579 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17580 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17582 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17583 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17584 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17585 (cmdline_parse_inst_t *)&cmd_queue_region,
17586 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17587 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17588 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17589 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17590 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17591 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17592 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17593 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17594 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17595 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17596 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17597 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17598 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17599 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17600 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17601 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17602 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17603 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
17604 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17605 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17606 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17607 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17608 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17609 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17610 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
17611 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
17612 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
17613 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17614 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17615 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17616 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17617 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17618 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17619 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17620 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17621 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17623 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17624 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17626 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
17627 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
17628 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
17629 (cmdline_parse_inst_t *)&cmd_set_raw,
17630 (cmdline_parse_inst_t *)&cmd_show_set_raw,
17631 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
17632 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
17633 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
17634 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
17635 (cmdline_parse_inst_t *)&cmd_show_capability,
17639 /* read cmdline commands from file */
17641 cmdline_read_from_file(const char *filename)
17643 struct cmdline *cl;
17645 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17647 printf("Failed to create file based cmdline context: %s\n",
17652 cmdline_interact(cl);
17657 printf("Read CLI commands from %s\n", filename);
17660 /* prompt function, called from main on MAIN lcore */
17664 /* initialize non-constant commands */
17665 cmd_set_fwd_mode_init();
17666 cmd_set_fwd_retry_mode_init();
17668 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17669 if (testpmd_cl == NULL)
17671 cmdline_interact(testpmd_cl);
17672 cmdline_stdin_exit(testpmd_cl);
17678 if (testpmd_cl != NULL)
17679 cmdline_quit(testpmd_cl);
17683 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17685 if (id == (portid_t)RTE_PORT_ALL) {
17688 RTE_ETH_FOREACH_DEV(pid) {
17689 /* check if need_reconfig has been set to 1 */
17690 if (ports[pid].need_reconfig == 0)
17691 ports[pid].need_reconfig = dev;
17692 /* check if need_reconfig_queues has been set to 1 */
17693 if (ports[pid].need_reconfig_queues == 0)
17694 ports[pid].need_reconfig_queues = queue;
17696 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17697 /* check if need_reconfig has been set to 1 */
17698 if (ports[id].need_reconfig == 0)
17699 ports[id].need_reconfig = dev;
17700 /* check if need_reconfig_queues has been set to 1 */
17701 if (ports[id].need_reconfig_queues == 0)
17702 ports[id].need_reconfig_queues = queue;