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"
847 " (enable|disable)\n"
848 " Enable/disable the E-tag support.\n\n"
850 "port config (port_id) pctype mapping reset\n"
851 " Reset flow type to pctype mapping on a port\n\n"
853 "port config (port_id) pctype mapping update"
854 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
855 " Update a flow type to pctype mapping item on a port\n\n"
857 "port config (port_id) pctype (pctype_id) hash_inset|"
858 "fdir_inset|fdir_flx_inset get|set|clear field\n"
860 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
862 "port config (port_id) pctype (pctype_id) hash_inset|"
863 "fdir_inset|fdir_flx_inset clear all"
864 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
866 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
867 " Add/remove UDP tunnel port for tunneling offload\n\n"
869 "port config <port_id> rx_offload vlan_strip|"
870 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
871 "outer_ipv4_cksum|macsec_strip|header_split|"
872 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
873 "buffer_split|timestamp|security|keep_crc on|off\n"
874 " Enable or disable a per port Rx offloading"
875 " on all Rx queues of a port\n\n"
877 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
878 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
879 "outer_ipv4_cksum|macsec_strip|header_split|"
880 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
881 "buffer_split|timestamp|security|keep_crc on|off\n"
882 " Enable or disable a per queue Rx offloading"
883 " only on a specific Rx queue\n\n"
885 "port config (port_id) tx_offload vlan_insert|"
886 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
887 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
888 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
889 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
891 " Enable or disable a per port Tx offloading"
892 " on all Tx queues of a port\n\n"
894 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
895 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
896 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
897 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
898 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
900 " Enable or disable a per queue Tx offloading"
901 " only on a specific Tx queue\n\n"
903 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
904 " Load an eBPF program as a callback"
905 " for particular RX/TX queue\n\n"
907 "bpf-unload rx|tx (port) (queue)\n"
908 " Unload previously loaded eBPF program"
909 " for particular RX/TX queue\n\n"
911 "port config (port_id) tx_metadata (value)\n"
912 " Set Tx metadata value per port. Testpmd will add this value"
913 " to any Tx packet sent from this port\n\n"
915 "port config (port_id) dynf (name) set|clear\n"
916 " Register a dynf and Set/clear this flag on Tx. "
917 "Testpmd will set this value to any Tx packet "
918 "sent from this port\n\n"
922 if (show_all || !strcmp(res->section, "registers")) {
930 "read reg (port_id) (address)\n"
931 " Display value of a port register.\n\n"
933 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
934 " Display a port register bit field.\n\n"
936 "read regbit (port_id) (address) (bit_x)\n"
937 " Display a single port register bit.\n\n"
939 "write reg (port_id) (address) (value)\n"
940 " Set value of a port register.\n\n"
942 "write regfield (port_id) (address) (bit_x) (bit_y)"
944 " Set bit field of a port register.\n\n"
946 "write regbit (port_id) (address) (bit_x) (value)\n"
947 " Set single bit value of a port register.\n\n"
950 if (show_all || !strcmp(res->section, "filters")) {
959 "flow_director_filter (port_id) mode raw (add|del|update)"
960 " flow (flow_id) (drop|fwd) queue (queue_id)"
961 " fd_id (fd_id_value) packet (packet file name)\n"
962 " Add/Del a raw type flow director filter.\n\n"
965 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
966 " src_mask (ipv4_src) (ipv6_src) (src_port)"
967 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
968 " Set flow director IP mask.\n\n"
970 "flow_director_mask (port_id) mode MAC-VLAN"
971 " vlan (vlan_value)\n"
972 " Set flow director MAC-VLAN mask.\n\n"
974 "flow_director_mask (port_id) mode Tunnel"
975 " vlan (vlan_value) mac (mac_value)"
976 " tunnel-type (tunnel_type_value)"
977 " tunnel-id (tunnel_id_value)\n"
978 " Set flow director Tunnel mask.\n\n"
980 "flow_director_flex_payload (port_id)"
981 " (raw|l2|l3|l4) (config)\n"
982 " Configure flex payload selection.\n\n"
984 "flow validate {port_id}"
985 " [group {group_id}] [priority {level}]"
986 " [ingress] [egress]"
987 " pattern {item} [/ {item} [...]] / end"
988 " actions {action} [/ {action} [...]] / end\n"
989 " Check whether a flow rule can be created.\n\n"
991 "flow create {port_id}"
992 " [group {group_id}] [priority {level}]"
993 " [ingress] [egress]"
994 " pattern {item} [/ {item} [...]] / end"
995 " actions {action} [/ {action} [...]] / end\n"
996 " Create a flow rule.\n\n"
998 "flow destroy {port_id} rule {rule_id} [...]\n"
999 " Destroy specific flow rules.\n\n"
1001 "flow flush {port_id}\n"
1002 " Destroy all flow rules.\n\n"
1004 "flow query {port_id} {rule_id} {action}\n"
1005 " Query an existing flow rule.\n\n"
1007 "flow list {port_id} [group {group_id}] [...]\n"
1008 " List existing flow rules sorted by priority,"
1009 " filtered by group identifiers.\n\n"
1011 "flow isolate {port_id} {boolean}\n"
1012 " Restrict ingress traffic to the defined"
1015 "flow aged {port_id} [destroy]\n"
1016 " List and destroy aged flows"
1019 "flow shared_action {port_id} create"
1020 " [action_id {shared_action_id}]"
1021 " [ingress] [egress]"
1022 " action {action} / end\n"
1023 " Create shared action.\n\n"
1025 "flow shared_action {port_id} update"
1026 " {shared_action_id} action {action} / end\n"
1027 " Update shared action.\n\n"
1029 "flow shared_action {port_id} destroy"
1030 " action_id {shared_action_id} [...]\n"
1031 " Destroy specific shared actions.\n\n"
1033 "flow shared_action {port_id} query"
1034 " {shared_action_id}\n"
1035 " Query an existing shared action.\n\n"
1037 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1038 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1039 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1040 " Configure the VXLAN encapsulation for flows.\n\n"
1042 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1043 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1044 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1045 " eth-dst (eth-dst)\n"
1046 " Configure the VXLAN encapsulation for flows.\n\n"
1048 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1049 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1050 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1051 " eth-dst (eth-dst)\n"
1052 " Configure the VXLAN encapsulation for flows.\n\n"
1054 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1055 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1057 " Configure the NVGRE encapsulation for flows.\n\n"
1059 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1060 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1061 " eth-src (eth-src) eth-dst (eth-dst)\n"
1062 " Configure the NVGRE encapsulation for flows.\n\n"
1064 "set raw_encap {flow items}\n"
1065 " Configure the encapsulation with raw data.\n\n"
1067 "set raw_decap {flow items}\n"
1068 " Configure the decapsulation with raw data.\n\n"
1073 if (show_all || !strcmp(res->section, "traffic_management")) {
1077 "Traffic Management:\n"
1079 "show port tm cap (port_id)\n"
1080 " Display the port TM capability.\n\n"
1082 "show port tm level cap (port_id) (level_id)\n"
1083 " Display the port TM hierarchical level capability.\n\n"
1085 "show port tm node cap (port_id) (node_id)\n"
1086 " Display the port TM node capability.\n\n"
1088 "show port tm node type (port_id) (node_id)\n"
1089 " Display the port TM node type.\n\n"
1091 "show port tm node stats (port_id) (node_id) (clear)\n"
1092 " Display the port TM node stats.\n\n"
1094 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1095 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1096 " (packet_length_adjust) (packet_mode)\n"
1097 " Add port tm node private shaper profile.\n\n"
1099 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1100 " Delete port tm node private shaper profile.\n\n"
1102 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1103 " (shaper_profile_id)\n"
1104 " Add/update port tm node shared shaper.\n\n"
1106 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1107 " Delete port tm node shared shaper.\n\n"
1109 "set port tm node shaper profile (port_id) (node_id)"
1110 " (shaper_profile_id)\n"
1111 " Set port tm node shaper profile.\n\n"
1113 "add port tm node wred profile (port_id) (wred_profile_id)"
1114 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1115 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1116 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1117 " Add port tm node wred profile.\n\n"
1119 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1120 " Delete port tm node wred profile.\n\n"
1122 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1123 " (priority) (weight) (level_id) (shaper_profile_id)"
1124 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1125 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1126 " Add port tm nonleaf node.\n\n"
1128 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1129 " (priority) (weight) (level_id) (shaper_profile_id)"
1130 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1131 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1132 " Add port tm nonleaf node with pkt mode enabled.\n\n"
1134 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1135 " (priority) (weight) (level_id) (shaper_profile_id)"
1136 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1137 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1138 " Add port tm leaf node.\n\n"
1140 "del port tm node (port_id) (node_id)\n"
1141 " Delete port tm node.\n\n"
1143 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1144 " (priority) (weight)\n"
1145 " Set port tm node parent.\n\n"
1147 "suspend port tm node (port_id) (node_id)"
1148 " Suspend tm node.\n\n"
1150 "resume port tm node (port_id) (node_id)"
1151 " Resume tm node.\n\n"
1153 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1154 " Commit tm hierarchy.\n\n"
1156 "set port tm mark ip_ecn (port) (green) (yellow)"
1158 " Enables/Disables the traffic management marking"
1159 " for IP ECN (Explicit Congestion Notification)"
1160 " packets on a given port\n\n"
1162 "set port tm mark ip_dscp (port) (green) (yellow)"
1164 " Enables/Disables the traffic management marking"
1165 " on the port for IP dscp packets\n\n"
1167 "set port tm mark vlan_dei (port) (green) (yellow)"
1169 " Enables/Disables the traffic management marking"
1170 " on the port for VLAN packets with DEI enabled\n\n"
1174 if (show_all || !strcmp(res->section, "devices")) {
1178 "Device Operations:\n"
1180 "device detach (identifier)\n"
1181 " Detach device by identifier.\n\n"
1187 cmdline_parse_token_string_t cmd_help_long_help =
1188 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1190 cmdline_parse_token_string_t cmd_help_long_section =
1191 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1192 "all#control#display#config#"
1193 "ports#registers#filters#traffic_management#devices");
1195 cmdline_parse_inst_t cmd_help_long = {
1196 .f = cmd_help_long_parsed,
1198 .help_str = "help all|control|display|config|ports|register|"
1199 "filters|traffic_management|devices: "
1202 (void *)&cmd_help_long_help,
1203 (void *)&cmd_help_long_section,
1209 /* *** start/stop/close all ports *** */
1210 struct cmd_operate_port_result {
1211 cmdline_fixed_string_t keyword;
1212 cmdline_fixed_string_t name;
1213 cmdline_fixed_string_t value;
1216 static void cmd_operate_port_parsed(void *parsed_result,
1217 __rte_unused struct cmdline *cl,
1218 __rte_unused void *data)
1220 struct cmd_operate_port_result *res = parsed_result;
1222 if (!strcmp(res->name, "start"))
1223 start_port(RTE_PORT_ALL);
1224 else if (!strcmp(res->name, "stop"))
1225 stop_port(RTE_PORT_ALL);
1226 else if (!strcmp(res->name, "close"))
1227 close_port(RTE_PORT_ALL);
1228 else if (!strcmp(res->name, "reset"))
1229 reset_port(RTE_PORT_ALL);
1231 printf("Unknown parameter\n");
1234 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1235 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1237 cmdline_parse_token_string_t cmd_operate_port_all_port =
1238 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1239 "start#stop#close#reset");
1240 cmdline_parse_token_string_t cmd_operate_port_all_all =
1241 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1243 cmdline_parse_inst_t cmd_operate_port = {
1244 .f = cmd_operate_port_parsed,
1246 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1248 (void *)&cmd_operate_port_all_cmd,
1249 (void *)&cmd_operate_port_all_port,
1250 (void *)&cmd_operate_port_all_all,
1255 /* *** start/stop/close specific port *** */
1256 struct cmd_operate_specific_port_result {
1257 cmdline_fixed_string_t keyword;
1258 cmdline_fixed_string_t name;
1262 static void cmd_operate_specific_port_parsed(void *parsed_result,
1263 __rte_unused struct cmdline *cl,
1264 __rte_unused void *data)
1266 struct cmd_operate_specific_port_result *res = parsed_result;
1268 if (!strcmp(res->name, "start"))
1269 start_port(res->value);
1270 else if (!strcmp(res->name, "stop"))
1271 stop_port(res->value);
1272 else if (!strcmp(res->name, "close"))
1273 close_port(res->value);
1274 else if (!strcmp(res->name, "reset"))
1275 reset_port(res->value);
1277 printf("Unknown parameter\n");
1280 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1281 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1283 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1284 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1285 name, "start#stop#close#reset");
1286 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1287 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1290 cmdline_parse_inst_t cmd_operate_specific_port = {
1291 .f = cmd_operate_specific_port_parsed,
1293 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1295 (void *)&cmd_operate_specific_port_cmd,
1296 (void *)&cmd_operate_specific_port_port,
1297 (void *)&cmd_operate_specific_port_id,
1302 /* *** enable port setup (after attach) via iterator or event *** */
1303 struct cmd_set_port_setup_on_result {
1304 cmdline_fixed_string_t set;
1305 cmdline_fixed_string_t port;
1306 cmdline_fixed_string_t setup;
1307 cmdline_fixed_string_t on;
1308 cmdline_fixed_string_t mode;
1311 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1312 __rte_unused struct cmdline *cl,
1313 __rte_unused void *data)
1315 struct cmd_set_port_setup_on_result *res = parsed_result;
1317 if (strcmp(res->mode, "event") == 0)
1318 setup_on_probe_event = true;
1319 else if (strcmp(res->mode, "iterator") == 0)
1320 setup_on_probe_event = false;
1322 printf("Unknown mode\n");
1325 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1326 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1328 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1329 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1331 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1332 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1334 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1335 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1337 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1338 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1339 mode, "iterator#event");
1341 cmdline_parse_inst_t cmd_set_port_setup_on = {
1342 .f = cmd_set_port_setup_on_parsed,
1344 .help_str = "set port setup on iterator|event",
1346 (void *)&cmd_set_port_setup_on_set,
1347 (void *)&cmd_set_port_setup_on_port,
1348 (void *)&cmd_set_port_setup_on_setup,
1349 (void *)&cmd_set_port_setup_on_on,
1350 (void *)&cmd_set_port_setup_on_mode,
1355 /* *** attach a specified port *** */
1356 struct cmd_operate_attach_port_result {
1357 cmdline_fixed_string_t port;
1358 cmdline_fixed_string_t keyword;
1359 cmdline_multi_string_t identifier;
1362 static void cmd_operate_attach_port_parsed(void *parsed_result,
1363 __rte_unused struct cmdline *cl,
1364 __rte_unused void *data)
1366 struct cmd_operate_attach_port_result *res = parsed_result;
1368 if (!strcmp(res->keyword, "attach"))
1369 attach_port(res->identifier);
1371 printf("Unknown parameter\n");
1374 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1375 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1377 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1378 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1380 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1381 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1382 identifier, TOKEN_STRING_MULTI);
1384 cmdline_parse_inst_t cmd_operate_attach_port = {
1385 .f = cmd_operate_attach_port_parsed,
1387 .help_str = "port attach <identifier>: "
1388 "(identifier: pci address or virtual dev name)",
1390 (void *)&cmd_operate_attach_port_port,
1391 (void *)&cmd_operate_attach_port_keyword,
1392 (void *)&cmd_operate_attach_port_identifier,
1397 /* *** detach a specified port *** */
1398 struct cmd_operate_detach_port_result {
1399 cmdline_fixed_string_t port;
1400 cmdline_fixed_string_t keyword;
1404 static void cmd_operate_detach_port_parsed(void *parsed_result,
1405 __rte_unused struct cmdline *cl,
1406 __rte_unused void *data)
1408 struct cmd_operate_detach_port_result *res = parsed_result;
1410 if (!strcmp(res->keyword, "detach")) {
1411 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1412 detach_port_device(res->port_id);
1414 printf("Unknown parameter\n");
1418 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1419 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1421 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1422 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1424 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1425 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1428 cmdline_parse_inst_t cmd_operate_detach_port = {
1429 .f = cmd_operate_detach_port_parsed,
1431 .help_str = "port detach <port_id>",
1433 (void *)&cmd_operate_detach_port_port,
1434 (void *)&cmd_operate_detach_port_keyword,
1435 (void *)&cmd_operate_detach_port_port_id,
1440 /* *** detach device by identifier *** */
1441 struct cmd_operate_detach_device_result {
1442 cmdline_fixed_string_t device;
1443 cmdline_fixed_string_t keyword;
1444 cmdline_fixed_string_t identifier;
1447 static void cmd_operate_detach_device_parsed(void *parsed_result,
1448 __rte_unused struct cmdline *cl,
1449 __rte_unused void *data)
1451 struct cmd_operate_detach_device_result *res = parsed_result;
1453 if (!strcmp(res->keyword, "detach"))
1454 detach_devargs(res->identifier);
1456 printf("Unknown parameter\n");
1459 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1460 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1462 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1463 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1465 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1466 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1469 cmdline_parse_inst_t cmd_operate_detach_device = {
1470 .f = cmd_operate_detach_device_parsed,
1472 .help_str = "device detach <identifier>:"
1473 "(identifier: pci address or virtual dev name)",
1475 (void *)&cmd_operate_detach_device_device,
1476 (void *)&cmd_operate_detach_device_keyword,
1477 (void *)&cmd_operate_detach_device_identifier,
1481 /* *** configure speed for all ports *** */
1482 struct cmd_config_speed_all {
1483 cmdline_fixed_string_t port;
1484 cmdline_fixed_string_t keyword;
1485 cmdline_fixed_string_t all;
1486 cmdline_fixed_string_t item1;
1487 cmdline_fixed_string_t item2;
1488 cmdline_fixed_string_t value1;
1489 cmdline_fixed_string_t value2;
1493 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1498 if (!strcmp(duplexstr, "half")) {
1499 duplex = ETH_LINK_HALF_DUPLEX;
1500 } else if (!strcmp(duplexstr, "full")) {
1501 duplex = ETH_LINK_FULL_DUPLEX;
1502 } else if (!strcmp(duplexstr, "auto")) {
1503 duplex = ETH_LINK_FULL_DUPLEX;
1505 printf("Unknown duplex parameter\n");
1509 if (!strcmp(speedstr, "10")) {
1510 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1511 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1512 } else if (!strcmp(speedstr, "100")) {
1513 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1514 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1516 if (duplex != ETH_LINK_FULL_DUPLEX) {
1517 printf("Invalid speed/duplex parameters\n");
1520 if (!strcmp(speedstr, "1000")) {
1521 *speed = ETH_LINK_SPEED_1G;
1522 } else if (!strcmp(speedstr, "10000")) {
1523 *speed = ETH_LINK_SPEED_10G;
1524 } else if (!strcmp(speedstr, "25000")) {
1525 *speed = ETH_LINK_SPEED_25G;
1526 } else if (!strcmp(speedstr, "40000")) {
1527 *speed = ETH_LINK_SPEED_40G;
1528 } else if (!strcmp(speedstr, "50000")) {
1529 *speed = ETH_LINK_SPEED_50G;
1530 } else if (!strcmp(speedstr, "100000")) {
1531 *speed = ETH_LINK_SPEED_100G;
1532 } else if (!strcmp(speedstr, "200000")) {
1533 *speed = ETH_LINK_SPEED_200G;
1534 } else if (!strcmp(speedstr, "auto")) {
1535 *speed = ETH_LINK_SPEED_AUTONEG;
1537 printf("Unknown speed parameter\n");
1546 cmd_config_speed_all_parsed(void *parsed_result,
1547 __rte_unused struct cmdline *cl,
1548 __rte_unused void *data)
1550 struct cmd_config_speed_all *res = parsed_result;
1551 uint32_t link_speed;
1554 if (!all_ports_stopped()) {
1555 printf("Please stop all ports first\n");
1559 if (parse_and_check_speed_duplex(res->value1, res->value2,
1563 RTE_ETH_FOREACH_DEV(pid) {
1564 ports[pid].dev_conf.link_speeds = link_speed;
1567 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1570 cmdline_parse_token_string_t cmd_config_speed_all_port =
1571 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1572 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1573 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1575 cmdline_parse_token_string_t cmd_config_speed_all_all =
1576 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1577 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1578 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1579 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1580 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1581 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1582 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1583 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1584 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1585 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1588 cmdline_parse_inst_t cmd_config_speed_all = {
1589 .f = cmd_config_speed_all_parsed,
1591 .help_str = "port config all speed "
1592 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1595 (void *)&cmd_config_speed_all_port,
1596 (void *)&cmd_config_speed_all_keyword,
1597 (void *)&cmd_config_speed_all_all,
1598 (void *)&cmd_config_speed_all_item1,
1599 (void *)&cmd_config_speed_all_value1,
1600 (void *)&cmd_config_speed_all_item2,
1601 (void *)&cmd_config_speed_all_value2,
1606 /* *** configure speed for specific port *** */
1607 struct cmd_config_speed_specific {
1608 cmdline_fixed_string_t port;
1609 cmdline_fixed_string_t keyword;
1611 cmdline_fixed_string_t item1;
1612 cmdline_fixed_string_t item2;
1613 cmdline_fixed_string_t value1;
1614 cmdline_fixed_string_t value2;
1618 cmd_config_speed_specific_parsed(void *parsed_result,
1619 __rte_unused struct cmdline *cl,
1620 __rte_unused void *data)
1622 struct cmd_config_speed_specific *res = parsed_result;
1623 uint32_t link_speed;
1625 if (!all_ports_stopped()) {
1626 printf("Please stop all ports first\n");
1630 if (port_id_is_invalid(res->id, ENABLED_WARN))
1633 if (parse_and_check_speed_duplex(res->value1, res->value2,
1637 ports[res->id].dev_conf.link_speeds = link_speed;
1639 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1643 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1644 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1646 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1647 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1649 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1650 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1651 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1652 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1654 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1655 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1656 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1657 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1658 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1660 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1661 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1664 cmdline_parse_inst_t cmd_config_speed_specific = {
1665 .f = cmd_config_speed_specific_parsed,
1667 .help_str = "port config <port_id> speed "
1668 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1671 (void *)&cmd_config_speed_specific_port,
1672 (void *)&cmd_config_speed_specific_keyword,
1673 (void *)&cmd_config_speed_specific_id,
1674 (void *)&cmd_config_speed_specific_item1,
1675 (void *)&cmd_config_speed_specific_value1,
1676 (void *)&cmd_config_speed_specific_item2,
1677 (void *)&cmd_config_speed_specific_value2,
1682 /* *** configure loopback for all ports *** */
1683 struct cmd_config_loopback_all {
1684 cmdline_fixed_string_t port;
1685 cmdline_fixed_string_t keyword;
1686 cmdline_fixed_string_t all;
1687 cmdline_fixed_string_t item;
1692 cmd_config_loopback_all_parsed(void *parsed_result,
1693 __rte_unused struct cmdline *cl,
1694 __rte_unused void *data)
1696 struct cmd_config_loopback_all *res = parsed_result;
1699 if (!all_ports_stopped()) {
1700 printf("Please stop all ports first\n");
1704 RTE_ETH_FOREACH_DEV(pid) {
1705 ports[pid].dev_conf.lpbk_mode = res->mode;
1708 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1711 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1712 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1713 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1714 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1716 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1717 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1718 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1719 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1721 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1722 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1724 cmdline_parse_inst_t cmd_config_loopback_all = {
1725 .f = cmd_config_loopback_all_parsed,
1727 .help_str = "port config all loopback <mode>",
1729 (void *)&cmd_config_loopback_all_port,
1730 (void *)&cmd_config_loopback_all_keyword,
1731 (void *)&cmd_config_loopback_all_all,
1732 (void *)&cmd_config_loopback_all_item,
1733 (void *)&cmd_config_loopback_all_mode,
1738 /* *** configure loopback for specific port *** */
1739 struct cmd_config_loopback_specific {
1740 cmdline_fixed_string_t port;
1741 cmdline_fixed_string_t keyword;
1743 cmdline_fixed_string_t item;
1748 cmd_config_loopback_specific_parsed(void *parsed_result,
1749 __rte_unused struct cmdline *cl,
1750 __rte_unused void *data)
1752 struct cmd_config_loopback_specific *res = parsed_result;
1754 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1757 if (!port_is_stopped(res->port_id)) {
1758 printf("Please stop port %u first\n", res->port_id);
1762 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1764 cmd_reconfig_device_queue(res->port_id, 1, 1);
1768 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1769 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1771 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1772 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1774 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1775 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1777 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1778 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1780 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1781 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1784 cmdline_parse_inst_t cmd_config_loopback_specific = {
1785 .f = cmd_config_loopback_specific_parsed,
1787 .help_str = "port config <port_id> loopback <mode>",
1789 (void *)&cmd_config_loopback_specific_port,
1790 (void *)&cmd_config_loopback_specific_keyword,
1791 (void *)&cmd_config_loopback_specific_id,
1792 (void *)&cmd_config_loopback_specific_item,
1793 (void *)&cmd_config_loopback_specific_mode,
1798 /* *** configure txq/rxq, txd/rxd *** */
1799 struct cmd_config_rx_tx {
1800 cmdline_fixed_string_t port;
1801 cmdline_fixed_string_t keyword;
1802 cmdline_fixed_string_t all;
1803 cmdline_fixed_string_t name;
1808 cmd_config_rx_tx_parsed(void *parsed_result,
1809 __rte_unused struct cmdline *cl,
1810 __rte_unused void *data)
1812 struct cmd_config_rx_tx *res = parsed_result;
1814 if (!all_ports_stopped()) {
1815 printf("Please stop all ports first\n");
1818 if (!strcmp(res->name, "rxq")) {
1819 if (!res->value && !nb_txq) {
1820 printf("Warning: Either rx or tx queues should be non zero\n");
1823 if (check_nb_rxq(res->value) != 0)
1825 nb_rxq = res->value;
1827 else if (!strcmp(res->name, "txq")) {
1828 if (!res->value && !nb_rxq) {
1829 printf("Warning: Either rx or tx queues should be non zero\n");
1832 if (check_nb_txq(res->value) != 0)
1834 nb_txq = res->value;
1836 else if (!strcmp(res->name, "rxd")) {
1837 if (check_nb_rxd(res->value) != 0)
1839 nb_rxd = res->value;
1840 } else if (!strcmp(res->name, "txd")) {
1841 if (check_nb_txd(res->value) != 0)
1844 nb_txd = res->value;
1846 printf("Unknown parameter\n");
1854 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1857 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1858 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1859 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1860 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1861 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1862 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1863 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1864 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1866 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1867 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1869 cmdline_parse_inst_t cmd_config_rx_tx = {
1870 .f = cmd_config_rx_tx_parsed,
1872 .help_str = "port config all rxq|txq|rxd|txd <value>",
1874 (void *)&cmd_config_rx_tx_port,
1875 (void *)&cmd_config_rx_tx_keyword,
1876 (void *)&cmd_config_rx_tx_all,
1877 (void *)&cmd_config_rx_tx_name,
1878 (void *)&cmd_config_rx_tx_value,
1883 /* *** config max packet length *** */
1884 struct cmd_config_max_pkt_len_result {
1885 cmdline_fixed_string_t port;
1886 cmdline_fixed_string_t keyword;
1887 cmdline_fixed_string_t all;
1888 cmdline_fixed_string_t name;
1893 cmd_config_max_pkt_len_parsed(void *parsed_result,
1894 __rte_unused struct cmdline *cl,
1895 __rte_unused void *data)
1897 struct cmd_config_max_pkt_len_result *res = parsed_result;
1900 if (!all_ports_stopped()) {
1901 printf("Please stop all ports first\n");
1905 RTE_ETH_FOREACH_DEV(pid) {
1906 struct rte_port *port = &ports[pid];
1907 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1909 if (!strcmp(res->name, "max-pkt-len")) {
1910 if (res->value < RTE_ETHER_MIN_LEN) {
1911 printf("max-pkt-len can not be less than %d\n",
1915 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1918 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1919 if (res->value > RTE_ETHER_MAX_LEN)
1920 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1922 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1923 port->dev_conf.rxmode.offloads = rx_offloads;
1925 printf("Unknown parameter\n");
1932 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1935 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1936 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1938 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1939 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1941 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1942 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1944 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1945 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1947 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1948 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1951 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1952 .f = cmd_config_max_pkt_len_parsed,
1954 .help_str = "port config all max-pkt-len <value>",
1956 (void *)&cmd_config_max_pkt_len_port,
1957 (void *)&cmd_config_max_pkt_len_keyword,
1958 (void *)&cmd_config_max_pkt_len_all,
1959 (void *)&cmd_config_max_pkt_len_name,
1960 (void *)&cmd_config_max_pkt_len_value,
1965 /* *** config max LRO aggregated packet size *** */
1966 struct cmd_config_max_lro_pkt_size_result {
1967 cmdline_fixed_string_t port;
1968 cmdline_fixed_string_t keyword;
1969 cmdline_fixed_string_t all;
1970 cmdline_fixed_string_t name;
1975 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1976 __rte_unused struct cmdline *cl,
1977 __rte_unused void *data)
1979 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1982 if (!all_ports_stopped()) {
1983 printf("Please stop all ports first\n");
1987 RTE_ETH_FOREACH_DEV(pid) {
1988 struct rte_port *port = &ports[pid];
1990 if (!strcmp(res->name, "max-lro-pkt-size")) {
1992 port->dev_conf.rxmode.max_lro_pkt_size)
1995 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
1997 printf("Unknown parameter\n");
2004 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2007 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2008 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2010 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2011 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2013 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2014 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2016 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2017 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2018 name, "max-lro-pkt-size");
2019 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2020 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2023 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2024 .f = cmd_config_max_lro_pkt_size_parsed,
2026 .help_str = "port config all max-lro-pkt-size <value>",
2028 (void *)&cmd_config_max_lro_pkt_size_port,
2029 (void *)&cmd_config_max_lro_pkt_size_keyword,
2030 (void *)&cmd_config_max_lro_pkt_size_all,
2031 (void *)&cmd_config_max_lro_pkt_size_name,
2032 (void *)&cmd_config_max_lro_pkt_size_value,
2037 /* *** configure port MTU *** */
2038 struct cmd_config_mtu_result {
2039 cmdline_fixed_string_t port;
2040 cmdline_fixed_string_t keyword;
2041 cmdline_fixed_string_t mtu;
2047 cmd_config_mtu_parsed(void *parsed_result,
2048 __rte_unused struct cmdline *cl,
2049 __rte_unused void *data)
2051 struct cmd_config_mtu_result *res = parsed_result;
2053 if (res->value < RTE_ETHER_MIN_LEN) {
2054 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2057 port_mtu_set(res->port_id, res->value);
2060 cmdline_parse_token_string_t cmd_config_mtu_port =
2061 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2063 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2064 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2066 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2067 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2069 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2070 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
2071 cmdline_parse_token_num_t cmd_config_mtu_value =
2072 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
2074 cmdline_parse_inst_t cmd_config_mtu = {
2075 .f = cmd_config_mtu_parsed,
2077 .help_str = "port config mtu <port_id> <value>",
2079 (void *)&cmd_config_mtu_port,
2080 (void *)&cmd_config_mtu_keyword,
2081 (void *)&cmd_config_mtu_mtu,
2082 (void *)&cmd_config_mtu_port_id,
2083 (void *)&cmd_config_mtu_value,
2088 /* *** configure rx mode *** */
2089 struct cmd_config_rx_mode_flag {
2090 cmdline_fixed_string_t port;
2091 cmdline_fixed_string_t keyword;
2092 cmdline_fixed_string_t all;
2093 cmdline_fixed_string_t name;
2094 cmdline_fixed_string_t value;
2098 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2099 __rte_unused struct cmdline *cl,
2100 __rte_unused void *data)
2102 struct cmd_config_rx_mode_flag *res = parsed_result;
2104 if (!all_ports_stopped()) {
2105 printf("Please stop all ports first\n");
2109 if (!strcmp(res->name, "drop-en")) {
2110 if (!strcmp(res->value, "on"))
2112 else if (!strcmp(res->value, "off"))
2115 printf("Unknown parameter\n");
2119 printf("Unknown parameter\n");
2125 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2128 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2129 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2130 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2131 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2133 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2134 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2135 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2136 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2138 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2139 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2142 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2143 .f = cmd_config_rx_mode_flag_parsed,
2145 .help_str = "port config all drop-en on|off",
2147 (void *)&cmd_config_rx_mode_flag_port,
2148 (void *)&cmd_config_rx_mode_flag_keyword,
2149 (void *)&cmd_config_rx_mode_flag_all,
2150 (void *)&cmd_config_rx_mode_flag_name,
2151 (void *)&cmd_config_rx_mode_flag_value,
2156 /* *** configure rss *** */
2157 struct cmd_config_rss {
2158 cmdline_fixed_string_t port;
2159 cmdline_fixed_string_t keyword;
2160 cmdline_fixed_string_t all;
2161 cmdline_fixed_string_t name;
2162 cmdline_fixed_string_t value;
2166 cmd_config_rss_parsed(void *parsed_result,
2167 __rte_unused struct cmdline *cl,
2168 __rte_unused void *data)
2170 struct cmd_config_rss *res = parsed_result;
2171 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2172 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2173 int use_default = 0;
2174 int all_updated = 1;
2179 if (!strcmp(res->value, "all"))
2180 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2181 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2182 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2183 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU;
2184 else if (!strcmp(res->value, "eth"))
2185 rss_conf.rss_hf = ETH_RSS_ETH;
2186 else if (!strcmp(res->value, "vlan"))
2187 rss_conf.rss_hf = ETH_RSS_VLAN;
2188 else if (!strcmp(res->value, "ip"))
2189 rss_conf.rss_hf = ETH_RSS_IP;
2190 else if (!strcmp(res->value, "udp"))
2191 rss_conf.rss_hf = ETH_RSS_UDP;
2192 else if (!strcmp(res->value, "tcp"))
2193 rss_conf.rss_hf = ETH_RSS_TCP;
2194 else if (!strcmp(res->value, "sctp"))
2195 rss_conf.rss_hf = ETH_RSS_SCTP;
2196 else if (!strcmp(res->value, "ether"))
2197 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2198 else if (!strcmp(res->value, "port"))
2199 rss_conf.rss_hf = ETH_RSS_PORT;
2200 else if (!strcmp(res->value, "vxlan"))
2201 rss_conf.rss_hf = ETH_RSS_VXLAN;
2202 else if (!strcmp(res->value, "geneve"))
2203 rss_conf.rss_hf = ETH_RSS_GENEVE;
2204 else if (!strcmp(res->value, "nvgre"))
2205 rss_conf.rss_hf = ETH_RSS_NVGRE;
2206 else if (!strcmp(res->value, "l3-pre32"))
2207 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2208 else if (!strcmp(res->value, "l3-pre40"))
2209 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2210 else if (!strcmp(res->value, "l3-pre48"))
2211 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2212 else if (!strcmp(res->value, "l3-pre56"))
2213 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2214 else if (!strcmp(res->value, "l3-pre64"))
2215 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2216 else if (!strcmp(res->value, "l3-pre96"))
2217 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2218 else if (!strcmp(res->value, "l3-src-only"))
2219 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2220 else if (!strcmp(res->value, "l3-dst-only"))
2221 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2222 else if (!strcmp(res->value, "l4-src-only"))
2223 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2224 else if (!strcmp(res->value, "l4-dst-only"))
2225 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2226 else if (!strcmp(res->value, "l2-src-only"))
2227 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2228 else if (!strcmp(res->value, "l2-dst-only"))
2229 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2230 else if (!strcmp(res->value, "l2tpv3"))
2231 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2232 else if (!strcmp(res->value, "esp"))
2233 rss_conf.rss_hf = ETH_RSS_ESP;
2234 else if (!strcmp(res->value, "ah"))
2235 rss_conf.rss_hf = ETH_RSS_AH;
2236 else if (!strcmp(res->value, "pfcp"))
2237 rss_conf.rss_hf = ETH_RSS_PFCP;
2238 else if (!strcmp(res->value, "pppoe"))
2239 rss_conf.rss_hf = ETH_RSS_PPPOE;
2240 else if (!strcmp(res->value, "gtpu"))
2241 rss_conf.rss_hf = ETH_RSS_GTPU;
2242 else if (!strcmp(res->value, "none"))
2243 rss_conf.rss_hf = 0;
2244 else if (!strcmp(res->value, "level-default")) {
2245 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2246 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2247 } else if (!strcmp(res->value, "level-outer")) {
2248 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2249 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2250 } else if (!strcmp(res->value, "level-inner")) {
2251 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2252 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2253 } else if (!strcmp(res->value, "default"))
2255 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2256 atoi(res->value) < 64)
2257 rss_conf.rss_hf = 1ULL << atoi(res->value);
2259 printf("Unknown parameter\n");
2262 rss_conf.rss_key = NULL;
2263 /* Update global configuration for RSS types. */
2264 RTE_ETH_FOREACH_DEV(i) {
2265 struct rte_eth_rss_conf local_rss_conf;
2267 ret = eth_dev_info_get_print_err(i, &dev_info);
2272 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2274 local_rss_conf = rss_conf;
2275 local_rss_conf.rss_hf = rss_conf.rss_hf &
2276 dev_info.flow_type_rss_offloads;
2277 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2278 printf("Port %u modified RSS hash function based on hardware support,"
2279 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2280 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2282 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2285 printf("Configuration of RSS hash at ethernet port %d "
2286 "failed with error (%d): %s.\n",
2287 i, -diag, strerror(-diag));
2290 if (all_updated && !use_default) {
2291 rss_hf = rss_conf.rss_hf;
2292 printf("rss_hf %#"PRIx64"\n", rss_hf);
2296 cmdline_parse_token_string_t cmd_config_rss_port =
2297 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2298 cmdline_parse_token_string_t cmd_config_rss_keyword =
2299 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2300 cmdline_parse_token_string_t cmd_config_rss_all =
2301 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2302 cmdline_parse_token_string_t cmd_config_rss_name =
2303 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2304 cmdline_parse_token_string_t cmd_config_rss_value =
2305 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2307 cmdline_parse_inst_t cmd_config_rss = {
2308 .f = cmd_config_rss_parsed,
2310 .help_str = "port config all rss "
2311 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2312 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|none|level-default|"
2313 "level-outer|level-inner|<flowtype_id>",
2315 (void *)&cmd_config_rss_port,
2316 (void *)&cmd_config_rss_keyword,
2317 (void *)&cmd_config_rss_all,
2318 (void *)&cmd_config_rss_name,
2319 (void *)&cmd_config_rss_value,
2324 /* *** configure rss hash key *** */
2325 struct cmd_config_rss_hash_key {
2326 cmdline_fixed_string_t port;
2327 cmdline_fixed_string_t config;
2329 cmdline_fixed_string_t rss_hash_key;
2330 cmdline_fixed_string_t rss_type;
2331 cmdline_fixed_string_t key;
2335 hexa_digit_to_value(char hexa_digit)
2337 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2338 return (uint8_t) (hexa_digit - '0');
2339 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2340 return (uint8_t) ((hexa_digit - 'a') + 10);
2341 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2342 return (uint8_t) ((hexa_digit - 'A') + 10);
2343 /* Invalid hexa digit */
2348 parse_and_check_key_hexa_digit(char *key, int idx)
2352 hexa_v = hexa_digit_to_value(key[idx]);
2354 printf("invalid key: character %c at position %d is not a "
2355 "valid hexa digit\n", key[idx], idx);
2360 cmd_config_rss_hash_key_parsed(void *parsed_result,
2361 __rte_unused struct cmdline *cl,
2362 __rte_unused void *data)
2364 struct cmd_config_rss_hash_key *res = parsed_result;
2365 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2369 struct rte_eth_dev_info dev_info;
2370 uint8_t hash_key_size;
2374 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2378 if (dev_info.hash_key_size > 0 &&
2379 dev_info.hash_key_size <= sizeof(hash_key))
2380 hash_key_size = dev_info.hash_key_size;
2382 printf("dev_info did not provide a valid hash key size\n");
2385 /* Check the length of the RSS hash key */
2386 key_len = strlen(res->key);
2387 if (key_len != (hash_key_size * 2)) {
2388 printf("key length: %d invalid - key must be a string of %d"
2389 " hexa-decimal numbers\n",
2390 (int) key_len, hash_key_size * 2);
2393 /* Translate RSS hash key into binary representation */
2394 for (i = 0; i < hash_key_size; i++) {
2395 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2398 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2401 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2403 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2407 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2408 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2409 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2410 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2412 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2413 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2414 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2415 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2416 rss_hash_key, "rss-hash-key");
2417 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2418 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2419 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2420 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2421 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2422 "ipv6-tcp-ex#ipv6-udp-ex#"
2423 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2424 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2425 "l2tpv3#esp#ah#pfcp#pppoe#gtpu");
2426 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2427 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2429 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2430 .f = cmd_config_rss_hash_key_parsed,
2432 .help_str = "port config <port_id> rss-hash-key "
2433 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2434 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2435 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2436 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2437 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2438 "l2tpv3|esp|ah|pfcp|pppoe|gtpu "
2439 "<string of hex digits (variable length, NIC dependent)>",
2441 (void *)&cmd_config_rss_hash_key_port,
2442 (void *)&cmd_config_rss_hash_key_config,
2443 (void *)&cmd_config_rss_hash_key_port_id,
2444 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2445 (void *)&cmd_config_rss_hash_key_rss_type,
2446 (void *)&cmd_config_rss_hash_key_value,
2451 /* *** configure port rxq/txq ring size *** */
2452 struct cmd_config_rxtx_ring_size {
2453 cmdline_fixed_string_t port;
2454 cmdline_fixed_string_t config;
2456 cmdline_fixed_string_t rxtxq;
2458 cmdline_fixed_string_t rsize;
2463 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2464 __rte_unused struct cmdline *cl,
2465 __rte_unused void *data)
2467 struct cmd_config_rxtx_ring_size *res = parsed_result;
2468 struct rte_port *port;
2471 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2474 if (res->portid == (portid_t)RTE_PORT_ALL) {
2475 printf("Invalid port id\n");
2479 port = &ports[res->portid];
2481 if (!strcmp(res->rxtxq, "rxq"))
2483 else if (!strcmp(res->rxtxq, "txq"))
2486 printf("Unknown parameter\n");
2490 if (isrx && rx_queue_id_is_invalid(res->qid))
2492 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2495 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2496 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2502 port->nb_rx_desc[res->qid] = res->size;
2504 port->nb_tx_desc[res->qid] = res->size;
2506 cmd_reconfig_device_queue(res->portid, 0, 1);
2509 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2510 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2512 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2513 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2515 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2516 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2518 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2519 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2521 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2522 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2524 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2525 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2526 rsize, "ring_size");
2527 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2528 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2531 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2532 .f = cmd_config_rxtx_ring_size_parsed,
2534 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2536 (void *)&cmd_config_rxtx_ring_size_port,
2537 (void *)&cmd_config_rxtx_ring_size_config,
2538 (void *)&cmd_config_rxtx_ring_size_portid,
2539 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2540 (void *)&cmd_config_rxtx_ring_size_qid,
2541 (void *)&cmd_config_rxtx_ring_size_rsize,
2542 (void *)&cmd_config_rxtx_ring_size_size,
2547 /* *** configure port rxq/txq start/stop *** */
2548 struct cmd_config_rxtx_queue {
2549 cmdline_fixed_string_t port;
2551 cmdline_fixed_string_t rxtxq;
2553 cmdline_fixed_string_t opname;
2557 cmd_config_rxtx_queue_parsed(void *parsed_result,
2558 __rte_unused struct cmdline *cl,
2559 __rte_unused void *data)
2561 struct cmd_config_rxtx_queue *res = parsed_result;
2566 if (test_done == 0) {
2567 printf("Please stop forwarding first\n");
2571 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2574 if (port_is_started(res->portid) != 1) {
2575 printf("Please start port %u first\n", res->portid);
2579 if (!strcmp(res->rxtxq, "rxq"))
2581 else if (!strcmp(res->rxtxq, "txq"))
2584 printf("Unknown parameter\n");
2588 if (isrx && rx_queue_id_is_invalid(res->qid))
2590 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2593 if (!strcmp(res->opname, "start"))
2595 else if (!strcmp(res->opname, "stop"))
2598 printf("Unknown parameter\n");
2602 if (isstart && isrx)
2603 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2604 else if (!isstart && isrx)
2605 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2606 else if (isstart && !isrx)
2607 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2609 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2611 if (ret == -ENOTSUP)
2612 printf("Function not supported in PMD driver\n");
2615 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2616 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2617 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2618 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2619 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2620 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2621 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2622 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2623 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2624 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2627 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2628 .f = cmd_config_rxtx_queue_parsed,
2630 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2632 (void *)&cmd_config_rxtx_queue_port,
2633 (void *)&cmd_config_rxtx_queue_portid,
2634 (void *)&cmd_config_rxtx_queue_rxtxq,
2635 (void *)&cmd_config_rxtx_queue_qid,
2636 (void *)&cmd_config_rxtx_queue_opname,
2641 /* *** configure port rxq/txq deferred start on/off *** */
2642 struct cmd_config_deferred_start_rxtx_queue {
2643 cmdline_fixed_string_t port;
2645 cmdline_fixed_string_t rxtxq;
2647 cmdline_fixed_string_t opname;
2648 cmdline_fixed_string_t state;
2652 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2653 __rte_unused struct cmdline *cl,
2654 __rte_unused void *data)
2656 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2657 struct rte_port *port;
2660 uint8_t needreconfig = 0;
2662 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2665 if (port_is_started(res->port_id) != 0) {
2666 printf("Please stop port %u first\n", res->port_id);
2670 port = &ports[res->port_id];
2672 isrx = !strcmp(res->rxtxq, "rxq");
2674 if (isrx && rx_queue_id_is_invalid(res->qid))
2676 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2679 ison = !strcmp(res->state, "on");
2681 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2682 port->rx_conf[res->qid].rx_deferred_start = ison;
2684 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2685 port->tx_conf[res->qid].tx_deferred_start = ison;
2690 cmd_reconfig_device_queue(res->port_id, 0, 1);
2693 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2694 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2696 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2697 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2699 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2700 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2702 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2703 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2705 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2706 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2707 opname, "deferred_start");
2708 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2709 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2712 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2713 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2715 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2717 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2718 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2719 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2720 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2721 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2722 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2727 /* *** configure port rxq/txq setup *** */
2728 struct cmd_setup_rxtx_queue {
2729 cmdline_fixed_string_t port;
2731 cmdline_fixed_string_t rxtxq;
2733 cmdline_fixed_string_t setup;
2736 /* Common CLI fields for queue setup */
2737 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2738 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2739 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2740 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2741 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2742 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2743 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2744 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2745 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2746 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2749 cmd_setup_rxtx_queue_parsed(
2750 void *parsed_result,
2751 __rte_unused struct cmdline *cl,
2752 __rte_unused void *data)
2754 struct cmd_setup_rxtx_queue *res = parsed_result;
2755 struct rte_port *port;
2756 struct rte_mempool *mp;
2757 unsigned int socket_id;
2761 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2764 if (res->portid == (portid_t)RTE_PORT_ALL) {
2765 printf("Invalid port id\n");
2769 if (!strcmp(res->rxtxq, "rxq"))
2771 else if (!strcmp(res->rxtxq, "txq"))
2774 printf("Unknown parameter\n");
2778 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2779 printf("Invalid rx queue\n");
2781 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2782 printf("Invalid tx queue\n");
2786 port = &ports[res->portid];
2788 socket_id = rxring_numa[res->portid];
2789 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2790 socket_id = port->socket_id;
2792 mp = mbuf_pool_find(socket_id, 0);
2794 printf("Failed to setup RX queue: "
2795 "No mempool allocation"
2796 " on the socket %d\n",
2797 rxring_numa[res->portid]);
2800 ret = rx_queue_setup(res->portid,
2802 port->nb_rx_desc[res->qid],
2804 &port->rx_conf[res->qid],
2807 printf("Failed to setup RX queue\n");
2809 socket_id = txring_numa[res->portid];
2810 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2811 socket_id = port->socket_id;
2813 ret = rte_eth_tx_queue_setup(res->portid,
2815 port->nb_tx_desc[res->qid],
2817 &port->tx_conf[res->qid]);
2819 printf("Failed to setup TX queue\n");
2823 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2824 .f = cmd_setup_rxtx_queue_parsed,
2826 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2828 (void *)&cmd_setup_rxtx_queue_port,
2829 (void *)&cmd_setup_rxtx_queue_portid,
2830 (void *)&cmd_setup_rxtx_queue_rxtxq,
2831 (void *)&cmd_setup_rxtx_queue_qid,
2832 (void *)&cmd_setup_rxtx_queue_setup,
2838 /* *** Configure RSS RETA *** */
2839 struct cmd_config_rss_reta {
2840 cmdline_fixed_string_t port;
2841 cmdline_fixed_string_t keyword;
2843 cmdline_fixed_string_t name;
2844 cmdline_fixed_string_t list_name;
2845 cmdline_fixed_string_t list_of_items;
2849 parse_reta_config(const char *str,
2850 struct rte_eth_rss_reta_entry64 *reta_conf,
2851 uint16_t nb_entries)
2855 uint16_t hash_index, idx, shift;
2858 const char *p, *p0 = str;
2865 unsigned long int_fld[_NUM_FLD];
2866 char *str_fld[_NUM_FLD];
2868 while ((p = strchr(p0,'(')) != NULL) {
2870 if((p0 = strchr(p,')')) == NULL)
2874 if(size >= sizeof(s))
2877 snprintf(s, sizeof(s), "%.*s", size, p);
2878 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2880 for (i = 0; i < _NUM_FLD; i++) {
2882 int_fld[i] = strtoul(str_fld[i], &end, 0);
2883 if (errno != 0 || end == str_fld[i] ||
2888 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2889 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2891 if (hash_index >= nb_entries) {
2892 printf("Invalid RETA hash index=%d\n", hash_index);
2896 idx = hash_index / RTE_RETA_GROUP_SIZE;
2897 shift = hash_index % RTE_RETA_GROUP_SIZE;
2898 reta_conf[idx].mask |= (1ULL << shift);
2899 reta_conf[idx].reta[shift] = nb_queue;
2906 cmd_set_rss_reta_parsed(void *parsed_result,
2907 __rte_unused struct cmdline *cl,
2908 __rte_unused void *data)
2911 struct rte_eth_dev_info dev_info;
2912 struct rte_eth_rss_reta_entry64 reta_conf[8];
2913 struct cmd_config_rss_reta *res = parsed_result;
2915 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2919 if (dev_info.reta_size == 0) {
2920 printf("Redirection table size is 0 which is "
2921 "invalid for RSS\n");
2924 printf("The reta size of port %d is %u\n",
2925 res->port_id, dev_info.reta_size);
2926 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2927 printf("Currently do not support more than %u entries of "
2928 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2932 memset(reta_conf, 0, sizeof(reta_conf));
2933 if (!strcmp(res->list_name, "reta")) {
2934 if (parse_reta_config(res->list_of_items, reta_conf,
2935 dev_info.reta_size)) {
2936 printf("Invalid RSS Redirection Table "
2937 "config entered\n");
2940 ret = rte_eth_dev_rss_reta_update(res->port_id,
2941 reta_conf, dev_info.reta_size);
2943 printf("Bad redirection table parameter, "
2944 "return code = %d \n", ret);
2948 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2949 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2950 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2951 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2952 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2953 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2954 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2955 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2956 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2957 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2958 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2959 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2961 cmdline_parse_inst_t cmd_config_rss_reta = {
2962 .f = cmd_set_rss_reta_parsed,
2964 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2966 (void *)&cmd_config_rss_reta_port,
2967 (void *)&cmd_config_rss_reta_keyword,
2968 (void *)&cmd_config_rss_reta_port_id,
2969 (void *)&cmd_config_rss_reta_name,
2970 (void *)&cmd_config_rss_reta_list_name,
2971 (void *)&cmd_config_rss_reta_list_of_items,
2976 /* *** SHOW PORT RETA INFO *** */
2977 struct cmd_showport_reta {
2978 cmdline_fixed_string_t show;
2979 cmdline_fixed_string_t port;
2981 cmdline_fixed_string_t rss;
2982 cmdline_fixed_string_t reta;
2984 cmdline_fixed_string_t list_of_items;
2988 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2989 uint16_t nb_entries,
2993 const char *p, *p0 = str;
2998 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2999 RTE_RETA_GROUP_SIZE;
3002 p = strchr(p0, '(');
3006 p0 = strchr(p, ')');
3010 if (size >= sizeof(s)) {
3011 printf("The string size exceeds the internal buffer size\n");
3014 snprintf(s, sizeof(s), "%.*s", size, p);
3015 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3016 if (ret <= 0 || ret != num) {
3017 printf("The bits of masks do not match the number of "
3018 "reta entries: %u\n", num);
3021 for (i = 0; i < ret; i++)
3022 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3028 cmd_showport_reta_parsed(void *parsed_result,
3029 __rte_unused struct cmdline *cl,
3030 __rte_unused void *data)
3032 struct cmd_showport_reta *res = parsed_result;
3033 struct rte_eth_rss_reta_entry64 reta_conf[8];
3034 struct rte_eth_dev_info dev_info;
3035 uint16_t max_reta_size;
3038 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3042 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3043 if (res->size == 0 || res->size > max_reta_size) {
3044 printf("Invalid redirection table size: %u (1-%u)\n",
3045 res->size, max_reta_size);
3049 memset(reta_conf, 0, sizeof(reta_conf));
3050 if (showport_parse_reta_config(reta_conf, res->size,
3051 res->list_of_items) < 0) {
3052 printf("Invalid string: %s for reta masks\n",
3053 res->list_of_items);
3056 port_rss_reta_info(res->port_id, reta_conf, res->size);
3059 cmdline_parse_token_string_t cmd_showport_reta_show =
3060 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3061 cmdline_parse_token_string_t cmd_showport_reta_port =
3062 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3063 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3064 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
3065 cmdline_parse_token_string_t cmd_showport_reta_rss =
3066 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3067 cmdline_parse_token_string_t cmd_showport_reta_reta =
3068 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3069 cmdline_parse_token_num_t cmd_showport_reta_size =
3070 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
3071 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3072 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3073 list_of_items, NULL);
3075 cmdline_parse_inst_t cmd_showport_reta = {
3076 .f = cmd_showport_reta_parsed,
3078 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3080 (void *)&cmd_showport_reta_show,
3081 (void *)&cmd_showport_reta_port,
3082 (void *)&cmd_showport_reta_port_id,
3083 (void *)&cmd_showport_reta_rss,
3084 (void *)&cmd_showport_reta_reta,
3085 (void *)&cmd_showport_reta_size,
3086 (void *)&cmd_showport_reta_list_of_items,
3091 /* *** Show RSS hash configuration *** */
3092 struct cmd_showport_rss_hash {
3093 cmdline_fixed_string_t show;
3094 cmdline_fixed_string_t port;
3096 cmdline_fixed_string_t rss_hash;
3097 cmdline_fixed_string_t rss_type;
3098 cmdline_fixed_string_t key; /* optional argument */
3101 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3102 __rte_unused struct cmdline *cl,
3105 struct cmd_showport_rss_hash *res = parsed_result;
3107 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3110 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3111 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3112 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3113 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3114 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3115 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
3116 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3117 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3119 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3120 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3122 cmdline_parse_inst_t cmd_showport_rss_hash = {
3123 .f = cmd_showport_rss_hash_parsed,
3125 .help_str = "show port <port_id> rss-hash",
3127 (void *)&cmd_showport_rss_hash_show,
3128 (void *)&cmd_showport_rss_hash_port,
3129 (void *)&cmd_showport_rss_hash_port_id,
3130 (void *)&cmd_showport_rss_hash_rss_hash,
3135 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3136 .f = cmd_showport_rss_hash_parsed,
3138 .help_str = "show port <port_id> rss-hash key",
3140 (void *)&cmd_showport_rss_hash_show,
3141 (void *)&cmd_showport_rss_hash_port,
3142 (void *)&cmd_showport_rss_hash_port_id,
3143 (void *)&cmd_showport_rss_hash_rss_hash,
3144 (void *)&cmd_showport_rss_hash_rss_key,
3149 /* *** Configure DCB *** */
3150 struct cmd_config_dcb {
3151 cmdline_fixed_string_t port;
3152 cmdline_fixed_string_t config;
3154 cmdline_fixed_string_t dcb;
3155 cmdline_fixed_string_t vt;
3156 cmdline_fixed_string_t vt_en;
3158 cmdline_fixed_string_t pfc;
3159 cmdline_fixed_string_t pfc_en;
3163 cmd_config_dcb_parsed(void *parsed_result,
3164 __rte_unused struct cmdline *cl,
3165 __rte_unused void *data)
3167 struct cmd_config_dcb *res = parsed_result;
3168 portid_t port_id = res->port_id;
3169 struct rte_port *port;
3173 port = &ports[port_id];
3174 /** Check if the port is not started **/
3175 if (port->port_status != RTE_PORT_STOPPED) {
3176 printf("Please stop port %d first\n", port_id);
3180 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3181 printf("The invalid number of traffic class,"
3182 " only 4 or 8 allowed.\n");
3186 if (nb_fwd_lcores < res->num_tcs) {
3187 printf("nb_cores shouldn't be less than number of TCs.\n");
3190 if (!strncmp(res->pfc_en, "on", 2))
3195 /* DCB in VT mode */
3196 if (!strncmp(res->vt_en, "on", 2))
3197 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3198 (enum rte_eth_nb_tcs)res->num_tcs,
3201 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3202 (enum rte_eth_nb_tcs)res->num_tcs,
3207 printf("Cannot initialize network ports.\n");
3211 cmd_reconfig_device_queue(port_id, 1, 1);
3214 cmdline_parse_token_string_t cmd_config_dcb_port =
3215 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3216 cmdline_parse_token_string_t cmd_config_dcb_config =
3217 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3218 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3219 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
3220 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3221 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3222 cmdline_parse_token_string_t cmd_config_dcb_vt =
3223 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3224 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3225 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3226 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3227 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
3228 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3229 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3230 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3231 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3233 cmdline_parse_inst_t cmd_config_dcb = {
3234 .f = cmd_config_dcb_parsed,
3236 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3238 (void *)&cmd_config_dcb_port,
3239 (void *)&cmd_config_dcb_config,
3240 (void *)&cmd_config_dcb_port_id,
3241 (void *)&cmd_config_dcb_dcb,
3242 (void *)&cmd_config_dcb_vt,
3243 (void *)&cmd_config_dcb_vt_en,
3244 (void *)&cmd_config_dcb_num_tcs,
3245 (void *)&cmd_config_dcb_pfc,
3246 (void *)&cmd_config_dcb_pfc_en,
3251 /* *** configure number of packets per burst *** */
3252 struct cmd_config_burst {
3253 cmdline_fixed_string_t port;
3254 cmdline_fixed_string_t keyword;
3255 cmdline_fixed_string_t all;
3256 cmdline_fixed_string_t name;
3261 cmd_config_burst_parsed(void *parsed_result,
3262 __rte_unused struct cmdline *cl,
3263 __rte_unused void *data)
3265 struct cmd_config_burst *res = parsed_result;
3266 struct rte_eth_dev_info dev_info;
3267 uint16_t rec_nb_pkts;
3270 if (!all_ports_stopped()) {
3271 printf("Please stop all ports first\n");
3275 if (!strcmp(res->name, "burst")) {
3276 if (res->value == 0) {
3277 /* If user gives a value of zero, query the PMD for
3278 * its recommended Rx burst size. Testpmd uses a single
3279 * size for all ports, so assume all ports are the same
3280 * NIC model and use the values from Port 0.
3282 ret = eth_dev_info_get_print_err(0, &dev_info);
3286 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3288 if (rec_nb_pkts == 0) {
3289 printf("PMD does not recommend a burst size.\n"
3290 "User provided value must be between"
3291 " 1 and %d\n", MAX_PKT_BURST);
3293 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3294 printf("PMD recommended burst size of %d"
3295 " exceeds maximum value of %d\n",
3296 rec_nb_pkts, MAX_PKT_BURST);
3299 printf("Using PMD-provided burst value of %d\n",
3301 nb_pkt_per_burst = rec_nb_pkts;
3302 } else if (res->value > MAX_PKT_BURST) {
3303 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3306 nb_pkt_per_burst = res->value;
3308 printf("Unknown parameter\n");
3314 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3317 cmdline_parse_token_string_t cmd_config_burst_port =
3318 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3319 cmdline_parse_token_string_t cmd_config_burst_keyword =
3320 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3321 cmdline_parse_token_string_t cmd_config_burst_all =
3322 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3323 cmdline_parse_token_string_t cmd_config_burst_name =
3324 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3325 cmdline_parse_token_num_t cmd_config_burst_value =
3326 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3328 cmdline_parse_inst_t cmd_config_burst = {
3329 .f = cmd_config_burst_parsed,
3331 .help_str = "port config all burst <value>",
3333 (void *)&cmd_config_burst_port,
3334 (void *)&cmd_config_burst_keyword,
3335 (void *)&cmd_config_burst_all,
3336 (void *)&cmd_config_burst_name,
3337 (void *)&cmd_config_burst_value,
3342 /* *** configure rx/tx queues *** */
3343 struct cmd_config_thresh {
3344 cmdline_fixed_string_t port;
3345 cmdline_fixed_string_t keyword;
3346 cmdline_fixed_string_t all;
3347 cmdline_fixed_string_t name;
3352 cmd_config_thresh_parsed(void *parsed_result,
3353 __rte_unused struct cmdline *cl,
3354 __rte_unused void *data)
3356 struct cmd_config_thresh *res = parsed_result;
3358 if (!all_ports_stopped()) {
3359 printf("Please stop all ports first\n");
3363 if (!strcmp(res->name, "txpt"))
3364 tx_pthresh = res->value;
3365 else if(!strcmp(res->name, "txht"))
3366 tx_hthresh = res->value;
3367 else if(!strcmp(res->name, "txwt"))
3368 tx_wthresh = res->value;
3369 else if(!strcmp(res->name, "rxpt"))
3370 rx_pthresh = res->value;
3371 else if(!strcmp(res->name, "rxht"))
3372 rx_hthresh = res->value;
3373 else if(!strcmp(res->name, "rxwt"))
3374 rx_wthresh = res->value;
3376 printf("Unknown parameter\n");
3382 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3385 cmdline_parse_token_string_t cmd_config_thresh_port =
3386 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3387 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3388 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3389 cmdline_parse_token_string_t cmd_config_thresh_all =
3390 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3391 cmdline_parse_token_string_t cmd_config_thresh_name =
3392 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3393 "txpt#txht#txwt#rxpt#rxht#rxwt");
3394 cmdline_parse_token_num_t cmd_config_thresh_value =
3395 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3397 cmdline_parse_inst_t cmd_config_thresh = {
3398 .f = cmd_config_thresh_parsed,
3400 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3402 (void *)&cmd_config_thresh_port,
3403 (void *)&cmd_config_thresh_keyword,
3404 (void *)&cmd_config_thresh_all,
3405 (void *)&cmd_config_thresh_name,
3406 (void *)&cmd_config_thresh_value,
3411 /* *** configure free/rs threshold *** */
3412 struct cmd_config_threshold {
3413 cmdline_fixed_string_t port;
3414 cmdline_fixed_string_t keyword;
3415 cmdline_fixed_string_t all;
3416 cmdline_fixed_string_t name;
3421 cmd_config_threshold_parsed(void *parsed_result,
3422 __rte_unused struct cmdline *cl,
3423 __rte_unused void *data)
3425 struct cmd_config_threshold *res = parsed_result;
3427 if (!all_ports_stopped()) {
3428 printf("Please stop all ports first\n");
3432 if (!strcmp(res->name, "txfreet"))
3433 tx_free_thresh = res->value;
3434 else if (!strcmp(res->name, "txrst"))
3435 tx_rs_thresh = res->value;
3436 else if (!strcmp(res->name, "rxfreet"))
3437 rx_free_thresh = res->value;
3439 printf("Unknown parameter\n");
3445 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3448 cmdline_parse_token_string_t cmd_config_threshold_port =
3449 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3450 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3451 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3453 cmdline_parse_token_string_t cmd_config_threshold_all =
3454 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3455 cmdline_parse_token_string_t cmd_config_threshold_name =
3456 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3457 "txfreet#txrst#rxfreet");
3458 cmdline_parse_token_num_t cmd_config_threshold_value =
3459 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3461 cmdline_parse_inst_t cmd_config_threshold = {
3462 .f = cmd_config_threshold_parsed,
3464 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3466 (void *)&cmd_config_threshold_port,
3467 (void *)&cmd_config_threshold_keyword,
3468 (void *)&cmd_config_threshold_all,
3469 (void *)&cmd_config_threshold_name,
3470 (void *)&cmd_config_threshold_value,
3476 struct cmd_stop_result {
3477 cmdline_fixed_string_t stop;
3480 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3481 __rte_unused struct cmdline *cl,
3482 __rte_unused void *data)
3484 stop_packet_forwarding();
3487 cmdline_parse_token_string_t cmd_stop_stop =
3488 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3490 cmdline_parse_inst_t cmd_stop = {
3491 .f = cmd_stop_parsed,
3493 .help_str = "stop: Stop packet forwarding",
3495 (void *)&cmd_stop_stop,
3500 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3503 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3504 unsigned int *parsed_items, int check_unique_values)
3506 unsigned int nb_item;
3514 * First parse all items in the list and store their value.
3519 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3521 if ((c >= '0') && (c <= '9')) {
3522 value = (unsigned int) (value * 10 + (c - '0'));
3527 printf("character %c is not a decimal digit\n", c);
3531 printf("No valid value before comma\n");
3534 if (nb_item < max_items) {
3535 parsed_items[nb_item] = value;
3541 if (nb_item >= max_items) {
3542 printf("Number of %s = %u > %u (maximum items)\n",
3543 item_name, nb_item + 1, max_items);
3546 parsed_items[nb_item++] = value;
3547 if (! check_unique_values)
3551 * Then, check that all values in the list are differents.
3552 * No optimization here...
3554 for (i = 0; i < nb_item; i++) {
3555 for (j = i + 1; j < nb_item; j++) {
3556 if (parsed_items[j] == parsed_items[i]) {
3557 printf("duplicated %s %u at index %u and %u\n",
3558 item_name, parsed_items[i], i, j);
3566 struct cmd_set_list_result {
3567 cmdline_fixed_string_t cmd_keyword;
3568 cmdline_fixed_string_t list_name;
3569 cmdline_fixed_string_t list_of_items;
3572 static void cmd_set_list_parsed(void *parsed_result,
3573 __rte_unused struct cmdline *cl,
3574 __rte_unused void *data)
3576 struct cmd_set_list_result *res;
3578 unsigned int lcorelist[RTE_MAX_LCORE];
3579 unsigned int portlist[RTE_MAX_ETHPORTS];
3581 unsigned int nb_item;
3583 if (test_done == 0) {
3584 printf("Please stop forwarding first\n");
3588 res = parsed_result;
3589 if (!strcmp(res->list_name, "corelist")) {
3590 nb_item = parse_item_list(res->list_of_items, "core",
3592 parsed_items.lcorelist, 1);
3594 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3599 if (!strcmp(res->list_name, "portlist")) {
3600 nb_item = parse_item_list(res->list_of_items, "port",
3602 parsed_items.portlist, 1);
3604 set_fwd_ports_list(parsed_items.portlist, nb_item);
3610 cmdline_parse_token_string_t cmd_set_list_keyword =
3611 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3613 cmdline_parse_token_string_t cmd_set_list_name =
3614 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3615 "corelist#portlist");
3616 cmdline_parse_token_string_t cmd_set_list_of_items =
3617 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3620 cmdline_parse_inst_t cmd_set_fwd_list = {
3621 .f = cmd_set_list_parsed,
3623 .help_str = "set corelist|portlist <list0[,list1]*>",
3625 (void *)&cmd_set_list_keyword,
3626 (void *)&cmd_set_list_name,
3627 (void *)&cmd_set_list_of_items,
3632 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3634 struct cmd_setmask_result {
3635 cmdline_fixed_string_t set;
3636 cmdline_fixed_string_t mask;
3640 static void cmd_set_mask_parsed(void *parsed_result,
3641 __rte_unused struct cmdline *cl,
3642 __rte_unused void *data)
3644 struct cmd_setmask_result *res = parsed_result;
3646 if (test_done == 0) {
3647 printf("Please stop forwarding first\n");
3650 if (!strcmp(res->mask, "coremask")) {
3651 set_fwd_lcores_mask(res->hexavalue);
3653 } else if (!strcmp(res->mask, "portmask")) {
3654 set_fwd_ports_mask(res->hexavalue);
3659 cmdline_parse_token_string_t cmd_setmask_set =
3660 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3661 cmdline_parse_token_string_t cmd_setmask_mask =
3662 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3663 "coremask#portmask");
3664 cmdline_parse_token_num_t cmd_setmask_value =
3665 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3667 cmdline_parse_inst_t cmd_set_fwd_mask = {
3668 .f = cmd_set_mask_parsed,
3670 .help_str = "set coremask|portmask <hexadecimal value>",
3672 (void *)&cmd_setmask_set,
3673 (void *)&cmd_setmask_mask,
3674 (void *)&cmd_setmask_value,
3680 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3682 struct cmd_set_result {
3683 cmdline_fixed_string_t set;
3684 cmdline_fixed_string_t what;
3688 static void cmd_set_parsed(void *parsed_result,
3689 __rte_unused struct cmdline *cl,
3690 __rte_unused void *data)
3692 struct cmd_set_result *res = parsed_result;
3693 if (!strcmp(res->what, "nbport")) {
3694 set_fwd_ports_number(res->value);
3696 } else if (!strcmp(res->what, "nbcore")) {
3697 set_fwd_lcores_number(res->value);
3699 } else if (!strcmp(res->what, "burst"))
3700 set_nb_pkt_per_burst(res->value);
3701 else if (!strcmp(res->what, "verbose"))
3702 set_verbose_level(res->value);
3705 cmdline_parse_token_string_t cmd_set_set =
3706 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3707 cmdline_parse_token_string_t cmd_set_what =
3708 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3709 "nbport#nbcore#burst#verbose");
3710 cmdline_parse_token_num_t cmd_set_value =
3711 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3713 cmdline_parse_inst_t cmd_set_numbers = {
3714 .f = cmd_set_parsed,
3716 .help_str = "set nbport|nbcore|burst|verbose <value>",
3718 (void *)&cmd_set_set,
3719 (void *)&cmd_set_what,
3720 (void *)&cmd_set_value,
3725 /* *** SET LOG LEVEL CONFIGURATION *** */
3727 struct cmd_set_log_result {
3728 cmdline_fixed_string_t set;
3729 cmdline_fixed_string_t log;
3730 cmdline_fixed_string_t type;
3735 cmd_set_log_parsed(void *parsed_result,
3736 __rte_unused struct cmdline *cl,
3737 __rte_unused void *data)
3739 struct cmd_set_log_result *res;
3742 res = parsed_result;
3743 if (!strcmp(res->type, "global"))
3744 rte_log_set_global_level(res->level);
3746 ret = rte_log_set_level_regexp(res->type, res->level);
3748 printf("Unable to set log level\n");
3752 cmdline_parse_token_string_t cmd_set_log_set =
3753 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3754 cmdline_parse_token_string_t cmd_set_log_log =
3755 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3756 cmdline_parse_token_string_t cmd_set_log_type =
3757 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3758 cmdline_parse_token_num_t cmd_set_log_level =
3759 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3761 cmdline_parse_inst_t cmd_set_log = {
3762 .f = cmd_set_log_parsed,
3764 .help_str = "set log global|<type> <level>",
3766 (void *)&cmd_set_log_set,
3767 (void *)&cmd_set_log_log,
3768 (void *)&cmd_set_log_type,
3769 (void *)&cmd_set_log_level,
3774 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3776 struct cmd_set_rxoffs_result {
3777 cmdline_fixed_string_t cmd_keyword;
3778 cmdline_fixed_string_t rxoffs;
3779 cmdline_fixed_string_t seg_offsets;
3783 cmd_set_rxoffs_parsed(void *parsed_result,
3784 __rte_unused struct cmdline *cl,
3785 __rte_unused void *data)
3787 struct cmd_set_rxoffs_result *res;
3788 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3789 unsigned int nb_segs;
3791 res = parsed_result;
3792 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3793 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3795 set_rx_pkt_offsets(seg_offsets, nb_segs);
3798 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3799 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3800 cmd_keyword, "set");
3801 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3802 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3804 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3805 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3808 cmdline_parse_inst_t cmd_set_rxoffs = {
3809 .f = cmd_set_rxoffs_parsed,
3811 .help_str = "set rxoffs <len0[,len1]*>",
3813 (void *)&cmd_set_rxoffs_keyword,
3814 (void *)&cmd_set_rxoffs_name,
3815 (void *)&cmd_set_rxoffs_offsets,
3820 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3822 struct cmd_set_rxpkts_result {
3823 cmdline_fixed_string_t cmd_keyword;
3824 cmdline_fixed_string_t rxpkts;
3825 cmdline_fixed_string_t seg_lengths;
3829 cmd_set_rxpkts_parsed(void *parsed_result,
3830 __rte_unused struct cmdline *cl,
3831 __rte_unused void *data)
3833 struct cmd_set_rxpkts_result *res;
3834 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3835 unsigned int nb_segs;
3837 res = parsed_result;
3838 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3839 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3841 set_rx_pkt_segments(seg_lengths, nb_segs);
3844 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3845 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3846 cmd_keyword, "set");
3847 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3848 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3850 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3851 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3854 cmdline_parse_inst_t cmd_set_rxpkts = {
3855 .f = cmd_set_rxpkts_parsed,
3857 .help_str = "set rxpkts <len0[,len1]*>",
3859 (void *)&cmd_set_rxpkts_keyword,
3860 (void *)&cmd_set_rxpkts_name,
3861 (void *)&cmd_set_rxpkts_lengths,
3866 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3868 struct cmd_set_txpkts_result {
3869 cmdline_fixed_string_t cmd_keyword;
3870 cmdline_fixed_string_t txpkts;
3871 cmdline_fixed_string_t seg_lengths;
3875 cmd_set_txpkts_parsed(void *parsed_result,
3876 __rte_unused struct cmdline *cl,
3877 __rte_unused void *data)
3879 struct cmd_set_txpkts_result *res;
3880 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3881 unsigned int nb_segs;
3883 res = parsed_result;
3884 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3885 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3887 set_tx_pkt_segments(seg_lengths, nb_segs);
3890 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3891 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3892 cmd_keyword, "set");
3893 cmdline_parse_token_string_t cmd_set_txpkts_name =
3894 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3896 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3897 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3900 cmdline_parse_inst_t cmd_set_txpkts = {
3901 .f = cmd_set_txpkts_parsed,
3903 .help_str = "set txpkts <len0[,len1]*>",
3905 (void *)&cmd_set_txpkts_keyword,
3906 (void *)&cmd_set_txpkts_name,
3907 (void *)&cmd_set_txpkts_lengths,
3912 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3914 struct cmd_set_txsplit_result {
3915 cmdline_fixed_string_t cmd_keyword;
3916 cmdline_fixed_string_t txsplit;
3917 cmdline_fixed_string_t mode;
3921 cmd_set_txsplit_parsed(void *parsed_result,
3922 __rte_unused struct cmdline *cl,
3923 __rte_unused void *data)
3925 struct cmd_set_txsplit_result *res;
3927 res = parsed_result;
3928 set_tx_pkt_split(res->mode);
3931 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3932 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3933 cmd_keyword, "set");
3934 cmdline_parse_token_string_t cmd_set_txsplit_name =
3935 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3936 txsplit, "txsplit");
3937 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3938 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3941 cmdline_parse_inst_t cmd_set_txsplit = {
3942 .f = cmd_set_txsplit_parsed,
3944 .help_str = "set txsplit on|off|rand",
3946 (void *)&cmd_set_txsplit_keyword,
3947 (void *)&cmd_set_txsplit_name,
3948 (void *)&cmd_set_txsplit_mode,
3953 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
3955 struct cmd_set_txtimes_result {
3956 cmdline_fixed_string_t cmd_keyword;
3957 cmdline_fixed_string_t txtimes;
3958 cmdline_fixed_string_t tx_times;
3962 cmd_set_txtimes_parsed(void *parsed_result,
3963 __rte_unused struct cmdline *cl,
3964 __rte_unused void *data)
3966 struct cmd_set_txtimes_result *res;
3967 unsigned int tx_times[2] = {0, 0};
3968 unsigned int n_times;
3970 res = parsed_result;
3971 n_times = parse_item_list(res->tx_times, "tx times",
3974 set_tx_pkt_times(tx_times);
3977 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
3978 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3979 cmd_keyword, "set");
3980 cmdline_parse_token_string_t cmd_set_txtimes_name =
3981 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3982 txtimes, "txtimes");
3983 cmdline_parse_token_string_t cmd_set_txtimes_value =
3984 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3987 cmdline_parse_inst_t cmd_set_txtimes = {
3988 .f = cmd_set_txtimes_parsed,
3990 .help_str = "set txtimes <inter_burst>,<intra_burst>",
3992 (void *)&cmd_set_txtimes_keyword,
3993 (void *)&cmd_set_txtimes_name,
3994 (void *)&cmd_set_txtimes_value,
3999 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4000 struct cmd_rx_vlan_filter_all_result {
4001 cmdline_fixed_string_t rx_vlan;
4002 cmdline_fixed_string_t what;
4003 cmdline_fixed_string_t all;
4008 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4009 __rte_unused struct cmdline *cl,
4010 __rte_unused void *data)
4012 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4014 if (!strcmp(res->what, "add"))
4015 rx_vlan_all_filter_set(res->port_id, 1);
4017 rx_vlan_all_filter_set(res->port_id, 0);
4020 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4021 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4022 rx_vlan, "rx_vlan");
4023 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4024 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4026 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4027 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4029 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4030 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4033 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4034 .f = cmd_rx_vlan_filter_all_parsed,
4036 .help_str = "rx_vlan add|rm all <port_id>: "
4037 "Add/Remove all identifiers to/from the set of VLAN "
4038 "identifiers filtered by a port",
4040 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4041 (void *)&cmd_rx_vlan_filter_all_what,
4042 (void *)&cmd_rx_vlan_filter_all_all,
4043 (void *)&cmd_rx_vlan_filter_all_portid,
4048 /* *** VLAN OFFLOAD SET ON A PORT *** */
4049 struct cmd_vlan_offload_result {
4050 cmdline_fixed_string_t vlan;
4051 cmdline_fixed_string_t set;
4052 cmdline_fixed_string_t vlan_type;
4053 cmdline_fixed_string_t what;
4054 cmdline_fixed_string_t on;
4055 cmdline_fixed_string_t port_id;
4059 cmd_vlan_offload_parsed(void *parsed_result,
4060 __rte_unused struct cmdline *cl,
4061 __rte_unused void *data)
4064 struct cmd_vlan_offload_result *res = parsed_result;
4067 portid_t port_id = 0;
4071 len = strnlen(str, STR_TOKEN_SIZE);
4073 /* Get port_id first */
4081 tmp = strtoul(str, NULL, 0);
4082 /* If port_id greater that what portid_t can represent, return */
4083 if(tmp >= RTE_MAX_ETHPORTS)
4085 port_id = (portid_t)tmp;
4087 if (!strcmp(res->on, "on"))
4092 if (!strcmp(res->what, "strip"))
4093 rx_vlan_strip_set(port_id, on);
4094 else if(!strcmp(res->what, "stripq")){
4095 uint16_t queue_id = 0;
4097 /* No queue_id, return */
4099 printf("must specify (port,queue_id)\n");
4102 tmp = strtoul(str + i + 1, NULL, 0);
4103 /* If queue_id greater that what 16-bits can represent, return */
4107 queue_id = (uint16_t)tmp;
4108 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4110 else if (!strcmp(res->what, "filter"))
4111 rx_vlan_filter_set(port_id, on);
4112 else if (!strcmp(res->what, "qinq_strip"))
4113 rx_vlan_qinq_strip_set(port_id, on);
4115 vlan_extend_set(port_id, on);
4120 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4121 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4123 cmdline_parse_token_string_t cmd_vlan_offload_set =
4124 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4126 cmdline_parse_token_string_t cmd_vlan_offload_what =
4127 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4128 what, "strip#filter#qinq_strip#extend#stripq");
4129 cmdline_parse_token_string_t cmd_vlan_offload_on =
4130 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4132 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4133 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4136 cmdline_parse_inst_t cmd_vlan_offload = {
4137 .f = cmd_vlan_offload_parsed,
4139 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4140 "<port_id[,queue_id]>: "
4141 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4143 (void *)&cmd_vlan_offload_vlan,
4144 (void *)&cmd_vlan_offload_set,
4145 (void *)&cmd_vlan_offload_what,
4146 (void *)&cmd_vlan_offload_on,
4147 (void *)&cmd_vlan_offload_portid,
4152 /* *** VLAN TPID SET ON A PORT *** */
4153 struct cmd_vlan_tpid_result {
4154 cmdline_fixed_string_t vlan;
4155 cmdline_fixed_string_t set;
4156 cmdline_fixed_string_t vlan_type;
4157 cmdline_fixed_string_t what;
4163 cmd_vlan_tpid_parsed(void *parsed_result,
4164 __rte_unused struct cmdline *cl,
4165 __rte_unused void *data)
4167 struct cmd_vlan_tpid_result *res = parsed_result;
4168 enum rte_vlan_type vlan_type;
4170 if (!strcmp(res->vlan_type, "inner"))
4171 vlan_type = ETH_VLAN_TYPE_INNER;
4172 else if (!strcmp(res->vlan_type, "outer"))
4173 vlan_type = ETH_VLAN_TYPE_OUTER;
4175 printf("Unknown vlan type\n");
4178 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4181 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4182 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4184 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4185 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4187 cmdline_parse_token_string_t cmd_vlan_type =
4188 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4189 vlan_type, "inner#outer");
4190 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4191 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4193 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4194 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4196 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4197 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4200 cmdline_parse_inst_t cmd_vlan_tpid = {
4201 .f = cmd_vlan_tpid_parsed,
4203 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4204 "Set the VLAN Ether type",
4206 (void *)&cmd_vlan_tpid_vlan,
4207 (void *)&cmd_vlan_tpid_set,
4208 (void *)&cmd_vlan_type,
4209 (void *)&cmd_vlan_tpid_what,
4210 (void *)&cmd_vlan_tpid_tpid,
4211 (void *)&cmd_vlan_tpid_portid,
4216 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4217 struct cmd_rx_vlan_filter_result {
4218 cmdline_fixed_string_t rx_vlan;
4219 cmdline_fixed_string_t what;
4225 cmd_rx_vlan_filter_parsed(void *parsed_result,
4226 __rte_unused struct cmdline *cl,
4227 __rte_unused void *data)
4229 struct cmd_rx_vlan_filter_result *res = parsed_result;
4231 if (!strcmp(res->what, "add"))
4232 rx_vft_set(res->port_id, res->vlan_id, 1);
4234 rx_vft_set(res->port_id, res->vlan_id, 0);
4237 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4238 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4239 rx_vlan, "rx_vlan");
4240 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4241 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4243 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4244 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4246 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4247 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4250 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4251 .f = cmd_rx_vlan_filter_parsed,
4253 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4254 "Add/Remove a VLAN identifier to/from the set of VLAN "
4255 "identifiers filtered by a port",
4257 (void *)&cmd_rx_vlan_filter_rx_vlan,
4258 (void *)&cmd_rx_vlan_filter_what,
4259 (void *)&cmd_rx_vlan_filter_vlanid,
4260 (void *)&cmd_rx_vlan_filter_portid,
4265 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4266 struct cmd_tx_vlan_set_result {
4267 cmdline_fixed_string_t tx_vlan;
4268 cmdline_fixed_string_t set;
4274 cmd_tx_vlan_set_parsed(void *parsed_result,
4275 __rte_unused struct cmdline *cl,
4276 __rte_unused void *data)
4278 struct cmd_tx_vlan_set_result *res = parsed_result;
4280 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4283 if (!port_is_stopped(res->port_id)) {
4284 printf("Please stop port %d first\n", res->port_id);
4288 tx_vlan_set(res->port_id, res->vlan_id);
4290 cmd_reconfig_device_queue(res->port_id, 1, 1);
4293 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4294 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4295 tx_vlan, "tx_vlan");
4296 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4297 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4299 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4300 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4302 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4303 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4306 cmdline_parse_inst_t cmd_tx_vlan_set = {
4307 .f = cmd_tx_vlan_set_parsed,
4309 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4310 "Enable hardware insertion of a single VLAN header "
4311 "with a given TAG Identifier in packets sent on a port",
4313 (void *)&cmd_tx_vlan_set_tx_vlan,
4314 (void *)&cmd_tx_vlan_set_set,
4315 (void *)&cmd_tx_vlan_set_portid,
4316 (void *)&cmd_tx_vlan_set_vlanid,
4321 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4322 struct cmd_tx_vlan_set_qinq_result {
4323 cmdline_fixed_string_t tx_vlan;
4324 cmdline_fixed_string_t set;
4327 uint16_t vlan_id_outer;
4331 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4332 __rte_unused struct cmdline *cl,
4333 __rte_unused void *data)
4335 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4337 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4340 if (!port_is_stopped(res->port_id)) {
4341 printf("Please stop port %d first\n", res->port_id);
4345 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4347 cmd_reconfig_device_queue(res->port_id, 1, 1);
4350 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4351 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4352 tx_vlan, "tx_vlan");
4353 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4354 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4356 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4357 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4359 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4360 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4362 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4363 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4364 vlan_id_outer, UINT16);
4366 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4367 .f = cmd_tx_vlan_set_qinq_parsed,
4369 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4370 "Enable hardware insertion of double VLAN header "
4371 "with given TAG Identifiers in packets sent on a port",
4373 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4374 (void *)&cmd_tx_vlan_set_qinq_set,
4375 (void *)&cmd_tx_vlan_set_qinq_portid,
4376 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4377 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4382 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4383 struct cmd_tx_vlan_set_pvid_result {
4384 cmdline_fixed_string_t tx_vlan;
4385 cmdline_fixed_string_t set;
4386 cmdline_fixed_string_t pvid;
4389 cmdline_fixed_string_t mode;
4393 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4394 __rte_unused struct cmdline *cl,
4395 __rte_unused void *data)
4397 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4399 if (strcmp(res->mode, "on") == 0)
4400 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4402 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4405 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4406 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4407 tx_vlan, "tx_vlan");
4408 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4409 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4411 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4412 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4414 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4415 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4417 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4418 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4420 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4421 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4424 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4425 .f = cmd_tx_vlan_set_pvid_parsed,
4427 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4429 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4430 (void *)&cmd_tx_vlan_set_pvid_set,
4431 (void *)&cmd_tx_vlan_set_pvid_pvid,
4432 (void *)&cmd_tx_vlan_set_pvid_port_id,
4433 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4434 (void *)&cmd_tx_vlan_set_pvid_mode,
4439 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4440 struct cmd_tx_vlan_reset_result {
4441 cmdline_fixed_string_t tx_vlan;
4442 cmdline_fixed_string_t reset;
4447 cmd_tx_vlan_reset_parsed(void *parsed_result,
4448 __rte_unused struct cmdline *cl,
4449 __rte_unused void *data)
4451 struct cmd_tx_vlan_reset_result *res = parsed_result;
4453 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4456 if (!port_is_stopped(res->port_id)) {
4457 printf("Please stop port %d first\n", res->port_id);
4461 tx_vlan_reset(res->port_id);
4463 cmd_reconfig_device_queue(res->port_id, 1, 1);
4466 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4467 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4468 tx_vlan, "tx_vlan");
4469 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4470 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4472 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4473 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4476 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4477 .f = cmd_tx_vlan_reset_parsed,
4479 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4480 "VLAN header in packets sent on a port",
4482 (void *)&cmd_tx_vlan_reset_tx_vlan,
4483 (void *)&cmd_tx_vlan_reset_reset,
4484 (void *)&cmd_tx_vlan_reset_portid,
4490 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4491 struct cmd_csum_result {
4492 cmdline_fixed_string_t csum;
4493 cmdline_fixed_string_t mode;
4494 cmdline_fixed_string_t proto;
4495 cmdline_fixed_string_t hwsw;
4500 csum_show(int port_id)
4502 struct rte_eth_dev_info dev_info;
4503 uint64_t tx_offloads;
4506 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4507 printf("Parse tunnel is %s\n",
4508 (ports[port_id].parse_tunnel) ? "on" : "off");
4509 printf("IP checksum offload is %s\n",
4510 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4511 printf("UDP checksum offload is %s\n",
4512 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4513 printf("TCP checksum offload is %s\n",
4514 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4515 printf("SCTP checksum offload is %s\n",
4516 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4517 printf("Outer-Ip checksum offload is %s\n",
4518 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4519 printf("Outer-Udp checksum offload is %s\n",
4520 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4522 /* display warnings if configuration is not supported by the NIC */
4523 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4527 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4528 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4529 printf("Warning: hardware IP checksum enabled but not "
4530 "supported by port %d\n", port_id);
4532 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4533 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4534 printf("Warning: hardware UDP checksum enabled but not "
4535 "supported by port %d\n", port_id);
4537 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4538 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4539 printf("Warning: hardware TCP checksum enabled but not "
4540 "supported by port %d\n", port_id);
4542 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4543 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4544 printf("Warning: hardware SCTP checksum enabled but not "
4545 "supported by port %d\n", port_id);
4547 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4548 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4549 printf("Warning: hardware outer IP checksum enabled but not "
4550 "supported by port %d\n", port_id);
4552 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4553 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4555 printf("Warning: hardware outer UDP checksum enabled but not "
4556 "supported by port %d\n", port_id);
4561 cmd_config_queue_tx_offloads(struct rte_port *port)
4565 /* Apply queue tx offloads configuration */
4566 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4567 port->tx_conf[k].offloads =
4568 port->dev_conf.txmode.offloads;
4572 cmd_csum_parsed(void *parsed_result,
4573 __rte_unused struct cmdline *cl,
4574 __rte_unused void *data)
4576 struct cmd_csum_result *res = parsed_result;
4578 uint64_t csum_offloads = 0;
4579 struct rte_eth_dev_info dev_info;
4582 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4583 printf("invalid port %d\n", res->port_id);
4586 if (!port_is_stopped(res->port_id)) {
4587 printf("Please stop port %d first\n", res->port_id);
4591 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4595 if (!strcmp(res->mode, "set")) {
4597 if (!strcmp(res->hwsw, "hw"))
4600 if (!strcmp(res->proto, "ip")) {
4601 if (hw == 0 || (dev_info.tx_offload_capa &
4602 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4603 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4605 printf("IP checksum offload is not supported "
4606 "by port %u\n", res->port_id);
4608 } else if (!strcmp(res->proto, "udp")) {
4609 if (hw == 0 || (dev_info.tx_offload_capa &
4610 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4611 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4613 printf("UDP checksum offload is not supported "
4614 "by port %u\n", res->port_id);
4616 } else if (!strcmp(res->proto, "tcp")) {
4617 if (hw == 0 || (dev_info.tx_offload_capa &
4618 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4619 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4621 printf("TCP checksum offload is not supported "
4622 "by port %u\n", res->port_id);
4624 } else if (!strcmp(res->proto, "sctp")) {
4625 if (hw == 0 || (dev_info.tx_offload_capa &
4626 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4627 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4629 printf("SCTP checksum offload is not supported "
4630 "by port %u\n", res->port_id);
4632 } else if (!strcmp(res->proto, "outer-ip")) {
4633 if (hw == 0 || (dev_info.tx_offload_capa &
4634 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4636 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4638 printf("Outer IP checksum offload is not "
4639 "supported by port %u\n", res->port_id);
4641 } else if (!strcmp(res->proto, "outer-udp")) {
4642 if (hw == 0 || (dev_info.tx_offload_capa &
4643 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4645 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4647 printf("Outer UDP checksum offload is not "
4648 "supported by port %u\n", res->port_id);
4653 ports[res->port_id].dev_conf.txmode.offloads |=
4656 ports[res->port_id].dev_conf.txmode.offloads &=
4659 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4661 csum_show(res->port_id);
4663 cmd_reconfig_device_queue(res->port_id, 1, 1);
4666 cmdline_parse_token_string_t cmd_csum_csum =
4667 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4669 cmdline_parse_token_string_t cmd_csum_mode =
4670 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4672 cmdline_parse_token_string_t cmd_csum_proto =
4673 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4674 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4675 cmdline_parse_token_string_t cmd_csum_hwsw =
4676 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4678 cmdline_parse_token_num_t cmd_csum_portid =
4679 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4682 cmdline_parse_inst_t cmd_csum_set = {
4683 .f = cmd_csum_parsed,
4685 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4686 "Enable/Disable hardware calculation of L3/L4 checksum when "
4687 "using csum forward engine",
4689 (void *)&cmd_csum_csum,
4690 (void *)&cmd_csum_mode,
4691 (void *)&cmd_csum_proto,
4692 (void *)&cmd_csum_hwsw,
4693 (void *)&cmd_csum_portid,
4698 cmdline_parse_token_string_t cmd_csum_mode_show =
4699 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4702 cmdline_parse_inst_t cmd_csum_show = {
4703 .f = cmd_csum_parsed,
4705 .help_str = "csum show <port_id>: Show checksum offload configuration",
4707 (void *)&cmd_csum_csum,
4708 (void *)&cmd_csum_mode_show,
4709 (void *)&cmd_csum_portid,
4714 /* Enable/disable tunnel parsing */
4715 struct cmd_csum_tunnel_result {
4716 cmdline_fixed_string_t csum;
4717 cmdline_fixed_string_t parse;
4718 cmdline_fixed_string_t onoff;
4723 cmd_csum_tunnel_parsed(void *parsed_result,
4724 __rte_unused struct cmdline *cl,
4725 __rte_unused void *data)
4727 struct cmd_csum_tunnel_result *res = parsed_result;
4729 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4732 if (!strcmp(res->onoff, "on"))
4733 ports[res->port_id].parse_tunnel = 1;
4735 ports[res->port_id].parse_tunnel = 0;
4737 csum_show(res->port_id);
4740 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4741 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4743 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4744 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4745 parse, "parse-tunnel");
4746 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4747 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4749 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4750 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4753 cmdline_parse_inst_t cmd_csum_tunnel = {
4754 .f = cmd_csum_tunnel_parsed,
4756 .help_str = "csum parse-tunnel on|off <port_id>: "
4757 "Enable/Disable parsing of tunnels for csum engine",
4759 (void *)&cmd_csum_tunnel_csum,
4760 (void *)&cmd_csum_tunnel_parse,
4761 (void *)&cmd_csum_tunnel_onoff,
4762 (void *)&cmd_csum_tunnel_portid,
4767 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4768 struct cmd_tso_set_result {
4769 cmdline_fixed_string_t tso;
4770 cmdline_fixed_string_t mode;
4776 cmd_tso_set_parsed(void *parsed_result,
4777 __rte_unused struct cmdline *cl,
4778 __rte_unused void *data)
4780 struct cmd_tso_set_result *res = parsed_result;
4781 struct rte_eth_dev_info dev_info;
4784 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4786 if (!port_is_stopped(res->port_id)) {
4787 printf("Please stop port %d first\n", res->port_id);
4791 if (!strcmp(res->mode, "set"))
4792 ports[res->port_id].tso_segsz = res->tso_segsz;
4794 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4798 if ((ports[res->port_id].tso_segsz != 0) &&
4799 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4800 printf("Error: TSO is not supported by port %d\n",
4805 if (ports[res->port_id].tso_segsz == 0) {
4806 ports[res->port_id].dev_conf.txmode.offloads &=
4807 ~DEV_TX_OFFLOAD_TCP_TSO;
4808 printf("TSO for non-tunneled packets is disabled\n");
4810 ports[res->port_id].dev_conf.txmode.offloads |=
4811 DEV_TX_OFFLOAD_TCP_TSO;
4812 printf("TSO segment size for non-tunneled packets is %d\n",
4813 ports[res->port_id].tso_segsz);
4815 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4817 /* display warnings if configuration is not supported by the NIC */
4818 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4822 if ((ports[res->port_id].tso_segsz != 0) &&
4823 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4824 printf("Warning: TSO enabled but not "
4825 "supported by port %d\n", res->port_id);
4828 cmd_reconfig_device_queue(res->port_id, 1, 1);
4831 cmdline_parse_token_string_t cmd_tso_set_tso =
4832 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4834 cmdline_parse_token_string_t cmd_tso_set_mode =
4835 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4837 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4838 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4840 cmdline_parse_token_num_t cmd_tso_set_portid =
4841 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4844 cmdline_parse_inst_t cmd_tso_set = {
4845 .f = cmd_tso_set_parsed,
4847 .help_str = "tso set <tso_segsz> <port_id>: "
4848 "Set TSO segment size of non-tunneled packets for csum engine "
4851 (void *)&cmd_tso_set_tso,
4852 (void *)&cmd_tso_set_mode,
4853 (void *)&cmd_tso_set_tso_segsz,
4854 (void *)&cmd_tso_set_portid,
4859 cmdline_parse_token_string_t cmd_tso_show_mode =
4860 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4864 cmdline_parse_inst_t cmd_tso_show = {
4865 .f = cmd_tso_set_parsed,
4867 .help_str = "tso show <port_id>: "
4868 "Show TSO segment size of non-tunneled packets for csum engine",
4870 (void *)&cmd_tso_set_tso,
4871 (void *)&cmd_tso_show_mode,
4872 (void *)&cmd_tso_set_portid,
4877 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4878 struct cmd_tunnel_tso_set_result {
4879 cmdline_fixed_string_t tso;
4880 cmdline_fixed_string_t mode;
4885 static struct rte_eth_dev_info
4886 check_tunnel_tso_nic_support(portid_t port_id)
4888 struct rte_eth_dev_info dev_info;
4890 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4893 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4894 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4895 "not enabled for port %d\n", port_id);
4896 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4897 printf("Warning: GRE TUNNEL TSO not supported therefore "
4898 "not enabled for port %d\n", port_id);
4899 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4900 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4901 "not enabled for port %d\n", port_id);
4902 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4903 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4904 "not enabled for port %d\n", port_id);
4905 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4906 printf("Warning: IP TUNNEL TSO not supported therefore "
4907 "not enabled for port %d\n", port_id);
4908 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4909 printf("Warning: UDP TUNNEL TSO not supported therefore "
4910 "not enabled for port %d\n", port_id);
4915 cmd_tunnel_tso_set_parsed(void *parsed_result,
4916 __rte_unused struct cmdline *cl,
4917 __rte_unused void *data)
4919 struct cmd_tunnel_tso_set_result *res = parsed_result;
4920 struct rte_eth_dev_info dev_info;
4922 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4924 if (!port_is_stopped(res->port_id)) {
4925 printf("Please stop port %d first\n", res->port_id);
4929 if (!strcmp(res->mode, "set"))
4930 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4932 dev_info = check_tunnel_tso_nic_support(res->port_id);
4933 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4934 ports[res->port_id].dev_conf.txmode.offloads &=
4935 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4936 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4937 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4938 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4939 DEV_TX_OFFLOAD_IP_TNL_TSO |
4940 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4941 printf("TSO for tunneled packets is disabled\n");
4943 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4944 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4945 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4946 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4947 DEV_TX_OFFLOAD_IP_TNL_TSO |
4948 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4950 ports[res->port_id].dev_conf.txmode.offloads |=
4951 (tso_offloads & dev_info.tx_offload_capa);
4952 printf("TSO segment size for tunneled packets is %d\n",
4953 ports[res->port_id].tunnel_tso_segsz);
4955 /* Below conditions are needed to make it work:
4956 * (1) tunnel TSO is supported by the NIC;
4957 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4959 * (3) for tunneled pkts with outer L3 of IPv4,
4960 * "csum set outer-ip" must be set to hw, because after tso,
4961 * total_len of outer IP header is changed, and the checksum
4962 * of outer IP header calculated by sw should be wrong; that
4963 * is not necessary for IPv6 tunneled pkts because there's no
4964 * checksum in IP header anymore.
4967 if (!ports[res->port_id].parse_tunnel)
4968 printf("Warning: csum parse_tunnel must be set "
4969 "so that tunneled packets are recognized\n");
4970 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4971 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4972 printf("Warning: csum set outer-ip must be set to hw "
4973 "if outer L3 is IPv4; not necessary for IPv6\n");
4976 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4977 cmd_reconfig_device_queue(res->port_id, 1, 1);
4980 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4981 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4983 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4984 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4986 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4987 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4989 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4990 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4993 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4994 .f = cmd_tunnel_tso_set_parsed,
4996 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4997 "Set TSO segment size of tunneled packets for csum engine "
5000 (void *)&cmd_tunnel_tso_set_tso,
5001 (void *)&cmd_tunnel_tso_set_mode,
5002 (void *)&cmd_tunnel_tso_set_tso_segsz,
5003 (void *)&cmd_tunnel_tso_set_portid,
5008 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5009 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5013 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5014 .f = cmd_tunnel_tso_set_parsed,
5016 .help_str = "tunnel_tso show <port_id> "
5017 "Show TSO segment size of tunneled packets for csum engine",
5019 (void *)&cmd_tunnel_tso_set_tso,
5020 (void *)&cmd_tunnel_tso_show_mode,
5021 (void *)&cmd_tunnel_tso_set_portid,
5026 /* *** SET GRO FOR A PORT *** */
5027 struct cmd_gro_enable_result {
5028 cmdline_fixed_string_t cmd_set;
5029 cmdline_fixed_string_t cmd_port;
5030 cmdline_fixed_string_t cmd_keyword;
5031 cmdline_fixed_string_t cmd_onoff;
5036 cmd_gro_enable_parsed(void *parsed_result,
5037 __rte_unused struct cmdline *cl,
5038 __rte_unused void *data)
5040 struct cmd_gro_enable_result *res;
5042 res = parsed_result;
5043 if (!strcmp(res->cmd_keyword, "gro"))
5044 setup_gro(res->cmd_onoff, res->cmd_pid);
5047 cmdline_parse_token_string_t cmd_gro_enable_set =
5048 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5050 cmdline_parse_token_string_t cmd_gro_enable_port =
5051 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5052 cmd_keyword, "port");
5053 cmdline_parse_token_num_t cmd_gro_enable_pid =
5054 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5056 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5057 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5058 cmd_keyword, "gro");
5059 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5060 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5061 cmd_onoff, "on#off");
5063 cmdline_parse_inst_t cmd_gro_enable = {
5064 .f = cmd_gro_enable_parsed,
5066 .help_str = "set port <port_id> gro on|off",
5068 (void *)&cmd_gro_enable_set,
5069 (void *)&cmd_gro_enable_port,
5070 (void *)&cmd_gro_enable_pid,
5071 (void *)&cmd_gro_enable_keyword,
5072 (void *)&cmd_gro_enable_onoff,
5077 /* *** DISPLAY GRO CONFIGURATION *** */
5078 struct cmd_gro_show_result {
5079 cmdline_fixed_string_t cmd_show;
5080 cmdline_fixed_string_t cmd_port;
5081 cmdline_fixed_string_t cmd_keyword;
5086 cmd_gro_show_parsed(void *parsed_result,
5087 __rte_unused struct cmdline *cl,
5088 __rte_unused void *data)
5090 struct cmd_gro_show_result *res;
5092 res = parsed_result;
5093 if (!strcmp(res->cmd_keyword, "gro"))
5094 show_gro(res->cmd_pid);
5097 cmdline_parse_token_string_t cmd_gro_show_show =
5098 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5100 cmdline_parse_token_string_t cmd_gro_show_port =
5101 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5103 cmdline_parse_token_num_t cmd_gro_show_pid =
5104 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5106 cmdline_parse_token_string_t cmd_gro_show_keyword =
5107 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5108 cmd_keyword, "gro");
5110 cmdline_parse_inst_t cmd_gro_show = {
5111 .f = cmd_gro_show_parsed,
5113 .help_str = "show port <port_id> gro",
5115 (void *)&cmd_gro_show_show,
5116 (void *)&cmd_gro_show_port,
5117 (void *)&cmd_gro_show_pid,
5118 (void *)&cmd_gro_show_keyword,
5123 /* *** SET FLUSH CYCLES FOR GRO *** */
5124 struct cmd_gro_flush_result {
5125 cmdline_fixed_string_t cmd_set;
5126 cmdline_fixed_string_t cmd_keyword;
5127 cmdline_fixed_string_t cmd_flush;
5132 cmd_gro_flush_parsed(void *parsed_result,
5133 __rte_unused struct cmdline *cl,
5134 __rte_unused void *data)
5136 struct cmd_gro_flush_result *res;
5138 res = parsed_result;
5139 if ((!strcmp(res->cmd_keyword, "gro")) &&
5140 (!strcmp(res->cmd_flush, "flush")))
5141 setup_gro_flush_cycles(res->cmd_cycles);
5144 cmdline_parse_token_string_t cmd_gro_flush_set =
5145 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5147 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5148 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5149 cmd_keyword, "gro");
5150 cmdline_parse_token_string_t cmd_gro_flush_flush =
5151 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5152 cmd_flush, "flush");
5153 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5154 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5157 cmdline_parse_inst_t cmd_gro_flush = {
5158 .f = cmd_gro_flush_parsed,
5160 .help_str = "set gro flush <cycles>",
5162 (void *)&cmd_gro_flush_set,
5163 (void *)&cmd_gro_flush_keyword,
5164 (void *)&cmd_gro_flush_flush,
5165 (void *)&cmd_gro_flush_cycles,
5170 /* *** ENABLE/DISABLE GSO *** */
5171 struct cmd_gso_enable_result {
5172 cmdline_fixed_string_t cmd_set;
5173 cmdline_fixed_string_t cmd_port;
5174 cmdline_fixed_string_t cmd_keyword;
5175 cmdline_fixed_string_t cmd_mode;
5180 cmd_gso_enable_parsed(void *parsed_result,
5181 __rte_unused struct cmdline *cl,
5182 __rte_unused void *data)
5184 struct cmd_gso_enable_result *res;
5186 res = parsed_result;
5187 if (!strcmp(res->cmd_keyword, "gso"))
5188 setup_gso(res->cmd_mode, res->cmd_pid);
5191 cmdline_parse_token_string_t cmd_gso_enable_set =
5192 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5194 cmdline_parse_token_string_t cmd_gso_enable_port =
5195 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5197 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5198 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5199 cmd_keyword, "gso");
5200 cmdline_parse_token_string_t cmd_gso_enable_mode =
5201 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5202 cmd_mode, "on#off");
5203 cmdline_parse_token_num_t cmd_gso_enable_pid =
5204 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5207 cmdline_parse_inst_t cmd_gso_enable = {
5208 .f = cmd_gso_enable_parsed,
5210 .help_str = "set port <port_id> gso on|off",
5212 (void *)&cmd_gso_enable_set,
5213 (void *)&cmd_gso_enable_port,
5214 (void *)&cmd_gso_enable_pid,
5215 (void *)&cmd_gso_enable_keyword,
5216 (void *)&cmd_gso_enable_mode,
5221 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5222 struct cmd_gso_size_result {
5223 cmdline_fixed_string_t cmd_set;
5224 cmdline_fixed_string_t cmd_keyword;
5225 cmdline_fixed_string_t cmd_segsz;
5230 cmd_gso_size_parsed(void *parsed_result,
5231 __rte_unused struct cmdline *cl,
5232 __rte_unused void *data)
5234 struct cmd_gso_size_result *res = parsed_result;
5236 if (test_done == 0) {
5237 printf("Before setting GSO segsz, please first"
5238 " stop forwarding\n");
5242 if (!strcmp(res->cmd_keyword, "gso") &&
5243 !strcmp(res->cmd_segsz, "segsz")) {
5244 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5245 printf("gso_size should be larger than %zu."
5246 " Please input a legal value\n",
5247 RTE_GSO_SEG_SIZE_MIN);
5249 gso_max_segment_size = res->cmd_size;
5253 cmdline_parse_token_string_t cmd_gso_size_set =
5254 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5256 cmdline_parse_token_string_t cmd_gso_size_keyword =
5257 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5258 cmd_keyword, "gso");
5259 cmdline_parse_token_string_t cmd_gso_size_segsz =
5260 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5261 cmd_segsz, "segsz");
5262 cmdline_parse_token_num_t cmd_gso_size_size =
5263 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5266 cmdline_parse_inst_t cmd_gso_size = {
5267 .f = cmd_gso_size_parsed,
5269 .help_str = "set gso segsz <length>",
5271 (void *)&cmd_gso_size_set,
5272 (void *)&cmd_gso_size_keyword,
5273 (void *)&cmd_gso_size_segsz,
5274 (void *)&cmd_gso_size_size,
5279 /* *** SHOW GSO CONFIGURATION *** */
5280 struct cmd_gso_show_result {
5281 cmdline_fixed_string_t cmd_show;
5282 cmdline_fixed_string_t cmd_port;
5283 cmdline_fixed_string_t cmd_keyword;
5288 cmd_gso_show_parsed(void *parsed_result,
5289 __rte_unused struct cmdline *cl,
5290 __rte_unused void *data)
5292 struct cmd_gso_show_result *res = parsed_result;
5294 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5295 printf("invalid port id %u\n", res->cmd_pid);
5298 if (!strcmp(res->cmd_keyword, "gso")) {
5299 if (gso_ports[res->cmd_pid].enable) {
5300 printf("Max GSO'd packet size: %uB\n"
5301 "Supported GSO types: TCP/IPv4, "
5302 "UDP/IPv4, VxLAN with inner "
5303 "TCP/IPv4 packet, GRE with inner "
5304 "TCP/IPv4 packet\n",
5305 gso_max_segment_size);
5307 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5311 cmdline_parse_token_string_t cmd_gso_show_show =
5312 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5314 cmdline_parse_token_string_t cmd_gso_show_port =
5315 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5317 cmdline_parse_token_string_t cmd_gso_show_keyword =
5318 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5319 cmd_keyword, "gso");
5320 cmdline_parse_token_num_t cmd_gso_show_pid =
5321 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5324 cmdline_parse_inst_t cmd_gso_show = {
5325 .f = cmd_gso_show_parsed,
5327 .help_str = "show port <port_id> gso",
5329 (void *)&cmd_gso_show_show,
5330 (void *)&cmd_gso_show_port,
5331 (void *)&cmd_gso_show_pid,
5332 (void *)&cmd_gso_show_keyword,
5337 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5338 struct cmd_set_flush_rx {
5339 cmdline_fixed_string_t set;
5340 cmdline_fixed_string_t flush_rx;
5341 cmdline_fixed_string_t mode;
5345 cmd_set_flush_rx_parsed(void *parsed_result,
5346 __rte_unused struct cmdline *cl,
5347 __rte_unused void *data)
5349 struct cmd_set_flush_rx *res = parsed_result;
5350 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5353 cmdline_parse_token_string_t cmd_setflushrx_set =
5354 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5356 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5357 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5358 flush_rx, "flush_rx");
5359 cmdline_parse_token_string_t cmd_setflushrx_mode =
5360 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5364 cmdline_parse_inst_t cmd_set_flush_rx = {
5365 .f = cmd_set_flush_rx_parsed,
5366 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5369 (void *)&cmd_setflushrx_set,
5370 (void *)&cmd_setflushrx_flush_rx,
5371 (void *)&cmd_setflushrx_mode,
5376 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5377 struct cmd_set_link_check {
5378 cmdline_fixed_string_t set;
5379 cmdline_fixed_string_t link_check;
5380 cmdline_fixed_string_t mode;
5384 cmd_set_link_check_parsed(void *parsed_result,
5385 __rte_unused struct cmdline *cl,
5386 __rte_unused void *data)
5388 struct cmd_set_link_check *res = parsed_result;
5389 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5392 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5393 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5395 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5396 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5397 link_check, "link_check");
5398 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5399 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5403 cmdline_parse_inst_t cmd_set_link_check = {
5404 .f = cmd_set_link_check_parsed,
5405 .help_str = "set link_check on|off: Enable/Disable link status check "
5406 "when starting/stopping a port",
5409 (void *)&cmd_setlinkcheck_set,
5410 (void *)&cmd_setlinkcheck_link_check,
5411 (void *)&cmd_setlinkcheck_mode,
5416 /* *** SET NIC BYPASS MODE *** */
5417 struct cmd_set_bypass_mode_result {
5418 cmdline_fixed_string_t set;
5419 cmdline_fixed_string_t bypass;
5420 cmdline_fixed_string_t mode;
5421 cmdline_fixed_string_t value;
5426 cmd_set_bypass_mode_parsed(void *parsed_result,
5427 __rte_unused struct cmdline *cl,
5428 __rte_unused void *data)
5430 struct cmd_set_bypass_mode_result *res = parsed_result;
5431 portid_t port_id = res->port_id;
5432 int32_t rc = -EINVAL;
5434 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5435 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5437 if (!strcmp(res->value, "bypass"))
5438 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5439 else if (!strcmp(res->value, "isolate"))
5440 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5442 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5444 /* Set the bypass mode for the relevant port. */
5445 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5448 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5451 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5452 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5454 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5455 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5457 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5458 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5460 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5461 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5462 value, "normal#bypass#isolate");
5463 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5464 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5467 cmdline_parse_inst_t cmd_set_bypass_mode = {
5468 .f = cmd_set_bypass_mode_parsed,
5469 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5470 "Set the NIC bypass mode for port_id",
5473 (void *)&cmd_setbypass_mode_set,
5474 (void *)&cmd_setbypass_mode_bypass,
5475 (void *)&cmd_setbypass_mode_mode,
5476 (void *)&cmd_setbypass_mode_value,
5477 (void *)&cmd_setbypass_mode_port,
5482 /* *** SET NIC BYPASS EVENT *** */
5483 struct cmd_set_bypass_event_result {
5484 cmdline_fixed_string_t set;
5485 cmdline_fixed_string_t bypass;
5486 cmdline_fixed_string_t event;
5487 cmdline_fixed_string_t event_value;
5488 cmdline_fixed_string_t mode;
5489 cmdline_fixed_string_t mode_value;
5494 cmd_set_bypass_event_parsed(void *parsed_result,
5495 __rte_unused struct cmdline *cl,
5496 __rte_unused void *data)
5498 int32_t rc = -EINVAL;
5499 struct cmd_set_bypass_event_result *res = parsed_result;
5500 portid_t port_id = res->port_id;
5502 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5503 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5504 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5506 if (!strcmp(res->event_value, "timeout"))
5507 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5508 else if (!strcmp(res->event_value, "os_on"))
5509 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5510 else if (!strcmp(res->event_value, "os_off"))
5511 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5512 else if (!strcmp(res->event_value, "power_on"))
5513 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5514 else if (!strcmp(res->event_value, "power_off"))
5515 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5517 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5519 if (!strcmp(res->mode_value, "bypass"))
5520 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5521 else if (!strcmp(res->mode_value, "isolate"))
5522 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5524 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5526 /* Set the watchdog timeout. */
5527 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5530 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5531 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5535 printf("Failed to set timeout value %u "
5536 "for port %d, errto code: %d.\n",
5537 bypass_timeout, port_id, rc);
5541 /* Set the bypass event to transition to bypass mode. */
5542 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5547 printf("\t Failed to set bypass event for port = %d.\n",
5551 cmdline_parse_token_string_t cmd_setbypass_event_set =
5552 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5554 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5555 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5557 cmdline_parse_token_string_t cmd_setbypass_event_event =
5558 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5560 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5561 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5562 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5563 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5564 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5566 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5567 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5568 mode_value, "normal#bypass#isolate");
5569 cmdline_parse_token_num_t cmd_setbypass_event_port =
5570 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5573 cmdline_parse_inst_t cmd_set_bypass_event = {
5574 .f = cmd_set_bypass_event_parsed,
5575 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5576 "power_off mode normal|bypass|isolate <port_id>: "
5577 "Set the NIC bypass event mode for port_id",
5580 (void *)&cmd_setbypass_event_set,
5581 (void *)&cmd_setbypass_event_bypass,
5582 (void *)&cmd_setbypass_event_event,
5583 (void *)&cmd_setbypass_event_event_value,
5584 (void *)&cmd_setbypass_event_mode,
5585 (void *)&cmd_setbypass_event_mode_value,
5586 (void *)&cmd_setbypass_event_port,
5592 /* *** SET NIC BYPASS TIMEOUT *** */
5593 struct cmd_set_bypass_timeout_result {
5594 cmdline_fixed_string_t set;
5595 cmdline_fixed_string_t bypass;
5596 cmdline_fixed_string_t timeout;
5597 cmdline_fixed_string_t value;
5601 cmd_set_bypass_timeout_parsed(void *parsed_result,
5602 __rte_unused struct cmdline *cl,
5603 __rte_unused void *data)
5605 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5607 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5608 if (!strcmp(res->value, "1.5"))
5609 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5610 else if (!strcmp(res->value, "2"))
5611 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5612 else if (!strcmp(res->value, "3"))
5613 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5614 else if (!strcmp(res->value, "4"))
5615 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5616 else if (!strcmp(res->value, "8"))
5617 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5618 else if (!strcmp(res->value, "16"))
5619 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5620 else if (!strcmp(res->value, "32"))
5621 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5623 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5627 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5628 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5630 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5631 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5633 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5634 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5635 timeout, "timeout");
5636 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5637 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5638 value, "0#1.5#2#3#4#8#16#32");
5640 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5641 .f = cmd_set_bypass_timeout_parsed,
5642 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5643 "Set the NIC bypass watchdog timeout in seconds",
5646 (void *)&cmd_setbypass_timeout_set,
5647 (void *)&cmd_setbypass_timeout_bypass,
5648 (void *)&cmd_setbypass_timeout_timeout,
5649 (void *)&cmd_setbypass_timeout_value,
5654 /* *** SHOW NIC BYPASS MODE *** */
5655 struct cmd_show_bypass_config_result {
5656 cmdline_fixed_string_t show;
5657 cmdline_fixed_string_t bypass;
5658 cmdline_fixed_string_t config;
5663 cmd_show_bypass_config_parsed(void *parsed_result,
5664 __rte_unused struct cmdline *cl,
5665 __rte_unused void *data)
5667 struct cmd_show_bypass_config_result *res = parsed_result;
5668 portid_t port_id = res->port_id;
5670 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5671 uint32_t event_mode;
5672 uint32_t bypass_mode;
5673 uint32_t timeout = bypass_timeout;
5676 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5677 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5678 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5679 {"UNKNOWN", "normal", "bypass", "isolate"};
5680 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5688 /* Display the bypass mode.*/
5689 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5690 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5694 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5695 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5697 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5700 /* Display the bypass timeout.*/
5701 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5702 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5704 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5706 /* Display the bypass events and associated modes. */
5707 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5709 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5710 printf("\tFailed to get bypass mode for event = %s\n",
5713 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5714 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5716 printf("\tbypass event: %-16s = %s\n", events[i],
5722 printf("\tFailed to get bypass configuration for port = %d\n",
5726 cmdline_parse_token_string_t cmd_showbypass_config_show =
5727 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5729 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5730 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5732 cmdline_parse_token_string_t cmd_showbypass_config_config =
5733 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5735 cmdline_parse_token_num_t cmd_showbypass_config_port =
5736 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5739 cmdline_parse_inst_t cmd_show_bypass_config = {
5740 .f = cmd_show_bypass_config_parsed,
5741 .help_str = "show bypass config <port_id>: "
5742 "Show the NIC bypass config for port_id",
5745 (void *)&cmd_showbypass_config_show,
5746 (void *)&cmd_showbypass_config_bypass,
5747 (void *)&cmd_showbypass_config_config,
5748 (void *)&cmd_showbypass_config_port,
5754 /* *** SET BONDING MODE *** */
5755 struct cmd_set_bonding_mode_result {
5756 cmdline_fixed_string_t set;
5757 cmdline_fixed_string_t bonding;
5758 cmdline_fixed_string_t mode;
5763 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5764 __rte_unused struct cmdline *cl,
5765 __rte_unused void *data)
5767 struct cmd_set_bonding_mode_result *res = parsed_result;
5768 portid_t port_id = res->port_id;
5770 /* Set the bonding mode for the relevant port. */
5771 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5772 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5775 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5776 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5778 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5779 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5780 bonding, "bonding");
5781 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5782 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5784 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5785 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5787 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5788 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5791 cmdline_parse_inst_t cmd_set_bonding_mode = {
5792 .f = cmd_set_bonding_mode_parsed,
5793 .help_str = "set bonding mode <mode_value> <port_id>: "
5794 "Set the bonding mode for port_id",
5797 (void *) &cmd_setbonding_mode_set,
5798 (void *) &cmd_setbonding_mode_bonding,
5799 (void *) &cmd_setbonding_mode_mode,
5800 (void *) &cmd_setbonding_mode_value,
5801 (void *) &cmd_setbonding_mode_port,
5806 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5807 struct cmd_set_bonding_lacp_dedicated_queues_result {
5808 cmdline_fixed_string_t set;
5809 cmdline_fixed_string_t bonding;
5810 cmdline_fixed_string_t lacp;
5811 cmdline_fixed_string_t dedicated_queues;
5813 cmdline_fixed_string_t mode;
5816 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5817 __rte_unused struct cmdline *cl,
5818 __rte_unused void *data)
5820 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5821 portid_t port_id = res->port_id;
5822 struct rte_port *port;
5824 port = &ports[port_id];
5826 /** Check if the port is not started **/
5827 if (port->port_status != RTE_PORT_STOPPED) {
5828 printf("Please stop port %d first\n", port_id);
5832 if (!strcmp(res->mode, "enable")) {
5833 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5834 printf("Dedicate queues for LACP control packets"
5837 printf("Enabling dedicate queues for LACP control "
5838 "packets on port %d failed\n", port_id);
5839 } else if (!strcmp(res->mode, "disable")) {
5840 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5841 printf("Dedicated queues for LACP control packets "
5844 printf("Disabling dedicated queues for LACP control "
5845 "traffic on port %d failed\n", port_id);
5849 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5850 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5852 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5853 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5854 bonding, "bonding");
5855 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5856 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5858 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5859 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5860 dedicated_queues, "dedicated_queues");
5861 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5862 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5864 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5865 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5866 mode, "enable#disable");
5868 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5869 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5870 .help_str = "set bonding lacp dedicated_queues <port_id> "
5872 "Enable/disable dedicated queues for LACP control traffic for port_id",
5875 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5876 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5877 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5878 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5879 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5880 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5885 /* *** SET BALANCE XMIT POLICY *** */
5886 struct cmd_set_bonding_balance_xmit_policy_result {
5887 cmdline_fixed_string_t set;
5888 cmdline_fixed_string_t bonding;
5889 cmdline_fixed_string_t balance_xmit_policy;
5891 cmdline_fixed_string_t policy;
5894 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5895 __rte_unused struct cmdline *cl,
5896 __rte_unused void *data)
5898 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5899 portid_t port_id = res->port_id;
5902 if (!strcmp(res->policy, "l2")) {
5903 policy = BALANCE_XMIT_POLICY_LAYER2;
5904 } else if (!strcmp(res->policy, "l23")) {
5905 policy = BALANCE_XMIT_POLICY_LAYER23;
5906 } else if (!strcmp(res->policy, "l34")) {
5907 policy = BALANCE_XMIT_POLICY_LAYER34;
5909 printf("\t Invalid xmit policy selection");
5913 /* Set the bonding mode for the relevant port. */
5914 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5915 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5920 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5921 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5923 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5924 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5925 bonding, "bonding");
5926 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5927 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5928 balance_xmit_policy, "balance_xmit_policy");
5929 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5930 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5932 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5933 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5934 policy, "l2#l23#l34");
5936 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5937 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5938 .help_str = "set bonding balance_xmit_policy <port_id> "
5940 "Set the bonding balance_xmit_policy for port_id",
5943 (void *)&cmd_setbonding_balance_xmit_policy_set,
5944 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5945 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5946 (void *)&cmd_setbonding_balance_xmit_policy_port,
5947 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5952 /* *** SHOW NIC BONDING CONFIGURATION *** */
5953 struct cmd_show_bonding_config_result {
5954 cmdline_fixed_string_t show;
5955 cmdline_fixed_string_t bonding;
5956 cmdline_fixed_string_t config;
5960 static void cmd_show_bonding_config_parsed(void *parsed_result,
5961 __rte_unused struct cmdline *cl,
5962 __rte_unused void *data)
5964 struct cmd_show_bonding_config_result *res = parsed_result;
5965 int bonding_mode, agg_mode;
5966 portid_t slaves[RTE_MAX_ETHPORTS];
5967 int num_slaves, num_active_slaves;
5970 portid_t port_id = res->port_id;
5972 /* Display the bonding mode.*/
5973 bonding_mode = rte_eth_bond_mode_get(port_id);
5974 if (bonding_mode < 0) {
5975 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5978 printf("\tBonding mode: %d\n", bonding_mode);
5980 if (bonding_mode == BONDING_MODE_BALANCE) {
5981 int balance_xmit_policy;
5983 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5984 if (balance_xmit_policy < 0) {
5985 printf("\tFailed to get balance xmit policy for port = %d\n",
5989 printf("\tBalance Xmit Policy: ");
5991 switch (balance_xmit_policy) {
5992 case BALANCE_XMIT_POLICY_LAYER2:
5993 printf("BALANCE_XMIT_POLICY_LAYER2");
5995 case BALANCE_XMIT_POLICY_LAYER23:
5996 printf("BALANCE_XMIT_POLICY_LAYER23");
5998 case BALANCE_XMIT_POLICY_LAYER34:
5999 printf("BALANCE_XMIT_POLICY_LAYER34");
6006 if (bonding_mode == BONDING_MODE_8023AD) {
6007 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6008 printf("\tIEEE802.3AD Aggregator Mode: ");
6011 printf("bandwidth");
6023 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6025 if (num_slaves < 0) {
6026 printf("\tFailed to get slave list for port = %d\n", port_id);
6029 if (num_slaves > 0) {
6030 printf("\tSlaves (%d): [", num_slaves);
6031 for (i = 0; i < num_slaves - 1; i++)
6032 printf("%d ", slaves[i]);
6034 printf("%d]\n", slaves[num_slaves - 1]);
6036 printf("\tSlaves: []\n");
6040 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6043 if (num_active_slaves < 0) {
6044 printf("\tFailed to get active slave list for port = %d\n", port_id);
6047 if (num_active_slaves > 0) {
6048 printf("\tActive Slaves (%d): [", num_active_slaves);
6049 for (i = 0; i < num_active_slaves - 1; i++)
6050 printf("%d ", slaves[i]);
6052 printf("%d]\n", slaves[num_active_slaves - 1]);
6055 printf("\tActive Slaves: []\n");
6059 primary_id = rte_eth_bond_primary_get(port_id);
6060 if (primary_id < 0) {
6061 printf("\tFailed to get primary slave for port = %d\n", port_id);
6064 printf("\tPrimary: [%d]\n", primary_id);
6068 cmdline_parse_token_string_t cmd_showbonding_config_show =
6069 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6071 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6072 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6073 bonding, "bonding");
6074 cmdline_parse_token_string_t cmd_showbonding_config_config =
6075 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6077 cmdline_parse_token_num_t cmd_showbonding_config_port =
6078 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6081 cmdline_parse_inst_t cmd_show_bonding_config = {
6082 .f = cmd_show_bonding_config_parsed,
6083 .help_str = "show bonding config <port_id>: "
6084 "Show the bonding config for port_id",
6087 (void *)&cmd_showbonding_config_show,
6088 (void *)&cmd_showbonding_config_bonding,
6089 (void *)&cmd_showbonding_config_config,
6090 (void *)&cmd_showbonding_config_port,
6095 /* *** SET BONDING PRIMARY *** */
6096 struct cmd_set_bonding_primary_result {
6097 cmdline_fixed_string_t set;
6098 cmdline_fixed_string_t bonding;
6099 cmdline_fixed_string_t primary;
6104 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6105 __rte_unused struct cmdline *cl,
6106 __rte_unused void *data)
6108 struct cmd_set_bonding_primary_result *res = parsed_result;
6109 portid_t master_port_id = res->port_id;
6110 portid_t slave_port_id = res->slave_id;
6112 /* Set the primary slave for a bonded device. */
6113 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6114 printf("\t Failed to set primary slave for port = %d.\n",
6121 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6122 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6124 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6125 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6126 bonding, "bonding");
6127 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6128 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6129 primary, "primary");
6130 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6131 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6133 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6134 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6137 cmdline_parse_inst_t cmd_set_bonding_primary = {
6138 .f = cmd_set_bonding_primary_parsed,
6139 .help_str = "set bonding primary <slave_id> <port_id>: "
6140 "Set the primary slave for port_id",
6143 (void *)&cmd_setbonding_primary_set,
6144 (void *)&cmd_setbonding_primary_bonding,
6145 (void *)&cmd_setbonding_primary_primary,
6146 (void *)&cmd_setbonding_primary_slave,
6147 (void *)&cmd_setbonding_primary_port,
6152 /* *** ADD SLAVE *** */
6153 struct cmd_add_bonding_slave_result {
6154 cmdline_fixed_string_t add;
6155 cmdline_fixed_string_t bonding;
6156 cmdline_fixed_string_t slave;
6161 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6162 __rte_unused struct cmdline *cl,
6163 __rte_unused void *data)
6165 struct cmd_add_bonding_slave_result *res = parsed_result;
6166 portid_t master_port_id = res->port_id;
6167 portid_t slave_port_id = res->slave_id;
6169 /* add the slave for a bonded device. */
6170 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6171 printf("\t Failed to add slave %d to master port = %d.\n",
6172 slave_port_id, master_port_id);
6176 set_port_slave_flag(slave_port_id);
6179 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6180 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6182 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6183 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6184 bonding, "bonding");
6185 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6186 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6188 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6189 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6191 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6192 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6195 cmdline_parse_inst_t cmd_add_bonding_slave = {
6196 .f = cmd_add_bonding_slave_parsed,
6197 .help_str = "add bonding slave <slave_id> <port_id>: "
6198 "Add a slave device to a bonded device",
6201 (void *)&cmd_addbonding_slave_add,
6202 (void *)&cmd_addbonding_slave_bonding,
6203 (void *)&cmd_addbonding_slave_slave,
6204 (void *)&cmd_addbonding_slave_slaveid,
6205 (void *)&cmd_addbonding_slave_port,
6210 /* *** REMOVE SLAVE *** */
6211 struct cmd_remove_bonding_slave_result {
6212 cmdline_fixed_string_t remove;
6213 cmdline_fixed_string_t bonding;
6214 cmdline_fixed_string_t slave;
6219 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6220 __rte_unused struct cmdline *cl,
6221 __rte_unused void *data)
6223 struct cmd_remove_bonding_slave_result *res = parsed_result;
6224 portid_t master_port_id = res->port_id;
6225 portid_t slave_port_id = res->slave_id;
6227 /* remove the slave from a bonded device. */
6228 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6229 printf("\t Failed to remove slave %d from master port = %d.\n",
6230 slave_port_id, master_port_id);
6234 clear_port_slave_flag(slave_port_id);
6237 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6238 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6240 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6241 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6242 bonding, "bonding");
6243 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6244 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6246 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6247 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6249 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6250 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6253 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6254 .f = cmd_remove_bonding_slave_parsed,
6255 .help_str = "remove bonding slave <slave_id> <port_id>: "
6256 "Remove a slave device from a bonded device",
6259 (void *)&cmd_removebonding_slave_remove,
6260 (void *)&cmd_removebonding_slave_bonding,
6261 (void *)&cmd_removebonding_slave_slave,
6262 (void *)&cmd_removebonding_slave_slaveid,
6263 (void *)&cmd_removebonding_slave_port,
6268 /* *** CREATE BONDED DEVICE *** */
6269 struct cmd_create_bonded_device_result {
6270 cmdline_fixed_string_t create;
6271 cmdline_fixed_string_t bonded;
6272 cmdline_fixed_string_t device;
6277 static int bond_dev_num = 0;
6279 static void cmd_create_bonded_device_parsed(void *parsed_result,
6280 __rte_unused struct cmdline *cl,
6281 __rte_unused void *data)
6283 struct cmd_create_bonded_device_result *res = parsed_result;
6284 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6288 if (test_done == 0) {
6289 printf("Please stop forwarding first\n");
6293 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6296 /* Create a new bonded device. */
6297 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6299 printf("\t Failed to create bonded device.\n");
6302 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6305 /* Update number of ports */
6306 nb_ports = rte_eth_dev_count_avail();
6307 reconfig(port_id, res->socket);
6308 ret = rte_eth_promiscuous_enable(port_id);
6310 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6311 port_id, rte_strerror(-ret));
6313 ports[port_id].need_setup = 0;
6314 ports[port_id].port_status = RTE_PORT_STOPPED;
6319 cmdline_parse_token_string_t cmd_createbonded_device_create =
6320 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6322 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6323 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6325 cmdline_parse_token_string_t cmd_createbonded_device_device =
6326 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6328 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6329 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6331 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6332 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6335 cmdline_parse_inst_t cmd_create_bonded_device = {
6336 .f = cmd_create_bonded_device_parsed,
6337 .help_str = "create bonded device <mode> <socket>: "
6338 "Create a new bonded device with specific bonding mode and socket",
6341 (void *)&cmd_createbonded_device_create,
6342 (void *)&cmd_createbonded_device_bonded,
6343 (void *)&cmd_createbonded_device_device,
6344 (void *)&cmd_createbonded_device_mode,
6345 (void *)&cmd_createbonded_device_socket,
6350 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6351 struct cmd_set_bond_mac_addr_result {
6352 cmdline_fixed_string_t set;
6353 cmdline_fixed_string_t bonding;
6354 cmdline_fixed_string_t mac_addr;
6356 struct rte_ether_addr address;
6359 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6360 __rte_unused struct cmdline *cl,
6361 __rte_unused void *data)
6363 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6366 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6369 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6371 /* check the return value and print it if is < 0 */
6373 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6376 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6377 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6378 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6379 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6381 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6382 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6384 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6385 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6387 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6388 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6390 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6391 .f = cmd_set_bond_mac_addr_parsed,
6393 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6395 (void *)&cmd_set_bond_mac_addr_set,
6396 (void *)&cmd_set_bond_mac_addr_bonding,
6397 (void *)&cmd_set_bond_mac_addr_mac,
6398 (void *)&cmd_set_bond_mac_addr_portnum,
6399 (void *)&cmd_set_bond_mac_addr_addr,
6405 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6406 struct cmd_set_bond_mon_period_result {
6407 cmdline_fixed_string_t set;
6408 cmdline_fixed_string_t bonding;
6409 cmdline_fixed_string_t mon_period;
6414 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6415 __rte_unused struct cmdline *cl,
6416 __rte_unused void *data)
6418 struct cmd_set_bond_mon_period_result *res = parsed_result;
6421 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6423 /* check the return value and print it if is < 0 */
6425 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6428 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6429 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6431 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6432 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6433 bonding, "bonding");
6434 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6435 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6436 mon_period, "mon_period");
6437 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6438 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6440 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6441 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6444 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6445 .f = cmd_set_bond_mon_period_parsed,
6447 .help_str = "set bonding mon_period <port_id> <period_ms>",
6449 (void *)&cmd_set_bond_mon_period_set,
6450 (void *)&cmd_set_bond_mon_period_bonding,
6451 (void *)&cmd_set_bond_mon_period_mon_period,
6452 (void *)&cmd_set_bond_mon_period_portnum,
6453 (void *)&cmd_set_bond_mon_period_period_ms,
6460 struct cmd_set_bonding_agg_mode_policy_result {
6461 cmdline_fixed_string_t set;
6462 cmdline_fixed_string_t bonding;
6463 cmdline_fixed_string_t agg_mode;
6465 cmdline_fixed_string_t policy;
6470 cmd_set_bonding_agg_mode(void *parsed_result,
6471 __rte_unused struct cmdline *cl,
6472 __rte_unused void *data)
6474 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6475 uint8_t policy = AGG_BANDWIDTH;
6477 if (!strcmp(res->policy, "bandwidth"))
6478 policy = AGG_BANDWIDTH;
6479 else if (!strcmp(res->policy, "stable"))
6480 policy = AGG_STABLE;
6481 else if (!strcmp(res->policy, "count"))
6484 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6488 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6489 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6491 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6492 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6493 bonding, "bonding");
6495 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6496 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6497 agg_mode, "agg_mode");
6499 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6500 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6503 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6504 TOKEN_STRING_INITIALIZER(
6505 struct cmd_set_bonding_balance_xmit_policy_result,
6506 policy, "stable#bandwidth#count");
6508 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6509 .f = cmd_set_bonding_agg_mode,
6511 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6513 (void *)&cmd_set_bonding_agg_mode_set,
6514 (void *)&cmd_set_bonding_agg_mode_bonding,
6515 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6516 (void *)&cmd_set_bonding_agg_mode_portnum,
6517 (void *)&cmd_set_bonding_agg_mode_policy_string,
6523 #endif /* RTE_NET_BOND */
6525 /* *** SET FORWARDING MODE *** */
6526 struct cmd_set_fwd_mode_result {
6527 cmdline_fixed_string_t set;
6528 cmdline_fixed_string_t fwd;
6529 cmdline_fixed_string_t mode;
6532 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6533 __rte_unused struct cmdline *cl,
6534 __rte_unused void *data)
6536 struct cmd_set_fwd_mode_result *res = parsed_result;
6539 set_pkt_forwarding_mode(res->mode);
6542 cmdline_parse_token_string_t cmd_setfwd_set =
6543 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6544 cmdline_parse_token_string_t cmd_setfwd_fwd =
6545 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6546 cmdline_parse_token_string_t cmd_setfwd_mode =
6547 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6548 "" /* defined at init */);
6550 cmdline_parse_inst_t cmd_set_fwd_mode = {
6551 .f = cmd_set_fwd_mode_parsed,
6553 .help_str = NULL, /* defined at init */
6555 (void *)&cmd_setfwd_set,
6556 (void *)&cmd_setfwd_fwd,
6557 (void *)&cmd_setfwd_mode,
6562 static void cmd_set_fwd_mode_init(void)
6565 static char token[128];
6566 static char help[256];
6567 cmdline_parse_token_string_t *token_struct;
6569 modes = list_pkt_forwarding_modes();
6570 snprintf(help, sizeof(help), "set fwd %s: "
6571 "Set packet forwarding mode", modes);
6572 cmd_set_fwd_mode.help_str = help;
6574 /* string token separator is # */
6575 for (c = token; *modes != '\0'; modes++)
6580 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6581 token_struct->string_data.str = token;
6584 /* *** SET RETRY FORWARDING MODE *** */
6585 struct cmd_set_fwd_retry_mode_result {
6586 cmdline_fixed_string_t set;
6587 cmdline_fixed_string_t fwd;
6588 cmdline_fixed_string_t mode;
6589 cmdline_fixed_string_t retry;
6592 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6593 __rte_unused struct cmdline *cl,
6594 __rte_unused void *data)
6596 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6599 set_pkt_forwarding_mode(res->mode);
6602 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6603 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6605 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6606 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6608 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6609 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6611 "" /* defined at init */);
6612 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6613 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6616 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6617 .f = cmd_set_fwd_retry_mode_parsed,
6619 .help_str = NULL, /* defined at init */
6621 (void *)&cmd_setfwd_retry_set,
6622 (void *)&cmd_setfwd_retry_fwd,
6623 (void *)&cmd_setfwd_retry_mode,
6624 (void *)&cmd_setfwd_retry_retry,
6629 static void cmd_set_fwd_retry_mode_init(void)
6632 static char token[128];
6633 static char help[256];
6634 cmdline_parse_token_string_t *token_struct;
6636 modes = list_pkt_forwarding_retry_modes();
6637 snprintf(help, sizeof(help), "set fwd %s retry: "
6638 "Set packet forwarding mode with retry", modes);
6639 cmd_set_fwd_retry_mode.help_str = help;
6641 /* string token separator is # */
6642 for (c = token; *modes != '\0'; modes++)
6647 token_struct = (cmdline_parse_token_string_t *)
6648 cmd_set_fwd_retry_mode.tokens[2];
6649 token_struct->string_data.str = token;
6652 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6653 struct cmd_set_burst_tx_retry_result {
6654 cmdline_fixed_string_t set;
6655 cmdline_fixed_string_t burst;
6656 cmdline_fixed_string_t tx;
6657 cmdline_fixed_string_t delay;
6659 cmdline_fixed_string_t retry;
6663 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6664 __rte_unused struct cmdline *cl,
6665 __rte_unused void *data)
6667 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6669 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6670 && !strcmp(res->tx, "tx")) {
6671 if (!strcmp(res->delay, "delay"))
6672 burst_tx_delay_time = res->time;
6673 if (!strcmp(res->retry, "retry"))
6674 burst_tx_retry_num = res->retry_num;
6679 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6680 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6681 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6682 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6684 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6685 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6686 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6687 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6688 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6689 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6690 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6691 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6692 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6693 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6695 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6696 .f = cmd_set_burst_tx_retry_parsed,
6697 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6699 (void *)&cmd_set_burst_tx_retry_set,
6700 (void *)&cmd_set_burst_tx_retry_burst,
6701 (void *)&cmd_set_burst_tx_retry_tx,
6702 (void *)&cmd_set_burst_tx_retry_delay,
6703 (void *)&cmd_set_burst_tx_retry_time,
6704 (void *)&cmd_set_burst_tx_retry_retry,
6705 (void *)&cmd_set_burst_tx_retry_retry_num,
6710 /* *** SET PROMISC MODE *** */
6711 struct cmd_set_promisc_mode_result {
6712 cmdline_fixed_string_t set;
6713 cmdline_fixed_string_t promisc;
6714 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6715 uint16_t port_num; /* valid if "allports" argument == 0 */
6716 cmdline_fixed_string_t mode;
6719 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6720 __rte_unused struct cmdline *cl,
6723 struct cmd_set_promisc_mode_result *res = parsed_result;
6727 if (!strcmp(res->mode, "on"))
6734 RTE_ETH_FOREACH_DEV(i)
6735 eth_set_promisc_mode(i, enable);
6737 eth_set_promisc_mode(res->port_num, enable);
6741 cmdline_parse_token_string_t cmd_setpromisc_set =
6742 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6743 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6744 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6746 cmdline_parse_token_string_t cmd_setpromisc_portall =
6747 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6749 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6750 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6752 cmdline_parse_token_string_t cmd_setpromisc_mode =
6753 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6756 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6757 .f = cmd_set_promisc_mode_parsed,
6759 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6761 (void *)&cmd_setpromisc_set,
6762 (void *)&cmd_setpromisc_promisc,
6763 (void *)&cmd_setpromisc_portall,
6764 (void *)&cmd_setpromisc_mode,
6769 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6770 .f = cmd_set_promisc_mode_parsed,
6772 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6774 (void *)&cmd_setpromisc_set,
6775 (void *)&cmd_setpromisc_promisc,
6776 (void *)&cmd_setpromisc_portnum,
6777 (void *)&cmd_setpromisc_mode,
6782 /* *** SET ALLMULTI MODE *** */
6783 struct cmd_set_allmulti_mode_result {
6784 cmdline_fixed_string_t set;
6785 cmdline_fixed_string_t allmulti;
6786 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6787 uint16_t port_num; /* valid if "allports" argument == 0 */
6788 cmdline_fixed_string_t mode;
6791 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6792 __rte_unused struct cmdline *cl,
6795 struct cmd_set_allmulti_mode_result *res = parsed_result;
6799 if (!strcmp(res->mode, "on"))
6806 RTE_ETH_FOREACH_DEV(i) {
6807 eth_set_allmulticast_mode(i, enable);
6811 eth_set_allmulticast_mode(res->port_num, enable);
6815 cmdline_parse_token_string_t cmd_setallmulti_set =
6816 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6817 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6818 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6820 cmdline_parse_token_string_t cmd_setallmulti_portall =
6821 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6823 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6824 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6826 cmdline_parse_token_string_t cmd_setallmulti_mode =
6827 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6830 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6831 .f = cmd_set_allmulti_mode_parsed,
6833 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6835 (void *)&cmd_setallmulti_set,
6836 (void *)&cmd_setallmulti_allmulti,
6837 (void *)&cmd_setallmulti_portall,
6838 (void *)&cmd_setallmulti_mode,
6843 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6844 .f = cmd_set_allmulti_mode_parsed,
6846 .help_str = "set allmulti <port_id> on|off: "
6847 "Set allmulti mode on port_id",
6849 (void *)&cmd_setallmulti_set,
6850 (void *)&cmd_setallmulti_allmulti,
6851 (void *)&cmd_setallmulti_portnum,
6852 (void *)&cmd_setallmulti_mode,
6857 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6858 struct cmd_link_flow_ctrl_set_result {
6859 cmdline_fixed_string_t set;
6860 cmdline_fixed_string_t flow_ctrl;
6861 cmdline_fixed_string_t rx;
6862 cmdline_fixed_string_t rx_lfc_mode;
6863 cmdline_fixed_string_t tx;
6864 cmdline_fixed_string_t tx_lfc_mode;
6865 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6866 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6867 cmdline_fixed_string_t autoneg_str;
6868 cmdline_fixed_string_t autoneg;
6869 cmdline_fixed_string_t hw_str;
6870 uint32_t high_water;
6871 cmdline_fixed_string_t lw_str;
6873 cmdline_fixed_string_t pt_str;
6874 uint16_t pause_time;
6875 cmdline_fixed_string_t xon_str;
6880 cmdline_parse_token_string_t cmd_lfc_set_set =
6881 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6883 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6884 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6885 flow_ctrl, "flow_ctrl");
6886 cmdline_parse_token_string_t cmd_lfc_set_rx =
6887 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6889 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6890 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6891 rx_lfc_mode, "on#off");
6892 cmdline_parse_token_string_t cmd_lfc_set_tx =
6893 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6895 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6896 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6897 tx_lfc_mode, "on#off");
6898 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6899 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6900 hw_str, "high_water");
6901 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6902 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6903 high_water, UINT32);
6904 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6905 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6906 lw_str, "low_water");
6907 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6908 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6910 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6911 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6912 pt_str, "pause_time");
6913 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6914 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6915 pause_time, UINT16);
6916 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6917 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6918 xon_str, "send_xon");
6919 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6920 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6922 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6923 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6924 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6925 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6926 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6927 mac_ctrl_frame_fwd_mode, "on#off");
6928 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6929 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6930 autoneg_str, "autoneg");
6931 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6932 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6934 cmdline_parse_token_num_t cmd_lfc_set_portid =
6935 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6938 /* forward declaration */
6940 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6943 cmdline_parse_inst_t cmd_link_flow_control_set = {
6944 .f = cmd_link_flow_ctrl_set_parsed,
6946 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6947 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6948 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6950 (void *)&cmd_lfc_set_set,
6951 (void *)&cmd_lfc_set_flow_ctrl,
6952 (void *)&cmd_lfc_set_rx,
6953 (void *)&cmd_lfc_set_rx_mode,
6954 (void *)&cmd_lfc_set_tx,
6955 (void *)&cmd_lfc_set_tx_mode,
6956 (void *)&cmd_lfc_set_high_water,
6957 (void *)&cmd_lfc_set_low_water,
6958 (void *)&cmd_lfc_set_pause_time,
6959 (void *)&cmd_lfc_set_send_xon,
6960 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6961 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6962 (void *)&cmd_lfc_set_autoneg_str,
6963 (void *)&cmd_lfc_set_autoneg,
6964 (void *)&cmd_lfc_set_portid,
6969 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6970 .f = cmd_link_flow_ctrl_set_parsed,
6971 .data = (void *)&cmd_link_flow_control_set_rx,
6972 .help_str = "set flow_ctrl rx on|off <port_id>: "
6973 "Change rx flow control parameter",
6975 (void *)&cmd_lfc_set_set,
6976 (void *)&cmd_lfc_set_flow_ctrl,
6977 (void *)&cmd_lfc_set_rx,
6978 (void *)&cmd_lfc_set_rx_mode,
6979 (void *)&cmd_lfc_set_portid,
6984 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6985 .f = cmd_link_flow_ctrl_set_parsed,
6986 .data = (void *)&cmd_link_flow_control_set_tx,
6987 .help_str = "set flow_ctrl tx on|off <port_id>: "
6988 "Change tx flow control parameter",
6990 (void *)&cmd_lfc_set_set,
6991 (void *)&cmd_lfc_set_flow_ctrl,
6992 (void *)&cmd_lfc_set_tx,
6993 (void *)&cmd_lfc_set_tx_mode,
6994 (void *)&cmd_lfc_set_portid,
6999 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7000 .f = cmd_link_flow_ctrl_set_parsed,
7001 .data = (void *)&cmd_link_flow_control_set_hw,
7002 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7003 "Change high water flow control parameter",
7005 (void *)&cmd_lfc_set_set,
7006 (void *)&cmd_lfc_set_flow_ctrl,
7007 (void *)&cmd_lfc_set_high_water_str,
7008 (void *)&cmd_lfc_set_high_water,
7009 (void *)&cmd_lfc_set_portid,
7014 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7015 .f = cmd_link_flow_ctrl_set_parsed,
7016 .data = (void *)&cmd_link_flow_control_set_lw,
7017 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7018 "Change low water flow control parameter",
7020 (void *)&cmd_lfc_set_set,
7021 (void *)&cmd_lfc_set_flow_ctrl,
7022 (void *)&cmd_lfc_set_low_water_str,
7023 (void *)&cmd_lfc_set_low_water,
7024 (void *)&cmd_lfc_set_portid,
7029 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7030 .f = cmd_link_flow_ctrl_set_parsed,
7031 .data = (void *)&cmd_link_flow_control_set_pt,
7032 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7033 "Change pause time flow control parameter",
7035 (void *)&cmd_lfc_set_set,
7036 (void *)&cmd_lfc_set_flow_ctrl,
7037 (void *)&cmd_lfc_set_pause_time_str,
7038 (void *)&cmd_lfc_set_pause_time,
7039 (void *)&cmd_lfc_set_portid,
7044 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7045 .f = cmd_link_flow_ctrl_set_parsed,
7046 .data = (void *)&cmd_link_flow_control_set_xon,
7047 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7048 "Change send_xon flow control parameter",
7050 (void *)&cmd_lfc_set_set,
7051 (void *)&cmd_lfc_set_flow_ctrl,
7052 (void *)&cmd_lfc_set_send_xon_str,
7053 (void *)&cmd_lfc_set_send_xon,
7054 (void *)&cmd_lfc_set_portid,
7059 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7060 .f = cmd_link_flow_ctrl_set_parsed,
7061 .data = (void *)&cmd_link_flow_control_set_macfwd,
7062 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7063 "Change mac ctrl fwd flow control parameter",
7065 (void *)&cmd_lfc_set_set,
7066 (void *)&cmd_lfc_set_flow_ctrl,
7067 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7068 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7069 (void *)&cmd_lfc_set_portid,
7074 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7075 .f = cmd_link_flow_ctrl_set_parsed,
7076 .data = (void *)&cmd_link_flow_control_set_autoneg,
7077 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7078 "Change autoneg flow control parameter",
7080 (void *)&cmd_lfc_set_set,
7081 (void *)&cmd_lfc_set_flow_ctrl,
7082 (void *)&cmd_lfc_set_autoneg_str,
7083 (void *)&cmd_lfc_set_autoneg,
7084 (void *)&cmd_lfc_set_portid,
7090 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7091 __rte_unused struct cmdline *cl,
7094 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7095 cmdline_parse_inst_t *cmd = data;
7096 struct rte_eth_fc_conf fc_conf;
7102 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7103 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7104 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7105 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7107 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7108 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7111 /* Partial command line, retrieve current configuration */
7113 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7115 printf("cannot get current flow ctrl parameters, return"
7116 "code = %d\n", ret);
7120 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7121 (fc_conf.mode == RTE_FC_FULL))
7123 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7124 (fc_conf.mode == RTE_FC_FULL))
7128 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7129 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7131 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7132 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7134 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7136 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7137 fc_conf.high_water = res->high_water;
7139 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7140 fc_conf.low_water = res->low_water;
7142 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7143 fc_conf.pause_time = res->pause_time;
7145 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7146 fc_conf.send_xon = res->send_xon;
7148 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7149 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7150 fc_conf.mac_ctrl_frame_fwd = 1;
7152 fc_conf.mac_ctrl_frame_fwd = 0;
7155 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7156 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7158 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7160 printf("bad flow contrl parameter, return code = %d \n", ret);
7163 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7164 struct cmd_priority_flow_ctrl_set_result {
7165 cmdline_fixed_string_t set;
7166 cmdline_fixed_string_t pfc_ctrl;
7167 cmdline_fixed_string_t rx;
7168 cmdline_fixed_string_t rx_pfc_mode;
7169 cmdline_fixed_string_t tx;
7170 cmdline_fixed_string_t tx_pfc_mode;
7171 uint32_t high_water;
7173 uint16_t pause_time;
7179 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7180 __rte_unused struct cmdline *cl,
7181 __rte_unused void *data)
7183 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7184 struct rte_eth_pfc_conf pfc_conf;
7185 int rx_fc_enable, tx_fc_enable;
7189 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7190 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7191 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7192 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7194 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7195 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7198 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7199 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7200 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7201 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7202 pfc_conf.fc.high_water = res->high_water;
7203 pfc_conf.fc.low_water = res->low_water;
7204 pfc_conf.fc.pause_time = res->pause_time;
7205 pfc_conf.priority = res->priority;
7207 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7209 printf("bad priority flow contrl parameter, return code = %d \n", ret);
7212 cmdline_parse_token_string_t cmd_pfc_set_set =
7213 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7215 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7216 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7217 pfc_ctrl, "pfc_ctrl");
7218 cmdline_parse_token_string_t cmd_pfc_set_rx =
7219 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7221 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7222 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7223 rx_pfc_mode, "on#off");
7224 cmdline_parse_token_string_t cmd_pfc_set_tx =
7225 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7227 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7228 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7229 tx_pfc_mode, "on#off");
7230 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7231 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7232 high_water, UINT32);
7233 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7234 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7236 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7237 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7238 pause_time, UINT16);
7239 cmdline_parse_token_num_t cmd_pfc_set_priority =
7240 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7242 cmdline_parse_token_num_t cmd_pfc_set_portid =
7243 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7246 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7247 .f = cmd_priority_flow_ctrl_set_parsed,
7249 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7250 "<pause_time> <priority> <port_id>: "
7251 "Configure the Ethernet priority flow control",
7253 (void *)&cmd_pfc_set_set,
7254 (void *)&cmd_pfc_set_flow_ctrl,
7255 (void *)&cmd_pfc_set_rx,
7256 (void *)&cmd_pfc_set_rx_mode,
7257 (void *)&cmd_pfc_set_tx,
7258 (void *)&cmd_pfc_set_tx_mode,
7259 (void *)&cmd_pfc_set_high_water,
7260 (void *)&cmd_pfc_set_low_water,
7261 (void *)&cmd_pfc_set_pause_time,
7262 (void *)&cmd_pfc_set_priority,
7263 (void *)&cmd_pfc_set_portid,
7268 /* *** RESET CONFIGURATION *** */
7269 struct cmd_reset_result {
7270 cmdline_fixed_string_t reset;
7271 cmdline_fixed_string_t def;
7274 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7276 __rte_unused void *data)
7278 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7279 set_def_fwd_config();
7282 cmdline_parse_token_string_t cmd_reset_set =
7283 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7284 cmdline_parse_token_string_t cmd_reset_def =
7285 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7288 cmdline_parse_inst_t cmd_reset = {
7289 .f = cmd_reset_parsed,
7291 .help_str = "set default: Reset default forwarding configuration",
7293 (void *)&cmd_reset_set,
7294 (void *)&cmd_reset_def,
7299 /* *** START FORWARDING *** */
7300 struct cmd_start_result {
7301 cmdline_fixed_string_t start;
7304 cmdline_parse_token_string_t cmd_start_start =
7305 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7307 static void cmd_start_parsed(__rte_unused void *parsed_result,
7308 __rte_unused struct cmdline *cl,
7309 __rte_unused void *data)
7311 start_packet_forwarding(0);
7314 cmdline_parse_inst_t cmd_start = {
7315 .f = cmd_start_parsed,
7317 .help_str = "start: Start packet forwarding",
7319 (void *)&cmd_start_start,
7324 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7325 struct cmd_start_tx_first_result {
7326 cmdline_fixed_string_t start;
7327 cmdline_fixed_string_t tx_first;
7331 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7332 __rte_unused struct cmdline *cl,
7333 __rte_unused void *data)
7335 start_packet_forwarding(1);
7338 cmdline_parse_token_string_t cmd_start_tx_first_start =
7339 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7341 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7342 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7343 tx_first, "tx_first");
7345 cmdline_parse_inst_t cmd_start_tx_first = {
7346 .f = cmd_start_tx_first_parsed,
7348 .help_str = "start tx_first: Start packet forwarding, "
7349 "after sending 1 burst of packets",
7351 (void *)&cmd_start_tx_first_start,
7352 (void *)&cmd_start_tx_first_tx_first,
7357 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7358 struct cmd_start_tx_first_n_result {
7359 cmdline_fixed_string_t start;
7360 cmdline_fixed_string_t tx_first;
7365 cmd_start_tx_first_n_parsed(void *parsed_result,
7366 __rte_unused struct cmdline *cl,
7367 __rte_unused void *data)
7369 struct cmd_start_tx_first_n_result *res = parsed_result;
7371 start_packet_forwarding(res->tx_num);
7374 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7375 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7377 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7378 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7379 tx_first, "tx_first");
7380 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7381 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7384 cmdline_parse_inst_t cmd_start_tx_first_n = {
7385 .f = cmd_start_tx_first_n_parsed,
7387 .help_str = "start tx_first <num>: "
7388 "packet forwarding, after sending <num> bursts of packets",
7390 (void *)&cmd_start_tx_first_n_start,
7391 (void *)&cmd_start_tx_first_n_tx_first,
7392 (void *)&cmd_start_tx_first_n_tx_num,
7397 /* *** SET LINK UP *** */
7398 struct cmd_set_link_up_result {
7399 cmdline_fixed_string_t set;
7400 cmdline_fixed_string_t link_up;
7401 cmdline_fixed_string_t port;
7405 cmdline_parse_token_string_t cmd_set_link_up_set =
7406 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7407 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7408 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7410 cmdline_parse_token_string_t cmd_set_link_up_port =
7411 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7412 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7413 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
7415 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7416 __rte_unused struct cmdline *cl,
7417 __rte_unused void *data)
7419 struct cmd_set_link_up_result *res = parsed_result;
7420 dev_set_link_up(res->port_id);
7423 cmdline_parse_inst_t cmd_set_link_up = {
7424 .f = cmd_set_link_up_parsed,
7426 .help_str = "set link-up port <port id>",
7428 (void *)&cmd_set_link_up_set,
7429 (void *)&cmd_set_link_up_link_up,
7430 (void *)&cmd_set_link_up_port,
7431 (void *)&cmd_set_link_up_port_id,
7436 /* *** SET LINK DOWN *** */
7437 struct cmd_set_link_down_result {
7438 cmdline_fixed_string_t set;
7439 cmdline_fixed_string_t link_down;
7440 cmdline_fixed_string_t port;
7444 cmdline_parse_token_string_t cmd_set_link_down_set =
7445 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7446 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7447 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7449 cmdline_parse_token_string_t cmd_set_link_down_port =
7450 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7451 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7452 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
7454 static void cmd_set_link_down_parsed(
7455 __rte_unused void *parsed_result,
7456 __rte_unused struct cmdline *cl,
7457 __rte_unused void *data)
7459 struct cmd_set_link_down_result *res = parsed_result;
7460 dev_set_link_down(res->port_id);
7463 cmdline_parse_inst_t cmd_set_link_down = {
7464 .f = cmd_set_link_down_parsed,
7466 .help_str = "set link-down port <port id>",
7468 (void *)&cmd_set_link_down_set,
7469 (void *)&cmd_set_link_down_link_down,
7470 (void *)&cmd_set_link_down_port,
7471 (void *)&cmd_set_link_down_port_id,
7476 /* *** SHOW CFG *** */
7477 struct cmd_showcfg_result {
7478 cmdline_fixed_string_t show;
7479 cmdline_fixed_string_t cfg;
7480 cmdline_fixed_string_t what;
7483 static void cmd_showcfg_parsed(void *parsed_result,
7484 __rte_unused struct cmdline *cl,
7485 __rte_unused void *data)
7487 struct cmd_showcfg_result *res = parsed_result;
7488 if (!strcmp(res->what, "rxtx"))
7489 rxtx_config_display();
7490 else if (!strcmp(res->what, "cores"))
7491 fwd_lcores_config_display();
7492 else if (!strcmp(res->what, "fwd"))
7493 pkt_fwd_config_display(&cur_fwd_config);
7494 else if (!strcmp(res->what, "rxoffs"))
7495 show_rx_pkt_offsets();
7496 else if (!strcmp(res->what, "rxpkts"))
7497 show_rx_pkt_segments();
7498 else if (!strcmp(res->what, "txpkts"))
7499 show_tx_pkt_segments();
7500 else if (!strcmp(res->what, "txtimes"))
7501 show_tx_pkt_times();
7504 cmdline_parse_token_string_t cmd_showcfg_show =
7505 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7506 cmdline_parse_token_string_t cmd_showcfg_port =
7507 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7508 cmdline_parse_token_string_t cmd_showcfg_what =
7509 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7510 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7512 cmdline_parse_inst_t cmd_showcfg = {
7513 .f = cmd_showcfg_parsed,
7515 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7517 (void *)&cmd_showcfg_show,
7518 (void *)&cmd_showcfg_port,
7519 (void *)&cmd_showcfg_what,
7524 /* *** SHOW ALL PORT INFO *** */
7525 struct cmd_showportall_result {
7526 cmdline_fixed_string_t show;
7527 cmdline_fixed_string_t port;
7528 cmdline_fixed_string_t what;
7529 cmdline_fixed_string_t all;
7532 static void cmd_showportall_parsed(void *parsed_result,
7533 __rte_unused struct cmdline *cl,
7534 __rte_unused void *data)
7538 struct cmd_showportall_result *res = parsed_result;
7539 if (!strcmp(res->show, "clear")) {
7540 if (!strcmp(res->what, "stats"))
7541 RTE_ETH_FOREACH_DEV(i)
7543 else if (!strcmp(res->what, "xstats"))
7544 RTE_ETH_FOREACH_DEV(i)
7545 nic_xstats_clear(i);
7546 } else if (!strcmp(res->what, "info"))
7547 RTE_ETH_FOREACH_DEV(i)
7548 port_infos_display(i);
7549 else if (!strcmp(res->what, "summary")) {
7550 port_summary_header_display();
7551 RTE_ETH_FOREACH_DEV(i)
7552 port_summary_display(i);
7554 else if (!strcmp(res->what, "stats"))
7555 RTE_ETH_FOREACH_DEV(i)
7556 nic_stats_display(i);
7557 else if (!strcmp(res->what, "xstats"))
7558 RTE_ETH_FOREACH_DEV(i)
7559 nic_xstats_display(i);
7560 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7561 else if (!strcmp(res->what, "fdir"))
7562 RTE_ETH_FOREACH_DEV(i)
7565 else if (!strcmp(res->what, "stat_qmap"))
7566 RTE_ETH_FOREACH_DEV(i)
7567 nic_stats_mapping_display(i);
7568 else if (!strcmp(res->what, "dcb_tc"))
7569 RTE_ETH_FOREACH_DEV(i)
7570 port_dcb_info_display(i);
7571 else if (!strcmp(res->what, "cap"))
7572 RTE_ETH_FOREACH_DEV(i)
7573 port_offload_cap_display(i);
7576 cmdline_parse_token_string_t cmd_showportall_show =
7577 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7579 cmdline_parse_token_string_t cmd_showportall_port =
7580 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7581 cmdline_parse_token_string_t cmd_showportall_what =
7582 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7583 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7584 cmdline_parse_token_string_t cmd_showportall_all =
7585 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7586 cmdline_parse_inst_t cmd_showportall = {
7587 .f = cmd_showportall_parsed,
7589 .help_str = "show|clear port "
7590 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7592 (void *)&cmd_showportall_show,
7593 (void *)&cmd_showportall_port,
7594 (void *)&cmd_showportall_what,
7595 (void *)&cmd_showportall_all,
7600 /* *** SHOW PORT INFO *** */
7601 struct cmd_showport_result {
7602 cmdline_fixed_string_t show;
7603 cmdline_fixed_string_t port;
7604 cmdline_fixed_string_t what;
7608 static void cmd_showport_parsed(void *parsed_result,
7609 __rte_unused struct cmdline *cl,
7610 __rte_unused void *data)
7612 struct cmd_showport_result *res = parsed_result;
7613 if (!strcmp(res->show, "clear")) {
7614 if (!strcmp(res->what, "stats"))
7615 nic_stats_clear(res->portnum);
7616 else if (!strcmp(res->what, "xstats"))
7617 nic_xstats_clear(res->portnum);
7618 } else if (!strcmp(res->what, "info"))
7619 port_infos_display(res->portnum);
7620 else if (!strcmp(res->what, "summary")) {
7621 port_summary_header_display();
7622 port_summary_display(res->portnum);
7624 else if (!strcmp(res->what, "stats"))
7625 nic_stats_display(res->portnum);
7626 else if (!strcmp(res->what, "xstats"))
7627 nic_xstats_display(res->portnum);
7628 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7629 else if (!strcmp(res->what, "fdir"))
7630 fdir_get_infos(res->portnum);
7632 else if (!strcmp(res->what, "stat_qmap"))
7633 nic_stats_mapping_display(res->portnum);
7634 else if (!strcmp(res->what, "dcb_tc"))
7635 port_dcb_info_display(res->portnum);
7636 else if (!strcmp(res->what, "cap"))
7637 port_offload_cap_display(res->portnum);
7640 cmdline_parse_token_string_t cmd_showport_show =
7641 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7643 cmdline_parse_token_string_t cmd_showport_port =
7644 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7645 cmdline_parse_token_string_t cmd_showport_what =
7646 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7647 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7648 cmdline_parse_token_num_t cmd_showport_portnum =
7649 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7651 cmdline_parse_inst_t cmd_showport = {
7652 .f = cmd_showport_parsed,
7654 .help_str = "show|clear port "
7655 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7658 (void *)&cmd_showport_show,
7659 (void *)&cmd_showport_port,
7660 (void *)&cmd_showport_what,
7661 (void *)&cmd_showport_portnum,
7666 /* *** SHOW DEVICE INFO *** */
7667 struct cmd_showdevice_result {
7668 cmdline_fixed_string_t show;
7669 cmdline_fixed_string_t device;
7670 cmdline_fixed_string_t what;
7671 cmdline_fixed_string_t identifier;
7674 static void cmd_showdevice_parsed(void *parsed_result,
7675 __rte_unused struct cmdline *cl,
7676 __rte_unused void *data)
7678 struct cmd_showdevice_result *res = parsed_result;
7679 if (!strcmp(res->what, "info")) {
7680 if (!strcmp(res->identifier, "all"))
7681 device_infos_display(NULL);
7683 device_infos_display(res->identifier);
7687 cmdline_parse_token_string_t cmd_showdevice_show =
7688 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7690 cmdline_parse_token_string_t cmd_showdevice_device =
7691 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7692 cmdline_parse_token_string_t cmd_showdevice_what =
7693 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7695 cmdline_parse_token_string_t cmd_showdevice_identifier =
7696 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7699 cmdline_parse_inst_t cmd_showdevice = {
7700 .f = cmd_showdevice_parsed,
7702 .help_str = "show device info <identifier>|all",
7704 (void *)&cmd_showdevice_show,
7705 (void *)&cmd_showdevice_device,
7706 (void *)&cmd_showdevice_what,
7707 (void *)&cmd_showdevice_identifier,
7712 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7713 struct cmd_showeeprom_result {
7714 cmdline_fixed_string_t show;
7715 cmdline_fixed_string_t port;
7717 cmdline_fixed_string_t type;
7720 static void cmd_showeeprom_parsed(void *parsed_result,
7721 __rte_unused struct cmdline *cl,
7722 __rte_unused void *data)
7724 struct cmd_showeeprom_result *res = parsed_result;
7726 if (!strcmp(res->type, "eeprom"))
7727 port_eeprom_display(res->portnum);
7728 else if (!strcmp(res->type, "module_eeprom"))
7729 port_module_eeprom_display(res->portnum);
7731 printf("Unknown argument\n");
7734 cmdline_parse_token_string_t cmd_showeeprom_show =
7735 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7736 cmdline_parse_token_string_t cmd_showeeprom_port =
7737 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7738 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7739 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum, UINT16);
7740 cmdline_parse_token_string_t cmd_showeeprom_type =
7741 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7743 cmdline_parse_inst_t cmd_showeeprom = {
7744 .f = cmd_showeeprom_parsed,
7746 .help_str = "show port <port_id> module_eeprom|eeprom",
7748 (void *)&cmd_showeeprom_show,
7749 (void *)&cmd_showeeprom_port,
7750 (void *)&cmd_showeeprom_portnum,
7751 (void *)&cmd_showeeprom_type,
7756 /* *** SHOW QUEUE INFO *** */
7757 struct cmd_showqueue_result {
7758 cmdline_fixed_string_t show;
7759 cmdline_fixed_string_t type;
7760 cmdline_fixed_string_t what;
7766 cmd_showqueue_parsed(void *parsed_result,
7767 __rte_unused struct cmdline *cl,
7768 __rte_unused void *data)
7770 struct cmd_showqueue_result *res = parsed_result;
7772 if (!strcmp(res->type, "rxq"))
7773 rx_queue_infos_display(res->portnum, res->queuenum);
7774 else if (!strcmp(res->type, "txq"))
7775 tx_queue_infos_display(res->portnum, res->queuenum);
7778 cmdline_parse_token_string_t cmd_showqueue_show =
7779 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7780 cmdline_parse_token_string_t cmd_showqueue_type =
7781 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7782 cmdline_parse_token_string_t cmd_showqueue_what =
7783 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7784 cmdline_parse_token_num_t cmd_showqueue_portnum =
7785 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7786 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7787 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7789 cmdline_parse_inst_t cmd_showqueue = {
7790 .f = cmd_showqueue_parsed,
7792 .help_str = "show rxq|txq info <port_id> <queue_id>",
7794 (void *)&cmd_showqueue_show,
7795 (void *)&cmd_showqueue_type,
7796 (void *)&cmd_showqueue_what,
7797 (void *)&cmd_showqueue_portnum,
7798 (void *)&cmd_showqueue_queuenum,
7803 /* show/clear fwd engine statistics */
7805 cmdline_fixed_string_t action;
7806 cmdline_fixed_string_t fwd;
7807 cmdline_fixed_string_t stats;
7808 cmdline_fixed_string_t all;
7811 cmdline_parse_token_string_t cmd_fwd_action =
7812 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7813 cmdline_parse_token_string_t cmd_fwd_fwd =
7814 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7815 cmdline_parse_token_string_t cmd_fwd_stats =
7816 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7817 cmdline_parse_token_string_t cmd_fwd_all =
7818 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7821 cmd_showfwdall_parsed(void *parsed_result,
7822 __rte_unused struct cmdline *cl,
7823 __rte_unused void *data)
7825 struct fwd_result *res = parsed_result;
7827 if (!strcmp(res->action, "show"))
7828 fwd_stats_display();
7833 static cmdline_parse_inst_t cmd_showfwdall = {
7834 .f = cmd_showfwdall_parsed,
7836 .help_str = "show|clear fwd stats all",
7838 (void *)&cmd_fwd_action,
7839 (void *)&cmd_fwd_fwd,
7840 (void *)&cmd_fwd_stats,
7841 (void *)&cmd_fwd_all,
7846 /* *** READ PORT REGISTER *** */
7847 struct cmd_read_reg_result {
7848 cmdline_fixed_string_t read;
7849 cmdline_fixed_string_t reg;
7855 cmd_read_reg_parsed(void *parsed_result,
7856 __rte_unused struct cmdline *cl,
7857 __rte_unused void *data)
7859 struct cmd_read_reg_result *res = parsed_result;
7860 port_reg_display(res->port_id, res->reg_off);
7863 cmdline_parse_token_string_t cmd_read_reg_read =
7864 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7865 cmdline_parse_token_string_t cmd_read_reg_reg =
7866 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7867 cmdline_parse_token_num_t cmd_read_reg_port_id =
7868 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7869 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7870 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7872 cmdline_parse_inst_t cmd_read_reg = {
7873 .f = cmd_read_reg_parsed,
7875 .help_str = "read reg <port_id> <reg_off>",
7877 (void *)&cmd_read_reg_read,
7878 (void *)&cmd_read_reg_reg,
7879 (void *)&cmd_read_reg_port_id,
7880 (void *)&cmd_read_reg_reg_off,
7885 /* *** READ PORT REGISTER BIT FIELD *** */
7886 struct cmd_read_reg_bit_field_result {
7887 cmdline_fixed_string_t read;
7888 cmdline_fixed_string_t regfield;
7896 cmd_read_reg_bit_field_parsed(void *parsed_result,
7897 __rte_unused struct cmdline *cl,
7898 __rte_unused void *data)
7900 struct cmd_read_reg_bit_field_result *res = parsed_result;
7901 port_reg_bit_field_display(res->port_id, res->reg_off,
7902 res->bit1_pos, res->bit2_pos);
7905 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7906 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7908 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7909 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7910 regfield, "regfield");
7911 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7912 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7914 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7915 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7917 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7918 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7920 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7921 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7924 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7925 .f = cmd_read_reg_bit_field_parsed,
7927 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7928 "Read register bit field between bit_x and bit_y included",
7930 (void *)&cmd_read_reg_bit_field_read,
7931 (void *)&cmd_read_reg_bit_field_regfield,
7932 (void *)&cmd_read_reg_bit_field_port_id,
7933 (void *)&cmd_read_reg_bit_field_reg_off,
7934 (void *)&cmd_read_reg_bit_field_bit1_pos,
7935 (void *)&cmd_read_reg_bit_field_bit2_pos,
7940 /* *** READ PORT REGISTER BIT *** */
7941 struct cmd_read_reg_bit_result {
7942 cmdline_fixed_string_t read;
7943 cmdline_fixed_string_t regbit;
7950 cmd_read_reg_bit_parsed(void *parsed_result,
7951 __rte_unused struct cmdline *cl,
7952 __rte_unused void *data)
7954 struct cmd_read_reg_bit_result *res = parsed_result;
7955 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7958 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7959 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7960 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7961 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7963 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7964 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7965 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7966 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7967 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7968 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7970 cmdline_parse_inst_t cmd_read_reg_bit = {
7971 .f = cmd_read_reg_bit_parsed,
7973 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7975 (void *)&cmd_read_reg_bit_read,
7976 (void *)&cmd_read_reg_bit_regbit,
7977 (void *)&cmd_read_reg_bit_port_id,
7978 (void *)&cmd_read_reg_bit_reg_off,
7979 (void *)&cmd_read_reg_bit_bit_pos,
7984 /* *** WRITE PORT REGISTER *** */
7985 struct cmd_write_reg_result {
7986 cmdline_fixed_string_t write;
7987 cmdline_fixed_string_t reg;
7994 cmd_write_reg_parsed(void *parsed_result,
7995 __rte_unused struct cmdline *cl,
7996 __rte_unused void *data)
7998 struct cmd_write_reg_result *res = parsed_result;
7999 port_reg_set(res->port_id, res->reg_off, res->value);
8002 cmdline_parse_token_string_t cmd_write_reg_write =
8003 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8004 cmdline_parse_token_string_t cmd_write_reg_reg =
8005 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8006 cmdline_parse_token_num_t cmd_write_reg_port_id =
8007 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
8008 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8009 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
8010 cmdline_parse_token_num_t cmd_write_reg_value =
8011 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
8013 cmdline_parse_inst_t cmd_write_reg = {
8014 .f = cmd_write_reg_parsed,
8016 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8018 (void *)&cmd_write_reg_write,
8019 (void *)&cmd_write_reg_reg,
8020 (void *)&cmd_write_reg_port_id,
8021 (void *)&cmd_write_reg_reg_off,
8022 (void *)&cmd_write_reg_value,
8027 /* *** WRITE PORT REGISTER BIT FIELD *** */
8028 struct cmd_write_reg_bit_field_result {
8029 cmdline_fixed_string_t write;
8030 cmdline_fixed_string_t regfield;
8039 cmd_write_reg_bit_field_parsed(void *parsed_result,
8040 __rte_unused struct cmdline *cl,
8041 __rte_unused void *data)
8043 struct cmd_write_reg_bit_field_result *res = parsed_result;
8044 port_reg_bit_field_set(res->port_id, res->reg_off,
8045 res->bit1_pos, res->bit2_pos, res->value);
8048 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8049 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8051 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8052 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8053 regfield, "regfield");
8054 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8055 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8057 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8058 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8060 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8061 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8063 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8064 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8066 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8067 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8070 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8071 .f = cmd_write_reg_bit_field_parsed,
8073 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8075 "Set register bit field between bit_x and bit_y included",
8077 (void *)&cmd_write_reg_bit_field_write,
8078 (void *)&cmd_write_reg_bit_field_regfield,
8079 (void *)&cmd_write_reg_bit_field_port_id,
8080 (void *)&cmd_write_reg_bit_field_reg_off,
8081 (void *)&cmd_write_reg_bit_field_bit1_pos,
8082 (void *)&cmd_write_reg_bit_field_bit2_pos,
8083 (void *)&cmd_write_reg_bit_field_value,
8088 /* *** WRITE PORT REGISTER BIT *** */
8089 struct cmd_write_reg_bit_result {
8090 cmdline_fixed_string_t write;
8091 cmdline_fixed_string_t regbit;
8099 cmd_write_reg_bit_parsed(void *parsed_result,
8100 __rte_unused struct cmdline *cl,
8101 __rte_unused void *data)
8103 struct cmd_write_reg_bit_result *res = parsed_result;
8104 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8107 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8108 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8110 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8111 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8113 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8114 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
8115 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8116 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
8117 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8118 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
8119 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8120 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
8122 cmdline_parse_inst_t cmd_write_reg_bit = {
8123 .f = cmd_write_reg_bit_parsed,
8125 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8128 (void *)&cmd_write_reg_bit_write,
8129 (void *)&cmd_write_reg_bit_regbit,
8130 (void *)&cmd_write_reg_bit_port_id,
8131 (void *)&cmd_write_reg_bit_reg_off,
8132 (void *)&cmd_write_reg_bit_bit_pos,
8133 (void *)&cmd_write_reg_bit_value,
8138 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8139 struct cmd_read_rxd_txd_result {
8140 cmdline_fixed_string_t read;
8141 cmdline_fixed_string_t rxd_txd;
8148 cmd_read_rxd_txd_parsed(void *parsed_result,
8149 __rte_unused struct cmdline *cl,
8150 __rte_unused void *data)
8152 struct cmd_read_rxd_txd_result *res = parsed_result;
8154 if (!strcmp(res->rxd_txd, "rxd"))
8155 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8156 else if (!strcmp(res->rxd_txd, "txd"))
8157 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8160 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8161 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8162 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8163 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8165 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8166 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
8167 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8168 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
8169 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8170 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
8172 cmdline_parse_inst_t cmd_read_rxd_txd = {
8173 .f = cmd_read_rxd_txd_parsed,
8175 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8177 (void *)&cmd_read_rxd_txd_read,
8178 (void *)&cmd_read_rxd_txd_rxd_txd,
8179 (void *)&cmd_read_rxd_txd_port_id,
8180 (void *)&cmd_read_rxd_txd_queue_id,
8181 (void *)&cmd_read_rxd_txd_desc_id,
8187 struct cmd_quit_result {
8188 cmdline_fixed_string_t quit;
8191 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8193 __rte_unused void *data)
8198 cmdline_parse_token_string_t cmd_quit_quit =
8199 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8201 cmdline_parse_inst_t cmd_quit = {
8202 .f = cmd_quit_parsed,
8204 .help_str = "quit: Exit application",
8206 (void *)&cmd_quit_quit,
8211 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8212 struct cmd_mac_addr_result {
8213 cmdline_fixed_string_t mac_addr_cmd;
8214 cmdline_fixed_string_t what;
8216 struct rte_ether_addr address;
8219 static void cmd_mac_addr_parsed(void *parsed_result,
8220 __rte_unused struct cmdline *cl,
8221 __rte_unused void *data)
8223 struct cmd_mac_addr_result *res = parsed_result;
8226 if (strcmp(res->what, "add") == 0)
8227 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8228 else if (strcmp(res->what, "set") == 0)
8229 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8232 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8234 /* check the return value and print it if is < 0 */
8236 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8240 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8241 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8243 cmdline_parse_token_string_t cmd_mac_addr_what =
8244 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8246 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8247 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8249 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8250 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8252 cmdline_parse_inst_t cmd_mac_addr = {
8253 .f = cmd_mac_addr_parsed,
8255 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8256 "Add/Remove/Set MAC address on port_id",
8258 (void *)&cmd_mac_addr_cmd,
8259 (void *)&cmd_mac_addr_what,
8260 (void *)&cmd_mac_addr_portnum,
8261 (void *)&cmd_mac_addr_addr,
8266 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8267 struct cmd_eth_peer_result {
8268 cmdline_fixed_string_t set;
8269 cmdline_fixed_string_t eth_peer;
8271 cmdline_fixed_string_t peer_addr;
8274 static void cmd_set_eth_peer_parsed(void *parsed_result,
8275 __rte_unused struct cmdline *cl,
8276 __rte_unused void *data)
8278 struct cmd_eth_peer_result *res = parsed_result;
8280 if (test_done == 0) {
8281 printf("Please stop forwarding first\n");
8284 if (!strcmp(res->eth_peer, "eth-peer")) {
8285 set_fwd_eth_peer(res->port_id, res->peer_addr);
8289 cmdline_parse_token_string_t cmd_eth_peer_set =
8290 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8291 cmdline_parse_token_string_t cmd_eth_peer =
8292 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8293 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8294 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
8295 cmdline_parse_token_string_t cmd_eth_peer_addr =
8296 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8298 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8299 .f = cmd_set_eth_peer_parsed,
8301 .help_str = "set eth-peer <port_id> <peer_mac>",
8303 (void *)&cmd_eth_peer_set,
8304 (void *)&cmd_eth_peer,
8305 (void *)&cmd_eth_peer_port_id,
8306 (void *)&cmd_eth_peer_addr,
8311 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8312 struct cmd_set_qmap_result {
8313 cmdline_fixed_string_t set;
8314 cmdline_fixed_string_t qmap;
8315 cmdline_fixed_string_t what;
8322 cmd_set_qmap_parsed(void *parsed_result,
8323 __rte_unused struct cmdline *cl,
8324 __rte_unused void *data)
8326 struct cmd_set_qmap_result *res = parsed_result;
8327 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8329 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8332 cmdline_parse_token_string_t cmd_setqmap_set =
8333 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8335 cmdline_parse_token_string_t cmd_setqmap_qmap =
8336 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8338 cmdline_parse_token_string_t cmd_setqmap_what =
8339 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8341 cmdline_parse_token_num_t cmd_setqmap_portid =
8342 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8344 cmdline_parse_token_num_t cmd_setqmap_queueid =
8345 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8347 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8348 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8351 cmdline_parse_inst_t cmd_set_qmap = {
8352 .f = cmd_set_qmap_parsed,
8354 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8355 "Set statistics mapping value on tx|rx queue_id of port_id",
8357 (void *)&cmd_setqmap_set,
8358 (void *)&cmd_setqmap_qmap,
8359 (void *)&cmd_setqmap_what,
8360 (void *)&cmd_setqmap_portid,
8361 (void *)&cmd_setqmap_queueid,
8362 (void *)&cmd_setqmap_mapvalue,
8367 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8368 struct cmd_set_xstats_hide_zero_result {
8369 cmdline_fixed_string_t keyword;
8370 cmdline_fixed_string_t name;
8371 cmdline_fixed_string_t on_off;
8375 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8376 __rte_unused struct cmdline *cl,
8377 __rte_unused void *data)
8379 struct cmd_set_xstats_hide_zero_result *res;
8380 uint16_t on_off = 0;
8382 res = parsed_result;
8383 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8384 set_xstats_hide_zero(on_off);
8387 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8388 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8390 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8391 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8392 name, "xstats-hide-zero");
8393 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8394 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8397 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8398 .f = cmd_set_xstats_hide_zero_parsed,
8400 .help_str = "set xstats-hide-zero on|off",
8402 (void *)&cmd_set_xstats_hide_zero_keyword,
8403 (void *)&cmd_set_xstats_hide_zero_name,
8404 (void *)&cmd_set_xstats_hide_zero_on_off,
8409 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8410 struct cmd_set_record_core_cycles_result {
8411 cmdline_fixed_string_t keyword;
8412 cmdline_fixed_string_t name;
8413 cmdline_fixed_string_t on_off;
8417 cmd_set_record_core_cycles_parsed(void *parsed_result,
8418 __rte_unused struct cmdline *cl,
8419 __rte_unused void *data)
8421 struct cmd_set_record_core_cycles_result *res;
8422 uint16_t on_off = 0;
8424 res = parsed_result;
8425 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8426 set_record_core_cycles(on_off);
8429 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8430 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8432 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8433 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8434 name, "record-core-cycles");
8435 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8436 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8439 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8440 .f = cmd_set_record_core_cycles_parsed,
8442 .help_str = "set record-core-cycles on|off",
8444 (void *)&cmd_set_record_core_cycles_keyword,
8445 (void *)&cmd_set_record_core_cycles_name,
8446 (void *)&cmd_set_record_core_cycles_on_off,
8451 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8452 struct cmd_set_record_burst_stats_result {
8453 cmdline_fixed_string_t keyword;
8454 cmdline_fixed_string_t name;
8455 cmdline_fixed_string_t on_off;
8459 cmd_set_record_burst_stats_parsed(void *parsed_result,
8460 __rte_unused struct cmdline *cl,
8461 __rte_unused void *data)
8463 struct cmd_set_record_burst_stats_result *res;
8464 uint16_t on_off = 0;
8466 res = parsed_result;
8467 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8468 set_record_burst_stats(on_off);
8471 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8472 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8474 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8475 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8476 name, "record-burst-stats");
8477 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8478 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8481 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8482 .f = cmd_set_record_burst_stats_parsed,
8484 .help_str = "set record-burst-stats on|off",
8486 (void *)&cmd_set_record_burst_stats_keyword,
8487 (void *)&cmd_set_record_burst_stats_name,
8488 (void *)&cmd_set_record_burst_stats_on_off,
8493 /* *** CONFIGURE UNICAST HASH TABLE *** */
8494 struct cmd_set_uc_hash_table {
8495 cmdline_fixed_string_t set;
8496 cmdline_fixed_string_t port;
8498 cmdline_fixed_string_t what;
8499 struct rte_ether_addr address;
8500 cmdline_fixed_string_t mode;
8504 cmd_set_uc_hash_parsed(void *parsed_result,
8505 __rte_unused struct cmdline *cl,
8506 __rte_unused void *data)
8509 struct cmd_set_uc_hash_table *res = parsed_result;
8511 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8513 if (strcmp(res->what, "uta") == 0)
8514 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8515 &res->address,(uint8_t)is_on);
8517 printf("bad unicast hash table parameter, return code = %d \n", ret);
8521 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8522 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8524 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8525 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8527 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8528 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8530 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8531 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8533 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8534 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8536 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8537 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8540 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8541 .f = cmd_set_uc_hash_parsed,
8543 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8545 (void *)&cmd_set_uc_hash_set,
8546 (void *)&cmd_set_uc_hash_port,
8547 (void *)&cmd_set_uc_hash_portid,
8548 (void *)&cmd_set_uc_hash_what,
8549 (void *)&cmd_set_uc_hash_mac,
8550 (void *)&cmd_set_uc_hash_mode,
8555 struct cmd_set_uc_all_hash_table {
8556 cmdline_fixed_string_t set;
8557 cmdline_fixed_string_t port;
8559 cmdline_fixed_string_t what;
8560 cmdline_fixed_string_t value;
8561 cmdline_fixed_string_t mode;
8565 cmd_set_uc_all_hash_parsed(void *parsed_result,
8566 __rte_unused struct cmdline *cl,
8567 __rte_unused void *data)
8570 struct cmd_set_uc_all_hash_table *res = parsed_result;
8572 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8574 if ((strcmp(res->what, "uta") == 0) &&
8575 (strcmp(res->value, "all") == 0))
8576 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8578 printf("bad unicast hash table parameter,"
8579 "return code = %d \n", ret);
8582 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8583 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8585 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8586 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8588 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8589 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8591 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8592 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8594 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8595 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8597 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8598 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8601 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8602 .f = cmd_set_uc_all_hash_parsed,
8604 .help_str = "set port <port_id> uta all on|off",
8606 (void *)&cmd_set_uc_all_hash_set,
8607 (void *)&cmd_set_uc_all_hash_port,
8608 (void *)&cmd_set_uc_all_hash_portid,
8609 (void *)&cmd_set_uc_all_hash_what,
8610 (void *)&cmd_set_uc_all_hash_value,
8611 (void *)&cmd_set_uc_all_hash_mode,
8616 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8617 struct cmd_set_vf_traffic {
8618 cmdline_fixed_string_t set;
8619 cmdline_fixed_string_t port;
8621 cmdline_fixed_string_t vf;
8623 cmdline_fixed_string_t what;
8624 cmdline_fixed_string_t mode;
8628 cmd_set_vf_traffic_parsed(void *parsed_result,
8629 __rte_unused struct cmdline *cl,
8630 __rte_unused void *data)
8632 struct cmd_set_vf_traffic *res = parsed_result;
8633 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8634 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8636 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8639 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8640 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8642 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8643 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8645 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8646 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8648 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8649 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8651 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8652 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8654 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8655 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8657 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8658 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8661 cmdline_parse_inst_t cmd_set_vf_traffic = {
8662 .f = cmd_set_vf_traffic_parsed,
8664 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8666 (void *)&cmd_setvf_traffic_set,
8667 (void *)&cmd_setvf_traffic_port,
8668 (void *)&cmd_setvf_traffic_portid,
8669 (void *)&cmd_setvf_traffic_vf,
8670 (void *)&cmd_setvf_traffic_vfid,
8671 (void *)&cmd_setvf_traffic_what,
8672 (void *)&cmd_setvf_traffic_mode,
8677 /* *** CONFIGURE VF RECEIVE MODE *** */
8678 struct cmd_set_vf_rxmode {
8679 cmdline_fixed_string_t set;
8680 cmdline_fixed_string_t port;
8682 cmdline_fixed_string_t vf;
8684 cmdline_fixed_string_t what;
8685 cmdline_fixed_string_t mode;
8686 cmdline_fixed_string_t on;
8690 cmd_set_vf_rxmode_parsed(void *parsed_result,
8691 __rte_unused struct cmdline *cl,
8692 __rte_unused void *data)
8695 uint16_t vf_rxmode = 0;
8696 struct cmd_set_vf_rxmode *res = parsed_result;
8698 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8699 if (!strcmp(res->what,"rxmode")) {
8700 if (!strcmp(res->mode, "AUPE"))
8701 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8702 else if (!strcmp(res->mode, "ROPE"))
8703 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8704 else if (!strcmp(res->mode, "BAM"))
8705 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8706 else if (!strncmp(res->mode, "MPE",3))
8707 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8710 RTE_SET_USED(is_on);
8712 #ifdef RTE_NET_IXGBE
8713 if (ret == -ENOTSUP)
8714 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8715 vf_rxmode, (uint8_t)is_on);
8718 if (ret == -ENOTSUP)
8719 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8720 vf_rxmode, (uint8_t)is_on);
8723 printf("bad VF receive mode parameter, return code = %d \n",
8727 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8728 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8730 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8731 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8733 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8734 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8736 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8737 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8739 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8740 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8742 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8743 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8745 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8746 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8747 mode, "AUPE#ROPE#BAM#MPE");
8748 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8749 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8752 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8753 .f = cmd_set_vf_rxmode_parsed,
8755 .help_str = "set port <port_id> vf <vf_id> rxmode "
8756 "AUPE|ROPE|BAM|MPE on|off",
8758 (void *)&cmd_set_vf_rxmode_set,
8759 (void *)&cmd_set_vf_rxmode_port,
8760 (void *)&cmd_set_vf_rxmode_portid,
8761 (void *)&cmd_set_vf_rxmode_vf,
8762 (void *)&cmd_set_vf_rxmode_vfid,
8763 (void *)&cmd_set_vf_rxmode_what,
8764 (void *)&cmd_set_vf_rxmode_mode,
8765 (void *)&cmd_set_vf_rxmode_on,
8770 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8771 struct cmd_vf_mac_addr_result {
8772 cmdline_fixed_string_t mac_addr_cmd;
8773 cmdline_fixed_string_t what;
8774 cmdline_fixed_string_t port;
8776 cmdline_fixed_string_t vf;
8778 struct rte_ether_addr address;
8781 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8782 __rte_unused struct cmdline *cl,
8783 __rte_unused void *data)
8785 struct cmd_vf_mac_addr_result *res = parsed_result;
8788 if (strcmp(res->what, "add") != 0)
8792 if (ret == -ENOTSUP)
8793 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8797 if (ret == -ENOTSUP)
8798 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8803 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8807 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8808 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8809 mac_addr_cmd,"mac_addr");
8810 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8811 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8813 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8814 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8816 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8817 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8819 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8820 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8822 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8823 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8825 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8826 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8829 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8830 .f = cmd_vf_mac_addr_parsed,
8832 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8833 "Add MAC address filtering for a VF on port_id",
8835 (void *)&cmd_vf_mac_addr_cmd,
8836 (void *)&cmd_vf_mac_addr_what,
8837 (void *)&cmd_vf_mac_addr_port,
8838 (void *)&cmd_vf_mac_addr_portnum,
8839 (void *)&cmd_vf_mac_addr_vf,
8840 (void *)&cmd_vf_mac_addr_vfnum,
8841 (void *)&cmd_vf_mac_addr_addr,
8846 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8847 struct cmd_vf_rx_vlan_filter {
8848 cmdline_fixed_string_t rx_vlan;
8849 cmdline_fixed_string_t what;
8851 cmdline_fixed_string_t port;
8853 cmdline_fixed_string_t vf;
8858 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8859 __rte_unused struct cmdline *cl,
8860 __rte_unused void *data)
8862 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8865 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8867 #ifdef RTE_NET_IXGBE
8868 if (ret == -ENOTSUP)
8869 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8870 res->vlan_id, res->vf_mask, is_add);
8873 if (ret == -ENOTSUP)
8874 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8875 res->vlan_id, res->vf_mask, is_add);
8878 if (ret == -ENOTSUP)
8879 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8880 res->vlan_id, res->vf_mask, is_add);
8887 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8888 res->vlan_id, res->vf_mask);
8891 printf("invalid port_id %d\n", res->port_id);
8894 printf("function not implemented or supported\n");
8897 printf("programming error: (%s)\n", strerror(-ret));
8901 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8902 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8903 rx_vlan, "rx_vlan");
8904 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8905 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8907 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8908 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8910 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8911 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8913 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8914 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8916 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8917 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8919 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8920 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8923 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8924 .f = cmd_vf_rx_vlan_filter_parsed,
8926 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8927 "(vf_mask = hexadecimal VF mask)",
8929 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8930 (void *)&cmd_vf_rx_vlan_filter_what,
8931 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8932 (void *)&cmd_vf_rx_vlan_filter_port,
8933 (void *)&cmd_vf_rx_vlan_filter_portid,
8934 (void *)&cmd_vf_rx_vlan_filter_vf,
8935 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8940 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8941 struct cmd_queue_rate_limit_result {
8942 cmdline_fixed_string_t set;
8943 cmdline_fixed_string_t port;
8945 cmdline_fixed_string_t queue;
8947 cmdline_fixed_string_t rate;
8951 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8952 __rte_unused struct cmdline *cl,
8953 __rte_unused void *data)
8955 struct cmd_queue_rate_limit_result *res = parsed_result;
8958 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8959 && (strcmp(res->queue, "queue") == 0)
8960 && (strcmp(res->rate, "rate") == 0))
8961 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8964 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8968 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8969 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8971 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8972 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8974 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8975 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8977 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8978 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8980 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8981 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8983 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8984 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8986 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8987 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8990 cmdline_parse_inst_t cmd_queue_rate_limit = {
8991 .f = cmd_queue_rate_limit_parsed,
8993 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8994 "Set rate limit for a queue on port_id",
8996 (void *)&cmd_queue_rate_limit_set,
8997 (void *)&cmd_queue_rate_limit_port,
8998 (void *)&cmd_queue_rate_limit_portnum,
8999 (void *)&cmd_queue_rate_limit_queue,
9000 (void *)&cmd_queue_rate_limit_queuenum,
9001 (void *)&cmd_queue_rate_limit_rate,
9002 (void *)&cmd_queue_rate_limit_ratenum,
9007 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9008 struct cmd_vf_rate_limit_result {
9009 cmdline_fixed_string_t set;
9010 cmdline_fixed_string_t port;
9012 cmdline_fixed_string_t vf;
9014 cmdline_fixed_string_t rate;
9016 cmdline_fixed_string_t q_msk;
9020 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9021 __rte_unused struct cmdline *cl,
9022 __rte_unused void *data)
9024 struct cmd_vf_rate_limit_result *res = parsed_result;
9027 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9028 && (strcmp(res->vf, "vf") == 0)
9029 && (strcmp(res->rate, "rate") == 0)
9030 && (strcmp(res->q_msk, "queue_mask") == 0))
9031 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9032 res->rate_num, res->q_msk_val);
9034 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9038 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9039 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9041 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9042 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9044 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9045 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9047 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9048 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9050 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9051 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9053 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9054 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9056 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9057 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9059 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9060 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9061 q_msk, "queue_mask");
9062 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9063 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9066 cmdline_parse_inst_t cmd_vf_rate_limit = {
9067 .f = cmd_vf_rate_limit_parsed,
9069 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9070 "queue_mask <queue_mask_value>: "
9071 "Set rate limit for queues of VF on port_id",
9073 (void *)&cmd_vf_rate_limit_set,
9074 (void *)&cmd_vf_rate_limit_port,
9075 (void *)&cmd_vf_rate_limit_portnum,
9076 (void *)&cmd_vf_rate_limit_vf,
9077 (void *)&cmd_vf_rate_limit_vfnum,
9078 (void *)&cmd_vf_rate_limit_rate,
9079 (void *)&cmd_vf_rate_limit_ratenum,
9080 (void *)&cmd_vf_rate_limit_q_msk,
9081 (void *)&cmd_vf_rate_limit_q_msk_val,
9086 /* *** CONFIGURE TUNNEL UDP PORT *** */
9087 struct cmd_tunnel_udp_config {
9088 cmdline_fixed_string_t cmd;
9089 cmdline_fixed_string_t what;
9095 cmd_tunnel_udp_config_parsed(void *parsed_result,
9096 __rte_unused struct cmdline *cl,
9097 __rte_unused void *data)
9099 struct cmd_tunnel_udp_config *res = parsed_result;
9100 struct rte_eth_udp_tunnel tunnel_udp;
9103 tunnel_udp.udp_port = res->udp_port;
9105 if (!strcmp(res->cmd, "rx_vxlan_port"))
9106 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9108 if (!strcmp(res->what, "add"))
9109 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9112 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9116 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9119 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9120 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9121 cmd, "rx_vxlan_port");
9122 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9123 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9125 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9126 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9128 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9129 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9132 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9133 .f = cmd_tunnel_udp_config_parsed,
9135 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9136 "Add/Remove a tunneling UDP port filter",
9138 (void *)&cmd_tunnel_udp_config_cmd,
9139 (void *)&cmd_tunnel_udp_config_what,
9140 (void *)&cmd_tunnel_udp_config_udp_port,
9141 (void *)&cmd_tunnel_udp_config_port_id,
9146 struct cmd_config_tunnel_udp_port {
9147 cmdline_fixed_string_t port;
9148 cmdline_fixed_string_t config;
9150 cmdline_fixed_string_t udp_tunnel_port;
9151 cmdline_fixed_string_t action;
9152 cmdline_fixed_string_t tunnel_type;
9157 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9158 __rte_unused struct cmdline *cl,
9159 __rte_unused void *data)
9161 struct cmd_config_tunnel_udp_port *res = parsed_result;
9162 struct rte_eth_udp_tunnel tunnel_udp;
9165 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9168 tunnel_udp.udp_port = res->udp_port;
9170 if (!strcmp(res->tunnel_type, "vxlan")) {
9171 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9172 } else if (!strcmp(res->tunnel_type, "geneve")) {
9173 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9174 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9175 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9177 printf("Invalid tunnel type\n");
9181 if (!strcmp(res->action, "add"))
9182 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9185 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9189 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9192 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9193 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9195 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9196 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9198 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9199 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9201 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9202 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9205 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9206 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9208 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9209 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9210 "vxlan#geneve#vxlan-gpe");
9211 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9212 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9215 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9216 .f = cmd_cfg_tunnel_udp_port_parsed,
9218 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe <udp_port>",
9220 (void *)&cmd_config_tunnel_udp_port_port,
9221 (void *)&cmd_config_tunnel_udp_port_config,
9222 (void *)&cmd_config_tunnel_udp_port_port_id,
9223 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9224 (void *)&cmd_config_tunnel_udp_port_action,
9225 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9226 (void *)&cmd_config_tunnel_udp_port_value,
9231 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9232 struct cmd_set_mirror_mask_result {
9233 cmdline_fixed_string_t set;
9234 cmdline_fixed_string_t port;
9236 cmdline_fixed_string_t mirror;
9238 cmdline_fixed_string_t what;
9239 cmdline_fixed_string_t value;
9240 cmdline_fixed_string_t dstpool;
9242 cmdline_fixed_string_t on;
9245 cmdline_parse_token_string_t cmd_mirror_mask_set =
9246 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9248 cmdline_parse_token_string_t cmd_mirror_mask_port =
9249 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9251 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9252 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9254 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9255 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9256 mirror, "mirror-rule");
9257 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9258 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9260 cmdline_parse_token_string_t cmd_mirror_mask_what =
9261 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9262 what, "pool-mirror-up#pool-mirror-down"
9264 cmdline_parse_token_string_t cmd_mirror_mask_value =
9265 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9267 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9268 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9269 dstpool, "dst-pool");
9270 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9271 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9273 cmdline_parse_token_string_t cmd_mirror_mask_on =
9274 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9278 cmd_set_mirror_mask_parsed(void *parsed_result,
9279 __rte_unused struct cmdline *cl,
9280 __rte_unused void *data)
9283 struct cmd_set_mirror_mask_result *res = parsed_result;
9284 struct rte_eth_mirror_conf mr_conf;
9286 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9288 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9290 mr_conf.dst_pool = res->dstpool_id;
9292 if (!strcmp(res->what, "pool-mirror-up")) {
9293 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9294 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9295 } else if (!strcmp(res->what, "pool-mirror-down")) {
9296 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9297 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9298 } else if (!strcmp(res->what, "vlan-mirror")) {
9299 mr_conf.rule_type = ETH_MIRROR_VLAN;
9300 nb_item = parse_item_list(res->value, "vlan",
9301 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9305 for (i = 0; i < nb_item; i++) {
9306 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9307 printf("Invalid vlan_id: must be < 4096\n");
9311 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9312 mr_conf.vlan.vlan_mask |= 1ULL << i;
9316 if (!strcmp(res->on, "on"))
9317 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9320 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9323 printf("mirror rule add error: (%s)\n", strerror(-ret));
9326 cmdline_parse_inst_t cmd_set_mirror_mask = {
9327 .f = cmd_set_mirror_mask_parsed,
9329 .help_str = "set port <port_id> mirror-rule <rule_id> "
9330 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9331 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9333 (void *)&cmd_mirror_mask_set,
9334 (void *)&cmd_mirror_mask_port,
9335 (void *)&cmd_mirror_mask_portid,
9336 (void *)&cmd_mirror_mask_mirror,
9337 (void *)&cmd_mirror_mask_ruleid,
9338 (void *)&cmd_mirror_mask_what,
9339 (void *)&cmd_mirror_mask_value,
9340 (void *)&cmd_mirror_mask_dstpool,
9341 (void *)&cmd_mirror_mask_poolid,
9342 (void *)&cmd_mirror_mask_on,
9347 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9348 struct cmd_set_mirror_link_result {
9349 cmdline_fixed_string_t set;
9350 cmdline_fixed_string_t port;
9352 cmdline_fixed_string_t mirror;
9354 cmdline_fixed_string_t what;
9355 cmdline_fixed_string_t dstpool;
9357 cmdline_fixed_string_t on;
9360 cmdline_parse_token_string_t cmd_mirror_link_set =
9361 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9363 cmdline_parse_token_string_t cmd_mirror_link_port =
9364 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9366 cmdline_parse_token_num_t cmd_mirror_link_portid =
9367 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9369 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9370 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9371 mirror, "mirror-rule");
9372 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9373 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9375 cmdline_parse_token_string_t cmd_mirror_link_what =
9376 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9377 what, "uplink-mirror#downlink-mirror");
9378 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9379 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9380 dstpool, "dst-pool");
9381 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9382 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9384 cmdline_parse_token_string_t cmd_mirror_link_on =
9385 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9389 cmd_set_mirror_link_parsed(void *parsed_result,
9390 __rte_unused struct cmdline *cl,
9391 __rte_unused void *data)
9394 struct cmd_set_mirror_link_result *res = parsed_result;
9395 struct rte_eth_mirror_conf mr_conf;
9397 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9398 if (!strcmp(res->what, "uplink-mirror"))
9399 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9401 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9403 mr_conf.dst_pool = res->dstpool_id;
9405 if (!strcmp(res->on, "on"))
9406 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9409 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9412 /* check the return value and print it if is < 0 */
9414 printf("mirror rule add error: (%s)\n", strerror(-ret));
9418 cmdline_parse_inst_t cmd_set_mirror_link = {
9419 .f = cmd_set_mirror_link_parsed,
9421 .help_str = "set port <port_id> mirror-rule <rule_id> "
9422 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9424 (void *)&cmd_mirror_link_set,
9425 (void *)&cmd_mirror_link_port,
9426 (void *)&cmd_mirror_link_portid,
9427 (void *)&cmd_mirror_link_mirror,
9428 (void *)&cmd_mirror_link_ruleid,
9429 (void *)&cmd_mirror_link_what,
9430 (void *)&cmd_mirror_link_dstpool,
9431 (void *)&cmd_mirror_link_poolid,
9432 (void *)&cmd_mirror_link_on,
9437 /* *** RESET VM MIRROR RULE *** */
9438 struct cmd_rm_mirror_rule_result {
9439 cmdline_fixed_string_t reset;
9440 cmdline_fixed_string_t port;
9442 cmdline_fixed_string_t mirror;
9446 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9447 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9449 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9450 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9452 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9453 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9455 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9456 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9457 mirror, "mirror-rule");
9458 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9459 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9463 cmd_reset_mirror_rule_parsed(void *parsed_result,
9464 __rte_unused struct cmdline *cl,
9465 __rte_unused void *data)
9468 struct cmd_set_mirror_link_result *res = parsed_result;
9470 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9472 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9475 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9476 .f = cmd_reset_mirror_rule_parsed,
9478 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9480 (void *)&cmd_rm_mirror_rule_reset,
9481 (void *)&cmd_rm_mirror_rule_port,
9482 (void *)&cmd_rm_mirror_rule_portid,
9483 (void *)&cmd_rm_mirror_rule_mirror,
9484 (void *)&cmd_rm_mirror_rule_ruleid,
9489 /* ******************************************************************************** */
9491 struct cmd_dump_result {
9492 cmdline_fixed_string_t dump;
9496 dump_struct_sizes(void)
9498 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9499 DUMP_SIZE(struct rte_mbuf);
9500 DUMP_SIZE(struct rte_mempool);
9501 DUMP_SIZE(struct rte_ring);
9506 /* Dump the socket memory statistics on console */
9508 dump_socket_mem(FILE *f)
9510 struct rte_malloc_socket_stats socket_stats;
9515 unsigned int n_alloc = 0;
9516 unsigned int n_free = 0;
9517 static size_t last_allocs;
9518 static size_t last_total;
9521 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9522 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9523 !socket_stats.heap_totalsz_bytes)
9525 total += socket_stats.heap_totalsz_bytes;
9526 alloc += socket_stats.heap_allocsz_bytes;
9527 free += socket_stats.heap_freesz_bytes;
9528 n_alloc += socket_stats.alloc_count;
9529 n_free += socket_stats.free_count;
9531 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9533 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9534 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9535 (double)socket_stats.heap_allocsz_bytes * 100 /
9536 (double)socket_stats.heap_totalsz_bytes,
9537 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9538 socket_stats.alloc_count,
9539 socket_stats.free_count);
9542 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9543 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9544 (double)alloc * 100 / (double)total,
9545 (double)free / (1024 * 1024),
9548 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9549 ((double)total - (double)last_total) / (1024 * 1024),
9550 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9551 last_allocs = alloc;
9555 static void cmd_dump_parsed(void *parsed_result,
9556 __rte_unused struct cmdline *cl,
9557 __rte_unused void *data)
9559 struct cmd_dump_result *res = parsed_result;
9561 if (!strcmp(res->dump, "dump_physmem"))
9562 rte_dump_physmem_layout(stdout);
9563 else if (!strcmp(res->dump, "dump_socket_mem"))
9564 dump_socket_mem(stdout);
9565 else if (!strcmp(res->dump, "dump_memzone"))
9566 rte_memzone_dump(stdout);
9567 else if (!strcmp(res->dump, "dump_struct_sizes"))
9568 dump_struct_sizes();
9569 else if (!strcmp(res->dump, "dump_ring"))
9570 rte_ring_list_dump(stdout);
9571 else if (!strcmp(res->dump, "dump_mempool"))
9572 rte_mempool_list_dump(stdout);
9573 else if (!strcmp(res->dump, "dump_devargs"))
9574 rte_devargs_dump(stdout);
9575 else if (!strcmp(res->dump, "dump_log_types"))
9576 rte_log_dump(stdout);
9579 cmdline_parse_token_string_t cmd_dump_dump =
9580 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9584 "dump_struct_sizes#"
9590 cmdline_parse_inst_t cmd_dump = {
9591 .f = cmd_dump_parsed, /* function to call */
9592 .data = NULL, /* 2nd arg of func */
9593 .help_str = "Dump status",
9594 .tokens = { /* token list, NULL terminated */
9595 (void *)&cmd_dump_dump,
9600 /* ******************************************************************************** */
9602 struct cmd_dump_one_result {
9603 cmdline_fixed_string_t dump;
9604 cmdline_fixed_string_t name;
9607 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9608 __rte_unused void *data)
9610 struct cmd_dump_one_result *res = parsed_result;
9612 if (!strcmp(res->dump, "dump_ring")) {
9614 r = rte_ring_lookup(res->name);
9616 cmdline_printf(cl, "Cannot find ring\n");
9619 rte_ring_dump(stdout, r);
9620 } else if (!strcmp(res->dump, "dump_mempool")) {
9621 struct rte_mempool *mp;
9622 mp = rte_mempool_lookup(res->name);
9624 cmdline_printf(cl, "Cannot find mempool\n");
9627 rte_mempool_dump(stdout, mp);
9631 cmdline_parse_token_string_t cmd_dump_one_dump =
9632 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9633 "dump_ring#dump_mempool");
9635 cmdline_parse_token_string_t cmd_dump_one_name =
9636 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9638 cmdline_parse_inst_t cmd_dump_one = {
9639 .f = cmd_dump_one_parsed, /* function to call */
9640 .data = NULL, /* 2nd arg of func */
9641 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9642 .tokens = { /* token list, NULL terminated */
9643 (void *)&cmd_dump_one_dump,
9644 (void *)&cmd_dump_one_name,
9649 /* *** queue region set *** */
9650 struct cmd_queue_region_result {
9651 cmdline_fixed_string_t set;
9652 cmdline_fixed_string_t port;
9654 cmdline_fixed_string_t cmd;
9655 cmdline_fixed_string_t region;
9657 cmdline_fixed_string_t queue_start_index;
9659 cmdline_fixed_string_t queue_num;
9660 uint8_t queue_num_value;
9664 cmd_queue_region_parsed(void *parsed_result,
9665 __rte_unused struct cmdline *cl,
9666 __rte_unused void *data)
9668 struct cmd_queue_region_result *res = parsed_result;
9671 struct rte_pmd_i40e_queue_region_conf region_conf;
9672 enum rte_pmd_i40e_queue_region_op op_type;
9675 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9679 memset(®ion_conf, 0, sizeof(region_conf));
9680 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9681 region_conf.region_id = res->region_id;
9682 region_conf.queue_num = res->queue_num_value;
9683 region_conf.queue_start_index = res->queue_id;
9685 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9686 op_type, ®ion_conf);
9693 printf("function not implemented or supported\n");
9696 printf("queue region config error: (%s)\n", strerror(-ret));
9700 cmdline_parse_token_string_t cmd_queue_region_set =
9701 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9703 cmdline_parse_token_string_t cmd_queue_region_port =
9704 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9705 cmdline_parse_token_num_t cmd_queue_region_port_id =
9706 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9708 cmdline_parse_token_string_t cmd_queue_region_cmd =
9709 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9710 cmd, "queue-region");
9711 cmdline_parse_token_string_t cmd_queue_region_id =
9712 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9713 region, "region_id");
9714 cmdline_parse_token_num_t cmd_queue_region_index =
9715 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9717 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9718 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9719 queue_start_index, "queue_start_index");
9720 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9721 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9723 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9724 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9725 queue_num, "queue_num");
9726 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9727 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9728 queue_num_value, UINT8);
9730 cmdline_parse_inst_t cmd_queue_region = {
9731 .f = cmd_queue_region_parsed,
9733 .help_str = "set port <port_id> queue-region region_id <value> "
9734 "queue_start_index <value> queue_num <value>: Set a queue region",
9736 (void *)&cmd_queue_region_set,
9737 (void *)&cmd_queue_region_port,
9738 (void *)&cmd_queue_region_port_id,
9739 (void *)&cmd_queue_region_cmd,
9740 (void *)&cmd_queue_region_id,
9741 (void *)&cmd_queue_region_index,
9742 (void *)&cmd_queue_region_queue_start_index,
9743 (void *)&cmd_queue_region_queue_id,
9744 (void *)&cmd_queue_region_queue_num,
9745 (void *)&cmd_queue_region_queue_num_value,
9750 /* *** queue region and flowtype set *** */
9751 struct cmd_region_flowtype_result {
9752 cmdline_fixed_string_t set;
9753 cmdline_fixed_string_t port;
9755 cmdline_fixed_string_t cmd;
9756 cmdline_fixed_string_t region;
9758 cmdline_fixed_string_t flowtype;
9759 uint8_t flowtype_id;
9763 cmd_region_flowtype_parsed(void *parsed_result,
9764 __rte_unused struct cmdline *cl,
9765 __rte_unused void *data)
9767 struct cmd_region_flowtype_result *res = parsed_result;
9770 struct rte_pmd_i40e_queue_region_conf region_conf;
9771 enum rte_pmd_i40e_queue_region_op op_type;
9774 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9778 memset(®ion_conf, 0, sizeof(region_conf));
9780 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9781 region_conf.region_id = res->region_id;
9782 region_conf.hw_flowtype = res->flowtype_id;
9784 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9785 op_type, ®ion_conf);
9792 printf("function not implemented or supported\n");
9795 printf("region flowtype config error: (%s)\n", strerror(-ret));
9799 cmdline_parse_token_string_t cmd_region_flowtype_set =
9800 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9802 cmdline_parse_token_string_t cmd_region_flowtype_port =
9803 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9805 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9806 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9808 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9809 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9810 cmd, "queue-region");
9811 cmdline_parse_token_string_t cmd_region_flowtype_index =
9812 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9813 region, "region_id");
9814 cmdline_parse_token_num_t cmd_region_flowtype_id =
9815 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9817 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9818 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9819 flowtype, "flowtype");
9820 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9821 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9822 flowtype_id, UINT8);
9823 cmdline_parse_inst_t cmd_region_flowtype = {
9824 .f = cmd_region_flowtype_parsed,
9826 .help_str = "set port <port_id> queue-region region_id <value> "
9827 "flowtype <value>: Set a flowtype region index",
9829 (void *)&cmd_region_flowtype_set,
9830 (void *)&cmd_region_flowtype_port,
9831 (void *)&cmd_region_flowtype_port_index,
9832 (void *)&cmd_region_flowtype_cmd,
9833 (void *)&cmd_region_flowtype_index,
9834 (void *)&cmd_region_flowtype_id,
9835 (void *)&cmd_region_flowtype_flow_index,
9836 (void *)&cmd_region_flowtype_flow_id,
9841 /* *** User Priority (UP) to queue region (region_id) set *** */
9842 struct cmd_user_priority_region_result {
9843 cmdline_fixed_string_t set;
9844 cmdline_fixed_string_t port;
9846 cmdline_fixed_string_t cmd;
9847 cmdline_fixed_string_t user_priority;
9848 uint8_t user_priority_id;
9849 cmdline_fixed_string_t region;
9854 cmd_user_priority_region_parsed(void *parsed_result,
9855 __rte_unused struct cmdline *cl,
9856 __rte_unused void *data)
9858 struct cmd_user_priority_region_result *res = parsed_result;
9861 struct rte_pmd_i40e_queue_region_conf region_conf;
9862 enum rte_pmd_i40e_queue_region_op op_type;
9865 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9869 memset(®ion_conf, 0, sizeof(region_conf));
9870 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9871 region_conf.user_priority = res->user_priority_id;
9872 region_conf.region_id = res->region_id;
9874 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9875 op_type, ®ion_conf);
9882 printf("function not implemented or supported\n");
9885 printf("user_priority region config error: (%s)\n",
9890 cmdline_parse_token_string_t cmd_user_priority_region_set =
9891 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9893 cmdline_parse_token_string_t cmd_user_priority_region_port =
9894 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9896 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9897 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9899 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9900 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9901 cmd, "queue-region");
9902 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9903 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9904 user_priority, "UP");
9905 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9906 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9907 user_priority_id, UINT8);
9908 cmdline_parse_token_string_t cmd_user_priority_region_region =
9909 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9910 region, "region_id");
9911 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9912 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9915 cmdline_parse_inst_t cmd_user_priority_region = {
9916 .f = cmd_user_priority_region_parsed,
9918 .help_str = "set port <port_id> queue-region UP <value> "
9919 "region_id <value>: Set the mapping of User Priority (UP) "
9920 "to queue region (region_id) ",
9922 (void *)&cmd_user_priority_region_set,
9923 (void *)&cmd_user_priority_region_port,
9924 (void *)&cmd_user_priority_region_port_index,
9925 (void *)&cmd_user_priority_region_cmd,
9926 (void *)&cmd_user_priority_region_UP,
9927 (void *)&cmd_user_priority_region_UP_id,
9928 (void *)&cmd_user_priority_region_region,
9929 (void *)&cmd_user_priority_region_region_id,
9934 /* *** flush all queue region related configuration *** */
9935 struct cmd_flush_queue_region_result {
9936 cmdline_fixed_string_t set;
9937 cmdline_fixed_string_t port;
9939 cmdline_fixed_string_t cmd;
9940 cmdline_fixed_string_t flush;
9941 cmdline_fixed_string_t what;
9945 cmd_flush_queue_region_parsed(void *parsed_result,
9946 __rte_unused struct cmdline *cl,
9947 __rte_unused void *data)
9949 struct cmd_flush_queue_region_result *res = parsed_result;
9952 struct rte_pmd_i40e_queue_region_conf region_conf;
9953 enum rte_pmd_i40e_queue_region_op op_type;
9956 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9960 memset(®ion_conf, 0, sizeof(region_conf));
9962 if (strcmp(res->what, "on") == 0)
9963 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9965 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9967 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9968 op_type, ®ion_conf);
9975 printf("function not implemented or supported\n");
9978 printf("queue region config flush error: (%s)\n",
9983 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9984 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9986 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9987 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9989 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9990 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9992 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9993 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9994 cmd, "queue-region");
9995 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9996 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9998 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9999 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10002 cmdline_parse_inst_t cmd_flush_queue_region = {
10003 .f = cmd_flush_queue_region_parsed,
10005 .help_str = "set port <port_id> queue-region flush on|off"
10006 ": flush all queue region related configuration",
10008 (void *)&cmd_flush_queue_region_set,
10009 (void *)&cmd_flush_queue_region_port,
10010 (void *)&cmd_flush_queue_region_port_index,
10011 (void *)&cmd_flush_queue_region_cmd,
10012 (void *)&cmd_flush_queue_region_flush,
10013 (void *)&cmd_flush_queue_region_what,
10018 /* *** get all queue region related configuration info *** */
10019 struct cmd_show_queue_region_info {
10020 cmdline_fixed_string_t show;
10021 cmdline_fixed_string_t port;
10023 cmdline_fixed_string_t cmd;
10027 cmd_show_queue_region_info_parsed(void *parsed_result,
10028 __rte_unused struct cmdline *cl,
10029 __rte_unused void *data)
10031 struct cmd_show_queue_region_info *res = parsed_result;
10032 int ret = -ENOTSUP;
10033 #ifdef RTE_NET_I40E
10034 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10035 enum rte_pmd_i40e_queue_region_op op_type;
10038 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10041 #ifdef RTE_NET_I40E
10042 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10044 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10046 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10047 op_type, &rte_pmd_regions);
10049 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10056 printf("function not implemented or supported\n");
10059 printf("queue region config info show error: (%s)\n",
10064 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10065 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10067 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10068 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10070 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10071 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10073 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10074 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10075 cmd, "queue-region");
10077 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10078 .f = cmd_show_queue_region_info_parsed,
10080 .help_str = "show port <port_id> queue-region"
10081 ": show all queue region related configuration info",
10083 (void *)&cmd_show_queue_region_info_get,
10084 (void *)&cmd_show_queue_region_info_port,
10085 (void *)&cmd_show_queue_region_info_port_index,
10086 (void *)&cmd_show_queue_region_info_cmd,
10091 /* *** Filters Control *** */
10094 str2flowtype(char *string)
10097 static const struct {
10100 } flowtype_str[] = {
10101 {"raw", RTE_ETH_FLOW_RAW},
10102 {"ipv4", RTE_ETH_FLOW_IPV4},
10103 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10104 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10105 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10106 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10107 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10108 {"ipv6", RTE_ETH_FLOW_IPV6},
10109 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10110 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10111 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10112 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10113 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10114 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10117 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10118 if (!strcmp(flowtype_str[i].str, string))
10119 return flowtype_str[i].type;
10122 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10123 return (uint16_t)atoi(string);
10125 return RTE_ETH_FLOW_UNKNOWN;
10128 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10130 if ((ip_addr).family == AF_INET) \
10131 (ip) = (ip_addr).addr.ipv4.s_addr; \
10133 printf("invalid parameter.\n"); \
10138 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10140 if ((ip_addr).family == AF_INET6) \
10141 rte_memcpy(&(ip), \
10142 &((ip_addr).addr.ipv6), \
10143 sizeof(struct in6_addr)); \
10145 printf("invalid parameter.\n"); \
10150 #ifdef RTE_NET_I40E
10152 /* *** deal with flow director filter *** */
10153 struct cmd_flow_director_result {
10154 cmdline_fixed_string_t flow_director_filter;
10156 cmdline_fixed_string_t mode;
10157 cmdline_fixed_string_t mode_value;
10158 cmdline_fixed_string_t ops;
10159 cmdline_fixed_string_t flow;
10160 cmdline_fixed_string_t flow_type;
10161 cmdline_fixed_string_t drop;
10162 cmdline_fixed_string_t queue;
10164 cmdline_fixed_string_t fd_id;
10165 uint32_t fd_id_value;
10166 cmdline_fixed_string_t packet;
10171 cmd_flow_director_filter_parsed(void *parsed_result,
10172 __rte_unused struct cmdline *cl,
10173 __rte_unused void *data)
10175 struct cmd_flow_director_result *res = parsed_result;
10177 struct rte_pmd_i40e_flow_type_mapping
10178 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10179 struct rte_pmd_i40e_pkt_template_conf conf;
10180 uint16_t flow_type = str2flowtype(res->flow_type);
10181 uint16_t i, port = res->port_id;
10184 memset(&conf, 0, sizeof(conf));
10186 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10187 printf("Invalid flow type specified.\n");
10190 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10194 if (mapping[flow_type].pctype == 0ULL) {
10195 printf("Invalid flow type specified.\n");
10198 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10199 if (mapping[flow_type].pctype & (1ULL << i)) {
10200 conf.input.pctype = i;
10205 conf.input.packet = open_file(res->filepath,
10206 &conf.input.length);
10207 if (!conf.input.packet)
10209 if (!strcmp(res->drop, "drop"))
10210 conf.action.behavior =
10211 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10213 conf.action.behavior =
10214 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10215 conf.action.report_status =
10216 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10217 conf.action.rx_queue = res->queue_id;
10218 conf.soft_id = res->fd_id_value;
10219 add = strcmp(res->ops, "del") ? 1 : 0;
10220 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10224 printf("flow director config error: (%s)\n",
10226 close_file(conf.input.packet);
10229 cmdline_parse_token_string_t cmd_flow_director_filter =
10230 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10231 flow_director_filter, "flow_director_filter");
10232 cmdline_parse_token_num_t cmd_flow_director_port_id =
10233 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10235 cmdline_parse_token_string_t cmd_flow_director_ops =
10236 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10237 ops, "add#del#update");
10238 cmdline_parse_token_string_t cmd_flow_director_flow =
10239 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10241 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10242 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10244 cmdline_parse_token_string_t cmd_flow_director_drop =
10245 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10247 cmdline_parse_token_string_t cmd_flow_director_queue =
10248 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10250 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10251 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10253 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10254 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10256 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10257 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10258 fd_id_value, UINT32);
10260 cmdline_parse_token_string_t cmd_flow_director_mode =
10261 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10263 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10264 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10265 mode_value, "raw");
10266 cmdline_parse_token_string_t cmd_flow_director_packet =
10267 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10269 cmdline_parse_token_string_t cmd_flow_director_filepath =
10270 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10273 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10274 .f = cmd_flow_director_filter_parsed,
10276 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10277 "director entry on NIC",
10279 (void *)&cmd_flow_director_filter,
10280 (void *)&cmd_flow_director_port_id,
10281 (void *)&cmd_flow_director_mode,
10282 (void *)&cmd_flow_director_mode_raw,
10283 (void *)&cmd_flow_director_ops,
10284 (void *)&cmd_flow_director_flow,
10285 (void *)&cmd_flow_director_flow_type,
10286 (void *)&cmd_flow_director_drop,
10287 (void *)&cmd_flow_director_queue,
10288 (void *)&cmd_flow_director_queue_id,
10289 (void *)&cmd_flow_director_fd_id,
10290 (void *)&cmd_flow_director_fd_id_value,
10291 (void *)&cmd_flow_director_packet,
10292 (void *)&cmd_flow_director_filepath,
10297 #endif /* RTE_NET_I40E */
10299 /* *** deal with flow director mask *** */
10300 struct cmd_flow_director_mask_result {
10301 cmdline_fixed_string_t flow_director_mask;
10303 cmdline_fixed_string_t mode;
10304 cmdline_fixed_string_t mode_value;
10305 cmdline_fixed_string_t vlan;
10306 uint16_t vlan_mask;
10307 cmdline_fixed_string_t src_mask;
10308 cmdline_ipaddr_t ipv4_src;
10309 cmdline_ipaddr_t ipv6_src;
10311 cmdline_fixed_string_t dst_mask;
10312 cmdline_ipaddr_t ipv4_dst;
10313 cmdline_ipaddr_t ipv6_dst;
10315 cmdline_fixed_string_t mac;
10316 uint8_t mac_addr_byte_mask;
10317 cmdline_fixed_string_t tunnel_id;
10318 uint32_t tunnel_id_mask;
10319 cmdline_fixed_string_t tunnel_type;
10320 uint8_t tunnel_type_mask;
10324 cmd_flow_director_mask_parsed(void *parsed_result,
10325 __rte_unused struct cmdline *cl,
10326 __rte_unused void *data)
10328 struct cmd_flow_director_mask_result *res = parsed_result;
10329 struct rte_eth_fdir_masks *mask;
10330 struct rte_port *port;
10332 port = &ports[res->port_id];
10333 /** Check if the port is not started **/
10334 if (port->port_status != RTE_PORT_STOPPED) {
10335 printf("Please stop port %d first\n", res->port_id);
10339 mask = &port->dev_conf.fdir_conf.mask;
10341 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10342 if (strcmp(res->mode_value, "MAC-VLAN")) {
10343 printf("Please set mode to MAC-VLAN.\n");
10347 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10348 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10349 if (strcmp(res->mode_value, "Tunnel")) {
10350 printf("Please set mode to Tunnel.\n");
10354 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10355 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10356 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10357 mask->tunnel_type_mask = res->tunnel_type_mask;
10359 if (strcmp(res->mode_value, "IP")) {
10360 printf("Please set mode to IP.\n");
10364 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10365 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10366 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10367 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10368 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10369 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10370 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10373 cmd_reconfig_device_queue(res->port_id, 1, 1);
10376 cmdline_parse_token_string_t cmd_flow_director_mask =
10377 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10378 flow_director_mask, "flow_director_mask");
10379 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10380 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10382 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10383 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10385 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10386 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10387 vlan_mask, UINT16);
10388 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10389 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10390 src_mask, "src_mask");
10391 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10392 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10394 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10395 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10397 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10398 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10400 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10401 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10402 dst_mask, "dst_mask");
10403 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10404 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10406 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10407 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10409 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10410 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10413 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10414 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10416 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10417 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10419 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10420 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10421 mode_value, "MAC-VLAN");
10422 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10423 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10424 mode_value, "Tunnel");
10425 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10426 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10428 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10429 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10430 mac_addr_byte_mask, UINT8);
10431 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10432 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10433 tunnel_type, "tunnel-type");
10434 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10435 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10436 tunnel_type_mask, UINT8);
10437 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10438 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10439 tunnel_id, "tunnel-id");
10440 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10441 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10442 tunnel_id_mask, UINT32);
10444 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10445 .f = cmd_flow_director_mask_parsed,
10447 .help_str = "flow_director_mask ... : "
10448 "Set IP mode flow director's mask on NIC",
10450 (void *)&cmd_flow_director_mask,
10451 (void *)&cmd_flow_director_mask_port_id,
10452 (void *)&cmd_flow_director_mask_mode,
10453 (void *)&cmd_flow_director_mask_mode_ip,
10454 (void *)&cmd_flow_director_mask_vlan,
10455 (void *)&cmd_flow_director_mask_vlan_value,
10456 (void *)&cmd_flow_director_mask_src,
10457 (void *)&cmd_flow_director_mask_ipv4_src,
10458 (void *)&cmd_flow_director_mask_ipv6_src,
10459 (void *)&cmd_flow_director_mask_port_src,
10460 (void *)&cmd_flow_director_mask_dst,
10461 (void *)&cmd_flow_director_mask_ipv4_dst,
10462 (void *)&cmd_flow_director_mask_ipv6_dst,
10463 (void *)&cmd_flow_director_mask_port_dst,
10468 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10469 .f = cmd_flow_director_mask_parsed,
10471 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10472 "flow director's mask on NIC",
10474 (void *)&cmd_flow_director_mask,
10475 (void *)&cmd_flow_director_mask_port_id,
10476 (void *)&cmd_flow_director_mask_mode,
10477 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10478 (void *)&cmd_flow_director_mask_vlan,
10479 (void *)&cmd_flow_director_mask_vlan_value,
10484 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10485 .f = cmd_flow_director_mask_parsed,
10487 .help_str = "flow_director_mask ... : Set tunnel mode "
10488 "flow director's mask on NIC",
10490 (void *)&cmd_flow_director_mask,
10491 (void *)&cmd_flow_director_mask_port_id,
10492 (void *)&cmd_flow_director_mask_mode,
10493 (void *)&cmd_flow_director_mask_mode_tunnel,
10494 (void *)&cmd_flow_director_mask_vlan,
10495 (void *)&cmd_flow_director_mask_vlan_value,
10496 (void *)&cmd_flow_director_mask_mac,
10497 (void *)&cmd_flow_director_mask_mac_value,
10498 (void *)&cmd_flow_director_mask_tunnel_type,
10499 (void *)&cmd_flow_director_mask_tunnel_type_value,
10500 (void *)&cmd_flow_director_mask_tunnel_id,
10501 (void *)&cmd_flow_director_mask_tunnel_id_value,
10506 /* *** deal with flow director flexible payload configuration *** */
10507 struct cmd_flow_director_flexpayload_result {
10508 cmdline_fixed_string_t flow_director_flexpayload;
10510 cmdline_fixed_string_t payload_layer;
10511 cmdline_fixed_string_t payload_cfg;
10515 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10518 const char *p, *p0 = q_arg;
10520 unsigned long int_fld;
10521 char *str_fld[max_num];
10526 p = strchr(p0, '(');
10530 p0 = strchr(p, ')');
10535 if (size >= sizeof(s))
10538 snprintf(s, sizeof(s), "%.*s", size, p);
10539 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10540 if (ret < 0 || ret > max_num)
10542 for (i = 0; i < ret; i++) {
10544 int_fld = strtoul(str_fld[i], &end, 0);
10545 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10547 offsets[i] = (uint16_t)int_fld;
10553 cmd_flow_director_flxpld_parsed(void *parsed_result,
10554 __rte_unused struct cmdline *cl,
10555 __rte_unused void *data)
10557 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10558 struct rte_eth_flex_payload_cfg flex_cfg;
10559 struct rte_port *port;
10562 port = &ports[res->port_id];
10563 /** Check if the port is not started **/
10564 if (port->port_status != RTE_PORT_STOPPED) {
10565 printf("Please stop port %d first\n", res->port_id);
10569 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10571 if (!strcmp(res->payload_layer, "raw"))
10572 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10573 else if (!strcmp(res->payload_layer, "l2"))
10574 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10575 else if (!strcmp(res->payload_layer, "l3"))
10576 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10577 else if (!strcmp(res->payload_layer, "l4"))
10578 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10580 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10581 RTE_ETH_FDIR_MAX_FLEXLEN);
10583 printf("error: Cannot parse flex payload input.\n");
10587 fdir_set_flex_payload(res->port_id, &flex_cfg);
10588 cmd_reconfig_device_queue(res->port_id, 1, 1);
10591 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10592 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10593 flow_director_flexpayload,
10594 "flow_director_flex_payload");
10595 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10596 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10598 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10599 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10600 payload_layer, "raw#l2#l3#l4");
10601 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10602 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10603 payload_cfg, NULL);
10605 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10606 .f = cmd_flow_director_flxpld_parsed,
10608 .help_str = "flow_director_flexpayload ... : "
10609 "Set flow director's flex payload on NIC",
10611 (void *)&cmd_flow_director_flexpayload,
10612 (void *)&cmd_flow_director_flexpayload_port_id,
10613 (void *)&cmd_flow_director_flexpayload_payload_layer,
10614 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10619 /* Generic flow interface command. */
10620 extern cmdline_parse_inst_t cmd_flow;
10622 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10623 struct cmd_mcast_addr_result {
10624 cmdline_fixed_string_t mcast_addr_cmd;
10625 cmdline_fixed_string_t what;
10627 struct rte_ether_addr mc_addr;
10630 static void cmd_mcast_addr_parsed(void *parsed_result,
10631 __rte_unused struct cmdline *cl,
10632 __rte_unused void *data)
10634 struct cmd_mcast_addr_result *res = parsed_result;
10636 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
10637 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10638 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10639 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10640 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10643 if (strcmp(res->what, "add") == 0)
10644 mcast_addr_add(res->port_num, &res->mc_addr);
10646 mcast_addr_remove(res->port_num, &res->mc_addr);
10649 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10650 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10651 mcast_addr_cmd, "mcast_addr");
10652 cmdline_parse_token_string_t cmd_mcast_addr_what =
10653 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10655 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10656 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
10657 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10658 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10660 cmdline_parse_inst_t cmd_mcast_addr = {
10661 .f = cmd_mcast_addr_parsed,
10663 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10664 "Add/Remove multicast MAC address on port_id",
10666 (void *)&cmd_mcast_addr_cmd,
10667 (void *)&cmd_mcast_addr_what,
10668 (void *)&cmd_mcast_addr_portnum,
10669 (void *)&cmd_mcast_addr_addr,
10674 /* l2 tunnel config
10675 * only support E-tag now.
10678 static enum rte_eth_tunnel_type
10679 str2fdir_l2_tunnel_type(char *string)
10683 static const struct {
10685 enum rte_eth_tunnel_type type;
10686 } l2_tunnel_type_str[] = {
10687 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
10690 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
10691 if (!strcmp(l2_tunnel_type_str[i].str, string))
10692 return l2_tunnel_type_str[i].type;
10694 return RTE_TUNNEL_TYPE_NONE;
10697 /* Enable/disable l2 tunnel */
10698 struct cmd_config_l2_tunnel_en_dis_result {
10699 cmdline_fixed_string_t port;
10700 cmdline_fixed_string_t config;
10701 cmdline_fixed_string_t all;
10703 cmdline_fixed_string_t l2_tunnel;
10704 cmdline_fixed_string_t l2_tunnel_type;
10705 cmdline_fixed_string_t en_dis;
10708 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
10709 TOKEN_STRING_INITIALIZER
10710 (struct cmd_config_l2_tunnel_en_dis_result,
10712 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
10713 TOKEN_STRING_INITIALIZER
10714 (struct cmd_config_l2_tunnel_en_dis_result,
10716 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
10717 TOKEN_STRING_INITIALIZER
10718 (struct cmd_config_l2_tunnel_en_dis_result,
10720 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
10721 TOKEN_NUM_INITIALIZER
10722 (struct cmd_config_l2_tunnel_en_dis_result,
10724 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
10725 TOKEN_STRING_INITIALIZER
10726 (struct cmd_config_l2_tunnel_en_dis_result,
10727 l2_tunnel, "l2-tunnel");
10728 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
10729 TOKEN_STRING_INITIALIZER
10730 (struct cmd_config_l2_tunnel_en_dis_result,
10731 l2_tunnel_type, "E-tag");
10732 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
10733 TOKEN_STRING_INITIALIZER
10734 (struct cmd_config_l2_tunnel_en_dis_result,
10735 en_dis, "enable#disable");
10737 /* enable/disable l2 tunnel for all ports */
10739 cmd_config_l2_tunnel_en_dis_all_parsed(
10740 void *parsed_result,
10741 __rte_unused struct cmdline *cl,
10742 __rte_unused void *data)
10744 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
10745 struct rte_eth_l2_tunnel_conf entry;
10749 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10751 if (!strcmp("enable", res->en_dis))
10756 RTE_ETH_FOREACH_DEV(pid) {
10757 rte_eth_dev_l2_tunnel_offload_set(pid,
10759 ETH_L2_TUNNEL_ENABLE_MASK,
10764 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
10765 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
10767 .help_str = "port config all l2-tunnel E-tag enable|disable",
10769 (void *)&cmd_config_l2_tunnel_en_dis_port,
10770 (void *)&cmd_config_l2_tunnel_en_dis_config,
10771 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
10772 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10773 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10774 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10779 /* enable/disable l2 tunnel for a port */
10781 cmd_config_l2_tunnel_en_dis_specific_parsed(
10782 void *parsed_result,
10783 __rte_unused struct cmdline *cl,
10784 __rte_unused void *data)
10786 struct cmd_config_l2_tunnel_en_dis_result *res =
10788 struct rte_eth_l2_tunnel_conf entry;
10790 if (port_id_is_invalid(res->id, ENABLED_WARN))
10793 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
10795 if (!strcmp("enable", res->en_dis))
10796 rte_eth_dev_l2_tunnel_offload_set(res->id,
10798 ETH_L2_TUNNEL_ENABLE_MASK,
10801 rte_eth_dev_l2_tunnel_offload_set(res->id,
10803 ETH_L2_TUNNEL_ENABLE_MASK,
10807 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
10808 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
10810 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
10812 (void *)&cmd_config_l2_tunnel_en_dis_port,
10813 (void *)&cmd_config_l2_tunnel_en_dis_config,
10814 (void *)&cmd_config_l2_tunnel_en_dis_id,
10815 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
10816 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
10817 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
10822 /* E-tag configuration */
10824 /* Common result structure for all E-tag configuration */
10825 struct cmd_config_e_tag_result {
10826 cmdline_fixed_string_t e_tag;
10827 cmdline_fixed_string_t set;
10828 cmdline_fixed_string_t insertion;
10829 cmdline_fixed_string_t stripping;
10830 cmdline_fixed_string_t forwarding;
10831 cmdline_fixed_string_t filter;
10832 cmdline_fixed_string_t add;
10833 cmdline_fixed_string_t del;
10834 cmdline_fixed_string_t on;
10835 cmdline_fixed_string_t off;
10836 cmdline_fixed_string_t on_off;
10837 cmdline_fixed_string_t port_tag_id;
10838 uint32_t port_tag_id_val;
10839 cmdline_fixed_string_t e_tag_id;
10840 uint16_t e_tag_id_val;
10841 cmdline_fixed_string_t dst_pool;
10842 uint8_t dst_pool_val;
10843 cmdline_fixed_string_t port;
10845 cmdline_fixed_string_t vf;
10849 /* Common CLI fields for all E-tag configuration */
10850 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
10851 TOKEN_STRING_INITIALIZER
10852 (struct cmd_config_e_tag_result,
10854 cmdline_parse_token_string_t cmd_config_e_tag_set =
10855 TOKEN_STRING_INITIALIZER
10856 (struct cmd_config_e_tag_result,
10858 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
10859 TOKEN_STRING_INITIALIZER
10860 (struct cmd_config_e_tag_result,
10861 insertion, "insertion");
10862 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
10863 TOKEN_STRING_INITIALIZER
10864 (struct cmd_config_e_tag_result,
10865 stripping, "stripping");
10866 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
10867 TOKEN_STRING_INITIALIZER
10868 (struct cmd_config_e_tag_result,
10869 forwarding, "forwarding");
10870 cmdline_parse_token_string_t cmd_config_e_tag_filter =
10871 TOKEN_STRING_INITIALIZER
10872 (struct cmd_config_e_tag_result,
10874 cmdline_parse_token_string_t cmd_config_e_tag_add =
10875 TOKEN_STRING_INITIALIZER
10876 (struct cmd_config_e_tag_result,
10878 cmdline_parse_token_string_t cmd_config_e_tag_del =
10879 TOKEN_STRING_INITIALIZER
10880 (struct cmd_config_e_tag_result,
10882 cmdline_parse_token_string_t cmd_config_e_tag_on =
10883 TOKEN_STRING_INITIALIZER
10884 (struct cmd_config_e_tag_result,
10886 cmdline_parse_token_string_t cmd_config_e_tag_off =
10887 TOKEN_STRING_INITIALIZER
10888 (struct cmd_config_e_tag_result,
10890 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
10891 TOKEN_STRING_INITIALIZER
10892 (struct cmd_config_e_tag_result,
10894 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
10895 TOKEN_STRING_INITIALIZER
10896 (struct cmd_config_e_tag_result,
10897 port_tag_id, "port-tag-id");
10898 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
10899 TOKEN_NUM_INITIALIZER
10900 (struct cmd_config_e_tag_result,
10901 port_tag_id_val, UINT32);
10902 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
10903 TOKEN_STRING_INITIALIZER
10904 (struct cmd_config_e_tag_result,
10905 e_tag_id, "e-tag-id");
10906 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
10907 TOKEN_NUM_INITIALIZER
10908 (struct cmd_config_e_tag_result,
10909 e_tag_id_val, UINT16);
10910 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
10911 TOKEN_STRING_INITIALIZER
10912 (struct cmd_config_e_tag_result,
10913 dst_pool, "dst-pool");
10914 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
10915 TOKEN_NUM_INITIALIZER
10916 (struct cmd_config_e_tag_result,
10917 dst_pool_val, UINT8);
10918 cmdline_parse_token_string_t cmd_config_e_tag_port =
10919 TOKEN_STRING_INITIALIZER
10920 (struct cmd_config_e_tag_result,
10922 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
10923 TOKEN_NUM_INITIALIZER
10924 (struct cmd_config_e_tag_result,
10926 cmdline_parse_token_string_t cmd_config_e_tag_vf =
10927 TOKEN_STRING_INITIALIZER
10928 (struct cmd_config_e_tag_result,
10930 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
10931 TOKEN_NUM_INITIALIZER
10932 (struct cmd_config_e_tag_result,
10935 /* E-tag insertion configuration */
10937 cmd_config_e_tag_insertion_en_parsed(
10938 void *parsed_result,
10939 __rte_unused struct cmdline *cl,
10940 __rte_unused void *data)
10942 struct cmd_config_e_tag_result *res =
10944 struct rte_eth_l2_tunnel_conf entry;
10946 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10949 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10950 entry.tunnel_id = res->port_tag_id_val;
10951 entry.vf_id = res->vf_id;
10952 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10954 ETH_L2_TUNNEL_INSERTION_MASK,
10959 cmd_config_e_tag_insertion_dis_parsed(
10960 void *parsed_result,
10961 __rte_unused struct cmdline *cl,
10962 __rte_unused void *data)
10964 struct cmd_config_e_tag_result *res =
10966 struct rte_eth_l2_tunnel_conf entry;
10968 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10971 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
10972 entry.vf_id = res->vf_id;
10974 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
10976 ETH_L2_TUNNEL_INSERTION_MASK,
10980 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
10981 .f = cmd_config_e_tag_insertion_en_parsed,
10983 .help_str = "E-tag ... : E-tag insertion enable",
10985 (void *)&cmd_config_e_tag_e_tag,
10986 (void *)&cmd_config_e_tag_set,
10987 (void *)&cmd_config_e_tag_insertion,
10988 (void *)&cmd_config_e_tag_on,
10989 (void *)&cmd_config_e_tag_port_tag_id,
10990 (void *)&cmd_config_e_tag_port_tag_id_val,
10991 (void *)&cmd_config_e_tag_port,
10992 (void *)&cmd_config_e_tag_port_id,
10993 (void *)&cmd_config_e_tag_vf,
10994 (void *)&cmd_config_e_tag_vf_id,
10999 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
11000 .f = cmd_config_e_tag_insertion_dis_parsed,
11002 .help_str = "E-tag ... : E-tag insertion disable",
11004 (void *)&cmd_config_e_tag_e_tag,
11005 (void *)&cmd_config_e_tag_set,
11006 (void *)&cmd_config_e_tag_insertion,
11007 (void *)&cmd_config_e_tag_off,
11008 (void *)&cmd_config_e_tag_port,
11009 (void *)&cmd_config_e_tag_port_id,
11010 (void *)&cmd_config_e_tag_vf,
11011 (void *)&cmd_config_e_tag_vf_id,
11016 /* E-tag stripping configuration */
11018 cmd_config_e_tag_stripping_parsed(
11019 void *parsed_result,
11020 __rte_unused struct cmdline *cl,
11021 __rte_unused void *data)
11023 struct cmd_config_e_tag_result *res =
11025 struct rte_eth_l2_tunnel_conf entry;
11027 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11030 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11032 if (!strcmp(res->on_off, "on"))
11033 rte_eth_dev_l2_tunnel_offload_set
11036 ETH_L2_TUNNEL_STRIPPING_MASK,
11039 rte_eth_dev_l2_tunnel_offload_set
11042 ETH_L2_TUNNEL_STRIPPING_MASK,
11046 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
11047 .f = cmd_config_e_tag_stripping_parsed,
11049 .help_str = "E-tag ... : E-tag stripping enable/disable",
11051 (void *)&cmd_config_e_tag_e_tag,
11052 (void *)&cmd_config_e_tag_set,
11053 (void *)&cmd_config_e_tag_stripping,
11054 (void *)&cmd_config_e_tag_on_off,
11055 (void *)&cmd_config_e_tag_port,
11056 (void *)&cmd_config_e_tag_port_id,
11061 /* E-tag forwarding configuration */
11063 cmd_config_e_tag_forwarding_parsed(
11064 void *parsed_result,
11065 __rte_unused struct cmdline *cl,
11066 __rte_unused void *data)
11068 struct cmd_config_e_tag_result *res = parsed_result;
11069 struct rte_eth_l2_tunnel_conf entry;
11071 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11074 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
11076 if (!strcmp(res->on_off, "on"))
11077 rte_eth_dev_l2_tunnel_offload_set
11080 ETH_L2_TUNNEL_FORWARDING_MASK,
11083 rte_eth_dev_l2_tunnel_offload_set
11086 ETH_L2_TUNNEL_FORWARDING_MASK,
11090 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
11091 .f = cmd_config_e_tag_forwarding_parsed,
11093 .help_str = "E-tag ... : E-tag forwarding enable/disable",
11095 (void *)&cmd_config_e_tag_e_tag,
11096 (void *)&cmd_config_e_tag_set,
11097 (void *)&cmd_config_e_tag_forwarding,
11098 (void *)&cmd_config_e_tag_on_off,
11099 (void *)&cmd_config_e_tag_port,
11100 (void *)&cmd_config_e_tag_port_id,
11105 /* vf vlan anti spoof configuration */
11107 /* Common result structure for vf vlan anti spoof */
11108 struct cmd_vf_vlan_anti_spoof_result {
11109 cmdline_fixed_string_t set;
11110 cmdline_fixed_string_t vf;
11111 cmdline_fixed_string_t vlan;
11112 cmdline_fixed_string_t antispoof;
11115 cmdline_fixed_string_t on_off;
11118 /* Common CLI fields for vf vlan anti spoof enable disable */
11119 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
11120 TOKEN_STRING_INITIALIZER
11121 (struct cmd_vf_vlan_anti_spoof_result,
11123 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
11124 TOKEN_STRING_INITIALIZER
11125 (struct cmd_vf_vlan_anti_spoof_result,
11127 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
11128 TOKEN_STRING_INITIALIZER
11129 (struct cmd_vf_vlan_anti_spoof_result,
11131 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
11132 TOKEN_STRING_INITIALIZER
11133 (struct cmd_vf_vlan_anti_spoof_result,
11134 antispoof, "antispoof");
11135 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
11136 TOKEN_NUM_INITIALIZER
11137 (struct cmd_vf_vlan_anti_spoof_result,
11139 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
11140 TOKEN_NUM_INITIALIZER
11141 (struct cmd_vf_vlan_anti_spoof_result,
11143 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
11144 TOKEN_STRING_INITIALIZER
11145 (struct cmd_vf_vlan_anti_spoof_result,
11149 cmd_set_vf_vlan_anti_spoof_parsed(
11150 void *parsed_result,
11151 __rte_unused struct cmdline *cl,
11152 __rte_unused void *data)
11154 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
11155 int ret = -ENOTSUP;
11157 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11159 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11162 #ifdef RTE_NET_IXGBE
11163 if (ret == -ENOTSUP)
11164 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11165 res->vf_id, is_on);
11167 #ifdef RTE_NET_I40E
11168 if (ret == -ENOTSUP)
11169 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11170 res->vf_id, is_on);
11172 #ifdef RTE_NET_BNXT
11173 if (ret == -ENOTSUP)
11174 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11175 res->vf_id, is_on);
11182 printf("invalid vf_id %d\n", res->vf_id);
11185 printf("invalid port_id %d\n", res->port_id);
11188 printf("function not implemented\n");
11191 printf("programming error: (%s)\n", strerror(-ret));
11195 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11196 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11198 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11200 (void *)&cmd_vf_vlan_anti_spoof_set,
11201 (void *)&cmd_vf_vlan_anti_spoof_vf,
11202 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11203 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11204 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11205 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11206 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11211 /* vf mac anti spoof configuration */
11213 /* Common result structure for vf mac anti spoof */
11214 struct cmd_vf_mac_anti_spoof_result {
11215 cmdline_fixed_string_t set;
11216 cmdline_fixed_string_t vf;
11217 cmdline_fixed_string_t mac;
11218 cmdline_fixed_string_t antispoof;
11221 cmdline_fixed_string_t on_off;
11224 /* Common CLI fields for vf mac anti spoof enable disable */
11225 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11226 TOKEN_STRING_INITIALIZER
11227 (struct cmd_vf_mac_anti_spoof_result,
11229 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11230 TOKEN_STRING_INITIALIZER
11231 (struct cmd_vf_mac_anti_spoof_result,
11233 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11234 TOKEN_STRING_INITIALIZER
11235 (struct cmd_vf_mac_anti_spoof_result,
11237 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11238 TOKEN_STRING_INITIALIZER
11239 (struct cmd_vf_mac_anti_spoof_result,
11240 antispoof, "antispoof");
11241 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11242 TOKEN_NUM_INITIALIZER
11243 (struct cmd_vf_mac_anti_spoof_result,
11245 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11246 TOKEN_NUM_INITIALIZER
11247 (struct cmd_vf_mac_anti_spoof_result,
11249 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11250 TOKEN_STRING_INITIALIZER
11251 (struct cmd_vf_mac_anti_spoof_result,
11255 cmd_set_vf_mac_anti_spoof_parsed(
11256 void *parsed_result,
11257 __rte_unused struct cmdline *cl,
11258 __rte_unused void *data)
11260 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11261 int ret = -ENOTSUP;
11263 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11265 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11268 #ifdef RTE_NET_IXGBE
11269 if (ret == -ENOTSUP)
11270 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11271 res->vf_id, is_on);
11273 #ifdef RTE_NET_I40E
11274 if (ret == -ENOTSUP)
11275 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11276 res->vf_id, is_on);
11278 #ifdef RTE_NET_BNXT
11279 if (ret == -ENOTSUP)
11280 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11281 res->vf_id, is_on);
11288 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11291 printf("invalid port_id %d\n", res->port_id);
11294 printf("function not implemented\n");
11297 printf("programming error: (%s)\n", strerror(-ret));
11301 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11302 .f = cmd_set_vf_mac_anti_spoof_parsed,
11304 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11306 (void *)&cmd_vf_mac_anti_spoof_set,
11307 (void *)&cmd_vf_mac_anti_spoof_vf,
11308 (void *)&cmd_vf_mac_anti_spoof_mac,
11309 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11310 (void *)&cmd_vf_mac_anti_spoof_port_id,
11311 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11312 (void *)&cmd_vf_mac_anti_spoof_on_off,
11317 /* vf vlan strip queue configuration */
11319 /* Common result structure for vf mac anti spoof */
11320 struct cmd_vf_vlan_stripq_result {
11321 cmdline_fixed_string_t set;
11322 cmdline_fixed_string_t vf;
11323 cmdline_fixed_string_t vlan;
11324 cmdline_fixed_string_t stripq;
11327 cmdline_fixed_string_t on_off;
11330 /* Common CLI fields for vf vlan strip enable disable */
11331 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11332 TOKEN_STRING_INITIALIZER
11333 (struct cmd_vf_vlan_stripq_result,
11335 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11336 TOKEN_STRING_INITIALIZER
11337 (struct cmd_vf_vlan_stripq_result,
11339 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11340 TOKEN_STRING_INITIALIZER
11341 (struct cmd_vf_vlan_stripq_result,
11343 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11344 TOKEN_STRING_INITIALIZER
11345 (struct cmd_vf_vlan_stripq_result,
11347 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11348 TOKEN_NUM_INITIALIZER
11349 (struct cmd_vf_vlan_stripq_result,
11351 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11352 TOKEN_NUM_INITIALIZER
11353 (struct cmd_vf_vlan_stripq_result,
11355 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11356 TOKEN_STRING_INITIALIZER
11357 (struct cmd_vf_vlan_stripq_result,
11361 cmd_set_vf_vlan_stripq_parsed(
11362 void *parsed_result,
11363 __rte_unused struct cmdline *cl,
11364 __rte_unused void *data)
11366 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11367 int ret = -ENOTSUP;
11369 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11371 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11374 #ifdef RTE_NET_IXGBE
11375 if (ret == -ENOTSUP)
11376 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11377 res->vf_id, is_on);
11379 #ifdef RTE_NET_I40E
11380 if (ret == -ENOTSUP)
11381 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11382 res->vf_id, is_on);
11384 #ifdef RTE_NET_BNXT
11385 if (ret == -ENOTSUP)
11386 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11387 res->vf_id, is_on);
11394 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11397 printf("invalid port_id %d\n", res->port_id);
11400 printf("function not implemented\n");
11403 printf("programming error: (%s)\n", strerror(-ret));
11407 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11408 .f = cmd_set_vf_vlan_stripq_parsed,
11410 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11412 (void *)&cmd_vf_vlan_stripq_set,
11413 (void *)&cmd_vf_vlan_stripq_vf,
11414 (void *)&cmd_vf_vlan_stripq_vlan,
11415 (void *)&cmd_vf_vlan_stripq_stripq,
11416 (void *)&cmd_vf_vlan_stripq_port_id,
11417 (void *)&cmd_vf_vlan_stripq_vf_id,
11418 (void *)&cmd_vf_vlan_stripq_on_off,
11423 /* vf vlan insert configuration */
11425 /* Common result structure for vf vlan insert */
11426 struct cmd_vf_vlan_insert_result {
11427 cmdline_fixed_string_t set;
11428 cmdline_fixed_string_t vf;
11429 cmdline_fixed_string_t vlan;
11430 cmdline_fixed_string_t insert;
11436 /* Common CLI fields for vf vlan insert enable disable */
11437 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11438 TOKEN_STRING_INITIALIZER
11439 (struct cmd_vf_vlan_insert_result,
11441 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11442 TOKEN_STRING_INITIALIZER
11443 (struct cmd_vf_vlan_insert_result,
11445 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11446 TOKEN_STRING_INITIALIZER
11447 (struct cmd_vf_vlan_insert_result,
11449 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11450 TOKEN_STRING_INITIALIZER
11451 (struct cmd_vf_vlan_insert_result,
11453 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11454 TOKEN_NUM_INITIALIZER
11455 (struct cmd_vf_vlan_insert_result,
11457 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11458 TOKEN_NUM_INITIALIZER
11459 (struct cmd_vf_vlan_insert_result,
11461 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11462 TOKEN_NUM_INITIALIZER
11463 (struct cmd_vf_vlan_insert_result,
11467 cmd_set_vf_vlan_insert_parsed(
11468 void *parsed_result,
11469 __rte_unused struct cmdline *cl,
11470 __rte_unused void *data)
11472 struct cmd_vf_vlan_insert_result *res = parsed_result;
11473 int ret = -ENOTSUP;
11475 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11478 #ifdef RTE_NET_IXGBE
11479 if (ret == -ENOTSUP)
11480 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11483 #ifdef RTE_NET_I40E
11484 if (ret == -ENOTSUP)
11485 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11488 #ifdef RTE_NET_BNXT
11489 if (ret == -ENOTSUP)
11490 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11498 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11501 printf("invalid port_id %d\n", res->port_id);
11504 printf("function not implemented\n");
11507 printf("programming error: (%s)\n", strerror(-ret));
11511 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11512 .f = cmd_set_vf_vlan_insert_parsed,
11514 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11516 (void *)&cmd_vf_vlan_insert_set,
11517 (void *)&cmd_vf_vlan_insert_vf,
11518 (void *)&cmd_vf_vlan_insert_vlan,
11519 (void *)&cmd_vf_vlan_insert_insert,
11520 (void *)&cmd_vf_vlan_insert_port_id,
11521 (void *)&cmd_vf_vlan_insert_vf_id,
11522 (void *)&cmd_vf_vlan_insert_vlan_id,
11527 /* tx loopback configuration */
11529 /* Common result structure for tx loopback */
11530 struct cmd_tx_loopback_result {
11531 cmdline_fixed_string_t set;
11532 cmdline_fixed_string_t tx;
11533 cmdline_fixed_string_t loopback;
11535 cmdline_fixed_string_t on_off;
11538 /* Common CLI fields for tx loopback enable disable */
11539 cmdline_parse_token_string_t cmd_tx_loopback_set =
11540 TOKEN_STRING_INITIALIZER
11541 (struct cmd_tx_loopback_result,
11543 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11544 TOKEN_STRING_INITIALIZER
11545 (struct cmd_tx_loopback_result,
11547 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11548 TOKEN_STRING_INITIALIZER
11549 (struct cmd_tx_loopback_result,
11550 loopback, "loopback");
11551 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11552 TOKEN_NUM_INITIALIZER
11553 (struct cmd_tx_loopback_result,
11555 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11556 TOKEN_STRING_INITIALIZER
11557 (struct cmd_tx_loopback_result,
11561 cmd_set_tx_loopback_parsed(
11562 void *parsed_result,
11563 __rte_unused struct cmdline *cl,
11564 __rte_unused void *data)
11566 struct cmd_tx_loopback_result *res = parsed_result;
11567 int ret = -ENOTSUP;
11569 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11571 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11574 #ifdef RTE_NET_IXGBE
11575 if (ret == -ENOTSUP)
11576 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11578 #ifdef RTE_NET_I40E
11579 if (ret == -ENOTSUP)
11580 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11582 #ifdef RTE_NET_BNXT
11583 if (ret == -ENOTSUP)
11584 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11586 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11587 if (ret == -ENOTSUP)
11588 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11595 printf("invalid is_on %d\n", is_on);
11598 printf("invalid port_id %d\n", res->port_id);
11601 printf("function not implemented\n");
11604 printf("programming error: (%s)\n", strerror(-ret));
11608 cmdline_parse_inst_t cmd_set_tx_loopback = {
11609 .f = cmd_set_tx_loopback_parsed,
11611 .help_str = "set tx loopback <port_id> on|off",
11613 (void *)&cmd_tx_loopback_set,
11614 (void *)&cmd_tx_loopback_tx,
11615 (void *)&cmd_tx_loopback_loopback,
11616 (void *)&cmd_tx_loopback_port_id,
11617 (void *)&cmd_tx_loopback_on_off,
11622 /* all queues drop enable configuration */
11624 /* Common result structure for all queues drop enable */
11625 struct cmd_all_queues_drop_en_result {
11626 cmdline_fixed_string_t set;
11627 cmdline_fixed_string_t all;
11628 cmdline_fixed_string_t queues;
11629 cmdline_fixed_string_t drop;
11631 cmdline_fixed_string_t on_off;
11634 /* Common CLI fields for tx loopback enable disable */
11635 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11636 TOKEN_STRING_INITIALIZER
11637 (struct cmd_all_queues_drop_en_result,
11639 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11640 TOKEN_STRING_INITIALIZER
11641 (struct cmd_all_queues_drop_en_result,
11643 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11644 TOKEN_STRING_INITIALIZER
11645 (struct cmd_all_queues_drop_en_result,
11647 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11648 TOKEN_STRING_INITIALIZER
11649 (struct cmd_all_queues_drop_en_result,
11651 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11652 TOKEN_NUM_INITIALIZER
11653 (struct cmd_all_queues_drop_en_result,
11655 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11656 TOKEN_STRING_INITIALIZER
11657 (struct cmd_all_queues_drop_en_result,
11661 cmd_set_all_queues_drop_en_parsed(
11662 void *parsed_result,
11663 __rte_unused struct cmdline *cl,
11664 __rte_unused void *data)
11666 struct cmd_all_queues_drop_en_result *res = parsed_result;
11667 int ret = -ENOTSUP;
11668 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11670 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11673 #ifdef RTE_NET_IXGBE
11674 if (ret == -ENOTSUP)
11675 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11677 #ifdef RTE_NET_BNXT
11678 if (ret == -ENOTSUP)
11679 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11685 printf("invalid is_on %d\n", is_on);
11688 printf("invalid port_id %d\n", res->port_id);
11691 printf("function not implemented\n");
11694 printf("programming error: (%s)\n", strerror(-ret));
11698 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11699 .f = cmd_set_all_queues_drop_en_parsed,
11701 .help_str = "set all queues drop <port_id> on|off",
11703 (void *)&cmd_all_queues_drop_en_set,
11704 (void *)&cmd_all_queues_drop_en_all,
11705 (void *)&cmd_all_queues_drop_en_queues,
11706 (void *)&cmd_all_queues_drop_en_drop,
11707 (void *)&cmd_all_queues_drop_en_port_id,
11708 (void *)&cmd_all_queues_drop_en_on_off,
11713 /* vf split drop enable configuration */
11715 /* Common result structure for vf split drop enable */
11716 struct cmd_vf_split_drop_en_result {
11717 cmdline_fixed_string_t set;
11718 cmdline_fixed_string_t vf;
11719 cmdline_fixed_string_t split;
11720 cmdline_fixed_string_t drop;
11723 cmdline_fixed_string_t on_off;
11726 /* Common CLI fields for vf split drop enable disable */
11727 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11728 TOKEN_STRING_INITIALIZER
11729 (struct cmd_vf_split_drop_en_result,
11731 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11732 TOKEN_STRING_INITIALIZER
11733 (struct cmd_vf_split_drop_en_result,
11735 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11736 TOKEN_STRING_INITIALIZER
11737 (struct cmd_vf_split_drop_en_result,
11739 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11740 TOKEN_STRING_INITIALIZER
11741 (struct cmd_vf_split_drop_en_result,
11743 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11744 TOKEN_NUM_INITIALIZER
11745 (struct cmd_vf_split_drop_en_result,
11747 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11748 TOKEN_NUM_INITIALIZER
11749 (struct cmd_vf_split_drop_en_result,
11751 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11752 TOKEN_STRING_INITIALIZER
11753 (struct cmd_vf_split_drop_en_result,
11757 cmd_set_vf_split_drop_en_parsed(
11758 void *parsed_result,
11759 __rte_unused struct cmdline *cl,
11760 __rte_unused void *data)
11762 struct cmd_vf_split_drop_en_result *res = parsed_result;
11763 int ret = -ENOTSUP;
11764 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11766 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11769 #ifdef RTE_NET_IXGBE
11770 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11777 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11780 printf("invalid port_id %d\n", res->port_id);
11783 printf("not supported on port %d\n", res->port_id);
11786 printf("programming error: (%s)\n", strerror(-ret));
11790 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11791 .f = cmd_set_vf_split_drop_en_parsed,
11793 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11795 (void *)&cmd_vf_split_drop_en_set,
11796 (void *)&cmd_vf_split_drop_en_vf,
11797 (void *)&cmd_vf_split_drop_en_split,
11798 (void *)&cmd_vf_split_drop_en_drop,
11799 (void *)&cmd_vf_split_drop_en_port_id,
11800 (void *)&cmd_vf_split_drop_en_vf_id,
11801 (void *)&cmd_vf_split_drop_en_on_off,
11806 /* vf mac address configuration */
11808 /* Common result structure for vf mac address */
11809 struct cmd_set_vf_mac_addr_result {
11810 cmdline_fixed_string_t set;
11811 cmdline_fixed_string_t vf;
11812 cmdline_fixed_string_t mac;
11813 cmdline_fixed_string_t addr;
11816 struct rte_ether_addr mac_addr;
11820 /* Common CLI fields for vf split drop enable disable */
11821 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11822 TOKEN_STRING_INITIALIZER
11823 (struct cmd_set_vf_mac_addr_result,
11825 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11826 TOKEN_STRING_INITIALIZER
11827 (struct cmd_set_vf_mac_addr_result,
11829 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11830 TOKEN_STRING_INITIALIZER
11831 (struct cmd_set_vf_mac_addr_result,
11833 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11834 TOKEN_STRING_INITIALIZER
11835 (struct cmd_set_vf_mac_addr_result,
11837 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11838 TOKEN_NUM_INITIALIZER
11839 (struct cmd_set_vf_mac_addr_result,
11841 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11842 TOKEN_NUM_INITIALIZER
11843 (struct cmd_set_vf_mac_addr_result,
11845 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11846 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11850 cmd_set_vf_mac_addr_parsed(
11851 void *parsed_result,
11852 __rte_unused struct cmdline *cl,
11853 __rte_unused void *data)
11855 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11856 int ret = -ENOTSUP;
11858 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11861 #ifdef RTE_NET_IXGBE
11862 if (ret == -ENOTSUP)
11863 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11866 #ifdef RTE_NET_I40E
11867 if (ret == -ENOTSUP)
11868 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11871 #ifdef RTE_NET_BNXT
11872 if (ret == -ENOTSUP)
11873 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11881 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11884 printf("invalid port_id %d\n", res->port_id);
11887 printf("function not implemented\n");
11890 printf("programming error: (%s)\n", strerror(-ret));
11894 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11895 .f = cmd_set_vf_mac_addr_parsed,
11897 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11899 (void *)&cmd_set_vf_mac_addr_set,
11900 (void *)&cmd_set_vf_mac_addr_vf,
11901 (void *)&cmd_set_vf_mac_addr_mac,
11902 (void *)&cmd_set_vf_mac_addr_addr,
11903 (void *)&cmd_set_vf_mac_addr_port_id,
11904 (void *)&cmd_set_vf_mac_addr_vf_id,
11905 (void *)&cmd_set_vf_mac_addr_mac_addr,
11910 /* MACsec configuration */
11912 /* Common result structure for MACsec offload enable */
11913 struct cmd_macsec_offload_on_result {
11914 cmdline_fixed_string_t set;
11915 cmdline_fixed_string_t macsec;
11916 cmdline_fixed_string_t offload;
11918 cmdline_fixed_string_t on;
11919 cmdline_fixed_string_t encrypt;
11920 cmdline_fixed_string_t en_on_off;
11921 cmdline_fixed_string_t replay_protect;
11922 cmdline_fixed_string_t rp_on_off;
11925 /* Common CLI fields for MACsec offload disable */
11926 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11927 TOKEN_STRING_INITIALIZER
11928 (struct cmd_macsec_offload_on_result,
11930 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11931 TOKEN_STRING_INITIALIZER
11932 (struct cmd_macsec_offload_on_result,
11934 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11935 TOKEN_STRING_INITIALIZER
11936 (struct cmd_macsec_offload_on_result,
11937 offload, "offload");
11938 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11939 TOKEN_NUM_INITIALIZER
11940 (struct cmd_macsec_offload_on_result,
11942 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11943 TOKEN_STRING_INITIALIZER
11944 (struct cmd_macsec_offload_on_result,
11946 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11947 TOKEN_STRING_INITIALIZER
11948 (struct cmd_macsec_offload_on_result,
11949 encrypt, "encrypt");
11950 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11951 TOKEN_STRING_INITIALIZER
11952 (struct cmd_macsec_offload_on_result,
11953 en_on_off, "on#off");
11954 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11955 TOKEN_STRING_INITIALIZER
11956 (struct cmd_macsec_offload_on_result,
11957 replay_protect, "replay-protect");
11958 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11959 TOKEN_STRING_INITIALIZER
11960 (struct cmd_macsec_offload_on_result,
11961 rp_on_off, "on#off");
11964 cmd_set_macsec_offload_on_parsed(
11965 void *parsed_result,
11966 __rte_unused struct cmdline *cl,
11967 __rte_unused void *data)
11969 struct cmd_macsec_offload_on_result *res = parsed_result;
11970 int ret = -ENOTSUP;
11971 portid_t port_id = res->port_id;
11972 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11973 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11974 struct rte_eth_dev_info dev_info;
11976 if (port_id_is_invalid(port_id, ENABLED_WARN))
11978 if (!port_is_stopped(port_id)) {
11979 printf("Please stop port %d first\n", port_id);
11983 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11987 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11988 #ifdef RTE_NET_IXGBE
11989 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11997 ports[port_id].dev_conf.txmode.offloads |=
11998 DEV_TX_OFFLOAD_MACSEC_INSERT;
11999 cmd_reconfig_device_queue(port_id, 1, 1);
12002 printf("invalid port_id %d\n", port_id);
12005 printf("not supported on port %d\n", port_id);
12008 printf("programming error: (%s)\n", strerror(-ret));
12012 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
12013 .f = cmd_set_macsec_offload_on_parsed,
12015 .help_str = "set macsec offload <port_id> on "
12016 "encrypt on|off replay-protect on|off",
12018 (void *)&cmd_macsec_offload_on_set,
12019 (void *)&cmd_macsec_offload_on_macsec,
12020 (void *)&cmd_macsec_offload_on_offload,
12021 (void *)&cmd_macsec_offload_on_port_id,
12022 (void *)&cmd_macsec_offload_on_on,
12023 (void *)&cmd_macsec_offload_on_encrypt,
12024 (void *)&cmd_macsec_offload_on_en_on_off,
12025 (void *)&cmd_macsec_offload_on_replay_protect,
12026 (void *)&cmd_macsec_offload_on_rp_on_off,
12031 /* Common result structure for MACsec offload disable */
12032 struct cmd_macsec_offload_off_result {
12033 cmdline_fixed_string_t set;
12034 cmdline_fixed_string_t macsec;
12035 cmdline_fixed_string_t offload;
12037 cmdline_fixed_string_t off;
12040 /* Common CLI fields for MACsec offload disable */
12041 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
12042 TOKEN_STRING_INITIALIZER
12043 (struct cmd_macsec_offload_off_result,
12045 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
12046 TOKEN_STRING_INITIALIZER
12047 (struct cmd_macsec_offload_off_result,
12049 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
12050 TOKEN_STRING_INITIALIZER
12051 (struct cmd_macsec_offload_off_result,
12052 offload, "offload");
12053 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
12054 TOKEN_NUM_INITIALIZER
12055 (struct cmd_macsec_offload_off_result,
12057 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
12058 TOKEN_STRING_INITIALIZER
12059 (struct cmd_macsec_offload_off_result,
12063 cmd_set_macsec_offload_off_parsed(
12064 void *parsed_result,
12065 __rte_unused struct cmdline *cl,
12066 __rte_unused void *data)
12068 struct cmd_macsec_offload_off_result *res = parsed_result;
12069 int ret = -ENOTSUP;
12070 struct rte_eth_dev_info dev_info;
12071 portid_t port_id = res->port_id;
12073 if (port_id_is_invalid(port_id, ENABLED_WARN))
12075 if (!port_is_stopped(port_id)) {
12076 printf("Please stop port %d first\n", port_id);
12080 ret = eth_dev_info_get_print_err(port_id, &dev_info);
12084 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
12085 #ifdef RTE_NET_IXGBE
12086 ret = rte_pmd_ixgbe_macsec_disable(port_id);
12091 ports[port_id].dev_conf.txmode.offloads &=
12092 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
12093 cmd_reconfig_device_queue(port_id, 1, 1);
12096 printf("invalid port_id %d\n", port_id);
12099 printf("not supported on port %d\n", port_id);
12102 printf("programming error: (%s)\n", strerror(-ret));
12106 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
12107 .f = cmd_set_macsec_offload_off_parsed,
12109 .help_str = "set macsec offload <port_id> off",
12111 (void *)&cmd_macsec_offload_off_set,
12112 (void *)&cmd_macsec_offload_off_macsec,
12113 (void *)&cmd_macsec_offload_off_offload,
12114 (void *)&cmd_macsec_offload_off_port_id,
12115 (void *)&cmd_macsec_offload_off_off,
12120 /* Common result structure for MACsec secure connection configure */
12121 struct cmd_macsec_sc_result {
12122 cmdline_fixed_string_t set;
12123 cmdline_fixed_string_t macsec;
12124 cmdline_fixed_string_t sc;
12125 cmdline_fixed_string_t tx_rx;
12127 struct rte_ether_addr mac;
12131 /* Common CLI fields for MACsec secure connection configure */
12132 cmdline_parse_token_string_t cmd_macsec_sc_set =
12133 TOKEN_STRING_INITIALIZER
12134 (struct cmd_macsec_sc_result,
12136 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
12137 TOKEN_STRING_INITIALIZER
12138 (struct cmd_macsec_sc_result,
12140 cmdline_parse_token_string_t cmd_macsec_sc_sc =
12141 TOKEN_STRING_INITIALIZER
12142 (struct cmd_macsec_sc_result,
12144 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
12145 TOKEN_STRING_INITIALIZER
12146 (struct cmd_macsec_sc_result,
12148 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
12149 TOKEN_NUM_INITIALIZER
12150 (struct cmd_macsec_sc_result,
12152 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
12153 TOKEN_ETHERADDR_INITIALIZER
12154 (struct cmd_macsec_sc_result,
12156 cmdline_parse_token_num_t cmd_macsec_sc_pi =
12157 TOKEN_NUM_INITIALIZER
12158 (struct cmd_macsec_sc_result,
12162 cmd_set_macsec_sc_parsed(
12163 void *parsed_result,
12164 __rte_unused struct cmdline *cl,
12165 __rte_unused void *data)
12167 struct cmd_macsec_sc_result *res = parsed_result;
12168 int ret = -ENOTSUP;
12169 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12171 #ifdef RTE_NET_IXGBE
12173 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12174 res->mac.addr_bytes) :
12175 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12176 res->mac.addr_bytes, res->pi);
12178 RTE_SET_USED(is_tx);
12184 printf("invalid port_id %d\n", res->port_id);
12187 printf("not supported on port %d\n", res->port_id);
12190 printf("programming error: (%s)\n", strerror(-ret));
12194 cmdline_parse_inst_t cmd_set_macsec_sc = {
12195 .f = cmd_set_macsec_sc_parsed,
12197 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12199 (void *)&cmd_macsec_sc_set,
12200 (void *)&cmd_macsec_sc_macsec,
12201 (void *)&cmd_macsec_sc_sc,
12202 (void *)&cmd_macsec_sc_tx_rx,
12203 (void *)&cmd_macsec_sc_port_id,
12204 (void *)&cmd_macsec_sc_mac,
12205 (void *)&cmd_macsec_sc_pi,
12210 /* Common result structure for MACsec secure connection configure */
12211 struct cmd_macsec_sa_result {
12212 cmdline_fixed_string_t set;
12213 cmdline_fixed_string_t macsec;
12214 cmdline_fixed_string_t sa;
12215 cmdline_fixed_string_t tx_rx;
12220 cmdline_fixed_string_t key;
12223 /* Common CLI fields for MACsec secure connection configure */
12224 cmdline_parse_token_string_t cmd_macsec_sa_set =
12225 TOKEN_STRING_INITIALIZER
12226 (struct cmd_macsec_sa_result,
12228 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12229 TOKEN_STRING_INITIALIZER
12230 (struct cmd_macsec_sa_result,
12232 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12233 TOKEN_STRING_INITIALIZER
12234 (struct cmd_macsec_sa_result,
12236 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12237 TOKEN_STRING_INITIALIZER
12238 (struct cmd_macsec_sa_result,
12240 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12241 TOKEN_NUM_INITIALIZER
12242 (struct cmd_macsec_sa_result,
12244 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12245 TOKEN_NUM_INITIALIZER
12246 (struct cmd_macsec_sa_result,
12248 cmdline_parse_token_num_t cmd_macsec_sa_an =
12249 TOKEN_NUM_INITIALIZER
12250 (struct cmd_macsec_sa_result,
12252 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12253 TOKEN_NUM_INITIALIZER
12254 (struct cmd_macsec_sa_result,
12256 cmdline_parse_token_string_t cmd_macsec_sa_key =
12257 TOKEN_STRING_INITIALIZER
12258 (struct cmd_macsec_sa_result,
12262 cmd_set_macsec_sa_parsed(
12263 void *parsed_result,
12264 __rte_unused struct cmdline *cl,
12265 __rte_unused void *data)
12267 struct cmd_macsec_sa_result *res = parsed_result;
12268 int ret = -ENOTSUP;
12269 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12270 uint8_t key[16] = { 0 };
12276 key_len = strlen(res->key) / 2;
12280 for (i = 0; i < key_len; i++) {
12281 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12284 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12287 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12290 #ifdef RTE_NET_IXGBE
12292 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12293 res->idx, res->an, res->pn, key) :
12294 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12295 res->idx, res->an, res->pn, key);
12297 RTE_SET_USED(is_tx);
12304 printf("invalid idx %d or an %d\n", res->idx, res->an);
12307 printf("invalid port_id %d\n", res->port_id);
12310 printf("not supported on port %d\n", res->port_id);
12313 printf("programming error: (%s)\n", strerror(-ret));
12317 cmdline_parse_inst_t cmd_set_macsec_sa = {
12318 .f = cmd_set_macsec_sa_parsed,
12320 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12322 (void *)&cmd_macsec_sa_set,
12323 (void *)&cmd_macsec_sa_macsec,
12324 (void *)&cmd_macsec_sa_sa,
12325 (void *)&cmd_macsec_sa_tx_rx,
12326 (void *)&cmd_macsec_sa_port_id,
12327 (void *)&cmd_macsec_sa_idx,
12328 (void *)&cmd_macsec_sa_an,
12329 (void *)&cmd_macsec_sa_pn,
12330 (void *)&cmd_macsec_sa_key,
12335 /* VF unicast promiscuous mode configuration */
12337 /* Common result structure for VF unicast promiscuous mode */
12338 struct cmd_vf_promisc_result {
12339 cmdline_fixed_string_t set;
12340 cmdline_fixed_string_t vf;
12341 cmdline_fixed_string_t promisc;
12344 cmdline_fixed_string_t on_off;
12347 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12348 cmdline_parse_token_string_t cmd_vf_promisc_set =
12349 TOKEN_STRING_INITIALIZER
12350 (struct cmd_vf_promisc_result,
12352 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12353 TOKEN_STRING_INITIALIZER
12354 (struct cmd_vf_promisc_result,
12356 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12357 TOKEN_STRING_INITIALIZER
12358 (struct cmd_vf_promisc_result,
12359 promisc, "promisc");
12360 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12361 TOKEN_NUM_INITIALIZER
12362 (struct cmd_vf_promisc_result,
12364 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12365 TOKEN_NUM_INITIALIZER
12366 (struct cmd_vf_promisc_result,
12368 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12369 TOKEN_STRING_INITIALIZER
12370 (struct cmd_vf_promisc_result,
12374 cmd_set_vf_promisc_parsed(
12375 void *parsed_result,
12376 __rte_unused struct cmdline *cl,
12377 __rte_unused void *data)
12379 struct cmd_vf_promisc_result *res = parsed_result;
12380 int ret = -ENOTSUP;
12382 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12384 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12387 #ifdef RTE_NET_I40E
12388 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12389 res->vf_id, is_on);
12396 printf("invalid vf_id %d\n", res->vf_id);
12399 printf("invalid port_id %d\n", res->port_id);
12402 printf("function not implemented\n");
12405 printf("programming error: (%s)\n", strerror(-ret));
12409 cmdline_parse_inst_t cmd_set_vf_promisc = {
12410 .f = cmd_set_vf_promisc_parsed,
12412 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12413 "Set unicast promiscuous mode for a VF from the PF",
12415 (void *)&cmd_vf_promisc_set,
12416 (void *)&cmd_vf_promisc_vf,
12417 (void *)&cmd_vf_promisc_promisc,
12418 (void *)&cmd_vf_promisc_port_id,
12419 (void *)&cmd_vf_promisc_vf_id,
12420 (void *)&cmd_vf_promisc_on_off,
12425 /* VF multicast promiscuous mode configuration */
12427 /* Common result structure for VF multicast promiscuous mode */
12428 struct cmd_vf_allmulti_result {
12429 cmdline_fixed_string_t set;
12430 cmdline_fixed_string_t vf;
12431 cmdline_fixed_string_t allmulti;
12434 cmdline_fixed_string_t on_off;
12437 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12438 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12439 TOKEN_STRING_INITIALIZER
12440 (struct cmd_vf_allmulti_result,
12442 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12443 TOKEN_STRING_INITIALIZER
12444 (struct cmd_vf_allmulti_result,
12446 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12447 TOKEN_STRING_INITIALIZER
12448 (struct cmd_vf_allmulti_result,
12449 allmulti, "allmulti");
12450 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12451 TOKEN_NUM_INITIALIZER
12452 (struct cmd_vf_allmulti_result,
12454 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12455 TOKEN_NUM_INITIALIZER
12456 (struct cmd_vf_allmulti_result,
12458 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12459 TOKEN_STRING_INITIALIZER
12460 (struct cmd_vf_allmulti_result,
12464 cmd_set_vf_allmulti_parsed(
12465 void *parsed_result,
12466 __rte_unused struct cmdline *cl,
12467 __rte_unused void *data)
12469 struct cmd_vf_allmulti_result *res = parsed_result;
12470 int ret = -ENOTSUP;
12472 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12474 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12477 #ifdef RTE_NET_I40E
12478 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12479 res->vf_id, is_on);
12486 printf("invalid vf_id %d\n", res->vf_id);
12489 printf("invalid port_id %d\n", res->port_id);
12492 printf("function not implemented\n");
12495 printf("programming error: (%s)\n", strerror(-ret));
12499 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12500 .f = cmd_set_vf_allmulti_parsed,
12502 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12503 "Set multicast promiscuous mode for a VF from the PF",
12505 (void *)&cmd_vf_allmulti_set,
12506 (void *)&cmd_vf_allmulti_vf,
12507 (void *)&cmd_vf_allmulti_allmulti,
12508 (void *)&cmd_vf_allmulti_port_id,
12509 (void *)&cmd_vf_allmulti_vf_id,
12510 (void *)&cmd_vf_allmulti_on_off,
12515 /* vf broadcast mode configuration */
12517 /* Common result structure for vf broadcast */
12518 struct cmd_set_vf_broadcast_result {
12519 cmdline_fixed_string_t set;
12520 cmdline_fixed_string_t vf;
12521 cmdline_fixed_string_t broadcast;
12524 cmdline_fixed_string_t on_off;
12527 /* Common CLI fields for vf broadcast enable disable */
12528 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12529 TOKEN_STRING_INITIALIZER
12530 (struct cmd_set_vf_broadcast_result,
12532 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12533 TOKEN_STRING_INITIALIZER
12534 (struct cmd_set_vf_broadcast_result,
12536 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12537 TOKEN_STRING_INITIALIZER
12538 (struct cmd_set_vf_broadcast_result,
12539 broadcast, "broadcast");
12540 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12541 TOKEN_NUM_INITIALIZER
12542 (struct cmd_set_vf_broadcast_result,
12544 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12545 TOKEN_NUM_INITIALIZER
12546 (struct cmd_set_vf_broadcast_result,
12548 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12549 TOKEN_STRING_INITIALIZER
12550 (struct cmd_set_vf_broadcast_result,
12554 cmd_set_vf_broadcast_parsed(
12555 void *parsed_result,
12556 __rte_unused struct cmdline *cl,
12557 __rte_unused void *data)
12559 struct cmd_set_vf_broadcast_result *res = parsed_result;
12560 int ret = -ENOTSUP;
12562 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12564 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12567 #ifdef RTE_NET_I40E
12568 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12569 res->vf_id, is_on);
12576 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12579 printf("invalid port_id %d\n", res->port_id);
12582 printf("function not implemented\n");
12585 printf("programming error: (%s)\n", strerror(-ret));
12589 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12590 .f = cmd_set_vf_broadcast_parsed,
12592 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12594 (void *)&cmd_set_vf_broadcast_set,
12595 (void *)&cmd_set_vf_broadcast_vf,
12596 (void *)&cmd_set_vf_broadcast_broadcast,
12597 (void *)&cmd_set_vf_broadcast_port_id,
12598 (void *)&cmd_set_vf_broadcast_vf_id,
12599 (void *)&cmd_set_vf_broadcast_on_off,
12604 /* vf vlan tag configuration */
12606 /* Common result structure for vf vlan tag */
12607 struct cmd_set_vf_vlan_tag_result {
12608 cmdline_fixed_string_t set;
12609 cmdline_fixed_string_t vf;
12610 cmdline_fixed_string_t vlan;
12611 cmdline_fixed_string_t tag;
12614 cmdline_fixed_string_t on_off;
12617 /* Common CLI fields for vf vlan tag enable disable */
12618 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12619 TOKEN_STRING_INITIALIZER
12620 (struct cmd_set_vf_vlan_tag_result,
12622 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12623 TOKEN_STRING_INITIALIZER
12624 (struct cmd_set_vf_vlan_tag_result,
12626 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12627 TOKEN_STRING_INITIALIZER
12628 (struct cmd_set_vf_vlan_tag_result,
12630 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12631 TOKEN_STRING_INITIALIZER
12632 (struct cmd_set_vf_vlan_tag_result,
12634 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12635 TOKEN_NUM_INITIALIZER
12636 (struct cmd_set_vf_vlan_tag_result,
12638 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12639 TOKEN_NUM_INITIALIZER
12640 (struct cmd_set_vf_vlan_tag_result,
12642 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12643 TOKEN_STRING_INITIALIZER
12644 (struct cmd_set_vf_vlan_tag_result,
12648 cmd_set_vf_vlan_tag_parsed(
12649 void *parsed_result,
12650 __rte_unused struct cmdline *cl,
12651 __rte_unused void *data)
12653 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12654 int ret = -ENOTSUP;
12656 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12658 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12661 #ifdef RTE_NET_I40E
12662 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12663 res->vf_id, is_on);
12670 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12673 printf("invalid port_id %d\n", res->port_id);
12676 printf("function not implemented\n");
12679 printf("programming error: (%s)\n", strerror(-ret));
12683 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12684 .f = cmd_set_vf_vlan_tag_parsed,
12686 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12688 (void *)&cmd_set_vf_vlan_tag_set,
12689 (void *)&cmd_set_vf_vlan_tag_vf,
12690 (void *)&cmd_set_vf_vlan_tag_vlan,
12691 (void *)&cmd_set_vf_vlan_tag_tag,
12692 (void *)&cmd_set_vf_vlan_tag_port_id,
12693 (void *)&cmd_set_vf_vlan_tag_vf_id,
12694 (void *)&cmd_set_vf_vlan_tag_on_off,
12699 /* Common definition of VF and TC TX bandwidth configuration */
12700 struct cmd_vf_tc_bw_result {
12701 cmdline_fixed_string_t set;
12702 cmdline_fixed_string_t vf;
12703 cmdline_fixed_string_t tc;
12704 cmdline_fixed_string_t tx;
12705 cmdline_fixed_string_t min_bw;
12706 cmdline_fixed_string_t max_bw;
12707 cmdline_fixed_string_t strict_link_prio;
12712 cmdline_fixed_string_t bw_list;
12716 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12717 TOKEN_STRING_INITIALIZER
12718 (struct cmd_vf_tc_bw_result,
12720 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12721 TOKEN_STRING_INITIALIZER
12722 (struct cmd_vf_tc_bw_result,
12724 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12725 TOKEN_STRING_INITIALIZER
12726 (struct cmd_vf_tc_bw_result,
12728 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12729 TOKEN_STRING_INITIALIZER
12730 (struct cmd_vf_tc_bw_result,
12732 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12733 TOKEN_STRING_INITIALIZER
12734 (struct cmd_vf_tc_bw_result,
12735 strict_link_prio, "strict-link-priority");
12736 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12737 TOKEN_STRING_INITIALIZER
12738 (struct cmd_vf_tc_bw_result,
12739 min_bw, "min-bandwidth");
12740 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12741 TOKEN_STRING_INITIALIZER
12742 (struct cmd_vf_tc_bw_result,
12743 max_bw, "max-bandwidth");
12744 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12745 TOKEN_NUM_INITIALIZER
12746 (struct cmd_vf_tc_bw_result,
12748 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12749 TOKEN_NUM_INITIALIZER
12750 (struct cmd_vf_tc_bw_result,
12752 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12753 TOKEN_NUM_INITIALIZER
12754 (struct cmd_vf_tc_bw_result,
12756 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12757 TOKEN_NUM_INITIALIZER
12758 (struct cmd_vf_tc_bw_result,
12760 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12761 TOKEN_STRING_INITIALIZER
12762 (struct cmd_vf_tc_bw_result,
12764 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12765 TOKEN_NUM_INITIALIZER
12766 (struct cmd_vf_tc_bw_result,
12769 /* VF max bandwidth setting */
12771 cmd_vf_max_bw_parsed(
12772 void *parsed_result,
12773 __rte_unused struct cmdline *cl,
12774 __rte_unused void *data)
12776 struct cmd_vf_tc_bw_result *res = parsed_result;
12777 int ret = -ENOTSUP;
12779 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12782 #ifdef RTE_NET_I40E
12783 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12784 res->vf_id, res->bw);
12791 printf("invalid vf_id %d or bandwidth %d\n",
12792 res->vf_id, res->bw);
12795 printf("invalid port_id %d\n", res->port_id);
12798 printf("function not implemented\n");
12801 printf("programming error: (%s)\n", strerror(-ret));
12805 cmdline_parse_inst_t cmd_vf_max_bw = {
12806 .f = cmd_vf_max_bw_parsed,
12808 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12810 (void *)&cmd_vf_tc_bw_set,
12811 (void *)&cmd_vf_tc_bw_vf,
12812 (void *)&cmd_vf_tc_bw_tx,
12813 (void *)&cmd_vf_tc_bw_max_bw,
12814 (void *)&cmd_vf_tc_bw_port_id,
12815 (void *)&cmd_vf_tc_bw_vf_id,
12816 (void *)&cmd_vf_tc_bw_bw,
12822 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12827 const char *p, *p0 = str;
12834 p = strchr(p0, '(');
12836 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12840 p0 = strchr(p, ')');
12842 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12846 if (size >= sizeof(s)) {
12847 printf("The string size exceeds the internal buffer size\n");
12850 snprintf(s, sizeof(s), "%.*s", size, p);
12851 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12853 printf("Failed to get the bandwidth list. ");
12857 for (i = 0; i < ret; i++)
12858 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12863 /* TC min bandwidth setting */
12865 cmd_vf_tc_min_bw_parsed(
12866 void *parsed_result,
12867 __rte_unused struct cmdline *cl,
12868 __rte_unused void *data)
12870 struct cmd_vf_tc_bw_result *res = parsed_result;
12873 int ret = -ENOTSUP;
12875 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12878 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12882 #ifdef RTE_NET_I40E
12883 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12891 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12894 printf("invalid port_id %d\n", res->port_id);
12897 printf("function not implemented\n");
12900 printf("programming error: (%s)\n", strerror(-ret));
12904 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12905 .f = cmd_vf_tc_min_bw_parsed,
12907 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12908 " <bw1, bw2, ...>",
12910 (void *)&cmd_vf_tc_bw_set,
12911 (void *)&cmd_vf_tc_bw_vf,
12912 (void *)&cmd_vf_tc_bw_tc,
12913 (void *)&cmd_vf_tc_bw_tx,
12914 (void *)&cmd_vf_tc_bw_min_bw,
12915 (void *)&cmd_vf_tc_bw_port_id,
12916 (void *)&cmd_vf_tc_bw_vf_id,
12917 (void *)&cmd_vf_tc_bw_bw_list,
12923 cmd_tc_min_bw_parsed(
12924 void *parsed_result,
12925 __rte_unused struct cmdline *cl,
12926 __rte_unused void *data)
12928 struct cmd_vf_tc_bw_result *res = parsed_result;
12929 struct rte_port *port;
12932 int ret = -ENOTSUP;
12934 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12937 port = &ports[res->port_id];
12938 /** Check if the port is not started **/
12939 if (port->port_status != RTE_PORT_STOPPED) {
12940 printf("Please stop port %d first\n", res->port_id);
12944 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12948 #ifdef RTE_NET_IXGBE
12949 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12956 printf("invalid bandwidth\n");
12959 printf("invalid port_id %d\n", res->port_id);
12962 printf("function not implemented\n");
12965 printf("programming error: (%s)\n", strerror(-ret));
12969 cmdline_parse_inst_t cmd_tc_min_bw = {
12970 .f = cmd_tc_min_bw_parsed,
12972 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12974 (void *)&cmd_vf_tc_bw_set,
12975 (void *)&cmd_vf_tc_bw_tc,
12976 (void *)&cmd_vf_tc_bw_tx,
12977 (void *)&cmd_vf_tc_bw_min_bw,
12978 (void *)&cmd_vf_tc_bw_port_id,
12979 (void *)&cmd_vf_tc_bw_bw_list,
12984 /* TC max bandwidth setting */
12986 cmd_vf_tc_max_bw_parsed(
12987 void *parsed_result,
12988 __rte_unused struct cmdline *cl,
12989 __rte_unused void *data)
12991 struct cmd_vf_tc_bw_result *res = parsed_result;
12992 int ret = -ENOTSUP;
12994 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12997 #ifdef RTE_NET_I40E
12998 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12999 res->tc_no, res->bw);
13006 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
13007 res->vf_id, res->tc_no, res->bw);
13010 printf("invalid port_id %d\n", res->port_id);
13013 printf("function not implemented\n");
13016 printf("programming error: (%s)\n", strerror(-ret));
13020 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
13021 .f = cmd_vf_tc_max_bw_parsed,
13023 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
13026 (void *)&cmd_vf_tc_bw_set,
13027 (void *)&cmd_vf_tc_bw_vf,
13028 (void *)&cmd_vf_tc_bw_tc,
13029 (void *)&cmd_vf_tc_bw_tx,
13030 (void *)&cmd_vf_tc_bw_max_bw,
13031 (void *)&cmd_vf_tc_bw_port_id,
13032 (void *)&cmd_vf_tc_bw_vf_id,
13033 (void *)&cmd_vf_tc_bw_tc_no,
13034 (void *)&cmd_vf_tc_bw_bw,
13039 /** Set VXLAN encapsulation details */
13040 struct cmd_set_vxlan_result {
13041 cmdline_fixed_string_t set;
13042 cmdline_fixed_string_t vxlan;
13043 cmdline_fixed_string_t pos_token;
13044 cmdline_fixed_string_t ip_version;
13045 uint32_t vlan_present:1;
13049 cmdline_ipaddr_t ip_src;
13050 cmdline_ipaddr_t ip_dst;
13054 struct rte_ether_addr eth_src;
13055 struct rte_ether_addr eth_dst;
13058 cmdline_parse_token_string_t cmd_set_vxlan_set =
13059 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
13060 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
13061 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
13062 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
13063 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
13065 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
13066 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
13067 "vxlan-with-vlan");
13068 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
13069 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13071 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
13072 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
13074 cmdline_parse_token_string_t cmd_set_vxlan_vni =
13075 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13077 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
13078 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
13079 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
13080 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13082 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
13083 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
13084 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
13085 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13087 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
13088 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
13089 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
13090 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13092 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
13093 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8);
13094 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
13095 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13097 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
13098 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8);
13099 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
13100 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13102 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
13103 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
13104 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
13105 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13107 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
13108 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
13109 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
13110 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13112 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
13113 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
13114 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
13115 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13117 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
13118 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
13119 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
13120 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
13122 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
13123 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
13125 static void cmd_set_vxlan_parsed(void *parsed_result,
13126 __rte_unused struct cmdline *cl,
13127 __rte_unused void *data)
13129 struct cmd_set_vxlan_result *res = parsed_result;
13134 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
13137 vxlan_encap_conf.select_tos_ttl = 0;
13138 if (strcmp(res->vxlan, "vxlan") == 0)
13139 vxlan_encap_conf.select_vlan = 0;
13140 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
13141 vxlan_encap_conf.select_vlan = 1;
13142 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
13143 vxlan_encap_conf.select_vlan = 0;
13144 vxlan_encap_conf.select_tos_ttl = 1;
13146 if (strcmp(res->ip_version, "ipv4") == 0)
13147 vxlan_encap_conf.select_ipv4 = 1;
13148 else if (strcmp(res->ip_version, "ipv6") == 0)
13149 vxlan_encap_conf.select_ipv4 = 0;
13152 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
13153 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13154 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13155 vxlan_encap_conf.ip_tos = res->tos;
13156 vxlan_encap_conf.ip_ttl = res->ttl;
13157 if (vxlan_encap_conf.select_ipv4) {
13158 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
13159 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
13161 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
13162 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
13164 if (vxlan_encap_conf.select_vlan)
13165 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13166 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
13167 RTE_ETHER_ADDR_LEN);
13168 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13169 RTE_ETHER_ADDR_LEN);
13172 cmdline_parse_inst_t cmd_set_vxlan = {
13173 .f = cmd_set_vxlan_parsed,
13175 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
13176 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
13177 " eth-src <eth-src> eth-dst <eth-dst>",
13179 (void *)&cmd_set_vxlan_set,
13180 (void *)&cmd_set_vxlan_vxlan,
13181 (void *)&cmd_set_vxlan_ip_version,
13182 (void *)&cmd_set_vxlan_ip_version_value,
13183 (void *)&cmd_set_vxlan_vni,
13184 (void *)&cmd_set_vxlan_vni_value,
13185 (void *)&cmd_set_vxlan_udp_src,
13186 (void *)&cmd_set_vxlan_udp_src_value,
13187 (void *)&cmd_set_vxlan_udp_dst,
13188 (void *)&cmd_set_vxlan_udp_dst_value,
13189 (void *)&cmd_set_vxlan_ip_src,
13190 (void *)&cmd_set_vxlan_ip_src_value,
13191 (void *)&cmd_set_vxlan_ip_dst,
13192 (void *)&cmd_set_vxlan_ip_dst_value,
13193 (void *)&cmd_set_vxlan_eth_src,
13194 (void *)&cmd_set_vxlan_eth_src_value,
13195 (void *)&cmd_set_vxlan_eth_dst,
13196 (void *)&cmd_set_vxlan_eth_dst_value,
13201 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
13202 .f = cmd_set_vxlan_parsed,
13204 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
13205 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
13206 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13207 " eth-dst <eth-dst>",
13209 (void *)&cmd_set_vxlan_set,
13210 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
13211 (void *)&cmd_set_vxlan_ip_version,
13212 (void *)&cmd_set_vxlan_ip_version_value,
13213 (void *)&cmd_set_vxlan_vni,
13214 (void *)&cmd_set_vxlan_vni_value,
13215 (void *)&cmd_set_vxlan_udp_src,
13216 (void *)&cmd_set_vxlan_udp_src_value,
13217 (void *)&cmd_set_vxlan_udp_dst,
13218 (void *)&cmd_set_vxlan_udp_dst_value,
13219 (void *)&cmd_set_vxlan_ip_tos,
13220 (void *)&cmd_set_vxlan_ip_tos_value,
13221 (void *)&cmd_set_vxlan_ip_ttl,
13222 (void *)&cmd_set_vxlan_ip_ttl_value,
13223 (void *)&cmd_set_vxlan_ip_src,
13224 (void *)&cmd_set_vxlan_ip_src_value,
13225 (void *)&cmd_set_vxlan_ip_dst,
13226 (void *)&cmd_set_vxlan_ip_dst_value,
13227 (void *)&cmd_set_vxlan_eth_src,
13228 (void *)&cmd_set_vxlan_eth_src_value,
13229 (void *)&cmd_set_vxlan_eth_dst,
13230 (void *)&cmd_set_vxlan_eth_dst_value,
13235 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
13236 .f = cmd_set_vxlan_parsed,
13238 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
13239 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
13240 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
13243 (void *)&cmd_set_vxlan_set,
13244 (void *)&cmd_set_vxlan_vxlan_with_vlan,
13245 (void *)&cmd_set_vxlan_ip_version,
13246 (void *)&cmd_set_vxlan_ip_version_value,
13247 (void *)&cmd_set_vxlan_vni,
13248 (void *)&cmd_set_vxlan_vni_value,
13249 (void *)&cmd_set_vxlan_udp_src,
13250 (void *)&cmd_set_vxlan_udp_src_value,
13251 (void *)&cmd_set_vxlan_udp_dst,
13252 (void *)&cmd_set_vxlan_udp_dst_value,
13253 (void *)&cmd_set_vxlan_ip_src,
13254 (void *)&cmd_set_vxlan_ip_src_value,
13255 (void *)&cmd_set_vxlan_ip_dst,
13256 (void *)&cmd_set_vxlan_ip_dst_value,
13257 (void *)&cmd_set_vxlan_vlan,
13258 (void *)&cmd_set_vxlan_vlan_value,
13259 (void *)&cmd_set_vxlan_eth_src,
13260 (void *)&cmd_set_vxlan_eth_src_value,
13261 (void *)&cmd_set_vxlan_eth_dst,
13262 (void *)&cmd_set_vxlan_eth_dst_value,
13267 /** Set NVGRE encapsulation details */
13268 struct cmd_set_nvgre_result {
13269 cmdline_fixed_string_t set;
13270 cmdline_fixed_string_t nvgre;
13271 cmdline_fixed_string_t pos_token;
13272 cmdline_fixed_string_t ip_version;
13274 cmdline_ipaddr_t ip_src;
13275 cmdline_ipaddr_t ip_dst;
13277 struct rte_ether_addr eth_src;
13278 struct rte_ether_addr eth_dst;
13281 cmdline_parse_token_string_t cmd_set_nvgre_set =
13282 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
13283 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
13284 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
13285 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
13286 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
13287 "nvgre-with-vlan");
13288 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
13289 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13291 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
13292 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
13294 cmdline_parse_token_string_t cmd_set_nvgre_tni =
13295 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13297 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
13298 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
13299 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
13300 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13302 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
13303 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
13304 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
13305 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13307 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
13308 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
13309 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
13310 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13312 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
13313 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
13314 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
13315 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13317 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
13318 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
13319 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
13320 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13322 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
13323 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
13325 static void cmd_set_nvgre_parsed(void *parsed_result,
13326 __rte_unused struct cmdline *cl,
13327 __rte_unused void *data)
13329 struct cmd_set_nvgre_result *res = parsed_result;
13331 uint32_t nvgre_tni;
13334 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
13337 if (strcmp(res->nvgre, "nvgre") == 0)
13338 nvgre_encap_conf.select_vlan = 0;
13339 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
13340 nvgre_encap_conf.select_vlan = 1;
13341 if (strcmp(res->ip_version, "ipv4") == 0)
13342 nvgre_encap_conf.select_ipv4 = 1;
13343 else if (strcmp(res->ip_version, "ipv6") == 0)
13344 nvgre_encap_conf.select_ipv4 = 0;
13347 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
13348 if (nvgre_encap_conf.select_ipv4) {
13349 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
13350 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
13352 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
13353 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
13355 if (nvgre_encap_conf.select_vlan)
13356 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13357 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
13358 RTE_ETHER_ADDR_LEN);
13359 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13360 RTE_ETHER_ADDR_LEN);
13363 cmdline_parse_inst_t cmd_set_nvgre = {
13364 .f = cmd_set_nvgre_parsed,
13366 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
13367 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13368 " eth-dst <eth-dst>",
13370 (void *)&cmd_set_nvgre_set,
13371 (void *)&cmd_set_nvgre_nvgre,
13372 (void *)&cmd_set_nvgre_ip_version,
13373 (void *)&cmd_set_nvgre_ip_version_value,
13374 (void *)&cmd_set_nvgre_tni,
13375 (void *)&cmd_set_nvgre_tni_value,
13376 (void *)&cmd_set_nvgre_ip_src,
13377 (void *)&cmd_set_nvgre_ip_src_value,
13378 (void *)&cmd_set_nvgre_ip_dst,
13379 (void *)&cmd_set_nvgre_ip_dst_value,
13380 (void *)&cmd_set_nvgre_eth_src,
13381 (void *)&cmd_set_nvgre_eth_src_value,
13382 (void *)&cmd_set_nvgre_eth_dst,
13383 (void *)&cmd_set_nvgre_eth_dst_value,
13388 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
13389 .f = cmd_set_nvgre_parsed,
13391 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
13392 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13393 " eth-src <eth-src> eth-dst <eth-dst>",
13395 (void *)&cmd_set_nvgre_set,
13396 (void *)&cmd_set_nvgre_nvgre_with_vlan,
13397 (void *)&cmd_set_nvgre_ip_version,
13398 (void *)&cmd_set_nvgre_ip_version_value,
13399 (void *)&cmd_set_nvgre_tni,
13400 (void *)&cmd_set_nvgre_tni_value,
13401 (void *)&cmd_set_nvgre_ip_src,
13402 (void *)&cmd_set_nvgre_ip_src_value,
13403 (void *)&cmd_set_nvgre_ip_dst,
13404 (void *)&cmd_set_nvgre_ip_dst_value,
13405 (void *)&cmd_set_nvgre_vlan,
13406 (void *)&cmd_set_nvgre_vlan_value,
13407 (void *)&cmd_set_nvgre_eth_src,
13408 (void *)&cmd_set_nvgre_eth_src_value,
13409 (void *)&cmd_set_nvgre_eth_dst,
13410 (void *)&cmd_set_nvgre_eth_dst_value,
13415 /** Set L2 encapsulation details */
13416 struct cmd_set_l2_encap_result {
13417 cmdline_fixed_string_t set;
13418 cmdline_fixed_string_t l2_encap;
13419 cmdline_fixed_string_t pos_token;
13420 cmdline_fixed_string_t ip_version;
13421 uint32_t vlan_present:1;
13423 struct rte_ether_addr eth_src;
13424 struct rte_ether_addr eth_dst;
13427 cmdline_parse_token_string_t cmd_set_l2_encap_set =
13428 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13429 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13430 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13431 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13432 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13433 "l2_encap-with-vlan");
13434 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13435 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13437 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13438 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13440 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13441 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13443 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13444 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16);
13445 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13446 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13448 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13449 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13450 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13451 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13453 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13454 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13456 static void cmd_set_l2_encap_parsed(void *parsed_result,
13457 __rte_unused struct cmdline *cl,
13458 __rte_unused void *data)
13460 struct cmd_set_l2_encap_result *res = parsed_result;
13462 if (strcmp(res->l2_encap, "l2_encap") == 0)
13463 l2_encap_conf.select_vlan = 0;
13464 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13465 l2_encap_conf.select_vlan = 1;
13466 if (strcmp(res->ip_version, "ipv4") == 0)
13467 l2_encap_conf.select_ipv4 = 1;
13468 else if (strcmp(res->ip_version, "ipv6") == 0)
13469 l2_encap_conf.select_ipv4 = 0;
13472 if (l2_encap_conf.select_vlan)
13473 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13474 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13475 RTE_ETHER_ADDR_LEN);
13476 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13477 RTE_ETHER_ADDR_LEN);
13480 cmdline_parse_inst_t cmd_set_l2_encap = {
13481 .f = cmd_set_l2_encap_parsed,
13483 .help_str = "set l2_encap ip-version ipv4|ipv6"
13484 " eth-src <eth-src> eth-dst <eth-dst>",
13486 (void *)&cmd_set_l2_encap_set,
13487 (void *)&cmd_set_l2_encap_l2_encap,
13488 (void *)&cmd_set_l2_encap_ip_version,
13489 (void *)&cmd_set_l2_encap_ip_version_value,
13490 (void *)&cmd_set_l2_encap_eth_src,
13491 (void *)&cmd_set_l2_encap_eth_src_value,
13492 (void *)&cmd_set_l2_encap_eth_dst,
13493 (void *)&cmd_set_l2_encap_eth_dst_value,
13498 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13499 .f = cmd_set_l2_encap_parsed,
13501 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13502 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13504 (void *)&cmd_set_l2_encap_set,
13505 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13506 (void *)&cmd_set_l2_encap_ip_version,
13507 (void *)&cmd_set_l2_encap_ip_version_value,
13508 (void *)&cmd_set_l2_encap_vlan,
13509 (void *)&cmd_set_l2_encap_vlan_value,
13510 (void *)&cmd_set_l2_encap_eth_src,
13511 (void *)&cmd_set_l2_encap_eth_src_value,
13512 (void *)&cmd_set_l2_encap_eth_dst,
13513 (void *)&cmd_set_l2_encap_eth_dst_value,
13518 /** Set L2 decapsulation details */
13519 struct cmd_set_l2_decap_result {
13520 cmdline_fixed_string_t set;
13521 cmdline_fixed_string_t l2_decap;
13522 cmdline_fixed_string_t pos_token;
13523 uint32_t vlan_present:1;
13526 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13527 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13528 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13529 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13531 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13532 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13533 "l2_decap-with-vlan");
13535 static void cmd_set_l2_decap_parsed(void *parsed_result,
13536 __rte_unused struct cmdline *cl,
13537 __rte_unused void *data)
13539 struct cmd_set_l2_decap_result *res = parsed_result;
13541 if (strcmp(res->l2_decap, "l2_decap") == 0)
13542 l2_decap_conf.select_vlan = 0;
13543 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13544 l2_decap_conf.select_vlan = 1;
13547 cmdline_parse_inst_t cmd_set_l2_decap = {
13548 .f = cmd_set_l2_decap_parsed,
13550 .help_str = "set l2_decap",
13552 (void *)&cmd_set_l2_decap_set,
13553 (void *)&cmd_set_l2_decap_l2_decap,
13558 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13559 .f = cmd_set_l2_decap_parsed,
13561 .help_str = "set l2_decap-with-vlan",
13563 (void *)&cmd_set_l2_decap_set,
13564 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13569 /** Set MPLSoGRE encapsulation details */
13570 struct cmd_set_mplsogre_encap_result {
13571 cmdline_fixed_string_t set;
13572 cmdline_fixed_string_t mplsogre;
13573 cmdline_fixed_string_t pos_token;
13574 cmdline_fixed_string_t ip_version;
13575 uint32_t vlan_present:1;
13577 cmdline_ipaddr_t ip_src;
13578 cmdline_ipaddr_t ip_dst;
13580 struct rte_ether_addr eth_src;
13581 struct rte_ether_addr eth_dst;
13584 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13585 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13587 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13588 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13590 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13591 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13592 mplsogre, "mplsogre_encap-with-vlan");
13593 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13594 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13595 pos_token, "ip-version");
13596 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13597 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13598 ip_version, "ipv4#ipv6");
13599 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13600 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13601 pos_token, "label");
13602 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13603 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13605 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13606 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13607 pos_token, "ip-src");
13608 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13609 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13610 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13611 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13612 pos_token, "ip-dst");
13613 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13614 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13615 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13616 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13617 pos_token, "vlan-tci");
13618 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13619 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13621 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13622 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13623 pos_token, "eth-src");
13624 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13625 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13627 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13628 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13629 pos_token, "eth-dst");
13630 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13631 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13634 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13635 __rte_unused struct cmdline *cl,
13636 __rte_unused void *data)
13638 struct cmd_set_mplsogre_encap_result *res = parsed_result;
13640 uint32_t mplsogre_label;
13643 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13646 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13647 mplsogre_encap_conf.select_vlan = 0;
13648 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13649 mplsogre_encap_conf.select_vlan = 1;
13650 if (strcmp(res->ip_version, "ipv4") == 0)
13651 mplsogre_encap_conf.select_ipv4 = 1;
13652 else if (strcmp(res->ip_version, "ipv6") == 0)
13653 mplsogre_encap_conf.select_ipv4 = 0;
13656 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13657 if (mplsogre_encap_conf.select_ipv4) {
13658 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13659 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13661 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13662 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13664 if (mplsogre_encap_conf.select_vlan)
13665 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13666 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13667 RTE_ETHER_ADDR_LEN);
13668 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13669 RTE_ETHER_ADDR_LEN);
13672 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13673 .f = cmd_set_mplsogre_encap_parsed,
13675 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13676 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13677 " eth-dst <eth-dst>",
13679 (void *)&cmd_set_mplsogre_encap_set,
13680 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13681 (void *)&cmd_set_mplsogre_encap_ip_version,
13682 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13683 (void *)&cmd_set_mplsogre_encap_label,
13684 (void *)&cmd_set_mplsogre_encap_label_value,
13685 (void *)&cmd_set_mplsogre_encap_ip_src,
13686 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13687 (void *)&cmd_set_mplsogre_encap_ip_dst,
13688 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13689 (void *)&cmd_set_mplsogre_encap_eth_src,
13690 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13691 (void *)&cmd_set_mplsogre_encap_eth_dst,
13692 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13697 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13698 .f = cmd_set_mplsogre_encap_parsed,
13700 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13701 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
13702 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13704 (void *)&cmd_set_mplsogre_encap_set,
13705 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13706 (void *)&cmd_set_mplsogre_encap_ip_version,
13707 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13708 (void *)&cmd_set_mplsogre_encap_label,
13709 (void *)&cmd_set_mplsogre_encap_label_value,
13710 (void *)&cmd_set_mplsogre_encap_ip_src,
13711 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13712 (void *)&cmd_set_mplsogre_encap_ip_dst,
13713 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13714 (void *)&cmd_set_mplsogre_encap_vlan,
13715 (void *)&cmd_set_mplsogre_encap_vlan_value,
13716 (void *)&cmd_set_mplsogre_encap_eth_src,
13717 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13718 (void *)&cmd_set_mplsogre_encap_eth_dst,
13719 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13724 /** Set MPLSoGRE decapsulation details */
13725 struct cmd_set_mplsogre_decap_result {
13726 cmdline_fixed_string_t set;
13727 cmdline_fixed_string_t mplsogre;
13728 cmdline_fixed_string_t pos_token;
13729 cmdline_fixed_string_t ip_version;
13730 uint32_t vlan_present:1;
13733 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13734 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13736 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13737 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13739 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13740 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13741 mplsogre, "mplsogre_decap-with-vlan");
13742 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13743 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13744 pos_token, "ip-version");
13745 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13746 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13747 ip_version, "ipv4#ipv6");
13749 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13750 __rte_unused struct cmdline *cl,
13751 __rte_unused void *data)
13753 struct cmd_set_mplsogre_decap_result *res = parsed_result;
13755 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13756 mplsogre_decap_conf.select_vlan = 0;
13757 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13758 mplsogre_decap_conf.select_vlan = 1;
13759 if (strcmp(res->ip_version, "ipv4") == 0)
13760 mplsogre_decap_conf.select_ipv4 = 1;
13761 else if (strcmp(res->ip_version, "ipv6") == 0)
13762 mplsogre_decap_conf.select_ipv4 = 0;
13765 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13766 .f = cmd_set_mplsogre_decap_parsed,
13768 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13770 (void *)&cmd_set_mplsogre_decap_set,
13771 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13772 (void *)&cmd_set_mplsogre_decap_ip_version,
13773 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13778 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13779 .f = cmd_set_mplsogre_decap_parsed,
13781 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13783 (void *)&cmd_set_mplsogre_decap_set,
13784 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13785 (void *)&cmd_set_mplsogre_decap_ip_version,
13786 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13791 /** Set MPLSoUDP encapsulation details */
13792 struct cmd_set_mplsoudp_encap_result {
13793 cmdline_fixed_string_t set;
13794 cmdline_fixed_string_t mplsoudp;
13795 cmdline_fixed_string_t pos_token;
13796 cmdline_fixed_string_t ip_version;
13797 uint32_t vlan_present:1;
13801 cmdline_ipaddr_t ip_src;
13802 cmdline_ipaddr_t ip_dst;
13804 struct rte_ether_addr eth_src;
13805 struct rte_ether_addr eth_dst;
13808 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13809 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13811 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13812 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13814 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13815 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13816 mplsoudp, "mplsoudp_encap-with-vlan");
13817 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13818 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13819 pos_token, "ip-version");
13820 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13821 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13822 ip_version, "ipv4#ipv6");
13823 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13824 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13825 pos_token, "label");
13826 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13827 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13829 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13830 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13831 pos_token, "udp-src");
13832 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13833 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13835 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13836 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13837 pos_token, "udp-dst");
13838 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13839 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13841 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13842 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13843 pos_token, "ip-src");
13844 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13845 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13846 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13847 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13848 pos_token, "ip-dst");
13849 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13850 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13851 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13852 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13853 pos_token, "vlan-tci");
13854 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13855 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13857 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13858 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13859 pos_token, "eth-src");
13860 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13861 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13863 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13864 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13865 pos_token, "eth-dst");
13866 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13867 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13870 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13871 __rte_unused struct cmdline *cl,
13872 __rte_unused void *data)
13874 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13876 uint32_t mplsoudp_label;
13879 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13882 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13883 mplsoudp_encap_conf.select_vlan = 0;
13884 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13885 mplsoudp_encap_conf.select_vlan = 1;
13886 if (strcmp(res->ip_version, "ipv4") == 0)
13887 mplsoudp_encap_conf.select_ipv4 = 1;
13888 else if (strcmp(res->ip_version, "ipv6") == 0)
13889 mplsoudp_encap_conf.select_ipv4 = 0;
13892 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13893 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13894 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13895 if (mplsoudp_encap_conf.select_ipv4) {
13896 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13897 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13899 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13900 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13902 if (mplsoudp_encap_conf.select_vlan)
13903 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13904 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13905 RTE_ETHER_ADDR_LEN);
13906 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13907 RTE_ETHER_ADDR_LEN);
13910 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13911 .f = cmd_set_mplsoudp_encap_parsed,
13913 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13914 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13915 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13917 (void *)&cmd_set_mplsoudp_encap_set,
13918 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13919 (void *)&cmd_set_mplsoudp_encap_ip_version,
13920 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13921 (void *)&cmd_set_mplsoudp_encap_label,
13922 (void *)&cmd_set_mplsoudp_encap_label_value,
13923 (void *)&cmd_set_mplsoudp_encap_udp_src,
13924 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13925 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13926 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13927 (void *)&cmd_set_mplsoudp_encap_ip_src,
13928 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13929 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13930 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13931 (void *)&cmd_set_mplsoudp_encap_eth_src,
13932 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13933 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13934 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13939 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13940 .f = cmd_set_mplsoudp_encap_parsed,
13942 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13943 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
13944 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13945 " eth-src <eth-src> eth-dst <eth-dst>",
13947 (void *)&cmd_set_mplsoudp_encap_set,
13948 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13949 (void *)&cmd_set_mplsoudp_encap_ip_version,
13950 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13951 (void *)&cmd_set_mplsoudp_encap_label,
13952 (void *)&cmd_set_mplsoudp_encap_label_value,
13953 (void *)&cmd_set_mplsoudp_encap_udp_src,
13954 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13955 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13956 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13957 (void *)&cmd_set_mplsoudp_encap_ip_src,
13958 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13959 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13960 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13961 (void *)&cmd_set_mplsoudp_encap_vlan,
13962 (void *)&cmd_set_mplsoudp_encap_vlan_value,
13963 (void *)&cmd_set_mplsoudp_encap_eth_src,
13964 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13965 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13966 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13971 /** Set MPLSoUDP decapsulation details */
13972 struct cmd_set_mplsoudp_decap_result {
13973 cmdline_fixed_string_t set;
13974 cmdline_fixed_string_t mplsoudp;
13975 cmdline_fixed_string_t pos_token;
13976 cmdline_fixed_string_t ip_version;
13977 uint32_t vlan_present:1;
13980 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
13981 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
13983 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
13984 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
13986 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
13987 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13988 mplsoudp, "mplsoudp_decap-with-vlan");
13989 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
13990 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13991 pos_token, "ip-version");
13992 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
13993 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13994 ip_version, "ipv4#ipv6");
13996 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
13997 __rte_unused struct cmdline *cl,
13998 __rte_unused void *data)
14000 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
14002 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
14003 mplsoudp_decap_conf.select_vlan = 0;
14004 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
14005 mplsoudp_decap_conf.select_vlan = 1;
14006 if (strcmp(res->ip_version, "ipv4") == 0)
14007 mplsoudp_decap_conf.select_ipv4 = 1;
14008 else if (strcmp(res->ip_version, "ipv6") == 0)
14009 mplsoudp_decap_conf.select_ipv4 = 0;
14012 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
14013 .f = cmd_set_mplsoudp_decap_parsed,
14015 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
14017 (void *)&cmd_set_mplsoudp_decap_set,
14018 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
14019 (void *)&cmd_set_mplsoudp_decap_ip_version,
14020 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
14025 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
14026 .f = cmd_set_mplsoudp_decap_parsed,
14028 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
14030 (void *)&cmd_set_mplsoudp_decap_set,
14031 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
14032 (void *)&cmd_set_mplsoudp_decap_ip_version,
14033 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
14038 /* Strict link priority scheduling mode setting */
14040 cmd_strict_link_prio_parsed(
14041 void *parsed_result,
14042 __rte_unused struct cmdline *cl,
14043 __rte_unused void *data)
14045 struct cmd_vf_tc_bw_result *res = parsed_result;
14046 int ret = -ENOTSUP;
14048 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14051 #ifdef RTE_NET_I40E
14052 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14059 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14062 printf("invalid port_id %d\n", res->port_id);
14065 printf("function not implemented\n");
14068 printf("programming error: (%s)\n", strerror(-ret));
14072 cmdline_parse_inst_t cmd_strict_link_prio = {
14073 .f = cmd_strict_link_prio_parsed,
14075 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14077 (void *)&cmd_vf_tc_bw_set,
14078 (void *)&cmd_vf_tc_bw_tx,
14079 (void *)&cmd_vf_tc_bw_strict_link_prio,
14080 (void *)&cmd_vf_tc_bw_port_id,
14081 (void *)&cmd_vf_tc_bw_tc_map,
14086 /* Load dynamic device personalization*/
14087 struct cmd_ddp_add_result {
14088 cmdline_fixed_string_t ddp;
14089 cmdline_fixed_string_t add;
14094 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14095 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14096 cmdline_parse_token_string_t cmd_ddp_add_add =
14097 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14098 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14099 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14100 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14101 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14104 cmd_ddp_add_parsed(
14105 void *parsed_result,
14106 __rte_unused struct cmdline *cl,
14107 __rte_unused void *data)
14109 struct cmd_ddp_add_result *res = parsed_result;
14115 int ret = -ENOTSUP;
14117 if (!all_ports_stopped()) {
14118 printf("Please stop all ports first\n");
14122 filepath = strdup(res->filepath);
14123 if (filepath == NULL) {
14124 printf("Failed to allocate memory\n");
14127 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14129 buff = open_file(file_fld[0], &size);
14131 free((void *)filepath);
14135 #ifdef RTE_NET_I40E
14136 if (ret == -ENOTSUP)
14137 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14139 RTE_PMD_I40E_PKG_OP_WR_ADD);
14142 if (ret == -EEXIST)
14143 printf("Profile has already existed.\n");
14145 printf("Failed to load profile.\n");
14146 else if (file_num == 2)
14147 save_file(file_fld[1], buff, size);
14150 free((void *)filepath);
14153 cmdline_parse_inst_t cmd_ddp_add = {
14154 .f = cmd_ddp_add_parsed,
14156 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14158 (void *)&cmd_ddp_add_ddp,
14159 (void *)&cmd_ddp_add_add,
14160 (void *)&cmd_ddp_add_port_id,
14161 (void *)&cmd_ddp_add_filepath,
14166 /* Delete dynamic device personalization*/
14167 struct cmd_ddp_del_result {
14168 cmdline_fixed_string_t ddp;
14169 cmdline_fixed_string_t del;
14174 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14175 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14176 cmdline_parse_token_string_t cmd_ddp_del_del =
14177 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14178 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14179 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14180 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14181 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14184 cmd_ddp_del_parsed(
14185 void *parsed_result,
14186 __rte_unused struct cmdline *cl,
14187 __rte_unused void *data)
14189 struct cmd_ddp_del_result *res = parsed_result;
14192 int ret = -ENOTSUP;
14194 if (!all_ports_stopped()) {
14195 printf("Please stop all ports first\n");
14199 buff = open_file(res->filepath, &size);
14203 #ifdef RTE_NET_I40E
14204 if (ret == -ENOTSUP)
14205 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14207 RTE_PMD_I40E_PKG_OP_WR_DEL);
14210 if (ret == -EACCES)
14211 printf("Profile does not exist.\n");
14213 printf("Failed to delete profile.\n");
14218 cmdline_parse_inst_t cmd_ddp_del = {
14219 .f = cmd_ddp_del_parsed,
14221 .help_str = "ddp del <port_id> <backup_profile_path>",
14223 (void *)&cmd_ddp_del_ddp,
14224 (void *)&cmd_ddp_del_del,
14225 (void *)&cmd_ddp_del_port_id,
14226 (void *)&cmd_ddp_del_filepath,
14231 /* Get dynamic device personalization profile info */
14232 struct cmd_ddp_info_result {
14233 cmdline_fixed_string_t ddp;
14234 cmdline_fixed_string_t get;
14235 cmdline_fixed_string_t info;
14239 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14240 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14241 cmdline_parse_token_string_t cmd_ddp_info_get =
14242 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14243 cmdline_parse_token_string_t cmd_ddp_info_info =
14244 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14245 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14246 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14249 cmd_ddp_info_parsed(
14250 void *parsed_result,
14251 __rte_unused struct cmdline *cl,
14252 __rte_unused void *data)
14254 struct cmd_ddp_info_result *res = parsed_result;
14257 int ret = -ENOTSUP;
14258 #ifdef RTE_NET_I40E
14261 uint32_t buff_size = 0;
14262 struct rte_pmd_i40e_profile_info info;
14263 uint32_t dev_num = 0;
14264 struct rte_pmd_i40e_ddp_device_id *devs;
14265 uint32_t proto_num = 0;
14266 struct rte_pmd_i40e_proto_info *proto = NULL;
14267 uint32_t pctype_num = 0;
14268 struct rte_pmd_i40e_ptype_info *pctype;
14269 uint32_t ptype_num = 0;
14270 struct rte_pmd_i40e_ptype_info *ptype;
14275 pkg = open_file(res->filepath, &pkg_size);
14279 #ifdef RTE_NET_I40E
14280 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14281 (uint8_t *)&info, sizeof(info),
14282 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14284 printf("Global Track id: 0x%x\n", info.track_id);
14285 printf("Global Version: %d.%d.%d.%d\n",
14286 info.version.major,
14287 info.version.minor,
14288 info.version.update,
14289 info.version.draft);
14290 printf("Global Package name: %s\n\n", info.name);
14293 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14294 (uint8_t *)&info, sizeof(info),
14295 RTE_PMD_I40E_PKG_INFO_HEADER);
14297 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14298 printf("i40e Profile Version: %d.%d.%d.%d\n",
14299 info.version.major,
14300 info.version.minor,
14301 info.version.update,
14302 info.version.draft);
14303 printf("i40e Profile name: %s\n\n", info.name);
14306 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14307 (uint8_t *)&buff_size, sizeof(buff_size),
14308 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14309 if (!ret && buff_size) {
14310 buff = (uint8_t *)malloc(buff_size);
14312 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14314 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14316 printf("Package Notes:\n%s\n\n", buff);
14321 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14322 (uint8_t *)&dev_num, sizeof(dev_num),
14323 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14324 if (!ret && dev_num) {
14325 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14326 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14328 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14329 (uint8_t *)devs, buff_size,
14330 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14332 printf("List of supported devices:\n");
14333 for (i = 0; i < dev_num; i++) {
14334 printf(" %04X:%04X %04X:%04X\n",
14335 devs[i].vendor_dev_id >> 16,
14336 devs[i].vendor_dev_id & 0xFFFF,
14337 devs[i].sub_vendor_dev_id >> 16,
14338 devs[i].sub_vendor_dev_id & 0xFFFF);
14346 /* get information about protocols and packet types */
14347 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14348 (uint8_t *)&proto_num, sizeof(proto_num),
14349 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14350 if (ret || !proto_num)
14351 goto no_print_return;
14353 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14354 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14356 goto no_print_return;
14358 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14360 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14362 printf("List of used protocols:\n");
14363 for (i = 0; i < proto_num; i++)
14364 printf(" %2u: %s\n", proto[i].proto_id,
14368 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14369 (uint8_t *)&pctype_num, sizeof(pctype_num),
14370 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14371 if (ret || !pctype_num)
14372 goto no_print_pctypes;
14374 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14375 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14377 goto no_print_pctypes;
14379 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14381 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14384 goto no_print_pctypes;
14387 printf("List of defined packet classification types:\n");
14388 for (i = 0; i < pctype_num; i++) {
14389 printf(" %2u:", pctype[i].ptype_id);
14390 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14391 proto_id = pctype[i].protocols[j];
14392 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14393 for (n = 0; n < proto_num; n++) {
14394 if (proto[n].proto_id == proto_id) {
14395 printf(" %s", proto[n].name);
14408 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14410 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14411 if (ret || !ptype_num)
14412 goto no_print_return;
14414 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14415 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14417 goto no_print_return;
14419 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14421 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14424 goto no_print_return;
14426 printf("List of defined packet types:\n");
14427 for (i = 0; i < ptype_num; i++) {
14428 printf(" %2u:", ptype[i].ptype_id);
14429 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14430 proto_id = ptype[i].protocols[j];
14431 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14432 for (n = 0; n < proto_num; n++) {
14433 if (proto[n].proto_id == proto_id) {
14434 printf(" %s", proto[n].name);
14450 if (ret == -ENOTSUP)
14451 printf("Function not supported in PMD driver\n");
14455 cmdline_parse_inst_t cmd_ddp_get_info = {
14456 .f = cmd_ddp_info_parsed,
14458 .help_str = "ddp get info <profile_path>",
14460 (void *)&cmd_ddp_info_ddp,
14461 (void *)&cmd_ddp_info_get,
14462 (void *)&cmd_ddp_info_info,
14463 (void *)&cmd_ddp_info_filepath,
14468 /* Get dynamic device personalization profile info list*/
14469 #define PROFILE_INFO_SIZE 48
14470 #define MAX_PROFILE_NUM 16
14472 struct cmd_ddp_get_list_result {
14473 cmdline_fixed_string_t ddp;
14474 cmdline_fixed_string_t get;
14475 cmdline_fixed_string_t list;
14479 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14480 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14481 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14482 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14483 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14484 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14485 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14486 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
14489 cmd_ddp_get_list_parsed(
14490 __rte_unused void *parsed_result,
14491 __rte_unused struct cmdline *cl,
14492 __rte_unused void *data)
14494 #ifdef RTE_NET_I40E
14495 struct cmd_ddp_get_list_result *res = parsed_result;
14496 struct rte_pmd_i40e_profile_list *p_list;
14497 struct rte_pmd_i40e_profile_info *p_info;
14502 int ret = -ENOTSUP;
14504 #ifdef RTE_NET_I40E
14505 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14506 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14508 printf("%s: Failed to malloc buffer\n", __func__);
14512 if (ret == -ENOTSUP)
14513 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14514 (uint8_t *)p_list, size);
14517 p_num = p_list->p_count;
14518 printf("Profile number is: %d\n\n", p_num);
14520 for (i = 0; i < p_num; i++) {
14521 p_info = &p_list->p_info[i];
14522 printf("Profile %d:\n", i);
14523 printf("Track id: 0x%x\n", p_info->track_id);
14524 printf("Version: %d.%d.%d.%d\n",
14525 p_info->version.major,
14526 p_info->version.minor,
14527 p_info->version.update,
14528 p_info->version.draft);
14529 printf("Profile name: %s\n\n", p_info->name);
14537 printf("Failed to get ddp list\n");
14540 cmdline_parse_inst_t cmd_ddp_get_list = {
14541 .f = cmd_ddp_get_list_parsed,
14543 .help_str = "ddp get list <port_id>",
14545 (void *)&cmd_ddp_get_list_ddp,
14546 (void *)&cmd_ddp_get_list_get,
14547 (void *)&cmd_ddp_get_list_list,
14548 (void *)&cmd_ddp_get_list_port_id,
14553 /* Configure input set */
14554 struct cmd_cfg_input_set_result {
14555 cmdline_fixed_string_t port;
14556 cmdline_fixed_string_t cfg;
14558 cmdline_fixed_string_t pctype;
14560 cmdline_fixed_string_t inset_type;
14561 cmdline_fixed_string_t opt;
14562 cmdline_fixed_string_t field;
14567 cmd_cfg_input_set_parsed(
14568 __rte_unused void *parsed_result,
14569 __rte_unused struct cmdline *cl,
14570 __rte_unused void *data)
14572 #ifdef RTE_NET_I40E
14573 struct cmd_cfg_input_set_result *res = parsed_result;
14574 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14575 struct rte_pmd_i40e_inset inset;
14577 int ret = -ENOTSUP;
14579 if (!all_ports_stopped()) {
14580 printf("Please stop all ports first\n");
14584 #ifdef RTE_NET_I40E
14585 if (!strcmp(res->inset_type, "hash_inset"))
14586 inset_type = INSET_HASH;
14587 else if (!strcmp(res->inset_type, "fdir_inset"))
14588 inset_type = INSET_FDIR;
14589 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14590 inset_type = INSET_FDIR_FLX;
14591 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14592 &inset, inset_type);
14594 printf("Failed to get input set.\n");
14598 if (!strcmp(res->opt, "get")) {
14599 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14602 printf("Field index %d is enabled.\n", res->field_idx);
14604 printf("Field index %d is disabled.\n", res->field_idx);
14606 } else if (!strcmp(res->opt, "set"))
14607 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14609 else if (!strcmp(res->opt, "clear"))
14610 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14613 printf("Failed to configure input set field.\n");
14617 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14618 &inset, inset_type);
14620 printf("Failed to set input set.\n");
14625 if (ret == -ENOTSUP)
14626 printf("Function not supported\n");
14629 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14630 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14632 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14633 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14635 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14636 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14638 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14639 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14641 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14642 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14644 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14645 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14647 "hash_inset#fdir_inset#fdir_flx_inset");
14648 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14649 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14650 opt, "get#set#clear");
14651 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14652 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14654 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14655 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14658 cmdline_parse_inst_t cmd_cfg_input_set = {
14659 .f = cmd_cfg_input_set_parsed,
14661 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14662 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
14664 (void *)&cmd_cfg_input_set_port,
14665 (void *)&cmd_cfg_input_set_cfg,
14666 (void *)&cmd_cfg_input_set_port_id,
14667 (void *)&cmd_cfg_input_set_pctype,
14668 (void *)&cmd_cfg_input_set_pctype_id,
14669 (void *)&cmd_cfg_input_set_inset_type,
14670 (void *)&cmd_cfg_input_set_opt,
14671 (void *)&cmd_cfg_input_set_field,
14672 (void *)&cmd_cfg_input_set_field_idx,
14677 /* Clear input set */
14678 struct cmd_clear_input_set_result {
14679 cmdline_fixed_string_t port;
14680 cmdline_fixed_string_t cfg;
14682 cmdline_fixed_string_t pctype;
14684 cmdline_fixed_string_t inset_type;
14685 cmdline_fixed_string_t clear;
14686 cmdline_fixed_string_t all;
14690 cmd_clear_input_set_parsed(
14691 __rte_unused void *parsed_result,
14692 __rte_unused struct cmdline *cl,
14693 __rte_unused void *data)
14695 #ifdef RTE_NET_I40E
14696 struct cmd_clear_input_set_result *res = parsed_result;
14697 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14698 struct rte_pmd_i40e_inset inset;
14700 int ret = -ENOTSUP;
14702 if (!all_ports_stopped()) {
14703 printf("Please stop all ports first\n");
14707 #ifdef RTE_NET_I40E
14708 if (!strcmp(res->inset_type, "hash_inset"))
14709 inset_type = INSET_HASH;
14710 else if (!strcmp(res->inset_type, "fdir_inset"))
14711 inset_type = INSET_FDIR;
14712 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14713 inset_type = INSET_FDIR_FLX;
14715 memset(&inset, 0, sizeof(inset));
14717 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14718 &inset, inset_type);
14720 printf("Failed to clear input set.\n");
14726 if (ret == -ENOTSUP)
14727 printf("Function not supported\n");
14730 cmdline_parse_token_string_t cmd_clear_input_set_port =
14731 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14733 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
14734 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14736 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
14737 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14739 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
14740 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14742 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
14743 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14745 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
14746 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14748 "hash_inset#fdir_inset#fdir_flx_inset");
14749 cmdline_parse_token_string_t cmd_clear_input_set_clear =
14750 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14752 cmdline_parse_token_string_t cmd_clear_input_set_all =
14753 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14756 cmdline_parse_inst_t cmd_clear_input_set = {
14757 .f = cmd_clear_input_set_parsed,
14759 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14760 "fdir_inset|fdir_flx_inset clear all",
14762 (void *)&cmd_clear_input_set_port,
14763 (void *)&cmd_clear_input_set_cfg,
14764 (void *)&cmd_clear_input_set_port_id,
14765 (void *)&cmd_clear_input_set_pctype,
14766 (void *)&cmd_clear_input_set_pctype_id,
14767 (void *)&cmd_clear_input_set_inset_type,
14768 (void *)&cmd_clear_input_set_clear,
14769 (void *)&cmd_clear_input_set_all,
14774 /* show vf stats */
14776 /* Common result structure for show vf stats */
14777 struct cmd_show_vf_stats_result {
14778 cmdline_fixed_string_t show;
14779 cmdline_fixed_string_t vf;
14780 cmdline_fixed_string_t stats;
14785 /* Common CLI fields show vf stats*/
14786 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14787 TOKEN_STRING_INITIALIZER
14788 (struct cmd_show_vf_stats_result,
14790 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14791 TOKEN_STRING_INITIALIZER
14792 (struct cmd_show_vf_stats_result,
14794 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14795 TOKEN_STRING_INITIALIZER
14796 (struct cmd_show_vf_stats_result,
14798 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14799 TOKEN_NUM_INITIALIZER
14800 (struct cmd_show_vf_stats_result,
14802 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14803 TOKEN_NUM_INITIALIZER
14804 (struct cmd_show_vf_stats_result,
14808 cmd_show_vf_stats_parsed(
14809 void *parsed_result,
14810 __rte_unused struct cmdline *cl,
14811 __rte_unused void *data)
14813 struct cmd_show_vf_stats_result *res = parsed_result;
14814 struct rte_eth_stats stats;
14815 int ret = -ENOTSUP;
14816 static const char *nic_stats_border = "########################";
14818 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14821 memset(&stats, 0, sizeof(stats));
14823 #ifdef RTE_NET_I40E
14824 if (ret == -ENOTSUP)
14825 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14829 #ifdef RTE_NET_BNXT
14830 if (ret == -ENOTSUP)
14831 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14840 printf("invalid vf_id %d\n", res->vf_id);
14843 printf("invalid port_id %d\n", res->port_id);
14846 printf("function not implemented\n");
14849 printf("programming error: (%s)\n", strerror(-ret));
14852 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14853 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14855 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14857 stats.ipackets, stats.imissed, stats.ibytes);
14858 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14859 printf(" RX-nombuf: %-10"PRIu64"\n",
14861 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14863 stats.opackets, stats.oerrors, stats.obytes);
14865 printf(" %s############################%s\n",
14866 nic_stats_border, nic_stats_border);
14869 cmdline_parse_inst_t cmd_show_vf_stats = {
14870 .f = cmd_show_vf_stats_parsed,
14872 .help_str = "show vf stats <port_id> <vf_id>",
14874 (void *)&cmd_show_vf_stats_show,
14875 (void *)&cmd_show_vf_stats_vf,
14876 (void *)&cmd_show_vf_stats_stats,
14877 (void *)&cmd_show_vf_stats_port_id,
14878 (void *)&cmd_show_vf_stats_vf_id,
14883 /* clear vf stats */
14885 /* Common result structure for clear vf stats */
14886 struct cmd_clear_vf_stats_result {
14887 cmdline_fixed_string_t clear;
14888 cmdline_fixed_string_t vf;
14889 cmdline_fixed_string_t stats;
14894 /* Common CLI fields clear vf stats*/
14895 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14896 TOKEN_STRING_INITIALIZER
14897 (struct cmd_clear_vf_stats_result,
14899 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
14900 TOKEN_STRING_INITIALIZER
14901 (struct cmd_clear_vf_stats_result,
14903 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
14904 TOKEN_STRING_INITIALIZER
14905 (struct cmd_clear_vf_stats_result,
14907 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
14908 TOKEN_NUM_INITIALIZER
14909 (struct cmd_clear_vf_stats_result,
14911 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
14912 TOKEN_NUM_INITIALIZER
14913 (struct cmd_clear_vf_stats_result,
14917 cmd_clear_vf_stats_parsed(
14918 void *parsed_result,
14919 __rte_unused struct cmdline *cl,
14920 __rte_unused void *data)
14922 struct cmd_clear_vf_stats_result *res = parsed_result;
14923 int ret = -ENOTSUP;
14925 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14928 #ifdef RTE_NET_I40E
14929 if (ret == -ENOTSUP)
14930 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
14933 #ifdef RTE_NET_BNXT
14934 if (ret == -ENOTSUP)
14935 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
14943 printf("invalid vf_id %d\n", res->vf_id);
14946 printf("invalid port_id %d\n", res->port_id);
14949 printf("function not implemented\n");
14952 printf("programming error: (%s)\n", strerror(-ret));
14956 cmdline_parse_inst_t cmd_clear_vf_stats = {
14957 .f = cmd_clear_vf_stats_parsed,
14959 .help_str = "clear vf stats <port_id> <vf_id>",
14961 (void *)&cmd_clear_vf_stats_clear,
14962 (void *)&cmd_clear_vf_stats_vf,
14963 (void *)&cmd_clear_vf_stats_stats,
14964 (void *)&cmd_clear_vf_stats_port_id,
14965 (void *)&cmd_clear_vf_stats_vf_id,
14970 /* port config pctype mapping reset */
14972 /* Common result structure for port config pctype mapping reset */
14973 struct cmd_pctype_mapping_reset_result {
14974 cmdline_fixed_string_t port;
14975 cmdline_fixed_string_t config;
14977 cmdline_fixed_string_t pctype;
14978 cmdline_fixed_string_t mapping;
14979 cmdline_fixed_string_t reset;
14982 /* Common CLI fields for port config pctype mapping reset*/
14983 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
14984 TOKEN_STRING_INITIALIZER
14985 (struct cmd_pctype_mapping_reset_result,
14987 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
14988 TOKEN_STRING_INITIALIZER
14989 (struct cmd_pctype_mapping_reset_result,
14991 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
14992 TOKEN_NUM_INITIALIZER
14993 (struct cmd_pctype_mapping_reset_result,
14995 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
14996 TOKEN_STRING_INITIALIZER
14997 (struct cmd_pctype_mapping_reset_result,
14999 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15000 TOKEN_STRING_INITIALIZER
15001 (struct cmd_pctype_mapping_reset_result,
15002 mapping, "mapping");
15003 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15004 TOKEN_STRING_INITIALIZER
15005 (struct cmd_pctype_mapping_reset_result,
15009 cmd_pctype_mapping_reset_parsed(
15010 void *parsed_result,
15011 __rte_unused struct cmdline *cl,
15012 __rte_unused void *data)
15014 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15015 int ret = -ENOTSUP;
15017 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15020 #ifdef RTE_NET_I40E
15021 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15028 printf("invalid port_id %d\n", res->port_id);
15031 printf("function not implemented\n");
15034 printf("programming error: (%s)\n", strerror(-ret));
15038 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15039 .f = cmd_pctype_mapping_reset_parsed,
15041 .help_str = "port config <port_id> pctype mapping reset",
15043 (void *)&cmd_pctype_mapping_reset_port,
15044 (void *)&cmd_pctype_mapping_reset_config,
15045 (void *)&cmd_pctype_mapping_reset_port_id,
15046 (void *)&cmd_pctype_mapping_reset_pctype,
15047 (void *)&cmd_pctype_mapping_reset_mapping,
15048 (void *)&cmd_pctype_mapping_reset_reset,
15053 /* show port pctype mapping */
15055 /* Common result structure for show port pctype mapping */
15056 struct cmd_pctype_mapping_get_result {
15057 cmdline_fixed_string_t show;
15058 cmdline_fixed_string_t port;
15060 cmdline_fixed_string_t pctype;
15061 cmdline_fixed_string_t mapping;
15064 /* Common CLI fields for pctype mapping get */
15065 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15066 TOKEN_STRING_INITIALIZER
15067 (struct cmd_pctype_mapping_get_result,
15069 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15070 TOKEN_STRING_INITIALIZER
15071 (struct cmd_pctype_mapping_get_result,
15073 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15074 TOKEN_NUM_INITIALIZER
15075 (struct cmd_pctype_mapping_get_result,
15077 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15078 TOKEN_STRING_INITIALIZER
15079 (struct cmd_pctype_mapping_get_result,
15081 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15082 TOKEN_STRING_INITIALIZER
15083 (struct cmd_pctype_mapping_get_result,
15084 mapping, "mapping");
15087 cmd_pctype_mapping_get_parsed(
15088 void *parsed_result,
15089 __rte_unused struct cmdline *cl,
15090 __rte_unused void *data)
15092 struct cmd_pctype_mapping_get_result *res = parsed_result;
15093 int ret = -ENOTSUP;
15094 #ifdef RTE_NET_I40E
15095 struct rte_pmd_i40e_flow_type_mapping
15096 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15097 int i, j, first_pctype;
15100 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15103 #ifdef RTE_NET_I40E
15104 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15111 printf("invalid port_id %d\n", res->port_id);
15114 printf("function not implemented\n");
15117 printf("programming error: (%s)\n", strerror(-ret));
15121 #ifdef RTE_NET_I40E
15122 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15123 if (mapping[i].pctype != 0ULL) {
15126 printf("pctype: ");
15127 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15128 if (mapping[i].pctype & (1ULL << j)) {
15129 printf(first_pctype ?
15130 "%02d" : ",%02d", j);
15134 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15140 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15141 .f = cmd_pctype_mapping_get_parsed,
15143 .help_str = "show port <port_id> pctype mapping",
15145 (void *)&cmd_pctype_mapping_get_show,
15146 (void *)&cmd_pctype_mapping_get_port,
15147 (void *)&cmd_pctype_mapping_get_port_id,
15148 (void *)&cmd_pctype_mapping_get_pctype,
15149 (void *)&cmd_pctype_mapping_get_mapping,
15154 /* port config pctype mapping update */
15156 /* Common result structure for port config pctype mapping update */
15157 struct cmd_pctype_mapping_update_result {
15158 cmdline_fixed_string_t port;
15159 cmdline_fixed_string_t config;
15161 cmdline_fixed_string_t pctype;
15162 cmdline_fixed_string_t mapping;
15163 cmdline_fixed_string_t update;
15164 cmdline_fixed_string_t pctype_list;
15165 uint16_t flow_type;
15168 /* Common CLI fields for pctype mapping update*/
15169 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15170 TOKEN_STRING_INITIALIZER
15171 (struct cmd_pctype_mapping_update_result,
15173 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15174 TOKEN_STRING_INITIALIZER
15175 (struct cmd_pctype_mapping_update_result,
15177 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15178 TOKEN_NUM_INITIALIZER
15179 (struct cmd_pctype_mapping_update_result,
15181 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15182 TOKEN_STRING_INITIALIZER
15183 (struct cmd_pctype_mapping_update_result,
15185 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15186 TOKEN_STRING_INITIALIZER
15187 (struct cmd_pctype_mapping_update_result,
15188 mapping, "mapping");
15189 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15190 TOKEN_STRING_INITIALIZER
15191 (struct cmd_pctype_mapping_update_result,
15193 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15194 TOKEN_STRING_INITIALIZER
15195 (struct cmd_pctype_mapping_update_result,
15196 pctype_list, NULL);
15197 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15198 TOKEN_NUM_INITIALIZER
15199 (struct cmd_pctype_mapping_update_result,
15200 flow_type, UINT16);
15203 cmd_pctype_mapping_update_parsed(
15204 void *parsed_result,
15205 __rte_unused struct cmdline *cl,
15206 __rte_unused void *data)
15208 struct cmd_pctype_mapping_update_result *res = parsed_result;
15209 int ret = -ENOTSUP;
15210 #ifdef RTE_NET_I40E
15211 struct rte_pmd_i40e_flow_type_mapping mapping;
15213 unsigned int nb_item;
15214 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15217 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15220 #ifdef RTE_NET_I40E
15221 nb_item = parse_item_list(res->pctype_list, "pctypes",
15222 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15223 mapping.flow_type = res->flow_type;
15224 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15225 mapping.pctype |= (1ULL << pctype_list[i]);
15226 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15236 printf("invalid pctype or flow type\n");
15239 printf("invalid port_id %d\n", res->port_id);
15242 printf("function not implemented\n");
15245 printf("programming error: (%s)\n", strerror(-ret));
15249 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15250 .f = cmd_pctype_mapping_update_parsed,
15252 .help_str = "port config <port_id> pctype mapping update"
15253 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15255 (void *)&cmd_pctype_mapping_update_port,
15256 (void *)&cmd_pctype_mapping_update_config,
15257 (void *)&cmd_pctype_mapping_update_port_id,
15258 (void *)&cmd_pctype_mapping_update_pctype,
15259 (void *)&cmd_pctype_mapping_update_mapping,
15260 (void *)&cmd_pctype_mapping_update_update,
15261 (void *)&cmd_pctype_mapping_update_pc_type,
15262 (void *)&cmd_pctype_mapping_update_flow_type,
15267 /* ptype mapping get */
15269 /* Common result structure for ptype mapping get */
15270 struct cmd_ptype_mapping_get_result {
15271 cmdline_fixed_string_t ptype;
15272 cmdline_fixed_string_t mapping;
15273 cmdline_fixed_string_t get;
15275 uint8_t valid_only;
15278 /* Common CLI fields for ptype mapping get */
15279 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15280 TOKEN_STRING_INITIALIZER
15281 (struct cmd_ptype_mapping_get_result,
15283 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15284 TOKEN_STRING_INITIALIZER
15285 (struct cmd_ptype_mapping_get_result,
15286 mapping, "mapping");
15287 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15288 TOKEN_STRING_INITIALIZER
15289 (struct cmd_ptype_mapping_get_result,
15291 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15292 TOKEN_NUM_INITIALIZER
15293 (struct cmd_ptype_mapping_get_result,
15295 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15296 TOKEN_NUM_INITIALIZER
15297 (struct cmd_ptype_mapping_get_result,
15298 valid_only, UINT8);
15301 cmd_ptype_mapping_get_parsed(
15302 void *parsed_result,
15303 __rte_unused struct cmdline *cl,
15304 __rte_unused void *data)
15306 struct cmd_ptype_mapping_get_result *res = parsed_result;
15307 int ret = -ENOTSUP;
15308 #ifdef RTE_NET_I40E
15309 int max_ptype_num = 256;
15310 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15315 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15318 #ifdef RTE_NET_I40E
15319 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15330 printf("invalid port_id %d\n", res->port_id);
15333 printf("function not implemented\n");
15336 printf("programming error: (%s)\n", strerror(-ret));
15339 #ifdef RTE_NET_I40E
15341 for (i = 0; i < count; i++)
15342 printf("%3d\t0x%08x\n",
15343 mapping[i].hw_ptype, mapping[i].sw_ptype);
15348 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15349 .f = cmd_ptype_mapping_get_parsed,
15351 .help_str = "ptype mapping get <port_id> <valid_only>",
15353 (void *)&cmd_ptype_mapping_get_ptype,
15354 (void *)&cmd_ptype_mapping_get_mapping,
15355 (void *)&cmd_ptype_mapping_get_get,
15356 (void *)&cmd_ptype_mapping_get_port_id,
15357 (void *)&cmd_ptype_mapping_get_valid_only,
15362 /* ptype mapping replace */
15364 /* Common result structure for ptype mapping replace */
15365 struct cmd_ptype_mapping_replace_result {
15366 cmdline_fixed_string_t ptype;
15367 cmdline_fixed_string_t mapping;
15368 cmdline_fixed_string_t replace;
15375 /* Common CLI fields for ptype mapping replace */
15376 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15377 TOKEN_STRING_INITIALIZER
15378 (struct cmd_ptype_mapping_replace_result,
15380 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15381 TOKEN_STRING_INITIALIZER
15382 (struct cmd_ptype_mapping_replace_result,
15383 mapping, "mapping");
15384 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15385 TOKEN_STRING_INITIALIZER
15386 (struct cmd_ptype_mapping_replace_result,
15387 replace, "replace");
15388 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15389 TOKEN_NUM_INITIALIZER
15390 (struct cmd_ptype_mapping_replace_result,
15392 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15393 TOKEN_NUM_INITIALIZER
15394 (struct cmd_ptype_mapping_replace_result,
15396 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15397 TOKEN_NUM_INITIALIZER
15398 (struct cmd_ptype_mapping_replace_result,
15400 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15401 TOKEN_NUM_INITIALIZER
15402 (struct cmd_ptype_mapping_replace_result,
15406 cmd_ptype_mapping_replace_parsed(
15407 void *parsed_result,
15408 __rte_unused struct cmdline *cl,
15409 __rte_unused void *data)
15411 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15412 int ret = -ENOTSUP;
15414 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15417 #ifdef RTE_NET_I40E
15418 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15428 printf("invalid ptype 0x%8x or 0x%8x\n",
15429 res->target, res->pkt_type);
15432 printf("invalid port_id %d\n", res->port_id);
15435 printf("function not implemented\n");
15438 printf("programming error: (%s)\n", strerror(-ret));
15442 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15443 .f = cmd_ptype_mapping_replace_parsed,
15446 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15448 (void *)&cmd_ptype_mapping_replace_ptype,
15449 (void *)&cmd_ptype_mapping_replace_mapping,
15450 (void *)&cmd_ptype_mapping_replace_replace,
15451 (void *)&cmd_ptype_mapping_replace_port_id,
15452 (void *)&cmd_ptype_mapping_replace_target,
15453 (void *)&cmd_ptype_mapping_replace_mask,
15454 (void *)&cmd_ptype_mapping_replace_pkt_type,
15459 /* ptype mapping reset */
15461 /* Common result structure for ptype mapping reset */
15462 struct cmd_ptype_mapping_reset_result {
15463 cmdline_fixed_string_t ptype;
15464 cmdline_fixed_string_t mapping;
15465 cmdline_fixed_string_t reset;
15469 /* Common CLI fields for ptype mapping reset*/
15470 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15471 TOKEN_STRING_INITIALIZER
15472 (struct cmd_ptype_mapping_reset_result,
15474 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15475 TOKEN_STRING_INITIALIZER
15476 (struct cmd_ptype_mapping_reset_result,
15477 mapping, "mapping");
15478 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15479 TOKEN_STRING_INITIALIZER
15480 (struct cmd_ptype_mapping_reset_result,
15482 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15483 TOKEN_NUM_INITIALIZER
15484 (struct cmd_ptype_mapping_reset_result,
15488 cmd_ptype_mapping_reset_parsed(
15489 void *parsed_result,
15490 __rte_unused struct cmdline *cl,
15491 __rte_unused void *data)
15493 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15494 int ret = -ENOTSUP;
15496 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15499 #ifdef RTE_NET_I40E
15500 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15507 printf("invalid port_id %d\n", res->port_id);
15510 printf("function not implemented\n");
15513 printf("programming error: (%s)\n", strerror(-ret));
15517 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15518 .f = cmd_ptype_mapping_reset_parsed,
15520 .help_str = "ptype mapping reset <port_id>",
15522 (void *)&cmd_ptype_mapping_reset_ptype,
15523 (void *)&cmd_ptype_mapping_reset_mapping,
15524 (void *)&cmd_ptype_mapping_reset_reset,
15525 (void *)&cmd_ptype_mapping_reset_port_id,
15530 /* ptype mapping update */
15532 /* Common result structure for ptype mapping update */
15533 struct cmd_ptype_mapping_update_result {
15534 cmdline_fixed_string_t ptype;
15535 cmdline_fixed_string_t mapping;
15536 cmdline_fixed_string_t reset;
15542 /* Common CLI fields for ptype mapping update*/
15543 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15544 TOKEN_STRING_INITIALIZER
15545 (struct cmd_ptype_mapping_update_result,
15547 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15548 TOKEN_STRING_INITIALIZER
15549 (struct cmd_ptype_mapping_update_result,
15550 mapping, "mapping");
15551 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15552 TOKEN_STRING_INITIALIZER
15553 (struct cmd_ptype_mapping_update_result,
15555 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15556 TOKEN_NUM_INITIALIZER
15557 (struct cmd_ptype_mapping_update_result,
15559 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15560 TOKEN_NUM_INITIALIZER
15561 (struct cmd_ptype_mapping_update_result,
15563 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15564 TOKEN_NUM_INITIALIZER
15565 (struct cmd_ptype_mapping_update_result,
15569 cmd_ptype_mapping_update_parsed(
15570 void *parsed_result,
15571 __rte_unused struct cmdline *cl,
15572 __rte_unused void *data)
15574 struct cmd_ptype_mapping_update_result *res = parsed_result;
15575 int ret = -ENOTSUP;
15576 #ifdef RTE_NET_I40E
15577 struct rte_pmd_i40e_ptype_mapping mapping;
15579 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15582 #ifdef RTE_NET_I40E
15583 mapping.hw_ptype = res->hw_ptype;
15584 mapping.sw_ptype = res->sw_ptype;
15585 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15595 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15598 printf("invalid port_id %d\n", res->port_id);
15601 printf("function not implemented\n");
15604 printf("programming error: (%s)\n", strerror(-ret));
15608 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15609 .f = cmd_ptype_mapping_update_parsed,
15611 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15613 (void *)&cmd_ptype_mapping_update_ptype,
15614 (void *)&cmd_ptype_mapping_update_mapping,
15615 (void *)&cmd_ptype_mapping_update_update,
15616 (void *)&cmd_ptype_mapping_update_port_id,
15617 (void *)&cmd_ptype_mapping_update_hw_ptype,
15618 (void *)&cmd_ptype_mapping_update_sw_ptype,
15623 /* Common result structure for file commands */
15624 struct cmd_cmdfile_result {
15625 cmdline_fixed_string_t load;
15626 cmdline_fixed_string_t filename;
15629 /* Common CLI fields for file commands */
15630 cmdline_parse_token_string_t cmd_load_cmdfile =
15631 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15632 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15633 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15636 cmd_load_from_file_parsed(
15637 void *parsed_result,
15638 __rte_unused struct cmdline *cl,
15639 __rte_unused void *data)
15641 struct cmd_cmdfile_result *res = parsed_result;
15643 cmdline_read_from_file(res->filename);
15646 cmdline_parse_inst_t cmd_load_from_file = {
15647 .f = cmd_load_from_file_parsed,
15649 .help_str = "load <filename>",
15651 (void *)&cmd_load_cmdfile,
15652 (void *)&cmd_load_cmdfile_filename,
15657 /* Get Rx offloads capabilities */
15658 struct cmd_rx_offload_get_capa_result {
15659 cmdline_fixed_string_t show;
15660 cmdline_fixed_string_t port;
15662 cmdline_fixed_string_t rx_offload;
15663 cmdline_fixed_string_t capabilities;
15666 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
15667 TOKEN_STRING_INITIALIZER
15668 (struct cmd_rx_offload_get_capa_result,
15670 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
15671 TOKEN_STRING_INITIALIZER
15672 (struct cmd_rx_offload_get_capa_result,
15674 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
15675 TOKEN_NUM_INITIALIZER
15676 (struct cmd_rx_offload_get_capa_result,
15678 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
15679 TOKEN_STRING_INITIALIZER
15680 (struct cmd_rx_offload_get_capa_result,
15681 rx_offload, "rx_offload");
15682 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
15683 TOKEN_STRING_INITIALIZER
15684 (struct cmd_rx_offload_get_capa_result,
15685 capabilities, "capabilities");
15688 print_rx_offloads(uint64_t offloads)
15690 uint64_t single_offload;
15698 begin = __builtin_ctzll(offloads);
15699 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15701 single_offload = 1ULL << begin;
15702 for (bit = begin; bit < end; bit++) {
15703 if (offloads & single_offload)
15705 rte_eth_dev_rx_offload_name(single_offload));
15706 single_offload <<= 1;
15711 cmd_rx_offload_get_capa_parsed(
15712 void *parsed_result,
15713 __rte_unused struct cmdline *cl,
15714 __rte_unused void *data)
15716 struct cmd_rx_offload_get_capa_result *res = parsed_result;
15717 struct rte_eth_dev_info dev_info;
15718 portid_t port_id = res->port_id;
15719 uint64_t queue_offloads;
15720 uint64_t port_offloads;
15723 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15727 queue_offloads = dev_info.rx_queue_offload_capa;
15728 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
15730 printf("Rx Offloading Capabilities of port %d :\n", port_id);
15731 printf(" Per Queue :");
15732 print_rx_offloads(queue_offloads);
15735 printf(" Per Port :");
15736 print_rx_offloads(port_offloads);
15740 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
15741 .f = cmd_rx_offload_get_capa_parsed,
15743 .help_str = "show port <port_id> rx_offload capabilities",
15745 (void *)&cmd_rx_offload_get_capa_show,
15746 (void *)&cmd_rx_offload_get_capa_port,
15747 (void *)&cmd_rx_offload_get_capa_port_id,
15748 (void *)&cmd_rx_offload_get_capa_rx_offload,
15749 (void *)&cmd_rx_offload_get_capa_capabilities,
15754 /* Get Rx offloads configuration */
15755 struct cmd_rx_offload_get_configuration_result {
15756 cmdline_fixed_string_t show;
15757 cmdline_fixed_string_t port;
15759 cmdline_fixed_string_t rx_offload;
15760 cmdline_fixed_string_t configuration;
15763 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
15764 TOKEN_STRING_INITIALIZER
15765 (struct cmd_rx_offload_get_configuration_result,
15767 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
15768 TOKEN_STRING_INITIALIZER
15769 (struct cmd_rx_offload_get_configuration_result,
15771 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
15772 TOKEN_NUM_INITIALIZER
15773 (struct cmd_rx_offload_get_configuration_result,
15775 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
15776 TOKEN_STRING_INITIALIZER
15777 (struct cmd_rx_offload_get_configuration_result,
15778 rx_offload, "rx_offload");
15779 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
15780 TOKEN_STRING_INITIALIZER
15781 (struct cmd_rx_offload_get_configuration_result,
15782 configuration, "configuration");
15785 cmd_rx_offload_get_configuration_parsed(
15786 void *parsed_result,
15787 __rte_unused struct cmdline *cl,
15788 __rte_unused void *data)
15790 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
15791 struct rte_eth_dev_info dev_info;
15792 portid_t port_id = res->port_id;
15793 struct rte_port *port = &ports[port_id];
15794 uint64_t port_offloads;
15795 uint64_t queue_offloads;
15796 uint16_t nb_rx_queues;
15800 printf("Rx Offloading Configuration of port %d :\n", port_id);
15802 port_offloads = port->dev_conf.rxmode.offloads;
15804 print_rx_offloads(port_offloads);
15807 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15811 nb_rx_queues = dev_info.nb_rx_queues;
15812 for (q = 0; q < nb_rx_queues; q++) {
15813 queue_offloads = port->rx_conf[q].offloads;
15814 printf(" Queue[%2d] :", q);
15815 print_rx_offloads(queue_offloads);
15821 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
15822 .f = cmd_rx_offload_get_configuration_parsed,
15824 .help_str = "show port <port_id> rx_offload configuration",
15826 (void *)&cmd_rx_offload_get_configuration_show,
15827 (void *)&cmd_rx_offload_get_configuration_port,
15828 (void *)&cmd_rx_offload_get_configuration_port_id,
15829 (void *)&cmd_rx_offload_get_configuration_rx_offload,
15830 (void *)&cmd_rx_offload_get_configuration_configuration,
15835 /* Enable/Disable a per port offloading */
15836 struct cmd_config_per_port_rx_offload_result {
15837 cmdline_fixed_string_t port;
15838 cmdline_fixed_string_t config;
15840 cmdline_fixed_string_t rx_offload;
15841 cmdline_fixed_string_t offload;
15842 cmdline_fixed_string_t on_off;
15845 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
15846 TOKEN_STRING_INITIALIZER
15847 (struct cmd_config_per_port_rx_offload_result,
15849 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
15850 TOKEN_STRING_INITIALIZER
15851 (struct cmd_config_per_port_rx_offload_result,
15853 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
15854 TOKEN_NUM_INITIALIZER
15855 (struct cmd_config_per_port_rx_offload_result,
15857 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
15858 TOKEN_STRING_INITIALIZER
15859 (struct cmd_config_per_port_rx_offload_result,
15860 rx_offload, "rx_offload");
15861 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
15862 TOKEN_STRING_INITIALIZER
15863 (struct cmd_config_per_port_rx_offload_result,
15864 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
15865 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
15866 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
15867 "scatter#buffer_split#timestamp#security#"
15868 "keep_crc#rss_hash");
15869 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
15870 TOKEN_STRING_INITIALIZER
15871 (struct cmd_config_per_port_rx_offload_result,
15875 search_rx_offload(const char *name)
15877 uint64_t single_offload;
15878 const char *single_name;
15882 single_offload = 1;
15883 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
15884 single_name = rte_eth_dev_rx_offload_name(single_offload);
15885 if (!strcasecmp(single_name, name)) {
15889 single_offload <<= 1;
15893 return single_offload;
15899 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
15900 __rte_unused struct cmdline *cl,
15901 __rte_unused void *data)
15903 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
15904 portid_t port_id = res->port_id;
15905 struct rte_eth_dev_info dev_info;
15906 struct rte_port *port = &ports[port_id];
15907 uint64_t single_offload;
15908 uint16_t nb_rx_queues;
15912 if (port->port_status != RTE_PORT_STOPPED) {
15913 printf("Error: Can't config offload when Port %d "
15914 "is not stopped\n", port_id);
15918 single_offload = search_rx_offload(res->offload);
15919 if (single_offload == 0) {
15920 printf("Unknown offload name: %s\n", res->offload);
15924 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15928 nb_rx_queues = dev_info.nb_rx_queues;
15929 if (!strcmp(res->on_off, "on")) {
15930 port->dev_conf.rxmode.offloads |= single_offload;
15931 for (q = 0; q < nb_rx_queues; q++)
15932 port->rx_conf[q].offloads |= single_offload;
15934 port->dev_conf.rxmode.offloads &= ~single_offload;
15935 for (q = 0; q < nb_rx_queues; q++)
15936 port->rx_conf[q].offloads &= ~single_offload;
15939 cmd_reconfig_device_queue(port_id, 1, 1);
15942 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
15943 .f = cmd_config_per_port_rx_offload_parsed,
15945 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
15946 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
15947 "macsec_strip|header_split|vlan_filter|vlan_extend|"
15948 "jumbo_frame|scatter|buffer_split|timestamp|security|"
15949 "keep_crc|rss_hash on|off",
15951 (void *)&cmd_config_per_port_rx_offload_result_port,
15952 (void *)&cmd_config_per_port_rx_offload_result_config,
15953 (void *)&cmd_config_per_port_rx_offload_result_port_id,
15954 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
15955 (void *)&cmd_config_per_port_rx_offload_result_offload,
15956 (void *)&cmd_config_per_port_rx_offload_result_on_off,
15961 /* Enable/Disable a per queue offloading */
15962 struct cmd_config_per_queue_rx_offload_result {
15963 cmdline_fixed_string_t port;
15965 cmdline_fixed_string_t rxq;
15967 cmdline_fixed_string_t rx_offload;
15968 cmdline_fixed_string_t offload;
15969 cmdline_fixed_string_t on_off;
15972 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
15973 TOKEN_STRING_INITIALIZER
15974 (struct cmd_config_per_queue_rx_offload_result,
15976 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
15977 TOKEN_NUM_INITIALIZER
15978 (struct cmd_config_per_queue_rx_offload_result,
15980 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
15981 TOKEN_STRING_INITIALIZER
15982 (struct cmd_config_per_queue_rx_offload_result,
15984 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
15985 TOKEN_NUM_INITIALIZER
15986 (struct cmd_config_per_queue_rx_offload_result,
15988 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
15989 TOKEN_STRING_INITIALIZER
15990 (struct cmd_config_per_queue_rx_offload_result,
15991 rx_offload, "rx_offload");
15992 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
15993 TOKEN_STRING_INITIALIZER
15994 (struct cmd_config_per_queue_rx_offload_result,
15995 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
15996 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
15997 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
15998 "scatter#buffer_split#timestamp#security#keep_crc");
15999 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16000 TOKEN_STRING_INITIALIZER
16001 (struct cmd_config_per_queue_rx_offload_result,
16005 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16006 __rte_unused struct cmdline *cl,
16007 __rte_unused void *data)
16009 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16010 struct rte_eth_dev_info dev_info;
16011 portid_t port_id = res->port_id;
16012 uint16_t queue_id = res->queue_id;
16013 struct rte_port *port = &ports[port_id];
16014 uint64_t single_offload;
16017 if (port->port_status != RTE_PORT_STOPPED) {
16018 printf("Error: Can't config offload when Port %d "
16019 "is not stopped\n", port_id);
16023 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16027 if (queue_id >= dev_info.nb_rx_queues) {
16028 printf("Error: input queue_id should be 0 ... "
16029 "%d\n", dev_info.nb_rx_queues - 1);
16033 single_offload = search_rx_offload(res->offload);
16034 if (single_offload == 0) {
16035 printf("Unknown offload name: %s\n", res->offload);
16039 if (!strcmp(res->on_off, "on"))
16040 port->rx_conf[queue_id].offloads |= single_offload;
16042 port->rx_conf[queue_id].offloads &= ~single_offload;
16044 cmd_reconfig_device_queue(port_id, 1, 1);
16047 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16048 .f = cmd_config_per_queue_rx_offload_parsed,
16050 .help_str = "port <port_id> rxq <queue_id> rx_offload "
16051 "vlan_strip|ipv4_cksum|"
16052 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16053 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16054 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16057 (void *)&cmd_config_per_queue_rx_offload_result_port,
16058 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
16059 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
16060 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16061 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16062 (void *)&cmd_config_per_queue_rx_offload_result_offload,
16063 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
16068 /* Get Tx offloads capabilities */
16069 struct cmd_tx_offload_get_capa_result {
16070 cmdline_fixed_string_t show;
16071 cmdline_fixed_string_t port;
16073 cmdline_fixed_string_t tx_offload;
16074 cmdline_fixed_string_t capabilities;
16077 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16078 TOKEN_STRING_INITIALIZER
16079 (struct cmd_tx_offload_get_capa_result,
16081 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16082 TOKEN_STRING_INITIALIZER
16083 (struct cmd_tx_offload_get_capa_result,
16085 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16086 TOKEN_NUM_INITIALIZER
16087 (struct cmd_tx_offload_get_capa_result,
16089 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16090 TOKEN_STRING_INITIALIZER
16091 (struct cmd_tx_offload_get_capa_result,
16092 tx_offload, "tx_offload");
16093 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16094 TOKEN_STRING_INITIALIZER
16095 (struct cmd_tx_offload_get_capa_result,
16096 capabilities, "capabilities");
16099 print_tx_offloads(uint64_t offloads)
16101 uint64_t single_offload;
16109 begin = __builtin_ctzll(offloads);
16110 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16112 single_offload = 1ULL << begin;
16113 for (bit = begin; bit < end; bit++) {
16114 if (offloads & single_offload)
16116 rte_eth_dev_tx_offload_name(single_offload));
16117 single_offload <<= 1;
16122 cmd_tx_offload_get_capa_parsed(
16123 void *parsed_result,
16124 __rte_unused struct cmdline *cl,
16125 __rte_unused void *data)
16127 struct cmd_tx_offload_get_capa_result *res = parsed_result;
16128 struct rte_eth_dev_info dev_info;
16129 portid_t port_id = res->port_id;
16130 uint64_t queue_offloads;
16131 uint64_t port_offloads;
16134 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16138 queue_offloads = dev_info.tx_queue_offload_capa;
16139 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16141 printf("Tx Offloading Capabilities of port %d :\n", port_id);
16142 printf(" Per Queue :");
16143 print_tx_offloads(queue_offloads);
16146 printf(" Per Port :");
16147 print_tx_offloads(port_offloads);
16151 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16152 .f = cmd_tx_offload_get_capa_parsed,
16154 .help_str = "show port <port_id> tx_offload capabilities",
16156 (void *)&cmd_tx_offload_get_capa_show,
16157 (void *)&cmd_tx_offload_get_capa_port,
16158 (void *)&cmd_tx_offload_get_capa_port_id,
16159 (void *)&cmd_tx_offload_get_capa_tx_offload,
16160 (void *)&cmd_tx_offload_get_capa_capabilities,
16165 /* Get Tx offloads configuration */
16166 struct cmd_tx_offload_get_configuration_result {
16167 cmdline_fixed_string_t show;
16168 cmdline_fixed_string_t port;
16170 cmdline_fixed_string_t tx_offload;
16171 cmdline_fixed_string_t configuration;
16174 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16175 TOKEN_STRING_INITIALIZER
16176 (struct cmd_tx_offload_get_configuration_result,
16178 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16179 TOKEN_STRING_INITIALIZER
16180 (struct cmd_tx_offload_get_configuration_result,
16182 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16183 TOKEN_NUM_INITIALIZER
16184 (struct cmd_tx_offload_get_configuration_result,
16186 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16187 TOKEN_STRING_INITIALIZER
16188 (struct cmd_tx_offload_get_configuration_result,
16189 tx_offload, "tx_offload");
16190 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16191 TOKEN_STRING_INITIALIZER
16192 (struct cmd_tx_offload_get_configuration_result,
16193 configuration, "configuration");
16196 cmd_tx_offload_get_configuration_parsed(
16197 void *parsed_result,
16198 __rte_unused struct cmdline *cl,
16199 __rte_unused void *data)
16201 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16202 struct rte_eth_dev_info dev_info;
16203 portid_t port_id = res->port_id;
16204 struct rte_port *port = &ports[port_id];
16205 uint64_t port_offloads;
16206 uint64_t queue_offloads;
16207 uint16_t nb_tx_queues;
16211 printf("Tx Offloading Configuration of port %d :\n", port_id);
16213 port_offloads = port->dev_conf.txmode.offloads;
16215 print_tx_offloads(port_offloads);
16218 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16222 nb_tx_queues = dev_info.nb_tx_queues;
16223 for (q = 0; q < nb_tx_queues; q++) {
16224 queue_offloads = port->tx_conf[q].offloads;
16225 printf(" Queue[%2d] :", q);
16226 print_tx_offloads(queue_offloads);
16232 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16233 .f = cmd_tx_offload_get_configuration_parsed,
16235 .help_str = "show port <port_id> tx_offload configuration",
16237 (void *)&cmd_tx_offload_get_configuration_show,
16238 (void *)&cmd_tx_offload_get_configuration_port,
16239 (void *)&cmd_tx_offload_get_configuration_port_id,
16240 (void *)&cmd_tx_offload_get_configuration_tx_offload,
16241 (void *)&cmd_tx_offload_get_configuration_configuration,
16246 /* Enable/Disable a per port offloading */
16247 struct cmd_config_per_port_tx_offload_result {
16248 cmdline_fixed_string_t port;
16249 cmdline_fixed_string_t config;
16251 cmdline_fixed_string_t tx_offload;
16252 cmdline_fixed_string_t offload;
16253 cmdline_fixed_string_t on_off;
16256 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16257 TOKEN_STRING_INITIALIZER
16258 (struct cmd_config_per_port_tx_offload_result,
16260 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16261 TOKEN_STRING_INITIALIZER
16262 (struct cmd_config_per_port_tx_offload_result,
16264 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16265 TOKEN_NUM_INITIALIZER
16266 (struct cmd_config_per_port_tx_offload_result,
16268 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16269 TOKEN_STRING_INITIALIZER
16270 (struct cmd_config_per_port_tx_offload_result,
16271 tx_offload, "tx_offload");
16272 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16273 TOKEN_STRING_INITIALIZER
16274 (struct cmd_config_per_port_tx_offload_result,
16275 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16276 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16277 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16278 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16279 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16280 "send_on_timestamp");
16281 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16282 TOKEN_STRING_INITIALIZER
16283 (struct cmd_config_per_port_tx_offload_result,
16287 search_tx_offload(const char *name)
16289 uint64_t single_offload;
16290 const char *single_name;
16294 single_offload = 1;
16295 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16296 single_name = rte_eth_dev_tx_offload_name(single_offload);
16297 if (single_name == NULL)
16299 if (!strcasecmp(single_name, name)) {
16302 } else if (!strcasecmp(single_name, "UNKNOWN"))
16304 single_offload <<= 1;
16308 return single_offload;
16314 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16315 __rte_unused struct cmdline *cl,
16316 __rte_unused void *data)
16318 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16319 portid_t port_id = res->port_id;
16320 struct rte_eth_dev_info dev_info;
16321 struct rte_port *port = &ports[port_id];
16322 uint64_t single_offload;
16323 uint16_t nb_tx_queues;
16327 if (port->port_status != RTE_PORT_STOPPED) {
16328 printf("Error: Can't config offload when Port %d "
16329 "is not stopped\n", port_id);
16333 single_offload = search_tx_offload(res->offload);
16334 if (single_offload == 0) {
16335 printf("Unknown offload name: %s\n", res->offload);
16339 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16343 nb_tx_queues = dev_info.nb_tx_queues;
16344 if (!strcmp(res->on_off, "on")) {
16345 port->dev_conf.txmode.offloads |= single_offload;
16346 for (q = 0; q < nb_tx_queues; q++)
16347 port->tx_conf[q].offloads |= single_offload;
16349 port->dev_conf.txmode.offloads &= ~single_offload;
16350 for (q = 0; q < nb_tx_queues; q++)
16351 port->tx_conf[q].offloads &= ~single_offload;
16354 cmd_reconfig_device_queue(port_id, 1, 1);
16357 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16358 .f = cmd_config_per_port_tx_offload_parsed,
16360 .help_str = "port config <port_id> tx_offload "
16361 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16362 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16363 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16364 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16365 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16366 "send_on_timestamp on|off",
16368 (void *)&cmd_config_per_port_tx_offload_result_port,
16369 (void *)&cmd_config_per_port_tx_offload_result_config,
16370 (void *)&cmd_config_per_port_tx_offload_result_port_id,
16371 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16372 (void *)&cmd_config_per_port_tx_offload_result_offload,
16373 (void *)&cmd_config_per_port_tx_offload_result_on_off,
16378 /* Enable/Disable a per queue offloading */
16379 struct cmd_config_per_queue_tx_offload_result {
16380 cmdline_fixed_string_t port;
16382 cmdline_fixed_string_t txq;
16384 cmdline_fixed_string_t tx_offload;
16385 cmdline_fixed_string_t offload;
16386 cmdline_fixed_string_t on_off;
16389 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16390 TOKEN_STRING_INITIALIZER
16391 (struct cmd_config_per_queue_tx_offload_result,
16393 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16394 TOKEN_NUM_INITIALIZER
16395 (struct cmd_config_per_queue_tx_offload_result,
16397 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16398 TOKEN_STRING_INITIALIZER
16399 (struct cmd_config_per_queue_tx_offload_result,
16401 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16402 TOKEN_NUM_INITIALIZER
16403 (struct cmd_config_per_queue_tx_offload_result,
16405 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16406 TOKEN_STRING_INITIALIZER
16407 (struct cmd_config_per_queue_tx_offload_result,
16408 tx_offload, "tx_offload");
16409 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16410 TOKEN_STRING_INITIALIZER
16411 (struct cmd_config_per_queue_tx_offload_result,
16412 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16413 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16414 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16415 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16416 "mt_lockfree#multi_segs#mbuf_fast_free#security");
16417 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16418 TOKEN_STRING_INITIALIZER
16419 (struct cmd_config_per_queue_tx_offload_result,
16423 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16424 __rte_unused struct cmdline *cl,
16425 __rte_unused void *data)
16427 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16428 struct rte_eth_dev_info dev_info;
16429 portid_t port_id = res->port_id;
16430 uint16_t queue_id = res->queue_id;
16431 struct rte_port *port = &ports[port_id];
16432 uint64_t single_offload;
16435 if (port->port_status != RTE_PORT_STOPPED) {
16436 printf("Error: Can't config offload when Port %d "
16437 "is not stopped\n", port_id);
16441 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16445 if (queue_id >= dev_info.nb_tx_queues) {
16446 printf("Error: input queue_id should be 0 ... "
16447 "%d\n", dev_info.nb_tx_queues - 1);
16451 single_offload = search_tx_offload(res->offload);
16452 if (single_offload == 0) {
16453 printf("Unknown offload name: %s\n", res->offload);
16457 if (!strcmp(res->on_off, "on"))
16458 port->tx_conf[queue_id].offloads |= single_offload;
16460 port->tx_conf[queue_id].offloads &= ~single_offload;
16462 cmd_reconfig_device_queue(port_id, 1, 1);
16465 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16466 .f = cmd_config_per_queue_tx_offload_parsed,
16468 .help_str = "port <port_id> txq <queue_id> tx_offload "
16469 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16470 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16471 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16472 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16473 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16476 (void *)&cmd_config_per_queue_tx_offload_result_port,
16477 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16478 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16479 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16480 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16481 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16482 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16487 /* *** configure tx_metadata for specific port *** */
16488 struct cmd_config_tx_metadata_specific_result {
16489 cmdline_fixed_string_t port;
16490 cmdline_fixed_string_t keyword;
16492 cmdline_fixed_string_t item;
16497 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16498 __rte_unused struct cmdline *cl,
16499 __rte_unused void *data)
16501 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16503 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16505 ports[res->port_id].tx_metadata = res->value;
16506 /* Add/remove callback to insert valid metadata in every Tx packet. */
16507 if (ports[res->port_id].tx_metadata)
16508 add_tx_md_callback(res->port_id);
16510 remove_tx_md_callback(res->port_id);
16511 rte_flow_dynf_metadata_register();
16514 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16515 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16517 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16518 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16519 keyword, "config");
16520 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16521 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16523 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16524 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16525 item, "tx_metadata");
16526 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16527 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16530 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16531 .f = cmd_config_tx_metadata_specific_parsed,
16533 .help_str = "port config <port_id> tx_metadata <value>",
16535 (void *)&cmd_config_tx_metadata_specific_port,
16536 (void *)&cmd_config_tx_metadata_specific_keyword,
16537 (void *)&cmd_config_tx_metadata_specific_id,
16538 (void *)&cmd_config_tx_metadata_specific_item,
16539 (void *)&cmd_config_tx_metadata_specific_value,
16544 /* *** set dynf *** */
16545 struct cmd_config_tx_dynf_specific_result {
16546 cmdline_fixed_string_t port;
16547 cmdline_fixed_string_t keyword;
16549 cmdline_fixed_string_t item;
16550 cmdline_fixed_string_t name;
16551 cmdline_fixed_string_t value;
16555 cmd_config_dynf_specific_parsed(void *parsed_result,
16556 __rte_unused struct cmdline *cl,
16557 __rte_unused void *data)
16559 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16560 struct rte_mbuf_dynflag desc_flag;
16562 uint64_t old_port_flags;
16564 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16566 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16568 if (strlcpy(desc_flag.name, res->name,
16569 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16570 printf("Flag name too long\n");
16573 desc_flag.flags = 0;
16574 flag = rte_mbuf_dynflag_register(&desc_flag);
16576 printf("Can't register flag\n");
16579 strcpy(dynf_names[flag], desc_flag.name);
16581 old_port_flags = ports[res->port_id].mbuf_dynf;
16582 if (!strcmp(res->value, "set")) {
16583 ports[res->port_id].mbuf_dynf |= 1UL << flag;
16584 if (old_port_flags == 0)
16585 add_tx_dynf_callback(res->port_id);
16587 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16588 if (ports[res->port_id].mbuf_dynf == 0)
16589 remove_tx_dynf_callback(res->port_id);
16593 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16594 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16596 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16597 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16598 keyword, "config");
16599 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
16600 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16602 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
16603 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16605 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
16606 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16608 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
16609 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16610 value, "set#clear");
16612 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
16613 .f = cmd_config_dynf_specific_parsed,
16615 .help_str = "port config <port id> dynf <name> set|clear",
16617 (void *)&cmd_config_tx_dynf_specific_port,
16618 (void *)&cmd_config_tx_dynf_specific_keyword,
16619 (void *)&cmd_config_tx_dynf_specific_port_id,
16620 (void *)&cmd_config_tx_dynf_specific_item,
16621 (void *)&cmd_config_tx_dynf_specific_name,
16622 (void *)&cmd_config_tx_dynf_specific_value,
16627 /* *** display tx_metadata per port configuration *** */
16628 struct cmd_show_tx_metadata_result {
16629 cmdline_fixed_string_t cmd_show;
16630 cmdline_fixed_string_t cmd_port;
16631 cmdline_fixed_string_t cmd_keyword;
16636 cmd_show_tx_metadata_parsed(void *parsed_result,
16637 __rte_unused struct cmdline *cl,
16638 __rte_unused void *data)
16640 struct cmd_show_tx_metadata_result *res = parsed_result;
16642 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16643 printf("invalid port id %u\n", res->cmd_pid);
16646 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
16647 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
16648 ports[res->cmd_pid].tx_metadata);
16652 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
16653 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16655 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
16656 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16658 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
16659 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
16661 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
16662 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16663 cmd_keyword, "tx_metadata");
16665 cmdline_parse_inst_t cmd_show_tx_metadata = {
16666 .f = cmd_show_tx_metadata_parsed,
16668 .help_str = "show port <port_id> tx_metadata",
16670 (void *)&cmd_show_tx_metadata_show,
16671 (void *)&cmd_show_tx_metadata_port,
16672 (void *)&cmd_show_tx_metadata_pid,
16673 (void *)&cmd_show_tx_metadata_keyword,
16678 /* *** show fec capability per port configuration *** */
16679 struct cmd_show_fec_capability_result {
16680 cmdline_fixed_string_t cmd_show;
16681 cmdline_fixed_string_t cmd_port;
16682 cmdline_fixed_string_t cmd_fec;
16683 cmdline_fixed_string_t cmd_keyword;
16688 cmd_show_fec_capability_parsed(void *parsed_result,
16689 __rte_unused struct cmdline *cl,
16690 __rte_unused void *data)
16692 #define FEC_CAP_NUM 2
16693 struct cmd_show_fec_capability_result *res = parsed_result;
16694 struct rte_eth_fec_capa speed_fec_capa[FEC_CAP_NUM];
16695 unsigned int num = FEC_CAP_NUM;
16696 unsigned int ret_num;
16699 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16700 printf("Invalid port id %u\n", res->cmd_pid);
16704 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
16705 if (ret == -ENOTSUP) {
16706 printf("Function not implemented\n");
16708 } else if (ret < 0) {
16709 printf("Get FEC capability failed\n");
16713 ret_num = (unsigned int)ret;
16714 show_fec_capability(ret_num, speed_fec_capa);
16717 cmdline_parse_token_string_t cmd_show_fec_capability_show =
16718 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16720 cmdline_parse_token_string_t cmd_show_fec_capability_port =
16721 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16723 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
16724 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
16726 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
16727 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16729 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
16730 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16731 cmd_keyword, "capabilities");
16733 cmdline_parse_inst_t cmd_show_capability = {
16734 .f = cmd_show_fec_capability_parsed,
16736 .help_str = "show port <port_id> fec capabilities",
16738 (void *)&cmd_show_fec_capability_show,
16739 (void *)&cmd_show_fec_capability_port,
16740 (void *)&cmd_show_fec_capability_pid,
16741 (void *)&cmd_show_fec_capability_fec,
16742 (void *)&cmd_show_fec_capability_keyword,
16747 /* *** show fec mode per port configuration *** */
16748 struct cmd_show_fec_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_fec_mode_parsed(void *parsed_result,
16757 __rte_unused struct cmdline *cl,
16758 __rte_unused void *data)
16760 #define FEC_NAME_SIZE 16
16761 struct cmd_show_fec_metadata_result *res = parsed_result;
16763 char buf[FEC_NAME_SIZE];
16766 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16767 printf("Invalid port id %u\n", res->cmd_pid);
16770 ret = rte_eth_fec_get(res->cmd_pid, &mode);
16771 if (ret == -ENOTSUP) {
16772 printf("Function not implemented\n");
16774 } else if (ret < 0) {
16775 printf("Get FEC mode failed\n");
16780 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
16781 strlcpy(buf, "off", sizeof(buf));
16783 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
16784 strlcpy(buf, "auto", sizeof(buf));
16786 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
16787 strlcpy(buf, "baser", sizeof(buf));
16789 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
16790 strlcpy(buf, "rs", sizeof(buf));
16796 printf("%s\n", buf);
16799 cmdline_parse_token_string_t cmd_show_fec_mode_show =
16800 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16802 cmdline_parse_token_string_t cmd_show_fec_mode_port =
16803 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16805 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
16806 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
16808 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
16809 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16810 cmd_keyword, "fec_mode");
16812 cmdline_parse_inst_t cmd_show_fec_mode = {
16813 .f = cmd_show_fec_mode_parsed,
16815 .help_str = "show port <port_id> fec_mode",
16817 (void *)&cmd_show_fec_mode_show,
16818 (void *)&cmd_show_fec_mode_port,
16819 (void *)&cmd_show_fec_mode_pid,
16820 (void *)&cmd_show_fec_mode_keyword,
16825 /* *** set fec mode per port configuration *** */
16826 struct cmd_set_port_fec_mode {
16827 cmdline_fixed_string_t set;
16828 cmdline_fixed_string_t port;
16830 cmdline_fixed_string_t fec_mode;
16831 cmdline_fixed_string_t fec_value;
16834 /* Common CLI fields for set fec mode */
16835 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
16836 TOKEN_STRING_INITIALIZER
16837 (struct cmd_set_port_fec_mode,
16839 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
16840 TOKEN_STRING_INITIALIZER
16841 (struct cmd_set_port_fec_mode,
16843 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
16844 TOKEN_NUM_INITIALIZER
16845 (struct cmd_set_port_fec_mode,
16847 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
16848 TOKEN_STRING_INITIALIZER
16849 (struct cmd_set_port_fec_mode,
16850 fec_mode, "fec_mode");
16851 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
16852 TOKEN_STRING_INITIALIZER
16853 (struct cmd_set_port_fec_mode,
16857 cmd_set_port_fec_mode_parsed(
16858 void *parsed_result,
16859 __rte_unused struct cmdline *cl,
16860 __rte_unused void *data)
16862 struct cmd_set_port_fec_mode *res = parsed_result;
16863 uint16_t port_id = res->port_id;
16867 ret = parse_fec_mode(res->fec_value, &mode);
16869 printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
16874 ret = rte_eth_fec_set(port_id, mode);
16875 if (ret == -ENOTSUP) {
16876 printf("Function not implemented\n");
16878 } else if (ret < 0) {
16879 printf("Set FEC mode failed\n");
16884 cmdline_parse_inst_t cmd_set_fec_mode = {
16885 .f = cmd_set_port_fec_mode_parsed,
16887 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
16889 (void *)&cmd_set_port_fec_mode_set,
16890 (void *)&cmd_set_port_fec_mode_port,
16891 (void *)&cmd_set_port_fec_mode_port_id,
16892 (void *)&cmd_set_port_fec_mode_str,
16893 (void *)&cmd_set_port_fec_mode_value,
16898 /* show port supported ptypes */
16900 /* Common result structure for show port ptypes */
16901 struct cmd_show_port_supported_ptypes_result {
16902 cmdline_fixed_string_t show;
16903 cmdline_fixed_string_t port;
16905 cmdline_fixed_string_t ptypes;
16908 /* Common CLI fields for show port ptypes */
16909 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
16910 TOKEN_STRING_INITIALIZER
16911 (struct cmd_show_port_supported_ptypes_result,
16913 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
16914 TOKEN_STRING_INITIALIZER
16915 (struct cmd_show_port_supported_ptypes_result,
16917 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
16918 TOKEN_NUM_INITIALIZER
16919 (struct cmd_show_port_supported_ptypes_result,
16921 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
16922 TOKEN_STRING_INITIALIZER
16923 (struct cmd_show_port_supported_ptypes_result,
16927 cmd_show_port_supported_ptypes_parsed(
16928 void *parsed_result,
16929 __rte_unused struct cmdline *cl,
16930 __rte_unused void *data)
16932 #define RSVD_PTYPE_MASK 0xf0000000
16933 #define MAX_PTYPES_PER_LAYER 16
16934 #define LTYPE_NAMESIZE 32
16935 #define PTYPE_NAMESIZE 256
16936 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
16937 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
16938 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
16939 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
16940 uint16_t port_id = res->port_id;
16943 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
16947 while (ptype_mask != RSVD_PTYPE_MASK) {
16949 switch (ptype_mask) {
16950 case RTE_PTYPE_L2_MASK:
16951 strlcpy(ltype, "L2", sizeof(ltype));
16953 case RTE_PTYPE_L3_MASK:
16954 strlcpy(ltype, "L3", sizeof(ltype));
16956 case RTE_PTYPE_L4_MASK:
16957 strlcpy(ltype, "L4", sizeof(ltype));
16959 case RTE_PTYPE_TUNNEL_MASK:
16960 strlcpy(ltype, "Tunnel", sizeof(ltype));
16962 case RTE_PTYPE_INNER_L2_MASK:
16963 strlcpy(ltype, "Inner L2", sizeof(ltype));
16965 case RTE_PTYPE_INNER_L3_MASK:
16966 strlcpy(ltype, "Inner L3", sizeof(ltype));
16968 case RTE_PTYPE_INNER_L4_MASK:
16969 strlcpy(ltype, "Inner L4", sizeof(ltype));
16975 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
16976 ptype_mask, ptypes,
16977 MAX_PTYPES_PER_LAYER);
16980 printf("Supported %s ptypes:\n", ltype);
16982 printf("%s ptypes unsupported\n", ltype);
16984 for (i = 0; i < ret; ++i) {
16985 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
16986 printf("%s\n", buf);
16993 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
16994 .f = cmd_show_port_supported_ptypes_parsed,
16996 .help_str = "show port <port_id> ptypes",
16998 (void *)&cmd_show_port_supported_ptypes_show,
16999 (void *)&cmd_show_port_supported_ptypes_port,
17000 (void *)&cmd_show_port_supported_ptypes_port_id,
17001 (void *)&cmd_show_port_supported_ptypes_ptypes,
17006 /* *** display rx/tx descriptor status *** */
17007 struct cmd_show_rx_tx_desc_status_result {
17008 cmdline_fixed_string_t cmd_show;
17009 cmdline_fixed_string_t cmd_port;
17010 cmdline_fixed_string_t cmd_keyword;
17011 cmdline_fixed_string_t cmd_desc;
17012 cmdline_fixed_string_t cmd_status;
17019 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
17020 __rte_unused struct cmdline *cl,
17021 __rte_unused void *data)
17023 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
17026 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17027 printf("invalid port id %u\n", res->cmd_pid);
17031 if (!strcmp(res->cmd_keyword, "rxq")) {
17032 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
17035 printf("Invalid queueid = %d\n", res->cmd_qid);
17038 if (rc == RTE_ETH_RX_DESC_AVAIL)
17039 printf("Desc status = AVAILABLE\n");
17040 else if (rc == RTE_ETH_RX_DESC_DONE)
17041 printf("Desc status = DONE\n");
17043 printf("Desc status = UNAVAILABLE\n");
17044 } else if (!strcmp(res->cmd_keyword, "txq")) {
17045 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17048 printf("Invalid queueid = %d\n", res->cmd_qid);
17051 if (rc == RTE_ETH_TX_DESC_FULL)
17052 printf("Desc status = FULL\n");
17053 else if (rc == RTE_ETH_TX_DESC_DONE)
17054 printf("Desc status = DONE\n");
17056 printf("Desc status = UNAVAILABLE\n");
17060 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17061 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17063 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17064 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17066 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17067 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17069 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17070 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17071 cmd_keyword, "rxq#txq");
17072 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17073 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17075 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17076 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17078 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17079 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17081 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17082 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17083 cmd_status, "status");
17084 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17085 .f = cmd_show_rx_tx_desc_status_parsed,
17087 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17090 (void *)&cmd_show_rx_tx_desc_status_show,
17091 (void *)&cmd_show_rx_tx_desc_status_port,
17092 (void *)&cmd_show_rx_tx_desc_status_pid,
17093 (void *)&cmd_show_rx_tx_desc_status_keyword,
17094 (void *)&cmd_show_rx_tx_desc_status_qid,
17095 (void *)&cmd_show_rx_tx_desc_status_desc,
17096 (void *)&cmd_show_rx_tx_desc_status_did,
17097 (void *)&cmd_show_rx_tx_desc_status_status,
17102 /* Common result structure for set port ptypes */
17103 struct cmd_set_port_ptypes_result {
17104 cmdline_fixed_string_t set;
17105 cmdline_fixed_string_t port;
17107 cmdline_fixed_string_t ptype_mask;
17111 /* Common CLI fields for set port ptypes */
17112 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17113 TOKEN_STRING_INITIALIZER
17114 (struct cmd_set_port_ptypes_result,
17116 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17117 TOKEN_STRING_INITIALIZER
17118 (struct cmd_set_port_ptypes_result,
17120 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17121 TOKEN_NUM_INITIALIZER
17122 (struct cmd_set_port_ptypes_result,
17124 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17125 TOKEN_STRING_INITIALIZER
17126 (struct cmd_set_port_ptypes_result,
17127 ptype_mask, "ptype_mask");
17128 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17129 TOKEN_NUM_INITIALIZER
17130 (struct cmd_set_port_ptypes_result,
17134 cmd_set_port_ptypes_parsed(
17135 void *parsed_result,
17136 __rte_unused struct cmdline *cl,
17137 __rte_unused void *data)
17139 struct cmd_set_port_ptypes_result *res = parsed_result;
17140 #define PTYPE_NAMESIZE 256
17141 char ptype_name[PTYPE_NAMESIZE];
17142 uint16_t port_id = res->port_id;
17143 uint32_t ptype_mask = res->mask;
17146 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17149 printf("Port %d doesn't support any ptypes.\n", port_id);
17153 uint32_t ptypes[ret];
17155 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17157 printf("Unable to set requested ptypes for Port %d\n", port_id);
17161 printf("Successfully set following ptypes for Port %d\n", port_id);
17162 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17163 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17164 printf("%s\n", ptype_name);
17167 clear_ptypes = false;
17170 cmdline_parse_inst_t cmd_set_port_ptypes = {
17171 .f = cmd_set_port_ptypes_parsed,
17173 .help_str = "set port <port_id> ptype_mask <mask>",
17175 (void *)&cmd_set_port_ptypes_set,
17176 (void *)&cmd_set_port_ptypes_port,
17177 (void *)&cmd_set_port_ptypes_port_id,
17178 (void *)&cmd_set_port_ptypes_mask_str,
17179 (void *)&cmd_set_port_ptypes_mask_u32,
17184 /* *** display mac addresses added to a port *** */
17185 struct cmd_showport_macs_result {
17186 cmdline_fixed_string_t cmd_show;
17187 cmdline_fixed_string_t cmd_port;
17188 cmdline_fixed_string_t cmd_keyword;
17193 cmd_showport_macs_parsed(void *parsed_result,
17194 __rte_unused struct cmdline *cl,
17195 __rte_unused void *data)
17197 struct cmd_showport_macs_result *res = parsed_result;
17199 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17202 if (!strcmp(res->cmd_keyword, "macs"))
17203 show_macs(res->cmd_pid);
17204 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17205 show_mcast_macs(res->cmd_pid);
17208 cmdline_parse_token_string_t cmd_showport_macs_show =
17209 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17211 cmdline_parse_token_string_t cmd_showport_macs_port =
17212 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17214 cmdline_parse_token_num_t cmd_showport_macs_pid =
17215 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17217 cmdline_parse_token_string_t cmd_showport_macs_keyword =
17218 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17219 cmd_keyword, "macs#mcast_macs");
17221 cmdline_parse_inst_t cmd_showport_macs = {
17222 .f = cmd_showport_macs_parsed,
17224 .help_str = "show port <port_id> macs|mcast_macs",
17226 (void *)&cmd_showport_macs_show,
17227 (void *)&cmd_showport_macs_port,
17228 (void *)&cmd_showport_macs_pid,
17229 (void *)&cmd_showport_macs_keyword,
17234 /* ******************************************************************************** */
17236 /* list of instructions */
17237 cmdline_parse_ctx_t main_ctx[] = {
17238 (cmdline_parse_inst_t *)&cmd_help_brief,
17239 (cmdline_parse_inst_t *)&cmd_help_long,
17240 (cmdline_parse_inst_t *)&cmd_quit,
17241 (cmdline_parse_inst_t *)&cmd_load_from_file,
17242 (cmdline_parse_inst_t *)&cmd_showport,
17243 (cmdline_parse_inst_t *)&cmd_showqueue,
17244 (cmdline_parse_inst_t *)&cmd_showeeprom,
17245 (cmdline_parse_inst_t *)&cmd_showportall,
17246 (cmdline_parse_inst_t *)&cmd_showdevice,
17247 (cmdline_parse_inst_t *)&cmd_showcfg,
17248 (cmdline_parse_inst_t *)&cmd_showfwdall,
17249 (cmdline_parse_inst_t *)&cmd_start,
17250 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17251 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17252 (cmdline_parse_inst_t *)&cmd_set_link_up,
17253 (cmdline_parse_inst_t *)&cmd_set_link_down,
17254 (cmdline_parse_inst_t *)&cmd_reset,
17255 (cmdline_parse_inst_t *)&cmd_set_numbers,
17256 (cmdline_parse_inst_t *)&cmd_set_log,
17257 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
17258 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
17259 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17260 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17261 (cmdline_parse_inst_t *)&cmd_set_txtimes,
17262 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17263 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17264 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17265 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17266 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17267 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17268 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17269 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17270 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17271 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17272 (cmdline_parse_inst_t *)&cmd_set_link_check,
17273 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17274 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17275 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17276 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17277 #ifdef RTE_NET_BOND
17278 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17279 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17280 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17281 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17282 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17283 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17284 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17285 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17286 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17287 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17288 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17290 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17291 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17292 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17293 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17294 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17295 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17296 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17297 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17298 (cmdline_parse_inst_t *)&cmd_csum_set,
17299 (cmdline_parse_inst_t *)&cmd_csum_show,
17300 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17301 (cmdline_parse_inst_t *)&cmd_tso_set,
17302 (cmdline_parse_inst_t *)&cmd_tso_show,
17303 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17304 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17305 (cmdline_parse_inst_t *)&cmd_gro_enable,
17306 (cmdline_parse_inst_t *)&cmd_gro_flush,
17307 (cmdline_parse_inst_t *)&cmd_gro_show,
17308 (cmdline_parse_inst_t *)&cmd_gso_enable,
17309 (cmdline_parse_inst_t *)&cmd_gso_size,
17310 (cmdline_parse_inst_t *)&cmd_gso_show,
17311 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17312 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17313 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17314 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17315 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17316 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17317 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17318 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17319 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17320 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17321 (cmdline_parse_inst_t *)&cmd_config_dcb,
17322 (cmdline_parse_inst_t *)&cmd_read_reg,
17323 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17324 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17325 (cmdline_parse_inst_t *)&cmd_write_reg,
17326 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17327 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17328 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17329 (cmdline_parse_inst_t *)&cmd_stop,
17330 (cmdline_parse_inst_t *)&cmd_mac_addr,
17331 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17332 (cmdline_parse_inst_t *)&cmd_set_qmap,
17333 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17334 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17335 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17336 (cmdline_parse_inst_t *)&cmd_operate_port,
17337 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17338 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17339 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17340 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
17341 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17342 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17343 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17344 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17345 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17346 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17347 (cmdline_parse_inst_t *)&cmd_config_mtu,
17348 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17349 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17350 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17351 (cmdline_parse_inst_t *)&cmd_config_rss,
17352 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17353 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17354 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17355 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17356 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17357 (cmdline_parse_inst_t *)&cmd_showport_reta,
17358 (cmdline_parse_inst_t *)&cmd_showport_macs,
17359 (cmdline_parse_inst_t *)&cmd_config_burst,
17360 (cmdline_parse_inst_t *)&cmd_config_thresh,
17361 (cmdline_parse_inst_t *)&cmd_config_threshold,
17362 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17363 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17364 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17365 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17366 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17367 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
17368 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
17369 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
17370 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17371 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17372 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17373 (cmdline_parse_inst_t *)&cmd_dump,
17374 (cmdline_parse_inst_t *)&cmd_dump_one,
17375 #ifdef RTE_NET_I40E
17376 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17378 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17379 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17380 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17381 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17382 (cmdline_parse_inst_t *)&cmd_flow,
17383 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17384 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17385 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17386 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17387 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17388 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17389 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17390 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17391 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17392 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17393 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
17394 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17395 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17396 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17397 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
17398 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
17399 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
17400 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
17401 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
17402 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
17403 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17404 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17405 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17406 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17407 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17408 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17409 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17410 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17411 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17412 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17413 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17414 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17415 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17416 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17417 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17418 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17419 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17420 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17421 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17422 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17423 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17424 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17425 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17426 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
17427 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
17428 (cmdline_parse_inst_t *)&cmd_set_vxlan,
17429 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
17430 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17431 (cmdline_parse_inst_t *)&cmd_set_nvgre,
17432 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17433 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
17434 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
17435 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
17436 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
17437 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
17438 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
17439 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
17440 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
17441 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
17442 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
17443 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
17444 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
17445 (cmdline_parse_inst_t *)&cmd_ddp_add,
17446 (cmdline_parse_inst_t *)&cmd_ddp_del,
17447 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
17448 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
17449 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
17450 (cmdline_parse_inst_t *)&cmd_clear_input_set,
17451 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
17452 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17453 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
17454 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
17455 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17456 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17457 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17458 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17460 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17461 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17462 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17463 (cmdline_parse_inst_t *)&cmd_queue_region,
17464 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17465 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17466 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17467 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17468 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17469 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17470 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17471 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17472 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17473 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17474 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17475 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17476 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17477 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17478 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17479 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17480 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17481 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
17482 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17483 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17484 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17485 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17486 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17487 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17488 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
17489 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
17490 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
17491 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17492 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17493 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17494 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17495 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17496 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17497 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17498 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17499 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17501 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17502 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17504 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
17505 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
17506 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
17507 (cmdline_parse_inst_t *)&cmd_set_raw,
17508 (cmdline_parse_inst_t *)&cmd_show_set_raw,
17509 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
17510 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
17511 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
17512 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
17513 (cmdline_parse_inst_t *)&cmd_show_capability,
17517 /* read cmdline commands from file */
17519 cmdline_read_from_file(const char *filename)
17521 struct cmdline *cl;
17523 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17525 printf("Failed to create file based cmdline context: %s\n",
17530 cmdline_interact(cl);
17535 printf("Read CLI commands from %s\n", filename);
17538 /* prompt function, called from main on MAIN lcore */
17542 /* initialize non-constant commands */
17543 cmd_set_fwd_mode_init();
17544 cmd_set_fwd_retry_mode_init();
17546 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17547 if (testpmd_cl == NULL)
17549 cmdline_interact(testpmd_cl);
17550 cmdline_stdin_exit(testpmd_cl);
17556 if (testpmd_cl != NULL)
17557 cmdline_quit(testpmd_cl);
17561 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17563 if (id == (portid_t)RTE_PORT_ALL) {
17566 RTE_ETH_FOREACH_DEV(pid) {
17567 /* check if need_reconfig has been set to 1 */
17568 if (ports[pid].need_reconfig == 0)
17569 ports[pid].need_reconfig = dev;
17570 /* check if need_reconfig_queues has been set to 1 */
17571 if (ports[pid].need_reconfig_queues == 0)
17572 ports[pid].need_reconfig_queues = queue;
17574 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17575 /* check if need_reconfig has been set to 1 */
17576 if (ports[id].need_reconfig == 0)
17577 ports[id].need_reconfig = dev;
17578 /* check if need_reconfig_queues has been set to 1 */
17579 if (ports[id].need_reconfig_queues == 0)
17580 ports[id].need_reconfig_queues = queue;