1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
14 #include <sys/socket.h>
15 #include <netinet/in.h>
17 #include <sys/queue.h>
19 #include <rte_common.h>
20 #include <rte_byteorder.h>
22 #include <rte_debug.h>
23 #include <rte_cycles.h>
24 #include <rte_memory.h>
25 #include <rte_memzone.h>
26 #include <rte_malloc.h>
27 #include <rte_launch.h>
29 #include <rte_per_lcore.h>
30 #include <rte_lcore.h>
31 #include <rte_atomic.h>
32 #include <rte_branch_prediction.h>
34 #include <rte_mempool.h>
35 #include <rte_interrupts.h>
37 #include <rte_ether.h>
38 #include <rte_ethdev.h>
39 #include <rte_string_fns.h>
40 #include <rte_devargs.h>
43 #include <rte_mbuf_dyn.h>
45 #include <cmdline_rdline.h>
46 #include <cmdline_parse.h>
47 #include <cmdline_parse_num.h>
48 #include <cmdline_parse_string.h>
49 #include <cmdline_parse_ipaddr.h>
50 #include <cmdline_parse_etheraddr.h>
51 #include <cmdline_socket.h>
54 #include <rte_eth_bond.h>
55 #include <rte_eth_bond_8023ad.h>
57 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
58 #include <rte_pmd_dpaa.h>
61 #include <rte_pmd_ixgbe.h>
64 #include <rte_pmd_i40e.h>
67 #include <rte_pmd_bnxt.h>
70 #include "cmdline_mtr.h"
71 #include "cmdline_tm.h"
74 static struct cmdline *testpmd_cl;
76 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
78 /* *** Help command with introduction. *** */
79 struct cmd_help_brief_result {
80 cmdline_fixed_string_t help;
83 static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
85 __rte_unused void *data)
90 "Help is available for the following sections:\n\n"
91 " help control : Start and stop forwarding.\n"
92 " help display : Displaying port, stats and config "
94 " help config : Configuration information.\n"
95 " help ports : Configuring ports.\n"
96 " help registers : Reading and setting port registers.\n"
97 " help filters : Filters configuration help.\n"
98 " help traffic_management : Traffic Management commands.\n"
99 " help devices : Device related cmds.\n"
100 " help all : All of the above sections.\n\n"
105 cmdline_parse_token_string_t cmd_help_brief_help =
106 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
108 cmdline_parse_inst_t cmd_help_brief = {
109 .f = cmd_help_brief_parsed,
111 .help_str = "help: Show help",
113 (void *)&cmd_help_brief_help,
118 /* *** Help command with help sections. *** */
119 struct cmd_help_long_result {
120 cmdline_fixed_string_t help;
121 cmdline_fixed_string_t section;
124 static void cmd_help_long_parsed(void *parsed_result,
126 __rte_unused void *data)
129 struct cmd_help_long_result *res = parsed_result;
131 if (!strcmp(res->section, "all"))
134 if (show_all || !strcmp(res->section, "control")) {
139 "Control forwarding:\n"
140 "-------------------\n\n"
143 " Start packet forwarding with current configuration.\n\n"
146 " Start packet forwarding with current config"
147 " after sending one burst of packets.\n\n"
150 " Stop packet forwarding, and display accumulated"
154 " Quit to prompt.\n\n"
158 if (show_all || !strcmp(res->section, "display")) {
166 "show port (info|stats|summary|xstats|fdir|dcb_tc|cap) (port_id|all)\n"
167 " Display information for port_id, or all.\n\n"
169 "show port port_id (module_eeprom|eeprom)\n"
170 " Display the module EEPROM or EEPROM information for port_id.\n\n"
172 "show port X rss reta (size) (mask0,mask1,...)\n"
173 " Display the rss redirection table entry indicated"
174 " by masks on port X. size is used to indicate the"
175 " hardware supported reta size\n\n"
177 "show port (port_id) rss-hash [key]\n"
178 " Display the RSS hash functions and RSS hash key of port\n\n"
180 "clear port (info|stats|xstats|fdir) (port_id|all)\n"
181 " Clear information for port_id, or all.\n\n"
183 "show (rxq|txq) info (port_id) (queue_id)\n"
184 " Display information for configured RX/TX queue.\n\n"
186 "show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n"
187 " Display the given configuration.\n\n"
189 "read rxd (port_id) (queue_id) (rxd_id)\n"
190 " Display an RX descriptor of a port RX queue.\n\n"
192 "read txd (port_id) (queue_id) (txd_id)\n"
193 " Display a TX descriptor of a port TX queue.\n\n"
195 "ddp get list (port_id)\n"
196 " Get ddp profile info list\n\n"
198 "ddp get info (profile_path)\n"
199 " Get ddp profile information.\n\n"
201 "show vf stats (port_id) (vf_id)\n"
202 " Display a VF's statistics.\n\n"
204 "clear vf stats (port_id) (vf_id)\n"
205 " Reset a VF's statistics.\n\n"
207 "show port (port_id) pctype mapping\n"
208 " Get flow ptype to pctype mapping on a port\n\n"
210 "show port meter stats (port_id) (meter_id) (clear)\n"
211 " Get meter stats on a port\n\n"
213 "show fwd stats all\n"
214 " Display statistics for all fwd engines.\n\n"
216 "clear fwd stats all\n"
217 " Clear statistics for all fwd engines.\n\n"
219 "show port (port_id) rx_offload capabilities\n"
220 " List all per queue and per port Rx offloading"
221 " capabilities of a port\n\n"
223 "show port (port_id) rx_offload configuration\n"
224 " List port level and all queue level"
225 " Rx offloading configuration\n\n"
227 "show port (port_id) tx_offload capabilities\n"
228 " List all per queue and per port"
229 " Tx offloading capabilities of a port\n\n"
231 "show port (port_id) tx_offload configuration\n"
232 " List port level and all queue level"
233 " Tx offloading configuration\n\n"
235 "show port (port_id) tx_metadata\n"
236 " Show Tx metadata value set"
237 " for a specific port\n\n"
239 "show port (port_id) ptypes\n"
240 " Show port supported ptypes"
241 " for a specific port\n\n"
243 "show device info (<identifier>|all)"
244 " Show general information about devices probed.\n\n"
246 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
247 " Show status of rx|tx descriptor.\n\n"
249 "show port (port_id) macs|mcast_macs"
250 " Display list of mac addresses added to port.\n\n"
252 "show port (port_id) fec capabilities"
253 " Show fec capabilities of a port.\n\n"
255 "show port (port_id) fec_mode"
256 " Show fec mode of a port.\n\n"
260 if (show_all || !strcmp(res->section, "config")) {
266 "Configuration changes only become active when"
267 " forwarding is started/restarted.\n\n"
270 " Reset forwarding to the default configuration.\n\n"
272 "set verbose (level)\n"
273 " Set the debug verbosity level X.\n\n"
275 "set log global|(type) (level)\n"
276 " Set the log level.\n\n"
279 " Set number of ports.\n\n"
282 " Set number of cores.\n\n"
284 "set coremask (mask)\n"
285 " Set the forwarding cores hexadecimal mask.\n\n"
287 "set portmask (mask)\n"
288 " Set the forwarding ports hexadecimal mask.\n\n"
291 " Set number of packets per burst.\n\n"
293 "set burst tx delay (microseconds) retry (num)\n"
294 " Set the transmit delay time and number of retries,"
295 " effective when retry is enabled.\n\n"
297 "set rxoffs (x[,y]*)\n"
298 " Set the offset of each packet segment on"
299 " receiving if split feature is engaged."
300 " Affects only the queues configured with split"
303 "set rxpkts (x[,y]*)\n"
304 " Set the length of each segment to scatter"
305 " packets on receiving if split feature is engaged."
306 " Affects only the queues configured with split"
309 "set txpkts (x[,y]*)\n"
310 " Set the length of each segment of TXONLY"
311 " and optionally CSUM packets.\n\n"
313 "set txsplit (off|on|rand)\n"
314 " Set the split policy for the TX packets."
315 " Right now only applicable for CSUM and TXONLY"
318 "set txtimes (x, y)\n"
319 " Set the scheduling on timestamps"
320 " timings for the TXONLY mode\n\n"
322 "set corelist (x[,y]*)\n"
323 " Set the list of forwarding cores.\n\n"
325 "set portlist (x[,y]*)\n"
326 " Set the list of forwarding ports.\n\n"
328 "set port setup on (iterator|event)\n"
329 " Select how attached port is retrieved for setup.\n\n"
331 "set tx loopback (port_id) (on|off)\n"
332 " Enable or disable tx loopback.\n\n"
334 "set all queues drop (port_id) (on|off)\n"
335 " Set drop enable bit for all queues.\n\n"
337 "set vf split drop (port_id) (vf_id) (on|off)\n"
338 " Set split drop enable bit for a VF from the PF.\n\n"
340 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
341 " Set MAC antispoof for a VF from the PF.\n\n"
343 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
344 " Enable MACsec offload.\n\n"
346 "set macsec offload (port_id) off\n"
347 " Disable MACsec offload.\n\n"
349 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
350 " Configure MACsec secure connection (SC).\n\n"
352 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
353 " Configure MACsec secure association (SA).\n\n"
355 "set vf broadcast (port_id) (vf_id) (on|off)\n"
356 " Set VF broadcast for a VF from the PF.\n\n"
358 "vlan set stripq (on|off) (port_id,queue_id)\n"
359 " Set the VLAN strip for a queue on a port.\n\n"
361 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
362 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
364 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
365 " Set VLAN insert for a VF from the PF.\n\n"
367 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
368 " Set VLAN antispoof for a VF from the PF.\n\n"
370 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
371 " Set VLAN tag for a VF from the PF.\n\n"
373 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
374 " Set a VF's max bandwidth(Mbps).\n\n"
376 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
377 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
379 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
380 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
382 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
383 " Set some TCs' strict link priority mode on a physical port.\n\n"
385 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
386 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
388 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
389 " Set the VLAN strip or filter or qinq strip or extend\n\n"
391 "vlan set (inner|outer) tpid (value) (port_id)\n"
392 " Set the VLAN TPID for Packet Filtering on"
395 "rx_vlan add (vlan_id|all) (port_id)\n"
396 " Add a vlan_id, or all identifiers, to the set"
397 " of VLAN identifiers filtered by port_id.\n\n"
399 "rx_vlan rm (vlan_id|all) (port_id)\n"
400 " Remove a vlan_id, or all identifiers, from the set"
401 " of VLAN identifiers filtered by port_id.\n\n"
403 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
404 " Add a vlan_id, to the set of VLAN identifiers"
405 "filtered for VF(s) from port_id.\n\n"
407 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
408 " Remove a vlan_id, to the set of VLAN identifiers"
409 "filtered for VF(s) from port_id.\n\n"
411 "rx_vxlan_port add (udp_port) (port_id)\n"
412 " Add an UDP port for VXLAN packet filter on a port\n\n"
414 "rx_vxlan_port rm (udp_port) (port_id)\n"
415 " Remove an UDP port for VXLAN packet filter on a port\n\n"
417 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
418 " Set hardware insertion of VLAN IDs (single or double VLAN "
419 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
421 "tx_vlan set pvid port_id vlan_id (on|off)\n"
422 " Set port based TX VLAN insertion.\n\n"
424 "tx_vlan reset (port_id)\n"
425 " Disable hardware insertion of a VLAN header in"
426 " packets sent on a port.\n\n"
428 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
429 " Select hardware or software calculation of the"
430 " checksum when transmitting a packet using the"
431 " csum forward engine.\n"
432 " ip|udp|tcp|sctp always concern the inner layer.\n"
433 " outer-ip concerns the outer IP layer in"
434 " outer-udp concerns the outer UDP layer in"
435 " case the packet is recognized as a tunnel packet by"
436 " the forward engine (vxlan, gre and ipip are supported)\n"
437 " Please check the NIC datasheet for HW limits.\n\n"
439 "csum parse-tunnel (on|off) (tx_port_id)\n"
440 " If disabled, treat tunnel packets as non-tunneled"
441 " packets (treat inner headers as payload). The port\n"
442 " argument is the port used for TX in csum forward"
445 "csum show (port_id)\n"
446 " Display tx checksum offload configuration\n\n"
448 "tso set (segsize) (portid)\n"
449 " Enable TCP Segmentation Offload in csum forward"
451 " Please check the NIC datasheet for HW limits.\n\n"
454 " Display the status of TCP Segmentation Offload.\n\n"
456 "set port (port_id) gro on|off\n"
457 " Enable or disable Generic Receive Offload in"
458 " csum forwarding engine.\n\n"
460 "show port (port_id) gro\n"
461 " Display GRO configuration.\n\n"
463 "set gro flush (cycles)\n"
464 " Set the cycle to flush GROed packets from"
465 " reassembly tables.\n\n"
467 "set port (port_id) gso (on|off)"
468 " Enable or disable Generic Segmentation Offload in"
469 " csum forwarding engine.\n\n"
471 "set gso segsz (length)\n"
472 " Set max packet length for output GSO segments,"
473 " including packet header and payload.\n\n"
475 "show port (port_id) gso\n"
476 " Show GSO configuration.\n\n"
479 " Set packet forwarding mode.\n\n"
481 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
482 " Add a MAC address on port_id.\n\n"
484 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
485 " Remove a MAC address from port_id.\n\n"
487 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
488 " Set the default MAC address for port_id.\n\n"
490 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
491 " Add a MAC address for a VF on the port.\n\n"
493 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
494 " Set the MAC address for a VF from the PF.\n\n"
496 "set eth-peer (port_id) (peer_addr)\n"
497 " set the peer address for certain port.\n\n"
499 "set port (port_id) uta (mac_address|all) (on|off)\n"
500 " Add/Remove a or all unicast hash filter(s)"
503 "set promisc (port_id|all) (on|off)\n"
504 " Set the promiscuous mode on port_id, or all.\n\n"
506 "set allmulti (port_id|all) (on|off)\n"
507 " Set the allmulti mode on port_id, or all.\n\n"
509 "set vf promisc (port_id) (vf_id) (on|off)\n"
510 " Set unicast promiscuous mode for a VF from the PF.\n\n"
512 "set vf allmulti (port_id) (vf_id) (on|off)\n"
513 " Set multicast promiscuous mode for a VF from the PF.\n\n"
515 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
516 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
517 " (on|off) autoneg (on|off) (port_id)\n"
518 "set flow_ctrl rx (on|off) (portid)\n"
519 "set flow_ctrl tx (on|off) (portid)\n"
520 "set flow_ctrl high_water (high_water) (portid)\n"
521 "set flow_ctrl low_water (low_water) (portid)\n"
522 "set flow_ctrl pause_time (pause_time) (portid)\n"
523 "set flow_ctrl send_xon (send_xon) (portid)\n"
524 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
525 "set flow_ctrl autoneg (on|off) (port_id)\n"
526 " Set the link flow control parameter on a port.\n\n"
528 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
529 " (low_water) (pause_time) (priority) (port_id)\n"
530 " Set the priority flow control parameter on a"
533 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
534 " Set statistics mapping (qmapping 0..15) for RX/TX"
536 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
537 " on port 0 to mapping 5.\n\n"
539 "set xstats-hide-zero on|off\n"
540 " Set the option to hide the zero values"
541 " for xstats display.\n"
543 "set record-core-cycles on|off\n"
544 " Set the option to enable measurement of CPU cycles.\n"
546 "set record-burst-stats on|off\n"
547 " Set the option to enable display of RX and TX bursts.\n"
549 "set port (port_id) vf (vf_id) rx|tx on|off\n"
550 " Enable/Disable a VF receive/tranmit from a port\n\n"
552 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
554 " AUPE:accepts untagged VLAN;"
555 "ROPE:accept unicast hash\n\n"
556 " BAM:accepts broadcast packets;"
557 "MPE:accepts all multicast packets\n\n"
558 " Enable/Disable a VF receive mode of a port\n\n"
560 "set port (port_id) queue (queue_id) rate (rate_num)\n"
561 " Set rate limit for a queue of a port\n\n"
563 "set port (port_id) vf (vf_id) rate (rate_num) "
564 "queue_mask (queue_mask_value)\n"
565 " Set rate limit for queues in VF of a port\n\n"
567 "set port (port_id) mirror-rule (rule_id)"
568 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
569 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
570 " Set pool or vlan type mirror rule on a port.\n"
571 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
572 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
575 "set port (port_id) mirror-rule (rule_id)"
576 " (uplink-mirror|downlink-mirror) dst-pool"
577 " (pool_id) (on|off)\n"
578 " Set uplink or downlink type mirror rule on a port.\n"
579 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
580 " 0 on' enable mirror income traffic to pool 0.\n\n"
582 "reset port (port_id) mirror-rule (rule_id)\n"
583 " Reset a mirror rule.\n\n"
585 "set flush_rx (on|off)\n"
586 " Flush (default) or don't flush RX streams before"
587 " forwarding. Mainly used with PCAP drivers.\n\n"
589 "set bypass mode (normal|bypass|isolate) (port_id)\n"
590 " Set the bypass mode for the lowest port on bypass enabled"
593 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
594 "mode (normal|bypass|isolate) (port_id)\n"
595 " Set the event required to initiate specified bypass mode for"
596 " the lowest port on a bypass enabled NIC where:\n"
597 " timeout = enable bypass after watchdog timeout.\n"
598 " os_on = enable bypass when OS/board is powered on.\n"
599 " os_off = enable bypass when OS/board is powered off.\n"
600 " power_on = enable bypass when power supply is turned on.\n"
601 " power_off = enable bypass when power supply is turned off."
604 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
605 " Set the bypass watchdog timeout to 'n' seconds"
606 " where 0 = instant.\n\n"
608 "show bypass config (port_id)\n"
609 " Show the bypass configuration for a bypass enabled NIC"
610 " using the lowest port on the NIC.\n\n"
613 "create bonded device (mode) (socket)\n"
614 " Create a new bonded device with specific bonding mode and socket.\n\n"
616 "add bonding slave (slave_id) (port_id)\n"
617 " Add a slave device to a bonded device.\n\n"
619 "remove bonding slave (slave_id) (port_id)\n"
620 " Remove a slave device from a bonded device.\n\n"
622 "set bonding mode (value) (port_id)\n"
623 " Set the bonding mode on a bonded device.\n\n"
625 "set bonding primary (slave_id) (port_id)\n"
626 " Set the primary slave for a bonded device.\n\n"
628 "show bonding config (port_id)\n"
629 " Show the bonding config for port_id.\n\n"
631 "set bonding mac_addr (port_id) (address)\n"
632 " Set the MAC address of a bonded device.\n\n"
634 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
635 " Set Aggregation mode for IEEE802.3AD (mode 4)"
637 "set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
638 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
640 "set bonding mon_period (port_id) (value)\n"
641 " Set the bonding link status monitoring polling period in ms.\n\n"
643 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
644 " Enable/disable dedicated queues for LACP control traffic.\n\n"
647 "set link-up port (port_id)\n"
648 " Set link up for a port.\n\n"
650 "set link-down port (port_id)\n"
651 " Set link down for a port.\n\n"
653 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
654 " Load a profile package on a port\n\n"
656 "ddp del (port_id) (backup_profile_path)\n"
657 " Delete a profile package from a port\n\n"
659 "ptype mapping get (port_id) (valid_only)\n"
660 " Get ptype mapping on a port\n\n"
662 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
663 " Replace target with the pkt_type in ptype mapping\n\n"
665 "ptype mapping reset (port_id)\n"
666 " Reset ptype mapping on a port\n\n"
668 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
669 " Update a ptype mapping item on a port\n\n"
671 "set port (port_id) ptype_mask (ptype_mask)\n"
672 " set packet types classification for a specific port\n\n"
674 "set port (port_id) queue-region region_id (value) "
675 "queue_start_index (value) queue_num (value)\n"
676 " Set a queue region on a port\n\n"
678 "set port (port_id) queue-region region_id (value) "
680 " Set a flowtype region index on a port\n\n"
682 "set port (port_id) queue-region UP (value) region_id (value)\n"
683 " Set the mapping of User Priority to "
684 "queue region on a port\n\n"
686 "set port (port_id) queue-region flush (on|off)\n"
687 " flush all queue region related configuration\n\n"
689 "show port meter cap (port_id)\n"
690 " Show port meter capability information\n\n"
692 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
693 " meter profile add - srtcm rfc 2697\n\n"
695 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
696 " meter profile add - trtcm rfc 2698\n\n"
698 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
699 " meter profile add - trtcm rfc 4115\n\n"
701 "del port meter profile (port_id) (profile_id)\n"
702 " meter profile delete\n\n"
704 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
705 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
706 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
707 "(dscp_tbl_entry63)]\n"
710 "enable port meter (port_id) (mtr_id)\n"
713 "disable port meter (port_id) (mtr_id)\n"
716 "del port meter (port_id) (mtr_id)\n"
719 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
720 " meter update meter profile\n\n"
722 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
723 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
724 " update meter dscp table entries\n\n"
726 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
727 "(action0) [(action1) (action2)]\n"
728 " meter update policer action\n\n"
730 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
731 " meter update stats\n\n"
733 "show port (port_id) queue-region\n"
734 " show all queue region related configuration info\n\n"
736 "set port (port_id) fec_mode auto|off|rs|baser\n"
737 " set fec mode for a specific port\n\n"
739 , list_pkt_forwarding_modes()
743 if (show_all || !strcmp(res->section, "ports")) {
749 "----------------\n\n"
751 "port start (port_id|all)\n"
752 " Start all ports or port_id.\n\n"
754 "port stop (port_id|all)\n"
755 " Stop all ports or port_id.\n\n"
757 "port close (port_id|all)\n"
758 " Close all ports or port_id.\n\n"
760 "port reset (port_id|all)\n"
761 " Reset all ports or port_id.\n\n"
763 "port attach (ident)\n"
764 " Attach physical or virtual dev by pci address or virtual device name\n\n"
766 "port detach (port_id)\n"
767 " Detach physical or virtual dev by port_id\n\n"
769 "port config (port_id|all)"
770 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
771 " duplex (half|full|auto)\n"
772 " Set speed and duplex for all ports or port_id\n\n"
774 "port config (port_id|all) loopback (mode)\n"
775 " Set loopback mode for all ports or port_id\n\n"
777 "port config all (rxq|txq|rxd|txd) (value)\n"
778 " Set number for rxq/txq/rxd/txd.\n\n"
780 "port config all max-pkt-len (value)\n"
781 " Set the max packet length.\n\n"
783 "port config all max-lro-pkt-size (value)\n"
784 " Set the max LRO aggregated packet size.\n\n"
786 "port config all drop-en (on|off)\n"
787 " Enable or disable packet drop on all RX queues of all ports when no "
788 "receive buffers available.\n\n"
790 "port config all rss (all|default|ip|tcp|udp|sctp|"
791 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|none|level-default|"
792 "level-outer|level-inner|<flowtype_id>)\n"
793 " Set the RSS mode.\n\n"
795 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
796 " Set the RSS redirection table.\n\n"
798 "port config (port_id) dcb vt (on|off) (traffic_class)"
800 " Set the DCB mode.\n\n"
802 "port config all burst (value)\n"
803 " Set the number of packets per burst.\n\n"
805 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
807 " Set the ring prefetch/host/writeback threshold"
808 " for tx/rx queue.\n\n"
810 "port config all (txfreet|txrst|rxfreet) (value)\n"
811 " Set free threshold for rx/tx, or set"
812 " tx rs bit threshold.\n\n"
813 "port config mtu X value\n"
814 " Set the MTU of port X to a given value\n\n"
816 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
817 " Set a rx/tx queue's ring size configuration, the new"
818 " value will take effect after command that (re-)start the port"
819 " or command that setup the specific queue\n\n"
821 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
822 " Start/stop a rx/tx queue of port X. Only take effect"
823 " when port X is started\n\n"
825 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
826 " Switch on/off a deferred start of port X rx/tx queue. Only"
827 " take effect when port X is stopped.\n\n"
829 "port (port_id) (rxq|txq) (queue_id) setup\n"
830 " Setup a rx/tx queue of port X.\n\n"
832 "port config (port_id) pctype mapping reset\n"
833 " Reset flow type to pctype mapping on a port\n\n"
835 "port config (port_id) pctype mapping update"
836 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
837 " Update a flow type to pctype mapping item on a port\n\n"
839 "port config (port_id) pctype (pctype_id) hash_inset|"
840 "fdir_inset|fdir_flx_inset get|set|clear field\n"
842 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
844 "port config (port_id) pctype (pctype_id) hash_inset|"
845 "fdir_inset|fdir_flx_inset clear all"
846 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
848 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
849 " Add/remove UDP tunnel port for tunneling offload\n\n"
851 "port config <port_id> rx_offload vlan_strip|"
852 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
853 "outer_ipv4_cksum|macsec_strip|header_split|"
854 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
855 "buffer_split|timestamp|security|keep_crc on|off\n"
856 " Enable or disable a per port Rx offloading"
857 " on all Rx queues of a port\n\n"
859 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
860 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
861 "outer_ipv4_cksum|macsec_strip|header_split|"
862 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
863 "buffer_split|timestamp|security|keep_crc on|off\n"
864 " Enable or disable a per queue Rx offloading"
865 " only on a specific Rx queue\n\n"
867 "port config (port_id) tx_offload vlan_insert|"
868 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
869 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
870 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
871 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
873 " Enable or disable a per port Tx offloading"
874 " on all Tx queues of a port\n\n"
876 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
877 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
878 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
879 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
880 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
882 " Enable or disable a per queue Tx offloading"
883 " only on a specific Tx queue\n\n"
885 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
886 " Load an eBPF program as a callback"
887 " for particular RX/TX queue\n\n"
889 "bpf-unload rx|tx (port) (queue)\n"
890 " Unload previously loaded eBPF program"
891 " for particular RX/TX queue\n\n"
893 "port config (port_id) tx_metadata (value)\n"
894 " Set Tx metadata value per port. Testpmd will add this value"
895 " to any Tx packet sent from this port\n\n"
897 "port config (port_id) dynf (name) set|clear\n"
898 " Register a dynf and Set/clear this flag on Tx. "
899 "Testpmd will set this value to any Tx packet "
900 "sent from this port\n\n"
904 if (show_all || !strcmp(res->section, "registers")) {
912 "read reg (port_id) (address)\n"
913 " Display value of a port register.\n\n"
915 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
916 " Display a port register bit field.\n\n"
918 "read regbit (port_id) (address) (bit_x)\n"
919 " Display a single port register bit.\n\n"
921 "write reg (port_id) (address) (value)\n"
922 " Set value of a port register.\n\n"
924 "write regfield (port_id) (address) (bit_x) (bit_y)"
926 " Set bit field of a port register.\n\n"
928 "write regbit (port_id) (address) (bit_x) (value)\n"
929 " Set single bit value of a port register.\n\n"
932 if (show_all || !strcmp(res->section, "filters")) {
941 "flow_director_filter (port_id) mode raw (add|del|update)"
942 " flow (flow_id) (drop|fwd) queue (queue_id)"
943 " fd_id (fd_id_value) packet (packet file name)\n"
944 " Add/Del a raw type flow director filter.\n\n"
947 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
948 " src_mask (ipv4_src) (ipv6_src) (src_port)"
949 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
950 " Set flow director IP mask.\n\n"
952 "flow_director_mask (port_id) mode MAC-VLAN"
953 " vlan (vlan_value)\n"
954 " Set flow director MAC-VLAN mask.\n\n"
956 "flow_director_mask (port_id) mode Tunnel"
957 " vlan (vlan_value) mac (mac_value)"
958 " tunnel-type (tunnel_type_value)"
959 " tunnel-id (tunnel_id_value)\n"
960 " Set flow director Tunnel mask.\n\n"
962 "flow_director_flex_payload (port_id)"
963 " (raw|l2|l3|l4) (config)\n"
964 " Configure flex payload selection.\n\n"
966 "flow validate {port_id}"
967 " [group {group_id}] [priority {level}]"
968 " [ingress] [egress]"
969 " pattern {item} [/ {item} [...]] / end"
970 " actions {action} [/ {action} [...]] / end\n"
971 " Check whether a flow rule can be created.\n\n"
973 "flow create {port_id}"
974 " [group {group_id}] [priority {level}]"
975 " [ingress] [egress]"
976 " pattern {item} [/ {item} [...]] / end"
977 " actions {action} [/ {action} [...]] / end\n"
978 " Create a flow rule.\n\n"
980 "flow destroy {port_id} rule {rule_id} [...]\n"
981 " Destroy specific flow rules.\n\n"
983 "flow flush {port_id}\n"
984 " Destroy all flow rules.\n\n"
986 "flow query {port_id} {rule_id} {action}\n"
987 " Query an existing flow rule.\n\n"
989 "flow list {port_id} [group {group_id}] [...]\n"
990 " List existing flow rules sorted by priority,"
991 " filtered by group identifiers.\n\n"
993 "flow isolate {port_id} {boolean}\n"
994 " Restrict ingress traffic to the defined"
997 "flow aged {port_id} [destroy]\n"
998 " List and destroy aged flows"
1001 "flow shared_action {port_id} create"
1002 " [action_id {shared_action_id}]"
1003 " [ingress] [egress]"
1004 " action {action} / end\n"
1005 " Create shared action.\n\n"
1007 "flow shared_action {port_id} update"
1008 " {shared_action_id} action {action} / end\n"
1009 " Update shared action.\n\n"
1011 "flow shared_action {port_id} destroy"
1012 " action_id {shared_action_id} [...]\n"
1013 " Destroy specific shared actions.\n\n"
1015 "flow shared_action {port_id} query"
1016 " {shared_action_id}\n"
1017 " Query an existing shared action.\n\n"
1019 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1020 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1021 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1022 " Configure the VXLAN encapsulation for flows.\n\n"
1024 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1025 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1026 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1027 " eth-dst (eth-dst)\n"
1028 " Configure the VXLAN encapsulation for flows.\n\n"
1030 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1031 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1032 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1033 " eth-dst (eth-dst)\n"
1034 " Configure the VXLAN encapsulation for flows.\n\n"
1036 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1037 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1039 " Configure the NVGRE encapsulation for flows.\n\n"
1041 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1042 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1043 " eth-src (eth-src) eth-dst (eth-dst)\n"
1044 " Configure the NVGRE encapsulation for flows.\n\n"
1046 "set raw_encap {flow items}\n"
1047 " Configure the encapsulation with raw data.\n\n"
1049 "set raw_decap {flow items}\n"
1050 " Configure the decapsulation with raw data.\n\n"
1055 if (show_all || !strcmp(res->section, "traffic_management")) {
1059 "Traffic Management:\n"
1061 "show port tm cap (port_id)\n"
1062 " Display the port TM capability.\n\n"
1064 "show port tm level cap (port_id) (level_id)\n"
1065 " Display the port TM hierarchical level capability.\n\n"
1067 "show port tm node cap (port_id) (node_id)\n"
1068 " Display the port TM node capability.\n\n"
1070 "show port tm node type (port_id) (node_id)\n"
1071 " Display the port TM node type.\n\n"
1073 "show port tm node stats (port_id) (node_id) (clear)\n"
1074 " Display the port TM node stats.\n\n"
1076 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1077 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1078 " (packet_length_adjust) (packet_mode)\n"
1079 " Add port tm node private shaper profile.\n\n"
1081 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1082 " Delete port tm node private shaper profile.\n\n"
1084 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1085 " (shaper_profile_id)\n"
1086 " Add/update port tm node shared shaper.\n\n"
1088 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1089 " Delete port tm node shared shaper.\n\n"
1091 "set port tm node shaper profile (port_id) (node_id)"
1092 " (shaper_profile_id)\n"
1093 " Set port tm node shaper profile.\n\n"
1095 "add port tm node wred profile (port_id) (wred_profile_id)"
1096 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1097 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1098 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1099 " Add port tm node wred profile.\n\n"
1101 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1102 " Delete port tm node wred profile.\n\n"
1104 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1105 " (priority) (weight) (level_id) (shaper_profile_id)"
1106 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1107 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1108 " Add port tm nonleaf node.\n\n"
1110 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1111 " (priority) (weight) (level_id) (shaper_profile_id)"
1112 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1113 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1114 " Add port tm nonleaf node with pkt mode enabled.\n\n"
1116 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1117 " (priority) (weight) (level_id) (shaper_profile_id)"
1118 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1119 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1120 " Add port tm leaf node.\n\n"
1122 "del port tm node (port_id) (node_id)\n"
1123 " Delete port tm node.\n\n"
1125 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1126 " (priority) (weight)\n"
1127 " Set port tm node parent.\n\n"
1129 "suspend port tm node (port_id) (node_id)"
1130 " Suspend tm node.\n\n"
1132 "resume port tm node (port_id) (node_id)"
1133 " Resume tm node.\n\n"
1135 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1136 " Commit tm hierarchy.\n\n"
1138 "set port tm mark ip_ecn (port) (green) (yellow)"
1140 " Enables/Disables the traffic management marking"
1141 " for IP ECN (Explicit Congestion Notification)"
1142 " packets on a given port\n\n"
1144 "set port tm mark ip_dscp (port) (green) (yellow)"
1146 " Enables/Disables the traffic management marking"
1147 " on the port for IP dscp packets\n\n"
1149 "set port tm mark vlan_dei (port) (green) (yellow)"
1151 " Enables/Disables the traffic management marking"
1152 " on the port for VLAN packets with DEI enabled\n\n"
1156 if (show_all || !strcmp(res->section, "devices")) {
1160 "Device Operations:\n"
1162 "device detach (identifier)\n"
1163 " Detach device by identifier.\n\n"
1169 cmdline_parse_token_string_t cmd_help_long_help =
1170 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1172 cmdline_parse_token_string_t cmd_help_long_section =
1173 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1174 "all#control#display#config#"
1175 "ports#registers#filters#traffic_management#devices");
1177 cmdline_parse_inst_t cmd_help_long = {
1178 .f = cmd_help_long_parsed,
1180 .help_str = "help all|control|display|config|ports|register|"
1181 "filters|traffic_management|devices: "
1184 (void *)&cmd_help_long_help,
1185 (void *)&cmd_help_long_section,
1191 /* *** start/stop/close all ports *** */
1192 struct cmd_operate_port_result {
1193 cmdline_fixed_string_t keyword;
1194 cmdline_fixed_string_t name;
1195 cmdline_fixed_string_t value;
1198 static void cmd_operate_port_parsed(void *parsed_result,
1199 __rte_unused struct cmdline *cl,
1200 __rte_unused void *data)
1202 struct cmd_operate_port_result *res = parsed_result;
1204 if (!strcmp(res->name, "start"))
1205 start_port(RTE_PORT_ALL);
1206 else if (!strcmp(res->name, "stop"))
1207 stop_port(RTE_PORT_ALL);
1208 else if (!strcmp(res->name, "close"))
1209 close_port(RTE_PORT_ALL);
1210 else if (!strcmp(res->name, "reset"))
1211 reset_port(RTE_PORT_ALL);
1213 printf("Unknown parameter\n");
1216 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1217 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1219 cmdline_parse_token_string_t cmd_operate_port_all_port =
1220 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1221 "start#stop#close#reset");
1222 cmdline_parse_token_string_t cmd_operate_port_all_all =
1223 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1225 cmdline_parse_inst_t cmd_operate_port = {
1226 .f = cmd_operate_port_parsed,
1228 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1230 (void *)&cmd_operate_port_all_cmd,
1231 (void *)&cmd_operate_port_all_port,
1232 (void *)&cmd_operate_port_all_all,
1237 /* *** start/stop/close specific port *** */
1238 struct cmd_operate_specific_port_result {
1239 cmdline_fixed_string_t keyword;
1240 cmdline_fixed_string_t name;
1244 static void cmd_operate_specific_port_parsed(void *parsed_result,
1245 __rte_unused struct cmdline *cl,
1246 __rte_unused void *data)
1248 struct cmd_operate_specific_port_result *res = parsed_result;
1250 if (!strcmp(res->name, "start"))
1251 start_port(res->value);
1252 else if (!strcmp(res->name, "stop"))
1253 stop_port(res->value);
1254 else if (!strcmp(res->name, "close"))
1255 close_port(res->value);
1256 else if (!strcmp(res->name, "reset"))
1257 reset_port(res->value);
1259 printf("Unknown parameter\n");
1262 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1263 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1265 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1266 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1267 name, "start#stop#close#reset");
1268 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1269 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1272 cmdline_parse_inst_t cmd_operate_specific_port = {
1273 .f = cmd_operate_specific_port_parsed,
1275 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1277 (void *)&cmd_operate_specific_port_cmd,
1278 (void *)&cmd_operate_specific_port_port,
1279 (void *)&cmd_operate_specific_port_id,
1284 /* *** enable port setup (after attach) via iterator or event *** */
1285 struct cmd_set_port_setup_on_result {
1286 cmdline_fixed_string_t set;
1287 cmdline_fixed_string_t port;
1288 cmdline_fixed_string_t setup;
1289 cmdline_fixed_string_t on;
1290 cmdline_fixed_string_t mode;
1293 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1294 __rte_unused struct cmdline *cl,
1295 __rte_unused void *data)
1297 struct cmd_set_port_setup_on_result *res = parsed_result;
1299 if (strcmp(res->mode, "event") == 0)
1300 setup_on_probe_event = true;
1301 else if (strcmp(res->mode, "iterator") == 0)
1302 setup_on_probe_event = false;
1304 printf("Unknown mode\n");
1307 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1308 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1310 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1311 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1313 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1314 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1316 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1317 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1319 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1320 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1321 mode, "iterator#event");
1323 cmdline_parse_inst_t cmd_set_port_setup_on = {
1324 .f = cmd_set_port_setup_on_parsed,
1326 .help_str = "set port setup on iterator|event",
1328 (void *)&cmd_set_port_setup_on_set,
1329 (void *)&cmd_set_port_setup_on_port,
1330 (void *)&cmd_set_port_setup_on_setup,
1331 (void *)&cmd_set_port_setup_on_on,
1332 (void *)&cmd_set_port_setup_on_mode,
1337 /* *** attach a specified port *** */
1338 struct cmd_operate_attach_port_result {
1339 cmdline_fixed_string_t port;
1340 cmdline_fixed_string_t keyword;
1341 cmdline_multi_string_t identifier;
1344 static void cmd_operate_attach_port_parsed(void *parsed_result,
1345 __rte_unused struct cmdline *cl,
1346 __rte_unused void *data)
1348 struct cmd_operate_attach_port_result *res = parsed_result;
1350 if (!strcmp(res->keyword, "attach"))
1351 attach_port(res->identifier);
1353 printf("Unknown parameter\n");
1356 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1357 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1359 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1360 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1362 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1363 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1364 identifier, TOKEN_STRING_MULTI);
1366 cmdline_parse_inst_t cmd_operate_attach_port = {
1367 .f = cmd_operate_attach_port_parsed,
1369 .help_str = "port attach <identifier>: "
1370 "(identifier: pci address or virtual dev name)",
1372 (void *)&cmd_operate_attach_port_port,
1373 (void *)&cmd_operate_attach_port_keyword,
1374 (void *)&cmd_operate_attach_port_identifier,
1379 /* *** detach a specified port *** */
1380 struct cmd_operate_detach_port_result {
1381 cmdline_fixed_string_t port;
1382 cmdline_fixed_string_t keyword;
1386 static void cmd_operate_detach_port_parsed(void *parsed_result,
1387 __rte_unused struct cmdline *cl,
1388 __rte_unused void *data)
1390 struct cmd_operate_detach_port_result *res = parsed_result;
1392 if (!strcmp(res->keyword, "detach")) {
1393 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1394 detach_port_device(res->port_id);
1396 printf("Unknown parameter\n");
1400 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1401 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1403 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1404 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1406 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1407 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1408 port_id, RTE_UINT16);
1410 cmdline_parse_inst_t cmd_operate_detach_port = {
1411 .f = cmd_operate_detach_port_parsed,
1413 .help_str = "port detach <port_id>",
1415 (void *)&cmd_operate_detach_port_port,
1416 (void *)&cmd_operate_detach_port_keyword,
1417 (void *)&cmd_operate_detach_port_port_id,
1422 /* *** detach device by identifier *** */
1423 struct cmd_operate_detach_device_result {
1424 cmdline_fixed_string_t device;
1425 cmdline_fixed_string_t keyword;
1426 cmdline_fixed_string_t identifier;
1429 static void cmd_operate_detach_device_parsed(void *parsed_result,
1430 __rte_unused struct cmdline *cl,
1431 __rte_unused void *data)
1433 struct cmd_operate_detach_device_result *res = parsed_result;
1435 if (!strcmp(res->keyword, "detach"))
1436 detach_devargs(res->identifier);
1438 printf("Unknown parameter\n");
1441 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1442 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1444 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1445 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1447 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1448 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1451 cmdline_parse_inst_t cmd_operate_detach_device = {
1452 .f = cmd_operate_detach_device_parsed,
1454 .help_str = "device detach <identifier>:"
1455 "(identifier: pci address or virtual dev name)",
1457 (void *)&cmd_operate_detach_device_device,
1458 (void *)&cmd_operate_detach_device_keyword,
1459 (void *)&cmd_operate_detach_device_identifier,
1463 /* *** configure speed for all ports *** */
1464 struct cmd_config_speed_all {
1465 cmdline_fixed_string_t port;
1466 cmdline_fixed_string_t keyword;
1467 cmdline_fixed_string_t all;
1468 cmdline_fixed_string_t item1;
1469 cmdline_fixed_string_t item2;
1470 cmdline_fixed_string_t value1;
1471 cmdline_fixed_string_t value2;
1475 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1480 if (!strcmp(duplexstr, "half")) {
1481 duplex = ETH_LINK_HALF_DUPLEX;
1482 } else if (!strcmp(duplexstr, "full")) {
1483 duplex = ETH_LINK_FULL_DUPLEX;
1484 } else if (!strcmp(duplexstr, "auto")) {
1485 duplex = ETH_LINK_FULL_DUPLEX;
1487 printf("Unknown duplex parameter\n");
1491 if (!strcmp(speedstr, "10")) {
1492 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1493 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1494 } else if (!strcmp(speedstr, "100")) {
1495 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1496 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1498 if (duplex != ETH_LINK_FULL_DUPLEX) {
1499 printf("Invalid speed/duplex parameters\n");
1502 if (!strcmp(speedstr, "1000")) {
1503 *speed = ETH_LINK_SPEED_1G;
1504 } else if (!strcmp(speedstr, "10000")) {
1505 *speed = ETH_LINK_SPEED_10G;
1506 } else if (!strcmp(speedstr, "25000")) {
1507 *speed = ETH_LINK_SPEED_25G;
1508 } else if (!strcmp(speedstr, "40000")) {
1509 *speed = ETH_LINK_SPEED_40G;
1510 } else if (!strcmp(speedstr, "50000")) {
1511 *speed = ETH_LINK_SPEED_50G;
1512 } else if (!strcmp(speedstr, "100000")) {
1513 *speed = ETH_LINK_SPEED_100G;
1514 } else if (!strcmp(speedstr, "200000")) {
1515 *speed = ETH_LINK_SPEED_200G;
1516 } else if (!strcmp(speedstr, "auto")) {
1517 *speed = ETH_LINK_SPEED_AUTONEG;
1519 printf("Unknown speed parameter\n");
1528 cmd_config_speed_all_parsed(void *parsed_result,
1529 __rte_unused struct cmdline *cl,
1530 __rte_unused void *data)
1532 struct cmd_config_speed_all *res = parsed_result;
1533 uint32_t link_speed;
1536 if (!all_ports_stopped()) {
1537 printf("Please stop all ports first\n");
1541 if (parse_and_check_speed_duplex(res->value1, res->value2,
1545 RTE_ETH_FOREACH_DEV(pid) {
1546 ports[pid].dev_conf.link_speeds = link_speed;
1549 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1552 cmdline_parse_token_string_t cmd_config_speed_all_port =
1553 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1554 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1555 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1557 cmdline_parse_token_string_t cmd_config_speed_all_all =
1558 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1559 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1560 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1561 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1562 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1563 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1564 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1565 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1566 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1567 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1570 cmdline_parse_inst_t cmd_config_speed_all = {
1571 .f = cmd_config_speed_all_parsed,
1573 .help_str = "port config all speed "
1574 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1577 (void *)&cmd_config_speed_all_port,
1578 (void *)&cmd_config_speed_all_keyword,
1579 (void *)&cmd_config_speed_all_all,
1580 (void *)&cmd_config_speed_all_item1,
1581 (void *)&cmd_config_speed_all_value1,
1582 (void *)&cmd_config_speed_all_item2,
1583 (void *)&cmd_config_speed_all_value2,
1588 /* *** configure speed for specific port *** */
1589 struct cmd_config_speed_specific {
1590 cmdline_fixed_string_t port;
1591 cmdline_fixed_string_t keyword;
1593 cmdline_fixed_string_t item1;
1594 cmdline_fixed_string_t item2;
1595 cmdline_fixed_string_t value1;
1596 cmdline_fixed_string_t value2;
1600 cmd_config_speed_specific_parsed(void *parsed_result,
1601 __rte_unused struct cmdline *cl,
1602 __rte_unused void *data)
1604 struct cmd_config_speed_specific *res = parsed_result;
1605 uint32_t link_speed;
1607 if (!all_ports_stopped()) {
1608 printf("Please stop all ports first\n");
1612 if (port_id_is_invalid(res->id, ENABLED_WARN))
1615 if (parse_and_check_speed_duplex(res->value1, res->value2,
1619 ports[res->id].dev_conf.link_speeds = link_speed;
1621 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1625 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1626 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1628 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1629 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1631 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1632 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1633 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1634 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1636 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1637 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1638 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1639 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1640 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1642 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1643 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1646 cmdline_parse_inst_t cmd_config_speed_specific = {
1647 .f = cmd_config_speed_specific_parsed,
1649 .help_str = "port config <port_id> speed "
1650 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1653 (void *)&cmd_config_speed_specific_port,
1654 (void *)&cmd_config_speed_specific_keyword,
1655 (void *)&cmd_config_speed_specific_id,
1656 (void *)&cmd_config_speed_specific_item1,
1657 (void *)&cmd_config_speed_specific_value1,
1658 (void *)&cmd_config_speed_specific_item2,
1659 (void *)&cmd_config_speed_specific_value2,
1664 /* *** configure loopback for all ports *** */
1665 struct cmd_config_loopback_all {
1666 cmdline_fixed_string_t port;
1667 cmdline_fixed_string_t keyword;
1668 cmdline_fixed_string_t all;
1669 cmdline_fixed_string_t item;
1674 cmd_config_loopback_all_parsed(void *parsed_result,
1675 __rte_unused struct cmdline *cl,
1676 __rte_unused void *data)
1678 struct cmd_config_loopback_all *res = parsed_result;
1681 if (!all_ports_stopped()) {
1682 printf("Please stop all ports first\n");
1686 RTE_ETH_FOREACH_DEV(pid) {
1687 ports[pid].dev_conf.lpbk_mode = res->mode;
1690 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1693 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1694 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1695 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1696 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1698 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1699 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1700 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1701 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1703 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1704 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1706 cmdline_parse_inst_t cmd_config_loopback_all = {
1707 .f = cmd_config_loopback_all_parsed,
1709 .help_str = "port config all loopback <mode>",
1711 (void *)&cmd_config_loopback_all_port,
1712 (void *)&cmd_config_loopback_all_keyword,
1713 (void *)&cmd_config_loopback_all_all,
1714 (void *)&cmd_config_loopback_all_item,
1715 (void *)&cmd_config_loopback_all_mode,
1720 /* *** configure loopback for specific port *** */
1721 struct cmd_config_loopback_specific {
1722 cmdline_fixed_string_t port;
1723 cmdline_fixed_string_t keyword;
1725 cmdline_fixed_string_t item;
1730 cmd_config_loopback_specific_parsed(void *parsed_result,
1731 __rte_unused struct cmdline *cl,
1732 __rte_unused void *data)
1734 struct cmd_config_loopback_specific *res = parsed_result;
1736 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1739 if (!port_is_stopped(res->port_id)) {
1740 printf("Please stop port %u first\n", res->port_id);
1744 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1746 cmd_reconfig_device_queue(res->port_id, 1, 1);
1750 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1751 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1753 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1754 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1756 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1757 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1759 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1760 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1762 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1763 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1766 cmdline_parse_inst_t cmd_config_loopback_specific = {
1767 .f = cmd_config_loopback_specific_parsed,
1769 .help_str = "port config <port_id> loopback <mode>",
1771 (void *)&cmd_config_loopback_specific_port,
1772 (void *)&cmd_config_loopback_specific_keyword,
1773 (void *)&cmd_config_loopback_specific_id,
1774 (void *)&cmd_config_loopback_specific_item,
1775 (void *)&cmd_config_loopback_specific_mode,
1780 /* *** configure txq/rxq, txd/rxd *** */
1781 struct cmd_config_rx_tx {
1782 cmdline_fixed_string_t port;
1783 cmdline_fixed_string_t keyword;
1784 cmdline_fixed_string_t all;
1785 cmdline_fixed_string_t name;
1790 cmd_config_rx_tx_parsed(void *parsed_result,
1791 __rte_unused struct cmdline *cl,
1792 __rte_unused void *data)
1794 struct cmd_config_rx_tx *res = parsed_result;
1796 if (!all_ports_stopped()) {
1797 printf("Please stop all ports first\n");
1800 if (!strcmp(res->name, "rxq")) {
1801 if (!res->value && !nb_txq) {
1802 printf("Warning: Either rx or tx queues should be non zero\n");
1805 if (check_nb_rxq(res->value) != 0)
1807 nb_rxq = res->value;
1809 else if (!strcmp(res->name, "txq")) {
1810 if (!res->value && !nb_rxq) {
1811 printf("Warning: Either rx or tx queues should be non zero\n");
1814 if (check_nb_txq(res->value) != 0)
1816 nb_txq = res->value;
1818 else if (!strcmp(res->name, "rxd")) {
1819 if (check_nb_rxd(res->value) != 0)
1821 nb_rxd = res->value;
1822 } else if (!strcmp(res->name, "txd")) {
1823 if (check_nb_txd(res->value) != 0)
1826 nb_txd = res->value;
1828 printf("Unknown parameter\n");
1836 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1839 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1840 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1841 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1842 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1843 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1844 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1845 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1846 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1848 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1849 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
1851 cmdline_parse_inst_t cmd_config_rx_tx = {
1852 .f = cmd_config_rx_tx_parsed,
1854 .help_str = "port config all rxq|txq|rxd|txd <value>",
1856 (void *)&cmd_config_rx_tx_port,
1857 (void *)&cmd_config_rx_tx_keyword,
1858 (void *)&cmd_config_rx_tx_all,
1859 (void *)&cmd_config_rx_tx_name,
1860 (void *)&cmd_config_rx_tx_value,
1865 /* *** config max packet length *** */
1866 struct cmd_config_max_pkt_len_result {
1867 cmdline_fixed_string_t port;
1868 cmdline_fixed_string_t keyword;
1869 cmdline_fixed_string_t all;
1870 cmdline_fixed_string_t name;
1875 cmd_config_max_pkt_len_parsed(void *parsed_result,
1876 __rte_unused struct cmdline *cl,
1877 __rte_unused void *data)
1879 struct cmd_config_max_pkt_len_result *res = parsed_result;
1880 uint32_t max_rx_pkt_len_backup = 0;
1884 if (!all_ports_stopped()) {
1885 printf("Please stop all ports first\n");
1889 RTE_ETH_FOREACH_DEV(pid) {
1890 struct rte_port *port = &ports[pid];
1892 if (!strcmp(res->name, "max-pkt-len")) {
1893 if (res->value < RTE_ETHER_MIN_LEN) {
1894 printf("max-pkt-len can not be less than %d\n",
1898 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1901 ret = eth_dev_info_get_print_err(pid, &port->dev_info);
1903 printf("rte_eth_dev_info_get() failed for port %u\n",
1908 max_rx_pkt_len_backup = port->dev_conf.rxmode.max_rx_pkt_len;
1910 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1911 if (update_jumbo_frame_offload(pid) != 0)
1912 port->dev_conf.rxmode.max_rx_pkt_len = max_rx_pkt_len_backup;
1914 printf("Unknown parameter\n");
1921 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1924 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1925 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1927 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1928 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1930 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1931 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1933 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1934 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1936 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1937 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1940 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1941 .f = cmd_config_max_pkt_len_parsed,
1943 .help_str = "port config all max-pkt-len <value>",
1945 (void *)&cmd_config_max_pkt_len_port,
1946 (void *)&cmd_config_max_pkt_len_keyword,
1947 (void *)&cmd_config_max_pkt_len_all,
1948 (void *)&cmd_config_max_pkt_len_name,
1949 (void *)&cmd_config_max_pkt_len_value,
1954 /* *** config max LRO aggregated packet size *** */
1955 struct cmd_config_max_lro_pkt_size_result {
1956 cmdline_fixed_string_t port;
1957 cmdline_fixed_string_t keyword;
1958 cmdline_fixed_string_t all;
1959 cmdline_fixed_string_t name;
1964 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1965 __rte_unused struct cmdline *cl,
1966 __rte_unused void *data)
1968 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1971 if (!all_ports_stopped()) {
1972 printf("Please stop all ports first\n");
1976 RTE_ETH_FOREACH_DEV(pid) {
1977 struct rte_port *port = &ports[pid];
1979 if (!strcmp(res->name, "max-lro-pkt-size")) {
1981 port->dev_conf.rxmode.max_lro_pkt_size)
1984 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
1986 printf("Unknown parameter\n");
1993 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1996 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
1997 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1999 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2000 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2002 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2003 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2005 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2006 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2007 name, "max-lro-pkt-size");
2008 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2009 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2012 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2013 .f = cmd_config_max_lro_pkt_size_parsed,
2015 .help_str = "port config all max-lro-pkt-size <value>",
2017 (void *)&cmd_config_max_lro_pkt_size_port,
2018 (void *)&cmd_config_max_lro_pkt_size_keyword,
2019 (void *)&cmd_config_max_lro_pkt_size_all,
2020 (void *)&cmd_config_max_lro_pkt_size_name,
2021 (void *)&cmd_config_max_lro_pkt_size_value,
2026 /* *** configure port MTU *** */
2027 struct cmd_config_mtu_result {
2028 cmdline_fixed_string_t port;
2029 cmdline_fixed_string_t keyword;
2030 cmdline_fixed_string_t mtu;
2036 cmd_config_mtu_parsed(void *parsed_result,
2037 __rte_unused struct cmdline *cl,
2038 __rte_unused void *data)
2040 struct cmd_config_mtu_result *res = parsed_result;
2042 if (res->value < RTE_ETHER_MIN_LEN) {
2043 printf("mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2046 port_mtu_set(res->port_id, res->value);
2049 cmdline_parse_token_string_t cmd_config_mtu_port =
2050 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2052 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2053 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2055 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2056 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2058 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2059 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2061 cmdline_parse_token_num_t cmd_config_mtu_value =
2062 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2065 cmdline_parse_inst_t cmd_config_mtu = {
2066 .f = cmd_config_mtu_parsed,
2068 .help_str = "port config mtu <port_id> <value>",
2070 (void *)&cmd_config_mtu_port,
2071 (void *)&cmd_config_mtu_keyword,
2072 (void *)&cmd_config_mtu_mtu,
2073 (void *)&cmd_config_mtu_port_id,
2074 (void *)&cmd_config_mtu_value,
2079 /* *** configure rx mode *** */
2080 struct cmd_config_rx_mode_flag {
2081 cmdline_fixed_string_t port;
2082 cmdline_fixed_string_t keyword;
2083 cmdline_fixed_string_t all;
2084 cmdline_fixed_string_t name;
2085 cmdline_fixed_string_t value;
2089 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2090 __rte_unused struct cmdline *cl,
2091 __rte_unused void *data)
2093 struct cmd_config_rx_mode_flag *res = parsed_result;
2095 if (!all_ports_stopped()) {
2096 printf("Please stop all ports first\n");
2100 if (!strcmp(res->name, "drop-en")) {
2101 if (!strcmp(res->value, "on"))
2103 else if (!strcmp(res->value, "off"))
2106 printf("Unknown parameter\n");
2110 printf("Unknown parameter\n");
2116 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2119 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2120 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2121 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2122 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2124 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2125 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2126 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2127 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2129 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2130 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2133 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2134 .f = cmd_config_rx_mode_flag_parsed,
2136 .help_str = "port config all drop-en on|off",
2138 (void *)&cmd_config_rx_mode_flag_port,
2139 (void *)&cmd_config_rx_mode_flag_keyword,
2140 (void *)&cmd_config_rx_mode_flag_all,
2141 (void *)&cmd_config_rx_mode_flag_name,
2142 (void *)&cmd_config_rx_mode_flag_value,
2147 /* *** configure rss *** */
2148 struct cmd_config_rss {
2149 cmdline_fixed_string_t port;
2150 cmdline_fixed_string_t keyword;
2151 cmdline_fixed_string_t all;
2152 cmdline_fixed_string_t name;
2153 cmdline_fixed_string_t value;
2157 cmd_config_rss_parsed(void *parsed_result,
2158 __rte_unused struct cmdline *cl,
2159 __rte_unused void *data)
2161 struct cmd_config_rss *res = parsed_result;
2162 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2163 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2164 int use_default = 0;
2165 int all_updated = 1;
2170 if (!strcmp(res->value, "all"))
2171 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2172 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2173 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2174 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU |
2176 else if (!strcmp(res->value, "eth"))
2177 rss_conf.rss_hf = ETH_RSS_ETH;
2178 else if (!strcmp(res->value, "vlan"))
2179 rss_conf.rss_hf = ETH_RSS_VLAN;
2180 else if (!strcmp(res->value, "ip"))
2181 rss_conf.rss_hf = ETH_RSS_IP;
2182 else if (!strcmp(res->value, "udp"))
2183 rss_conf.rss_hf = ETH_RSS_UDP;
2184 else if (!strcmp(res->value, "tcp"))
2185 rss_conf.rss_hf = ETH_RSS_TCP;
2186 else if (!strcmp(res->value, "sctp"))
2187 rss_conf.rss_hf = ETH_RSS_SCTP;
2188 else if (!strcmp(res->value, "ether"))
2189 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2190 else if (!strcmp(res->value, "port"))
2191 rss_conf.rss_hf = ETH_RSS_PORT;
2192 else if (!strcmp(res->value, "vxlan"))
2193 rss_conf.rss_hf = ETH_RSS_VXLAN;
2194 else if (!strcmp(res->value, "geneve"))
2195 rss_conf.rss_hf = ETH_RSS_GENEVE;
2196 else if (!strcmp(res->value, "nvgre"))
2197 rss_conf.rss_hf = ETH_RSS_NVGRE;
2198 else if (!strcmp(res->value, "l3-pre32"))
2199 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2200 else if (!strcmp(res->value, "l3-pre40"))
2201 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2202 else if (!strcmp(res->value, "l3-pre48"))
2203 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2204 else if (!strcmp(res->value, "l3-pre56"))
2205 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2206 else if (!strcmp(res->value, "l3-pre64"))
2207 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2208 else if (!strcmp(res->value, "l3-pre96"))
2209 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2210 else if (!strcmp(res->value, "l3-src-only"))
2211 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2212 else if (!strcmp(res->value, "l3-dst-only"))
2213 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2214 else if (!strcmp(res->value, "l4-src-only"))
2215 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2216 else if (!strcmp(res->value, "l4-dst-only"))
2217 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2218 else if (!strcmp(res->value, "l2-src-only"))
2219 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2220 else if (!strcmp(res->value, "l2-dst-only"))
2221 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2222 else if (!strcmp(res->value, "l2tpv3"))
2223 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2224 else if (!strcmp(res->value, "esp"))
2225 rss_conf.rss_hf = ETH_RSS_ESP;
2226 else if (!strcmp(res->value, "ah"))
2227 rss_conf.rss_hf = ETH_RSS_AH;
2228 else if (!strcmp(res->value, "pfcp"))
2229 rss_conf.rss_hf = ETH_RSS_PFCP;
2230 else if (!strcmp(res->value, "pppoe"))
2231 rss_conf.rss_hf = ETH_RSS_PPPOE;
2232 else if (!strcmp(res->value, "gtpu"))
2233 rss_conf.rss_hf = ETH_RSS_GTPU;
2234 else if (!strcmp(res->value, "ecpri"))
2235 rss_conf.rss_hf = ETH_RSS_ECPRI;
2236 else if (!strcmp(res->value, "mpls"))
2237 rss_conf.rss_hf = ETH_RSS_MPLS;
2238 else if (!strcmp(res->value, "none"))
2239 rss_conf.rss_hf = 0;
2240 else if (!strcmp(res->value, "level-default")) {
2241 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2242 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2243 } else if (!strcmp(res->value, "level-outer")) {
2244 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2245 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2246 } else if (!strcmp(res->value, "level-inner")) {
2247 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2248 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2249 } else if (!strcmp(res->value, "default"))
2251 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2252 atoi(res->value) < 64)
2253 rss_conf.rss_hf = 1ULL << atoi(res->value);
2255 printf("Unknown parameter\n");
2258 rss_conf.rss_key = NULL;
2259 /* Update global configuration for RSS types. */
2260 RTE_ETH_FOREACH_DEV(i) {
2261 struct rte_eth_rss_conf local_rss_conf;
2263 ret = eth_dev_info_get_print_err(i, &dev_info);
2268 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2270 local_rss_conf = rss_conf;
2271 local_rss_conf.rss_hf = rss_conf.rss_hf &
2272 dev_info.flow_type_rss_offloads;
2273 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2274 printf("Port %u modified RSS hash function based on hardware support,"
2275 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2276 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2278 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2281 printf("Configuration of RSS hash at ethernet port %d "
2282 "failed with error (%d): %s.\n",
2283 i, -diag, strerror(-diag));
2286 if (all_updated && !use_default) {
2287 rss_hf = rss_conf.rss_hf;
2288 printf("rss_hf %#"PRIx64"\n", rss_hf);
2292 cmdline_parse_token_string_t cmd_config_rss_port =
2293 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2294 cmdline_parse_token_string_t cmd_config_rss_keyword =
2295 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2296 cmdline_parse_token_string_t cmd_config_rss_all =
2297 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2298 cmdline_parse_token_string_t cmd_config_rss_name =
2299 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2300 cmdline_parse_token_string_t cmd_config_rss_value =
2301 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2303 cmdline_parse_inst_t cmd_config_rss = {
2304 .f = cmd_config_rss_parsed,
2306 .help_str = "port config all rss "
2307 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2308 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none|level-default|"
2309 "level-outer|level-inner|<flowtype_id>",
2311 (void *)&cmd_config_rss_port,
2312 (void *)&cmd_config_rss_keyword,
2313 (void *)&cmd_config_rss_all,
2314 (void *)&cmd_config_rss_name,
2315 (void *)&cmd_config_rss_value,
2320 /* *** configure rss hash key *** */
2321 struct cmd_config_rss_hash_key {
2322 cmdline_fixed_string_t port;
2323 cmdline_fixed_string_t config;
2325 cmdline_fixed_string_t rss_hash_key;
2326 cmdline_fixed_string_t rss_type;
2327 cmdline_fixed_string_t key;
2331 hexa_digit_to_value(char hexa_digit)
2333 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2334 return (uint8_t) (hexa_digit - '0');
2335 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2336 return (uint8_t) ((hexa_digit - 'a') + 10);
2337 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2338 return (uint8_t) ((hexa_digit - 'A') + 10);
2339 /* Invalid hexa digit */
2344 parse_and_check_key_hexa_digit(char *key, int idx)
2348 hexa_v = hexa_digit_to_value(key[idx]);
2350 printf("invalid key: character %c at position %d is not a "
2351 "valid hexa digit\n", key[idx], idx);
2356 cmd_config_rss_hash_key_parsed(void *parsed_result,
2357 __rte_unused struct cmdline *cl,
2358 __rte_unused void *data)
2360 struct cmd_config_rss_hash_key *res = parsed_result;
2361 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2365 struct rte_eth_dev_info dev_info;
2366 uint8_t hash_key_size;
2370 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2374 if (dev_info.hash_key_size > 0 &&
2375 dev_info.hash_key_size <= sizeof(hash_key))
2376 hash_key_size = dev_info.hash_key_size;
2378 printf("dev_info did not provide a valid hash key size\n");
2381 /* Check the length of the RSS hash key */
2382 key_len = strlen(res->key);
2383 if (key_len != (hash_key_size * 2)) {
2384 printf("key length: %d invalid - key must be a string of %d"
2385 " hexa-decimal numbers\n",
2386 (int) key_len, hash_key_size * 2);
2389 /* Translate RSS hash key into binary representation */
2390 for (i = 0; i < hash_key_size; i++) {
2391 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2394 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2397 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2399 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2403 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2404 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2405 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2406 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2408 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2409 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2411 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2412 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2413 rss_hash_key, "rss-hash-key");
2414 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2415 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2416 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2417 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2418 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2419 "ipv6-tcp-ex#ipv6-udp-ex#"
2420 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2421 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2422 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri");
2423 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2424 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2426 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2427 .f = cmd_config_rss_hash_key_parsed,
2429 .help_str = "port config <port_id> rss-hash-key "
2430 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2431 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2432 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2433 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2434 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2435 "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri "
2436 "<string of hex digits (variable length, NIC dependent)>",
2438 (void *)&cmd_config_rss_hash_key_port,
2439 (void *)&cmd_config_rss_hash_key_config,
2440 (void *)&cmd_config_rss_hash_key_port_id,
2441 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2442 (void *)&cmd_config_rss_hash_key_rss_type,
2443 (void *)&cmd_config_rss_hash_key_value,
2448 /* *** configure port rxq/txq ring size *** */
2449 struct cmd_config_rxtx_ring_size {
2450 cmdline_fixed_string_t port;
2451 cmdline_fixed_string_t config;
2453 cmdline_fixed_string_t rxtxq;
2455 cmdline_fixed_string_t rsize;
2460 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2461 __rte_unused struct cmdline *cl,
2462 __rte_unused void *data)
2464 struct cmd_config_rxtx_ring_size *res = parsed_result;
2465 struct rte_port *port;
2468 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2471 if (res->portid == (portid_t)RTE_PORT_ALL) {
2472 printf("Invalid port id\n");
2476 port = &ports[res->portid];
2478 if (!strcmp(res->rxtxq, "rxq"))
2480 else if (!strcmp(res->rxtxq, "txq"))
2483 printf("Unknown parameter\n");
2487 if (isrx && rx_queue_id_is_invalid(res->qid))
2489 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2492 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2493 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2499 port->nb_rx_desc[res->qid] = res->size;
2501 port->nb_tx_desc[res->qid] = res->size;
2503 cmd_reconfig_device_queue(res->portid, 0, 1);
2506 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2507 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2509 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2510 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2512 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2513 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2514 portid, RTE_UINT16);
2515 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2516 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2518 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2519 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2521 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2522 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2523 rsize, "ring_size");
2524 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2525 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2528 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2529 .f = cmd_config_rxtx_ring_size_parsed,
2531 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2533 (void *)&cmd_config_rxtx_ring_size_port,
2534 (void *)&cmd_config_rxtx_ring_size_config,
2535 (void *)&cmd_config_rxtx_ring_size_portid,
2536 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2537 (void *)&cmd_config_rxtx_ring_size_qid,
2538 (void *)&cmd_config_rxtx_ring_size_rsize,
2539 (void *)&cmd_config_rxtx_ring_size_size,
2544 /* *** configure port rxq/txq start/stop *** */
2545 struct cmd_config_rxtx_queue {
2546 cmdline_fixed_string_t port;
2548 cmdline_fixed_string_t rxtxq;
2550 cmdline_fixed_string_t opname;
2554 cmd_config_rxtx_queue_parsed(void *parsed_result,
2555 __rte_unused struct cmdline *cl,
2556 __rte_unused void *data)
2558 struct cmd_config_rxtx_queue *res = parsed_result;
2563 if (test_done == 0) {
2564 printf("Please stop forwarding first\n");
2568 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2571 if (port_is_started(res->portid) != 1) {
2572 printf("Please start port %u first\n", res->portid);
2576 if (!strcmp(res->rxtxq, "rxq"))
2578 else if (!strcmp(res->rxtxq, "txq"))
2581 printf("Unknown parameter\n");
2585 if (isrx && rx_queue_id_is_invalid(res->qid))
2587 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2590 if (!strcmp(res->opname, "start"))
2592 else if (!strcmp(res->opname, "stop"))
2595 printf("Unknown parameter\n");
2599 if (isstart && isrx)
2600 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2601 else if (!isstart && isrx)
2602 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2603 else if (isstart && !isrx)
2604 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2606 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2608 if (ret == -ENOTSUP)
2609 printf("Function not supported in PMD driver\n");
2612 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2613 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2614 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2615 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2616 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2617 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2618 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2619 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2620 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2621 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2624 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2625 .f = cmd_config_rxtx_queue_parsed,
2627 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2629 (void *)&cmd_config_rxtx_queue_port,
2630 (void *)&cmd_config_rxtx_queue_portid,
2631 (void *)&cmd_config_rxtx_queue_rxtxq,
2632 (void *)&cmd_config_rxtx_queue_qid,
2633 (void *)&cmd_config_rxtx_queue_opname,
2638 /* *** configure port rxq/txq deferred start on/off *** */
2639 struct cmd_config_deferred_start_rxtx_queue {
2640 cmdline_fixed_string_t port;
2642 cmdline_fixed_string_t rxtxq;
2644 cmdline_fixed_string_t opname;
2645 cmdline_fixed_string_t state;
2649 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2650 __rte_unused struct cmdline *cl,
2651 __rte_unused void *data)
2653 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2654 struct rte_port *port;
2657 uint8_t needreconfig = 0;
2659 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2662 if (port_is_started(res->port_id) != 0) {
2663 printf("Please stop port %u first\n", res->port_id);
2667 port = &ports[res->port_id];
2669 isrx = !strcmp(res->rxtxq, "rxq");
2671 if (isrx && rx_queue_id_is_invalid(res->qid))
2673 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2676 ison = !strcmp(res->state, "on");
2678 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2679 port->rx_conf[res->qid].rx_deferred_start = ison;
2681 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2682 port->tx_conf[res->qid].tx_deferred_start = ison;
2687 cmd_reconfig_device_queue(res->port_id, 0, 1);
2690 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2691 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2693 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2694 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2695 port_id, RTE_UINT16);
2696 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2697 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2699 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2700 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2702 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2703 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2704 opname, "deferred_start");
2705 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2706 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2709 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2710 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2712 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2714 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2715 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2716 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2717 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2718 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2719 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2724 /* *** configure port rxq/txq setup *** */
2725 struct cmd_setup_rxtx_queue {
2726 cmdline_fixed_string_t port;
2728 cmdline_fixed_string_t rxtxq;
2730 cmdline_fixed_string_t setup;
2733 /* Common CLI fields for queue setup */
2734 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2735 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2736 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2737 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2738 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2739 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2740 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2741 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2742 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2743 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2746 cmd_setup_rxtx_queue_parsed(
2747 void *parsed_result,
2748 __rte_unused struct cmdline *cl,
2749 __rte_unused void *data)
2751 struct cmd_setup_rxtx_queue *res = parsed_result;
2752 struct rte_port *port;
2753 struct rte_mempool *mp;
2754 unsigned int socket_id;
2758 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2761 if (res->portid == (portid_t)RTE_PORT_ALL) {
2762 printf("Invalid port id\n");
2766 if (!strcmp(res->rxtxq, "rxq"))
2768 else if (!strcmp(res->rxtxq, "txq"))
2771 printf("Unknown parameter\n");
2775 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2776 printf("Invalid rx queue\n");
2778 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2779 printf("Invalid tx queue\n");
2783 port = &ports[res->portid];
2785 socket_id = rxring_numa[res->portid];
2786 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2787 socket_id = port->socket_id;
2789 mp = mbuf_pool_find(socket_id, 0);
2791 printf("Failed to setup RX queue: "
2792 "No mempool allocation"
2793 " on the socket %d\n",
2794 rxring_numa[res->portid]);
2797 ret = rx_queue_setup(res->portid,
2799 port->nb_rx_desc[res->qid],
2801 &port->rx_conf[res->qid],
2804 printf("Failed to setup RX queue\n");
2806 socket_id = txring_numa[res->portid];
2807 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2808 socket_id = port->socket_id;
2810 ret = rte_eth_tx_queue_setup(res->portid,
2812 port->nb_tx_desc[res->qid],
2814 &port->tx_conf[res->qid]);
2816 printf("Failed to setup TX queue\n");
2820 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2821 .f = cmd_setup_rxtx_queue_parsed,
2823 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2825 (void *)&cmd_setup_rxtx_queue_port,
2826 (void *)&cmd_setup_rxtx_queue_portid,
2827 (void *)&cmd_setup_rxtx_queue_rxtxq,
2828 (void *)&cmd_setup_rxtx_queue_qid,
2829 (void *)&cmd_setup_rxtx_queue_setup,
2835 /* *** Configure RSS RETA *** */
2836 struct cmd_config_rss_reta {
2837 cmdline_fixed_string_t port;
2838 cmdline_fixed_string_t keyword;
2840 cmdline_fixed_string_t name;
2841 cmdline_fixed_string_t list_name;
2842 cmdline_fixed_string_t list_of_items;
2846 parse_reta_config(const char *str,
2847 struct rte_eth_rss_reta_entry64 *reta_conf,
2848 uint16_t nb_entries)
2852 uint16_t hash_index, idx, shift;
2855 const char *p, *p0 = str;
2862 unsigned long int_fld[_NUM_FLD];
2863 char *str_fld[_NUM_FLD];
2865 while ((p = strchr(p0,'(')) != NULL) {
2867 if((p0 = strchr(p,')')) == NULL)
2871 if(size >= sizeof(s))
2874 snprintf(s, sizeof(s), "%.*s", size, p);
2875 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2877 for (i = 0; i < _NUM_FLD; i++) {
2879 int_fld[i] = strtoul(str_fld[i], &end, 0);
2880 if (errno != 0 || end == str_fld[i] ||
2885 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2886 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2888 if (hash_index >= nb_entries) {
2889 printf("Invalid RETA hash index=%d\n", hash_index);
2893 idx = hash_index / RTE_RETA_GROUP_SIZE;
2894 shift = hash_index % RTE_RETA_GROUP_SIZE;
2895 reta_conf[idx].mask |= (1ULL << shift);
2896 reta_conf[idx].reta[shift] = nb_queue;
2903 cmd_set_rss_reta_parsed(void *parsed_result,
2904 __rte_unused struct cmdline *cl,
2905 __rte_unused void *data)
2908 struct rte_eth_dev_info dev_info;
2909 struct rte_eth_rss_reta_entry64 reta_conf[8];
2910 struct cmd_config_rss_reta *res = parsed_result;
2912 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2916 if (dev_info.reta_size == 0) {
2917 printf("Redirection table size is 0 which is "
2918 "invalid for RSS\n");
2921 printf("The reta size of port %d is %u\n",
2922 res->port_id, dev_info.reta_size);
2923 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2924 printf("Currently do not support more than %u entries of "
2925 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2929 memset(reta_conf, 0, sizeof(reta_conf));
2930 if (!strcmp(res->list_name, "reta")) {
2931 if (parse_reta_config(res->list_of_items, reta_conf,
2932 dev_info.reta_size)) {
2933 printf("Invalid RSS Redirection Table "
2934 "config entered\n");
2937 ret = rte_eth_dev_rss_reta_update(res->port_id,
2938 reta_conf, dev_info.reta_size);
2940 printf("Bad redirection table parameter, "
2941 "return code = %d \n", ret);
2945 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2946 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2947 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2948 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2949 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2950 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
2951 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2952 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2953 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2954 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2955 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2956 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2958 cmdline_parse_inst_t cmd_config_rss_reta = {
2959 .f = cmd_set_rss_reta_parsed,
2961 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2963 (void *)&cmd_config_rss_reta_port,
2964 (void *)&cmd_config_rss_reta_keyword,
2965 (void *)&cmd_config_rss_reta_port_id,
2966 (void *)&cmd_config_rss_reta_name,
2967 (void *)&cmd_config_rss_reta_list_name,
2968 (void *)&cmd_config_rss_reta_list_of_items,
2973 /* *** SHOW PORT RETA INFO *** */
2974 struct cmd_showport_reta {
2975 cmdline_fixed_string_t show;
2976 cmdline_fixed_string_t port;
2978 cmdline_fixed_string_t rss;
2979 cmdline_fixed_string_t reta;
2981 cmdline_fixed_string_t list_of_items;
2985 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2986 uint16_t nb_entries,
2990 const char *p, *p0 = str;
2995 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2996 RTE_RETA_GROUP_SIZE;
2999 p = strchr(p0, '(');
3003 p0 = strchr(p, ')');
3007 if (size >= sizeof(s)) {
3008 printf("The string size exceeds the internal buffer size\n");
3011 snprintf(s, sizeof(s), "%.*s", size, p);
3012 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3013 if (ret <= 0 || ret != num) {
3014 printf("The bits of masks do not match the number of "
3015 "reta entries: %u\n", num);
3018 for (i = 0; i < ret; i++)
3019 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3025 cmd_showport_reta_parsed(void *parsed_result,
3026 __rte_unused struct cmdline *cl,
3027 __rte_unused void *data)
3029 struct cmd_showport_reta *res = parsed_result;
3030 struct rte_eth_rss_reta_entry64 reta_conf[8];
3031 struct rte_eth_dev_info dev_info;
3032 uint16_t max_reta_size;
3035 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3039 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3040 if (res->size == 0 || res->size > max_reta_size) {
3041 printf("Invalid redirection table size: %u (1-%u)\n",
3042 res->size, max_reta_size);
3046 memset(reta_conf, 0, sizeof(reta_conf));
3047 if (showport_parse_reta_config(reta_conf, res->size,
3048 res->list_of_items) < 0) {
3049 printf("Invalid string: %s for reta masks\n",
3050 res->list_of_items);
3053 port_rss_reta_info(res->port_id, reta_conf, res->size);
3056 cmdline_parse_token_string_t cmd_showport_reta_show =
3057 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3058 cmdline_parse_token_string_t cmd_showport_reta_port =
3059 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3060 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3061 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3062 cmdline_parse_token_string_t cmd_showport_reta_rss =
3063 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3064 cmdline_parse_token_string_t cmd_showport_reta_reta =
3065 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3066 cmdline_parse_token_num_t cmd_showport_reta_size =
3067 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3068 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3069 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3070 list_of_items, NULL);
3072 cmdline_parse_inst_t cmd_showport_reta = {
3073 .f = cmd_showport_reta_parsed,
3075 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3077 (void *)&cmd_showport_reta_show,
3078 (void *)&cmd_showport_reta_port,
3079 (void *)&cmd_showport_reta_port_id,
3080 (void *)&cmd_showport_reta_rss,
3081 (void *)&cmd_showport_reta_reta,
3082 (void *)&cmd_showport_reta_size,
3083 (void *)&cmd_showport_reta_list_of_items,
3088 /* *** Show RSS hash configuration *** */
3089 struct cmd_showport_rss_hash {
3090 cmdline_fixed_string_t show;
3091 cmdline_fixed_string_t port;
3093 cmdline_fixed_string_t rss_hash;
3094 cmdline_fixed_string_t rss_type;
3095 cmdline_fixed_string_t key; /* optional argument */
3098 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3099 __rte_unused struct cmdline *cl,
3102 struct cmd_showport_rss_hash *res = parsed_result;
3104 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3107 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3108 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3109 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3110 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3111 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3112 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3114 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3115 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3117 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3118 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3120 cmdline_parse_inst_t cmd_showport_rss_hash = {
3121 .f = cmd_showport_rss_hash_parsed,
3123 .help_str = "show port <port_id> rss-hash",
3125 (void *)&cmd_showport_rss_hash_show,
3126 (void *)&cmd_showport_rss_hash_port,
3127 (void *)&cmd_showport_rss_hash_port_id,
3128 (void *)&cmd_showport_rss_hash_rss_hash,
3133 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3134 .f = cmd_showport_rss_hash_parsed,
3136 .help_str = "show port <port_id> rss-hash key",
3138 (void *)&cmd_showport_rss_hash_show,
3139 (void *)&cmd_showport_rss_hash_port,
3140 (void *)&cmd_showport_rss_hash_port_id,
3141 (void *)&cmd_showport_rss_hash_rss_hash,
3142 (void *)&cmd_showport_rss_hash_rss_key,
3147 /* *** Configure DCB *** */
3148 struct cmd_config_dcb {
3149 cmdline_fixed_string_t port;
3150 cmdline_fixed_string_t config;
3152 cmdline_fixed_string_t dcb;
3153 cmdline_fixed_string_t vt;
3154 cmdline_fixed_string_t vt_en;
3156 cmdline_fixed_string_t pfc;
3157 cmdline_fixed_string_t pfc_en;
3161 cmd_config_dcb_parsed(void *parsed_result,
3162 __rte_unused struct cmdline *cl,
3163 __rte_unused void *data)
3165 struct cmd_config_dcb *res = parsed_result;
3166 portid_t port_id = res->port_id;
3167 struct rte_port *port;
3171 port = &ports[port_id];
3172 /** Check if the port is not started **/
3173 if (port->port_status != RTE_PORT_STOPPED) {
3174 printf("Please stop port %d first\n", port_id);
3178 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3179 printf("The invalid number of traffic class,"
3180 " only 4 or 8 allowed.\n");
3184 if (nb_fwd_lcores < res->num_tcs) {
3185 printf("nb_cores shouldn't be less than number of TCs.\n");
3188 if (!strncmp(res->pfc_en, "on", 2))
3193 /* DCB in VT mode */
3194 if (!strncmp(res->vt_en, "on", 2))
3195 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3196 (enum rte_eth_nb_tcs)res->num_tcs,
3199 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3200 (enum rte_eth_nb_tcs)res->num_tcs,
3205 printf("Cannot initialize network ports.\n");
3209 cmd_reconfig_device_queue(port_id, 1, 1);
3212 cmdline_parse_token_string_t cmd_config_dcb_port =
3213 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3214 cmdline_parse_token_string_t cmd_config_dcb_config =
3215 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3216 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3217 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3218 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3219 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3220 cmdline_parse_token_string_t cmd_config_dcb_vt =
3221 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3222 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3223 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3224 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3225 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3226 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3227 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3228 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3229 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3231 cmdline_parse_inst_t cmd_config_dcb = {
3232 .f = cmd_config_dcb_parsed,
3234 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3236 (void *)&cmd_config_dcb_port,
3237 (void *)&cmd_config_dcb_config,
3238 (void *)&cmd_config_dcb_port_id,
3239 (void *)&cmd_config_dcb_dcb,
3240 (void *)&cmd_config_dcb_vt,
3241 (void *)&cmd_config_dcb_vt_en,
3242 (void *)&cmd_config_dcb_num_tcs,
3243 (void *)&cmd_config_dcb_pfc,
3244 (void *)&cmd_config_dcb_pfc_en,
3249 /* *** configure number of packets per burst *** */
3250 struct cmd_config_burst {
3251 cmdline_fixed_string_t port;
3252 cmdline_fixed_string_t keyword;
3253 cmdline_fixed_string_t all;
3254 cmdline_fixed_string_t name;
3259 cmd_config_burst_parsed(void *parsed_result,
3260 __rte_unused struct cmdline *cl,
3261 __rte_unused void *data)
3263 struct cmd_config_burst *res = parsed_result;
3264 struct rte_eth_dev_info dev_info;
3265 uint16_t rec_nb_pkts;
3268 if (!all_ports_stopped()) {
3269 printf("Please stop all ports first\n");
3273 if (!strcmp(res->name, "burst")) {
3274 if (res->value == 0) {
3275 /* If user gives a value of zero, query the PMD for
3276 * its recommended Rx burst size. Testpmd uses a single
3277 * size for all ports, so assume all ports are the same
3278 * NIC model and use the values from Port 0.
3280 ret = eth_dev_info_get_print_err(0, &dev_info);
3284 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3286 if (rec_nb_pkts == 0) {
3287 printf("PMD does not recommend a burst size.\n"
3288 "User provided value must be between"
3289 " 1 and %d\n", MAX_PKT_BURST);
3291 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3292 printf("PMD recommended burst size of %d"
3293 " exceeds maximum value of %d\n",
3294 rec_nb_pkts, MAX_PKT_BURST);
3297 printf("Using PMD-provided burst value of %d\n",
3299 nb_pkt_per_burst = rec_nb_pkts;
3300 } else if (res->value > MAX_PKT_BURST) {
3301 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3304 nb_pkt_per_burst = res->value;
3306 printf("Unknown parameter\n");
3312 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3315 cmdline_parse_token_string_t cmd_config_burst_port =
3316 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3317 cmdline_parse_token_string_t cmd_config_burst_keyword =
3318 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3319 cmdline_parse_token_string_t cmd_config_burst_all =
3320 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3321 cmdline_parse_token_string_t cmd_config_burst_name =
3322 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3323 cmdline_parse_token_num_t cmd_config_burst_value =
3324 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3326 cmdline_parse_inst_t cmd_config_burst = {
3327 .f = cmd_config_burst_parsed,
3329 .help_str = "port config all burst <value>",
3331 (void *)&cmd_config_burst_port,
3332 (void *)&cmd_config_burst_keyword,
3333 (void *)&cmd_config_burst_all,
3334 (void *)&cmd_config_burst_name,
3335 (void *)&cmd_config_burst_value,
3340 /* *** configure rx/tx queues *** */
3341 struct cmd_config_thresh {
3342 cmdline_fixed_string_t port;
3343 cmdline_fixed_string_t keyword;
3344 cmdline_fixed_string_t all;
3345 cmdline_fixed_string_t name;
3350 cmd_config_thresh_parsed(void *parsed_result,
3351 __rte_unused struct cmdline *cl,
3352 __rte_unused void *data)
3354 struct cmd_config_thresh *res = parsed_result;
3356 if (!all_ports_stopped()) {
3357 printf("Please stop all ports first\n");
3361 if (!strcmp(res->name, "txpt"))
3362 tx_pthresh = res->value;
3363 else if(!strcmp(res->name, "txht"))
3364 tx_hthresh = res->value;
3365 else if(!strcmp(res->name, "txwt"))
3366 tx_wthresh = res->value;
3367 else if(!strcmp(res->name, "rxpt"))
3368 rx_pthresh = res->value;
3369 else if(!strcmp(res->name, "rxht"))
3370 rx_hthresh = res->value;
3371 else if(!strcmp(res->name, "rxwt"))
3372 rx_wthresh = res->value;
3374 printf("Unknown parameter\n");
3380 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3383 cmdline_parse_token_string_t cmd_config_thresh_port =
3384 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3385 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3386 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3387 cmdline_parse_token_string_t cmd_config_thresh_all =
3388 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3389 cmdline_parse_token_string_t cmd_config_thresh_name =
3390 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3391 "txpt#txht#txwt#rxpt#rxht#rxwt");
3392 cmdline_parse_token_num_t cmd_config_thresh_value =
3393 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3395 cmdline_parse_inst_t cmd_config_thresh = {
3396 .f = cmd_config_thresh_parsed,
3398 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3400 (void *)&cmd_config_thresh_port,
3401 (void *)&cmd_config_thresh_keyword,
3402 (void *)&cmd_config_thresh_all,
3403 (void *)&cmd_config_thresh_name,
3404 (void *)&cmd_config_thresh_value,
3409 /* *** configure free/rs threshold *** */
3410 struct cmd_config_threshold {
3411 cmdline_fixed_string_t port;
3412 cmdline_fixed_string_t keyword;
3413 cmdline_fixed_string_t all;
3414 cmdline_fixed_string_t name;
3419 cmd_config_threshold_parsed(void *parsed_result,
3420 __rte_unused struct cmdline *cl,
3421 __rte_unused void *data)
3423 struct cmd_config_threshold *res = parsed_result;
3425 if (!all_ports_stopped()) {
3426 printf("Please stop all ports first\n");
3430 if (!strcmp(res->name, "txfreet"))
3431 tx_free_thresh = res->value;
3432 else if (!strcmp(res->name, "txrst"))
3433 tx_rs_thresh = res->value;
3434 else if (!strcmp(res->name, "rxfreet"))
3435 rx_free_thresh = res->value;
3437 printf("Unknown parameter\n");
3443 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3446 cmdline_parse_token_string_t cmd_config_threshold_port =
3447 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3448 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3449 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3451 cmdline_parse_token_string_t cmd_config_threshold_all =
3452 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3453 cmdline_parse_token_string_t cmd_config_threshold_name =
3454 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3455 "txfreet#txrst#rxfreet");
3456 cmdline_parse_token_num_t cmd_config_threshold_value =
3457 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3459 cmdline_parse_inst_t cmd_config_threshold = {
3460 .f = cmd_config_threshold_parsed,
3462 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3464 (void *)&cmd_config_threshold_port,
3465 (void *)&cmd_config_threshold_keyword,
3466 (void *)&cmd_config_threshold_all,
3467 (void *)&cmd_config_threshold_name,
3468 (void *)&cmd_config_threshold_value,
3474 struct cmd_stop_result {
3475 cmdline_fixed_string_t stop;
3478 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3479 __rte_unused struct cmdline *cl,
3480 __rte_unused void *data)
3482 stop_packet_forwarding();
3485 cmdline_parse_token_string_t cmd_stop_stop =
3486 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3488 cmdline_parse_inst_t cmd_stop = {
3489 .f = cmd_stop_parsed,
3491 .help_str = "stop: Stop packet forwarding",
3493 (void *)&cmd_stop_stop,
3498 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3501 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3502 unsigned int *parsed_items, int check_unique_values)
3504 unsigned int nb_item;
3512 * First parse all items in the list and store their value.
3517 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3519 if ((c >= '0') && (c <= '9')) {
3520 value = (unsigned int) (value * 10 + (c - '0'));
3525 printf("character %c is not a decimal digit\n", c);
3529 printf("No valid value before comma\n");
3532 if (nb_item < max_items) {
3533 parsed_items[nb_item] = value;
3539 if (nb_item >= max_items) {
3540 printf("Number of %s = %u > %u (maximum items)\n",
3541 item_name, nb_item + 1, max_items);
3544 parsed_items[nb_item++] = value;
3545 if (! check_unique_values)
3549 * Then, check that all values in the list are differents.
3550 * No optimization here...
3552 for (i = 0; i < nb_item; i++) {
3553 for (j = i + 1; j < nb_item; j++) {
3554 if (parsed_items[j] == parsed_items[i]) {
3555 printf("duplicated %s %u at index %u and %u\n",
3556 item_name, parsed_items[i], i, j);
3564 struct cmd_set_list_result {
3565 cmdline_fixed_string_t cmd_keyword;
3566 cmdline_fixed_string_t list_name;
3567 cmdline_fixed_string_t list_of_items;
3570 static void cmd_set_list_parsed(void *parsed_result,
3571 __rte_unused struct cmdline *cl,
3572 __rte_unused void *data)
3574 struct cmd_set_list_result *res;
3576 unsigned int lcorelist[RTE_MAX_LCORE];
3577 unsigned int portlist[RTE_MAX_ETHPORTS];
3579 unsigned int nb_item;
3581 if (test_done == 0) {
3582 printf("Please stop forwarding first\n");
3586 res = parsed_result;
3587 if (!strcmp(res->list_name, "corelist")) {
3588 nb_item = parse_item_list(res->list_of_items, "core",
3590 parsed_items.lcorelist, 1);
3592 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3597 if (!strcmp(res->list_name, "portlist")) {
3598 nb_item = parse_item_list(res->list_of_items, "port",
3600 parsed_items.portlist, 1);
3602 set_fwd_ports_list(parsed_items.portlist, nb_item);
3608 cmdline_parse_token_string_t cmd_set_list_keyword =
3609 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3611 cmdline_parse_token_string_t cmd_set_list_name =
3612 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3613 "corelist#portlist");
3614 cmdline_parse_token_string_t cmd_set_list_of_items =
3615 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3618 cmdline_parse_inst_t cmd_set_fwd_list = {
3619 .f = cmd_set_list_parsed,
3621 .help_str = "set corelist|portlist <list0[,list1]*>",
3623 (void *)&cmd_set_list_keyword,
3624 (void *)&cmd_set_list_name,
3625 (void *)&cmd_set_list_of_items,
3630 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3632 struct cmd_setmask_result {
3633 cmdline_fixed_string_t set;
3634 cmdline_fixed_string_t mask;
3638 static void cmd_set_mask_parsed(void *parsed_result,
3639 __rte_unused struct cmdline *cl,
3640 __rte_unused void *data)
3642 struct cmd_setmask_result *res = parsed_result;
3644 if (test_done == 0) {
3645 printf("Please stop forwarding first\n");
3648 if (!strcmp(res->mask, "coremask")) {
3649 set_fwd_lcores_mask(res->hexavalue);
3651 } else if (!strcmp(res->mask, "portmask")) {
3652 set_fwd_ports_mask(res->hexavalue);
3657 cmdline_parse_token_string_t cmd_setmask_set =
3658 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3659 cmdline_parse_token_string_t cmd_setmask_mask =
3660 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3661 "coremask#portmask");
3662 cmdline_parse_token_num_t cmd_setmask_value =
3663 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3665 cmdline_parse_inst_t cmd_set_fwd_mask = {
3666 .f = cmd_set_mask_parsed,
3668 .help_str = "set coremask|portmask <hexadecimal value>",
3670 (void *)&cmd_setmask_set,
3671 (void *)&cmd_setmask_mask,
3672 (void *)&cmd_setmask_value,
3678 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3680 struct cmd_set_result {
3681 cmdline_fixed_string_t set;
3682 cmdline_fixed_string_t what;
3686 static void cmd_set_parsed(void *parsed_result,
3687 __rte_unused struct cmdline *cl,
3688 __rte_unused void *data)
3690 struct cmd_set_result *res = parsed_result;
3691 if (!strcmp(res->what, "nbport")) {
3692 set_fwd_ports_number(res->value);
3694 } else if (!strcmp(res->what, "nbcore")) {
3695 set_fwd_lcores_number(res->value);
3697 } else if (!strcmp(res->what, "burst"))
3698 set_nb_pkt_per_burst(res->value);
3699 else if (!strcmp(res->what, "verbose"))
3700 set_verbose_level(res->value);
3703 cmdline_parse_token_string_t cmd_set_set =
3704 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3705 cmdline_parse_token_string_t cmd_set_what =
3706 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3707 "nbport#nbcore#burst#verbose");
3708 cmdline_parse_token_num_t cmd_set_value =
3709 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3711 cmdline_parse_inst_t cmd_set_numbers = {
3712 .f = cmd_set_parsed,
3714 .help_str = "set nbport|nbcore|burst|verbose <value>",
3716 (void *)&cmd_set_set,
3717 (void *)&cmd_set_what,
3718 (void *)&cmd_set_value,
3723 /* *** SET LOG LEVEL CONFIGURATION *** */
3725 struct cmd_set_log_result {
3726 cmdline_fixed_string_t set;
3727 cmdline_fixed_string_t log;
3728 cmdline_fixed_string_t type;
3733 cmd_set_log_parsed(void *parsed_result,
3734 __rte_unused struct cmdline *cl,
3735 __rte_unused void *data)
3737 struct cmd_set_log_result *res;
3740 res = parsed_result;
3741 if (!strcmp(res->type, "global"))
3742 rte_log_set_global_level(res->level);
3744 ret = rte_log_set_level_regexp(res->type, res->level);
3746 printf("Unable to set log level\n");
3750 cmdline_parse_token_string_t cmd_set_log_set =
3751 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3752 cmdline_parse_token_string_t cmd_set_log_log =
3753 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3754 cmdline_parse_token_string_t cmd_set_log_type =
3755 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3756 cmdline_parse_token_num_t cmd_set_log_level =
3757 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3759 cmdline_parse_inst_t cmd_set_log = {
3760 .f = cmd_set_log_parsed,
3762 .help_str = "set log global|<type> <level>",
3764 (void *)&cmd_set_log_set,
3765 (void *)&cmd_set_log_log,
3766 (void *)&cmd_set_log_type,
3767 (void *)&cmd_set_log_level,
3772 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3774 struct cmd_set_rxoffs_result {
3775 cmdline_fixed_string_t cmd_keyword;
3776 cmdline_fixed_string_t rxoffs;
3777 cmdline_fixed_string_t seg_offsets;
3781 cmd_set_rxoffs_parsed(void *parsed_result,
3782 __rte_unused struct cmdline *cl,
3783 __rte_unused void *data)
3785 struct cmd_set_rxoffs_result *res;
3786 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3787 unsigned int nb_segs;
3789 res = parsed_result;
3790 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3791 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3793 set_rx_pkt_offsets(seg_offsets, nb_segs);
3796 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3797 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3798 cmd_keyword, "set");
3799 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3800 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3802 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3803 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3806 cmdline_parse_inst_t cmd_set_rxoffs = {
3807 .f = cmd_set_rxoffs_parsed,
3809 .help_str = "set rxoffs <len0[,len1]*>",
3811 (void *)&cmd_set_rxoffs_keyword,
3812 (void *)&cmd_set_rxoffs_name,
3813 (void *)&cmd_set_rxoffs_offsets,
3818 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3820 struct cmd_set_rxpkts_result {
3821 cmdline_fixed_string_t cmd_keyword;
3822 cmdline_fixed_string_t rxpkts;
3823 cmdline_fixed_string_t seg_lengths;
3827 cmd_set_rxpkts_parsed(void *parsed_result,
3828 __rte_unused struct cmdline *cl,
3829 __rte_unused void *data)
3831 struct cmd_set_rxpkts_result *res;
3832 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3833 unsigned int nb_segs;
3835 res = parsed_result;
3836 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3837 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3839 set_rx_pkt_segments(seg_lengths, nb_segs);
3842 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3843 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3844 cmd_keyword, "set");
3845 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3846 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3848 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3849 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3852 cmdline_parse_inst_t cmd_set_rxpkts = {
3853 .f = cmd_set_rxpkts_parsed,
3855 .help_str = "set rxpkts <len0[,len1]*>",
3857 (void *)&cmd_set_rxpkts_keyword,
3858 (void *)&cmd_set_rxpkts_name,
3859 (void *)&cmd_set_rxpkts_lengths,
3864 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3866 struct cmd_set_txpkts_result {
3867 cmdline_fixed_string_t cmd_keyword;
3868 cmdline_fixed_string_t txpkts;
3869 cmdline_fixed_string_t seg_lengths;
3873 cmd_set_txpkts_parsed(void *parsed_result,
3874 __rte_unused struct cmdline *cl,
3875 __rte_unused void *data)
3877 struct cmd_set_txpkts_result *res;
3878 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3879 unsigned int nb_segs;
3881 res = parsed_result;
3882 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3883 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3885 set_tx_pkt_segments(seg_lengths, nb_segs);
3888 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3889 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3890 cmd_keyword, "set");
3891 cmdline_parse_token_string_t cmd_set_txpkts_name =
3892 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3894 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3895 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3898 cmdline_parse_inst_t cmd_set_txpkts = {
3899 .f = cmd_set_txpkts_parsed,
3901 .help_str = "set txpkts <len0[,len1]*>",
3903 (void *)&cmd_set_txpkts_keyword,
3904 (void *)&cmd_set_txpkts_name,
3905 (void *)&cmd_set_txpkts_lengths,
3910 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3912 struct cmd_set_txsplit_result {
3913 cmdline_fixed_string_t cmd_keyword;
3914 cmdline_fixed_string_t txsplit;
3915 cmdline_fixed_string_t mode;
3919 cmd_set_txsplit_parsed(void *parsed_result,
3920 __rte_unused struct cmdline *cl,
3921 __rte_unused void *data)
3923 struct cmd_set_txsplit_result *res;
3925 res = parsed_result;
3926 set_tx_pkt_split(res->mode);
3929 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3930 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3931 cmd_keyword, "set");
3932 cmdline_parse_token_string_t cmd_set_txsplit_name =
3933 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3934 txsplit, "txsplit");
3935 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3936 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3939 cmdline_parse_inst_t cmd_set_txsplit = {
3940 .f = cmd_set_txsplit_parsed,
3942 .help_str = "set txsplit on|off|rand",
3944 (void *)&cmd_set_txsplit_keyword,
3945 (void *)&cmd_set_txsplit_name,
3946 (void *)&cmd_set_txsplit_mode,
3951 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
3953 struct cmd_set_txtimes_result {
3954 cmdline_fixed_string_t cmd_keyword;
3955 cmdline_fixed_string_t txtimes;
3956 cmdline_fixed_string_t tx_times;
3960 cmd_set_txtimes_parsed(void *parsed_result,
3961 __rte_unused struct cmdline *cl,
3962 __rte_unused void *data)
3964 struct cmd_set_txtimes_result *res;
3965 unsigned int tx_times[2] = {0, 0};
3966 unsigned int n_times;
3968 res = parsed_result;
3969 n_times = parse_item_list(res->tx_times, "tx times",
3972 set_tx_pkt_times(tx_times);
3975 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
3976 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3977 cmd_keyword, "set");
3978 cmdline_parse_token_string_t cmd_set_txtimes_name =
3979 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3980 txtimes, "txtimes");
3981 cmdline_parse_token_string_t cmd_set_txtimes_value =
3982 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
3985 cmdline_parse_inst_t cmd_set_txtimes = {
3986 .f = cmd_set_txtimes_parsed,
3988 .help_str = "set txtimes <inter_burst>,<intra_burst>",
3990 (void *)&cmd_set_txtimes_keyword,
3991 (void *)&cmd_set_txtimes_name,
3992 (void *)&cmd_set_txtimes_value,
3997 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3998 struct cmd_rx_vlan_filter_all_result {
3999 cmdline_fixed_string_t rx_vlan;
4000 cmdline_fixed_string_t what;
4001 cmdline_fixed_string_t all;
4006 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4007 __rte_unused struct cmdline *cl,
4008 __rte_unused void *data)
4010 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4012 if (!strcmp(res->what, "add"))
4013 rx_vlan_all_filter_set(res->port_id, 1);
4015 rx_vlan_all_filter_set(res->port_id, 0);
4018 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4019 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4020 rx_vlan, "rx_vlan");
4021 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4022 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4024 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4025 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4027 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4028 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4029 port_id, RTE_UINT16);
4031 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4032 .f = cmd_rx_vlan_filter_all_parsed,
4034 .help_str = "rx_vlan add|rm all <port_id>: "
4035 "Add/Remove all identifiers to/from the set of VLAN "
4036 "identifiers filtered by a port",
4038 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4039 (void *)&cmd_rx_vlan_filter_all_what,
4040 (void *)&cmd_rx_vlan_filter_all_all,
4041 (void *)&cmd_rx_vlan_filter_all_portid,
4046 /* *** VLAN OFFLOAD SET ON A PORT *** */
4047 struct cmd_vlan_offload_result {
4048 cmdline_fixed_string_t vlan;
4049 cmdline_fixed_string_t set;
4050 cmdline_fixed_string_t vlan_type;
4051 cmdline_fixed_string_t what;
4052 cmdline_fixed_string_t on;
4053 cmdline_fixed_string_t port_id;
4057 cmd_vlan_offload_parsed(void *parsed_result,
4058 __rte_unused struct cmdline *cl,
4059 __rte_unused void *data)
4062 struct cmd_vlan_offload_result *res = parsed_result;
4065 portid_t port_id = 0;
4069 len = strnlen(str, STR_TOKEN_SIZE);
4071 /* Get port_id first */
4079 tmp = strtoul(str, NULL, 0);
4080 /* If port_id greater that what portid_t can represent, return */
4081 if(tmp >= RTE_MAX_ETHPORTS)
4083 port_id = (portid_t)tmp;
4085 if (!strcmp(res->on, "on"))
4090 if (!strcmp(res->what, "strip"))
4091 rx_vlan_strip_set(port_id, on);
4092 else if(!strcmp(res->what, "stripq")){
4093 uint16_t queue_id = 0;
4095 /* No queue_id, return */
4097 printf("must specify (port,queue_id)\n");
4100 tmp = strtoul(str + i + 1, NULL, 0);
4101 /* If queue_id greater that what 16-bits can represent, return */
4105 queue_id = (uint16_t)tmp;
4106 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4108 else if (!strcmp(res->what, "filter"))
4109 rx_vlan_filter_set(port_id, on);
4110 else if (!strcmp(res->what, "qinq_strip"))
4111 rx_vlan_qinq_strip_set(port_id, on);
4113 vlan_extend_set(port_id, on);
4118 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4119 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4121 cmdline_parse_token_string_t cmd_vlan_offload_set =
4122 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4124 cmdline_parse_token_string_t cmd_vlan_offload_what =
4125 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4126 what, "strip#filter#qinq_strip#extend#stripq");
4127 cmdline_parse_token_string_t cmd_vlan_offload_on =
4128 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4130 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4131 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4134 cmdline_parse_inst_t cmd_vlan_offload = {
4135 .f = cmd_vlan_offload_parsed,
4137 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4138 "<port_id[,queue_id]>: "
4139 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4141 (void *)&cmd_vlan_offload_vlan,
4142 (void *)&cmd_vlan_offload_set,
4143 (void *)&cmd_vlan_offload_what,
4144 (void *)&cmd_vlan_offload_on,
4145 (void *)&cmd_vlan_offload_portid,
4150 /* *** VLAN TPID SET ON A PORT *** */
4151 struct cmd_vlan_tpid_result {
4152 cmdline_fixed_string_t vlan;
4153 cmdline_fixed_string_t set;
4154 cmdline_fixed_string_t vlan_type;
4155 cmdline_fixed_string_t what;
4161 cmd_vlan_tpid_parsed(void *parsed_result,
4162 __rte_unused struct cmdline *cl,
4163 __rte_unused void *data)
4165 struct cmd_vlan_tpid_result *res = parsed_result;
4166 enum rte_vlan_type vlan_type;
4168 if (!strcmp(res->vlan_type, "inner"))
4169 vlan_type = ETH_VLAN_TYPE_INNER;
4170 else if (!strcmp(res->vlan_type, "outer"))
4171 vlan_type = ETH_VLAN_TYPE_OUTER;
4173 printf("Unknown vlan type\n");
4176 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4179 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4180 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4182 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4183 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4185 cmdline_parse_token_string_t cmd_vlan_type =
4186 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4187 vlan_type, "inner#outer");
4188 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4189 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4191 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4192 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4194 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4195 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4196 port_id, RTE_UINT16);
4198 cmdline_parse_inst_t cmd_vlan_tpid = {
4199 .f = cmd_vlan_tpid_parsed,
4201 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4202 "Set the VLAN Ether type",
4204 (void *)&cmd_vlan_tpid_vlan,
4205 (void *)&cmd_vlan_tpid_set,
4206 (void *)&cmd_vlan_type,
4207 (void *)&cmd_vlan_tpid_what,
4208 (void *)&cmd_vlan_tpid_tpid,
4209 (void *)&cmd_vlan_tpid_portid,
4214 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4215 struct cmd_rx_vlan_filter_result {
4216 cmdline_fixed_string_t rx_vlan;
4217 cmdline_fixed_string_t what;
4223 cmd_rx_vlan_filter_parsed(void *parsed_result,
4224 __rte_unused struct cmdline *cl,
4225 __rte_unused void *data)
4227 struct cmd_rx_vlan_filter_result *res = parsed_result;
4229 if (!strcmp(res->what, "add"))
4230 rx_vft_set(res->port_id, res->vlan_id, 1);
4232 rx_vft_set(res->port_id, res->vlan_id, 0);
4235 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4236 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4237 rx_vlan, "rx_vlan");
4238 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4239 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4241 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4242 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4243 vlan_id, RTE_UINT16);
4244 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4245 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4246 port_id, RTE_UINT16);
4248 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4249 .f = cmd_rx_vlan_filter_parsed,
4251 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4252 "Add/Remove a VLAN identifier to/from the set of VLAN "
4253 "identifiers filtered by a port",
4255 (void *)&cmd_rx_vlan_filter_rx_vlan,
4256 (void *)&cmd_rx_vlan_filter_what,
4257 (void *)&cmd_rx_vlan_filter_vlanid,
4258 (void *)&cmd_rx_vlan_filter_portid,
4263 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4264 struct cmd_tx_vlan_set_result {
4265 cmdline_fixed_string_t tx_vlan;
4266 cmdline_fixed_string_t set;
4272 cmd_tx_vlan_set_parsed(void *parsed_result,
4273 __rte_unused struct cmdline *cl,
4274 __rte_unused void *data)
4276 struct cmd_tx_vlan_set_result *res = parsed_result;
4278 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4281 if (!port_is_stopped(res->port_id)) {
4282 printf("Please stop port %d first\n", res->port_id);
4286 tx_vlan_set(res->port_id, res->vlan_id);
4288 cmd_reconfig_device_queue(res->port_id, 1, 1);
4291 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4292 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4293 tx_vlan, "tx_vlan");
4294 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4295 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4297 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4298 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4299 port_id, RTE_UINT16);
4300 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4301 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4302 vlan_id, RTE_UINT16);
4304 cmdline_parse_inst_t cmd_tx_vlan_set = {
4305 .f = cmd_tx_vlan_set_parsed,
4307 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4308 "Enable hardware insertion of a single VLAN header "
4309 "with a given TAG Identifier in packets sent on a port",
4311 (void *)&cmd_tx_vlan_set_tx_vlan,
4312 (void *)&cmd_tx_vlan_set_set,
4313 (void *)&cmd_tx_vlan_set_portid,
4314 (void *)&cmd_tx_vlan_set_vlanid,
4319 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4320 struct cmd_tx_vlan_set_qinq_result {
4321 cmdline_fixed_string_t tx_vlan;
4322 cmdline_fixed_string_t set;
4325 uint16_t vlan_id_outer;
4329 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4330 __rte_unused struct cmdline *cl,
4331 __rte_unused void *data)
4333 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4335 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4338 if (!port_is_stopped(res->port_id)) {
4339 printf("Please stop port %d first\n", res->port_id);
4343 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4345 cmd_reconfig_device_queue(res->port_id, 1, 1);
4348 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4349 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4350 tx_vlan, "tx_vlan");
4351 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4352 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4354 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4355 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4356 port_id, RTE_UINT16);
4357 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4358 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4359 vlan_id, RTE_UINT16);
4360 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4361 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4362 vlan_id_outer, RTE_UINT16);
4364 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4365 .f = cmd_tx_vlan_set_qinq_parsed,
4367 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4368 "Enable hardware insertion of double VLAN header "
4369 "with given TAG Identifiers in packets sent on a port",
4371 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4372 (void *)&cmd_tx_vlan_set_qinq_set,
4373 (void *)&cmd_tx_vlan_set_qinq_portid,
4374 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4375 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4380 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4381 struct cmd_tx_vlan_set_pvid_result {
4382 cmdline_fixed_string_t tx_vlan;
4383 cmdline_fixed_string_t set;
4384 cmdline_fixed_string_t pvid;
4387 cmdline_fixed_string_t mode;
4391 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4392 __rte_unused struct cmdline *cl,
4393 __rte_unused void *data)
4395 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4397 if (strcmp(res->mode, "on") == 0)
4398 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4400 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4403 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4404 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4405 tx_vlan, "tx_vlan");
4406 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4407 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4409 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4410 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4412 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4413 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4414 port_id, RTE_UINT16);
4415 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4416 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4417 vlan_id, RTE_UINT16);
4418 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4419 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4422 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4423 .f = cmd_tx_vlan_set_pvid_parsed,
4425 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4427 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4428 (void *)&cmd_tx_vlan_set_pvid_set,
4429 (void *)&cmd_tx_vlan_set_pvid_pvid,
4430 (void *)&cmd_tx_vlan_set_pvid_port_id,
4431 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4432 (void *)&cmd_tx_vlan_set_pvid_mode,
4437 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4438 struct cmd_tx_vlan_reset_result {
4439 cmdline_fixed_string_t tx_vlan;
4440 cmdline_fixed_string_t reset;
4445 cmd_tx_vlan_reset_parsed(void *parsed_result,
4446 __rte_unused struct cmdline *cl,
4447 __rte_unused void *data)
4449 struct cmd_tx_vlan_reset_result *res = parsed_result;
4451 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4454 if (!port_is_stopped(res->port_id)) {
4455 printf("Please stop port %d first\n", res->port_id);
4459 tx_vlan_reset(res->port_id);
4461 cmd_reconfig_device_queue(res->port_id, 1, 1);
4464 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4465 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4466 tx_vlan, "tx_vlan");
4467 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4468 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4470 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4471 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4472 port_id, RTE_UINT16);
4474 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4475 .f = cmd_tx_vlan_reset_parsed,
4477 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4478 "VLAN header in packets sent on a port",
4480 (void *)&cmd_tx_vlan_reset_tx_vlan,
4481 (void *)&cmd_tx_vlan_reset_reset,
4482 (void *)&cmd_tx_vlan_reset_portid,
4488 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4489 struct cmd_csum_result {
4490 cmdline_fixed_string_t csum;
4491 cmdline_fixed_string_t mode;
4492 cmdline_fixed_string_t proto;
4493 cmdline_fixed_string_t hwsw;
4498 csum_show(int port_id)
4500 struct rte_eth_dev_info dev_info;
4501 uint64_t tx_offloads;
4504 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4505 printf("Parse tunnel is %s\n",
4506 (ports[port_id].parse_tunnel) ? "on" : "off");
4507 printf("IP checksum offload is %s\n",
4508 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4509 printf("UDP checksum offload is %s\n",
4510 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4511 printf("TCP checksum offload is %s\n",
4512 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4513 printf("SCTP checksum offload is %s\n",
4514 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4515 printf("Outer-Ip checksum offload is %s\n",
4516 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4517 printf("Outer-Udp checksum offload is %s\n",
4518 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4520 /* display warnings if configuration is not supported by the NIC */
4521 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4525 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4526 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4527 printf("Warning: hardware IP checksum enabled but not "
4528 "supported by port %d\n", port_id);
4530 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4531 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4532 printf("Warning: hardware UDP checksum enabled but not "
4533 "supported by port %d\n", port_id);
4535 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4536 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4537 printf("Warning: hardware TCP checksum enabled but not "
4538 "supported by port %d\n", port_id);
4540 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4541 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4542 printf("Warning: hardware SCTP checksum enabled but not "
4543 "supported by port %d\n", port_id);
4545 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4546 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4547 printf("Warning: hardware outer IP checksum enabled but not "
4548 "supported by port %d\n", port_id);
4550 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4551 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4553 printf("Warning: hardware outer UDP checksum enabled but not "
4554 "supported by port %d\n", port_id);
4559 cmd_config_queue_tx_offloads(struct rte_port *port)
4563 /* Apply queue tx offloads configuration */
4564 for (k = 0; k < port->dev_info.max_rx_queues; k++)
4565 port->tx_conf[k].offloads =
4566 port->dev_conf.txmode.offloads;
4570 cmd_csum_parsed(void *parsed_result,
4571 __rte_unused struct cmdline *cl,
4572 __rte_unused void *data)
4574 struct cmd_csum_result *res = parsed_result;
4576 uint64_t csum_offloads = 0;
4577 struct rte_eth_dev_info dev_info;
4580 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4581 printf("invalid port %d\n", res->port_id);
4584 if (!port_is_stopped(res->port_id)) {
4585 printf("Please stop port %d first\n", res->port_id);
4589 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4593 if (!strcmp(res->mode, "set")) {
4595 if (!strcmp(res->hwsw, "hw"))
4598 if (!strcmp(res->proto, "ip")) {
4599 if (hw == 0 || (dev_info.tx_offload_capa &
4600 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4601 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4603 printf("IP checksum offload is not supported "
4604 "by port %u\n", res->port_id);
4606 } else if (!strcmp(res->proto, "udp")) {
4607 if (hw == 0 || (dev_info.tx_offload_capa &
4608 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4609 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4611 printf("UDP checksum offload is not supported "
4612 "by port %u\n", res->port_id);
4614 } else if (!strcmp(res->proto, "tcp")) {
4615 if (hw == 0 || (dev_info.tx_offload_capa &
4616 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4617 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4619 printf("TCP checksum offload is not supported "
4620 "by port %u\n", res->port_id);
4622 } else if (!strcmp(res->proto, "sctp")) {
4623 if (hw == 0 || (dev_info.tx_offload_capa &
4624 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4625 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4627 printf("SCTP checksum offload is not supported "
4628 "by port %u\n", res->port_id);
4630 } else if (!strcmp(res->proto, "outer-ip")) {
4631 if (hw == 0 || (dev_info.tx_offload_capa &
4632 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4634 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4636 printf("Outer IP checksum offload is not "
4637 "supported by port %u\n", res->port_id);
4639 } else if (!strcmp(res->proto, "outer-udp")) {
4640 if (hw == 0 || (dev_info.tx_offload_capa &
4641 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4643 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4645 printf("Outer UDP checksum offload is not "
4646 "supported by port %u\n", res->port_id);
4651 ports[res->port_id].dev_conf.txmode.offloads |=
4654 ports[res->port_id].dev_conf.txmode.offloads &=
4657 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4659 csum_show(res->port_id);
4661 cmd_reconfig_device_queue(res->port_id, 1, 1);
4664 cmdline_parse_token_string_t cmd_csum_csum =
4665 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4667 cmdline_parse_token_string_t cmd_csum_mode =
4668 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4670 cmdline_parse_token_string_t cmd_csum_proto =
4671 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4672 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4673 cmdline_parse_token_string_t cmd_csum_hwsw =
4674 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4676 cmdline_parse_token_num_t cmd_csum_portid =
4677 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4678 port_id, RTE_UINT16);
4680 cmdline_parse_inst_t cmd_csum_set = {
4681 .f = cmd_csum_parsed,
4683 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4684 "Enable/Disable hardware calculation of L3/L4 checksum when "
4685 "using csum forward engine",
4687 (void *)&cmd_csum_csum,
4688 (void *)&cmd_csum_mode,
4689 (void *)&cmd_csum_proto,
4690 (void *)&cmd_csum_hwsw,
4691 (void *)&cmd_csum_portid,
4696 cmdline_parse_token_string_t cmd_csum_mode_show =
4697 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4700 cmdline_parse_inst_t cmd_csum_show = {
4701 .f = cmd_csum_parsed,
4703 .help_str = "csum show <port_id>: Show checksum offload configuration",
4705 (void *)&cmd_csum_csum,
4706 (void *)&cmd_csum_mode_show,
4707 (void *)&cmd_csum_portid,
4712 /* Enable/disable tunnel parsing */
4713 struct cmd_csum_tunnel_result {
4714 cmdline_fixed_string_t csum;
4715 cmdline_fixed_string_t parse;
4716 cmdline_fixed_string_t onoff;
4721 cmd_csum_tunnel_parsed(void *parsed_result,
4722 __rte_unused struct cmdline *cl,
4723 __rte_unused void *data)
4725 struct cmd_csum_tunnel_result *res = parsed_result;
4727 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4730 if (!strcmp(res->onoff, "on"))
4731 ports[res->port_id].parse_tunnel = 1;
4733 ports[res->port_id].parse_tunnel = 0;
4735 csum_show(res->port_id);
4738 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4739 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4741 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4742 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4743 parse, "parse-tunnel");
4744 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4745 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4747 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4748 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4749 port_id, RTE_UINT16);
4751 cmdline_parse_inst_t cmd_csum_tunnel = {
4752 .f = cmd_csum_tunnel_parsed,
4754 .help_str = "csum parse-tunnel on|off <port_id>: "
4755 "Enable/Disable parsing of tunnels for csum engine",
4757 (void *)&cmd_csum_tunnel_csum,
4758 (void *)&cmd_csum_tunnel_parse,
4759 (void *)&cmd_csum_tunnel_onoff,
4760 (void *)&cmd_csum_tunnel_portid,
4765 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4766 struct cmd_tso_set_result {
4767 cmdline_fixed_string_t tso;
4768 cmdline_fixed_string_t mode;
4774 cmd_tso_set_parsed(void *parsed_result,
4775 __rte_unused struct cmdline *cl,
4776 __rte_unused void *data)
4778 struct cmd_tso_set_result *res = parsed_result;
4779 struct rte_eth_dev_info dev_info;
4782 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4784 if (!port_is_stopped(res->port_id)) {
4785 printf("Please stop port %d first\n", res->port_id);
4789 if (!strcmp(res->mode, "set"))
4790 ports[res->port_id].tso_segsz = res->tso_segsz;
4792 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4796 if ((ports[res->port_id].tso_segsz != 0) &&
4797 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4798 printf("Error: TSO is not supported by port %d\n",
4803 if (ports[res->port_id].tso_segsz == 0) {
4804 ports[res->port_id].dev_conf.txmode.offloads &=
4805 ~DEV_TX_OFFLOAD_TCP_TSO;
4806 printf("TSO for non-tunneled packets is disabled\n");
4808 ports[res->port_id].dev_conf.txmode.offloads |=
4809 DEV_TX_OFFLOAD_TCP_TSO;
4810 printf("TSO segment size for non-tunneled packets is %d\n",
4811 ports[res->port_id].tso_segsz);
4813 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4815 /* display warnings if configuration is not supported by the NIC */
4816 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4820 if ((ports[res->port_id].tso_segsz != 0) &&
4821 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4822 printf("Warning: TSO enabled but not "
4823 "supported by port %d\n", res->port_id);
4826 cmd_reconfig_device_queue(res->port_id, 1, 1);
4829 cmdline_parse_token_string_t cmd_tso_set_tso =
4830 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4832 cmdline_parse_token_string_t cmd_tso_set_mode =
4833 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4835 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4836 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4837 tso_segsz, RTE_UINT16);
4838 cmdline_parse_token_num_t cmd_tso_set_portid =
4839 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4840 port_id, RTE_UINT16);
4842 cmdline_parse_inst_t cmd_tso_set = {
4843 .f = cmd_tso_set_parsed,
4845 .help_str = "tso set <tso_segsz> <port_id>: "
4846 "Set TSO segment size of non-tunneled packets for csum engine "
4849 (void *)&cmd_tso_set_tso,
4850 (void *)&cmd_tso_set_mode,
4851 (void *)&cmd_tso_set_tso_segsz,
4852 (void *)&cmd_tso_set_portid,
4857 cmdline_parse_token_string_t cmd_tso_show_mode =
4858 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4862 cmdline_parse_inst_t cmd_tso_show = {
4863 .f = cmd_tso_set_parsed,
4865 .help_str = "tso show <port_id>: "
4866 "Show TSO segment size of non-tunneled packets for csum engine",
4868 (void *)&cmd_tso_set_tso,
4869 (void *)&cmd_tso_show_mode,
4870 (void *)&cmd_tso_set_portid,
4875 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4876 struct cmd_tunnel_tso_set_result {
4877 cmdline_fixed_string_t tso;
4878 cmdline_fixed_string_t mode;
4883 static struct rte_eth_dev_info
4884 check_tunnel_tso_nic_support(portid_t port_id)
4886 struct rte_eth_dev_info dev_info;
4888 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
4891 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4892 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4893 "not enabled for port %d\n", port_id);
4894 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4895 printf("Warning: GRE TUNNEL TSO not supported therefore "
4896 "not enabled for port %d\n", port_id);
4897 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4898 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4899 "not enabled for port %d\n", port_id);
4900 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4901 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4902 "not enabled for port %d\n", port_id);
4903 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4904 printf("Warning: IP TUNNEL TSO not supported therefore "
4905 "not enabled for port %d\n", port_id);
4906 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4907 printf("Warning: UDP TUNNEL TSO not supported therefore "
4908 "not enabled for port %d\n", port_id);
4913 cmd_tunnel_tso_set_parsed(void *parsed_result,
4914 __rte_unused struct cmdline *cl,
4915 __rte_unused void *data)
4917 struct cmd_tunnel_tso_set_result *res = parsed_result;
4918 struct rte_eth_dev_info dev_info;
4920 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4922 if (!port_is_stopped(res->port_id)) {
4923 printf("Please stop port %d first\n", res->port_id);
4927 if (!strcmp(res->mode, "set"))
4928 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4930 dev_info = check_tunnel_tso_nic_support(res->port_id);
4931 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4932 ports[res->port_id].dev_conf.txmode.offloads &=
4933 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4934 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4935 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4936 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4937 DEV_TX_OFFLOAD_IP_TNL_TSO |
4938 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4939 printf("TSO for tunneled packets is disabled\n");
4941 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4942 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4943 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4944 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4945 DEV_TX_OFFLOAD_IP_TNL_TSO |
4946 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4948 ports[res->port_id].dev_conf.txmode.offloads |=
4949 (tso_offloads & dev_info.tx_offload_capa);
4950 printf("TSO segment size for tunneled packets is %d\n",
4951 ports[res->port_id].tunnel_tso_segsz);
4953 /* Below conditions are needed to make it work:
4954 * (1) tunnel TSO is supported by the NIC;
4955 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4957 * (3) for tunneled pkts with outer L3 of IPv4,
4958 * "csum set outer-ip" must be set to hw, because after tso,
4959 * total_len of outer IP header is changed, and the checksum
4960 * of outer IP header calculated by sw should be wrong; that
4961 * is not necessary for IPv6 tunneled pkts because there's no
4962 * checksum in IP header anymore.
4965 if (!ports[res->port_id].parse_tunnel)
4966 printf("Warning: csum parse_tunnel must be set "
4967 "so that tunneled packets are recognized\n");
4968 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4969 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4970 printf("Warning: csum set outer-ip must be set to hw "
4971 "if outer L3 is IPv4; not necessary for IPv6\n");
4974 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4975 cmd_reconfig_device_queue(res->port_id, 1, 1);
4978 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4979 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4981 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4982 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4984 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4985 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4986 tso_segsz, RTE_UINT16);
4987 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4988 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4989 port_id, RTE_UINT16);
4991 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4992 .f = cmd_tunnel_tso_set_parsed,
4994 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4995 "Set TSO segment size of tunneled packets for csum engine "
4998 (void *)&cmd_tunnel_tso_set_tso,
4999 (void *)&cmd_tunnel_tso_set_mode,
5000 (void *)&cmd_tunnel_tso_set_tso_segsz,
5001 (void *)&cmd_tunnel_tso_set_portid,
5006 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5007 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5011 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5012 .f = cmd_tunnel_tso_set_parsed,
5014 .help_str = "tunnel_tso show <port_id> "
5015 "Show TSO segment size of tunneled packets for csum engine",
5017 (void *)&cmd_tunnel_tso_set_tso,
5018 (void *)&cmd_tunnel_tso_show_mode,
5019 (void *)&cmd_tunnel_tso_set_portid,
5024 /* *** SET GRO FOR A PORT *** */
5025 struct cmd_gro_enable_result {
5026 cmdline_fixed_string_t cmd_set;
5027 cmdline_fixed_string_t cmd_port;
5028 cmdline_fixed_string_t cmd_keyword;
5029 cmdline_fixed_string_t cmd_onoff;
5034 cmd_gro_enable_parsed(void *parsed_result,
5035 __rte_unused struct cmdline *cl,
5036 __rte_unused void *data)
5038 struct cmd_gro_enable_result *res;
5040 res = parsed_result;
5041 if (!strcmp(res->cmd_keyword, "gro"))
5042 setup_gro(res->cmd_onoff, res->cmd_pid);
5045 cmdline_parse_token_string_t cmd_gro_enable_set =
5046 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5048 cmdline_parse_token_string_t cmd_gro_enable_port =
5049 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5050 cmd_keyword, "port");
5051 cmdline_parse_token_num_t cmd_gro_enable_pid =
5052 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5053 cmd_pid, RTE_UINT16);
5054 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5055 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5056 cmd_keyword, "gro");
5057 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5058 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5059 cmd_onoff, "on#off");
5061 cmdline_parse_inst_t cmd_gro_enable = {
5062 .f = cmd_gro_enable_parsed,
5064 .help_str = "set port <port_id> gro on|off",
5066 (void *)&cmd_gro_enable_set,
5067 (void *)&cmd_gro_enable_port,
5068 (void *)&cmd_gro_enable_pid,
5069 (void *)&cmd_gro_enable_keyword,
5070 (void *)&cmd_gro_enable_onoff,
5075 /* *** DISPLAY GRO CONFIGURATION *** */
5076 struct cmd_gro_show_result {
5077 cmdline_fixed_string_t cmd_show;
5078 cmdline_fixed_string_t cmd_port;
5079 cmdline_fixed_string_t cmd_keyword;
5084 cmd_gro_show_parsed(void *parsed_result,
5085 __rte_unused struct cmdline *cl,
5086 __rte_unused void *data)
5088 struct cmd_gro_show_result *res;
5090 res = parsed_result;
5091 if (!strcmp(res->cmd_keyword, "gro"))
5092 show_gro(res->cmd_pid);
5095 cmdline_parse_token_string_t cmd_gro_show_show =
5096 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5098 cmdline_parse_token_string_t cmd_gro_show_port =
5099 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5101 cmdline_parse_token_num_t cmd_gro_show_pid =
5102 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5103 cmd_pid, RTE_UINT16);
5104 cmdline_parse_token_string_t cmd_gro_show_keyword =
5105 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5106 cmd_keyword, "gro");
5108 cmdline_parse_inst_t cmd_gro_show = {
5109 .f = cmd_gro_show_parsed,
5111 .help_str = "show port <port_id> gro",
5113 (void *)&cmd_gro_show_show,
5114 (void *)&cmd_gro_show_port,
5115 (void *)&cmd_gro_show_pid,
5116 (void *)&cmd_gro_show_keyword,
5121 /* *** SET FLUSH CYCLES FOR GRO *** */
5122 struct cmd_gro_flush_result {
5123 cmdline_fixed_string_t cmd_set;
5124 cmdline_fixed_string_t cmd_keyword;
5125 cmdline_fixed_string_t cmd_flush;
5130 cmd_gro_flush_parsed(void *parsed_result,
5131 __rte_unused struct cmdline *cl,
5132 __rte_unused void *data)
5134 struct cmd_gro_flush_result *res;
5136 res = parsed_result;
5137 if ((!strcmp(res->cmd_keyword, "gro")) &&
5138 (!strcmp(res->cmd_flush, "flush")))
5139 setup_gro_flush_cycles(res->cmd_cycles);
5142 cmdline_parse_token_string_t cmd_gro_flush_set =
5143 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5145 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5146 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5147 cmd_keyword, "gro");
5148 cmdline_parse_token_string_t cmd_gro_flush_flush =
5149 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5150 cmd_flush, "flush");
5151 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5152 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5153 cmd_cycles, RTE_UINT8);
5155 cmdline_parse_inst_t cmd_gro_flush = {
5156 .f = cmd_gro_flush_parsed,
5158 .help_str = "set gro flush <cycles>",
5160 (void *)&cmd_gro_flush_set,
5161 (void *)&cmd_gro_flush_keyword,
5162 (void *)&cmd_gro_flush_flush,
5163 (void *)&cmd_gro_flush_cycles,
5168 /* *** ENABLE/DISABLE GSO *** */
5169 struct cmd_gso_enable_result {
5170 cmdline_fixed_string_t cmd_set;
5171 cmdline_fixed_string_t cmd_port;
5172 cmdline_fixed_string_t cmd_keyword;
5173 cmdline_fixed_string_t cmd_mode;
5178 cmd_gso_enable_parsed(void *parsed_result,
5179 __rte_unused struct cmdline *cl,
5180 __rte_unused void *data)
5182 struct cmd_gso_enable_result *res;
5184 res = parsed_result;
5185 if (!strcmp(res->cmd_keyword, "gso"))
5186 setup_gso(res->cmd_mode, res->cmd_pid);
5189 cmdline_parse_token_string_t cmd_gso_enable_set =
5190 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5192 cmdline_parse_token_string_t cmd_gso_enable_port =
5193 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5195 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5196 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5197 cmd_keyword, "gso");
5198 cmdline_parse_token_string_t cmd_gso_enable_mode =
5199 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5200 cmd_mode, "on#off");
5201 cmdline_parse_token_num_t cmd_gso_enable_pid =
5202 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5203 cmd_pid, RTE_UINT16);
5205 cmdline_parse_inst_t cmd_gso_enable = {
5206 .f = cmd_gso_enable_parsed,
5208 .help_str = "set port <port_id> gso on|off",
5210 (void *)&cmd_gso_enable_set,
5211 (void *)&cmd_gso_enable_port,
5212 (void *)&cmd_gso_enable_pid,
5213 (void *)&cmd_gso_enable_keyword,
5214 (void *)&cmd_gso_enable_mode,
5219 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5220 struct cmd_gso_size_result {
5221 cmdline_fixed_string_t cmd_set;
5222 cmdline_fixed_string_t cmd_keyword;
5223 cmdline_fixed_string_t cmd_segsz;
5228 cmd_gso_size_parsed(void *parsed_result,
5229 __rte_unused struct cmdline *cl,
5230 __rte_unused void *data)
5232 struct cmd_gso_size_result *res = parsed_result;
5234 if (test_done == 0) {
5235 printf("Before setting GSO segsz, please first"
5236 " stop forwarding\n");
5240 if (!strcmp(res->cmd_keyword, "gso") &&
5241 !strcmp(res->cmd_segsz, "segsz")) {
5242 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5243 printf("gso_size should be larger than %zu."
5244 " Please input a legal value\n",
5245 RTE_GSO_SEG_SIZE_MIN);
5247 gso_max_segment_size = res->cmd_size;
5251 cmdline_parse_token_string_t cmd_gso_size_set =
5252 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5254 cmdline_parse_token_string_t cmd_gso_size_keyword =
5255 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5256 cmd_keyword, "gso");
5257 cmdline_parse_token_string_t cmd_gso_size_segsz =
5258 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5259 cmd_segsz, "segsz");
5260 cmdline_parse_token_num_t cmd_gso_size_size =
5261 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5262 cmd_size, RTE_UINT16);
5264 cmdline_parse_inst_t cmd_gso_size = {
5265 .f = cmd_gso_size_parsed,
5267 .help_str = "set gso segsz <length>",
5269 (void *)&cmd_gso_size_set,
5270 (void *)&cmd_gso_size_keyword,
5271 (void *)&cmd_gso_size_segsz,
5272 (void *)&cmd_gso_size_size,
5277 /* *** SHOW GSO CONFIGURATION *** */
5278 struct cmd_gso_show_result {
5279 cmdline_fixed_string_t cmd_show;
5280 cmdline_fixed_string_t cmd_port;
5281 cmdline_fixed_string_t cmd_keyword;
5286 cmd_gso_show_parsed(void *parsed_result,
5287 __rte_unused struct cmdline *cl,
5288 __rte_unused void *data)
5290 struct cmd_gso_show_result *res = parsed_result;
5292 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5293 printf("invalid port id %u\n", res->cmd_pid);
5296 if (!strcmp(res->cmd_keyword, "gso")) {
5297 if (gso_ports[res->cmd_pid].enable) {
5298 printf("Max GSO'd packet size: %uB\n"
5299 "Supported GSO types: TCP/IPv4, "
5300 "UDP/IPv4, VxLAN with inner "
5301 "TCP/IPv4 packet, GRE with inner "
5302 "TCP/IPv4 packet\n",
5303 gso_max_segment_size);
5305 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5309 cmdline_parse_token_string_t cmd_gso_show_show =
5310 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5312 cmdline_parse_token_string_t cmd_gso_show_port =
5313 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5315 cmdline_parse_token_string_t cmd_gso_show_keyword =
5316 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5317 cmd_keyword, "gso");
5318 cmdline_parse_token_num_t cmd_gso_show_pid =
5319 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5320 cmd_pid, RTE_UINT16);
5322 cmdline_parse_inst_t cmd_gso_show = {
5323 .f = cmd_gso_show_parsed,
5325 .help_str = "show port <port_id> gso",
5327 (void *)&cmd_gso_show_show,
5328 (void *)&cmd_gso_show_port,
5329 (void *)&cmd_gso_show_pid,
5330 (void *)&cmd_gso_show_keyword,
5335 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5336 struct cmd_set_flush_rx {
5337 cmdline_fixed_string_t set;
5338 cmdline_fixed_string_t flush_rx;
5339 cmdline_fixed_string_t mode;
5343 cmd_set_flush_rx_parsed(void *parsed_result,
5344 __rte_unused struct cmdline *cl,
5345 __rte_unused void *data)
5347 struct cmd_set_flush_rx *res = parsed_result;
5348 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5351 cmdline_parse_token_string_t cmd_setflushrx_set =
5352 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5354 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5355 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5356 flush_rx, "flush_rx");
5357 cmdline_parse_token_string_t cmd_setflushrx_mode =
5358 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5362 cmdline_parse_inst_t cmd_set_flush_rx = {
5363 .f = cmd_set_flush_rx_parsed,
5364 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5367 (void *)&cmd_setflushrx_set,
5368 (void *)&cmd_setflushrx_flush_rx,
5369 (void *)&cmd_setflushrx_mode,
5374 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5375 struct cmd_set_link_check {
5376 cmdline_fixed_string_t set;
5377 cmdline_fixed_string_t link_check;
5378 cmdline_fixed_string_t mode;
5382 cmd_set_link_check_parsed(void *parsed_result,
5383 __rte_unused struct cmdline *cl,
5384 __rte_unused void *data)
5386 struct cmd_set_link_check *res = parsed_result;
5387 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5390 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5391 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5393 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5394 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5395 link_check, "link_check");
5396 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5397 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5401 cmdline_parse_inst_t cmd_set_link_check = {
5402 .f = cmd_set_link_check_parsed,
5403 .help_str = "set link_check on|off: Enable/Disable link status check "
5404 "when starting/stopping a port",
5407 (void *)&cmd_setlinkcheck_set,
5408 (void *)&cmd_setlinkcheck_link_check,
5409 (void *)&cmd_setlinkcheck_mode,
5414 /* *** SET NIC BYPASS MODE *** */
5415 struct cmd_set_bypass_mode_result {
5416 cmdline_fixed_string_t set;
5417 cmdline_fixed_string_t bypass;
5418 cmdline_fixed_string_t mode;
5419 cmdline_fixed_string_t value;
5424 cmd_set_bypass_mode_parsed(void *parsed_result,
5425 __rte_unused struct cmdline *cl,
5426 __rte_unused void *data)
5428 struct cmd_set_bypass_mode_result *res = parsed_result;
5429 portid_t port_id = res->port_id;
5430 int32_t rc = -EINVAL;
5432 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5433 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5435 if (!strcmp(res->value, "bypass"))
5436 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5437 else if (!strcmp(res->value, "isolate"))
5438 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5440 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5442 /* Set the bypass mode for the relevant port. */
5443 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5446 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
5449 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5450 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5452 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5453 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5455 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5456 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5458 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5459 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5460 value, "normal#bypass#isolate");
5461 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5462 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5463 port_id, RTE_UINT16);
5465 cmdline_parse_inst_t cmd_set_bypass_mode = {
5466 .f = cmd_set_bypass_mode_parsed,
5467 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5468 "Set the NIC bypass mode for port_id",
5471 (void *)&cmd_setbypass_mode_set,
5472 (void *)&cmd_setbypass_mode_bypass,
5473 (void *)&cmd_setbypass_mode_mode,
5474 (void *)&cmd_setbypass_mode_value,
5475 (void *)&cmd_setbypass_mode_port,
5480 /* *** SET NIC BYPASS EVENT *** */
5481 struct cmd_set_bypass_event_result {
5482 cmdline_fixed_string_t set;
5483 cmdline_fixed_string_t bypass;
5484 cmdline_fixed_string_t event;
5485 cmdline_fixed_string_t event_value;
5486 cmdline_fixed_string_t mode;
5487 cmdline_fixed_string_t mode_value;
5492 cmd_set_bypass_event_parsed(void *parsed_result,
5493 __rte_unused struct cmdline *cl,
5494 __rte_unused void *data)
5496 int32_t rc = -EINVAL;
5497 struct cmd_set_bypass_event_result *res = parsed_result;
5498 portid_t port_id = res->port_id;
5500 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5501 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5502 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5504 if (!strcmp(res->event_value, "timeout"))
5505 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5506 else if (!strcmp(res->event_value, "os_on"))
5507 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5508 else if (!strcmp(res->event_value, "os_off"))
5509 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5510 else if (!strcmp(res->event_value, "power_on"))
5511 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5512 else if (!strcmp(res->event_value, "power_off"))
5513 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5515 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5517 if (!strcmp(res->mode_value, "bypass"))
5518 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5519 else if (!strcmp(res->mode_value, "isolate"))
5520 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5522 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5524 /* Set the watchdog timeout. */
5525 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5528 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5529 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5533 printf("Failed to set timeout value %u "
5534 "for port %d, errto code: %d.\n",
5535 bypass_timeout, port_id, rc);
5539 /* Set the bypass event to transition to bypass mode. */
5540 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5545 printf("\t Failed to set bypass event for port = %d.\n",
5549 cmdline_parse_token_string_t cmd_setbypass_event_set =
5550 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5552 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5553 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5555 cmdline_parse_token_string_t cmd_setbypass_event_event =
5556 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5558 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5559 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5560 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5561 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5562 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5564 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5565 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5566 mode_value, "normal#bypass#isolate");
5567 cmdline_parse_token_num_t cmd_setbypass_event_port =
5568 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5569 port_id, RTE_UINT16);
5571 cmdline_parse_inst_t cmd_set_bypass_event = {
5572 .f = cmd_set_bypass_event_parsed,
5573 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5574 "power_off mode normal|bypass|isolate <port_id>: "
5575 "Set the NIC bypass event mode for port_id",
5578 (void *)&cmd_setbypass_event_set,
5579 (void *)&cmd_setbypass_event_bypass,
5580 (void *)&cmd_setbypass_event_event,
5581 (void *)&cmd_setbypass_event_event_value,
5582 (void *)&cmd_setbypass_event_mode,
5583 (void *)&cmd_setbypass_event_mode_value,
5584 (void *)&cmd_setbypass_event_port,
5590 /* *** SET NIC BYPASS TIMEOUT *** */
5591 struct cmd_set_bypass_timeout_result {
5592 cmdline_fixed_string_t set;
5593 cmdline_fixed_string_t bypass;
5594 cmdline_fixed_string_t timeout;
5595 cmdline_fixed_string_t value;
5599 cmd_set_bypass_timeout_parsed(void *parsed_result,
5600 __rte_unused struct cmdline *cl,
5601 __rte_unused void *data)
5603 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5605 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5606 if (!strcmp(res->value, "1.5"))
5607 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5608 else if (!strcmp(res->value, "2"))
5609 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5610 else if (!strcmp(res->value, "3"))
5611 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5612 else if (!strcmp(res->value, "4"))
5613 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5614 else if (!strcmp(res->value, "8"))
5615 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5616 else if (!strcmp(res->value, "16"))
5617 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5618 else if (!strcmp(res->value, "32"))
5619 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5621 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5625 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5626 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5628 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5629 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5631 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5632 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5633 timeout, "timeout");
5634 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5635 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5636 value, "0#1.5#2#3#4#8#16#32");
5638 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5639 .f = cmd_set_bypass_timeout_parsed,
5640 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5641 "Set the NIC bypass watchdog timeout in seconds",
5644 (void *)&cmd_setbypass_timeout_set,
5645 (void *)&cmd_setbypass_timeout_bypass,
5646 (void *)&cmd_setbypass_timeout_timeout,
5647 (void *)&cmd_setbypass_timeout_value,
5652 /* *** SHOW NIC BYPASS MODE *** */
5653 struct cmd_show_bypass_config_result {
5654 cmdline_fixed_string_t show;
5655 cmdline_fixed_string_t bypass;
5656 cmdline_fixed_string_t config;
5661 cmd_show_bypass_config_parsed(void *parsed_result,
5662 __rte_unused struct cmdline *cl,
5663 __rte_unused void *data)
5665 struct cmd_show_bypass_config_result *res = parsed_result;
5666 portid_t port_id = res->port_id;
5668 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5669 uint32_t event_mode;
5670 uint32_t bypass_mode;
5671 uint32_t timeout = bypass_timeout;
5674 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5675 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5676 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5677 {"UNKNOWN", "normal", "bypass", "isolate"};
5678 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5686 /* Display the bypass mode.*/
5687 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5688 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5692 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5693 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5695 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5698 /* Display the bypass timeout.*/
5699 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5700 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5702 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5704 /* Display the bypass events and associated modes. */
5705 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5707 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5708 printf("\tFailed to get bypass mode for event = %s\n",
5711 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5712 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5714 printf("\tbypass event: %-16s = %s\n", events[i],
5720 printf("\tFailed to get bypass configuration for port = %d\n",
5724 cmdline_parse_token_string_t cmd_showbypass_config_show =
5725 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5727 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5728 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5730 cmdline_parse_token_string_t cmd_showbypass_config_config =
5731 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5733 cmdline_parse_token_num_t cmd_showbypass_config_port =
5734 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5735 port_id, RTE_UINT16);
5737 cmdline_parse_inst_t cmd_show_bypass_config = {
5738 .f = cmd_show_bypass_config_parsed,
5739 .help_str = "show bypass config <port_id>: "
5740 "Show the NIC bypass config for port_id",
5743 (void *)&cmd_showbypass_config_show,
5744 (void *)&cmd_showbypass_config_bypass,
5745 (void *)&cmd_showbypass_config_config,
5746 (void *)&cmd_showbypass_config_port,
5752 /* *** SET BONDING MODE *** */
5753 struct cmd_set_bonding_mode_result {
5754 cmdline_fixed_string_t set;
5755 cmdline_fixed_string_t bonding;
5756 cmdline_fixed_string_t mode;
5761 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5762 __rte_unused struct cmdline *cl,
5763 __rte_unused void *data)
5765 struct cmd_set_bonding_mode_result *res = parsed_result;
5766 portid_t port_id = res->port_id;
5768 /* Set the bonding mode for the relevant port. */
5769 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5770 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5773 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5774 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5776 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5777 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5778 bonding, "bonding");
5779 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5780 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5782 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5783 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5785 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5786 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5787 port_id, RTE_UINT16);
5789 cmdline_parse_inst_t cmd_set_bonding_mode = {
5790 .f = cmd_set_bonding_mode_parsed,
5791 .help_str = "set bonding mode <mode_value> <port_id>: "
5792 "Set the bonding mode for port_id",
5795 (void *) &cmd_setbonding_mode_set,
5796 (void *) &cmd_setbonding_mode_bonding,
5797 (void *) &cmd_setbonding_mode_mode,
5798 (void *) &cmd_setbonding_mode_value,
5799 (void *) &cmd_setbonding_mode_port,
5804 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5805 struct cmd_set_bonding_lacp_dedicated_queues_result {
5806 cmdline_fixed_string_t set;
5807 cmdline_fixed_string_t bonding;
5808 cmdline_fixed_string_t lacp;
5809 cmdline_fixed_string_t dedicated_queues;
5811 cmdline_fixed_string_t mode;
5814 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5815 __rte_unused struct cmdline *cl,
5816 __rte_unused void *data)
5818 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5819 portid_t port_id = res->port_id;
5820 struct rte_port *port;
5822 port = &ports[port_id];
5824 /** Check if the port is not started **/
5825 if (port->port_status != RTE_PORT_STOPPED) {
5826 printf("Please stop port %d first\n", port_id);
5830 if (!strcmp(res->mode, "enable")) {
5831 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5832 printf("Dedicate queues for LACP control packets"
5835 printf("Enabling dedicate queues for LACP control "
5836 "packets on port %d failed\n", port_id);
5837 } else if (!strcmp(res->mode, "disable")) {
5838 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5839 printf("Dedicated queues for LACP control packets "
5842 printf("Disabling dedicated queues for LACP control "
5843 "traffic on port %d failed\n", port_id);
5847 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5848 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5850 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5851 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5852 bonding, "bonding");
5853 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5854 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5856 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5857 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5858 dedicated_queues, "dedicated_queues");
5859 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5860 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5861 port_id, RTE_UINT16);
5862 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5863 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5864 mode, "enable#disable");
5866 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5867 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5868 .help_str = "set bonding lacp dedicated_queues <port_id> "
5870 "Enable/disable dedicated queues for LACP control traffic for port_id",
5873 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5874 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5875 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5876 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5877 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5878 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5883 /* *** SET BALANCE XMIT POLICY *** */
5884 struct cmd_set_bonding_balance_xmit_policy_result {
5885 cmdline_fixed_string_t set;
5886 cmdline_fixed_string_t bonding;
5887 cmdline_fixed_string_t balance_xmit_policy;
5889 cmdline_fixed_string_t policy;
5892 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5893 __rte_unused struct cmdline *cl,
5894 __rte_unused void *data)
5896 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5897 portid_t port_id = res->port_id;
5900 if (!strcmp(res->policy, "l2")) {
5901 policy = BALANCE_XMIT_POLICY_LAYER2;
5902 } else if (!strcmp(res->policy, "l23")) {
5903 policy = BALANCE_XMIT_POLICY_LAYER23;
5904 } else if (!strcmp(res->policy, "l34")) {
5905 policy = BALANCE_XMIT_POLICY_LAYER34;
5907 printf("\t Invalid xmit policy selection");
5911 /* Set the bonding mode for the relevant port. */
5912 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5913 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5918 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5919 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5921 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5922 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5923 bonding, "bonding");
5924 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5925 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5926 balance_xmit_policy, "balance_xmit_policy");
5927 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5928 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5929 port_id, RTE_UINT16);
5930 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5931 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5932 policy, "l2#l23#l34");
5934 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5935 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5936 .help_str = "set bonding balance_xmit_policy <port_id> "
5938 "Set the bonding balance_xmit_policy for port_id",
5941 (void *)&cmd_setbonding_balance_xmit_policy_set,
5942 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5943 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5944 (void *)&cmd_setbonding_balance_xmit_policy_port,
5945 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5950 /* *** SHOW NIC BONDING CONFIGURATION *** */
5951 struct cmd_show_bonding_config_result {
5952 cmdline_fixed_string_t show;
5953 cmdline_fixed_string_t bonding;
5954 cmdline_fixed_string_t config;
5958 static void cmd_show_bonding_config_parsed(void *parsed_result,
5959 __rte_unused struct cmdline *cl,
5960 __rte_unused void *data)
5962 struct cmd_show_bonding_config_result *res = parsed_result;
5963 int bonding_mode, agg_mode;
5964 portid_t slaves[RTE_MAX_ETHPORTS];
5965 int num_slaves, num_active_slaves;
5968 portid_t port_id = res->port_id;
5970 /* Display the bonding mode.*/
5971 bonding_mode = rte_eth_bond_mode_get(port_id);
5972 if (bonding_mode < 0) {
5973 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5976 printf("\tBonding mode: %d\n", bonding_mode);
5978 if (bonding_mode == BONDING_MODE_BALANCE) {
5979 int balance_xmit_policy;
5981 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5982 if (balance_xmit_policy < 0) {
5983 printf("\tFailed to get balance xmit policy for port = %d\n",
5987 printf("\tBalance Xmit Policy: ");
5989 switch (balance_xmit_policy) {
5990 case BALANCE_XMIT_POLICY_LAYER2:
5991 printf("BALANCE_XMIT_POLICY_LAYER2");
5993 case BALANCE_XMIT_POLICY_LAYER23:
5994 printf("BALANCE_XMIT_POLICY_LAYER23");
5996 case BALANCE_XMIT_POLICY_LAYER34:
5997 printf("BALANCE_XMIT_POLICY_LAYER34");
6004 if (bonding_mode == BONDING_MODE_8023AD) {
6005 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6006 printf("\tIEEE802.3AD Aggregator Mode: ");
6009 printf("bandwidth");
6021 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6023 if (num_slaves < 0) {
6024 printf("\tFailed to get slave list for port = %d\n", port_id);
6027 if (num_slaves > 0) {
6028 printf("\tSlaves (%d): [", num_slaves);
6029 for (i = 0; i < num_slaves - 1; i++)
6030 printf("%d ", slaves[i]);
6032 printf("%d]\n", slaves[num_slaves - 1]);
6034 printf("\tSlaves: []\n");
6038 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6041 if (num_active_slaves < 0) {
6042 printf("\tFailed to get active slave list for port = %d\n", port_id);
6045 if (num_active_slaves > 0) {
6046 printf("\tActive Slaves (%d): [", num_active_slaves);
6047 for (i = 0; i < num_active_slaves - 1; i++)
6048 printf("%d ", slaves[i]);
6050 printf("%d]\n", slaves[num_active_slaves - 1]);
6053 printf("\tActive Slaves: []\n");
6057 primary_id = rte_eth_bond_primary_get(port_id);
6058 if (primary_id < 0) {
6059 printf("\tFailed to get primary slave for port = %d\n", port_id);
6062 printf("\tPrimary: [%d]\n", primary_id);
6066 cmdline_parse_token_string_t cmd_showbonding_config_show =
6067 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6069 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6070 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6071 bonding, "bonding");
6072 cmdline_parse_token_string_t cmd_showbonding_config_config =
6073 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6075 cmdline_parse_token_num_t cmd_showbonding_config_port =
6076 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6077 port_id, RTE_UINT16);
6079 cmdline_parse_inst_t cmd_show_bonding_config = {
6080 .f = cmd_show_bonding_config_parsed,
6081 .help_str = "show bonding config <port_id>: "
6082 "Show the bonding config for port_id",
6085 (void *)&cmd_showbonding_config_show,
6086 (void *)&cmd_showbonding_config_bonding,
6087 (void *)&cmd_showbonding_config_config,
6088 (void *)&cmd_showbonding_config_port,
6093 /* *** SET BONDING PRIMARY *** */
6094 struct cmd_set_bonding_primary_result {
6095 cmdline_fixed_string_t set;
6096 cmdline_fixed_string_t bonding;
6097 cmdline_fixed_string_t primary;
6102 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6103 __rte_unused struct cmdline *cl,
6104 __rte_unused void *data)
6106 struct cmd_set_bonding_primary_result *res = parsed_result;
6107 portid_t master_port_id = res->port_id;
6108 portid_t slave_port_id = res->slave_id;
6110 /* Set the primary slave for a bonded device. */
6111 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6112 printf("\t Failed to set primary slave for port = %d.\n",
6119 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6120 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6122 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6123 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6124 bonding, "bonding");
6125 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6126 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6127 primary, "primary");
6128 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6129 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6130 slave_id, RTE_UINT16);
6131 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6132 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6133 port_id, RTE_UINT16);
6135 cmdline_parse_inst_t cmd_set_bonding_primary = {
6136 .f = cmd_set_bonding_primary_parsed,
6137 .help_str = "set bonding primary <slave_id> <port_id>: "
6138 "Set the primary slave for port_id",
6141 (void *)&cmd_setbonding_primary_set,
6142 (void *)&cmd_setbonding_primary_bonding,
6143 (void *)&cmd_setbonding_primary_primary,
6144 (void *)&cmd_setbonding_primary_slave,
6145 (void *)&cmd_setbonding_primary_port,
6150 /* *** ADD SLAVE *** */
6151 struct cmd_add_bonding_slave_result {
6152 cmdline_fixed_string_t add;
6153 cmdline_fixed_string_t bonding;
6154 cmdline_fixed_string_t slave;
6159 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6160 __rte_unused struct cmdline *cl,
6161 __rte_unused void *data)
6163 struct cmd_add_bonding_slave_result *res = parsed_result;
6164 portid_t master_port_id = res->port_id;
6165 portid_t slave_port_id = res->slave_id;
6167 /* add the slave for a bonded device. */
6168 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6169 printf("\t Failed to add slave %d to master port = %d.\n",
6170 slave_port_id, master_port_id);
6174 set_port_slave_flag(slave_port_id);
6177 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6178 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6180 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6181 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6182 bonding, "bonding");
6183 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6184 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6186 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6187 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6188 slave_id, RTE_UINT16);
6189 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6190 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6191 port_id, RTE_UINT16);
6193 cmdline_parse_inst_t cmd_add_bonding_slave = {
6194 .f = cmd_add_bonding_slave_parsed,
6195 .help_str = "add bonding slave <slave_id> <port_id>: "
6196 "Add a slave device to a bonded device",
6199 (void *)&cmd_addbonding_slave_add,
6200 (void *)&cmd_addbonding_slave_bonding,
6201 (void *)&cmd_addbonding_slave_slave,
6202 (void *)&cmd_addbonding_slave_slaveid,
6203 (void *)&cmd_addbonding_slave_port,
6208 /* *** REMOVE SLAVE *** */
6209 struct cmd_remove_bonding_slave_result {
6210 cmdline_fixed_string_t remove;
6211 cmdline_fixed_string_t bonding;
6212 cmdline_fixed_string_t slave;
6217 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6218 __rte_unused struct cmdline *cl,
6219 __rte_unused void *data)
6221 struct cmd_remove_bonding_slave_result *res = parsed_result;
6222 portid_t master_port_id = res->port_id;
6223 portid_t slave_port_id = res->slave_id;
6225 /* remove the slave from a bonded device. */
6226 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6227 printf("\t Failed to remove slave %d from master port = %d.\n",
6228 slave_port_id, master_port_id);
6232 clear_port_slave_flag(slave_port_id);
6235 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6236 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6238 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6239 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6240 bonding, "bonding");
6241 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6242 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6244 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6245 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6246 slave_id, RTE_UINT16);
6247 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6248 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6249 port_id, RTE_UINT16);
6251 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6252 .f = cmd_remove_bonding_slave_parsed,
6253 .help_str = "remove bonding slave <slave_id> <port_id>: "
6254 "Remove a slave device from a bonded device",
6257 (void *)&cmd_removebonding_slave_remove,
6258 (void *)&cmd_removebonding_slave_bonding,
6259 (void *)&cmd_removebonding_slave_slave,
6260 (void *)&cmd_removebonding_slave_slaveid,
6261 (void *)&cmd_removebonding_slave_port,
6266 /* *** CREATE BONDED DEVICE *** */
6267 struct cmd_create_bonded_device_result {
6268 cmdline_fixed_string_t create;
6269 cmdline_fixed_string_t bonded;
6270 cmdline_fixed_string_t device;
6275 static int bond_dev_num = 0;
6277 static void cmd_create_bonded_device_parsed(void *parsed_result,
6278 __rte_unused struct cmdline *cl,
6279 __rte_unused void *data)
6281 struct cmd_create_bonded_device_result *res = parsed_result;
6282 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6286 if (test_done == 0) {
6287 printf("Please stop forwarding first\n");
6291 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6294 /* Create a new bonded device. */
6295 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6297 printf("\t Failed to create bonded device.\n");
6300 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6303 /* Update number of ports */
6304 nb_ports = rte_eth_dev_count_avail();
6305 reconfig(port_id, res->socket);
6306 ret = rte_eth_promiscuous_enable(port_id);
6308 printf("Failed to enable promiscuous mode for port %u: %s - ignore\n",
6309 port_id, rte_strerror(-ret));
6311 ports[port_id].need_setup = 0;
6312 ports[port_id].port_status = RTE_PORT_STOPPED;
6317 cmdline_parse_token_string_t cmd_createbonded_device_create =
6318 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6320 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6321 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6323 cmdline_parse_token_string_t cmd_createbonded_device_device =
6324 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6326 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6327 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6329 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6330 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6333 cmdline_parse_inst_t cmd_create_bonded_device = {
6334 .f = cmd_create_bonded_device_parsed,
6335 .help_str = "create bonded device <mode> <socket>: "
6336 "Create a new bonded device with specific bonding mode and socket",
6339 (void *)&cmd_createbonded_device_create,
6340 (void *)&cmd_createbonded_device_bonded,
6341 (void *)&cmd_createbonded_device_device,
6342 (void *)&cmd_createbonded_device_mode,
6343 (void *)&cmd_createbonded_device_socket,
6348 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6349 struct cmd_set_bond_mac_addr_result {
6350 cmdline_fixed_string_t set;
6351 cmdline_fixed_string_t bonding;
6352 cmdline_fixed_string_t mac_addr;
6354 struct rte_ether_addr address;
6357 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6358 __rte_unused struct cmdline *cl,
6359 __rte_unused void *data)
6361 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6364 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6367 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6369 /* check the return value and print it if is < 0 */
6371 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6374 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6375 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6376 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6377 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6379 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6380 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6382 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6383 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6384 port_num, RTE_UINT16);
6385 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6386 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6388 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6389 .f = cmd_set_bond_mac_addr_parsed,
6391 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6393 (void *)&cmd_set_bond_mac_addr_set,
6394 (void *)&cmd_set_bond_mac_addr_bonding,
6395 (void *)&cmd_set_bond_mac_addr_mac,
6396 (void *)&cmd_set_bond_mac_addr_portnum,
6397 (void *)&cmd_set_bond_mac_addr_addr,
6403 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6404 struct cmd_set_bond_mon_period_result {
6405 cmdline_fixed_string_t set;
6406 cmdline_fixed_string_t bonding;
6407 cmdline_fixed_string_t mon_period;
6412 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6413 __rte_unused struct cmdline *cl,
6414 __rte_unused void *data)
6416 struct cmd_set_bond_mon_period_result *res = parsed_result;
6419 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6421 /* check the return value and print it if is < 0 */
6423 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
6426 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6427 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6429 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6430 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6431 bonding, "bonding");
6432 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6433 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6434 mon_period, "mon_period");
6435 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6436 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6437 port_num, RTE_UINT16);
6438 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6439 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6440 period_ms, RTE_UINT32);
6442 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6443 .f = cmd_set_bond_mon_period_parsed,
6445 .help_str = "set bonding mon_period <port_id> <period_ms>",
6447 (void *)&cmd_set_bond_mon_period_set,
6448 (void *)&cmd_set_bond_mon_period_bonding,
6449 (void *)&cmd_set_bond_mon_period_mon_period,
6450 (void *)&cmd_set_bond_mon_period_portnum,
6451 (void *)&cmd_set_bond_mon_period_period_ms,
6458 struct cmd_set_bonding_agg_mode_policy_result {
6459 cmdline_fixed_string_t set;
6460 cmdline_fixed_string_t bonding;
6461 cmdline_fixed_string_t agg_mode;
6463 cmdline_fixed_string_t policy;
6468 cmd_set_bonding_agg_mode(void *parsed_result,
6469 __rte_unused struct cmdline *cl,
6470 __rte_unused void *data)
6472 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6473 uint8_t policy = AGG_BANDWIDTH;
6475 if (!strcmp(res->policy, "bandwidth"))
6476 policy = AGG_BANDWIDTH;
6477 else if (!strcmp(res->policy, "stable"))
6478 policy = AGG_STABLE;
6479 else if (!strcmp(res->policy, "count"))
6482 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6486 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6487 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6489 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6490 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6491 bonding, "bonding");
6493 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6494 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6495 agg_mode, "agg_mode");
6497 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6498 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6499 port_num, RTE_UINT16);
6501 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6502 TOKEN_STRING_INITIALIZER(
6503 struct cmd_set_bonding_balance_xmit_policy_result,
6504 policy, "stable#bandwidth#count");
6506 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6507 .f = cmd_set_bonding_agg_mode,
6509 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6511 (void *)&cmd_set_bonding_agg_mode_set,
6512 (void *)&cmd_set_bonding_agg_mode_bonding,
6513 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6514 (void *)&cmd_set_bonding_agg_mode_portnum,
6515 (void *)&cmd_set_bonding_agg_mode_policy_string,
6521 #endif /* RTE_NET_BOND */
6523 /* *** SET FORWARDING MODE *** */
6524 struct cmd_set_fwd_mode_result {
6525 cmdline_fixed_string_t set;
6526 cmdline_fixed_string_t fwd;
6527 cmdline_fixed_string_t mode;
6530 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6531 __rte_unused struct cmdline *cl,
6532 __rte_unused void *data)
6534 struct cmd_set_fwd_mode_result *res = parsed_result;
6537 set_pkt_forwarding_mode(res->mode);
6540 cmdline_parse_token_string_t cmd_setfwd_set =
6541 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6542 cmdline_parse_token_string_t cmd_setfwd_fwd =
6543 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6544 cmdline_parse_token_string_t cmd_setfwd_mode =
6545 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6546 "" /* defined at init */);
6548 cmdline_parse_inst_t cmd_set_fwd_mode = {
6549 .f = cmd_set_fwd_mode_parsed,
6551 .help_str = NULL, /* defined at init */
6553 (void *)&cmd_setfwd_set,
6554 (void *)&cmd_setfwd_fwd,
6555 (void *)&cmd_setfwd_mode,
6560 static void cmd_set_fwd_mode_init(void)
6563 static char token[128];
6564 static char help[256];
6565 cmdline_parse_token_string_t *token_struct;
6567 modes = list_pkt_forwarding_modes();
6568 snprintf(help, sizeof(help), "set fwd %s: "
6569 "Set packet forwarding mode", modes);
6570 cmd_set_fwd_mode.help_str = help;
6572 /* string token separator is # */
6573 for (c = token; *modes != '\0'; modes++)
6578 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6579 token_struct->string_data.str = token;
6582 /* *** SET RETRY FORWARDING MODE *** */
6583 struct cmd_set_fwd_retry_mode_result {
6584 cmdline_fixed_string_t set;
6585 cmdline_fixed_string_t fwd;
6586 cmdline_fixed_string_t mode;
6587 cmdline_fixed_string_t retry;
6590 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6591 __rte_unused struct cmdline *cl,
6592 __rte_unused void *data)
6594 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6597 set_pkt_forwarding_mode(res->mode);
6600 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6601 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6603 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6604 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6606 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6607 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6609 "" /* defined at init */);
6610 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6611 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6614 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6615 .f = cmd_set_fwd_retry_mode_parsed,
6617 .help_str = NULL, /* defined at init */
6619 (void *)&cmd_setfwd_retry_set,
6620 (void *)&cmd_setfwd_retry_fwd,
6621 (void *)&cmd_setfwd_retry_mode,
6622 (void *)&cmd_setfwd_retry_retry,
6627 static void cmd_set_fwd_retry_mode_init(void)
6630 static char token[128];
6631 static char help[256];
6632 cmdline_parse_token_string_t *token_struct;
6634 modes = list_pkt_forwarding_retry_modes();
6635 snprintf(help, sizeof(help), "set fwd %s retry: "
6636 "Set packet forwarding mode with retry", modes);
6637 cmd_set_fwd_retry_mode.help_str = help;
6639 /* string token separator is # */
6640 for (c = token; *modes != '\0'; modes++)
6645 token_struct = (cmdline_parse_token_string_t *)
6646 cmd_set_fwd_retry_mode.tokens[2];
6647 token_struct->string_data.str = token;
6650 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6651 struct cmd_set_burst_tx_retry_result {
6652 cmdline_fixed_string_t set;
6653 cmdline_fixed_string_t burst;
6654 cmdline_fixed_string_t tx;
6655 cmdline_fixed_string_t delay;
6657 cmdline_fixed_string_t retry;
6661 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6662 __rte_unused struct cmdline *cl,
6663 __rte_unused void *data)
6665 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6667 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6668 && !strcmp(res->tx, "tx")) {
6669 if (!strcmp(res->delay, "delay"))
6670 burst_tx_delay_time = res->time;
6671 if (!strcmp(res->retry, "retry"))
6672 burst_tx_retry_num = res->retry_num;
6677 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6678 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6679 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6680 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6682 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6683 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6684 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6685 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6686 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6687 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
6689 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6690 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6691 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6692 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
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, RTE_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,
6909 low_water, RTE_UINT32);
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, RTE_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,
6921 send_xon, RTE_UINT16);
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,
6936 port_id, RTE_UINT16);
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, RTE_UINT32);
7233 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7234 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7235 low_water, RTE_UINT32);
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, RTE_UINT16);
7239 cmdline_parse_token_num_t cmd_pfc_set_priority =
7240 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7241 priority, RTE_UINT8);
7242 cmdline_parse_token_num_t cmd_pfc_set_portid =
7243 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7244 port_id, RTE_UINT16);
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,
7382 tx_num, RTE_UINT32);
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,
7416 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7417 __rte_unused struct cmdline *cl,
7418 __rte_unused void *data)
7420 struct cmd_set_link_up_result *res = parsed_result;
7421 dev_set_link_up(res->port_id);
7424 cmdline_parse_inst_t cmd_set_link_up = {
7425 .f = cmd_set_link_up_parsed,
7427 .help_str = "set link-up port <port id>",
7429 (void *)&cmd_set_link_up_set,
7430 (void *)&cmd_set_link_up_link_up,
7431 (void *)&cmd_set_link_up_port,
7432 (void *)&cmd_set_link_up_port_id,
7437 /* *** SET LINK DOWN *** */
7438 struct cmd_set_link_down_result {
7439 cmdline_fixed_string_t set;
7440 cmdline_fixed_string_t link_down;
7441 cmdline_fixed_string_t port;
7445 cmdline_parse_token_string_t cmd_set_link_down_set =
7446 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7447 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7448 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7450 cmdline_parse_token_string_t cmd_set_link_down_port =
7451 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7452 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7453 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7456 static void cmd_set_link_down_parsed(
7457 __rte_unused void *parsed_result,
7458 __rte_unused struct cmdline *cl,
7459 __rte_unused void *data)
7461 struct cmd_set_link_down_result *res = parsed_result;
7462 dev_set_link_down(res->port_id);
7465 cmdline_parse_inst_t cmd_set_link_down = {
7466 .f = cmd_set_link_down_parsed,
7468 .help_str = "set link-down port <port id>",
7470 (void *)&cmd_set_link_down_set,
7471 (void *)&cmd_set_link_down_link_down,
7472 (void *)&cmd_set_link_down_port,
7473 (void *)&cmd_set_link_down_port_id,
7478 /* *** SHOW CFG *** */
7479 struct cmd_showcfg_result {
7480 cmdline_fixed_string_t show;
7481 cmdline_fixed_string_t cfg;
7482 cmdline_fixed_string_t what;
7485 static void cmd_showcfg_parsed(void *parsed_result,
7486 __rte_unused struct cmdline *cl,
7487 __rte_unused void *data)
7489 struct cmd_showcfg_result *res = parsed_result;
7490 if (!strcmp(res->what, "rxtx"))
7491 rxtx_config_display();
7492 else if (!strcmp(res->what, "cores"))
7493 fwd_lcores_config_display();
7494 else if (!strcmp(res->what, "fwd"))
7495 pkt_fwd_config_display(&cur_fwd_config);
7496 else if (!strcmp(res->what, "rxoffs"))
7497 show_rx_pkt_offsets();
7498 else if (!strcmp(res->what, "rxpkts"))
7499 show_rx_pkt_segments();
7500 else if (!strcmp(res->what, "txpkts"))
7501 show_tx_pkt_segments();
7502 else if (!strcmp(res->what, "txtimes"))
7503 show_tx_pkt_times();
7506 cmdline_parse_token_string_t cmd_showcfg_show =
7507 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7508 cmdline_parse_token_string_t cmd_showcfg_port =
7509 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7510 cmdline_parse_token_string_t cmd_showcfg_what =
7511 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7512 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7514 cmdline_parse_inst_t cmd_showcfg = {
7515 .f = cmd_showcfg_parsed,
7517 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7519 (void *)&cmd_showcfg_show,
7520 (void *)&cmd_showcfg_port,
7521 (void *)&cmd_showcfg_what,
7526 /* *** SHOW ALL PORT INFO *** */
7527 struct cmd_showportall_result {
7528 cmdline_fixed_string_t show;
7529 cmdline_fixed_string_t port;
7530 cmdline_fixed_string_t what;
7531 cmdline_fixed_string_t all;
7534 static void cmd_showportall_parsed(void *parsed_result,
7535 __rte_unused struct cmdline *cl,
7536 __rte_unused void *data)
7540 struct cmd_showportall_result *res = parsed_result;
7541 if (!strcmp(res->show, "clear")) {
7542 if (!strcmp(res->what, "stats"))
7543 RTE_ETH_FOREACH_DEV(i)
7545 else if (!strcmp(res->what, "xstats"))
7546 RTE_ETH_FOREACH_DEV(i)
7547 nic_xstats_clear(i);
7548 } else if (!strcmp(res->what, "info"))
7549 RTE_ETH_FOREACH_DEV(i)
7550 port_infos_display(i);
7551 else if (!strcmp(res->what, "summary")) {
7552 port_summary_header_display();
7553 RTE_ETH_FOREACH_DEV(i)
7554 port_summary_display(i);
7556 else if (!strcmp(res->what, "stats"))
7557 RTE_ETH_FOREACH_DEV(i)
7558 nic_stats_display(i);
7559 else if (!strcmp(res->what, "xstats"))
7560 RTE_ETH_FOREACH_DEV(i)
7561 nic_xstats_display(i);
7562 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7563 else if (!strcmp(res->what, "fdir"))
7564 RTE_ETH_FOREACH_DEV(i)
7567 else if (!strcmp(res->what, "dcb_tc"))
7568 RTE_ETH_FOREACH_DEV(i)
7569 port_dcb_info_display(i);
7570 else if (!strcmp(res->what, "cap"))
7571 RTE_ETH_FOREACH_DEV(i)
7572 port_offload_cap_display(i);
7575 cmdline_parse_token_string_t cmd_showportall_show =
7576 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7578 cmdline_parse_token_string_t cmd_showportall_port =
7579 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7580 cmdline_parse_token_string_t cmd_showportall_what =
7581 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7582 "info#summary#stats#xstats#fdir#dcb_tc#cap");
7583 cmdline_parse_token_string_t cmd_showportall_all =
7584 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7585 cmdline_parse_inst_t cmd_showportall = {
7586 .f = cmd_showportall_parsed,
7588 .help_str = "show|clear port "
7589 "info|summary|stats|xstats|fdir|dcb_tc|cap all",
7591 (void *)&cmd_showportall_show,
7592 (void *)&cmd_showportall_port,
7593 (void *)&cmd_showportall_what,
7594 (void *)&cmd_showportall_all,
7599 /* *** SHOW PORT INFO *** */
7600 struct cmd_showport_result {
7601 cmdline_fixed_string_t show;
7602 cmdline_fixed_string_t port;
7603 cmdline_fixed_string_t what;
7607 static void cmd_showport_parsed(void *parsed_result,
7608 __rte_unused struct cmdline *cl,
7609 __rte_unused void *data)
7611 struct cmd_showport_result *res = parsed_result;
7612 if (!strcmp(res->show, "clear")) {
7613 if (!strcmp(res->what, "stats"))
7614 nic_stats_clear(res->portnum);
7615 else if (!strcmp(res->what, "xstats"))
7616 nic_xstats_clear(res->portnum);
7617 } else if (!strcmp(res->what, "info"))
7618 port_infos_display(res->portnum);
7619 else if (!strcmp(res->what, "summary")) {
7620 port_summary_header_display();
7621 port_summary_display(res->portnum);
7623 else if (!strcmp(res->what, "stats"))
7624 nic_stats_display(res->portnum);
7625 else if (!strcmp(res->what, "xstats"))
7626 nic_xstats_display(res->portnum);
7627 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7628 else if (!strcmp(res->what, "fdir"))
7629 fdir_get_infos(res->portnum);
7631 else if (!strcmp(res->what, "dcb_tc"))
7632 port_dcb_info_display(res->portnum);
7633 else if (!strcmp(res->what, "cap"))
7634 port_offload_cap_display(res->portnum);
7637 cmdline_parse_token_string_t cmd_showport_show =
7638 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7640 cmdline_parse_token_string_t cmd_showport_port =
7641 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7642 cmdline_parse_token_string_t cmd_showport_what =
7643 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7644 "info#summary#stats#xstats#fdir#dcb_tc#cap");
7645 cmdline_parse_token_num_t cmd_showport_portnum =
7646 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
7648 cmdline_parse_inst_t cmd_showport = {
7649 .f = cmd_showport_parsed,
7651 .help_str = "show|clear port "
7652 "info|summary|stats|xstats|fdir|dcb_tc|cap "
7655 (void *)&cmd_showport_show,
7656 (void *)&cmd_showport_port,
7657 (void *)&cmd_showport_what,
7658 (void *)&cmd_showport_portnum,
7663 /* *** SHOW DEVICE INFO *** */
7664 struct cmd_showdevice_result {
7665 cmdline_fixed_string_t show;
7666 cmdline_fixed_string_t device;
7667 cmdline_fixed_string_t what;
7668 cmdline_fixed_string_t identifier;
7671 static void cmd_showdevice_parsed(void *parsed_result,
7672 __rte_unused struct cmdline *cl,
7673 __rte_unused void *data)
7675 struct cmd_showdevice_result *res = parsed_result;
7676 if (!strcmp(res->what, "info")) {
7677 if (!strcmp(res->identifier, "all"))
7678 device_infos_display(NULL);
7680 device_infos_display(res->identifier);
7684 cmdline_parse_token_string_t cmd_showdevice_show =
7685 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7687 cmdline_parse_token_string_t cmd_showdevice_device =
7688 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7689 cmdline_parse_token_string_t cmd_showdevice_what =
7690 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7692 cmdline_parse_token_string_t cmd_showdevice_identifier =
7693 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7696 cmdline_parse_inst_t cmd_showdevice = {
7697 .f = cmd_showdevice_parsed,
7699 .help_str = "show device info <identifier>|all",
7701 (void *)&cmd_showdevice_show,
7702 (void *)&cmd_showdevice_device,
7703 (void *)&cmd_showdevice_what,
7704 (void *)&cmd_showdevice_identifier,
7709 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7710 struct cmd_showeeprom_result {
7711 cmdline_fixed_string_t show;
7712 cmdline_fixed_string_t port;
7714 cmdline_fixed_string_t type;
7717 static void cmd_showeeprom_parsed(void *parsed_result,
7718 __rte_unused struct cmdline *cl,
7719 __rte_unused void *data)
7721 struct cmd_showeeprom_result *res = parsed_result;
7723 if (!strcmp(res->type, "eeprom"))
7724 port_eeprom_display(res->portnum);
7725 else if (!strcmp(res->type, "module_eeprom"))
7726 port_module_eeprom_display(res->portnum);
7728 printf("Unknown argument\n");
7731 cmdline_parse_token_string_t cmd_showeeprom_show =
7732 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7733 cmdline_parse_token_string_t cmd_showeeprom_port =
7734 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7735 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7736 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7738 cmdline_parse_token_string_t cmd_showeeprom_type =
7739 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7741 cmdline_parse_inst_t cmd_showeeprom = {
7742 .f = cmd_showeeprom_parsed,
7744 .help_str = "show port <port_id> module_eeprom|eeprom",
7746 (void *)&cmd_showeeprom_show,
7747 (void *)&cmd_showeeprom_port,
7748 (void *)&cmd_showeeprom_portnum,
7749 (void *)&cmd_showeeprom_type,
7754 /* *** SHOW QUEUE INFO *** */
7755 struct cmd_showqueue_result {
7756 cmdline_fixed_string_t show;
7757 cmdline_fixed_string_t type;
7758 cmdline_fixed_string_t what;
7764 cmd_showqueue_parsed(void *parsed_result,
7765 __rte_unused struct cmdline *cl,
7766 __rte_unused void *data)
7768 struct cmd_showqueue_result *res = parsed_result;
7770 if (!strcmp(res->type, "rxq"))
7771 rx_queue_infos_display(res->portnum, res->queuenum);
7772 else if (!strcmp(res->type, "txq"))
7773 tx_queue_infos_display(res->portnum, res->queuenum);
7776 cmdline_parse_token_string_t cmd_showqueue_show =
7777 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7778 cmdline_parse_token_string_t cmd_showqueue_type =
7779 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7780 cmdline_parse_token_string_t cmd_showqueue_what =
7781 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7782 cmdline_parse_token_num_t cmd_showqueue_portnum =
7783 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
7785 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7786 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
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, RTE_UINT16);
7869 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7870 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_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,
7966 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7967 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
7969 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7970 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
7973 cmdline_parse_inst_t cmd_read_reg_bit = {
7974 .f = cmd_read_reg_bit_parsed,
7976 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7978 (void *)&cmd_read_reg_bit_read,
7979 (void *)&cmd_read_reg_bit_regbit,
7980 (void *)&cmd_read_reg_bit_port_id,
7981 (void *)&cmd_read_reg_bit_reg_off,
7982 (void *)&cmd_read_reg_bit_bit_pos,
7987 /* *** WRITE PORT REGISTER *** */
7988 struct cmd_write_reg_result {
7989 cmdline_fixed_string_t write;
7990 cmdline_fixed_string_t reg;
7997 cmd_write_reg_parsed(void *parsed_result,
7998 __rte_unused struct cmdline *cl,
7999 __rte_unused void *data)
8001 struct cmd_write_reg_result *res = parsed_result;
8002 port_reg_set(res->port_id, res->reg_off, res->value);
8005 cmdline_parse_token_string_t cmd_write_reg_write =
8006 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8007 cmdline_parse_token_string_t cmd_write_reg_reg =
8008 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8009 cmdline_parse_token_num_t cmd_write_reg_port_id =
8010 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8011 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8012 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8013 cmdline_parse_token_num_t cmd_write_reg_value =
8014 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8016 cmdline_parse_inst_t cmd_write_reg = {
8017 .f = cmd_write_reg_parsed,
8019 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8021 (void *)&cmd_write_reg_write,
8022 (void *)&cmd_write_reg_reg,
8023 (void *)&cmd_write_reg_port_id,
8024 (void *)&cmd_write_reg_reg_off,
8025 (void *)&cmd_write_reg_value,
8030 /* *** WRITE PORT REGISTER BIT FIELD *** */
8031 struct cmd_write_reg_bit_field_result {
8032 cmdline_fixed_string_t write;
8033 cmdline_fixed_string_t regfield;
8042 cmd_write_reg_bit_field_parsed(void *parsed_result,
8043 __rte_unused struct cmdline *cl,
8044 __rte_unused void *data)
8046 struct cmd_write_reg_bit_field_result *res = parsed_result;
8047 port_reg_bit_field_set(res->port_id, res->reg_off,
8048 res->bit1_pos, res->bit2_pos, res->value);
8051 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8052 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8054 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8055 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8056 regfield, "regfield");
8057 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8058 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8060 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8061 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8063 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8064 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8066 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8067 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8069 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8070 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8073 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8074 .f = cmd_write_reg_bit_field_parsed,
8076 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8078 "Set register bit field between bit_x and bit_y included",
8080 (void *)&cmd_write_reg_bit_field_write,
8081 (void *)&cmd_write_reg_bit_field_regfield,
8082 (void *)&cmd_write_reg_bit_field_port_id,
8083 (void *)&cmd_write_reg_bit_field_reg_off,
8084 (void *)&cmd_write_reg_bit_field_bit1_pos,
8085 (void *)&cmd_write_reg_bit_field_bit2_pos,
8086 (void *)&cmd_write_reg_bit_field_value,
8091 /* *** WRITE PORT REGISTER BIT *** */
8092 struct cmd_write_reg_bit_result {
8093 cmdline_fixed_string_t write;
8094 cmdline_fixed_string_t regbit;
8102 cmd_write_reg_bit_parsed(void *parsed_result,
8103 __rte_unused struct cmdline *cl,
8104 __rte_unused void *data)
8106 struct cmd_write_reg_bit_result *res = parsed_result;
8107 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8110 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8111 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8113 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8114 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8116 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8117 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8119 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8120 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8122 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8123 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8125 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8126 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8129 cmdline_parse_inst_t cmd_write_reg_bit = {
8130 .f = cmd_write_reg_bit_parsed,
8132 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8135 (void *)&cmd_write_reg_bit_write,
8136 (void *)&cmd_write_reg_bit_regbit,
8137 (void *)&cmd_write_reg_bit_port_id,
8138 (void *)&cmd_write_reg_bit_reg_off,
8139 (void *)&cmd_write_reg_bit_bit_pos,
8140 (void *)&cmd_write_reg_bit_value,
8145 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8146 struct cmd_read_rxd_txd_result {
8147 cmdline_fixed_string_t read;
8148 cmdline_fixed_string_t rxd_txd;
8155 cmd_read_rxd_txd_parsed(void *parsed_result,
8156 __rte_unused struct cmdline *cl,
8157 __rte_unused void *data)
8159 struct cmd_read_rxd_txd_result *res = parsed_result;
8161 if (!strcmp(res->rxd_txd, "rxd"))
8162 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8163 else if (!strcmp(res->rxd_txd, "txd"))
8164 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8167 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8168 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8169 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8170 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8172 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8173 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8175 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8176 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8178 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8179 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8182 cmdline_parse_inst_t cmd_read_rxd_txd = {
8183 .f = cmd_read_rxd_txd_parsed,
8185 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8187 (void *)&cmd_read_rxd_txd_read,
8188 (void *)&cmd_read_rxd_txd_rxd_txd,
8189 (void *)&cmd_read_rxd_txd_port_id,
8190 (void *)&cmd_read_rxd_txd_queue_id,
8191 (void *)&cmd_read_rxd_txd_desc_id,
8197 struct cmd_quit_result {
8198 cmdline_fixed_string_t quit;
8201 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8203 __rte_unused void *data)
8208 cmdline_parse_token_string_t cmd_quit_quit =
8209 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8211 cmdline_parse_inst_t cmd_quit = {
8212 .f = cmd_quit_parsed,
8214 .help_str = "quit: Exit application",
8216 (void *)&cmd_quit_quit,
8221 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8222 struct cmd_mac_addr_result {
8223 cmdline_fixed_string_t mac_addr_cmd;
8224 cmdline_fixed_string_t what;
8226 struct rte_ether_addr address;
8229 static void cmd_mac_addr_parsed(void *parsed_result,
8230 __rte_unused struct cmdline *cl,
8231 __rte_unused void *data)
8233 struct cmd_mac_addr_result *res = parsed_result;
8236 if (strcmp(res->what, "add") == 0)
8237 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8238 else if (strcmp(res->what, "set") == 0)
8239 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8242 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8244 /* check the return value and print it if is < 0 */
8246 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
8250 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8251 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8253 cmdline_parse_token_string_t cmd_mac_addr_what =
8254 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8256 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8257 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8259 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8260 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8262 cmdline_parse_inst_t cmd_mac_addr = {
8263 .f = cmd_mac_addr_parsed,
8265 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8266 "Add/Remove/Set MAC address on port_id",
8268 (void *)&cmd_mac_addr_cmd,
8269 (void *)&cmd_mac_addr_what,
8270 (void *)&cmd_mac_addr_portnum,
8271 (void *)&cmd_mac_addr_addr,
8276 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8277 struct cmd_eth_peer_result {
8278 cmdline_fixed_string_t set;
8279 cmdline_fixed_string_t eth_peer;
8281 cmdline_fixed_string_t peer_addr;
8284 static void cmd_set_eth_peer_parsed(void *parsed_result,
8285 __rte_unused struct cmdline *cl,
8286 __rte_unused void *data)
8288 struct cmd_eth_peer_result *res = parsed_result;
8290 if (test_done == 0) {
8291 printf("Please stop forwarding first\n");
8294 if (!strcmp(res->eth_peer, "eth-peer")) {
8295 set_fwd_eth_peer(res->port_id, res->peer_addr);
8299 cmdline_parse_token_string_t cmd_eth_peer_set =
8300 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8301 cmdline_parse_token_string_t cmd_eth_peer =
8302 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8303 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8304 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8306 cmdline_parse_token_string_t cmd_eth_peer_addr =
8307 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8309 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8310 .f = cmd_set_eth_peer_parsed,
8312 .help_str = "set eth-peer <port_id> <peer_mac>",
8314 (void *)&cmd_eth_peer_set,
8315 (void *)&cmd_eth_peer,
8316 (void *)&cmd_eth_peer_port_id,
8317 (void *)&cmd_eth_peer_addr,
8322 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8323 struct cmd_set_qmap_result {
8324 cmdline_fixed_string_t set;
8325 cmdline_fixed_string_t qmap;
8326 cmdline_fixed_string_t what;
8333 cmd_set_qmap_parsed(void *parsed_result,
8334 __rte_unused struct cmdline *cl,
8335 __rte_unused void *data)
8337 struct cmd_set_qmap_result *res = parsed_result;
8338 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8340 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8343 cmdline_parse_token_string_t cmd_setqmap_set =
8344 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8346 cmdline_parse_token_string_t cmd_setqmap_qmap =
8347 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8349 cmdline_parse_token_string_t cmd_setqmap_what =
8350 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8352 cmdline_parse_token_num_t cmd_setqmap_portid =
8353 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8354 port_id, RTE_UINT16);
8355 cmdline_parse_token_num_t cmd_setqmap_queueid =
8356 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8357 queue_id, RTE_UINT16);
8358 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8359 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8360 map_value, RTE_UINT8);
8362 cmdline_parse_inst_t cmd_set_qmap = {
8363 .f = cmd_set_qmap_parsed,
8365 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8366 "Set statistics mapping value on tx|rx queue_id of port_id",
8368 (void *)&cmd_setqmap_set,
8369 (void *)&cmd_setqmap_qmap,
8370 (void *)&cmd_setqmap_what,
8371 (void *)&cmd_setqmap_portid,
8372 (void *)&cmd_setqmap_queueid,
8373 (void *)&cmd_setqmap_mapvalue,
8378 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8379 struct cmd_set_xstats_hide_zero_result {
8380 cmdline_fixed_string_t keyword;
8381 cmdline_fixed_string_t name;
8382 cmdline_fixed_string_t on_off;
8386 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8387 __rte_unused struct cmdline *cl,
8388 __rte_unused void *data)
8390 struct cmd_set_xstats_hide_zero_result *res;
8391 uint16_t on_off = 0;
8393 res = parsed_result;
8394 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8395 set_xstats_hide_zero(on_off);
8398 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8399 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8401 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8402 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8403 name, "xstats-hide-zero");
8404 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8405 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8408 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8409 .f = cmd_set_xstats_hide_zero_parsed,
8411 .help_str = "set xstats-hide-zero on|off",
8413 (void *)&cmd_set_xstats_hide_zero_keyword,
8414 (void *)&cmd_set_xstats_hide_zero_name,
8415 (void *)&cmd_set_xstats_hide_zero_on_off,
8420 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8421 struct cmd_set_record_core_cycles_result {
8422 cmdline_fixed_string_t keyword;
8423 cmdline_fixed_string_t name;
8424 cmdline_fixed_string_t on_off;
8428 cmd_set_record_core_cycles_parsed(void *parsed_result,
8429 __rte_unused struct cmdline *cl,
8430 __rte_unused void *data)
8432 struct cmd_set_record_core_cycles_result *res;
8433 uint16_t on_off = 0;
8435 res = parsed_result;
8436 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8437 set_record_core_cycles(on_off);
8440 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8441 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8443 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8444 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8445 name, "record-core-cycles");
8446 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8447 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8450 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8451 .f = cmd_set_record_core_cycles_parsed,
8453 .help_str = "set record-core-cycles on|off",
8455 (void *)&cmd_set_record_core_cycles_keyword,
8456 (void *)&cmd_set_record_core_cycles_name,
8457 (void *)&cmd_set_record_core_cycles_on_off,
8462 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8463 struct cmd_set_record_burst_stats_result {
8464 cmdline_fixed_string_t keyword;
8465 cmdline_fixed_string_t name;
8466 cmdline_fixed_string_t on_off;
8470 cmd_set_record_burst_stats_parsed(void *parsed_result,
8471 __rte_unused struct cmdline *cl,
8472 __rte_unused void *data)
8474 struct cmd_set_record_burst_stats_result *res;
8475 uint16_t on_off = 0;
8477 res = parsed_result;
8478 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8479 set_record_burst_stats(on_off);
8482 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8483 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8485 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8486 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8487 name, "record-burst-stats");
8488 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8489 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8492 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8493 .f = cmd_set_record_burst_stats_parsed,
8495 .help_str = "set record-burst-stats on|off",
8497 (void *)&cmd_set_record_burst_stats_keyword,
8498 (void *)&cmd_set_record_burst_stats_name,
8499 (void *)&cmd_set_record_burst_stats_on_off,
8504 /* *** CONFIGURE UNICAST HASH TABLE *** */
8505 struct cmd_set_uc_hash_table {
8506 cmdline_fixed_string_t set;
8507 cmdline_fixed_string_t port;
8509 cmdline_fixed_string_t what;
8510 struct rte_ether_addr address;
8511 cmdline_fixed_string_t mode;
8515 cmd_set_uc_hash_parsed(void *parsed_result,
8516 __rte_unused struct cmdline *cl,
8517 __rte_unused void *data)
8520 struct cmd_set_uc_hash_table *res = parsed_result;
8522 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8524 if (strcmp(res->what, "uta") == 0)
8525 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8526 &res->address,(uint8_t)is_on);
8528 printf("bad unicast hash table parameter, return code = %d \n", ret);
8532 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8533 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8535 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8536 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8538 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8539 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8540 port_id, RTE_UINT16);
8541 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8542 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8544 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8545 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8547 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8548 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8551 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8552 .f = cmd_set_uc_hash_parsed,
8554 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8556 (void *)&cmd_set_uc_hash_set,
8557 (void *)&cmd_set_uc_hash_port,
8558 (void *)&cmd_set_uc_hash_portid,
8559 (void *)&cmd_set_uc_hash_what,
8560 (void *)&cmd_set_uc_hash_mac,
8561 (void *)&cmd_set_uc_hash_mode,
8566 struct cmd_set_uc_all_hash_table {
8567 cmdline_fixed_string_t set;
8568 cmdline_fixed_string_t port;
8570 cmdline_fixed_string_t what;
8571 cmdline_fixed_string_t value;
8572 cmdline_fixed_string_t mode;
8576 cmd_set_uc_all_hash_parsed(void *parsed_result,
8577 __rte_unused struct cmdline *cl,
8578 __rte_unused void *data)
8581 struct cmd_set_uc_all_hash_table *res = parsed_result;
8583 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8585 if ((strcmp(res->what, "uta") == 0) &&
8586 (strcmp(res->value, "all") == 0))
8587 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8589 printf("bad unicast hash table parameter,"
8590 "return code = %d \n", ret);
8593 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8594 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8596 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8597 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8599 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8600 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8601 port_id, RTE_UINT16);
8602 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8603 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8605 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8606 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8608 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8609 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8612 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8613 .f = cmd_set_uc_all_hash_parsed,
8615 .help_str = "set port <port_id> uta all on|off",
8617 (void *)&cmd_set_uc_all_hash_set,
8618 (void *)&cmd_set_uc_all_hash_port,
8619 (void *)&cmd_set_uc_all_hash_portid,
8620 (void *)&cmd_set_uc_all_hash_what,
8621 (void *)&cmd_set_uc_all_hash_value,
8622 (void *)&cmd_set_uc_all_hash_mode,
8627 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8628 struct cmd_set_vf_traffic {
8629 cmdline_fixed_string_t set;
8630 cmdline_fixed_string_t port;
8632 cmdline_fixed_string_t vf;
8634 cmdline_fixed_string_t what;
8635 cmdline_fixed_string_t mode;
8639 cmd_set_vf_traffic_parsed(void *parsed_result,
8640 __rte_unused struct cmdline *cl,
8641 __rte_unused void *data)
8643 struct cmd_set_vf_traffic *res = parsed_result;
8644 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8645 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8647 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8650 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8651 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8653 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8654 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8656 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8657 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8658 port_id, RTE_UINT16);
8659 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8660 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8662 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8663 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8665 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8666 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8668 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8669 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8672 cmdline_parse_inst_t cmd_set_vf_traffic = {
8673 .f = cmd_set_vf_traffic_parsed,
8675 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8677 (void *)&cmd_setvf_traffic_set,
8678 (void *)&cmd_setvf_traffic_port,
8679 (void *)&cmd_setvf_traffic_portid,
8680 (void *)&cmd_setvf_traffic_vf,
8681 (void *)&cmd_setvf_traffic_vfid,
8682 (void *)&cmd_setvf_traffic_what,
8683 (void *)&cmd_setvf_traffic_mode,
8688 /* *** CONFIGURE VF RECEIVE MODE *** */
8689 struct cmd_set_vf_rxmode {
8690 cmdline_fixed_string_t set;
8691 cmdline_fixed_string_t port;
8693 cmdline_fixed_string_t vf;
8695 cmdline_fixed_string_t what;
8696 cmdline_fixed_string_t mode;
8697 cmdline_fixed_string_t on;
8701 cmd_set_vf_rxmode_parsed(void *parsed_result,
8702 __rte_unused struct cmdline *cl,
8703 __rte_unused void *data)
8706 uint16_t vf_rxmode = 0;
8707 struct cmd_set_vf_rxmode *res = parsed_result;
8709 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8710 if (!strcmp(res->what,"rxmode")) {
8711 if (!strcmp(res->mode, "AUPE"))
8712 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8713 else if (!strcmp(res->mode, "ROPE"))
8714 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8715 else if (!strcmp(res->mode, "BAM"))
8716 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8717 else if (!strncmp(res->mode, "MPE",3))
8718 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8721 RTE_SET_USED(is_on);
8723 #ifdef RTE_NET_IXGBE
8724 if (ret == -ENOTSUP)
8725 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8726 vf_rxmode, (uint8_t)is_on);
8729 if (ret == -ENOTSUP)
8730 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8731 vf_rxmode, (uint8_t)is_on);
8734 printf("bad VF receive mode parameter, return code = %d \n",
8738 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8739 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8741 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8742 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8744 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8745 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8746 port_id, RTE_UINT16);
8747 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8748 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8750 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8751 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8753 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8754 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8756 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8757 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8758 mode, "AUPE#ROPE#BAM#MPE");
8759 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8760 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8763 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8764 .f = cmd_set_vf_rxmode_parsed,
8766 .help_str = "set port <port_id> vf <vf_id> rxmode "
8767 "AUPE|ROPE|BAM|MPE on|off",
8769 (void *)&cmd_set_vf_rxmode_set,
8770 (void *)&cmd_set_vf_rxmode_port,
8771 (void *)&cmd_set_vf_rxmode_portid,
8772 (void *)&cmd_set_vf_rxmode_vf,
8773 (void *)&cmd_set_vf_rxmode_vfid,
8774 (void *)&cmd_set_vf_rxmode_what,
8775 (void *)&cmd_set_vf_rxmode_mode,
8776 (void *)&cmd_set_vf_rxmode_on,
8781 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8782 struct cmd_vf_mac_addr_result {
8783 cmdline_fixed_string_t mac_addr_cmd;
8784 cmdline_fixed_string_t what;
8785 cmdline_fixed_string_t port;
8787 cmdline_fixed_string_t vf;
8789 struct rte_ether_addr address;
8792 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8793 __rte_unused struct cmdline *cl,
8794 __rte_unused void *data)
8796 struct cmd_vf_mac_addr_result *res = parsed_result;
8799 if (strcmp(res->what, "add") != 0)
8803 if (ret == -ENOTSUP)
8804 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8808 if (ret == -ENOTSUP)
8809 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8814 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8818 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8819 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8820 mac_addr_cmd,"mac_addr");
8821 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8822 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8824 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8825 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8827 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8828 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8829 port_num, RTE_UINT16);
8830 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8831 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8833 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8834 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8836 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8837 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8840 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8841 .f = cmd_vf_mac_addr_parsed,
8843 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8844 "Add MAC address filtering for a VF on port_id",
8846 (void *)&cmd_vf_mac_addr_cmd,
8847 (void *)&cmd_vf_mac_addr_what,
8848 (void *)&cmd_vf_mac_addr_port,
8849 (void *)&cmd_vf_mac_addr_portnum,
8850 (void *)&cmd_vf_mac_addr_vf,
8851 (void *)&cmd_vf_mac_addr_vfnum,
8852 (void *)&cmd_vf_mac_addr_addr,
8857 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8858 struct cmd_vf_rx_vlan_filter {
8859 cmdline_fixed_string_t rx_vlan;
8860 cmdline_fixed_string_t what;
8862 cmdline_fixed_string_t port;
8864 cmdline_fixed_string_t vf;
8869 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8870 __rte_unused struct cmdline *cl,
8871 __rte_unused void *data)
8873 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8876 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8878 #ifdef RTE_NET_IXGBE
8879 if (ret == -ENOTSUP)
8880 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8881 res->vlan_id, res->vf_mask, is_add);
8884 if (ret == -ENOTSUP)
8885 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8886 res->vlan_id, res->vf_mask, is_add);
8889 if (ret == -ENOTSUP)
8890 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8891 res->vlan_id, res->vf_mask, is_add);
8898 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8899 res->vlan_id, res->vf_mask);
8902 printf("invalid port_id %d\n", res->port_id);
8905 printf("function not implemented or supported\n");
8908 printf("programming error: (%s)\n", strerror(-ret));
8912 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8913 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8914 rx_vlan, "rx_vlan");
8915 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8916 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8918 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8919 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8920 vlan_id, RTE_UINT16);
8921 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8922 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8924 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8925 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8926 port_id, RTE_UINT16);
8927 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8928 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8930 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8931 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8932 vf_mask, RTE_UINT64);
8934 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8935 .f = cmd_vf_rx_vlan_filter_parsed,
8937 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8938 "(vf_mask = hexadecimal VF mask)",
8940 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8941 (void *)&cmd_vf_rx_vlan_filter_what,
8942 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8943 (void *)&cmd_vf_rx_vlan_filter_port,
8944 (void *)&cmd_vf_rx_vlan_filter_portid,
8945 (void *)&cmd_vf_rx_vlan_filter_vf,
8946 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8951 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8952 struct cmd_queue_rate_limit_result {
8953 cmdline_fixed_string_t set;
8954 cmdline_fixed_string_t port;
8956 cmdline_fixed_string_t queue;
8958 cmdline_fixed_string_t rate;
8962 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8963 __rte_unused struct cmdline *cl,
8964 __rte_unused void *data)
8966 struct cmd_queue_rate_limit_result *res = parsed_result;
8969 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8970 && (strcmp(res->queue, "queue") == 0)
8971 && (strcmp(res->rate, "rate") == 0))
8972 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8975 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8979 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8980 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8982 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8983 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8985 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8986 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8987 port_num, RTE_UINT16);
8988 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8989 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8991 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8992 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8993 queue_num, RTE_UINT8);
8994 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8995 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8997 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8998 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8999 rate_num, RTE_UINT16);
9001 cmdline_parse_inst_t cmd_queue_rate_limit = {
9002 .f = cmd_queue_rate_limit_parsed,
9004 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9005 "Set rate limit for a queue on port_id",
9007 (void *)&cmd_queue_rate_limit_set,
9008 (void *)&cmd_queue_rate_limit_port,
9009 (void *)&cmd_queue_rate_limit_portnum,
9010 (void *)&cmd_queue_rate_limit_queue,
9011 (void *)&cmd_queue_rate_limit_queuenum,
9012 (void *)&cmd_queue_rate_limit_rate,
9013 (void *)&cmd_queue_rate_limit_ratenum,
9018 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9019 struct cmd_vf_rate_limit_result {
9020 cmdline_fixed_string_t set;
9021 cmdline_fixed_string_t port;
9023 cmdline_fixed_string_t vf;
9025 cmdline_fixed_string_t rate;
9027 cmdline_fixed_string_t q_msk;
9031 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9032 __rte_unused struct cmdline *cl,
9033 __rte_unused void *data)
9035 struct cmd_vf_rate_limit_result *res = parsed_result;
9038 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9039 && (strcmp(res->vf, "vf") == 0)
9040 && (strcmp(res->rate, "rate") == 0)
9041 && (strcmp(res->q_msk, "queue_mask") == 0))
9042 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9043 res->rate_num, res->q_msk_val);
9045 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
9049 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9050 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9052 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9053 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9055 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9056 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9057 port_num, RTE_UINT16);
9058 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9059 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9061 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9062 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9064 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9065 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9067 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9068 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9069 rate_num, RTE_UINT16);
9070 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9071 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9072 q_msk, "queue_mask");
9073 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9074 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9075 q_msk_val, RTE_UINT64);
9077 cmdline_parse_inst_t cmd_vf_rate_limit = {
9078 .f = cmd_vf_rate_limit_parsed,
9080 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9081 "queue_mask <queue_mask_value>: "
9082 "Set rate limit for queues of VF on port_id",
9084 (void *)&cmd_vf_rate_limit_set,
9085 (void *)&cmd_vf_rate_limit_port,
9086 (void *)&cmd_vf_rate_limit_portnum,
9087 (void *)&cmd_vf_rate_limit_vf,
9088 (void *)&cmd_vf_rate_limit_vfnum,
9089 (void *)&cmd_vf_rate_limit_rate,
9090 (void *)&cmd_vf_rate_limit_ratenum,
9091 (void *)&cmd_vf_rate_limit_q_msk,
9092 (void *)&cmd_vf_rate_limit_q_msk_val,
9097 /* *** CONFIGURE TUNNEL UDP PORT *** */
9098 struct cmd_tunnel_udp_config {
9099 cmdline_fixed_string_t cmd;
9100 cmdline_fixed_string_t what;
9106 cmd_tunnel_udp_config_parsed(void *parsed_result,
9107 __rte_unused struct cmdline *cl,
9108 __rte_unused void *data)
9110 struct cmd_tunnel_udp_config *res = parsed_result;
9111 struct rte_eth_udp_tunnel tunnel_udp;
9114 tunnel_udp.udp_port = res->udp_port;
9116 if (!strcmp(res->cmd, "rx_vxlan_port"))
9117 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9119 if (!strcmp(res->what, "add"))
9120 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9123 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9127 printf("udp tunneling add error: (%s)\n", strerror(-ret));
9130 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
9131 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9132 cmd, "rx_vxlan_port");
9133 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9134 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9136 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9137 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9138 udp_port, RTE_UINT16);
9139 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9140 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9141 port_id, RTE_UINT16);
9143 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9144 .f = cmd_tunnel_udp_config_parsed,
9146 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9147 "Add/Remove a tunneling UDP port filter",
9149 (void *)&cmd_tunnel_udp_config_cmd,
9150 (void *)&cmd_tunnel_udp_config_what,
9151 (void *)&cmd_tunnel_udp_config_udp_port,
9152 (void *)&cmd_tunnel_udp_config_port_id,
9157 struct cmd_config_tunnel_udp_port {
9158 cmdline_fixed_string_t port;
9159 cmdline_fixed_string_t config;
9161 cmdline_fixed_string_t udp_tunnel_port;
9162 cmdline_fixed_string_t action;
9163 cmdline_fixed_string_t tunnel_type;
9168 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9169 __rte_unused struct cmdline *cl,
9170 __rte_unused void *data)
9172 struct cmd_config_tunnel_udp_port *res = parsed_result;
9173 struct rte_eth_udp_tunnel tunnel_udp;
9176 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9179 tunnel_udp.udp_port = res->udp_port;
9181 if (!strcmp(res->tunnel_type, "vxlan")) {
9182 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9183 } else if (!strcmp(res->tunnel_type, "geneve")) {
9184 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9185 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9186 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9187 } else if (!strcmp(res->tunnel_type, "ecpri")) {
9188 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_ECPRI;
9190 printf("Invalid tunnel type\n");
9194 if (!strcmp(res->action, "add"))
9195 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9198 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9202 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
9205 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9206 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9208 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9209 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9211 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9212 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9214 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9215 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9218 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9219 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9221 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9222 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9223 "vxlan#geneve#vxlan-gpe#ecpri");
9224 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9225 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9228 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9229 .f = cmd_cfg_tunnel_udp_port_parsed,
9231 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9232 "geneve|vxlan-gpe|ecpri <udp_port>",
9234 (void *)&cmd_config_tunnel_udp_port_port,
9235 (void *)&cmd_config_tunnel_udp_port_config,
9236 (void *)&cmd_config_tunnel_udp_port_port_id,
9237 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9238 (void *)&cmd_config_tunnel_udp_port_action,
9239 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9240 (void *)&cmd_config_tunnel_udp_port_value,
9245 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9246 struct cmd_set_mirror_mask_result {
9247 cmdline_fixed_string_t set;
9248 cmdline_fixed_string_t port;
9250 cmdline_fixed_string_t mirror;
9252 cmdline_fixed_string_t what;
9253 cmdline_fixed_string_t value;
9254 cmdline_fixed_string_t dstpool;
9256 cmdline_fixed_string_t on;
9259 cmdline_parse_token_string_t cmd_mirror_mask_set =
9260 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9262 cmdline_parse_token_string_t cmd_mirror_mask_port =
9263 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9265 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9266 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9267 port_id, RTE_UINT16);
9268 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9269 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9270 mirror, "mirror-rule");
9271 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9272 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9273 rule_id, RTE_UINT8);
9274 cmdline_parse_token_string_t cmd_mirror_mask_what =
9275 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9276 what, "pool-mirror-up#pool-mirror-down"
9278 cmdline_parse_token_string_t cmd_mirror_mask_value =
9279 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9281 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9282 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9283 dstpool, "dst-pool");
9284 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9285 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9286 dstpool_id, RTE_UINT8);
9287 cmdline_parse_token_string_t cmd_mirror_mask_on =
9288 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9292 cmd_set_mirror_mask_parsed(void *parsed_result,
9293 __rte_unused struct cmdline *cl,
9294 __rte_unused void *data)
9297 struct cmd_set_mirror_mask_result *res = parsed_result;
9298 struct rte_eth_mirror_conf mr_conf;
9300 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9302 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9304 mr_conf.dst_pool = res->dstpool_id;
9306 if (!strcmp(res->what, "pool-mirror-up")) {
9307 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9308 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9309 } else if (!strcmp(res->what, "pool-mirror-down")) {
9310 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9311 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9312 } else if (!strcmp(res->what, "vlan-mirror")) {
9313 mr_conf.rule_type = ETH_MIRROR_VLAN;
9314 nb_item = parse_item_list(res->value, "vlan",
9315 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9319 for (i = 0; i < nb_item; i++) {
9320 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9321 printf("Invalid vlan_id: must be < 4096\n");
9325 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9326 mr_conf.vlan.vlan_mask |= 1ULL << i;
9330 if (!strcmp(res->on, "on"))
9331 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9334 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9337 printf("mirror rule add error: (%s)\n", strerror(-ret));
9340 cmdline_parse_inst_t cmd_set_mirror_mask = {
9341 .f = cmd_set_mirror_mask_parsed,
9343 .help_str = "set port <port_id> mirror-rule <rule_id> "
9344 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9345 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9347 (void *)&cmd_mirror_mask_set,
9348 (void *)&cmd_mirror_mask_port,
9349 (void *)&cmd_mirror_mask_portid,
9350 (void *)&cmd_mirror_mask_mirror,
9351 (void *)&cmd_mirror_mask_ruleid,
9352 (void *)&cmd_mirror_mask_what,
9353 (void *)&cmd_mirror_mask_value,
9354 (void *)&cmd_mirror_mask_dstpool,
9355 (void *)&cmd_mirror_mask_poolid,
9356 (void *)&cmd_mirror_mask_on,
9361 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9362 struct cmd_set_mirror_link_result {
9363 cmdline_fixed_string_t set;
9364 cmdline_fixed_string_t port;
9366 cmdline_fixed_string_t mirror;
9368 cmdline_fixed_string_t what;
9369 cmdline_fixed_string_t dstpool;
9371 cmdline_fixed_string_t on;
9374 cmdline_parse_token_string_t cmd_mirror_link_set =
9375 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9377 cmdline_parse_token_string_t cmd_mirror_link_port =
9378 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9380 cmdline_parse_token_num_t cmd_mirror_link_portid =
9381 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9382 port_id, RTE_UINT16);
9383 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9384 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9385 mirror, "mirror-rule");
9386 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9387 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9388 rule_id, RTE_UINT8);
9389 cmdline_parse_token_string_t cmd_mirror_link_what =
9390 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9391 what, "uplink-mirror#downlink-mirror");
9392 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9393 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9394 dstpool, "dst-pool");
9395 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9396 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9397 dstpool_id, RTE_UINT8);
9398 cmdline_parse_token_string_t cmd_mirror_link_on =
9399 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9403 cmd_set_mirror_link_parsed(void *parsed_result,
9404 __rte_unused struct cmdline *cl,
9405 __rte_unused void *data)
9408 struct cmd_set_mirror_link_result *res = parsed_result;
9409 struct rte_eth_mirror_conf mr_conf;
9411 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9412 if (!strcmp(res->what, "uplink-mirror"))
9413 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9415 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9417 mr_conf.dst_pool = res->dstpool_id;
9419 if (!strcmp(res->on, "on"))
9420 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9423 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9426 /* check the return value and print it if is < 0 */
9428 printf("mirror rule add error: (%s)\n", strerror(-ret));
9432 cmdline_parse_inst_t cmd_set_mirror_link = {
9433 .f = cmd_set_mirror_link_parsed,
9435 .help_str = "set port <port_id> mirror-rule <rule_id> "
9436 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9438 (void *)&cmd_mirror_link_set,
9439 (void *)&cmd_mirror_link_port,
9440 (void *)&cmd_mirror_link_portid,
9441 (void *)&cmd_mirror_link_mirror,
9442 (void *)&cmd_mirror_link_ruleid,
9443 (void *)&cmd_mirror_link_what,
9444 (void *)&cmd_mirror_link_dstpool,
9445 (void *)&cmd_mirror_link_poolid,
9446 (void *)&cmd_mirror_link_on,
9451 /* *** RESET VM MIRROR RULE *** */
9452 struct cmd_rm_mirror_rule_result {
9453 cmdline_fixed_string_t reset;
9454 cmdline_fixed_string_t port;
9456 cmdline_fixed_string_t mirror;
9460 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9461 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9463 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9464 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9466 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9467 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9468 port_id, RTE_UINT16);
9469 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9470 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9471 mirror, "mirror-rule");
9472 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9473 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9474 rule_id, RTE_UINT8);
9477 cmd_reset_mirror_rule_parsed(void *parsed_result,
9478 __rte_unused struct cmdline *cl,
9479 __rte_unused void *data)
9482 struct cmd_set_mirror_link_result *res = parsed_result;
9484 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9486 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9489 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9490 .f = cmd_reset_mirror_rule_parsed,
9492 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9494 (void *)&cmd_rm_mirror_rule_reset,
9495 (void *)&cmd_rm_mirror_rule_port,
9496 (void *)&cmd_rm_mirror_rule_portid,
9497 (void *)&cmd_rm_mirror_rule_mirror,
9498 (void *)&cmd_rm_mirror_rule_ruleid,
9503 /* ******************************************************************************** */
9505 struct cmd_dump_result {
9506 cmdline_fixed_string_t dump;
9510 dump_struct_sizes(void)
9512 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9513 DUMP_SIZE(struct rte_mbuf);
9514 DUMP_SIZE(struct rte_mempool);
9515 DUMP_SIZE(struct rte_ring);
9520 /* Dump the socket memory statistics on console */
9522 dump_socket_mem(FILE *f)
9524 struct rte_malloc_socket_stats socket_stats;
9529 unsigned int n_alloc = 0;
9530 unsigned int n_free = 0;
9531 static size_t last_allocs;
9532 static size_t last_total;
9535 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9536 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9537 !socket_stats.heap_totalsz_bytes)
9539 total += socket_stats.heap_totalsz_bytes;
9540 alloc += socket_stats.heap_allocsz_bytes;
9541 free += socket_stats.heap_freesz_bytes;
9542 n_alloc += socket_stats.alloc_count;
9543 n_free += socket_stats.free_count;
9545 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9547 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9548 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9549 (double)socket_stats.heap_allocsz_bytes * 100 /
9550 (double)socket_stats.heap_totalsz_bytes,
9551 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9552 socket_stats.alloc_count,
9553 socket_stats.free_count);
9556 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9557 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9558 (double)alloc * 100 / (double)total,
9559 (double)free / (1024 * 1024),
9562 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9563 ((double)total - (double)last_total) / (1024 * 1024),
9564 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9565 last_allocs = alloc;
9569 static void cmd_dump_parsed(void *parsed_result,
9570 __rte_unused struct cmdline *cl,
9571 __rte_unused void *data)
9573 struct cmd_dump_result *res = parsed_result;
9575 if (!strcmp(res->dump, "dump_physmem"))
9576 rte_dump_physmem_layout(stdout);
9577 else if (!strcmp(res->dump, "dump_socket_mem"))
9578 dump_socket_mem(stdout);
9579 else if (!strcmp(res->dump, "dump_memzone"))
9580 rte_memzone_dump(stdout);
9581 else if (!strcmp(res->dump, "dump_struct_sizes"))
9582 dump_struct_sizes();
9583 else if (!strcmp(res->dump, "dump_ring"))
9584 rte_ring_list_dump(stdout);
9585 else if (!strcmp(res->dump, "dump_mempool"))
9586 rte_mempool_list_dump(stdout);
9587 else if (!strcmp(res->dump, "dump_devargs"))
9588 rte_devargs_dump(stdout);
9589 else if (!strcmp(res->dump, "dump_log_types"))
9590 rte_log_dump(stdout);
9593 cmdline_parse_token_string_t cmd_dump_dump =
9594 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9598 "dump_struct_sizes#"
9604 cmdline_parse_inst_t cmd_dump = {
9605 .f = cmd_dump_parsed, /* function to call */
9606 .data = NULL, /* 2nd arg of func */
9607 .help_str = "Dump status",
9608 .tokens = { /* token list, NULL terminated */
9609 (void *)&cmd_dump_dump,
9614 /* ******************************************************************************** */
9616 struct cmd_dump_one_result {
9617 cmdline_fixed_string_t dump;
9618 cmdline_fixed_string_t name;
9621 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9622 __rte_unused void *data)
9624 struct cmd_dump_one_result *res = parsed_result;
9626 if (!strcmp(res->dump, "dump_ring")) {
9628 r = rte_ring_lookup(res->name);
9630 cmdline_printf(cl, "Cannot find ring\n");
9633 rte_ring_dump(stdout, r);
9634 } else if (!strcmp(res->dump, "dump_mempool")) {
9635 struct rte_mempool *mp;
9636 mp = rte_mempool_lookup(res->name);
9638 cmdline_printf(cl, "Cannot find mempool\n");
9641 rte_mempool_dump(stdout, mp);
9645 cmdline_parse_token_string_t cmd_dump_one_dump =
9646 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9647 "dump_ring#dump_mempool");
9649 cmdline_parse_token_string_t cmd_dump_one_name =
9650 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9652 cmdline_parse_inst_t cmd_dump_one = {
9653 .f = cmd_dump_one_parsed, /* function to call */
9654 .data = NULL, /* 2nd arg of func */
9655 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9656 .tokens = { /* token list, NULL terminated */
9657 (void *)&cmd_dump_one_dump,
9658 (void *)&cmd_dump_one_name,
9663 /* *** queue region set *** */
9664 struct cmd_queue_region_result {
9665 cmdline_fixed_string_t set;
9666 cmdline_fixed_string_t port;
9668 cmdline_fixed_string_t cmd;
9669 cmdline_fixed_string_t region;
9671 cmdline_fixed_string_t queue_start_index;
9673 cmdline_fixed_string_t queue_num;
9674 uint8_t queue_num_value;
9678 cmd_queue_region_parsed(void *parsed_result,
9679 __rte_unused struct cmdline *cl,
9680 __rte_unused void *data)
9682 struct cmd_queue_region_result *res = parsed_result;
9685 struct rte_pmd_i40e_queue_region_conf region_conf;
9686 enum rte_pmd_i40e_queue_region_op op_type;
9689 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9693 memset(®ion_conf, 0, sizeof(region_conf));
9694 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9695 region_conf.region_id = res->region_id;
9696 region_conf.queue_num = res->queue_num_value;
9697 region_conf.queue_start_index = res->queue_id;
9699 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9700 op_type, ®ion_conf);
9707 printf("function not implemented or supported\n");
9710 printf("queue region config error: (%s)\n", strerror(-ret));
9714 cmdline_parse_token_string_t cmd_queue_region_set =
9715 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9717 cmdline_parse_token_string_t cmd_queue_region_port =
9718 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9719 cmdline_parse_token_num_t cmd_queue_region_port_id =
9720 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9721 port_id, RTE_UINT16);
9722 cmdline_parse_token_string_t cmd_queue_region_cmd =
9723 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9724 cmd, "queue-region");
9725 cmdline_parse_token_string_t cmd_queue_region_id =
9726 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9727 region, "region_id");
9728 cmdline_parse_token_num_t cmd_queue_region_index =
9729 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9730 region_id, RTE_UINT8);
9731 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9732 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9733 queue_start_index, "queue_start_index");
9734 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9735 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9736 queue_id, RTE_UINT8);
9737 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9738 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9739 queue_num, "queue_num");
9740 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9741 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9742 queue_num_value, RTE_UINT8);
9744 cmdline_parse_inst_t cmd_queue_region = {
9745 .f = cmd_queue_region_parsed,
9747 .help_str = "set port <port_id> queue-region region_id <value> "
9748 "queue_start_index <value> queue_num <value>: Set a queue region",
9750 (void *)&cmd_queue_region_set,
9751 (void *)&cmd_queue_region_port,
9752 (void *)&cmd_queue_region_port_id,
9753 (void *)&cmd_queue_region_cmd,
9754 (void *)&cmd_queue_region_id,
9755 (void *)&cmd_queue_region_index,
9756 (void *)&cmd_queue_region_queue_start_index,
9757 (void *)&cmd_queue_region_queue_id,
9758 (void *)&cmd_queue_region_queue_num,
9759 (void *)&cmd_queue_region_queue_num_value,
9764 /* *** queue region and flowtype set *** */
9765 struct cmd_region_flowtype_result {
9766 cmdline_fixed_string_t set;
9767 cmdline_fixed_string_t port;
9769 cmdline_fixed_string_t cmd;
9770 cmdline_fixed_string_t region;
9772 cmdline_fixed_string_t flowtype;
9773 uint8_t flowtype_id;
9777 cmd_region_flowtype_parsed(void *parsed_result,
9778 __rte_unused struct cmdline *cl,
9779 __rte_unused void *data)
9781 struct cmd_region_flowtype_result *res = parsed_result;
9784 struct rte_pmd_i40e_queue_region_conf region_conf;
9785 enum rte_pmd_i40e_queue_region_op op_type;
9788 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9792 memset(®ion_conf, 0, sizeof(region_conf));
9794 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9795 region_conf.region_id = res->region_id;
9796 region_conf.hw_flowtype = res->flowtype_id;
9798 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9799 op_type, ®ion_conf);
9806 printf("function not implemented or supported\n");
9809 printf("region flowtype config error: (%s)\n", strerror(-ret));
9813 cmdline_parse_token_string_t cmd_region_flowtype_set =
9814 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9816 cmdline_parse_token_string_t cmd_region_flowtype_port =
9817 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9819 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9820 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9821 port_id, RTE_UINT16);
9822 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9823 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9824 cmd, "queue-region");
9825 cmdline_parse_token_string_t cmd_region_flowtype_index =
9826 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9827 region, "region_id");
9828 cmdline_parse_token_num_t cmd_region_flowtype_id =
9829 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9830 region_id, RTE_UINT8);
9831 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9832 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9833 flowtype, "flowtype");
9834 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9835 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9836 flowtype_id, RTE_UINT8);
9837 cmdline_parse_inst_t cmd_region_flowtype = {
9838 .f = cmd_region_flowtype_parsed,
9840 .help_str = "set port <port_id> queue-region region_id <value> "
9841 "flowtype <value>: Set a flowtype region index",
9843 (void *)&cmd_region_flowtype_set,
9844 (void *)&cmd_region_flowtype_port,
9845 (void *)&cmd_region_flowtype_port_index,
9846 (void *)&cmd_region_flowtype_cmd,
9847 (void *)&cmd_region_flowtype_index,
9848 (void *)&cmd_region_flowtype_id,
9849 (void *)&cmd_region_flowtype_flow_index,
9850 (void *)&cmd_region_flowtype_flow_id,
9855 /* *** User Priority (UP) to queue region (region_id) set *** */
9856 struct cmd_user_priority_region_result {
9857 cmdline_fixed_string_t set;
9858 cmdline_fixed_string_t port;
9860 cmdline_fixed_string_t cmd;
9861 cmdline_fixed_string_t user_priority;
9862 uint8_t user_priority_id;
9863 cmdline_fixed_string_t region;
9868 cmd_user_priority_region_parsed(void *parsed_result,
9869 __rte_unused struct cmdline *cl,
9870 __rte_unused void *data)
9872 struct cmd_user_priority_region_result *res = parsed_result;
9875 struct rte_pmd_i40e_queue_region_conf region_conf;
9876 enum rte_pmd_i40e_queue_region_op op_type;
9879 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9883 memset(®ion_conf, 0, sizeof(region_conf));
9884 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9885 region_conf.user_priority = res->user_priority_id;
9886 region_conf.region_id = res->region_id;
9888 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9889 op_type, ®ion_conf);
9896 printf("function not implemented or supported\n");
9899 printf("user_priority region config error: (%s)\n",
9904 cmdline_parse_token_string_t cmd_user_priority_region_set =
9905 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9907 cmdline_parse_token_string_t cmd_user_priority_region_port =
9908 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9910 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9911 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9912 port_id, RTE_UINT16);
9913 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9914 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9915 cmd, "queue-region");
9916 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9917 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9918 user_priority, "UP");
9919 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9920 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9921 user_priority_id, RTE_UINT8);
9922 cmdline_parse_token_string_t cmd_user_priority_region_region =
9923 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9924 region, "region_id");
9925 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9926 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9927 region_id, RTE_UINT8);
9929 cmdline_parse_inst_t cmd_user_priority_region = {
9930 .f = cmd_user_priority_region_parsed,
9932 .help_str = "set port <port_id> queue-region UP <value> "
9933 "region_id <value>: Set the mapping of User Priority (UP) "
9934 "to queue region (region_id) ",
9936 (void *)&cmd_user_priority_region_set,
9937 (void *)&cmd_user_priority_region_port,
9938 (void *)&cmd_user_priority_region_port_index,
9939 (void *)&cmd_user_priority_region_cmd,
9940 (void *)&cmd_user_priority_region_UP,
9941 (void *)&cmd_user_priority_region_UP_id,
9942 (void *)&cmd_user_priority_region_region,
9943 (void *)&cmd_user_priority_region_region_id,
9948 /* *** flush all queue region related configuration *** */
9949 struct cmd_flush_queue_region_result {
9950 cmdline_fixed_string_t set;
9951 cmdline_fixed_string_t port;
9953 cmdline_fixed_string_t cmd;
9954 cmdline_fixed_string_t flush;
9955 cmdline_fixed_string_t what;
9959 cmd_flush_queue_region_parsed(void *parsed_result,
9960 __rte_unused struct cmdline *cl,
9961 __rte_unused void *data)
9963 struct cmd_flush_queue_region_result *res = parsed_result;
9966 struct rte_pmd_i40e_queue_region_conf region_conf;
9967 enum rte_pmd_i40e_queue_region_op op_type;
9970 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9974 memset(®ion_conf, 0, sizeof(region_conf));
9976 if (strcmp(res->what, "on") == 0)
9977 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9979 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9981 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9982 op_type, ®ion_conf);
9989 printf("function not implemented or supported\n");
9992 printf("queue region config flush error: (%s)\n",
9997 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9998 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10000 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10001 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10003 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10004 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10005 port_id, RTE_UINT16);
10006 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10007 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10008 cmd, "queue-region");
10009 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10010 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10012 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10013 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10016 cmdline_parse_inst_t cmd_flush_queue_region = {
10017 .f = cmd_flush_queue_region_parsed,
10019 .help_str = "set port <port_id> queue-region flush on|off"
10020 ": flush all queue region related configuration",
10022 (void *)&cmd_flush_queue_region_set,
10023 (void *)&cmd_flush_queue_region_port,
10024 (void *)&cmd_flush_queue_region_port_index,
10025 (void *)&cmd_flush_queue_region_cmd,
10026 (void *)&cmd_flush_queue_region_flush,
10027 (void *)&cmd_flush_queue_region_what,
10032 /* *** get all queue region related configuration info *** */
10033 struct cmd_show_queue_region_info {
10034 cmdline_fixed_string_t show;
10035 cmdline_fixed_string_t port;
10037 cmdline_fixed_string_t cmd;
10041 cmd_show_queue_region_info_parsed(void *parsed_result,
10042 __rte_unused struct cmdline *cl,
10043 __rte_unused void *data)
10045 struct cmd_show_queue_region_info *res = parsed_result;
10046 int ret = -ENOTSUP;
10047 #ifdef RTE_NET_I40E
10048 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10049 enum rte_pmd_i40e_queue_region_op op_type;
10052 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10055 #ifdef RTE_NET_I40E
10056 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10058 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10060 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10061 op_type, &rte_pmd_regions);
10063 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10070 printf("function not implemented or supported\n");
10073 printf("queue region config info show error: (%s)\n",
10078 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10079 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10081 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10082 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10084 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10085 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10086 port_id, RTE_UINT16);
10087 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10088 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10089 cmd, "queue-region");
10091 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10092 .f = cmd_show_queue_region_info_parsed,
10094 .help_str = "show port <port_id> queue-region"
10095 ": show all queue region related configuration info",
10097 (void *)&cmd_show_queue_region_info_get,
10098 (void *)&cmd_show_queue_region_info_port,
10099 (void *)&cmd_show_queue_region_info_port_index,
10100 (void *)&cmd_show_queue_region_info_cmd,
10105 /* *** Filters Control *** */
10107 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10109 if ((ip_addr).family == AF_INET) \
10110 (ip) = (ip_addr).addr.ipv4.s_addr; \
10112 printf("invalid parameter.\n"); \
10117 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10119 if ((ip_addr).family == AF_INET6) \
10120 rte_memcpy(&(ip), \
10121 &((ip_addr).addr.ipv6), \
10122 sizeof(struct in6_addr)); \
10124 printf("invalid parameter.\n"); \
10129 #ifdef RTE_NET_I40E
10132 str2flowtype(char *string)
10135 static const struct {
10138 } flowtype_str[] = {
10139 {"raw", RTE_ETH_FLOW_RAW},
10140 {"ipv4", RTE_ETH_FLOW_IPV4},
10141 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10142 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10143 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10144 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10145 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10146 {"ipv6", RTE_ETH_FLOW_IPV6},
10147 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10148 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10149 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10150 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10151 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10152 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10155 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10156 if (!strcmp(flowtype_str[i].str, string))
10157 return flowtype_str[i].type;
10160 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10161 return (uint16_t)atoi(string);
10163 return RTE_ETH_FLOW_UNKNOWN;
10166 /* *** deal with flow director filter *** */
10167 struct cmd_flow_director_result {
10168 cmdline_fixed_string_t flow_director_filter;
10170 cmdline_fixed_string_t mode;
10171 cmdline_fixed_string_t mode_value;
10172 cmdline_fixed_string_t ops;
10173 cmdline_fixed_string_t flow;
10174 cmdline_fixed_string_t flow_type;
10175 cmdline_fixed_string_t drop;
10176 cmdline_fixed_string_t queue;
10178 cmdline_fixed_string_t fd_id;
10179 uint32_t fd_id_value;
10180 cmdline_fixed_string_t packet;
10185 cmd_flow_director_filter_parsed(void *parsed_result,
10186 __rte_unused struct cmdline *cl,
10187 __rte_unused void *data)
10189 struct cmd_flow_director_result *res = parsed_result;
10191 struct rte_pmd_i40e_flow_type_mapping
10192 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10193 struct rte_pmd_i40e_pkt_template_conf conf;
10194 uint16_t flow_type = str2flowtype(res->flow_type);
10195 uint16_t i, port = res->port_id;
10198 memset(&conf, 0, sizeof(conf));
10200 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10201 printf("Invalid flow type specified.\n");
10204 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10208 if (mapping[flow_type].pctype == 0ULL) {
10209 printf("Invalid flow type specified.\n");
10212 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10213 if (mapping[flow_type].pctype & (1ULL << i)) {
10214 conf.input.pctype = i;
10219 conf.input.packet = open_file(res->filepath,
10220 &conf.input.length);
10221 if (!conf.input.packet)
10223 if (!strcmp(res->drop, "drop"))
10224 conf.action.behavior =
10225 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10227 conf.action.behavior =
10228 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10229 conf.action.report_status =
10230 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10231 conf.action.rx_queue = res->queue_id;
10232 conf.soft_id = res->fd_id_value;
10233 add = strcmp(res->ops, "del") ? 1 : 0;
10234 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10238 printf("flow director config error: (%s)\n",
10240 close_file(conf.input.packet);
10243 cmdline_parse_token_string_t cmd_flow_director_filter =
10244 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10245 flow_director_filter, "flow_director_filter");
10246 cmdline_parse_token_num_t cmd_flow_director_port_id =
10247 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10248 port_id, RTE_UINT16);
10249 cmdline_parse_token_string_t cmd_flow_director_ops =
10250 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10251 ops, "add#del#update");
10252 cmdline_parse_token_string_t cmd_flow_director_flow =
10253 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10255 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10256 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10258 cmdline_parse_token_string_t cmd_flow_director_drop =
10259 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10261 cmdline_parse_token_string_t cmd_flow_director_queue =
10262 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10264 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10265 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10266 queue_id, RTE_UINT16);
10267 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10268 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10270 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10271 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10272 fd_id_value, RTE_UINT32);
10274 cmdline_parse_token_string_t cmd_flow_director_mode =
10275 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10277 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10278 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10279 mode_value, "raw");
10280 cmdline_parse_token_string_t cmd_flow_director_packet =
10281 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10283 cmdline_parse_token_string_t cmd_flow_director_filepath =
10284 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10287 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10288 .f = cmd_flow_director_filter_parsed,
10290 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10291 "director entry on NIC",
10293 (void *)&cmd_flow_director_filter,
10294 (void *)&cmd_flow_director_port_id,
10295 (void *)&cmd_flow_director_mode,
10296 (void *)&cmd_flow_director_mode_raw,
10297 (void *)&cmd_flow_director_ops,
10298 (void *)&cmd_flow_director_flow,
10299 (void *)&cmd_flow_director_flow_type,
10300 (void *)&cmd_flow_director_drop,
10301 (void *)&cmd_flow_director_queue,
10302 (void *)&cmd_flow_director_queue_id,
10303 (void *)&cmd_flow_director_fd_id,
10304 (void *)&cmd_flow_director_fd_id_value,
10305 (void *)&cmd_flow_director_packet,
10306 (void *)&cmd_flow_director_filepath,
10311 #endif /* RTE_NET_I40E */
10313 /* *** deal with flow director mask *** */
10314 struct cmd_flow_director_mask_result {
10315 cmdline_fixed_string_t flow_director_mask;
10317 cmdline_fixed_string_t mode;
10318 cmdline_fixed_string_t mode_value;
10319 cmdline_fixed_string_t vlan;
10320 uint16_t vlan_mask;
10321 cmdline_fixed_string_t src_mask;
10322 cmdline_ipaddr_t ipv4_src;
10323 cmdline_ipaddr_t ipv6_src;
10325 cmdline_fixed_string_t dst_mask;
10326 cmdline_ipaddr_t ipv4_dst;
10327 cmdline_ipaddr_t ipv6_dst;
10329 cmdline_fixed_string_t mac;
10330 uint8_t mac_addr_byte_mask;
10331 cmdline_fixed_string_t tunnel_id;
10332 uint32_t tunnel_id_mask;
10333 cmdline_fixed_string_t tunnel_type;
10334 uint8_t tunnel_type_mask;
10338 cmd_flow_director_mask_parsed(void *parsed_result,
10339 __rte_unused struct cmdline *cl,
10340 __rte_unused void *data)
10342 struct cmd_flow_director_mask_result *res = parsed_result;
10343 struct rte_eth_fdir_masks *mask;
10344 struct rte_port *port;
10346 port = &ports[res->port_id];
10347 /** Check if the port is not started **/
10348 if (port->port_status != RTE_PORT_STOPPED) {
10349 printf("Please stop port %d first\n", res->port_id);
10353 mask = &port->dev_conf.fdir_conf.mask;
10355 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10356 if (strcmp(res->mode_value, "MAC-VLAN")) {
10357 printf("Please set mode to MAC-VLAN.\n");
10361 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10362 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10363 if (strcmp(res->mode_value, "Tunnel")) {
10364 printf("Please set mode to Tunnel.\n");
10368 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10369 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10370 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10371 mask->tunnel_type_mask = res->tunnel_type_mask;
10373 if (strcmp(res->mode_value, "IP")) {
10374 printf("Please set mode to IP.\n");
10378 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10379 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10380 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10381 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10382 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10383 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10384 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10387 cmd_reconfig_device_queue(res->port_id, 1, 1);
10390 cmdline_parse_token_string_t cmd_flow_director_mask =
10391 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10392 flow_director_mask, "flow_director_mask");
10393 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10394 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10395 port_id, RTE_UINT16);
10396 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10397 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10399 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10400 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10401 vlan_mask, RTE_UINT16);
10402 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10403 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10404 src_mask, "src_mask");
10405 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10406 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10408 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10409 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10411 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10412 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10413 port_src, RTE_UINT16);
10414 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10415 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10416 dst_mask, "dst_mask");
10417 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10418 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10420 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10421 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10423 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10424 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10425 port_dst, RTE_UINT16);
10427 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10428 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10430 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10431 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10433 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10434 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10435 mode_value, "MAC-VLAN");
10436 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10437 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10438 mode_value, "Tunnel");
10439 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10440 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10442 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10443 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10444 mac_addr_byte_mask, RTE_UINT8);
10445 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10446 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10447 tunnel_type, "tunnel-type");
10448 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10449 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10450 tunnel_type_mask, RTE_UINT8);
10451 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10452 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10453 tunnel_id, "tunnel-id");
10454 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10455 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10456 tunnel_id_mask, RTE_UINT32);
10458 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10459 .f = cmd_flow_director_mask_parsed,
10461 .help_str = "flow_director_mask ... : "
10462 "Set IP mode flow director's mask on NIC",
10464 (void *)&cmd_flow_director_mask,
10465 (void *)&cmd_flow_director_mask_port_id,
10466 (void *)&cmd_flow_director_mask_mode,
10467 (void *)&cmd_flow_director_mask_mode_ip,
10468 (void *)&cmd_flow_director_mask_vlan,
10469 (void *)&cmd_flow_director_mask_vlan_value,
10470 (void *)&cmd_flow_director_mask_src,
10471 (void *)&cmd_flow_director_mask_ipv4_src,
10472 (void *)&cmd_flow_director_mask_ipv6_src,
10473 (void *)&cmd_flow_director_mask_port_src,
10474 (void *)&cmd_flow_director_mask_dst,
10475 (void *)&cmd_flow_director_mask_ipv4_dst,
10476 (void *)&cmd_flow_director_mask_ipv6_dst,
10477 (void *)&cmd_flow_director_mask_port_dst,
10482 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10483 .f = cmd_flow_director_mask_parsed,
10485 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10486 "flow director's mask on NIC",
10488 (void *)&cmd_flow_director_mask,
10489 (void *)&cmd_flow_director_mask_port_id,
10490 (void *)&cmd_flow_director_mask_mode,
10491 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10492 (void *)&cmd_flow_director_mask_vlan,
10493 (void *)&cmd_flow_director_mask_vlan_value,
10498 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10499 .f = cmd_flow_director_mask_parsed,
10501 .help_str = "flow_director_mask ... : Set tunnel mode "
10502 "flow director's mask on NIC",
10504 (void *)&cmd_flow_director_mask,
10505 (void *)&cmd_flow_director_mask_port_id,
10506 (void *)&cmd_flow_director_mask_mode,
10507 (void *)&cmd_flow_director_mask_mode_tunnel,
10508 (void *)&cmd_flow_director_mask_vlan,
10509 (void *)&cmd_flow_director_mask_vlan_value,
10510 (void *)&cmd_flow_director_mask_mac,
10511 (void *)&cmd_flow_director_mask_mac_value,
10512 (void *)&cmd_flow_director_mask_tunnel_type,
10513 (void *)&cmd_flow_director_mask_tunnel_type_value,
10514 (void *)&cmd_flow_director_mask_tunnel_id,
10515 (void *)&cmd_flow_director_mask_tunnel_id_value,
10520 /* *** deal with flow director flexible payload configuration *** */
10521 struct cmd_flow_director_flexpayload_result {
10522 cmdline_fixed_string_t flow_director_flexpayload;
10524 cmdline_fixed_string_t payload_layer;
10525 cmdline_fixed_string_t payload_cfg;
10529 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10532 const char *p, *p0 = q_arg;
10534 unsigned long int_fld;
10535 char *str_fld[max_num];
10540 p = strchr(p0, '(');
10544 p0 = strchr(p, ')');
10549 if (size >= sizeof(s))
10552 snprintf(s, sizeof(s), "%.*s", size, p);
10553 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10554 if (ret < 0 || ret > max_num)
10556 for (i = 0; i < ret; i++) {
10558 int_fld = strtoul(str_fld[i], &end, 0);
10559 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10561 offsets[i] = (uint16_t)int_fld;
10567 cmd_flow_director_flxpld_parsed(void *parsed_result,
10568 __rte_unused struct cmdline *cl,
10569 __rte_unused void *data)
10571 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10572 struct rte_eth_flex_payload_cfg flex_cfg;
10573 struct rte_port *port;
10576 port = &ports[res->port_id];
10577 /** Check if the port is not started **/
10578 if (port->port_status != RTE_PORT_STOPPED) {
10579 printf("Please stop port %d first\n", res->port_id);
10583 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10585 if (!strcmp(res->payload_layer, "raw"))
10586 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10587 else if (!strcmp(res->payload_layer, "l2"))
10588 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10589 else if (!strcmp(res->payload_layer, "l3"))
10590 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10591 else if (!strcmp(res->payload_layer, "l4"))
10592 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10594 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10595 RTE_ETH_FDIR_MAX_FLEXLEN);
10597 printf("error: Cannot parse flex payload input.\n");
10601 fdir_set_flex_payload(res->port_id, &flex_cfg);
10602 cmd_reconfig_device_queue(res->port_id, 1, 1);
10605 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10606 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10607 flow_director_flexpayload,
10608 "flow_director_flex_payload");
10609 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10610 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10611 port_id, RTE_UINT16);
10612 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10613 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10614 payload_layer, "raw#l2#l3#l4");
10615 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10616 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10617 payload_cfg, NULL);
10619 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10620 .f = cmd_flow_director_flxpld_parsed,
10622 .help_str = "flow_director_flexpayload ... : "
10623 "Set flow director's flex payload on NIC",
10625 (void *)&cmd_flow_director_flexpayload,
10626 (void *)&cmd_flow_director_flexpayload_port_id,
10627 (void *)&cmd_flow_director_flexpayload_payload_layer,
10628 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10633 /* Generic flow interface command. */
10634 extern cmdline_parse_inst_t cmd_flow;
10636 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10637 struct cmd_mcast_addr_result {
10638 cmdline_fixed_string_t mcast_addr_cmd;
10639 cmdline_fixed_string_t what;
10641 struct rte_ether_addr mc_addr;
10644 static void cmd_mcast_addr_parsed(void *parsed_result,
10645 __rte_unused struct cmdline *cl,
10646 __rte_unused void *data)
10648 struct cmd_mcast_addr_result *res = parsed_result;
10650 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
10651 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
10652 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
10653 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
10654 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
10657 if (strcmp(res->what, "add") == 0)
10658 mcast_addr_add(res->port_num, &res->mc_addr);
10660 mcast_addr_remove(res->port_num, &res->mc_addr);
10663 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10664 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10665 mcast_addr_cmd, "mcast_addr");
10666 cmdline_parse_token_string_t cmd_mcast_addr_what =
10667 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10669 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10670 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
10672 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10673 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10675 cmdline_parse_inst_t cmd_mcast_addr = {
10676 .f = cmd_mcast_addr_parsed,
10678 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10679 "Add/Remove multicast MAC address on port_id",
10681 (void *)&cmd_mcast_addr_cmd,
10682 (void *)&cmd_mcast_addr_what,
10683 (void *)&cmd_mcast_addr_portnum,
10684 (void *)&cmd_mcast_addr_addr,
10689 /* vf vlan anti spoof configuration */
10691 /* Common result structure for vf vlan anti spoof */
10692 struct cmd_vf_vlan_anti_spoof_result {
10693 cmdline_fixed_string_t set;
10694 cmdline_fixed_string_t vf;
10695 cmdline_fixed_string_t vlan;
10696 cmdline_fixed_string_t antispoof;
10699 cmdline_fixed_string_t on_off;
10702 /* Common CLI fields for vf vlan anti spoof enable disable */
10703 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10704 TOKEN_STRING_INITIALIZER
10705 (struct cmd_vf_vlan_anti_spoof_result,
10707 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10708 TOKEN_STRING_INITIALIZER
10709 (struct cmd_vf_vlan_anti_spoof_result,
10711 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10712 TOKEN_STRING_INITIALIZER
10713 (struct cmd_vf_vlan_anti_spoof_result,
10715 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10716 TOKEN_STRING_INITIALIZER
10717 (struct cmd_vf_vlan_anti_spoof_result,
10718 antispoof, "antispoof");
10719 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10720 TOKEN_NUM_INITIALIZER
10721 (struct cmd_vf_vlan_anti_spoof_result,
10722 port_id, RTE_UINT16);
10723 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10724 TOKEN_NUM_INITIALIZER
10725 (struct cmd_vf_vlan_anti_spoof_result,
10726 vf_id, RTE_UINT32);
10727 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10728 TOKEN_STRING_INITIALIZER
10729 (struct cmd_vf_vlan_anti_spoof_result,
10733 cmd_set_vf_vlan_anti_spoof_parsed(
10734 void *parsed_result,
10735 __rte_unused struct cmdline *cl,
10736 __rte_unused void *data)
10738 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10739 int ret = -ENOTSUP;
10741 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10743 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10746 #ifdef RTE_NET_IXGBE
10747 if (ret == -ENOTSUP)
10748 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
10749 res->vf_id, is_on);
10751 #ifdef RTE_NET_I40E
10752 if (ret == -ENOTSUP)
10753 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
10754 res->vf_id, is_on);
10756 #ifdef RTE_NET_BNXT
10757 if (ret == -ENOTSUP)
10758 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
10759 res->vf_id, is_on);
10766 printf("invalid vf_id %d\n", res->vf_id);
10769 printf("invalid port_id %d\n", res->port_id);
10772 printf("function not implemented\n");
10775 printf("programming error: (%s)\n", strerror(-ret));
10779 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
10780 .f = cmd_set_vf_vlan_anti_spoof_parsed,
10782 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
10784 (void *)&cmd_vf_vlan_anti_spoof_set,
10785 (void *)&cmd_vf_vlan_anti_spoof_vf,
10786 (void *)&cmd_vf_vlan_anti_spoof_vlan,
10787 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
10788 (void *)&cmd_vf_vlan_anti_spoof_port_id,
10789 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
10790 (void *)&cmd_vf_vlan_anti_spoof_on_off,
10795 /* vf mac anti spoof configuration */
10797 /* Common result structure for vf mac anti spoof */
10798 struct cmd_vf_mac_anti_spoof_result {
10799 cmdline_fixed_string_t set;
10800 cmdline_fixed_string_t vf;
10801 cmdline_fixed_string_t mac;
10802 cmdline_fixed_string_t antispoof;
10805 cmdline_fixed_string_t on_off;
10808 /* Common CLI fields for vf mac anti spoof enable disable */
10809 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
10810 TOKEN_STRING_INITIALIZER
10811 (struct cmd_vf_mac_anti_spoof_result,
10813 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
10814 TOKEN_STRING_INITIALIZER
10815 (struct cmd_vf_mac_anti_spoof_result,
10817 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
10818 TOKEN_STRING_INITIALIZER
10819 (struct cmd_vf_mac_anti_spoof_result,
10821 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
10822 TOKEN_STRING_INITIALIZER
10823 (struct cmd_vf_mac_anti_spoof_result,
10824 antispoof, "antispoof");
10825 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
10826 TOKEN_NUM_INITIALIZER
10827 (struct cmd_vf_mac_anti_spoof_result,
10828 port_id, RTE_UINT16);
10829 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
10830 TOKEN_NUM_INITIALIZER
10831 (struct cmd_vf_mac_anti_spoof_result,
10832 vf_id, RTE_UINT32);
10833 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
10834 TOKEN_STRING_INITIALIZER
10835 (struct cmd_vf_mac_anti_spoof_result,
10839 cmd_set_vf_mac_anti_spoof_parsed(
10840 void *parsed_result,
10841 __rte_unused struct cmdline *cl,
10842 __rte_unused void *data)
10844 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
10845 int ret = -ENOTSUP;
10847 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10849 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10852 #ifdef RTE_NET_IXGBE
10853 if (ret == -ENOTSUP)
10854 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
10855 res->vf_id, is_on);
10857 #ifdef RTE_NET_I40E
10858 if (ret == -ENOTSUP)
10859 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
10860 res->vf_id, is_on);
10862 #ifdef RTE_NET_BNXT
10863 if (ret == -ENOTSUP)
10864 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
10865 res->vf_id, is_on);
10872 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
10875 printf("invalid port_id %d\n", res->port_id);
10878 printf("function not implemented\n");
10881 printf("programming error: (%s)\n", strerror(-ret));
10885 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
10886 .f = cmd_set_vf_mac_anti_spoof_parsed,
10888 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
10890 (void *)&cmd_vf_mac_anti_spoof_set,
10891 (void *)&cmd_vf_mac_anti_spoof_vf,
10892 (void *)&cmd_vf_mac_anti_spoof_mac,
10893 (void *)&cmd_vf_mac_anti_spoof_antispoof,
10894 (void *)&cmd_vf_mac_anti_spoof_port_id,
10895 (void *)&cmd_vf_mac_anti_spoof_vf_id,
10896 (void *)&cmd_vf_mac_anti_spoof_on_off,
10901 /* vf vlan strip queue configuration */
10903 /* Common result structure for vf mac anti spoof */
10904 struct cmd_vf_vlan_stripq_result {
10905 cmdline_fixed_string_t set;
10906 cmdline_fixed_string_t vf;
10907 cmdline_fixed_string_t vlan;
10908 cmdline_fixed_string_t stripq;
10911 cmdline_fixed_string_t on_off;
10914 /* Common CLI fields for vf vlan strip enable disable */
10915 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
10916 TOKEN_STRING_INITIALIZER
10917 (struct cmd_vf_vlan_stripq_result,
10919 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
10920 TOKEN_STRING_INITIALIZER
10921 (struct cmd_vf_vlan_stripq_result,
10923 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
10924 TOKEN_STRING_INITIALIZER
10925 (struct cmd_vf_vlan_stripq_result,
10927 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
10928 TOKEN_STRING_INITIALIZER
10929 (struct cmd_vf_vlan_stripq_result,
10931 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
10932 TOKEN_NUM_INITIALIZER
10933 (struct cmd_vf_vlan_stripq_result,
10934 port_id, RTE_UINT16);
10935 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
10936 TOKEN_NUM_INITIALIZER
10937 (struct cmd_vf_vlan_stripq_result,
10938 vf_id, RTE_UINT16);
10939 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
10940 TOKEN_STRING_INITIALIZER
10941 (struct cmd_vf_vlan_stripq_result,
10945 cmd_set_vf_vlan_stripq_parsed(
10946 void *parsed_result,
10947 __rte_unused struct cmdline *cl,
10948 __rte_unused void *data)
10950 struct cmd_vf_vlan_stripq_result *res = parsed_result;
10951 int ret = -ENOTSUP;
10953 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10955 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10958 #ifdef RTE_NET_IXGBE
10959 if (ret == -ENOTSUP)
10960 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
10961 res->vf_id, is_on);
10963 #ifdef RTE_NET_I40E
10964 if (ret == -ENOTSUP)
10965 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
10966 res->vf_id, is_on);
10968 #ifdef RTE_NET_BNXT
10969 if (ret == -ENOTSUP)
10970 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
10971 res->vf_id, is_on);
10978 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
10981 printf("invalid port_id %d\n", res->port_id);
10984 printf("function not implemented\n");
10987 printf("programming error: (%s)\n", strerror(-ret));
10991 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
10992 .f = cmd_set_vf_vlan_stripq_parsed,
10994 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
10996 (void *)&cmd_vf_vlan_stripq_set,
10997 (void *)&cmd_vf_vlan_stripq_vf,
10998 (void *)&cmd_vf_vlan_stripq_vlan,
10999 (void *)&cmd_vf_vlan_stripq_stripq,
11000 (void *)&cmd_vf_vlan_stripq_port_id,
11001 (void *)&cmd_vf_vlan_stripq_vf_id,
11002 (void *)&cmd_vf_vlan_stripq_on_off,
11007 /* vf vlan insert configuration */
11009 /* Common result structure for vf vlan insert */
11010 struct cmd_vf_vlan_insert_result {
11011 cmdline_fixed_string_t set;
11012 cmdline_fixed_string_t vf;
11013 cmdline_fixed_string_t vlan;
11014 cmdline_fixed_string_t insert;
11020 /* Common CLI fields for vf vlan insert enable disable */
11021 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11022 TOKEN_STRING_INITIALIZER
11023 (struct cmd_vf_vlan_insert_result,
11025 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11026 TOKEN_STRING_INITIALIZER
11027 (struct cmd_vf_vlan_insert_result,
11029 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11030 TOKEN_STRING_INITIALIZER
11031 (struct cmd_vf_vlan_insert_result,
11033 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11034 TOKEN_STRING_INITIALIZER
11035 (struct cmd_vf_vlan_insert_result,
11037 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11038 TOKEN_NUM_INITIALIZER
11039 (struct cmd_vf_vlan_insert_result,
11040 port_id, RTE_UINT16);
11041 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11042 TOKEN_NUM_INITIALIZER
11043 (struct cmd_vf_vlan_insert_result,
11044 vf_id, RTE_UINT16);
11045 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11046 TOKEN_NUM_INITIALIZER
11047 (struct cmd_vf_vlan_insert_result,
11048 vlan_id, RTE_UINT16);
11051 cmd_set_vf_vlan_insert_parsed(
11052 void *parsed_result,
11053 __rte_unused struct cmdline *cl,
11054 __rte_unused void *data)
11056 struct cmd_vf_vlan_insert_result *res = parsed_result;
11057 int ret = -ENOTSUP;
11059 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11062 #ifdef RTE_NET_IXGBE
11063 if (ret == -ENOTSUP)
11064 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11067 #ifdef RTE_NET_I40E
11068 if (ret == -ENOTSUP)
11069 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11072 #ifdef RTE_NET_BNXT
11073 if (ret == -ENOTSUP)
11074 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11082 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
11085 printf("invalid port_id %d\n", res->port_id);
11088 printf("function not implemented\n");
11091 printf("programming error: (%s)\n", strerror(-ret));
11095 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11096 .f = cmd_set_vf_vlan_insert_parsed,
11098 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11100 (void *)&cmd_vf_vlan_insert_set,
11101 (void *)&cmd_vf_vlan_insert_vf,
11102 (void *)&cmd_vf_vlan_insert_vlan,
11103 (void *)&cmd_vf_vlan_insert_insert,
11104 (void *)&cmd_vf_vlan_insert_port_id,
11105 (void *)&cmd_vf_vlan_insert_vf_id,
11106 (void *)&cmd_vf_vlan_insert_vlan_id,
11111 /* tx loopback configuration */
11113 /* Common result structure for tx loopback */
11114 struct cmd_tx_loopback_result {
11115 cmdline_fixed_string_t set;
11116 cmdline_fixed_string_t tx;
11117 cmdline_fixed_string_t loopback;
11119 cmdline_fixed_string_t on_off;
11122 /* Common CLI fields for tx loopback enable disable */
11123 cmdline_parse_token_string_t cmd_tx_loopback_set =
11124 TOKEN_STRING_INITIALIZER
11125 (struct cmd_tx_loopback_result,
11127 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11128 TOKEN_STRING_INITIALIZER
11129 (struct cmd_tx_loopback_result,
11131 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11132 TOKEN_STRING_INITIALIZER
11133 (struct cmd_tx_loopback_result,
11134 loopback, "loopback");
11135 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11136 TOKEN_NUM_INITIALIZER
11137 (struct cmd_tx_loopback_result,
11138 port_id, RTE_UINT16);
11139 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11140 TOKEN_STRING_INITIALIZER
11141 (struct cmd_tx_loopback_result,
11145 cmd_set_tx_loopback_parsed(
11146 void *parsed_result,
11147 __rte_unused struct cmdline *cl,
11148 __rte_unused void *data)
11150 struct cmd_tx_loopback_result *res = parsed_result;
11151 int ret = -ENOTSUP;
11153 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11155 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11158 #ifdef RTE_NET_IXGBE
11159 if (ret == -ENOTSUP)
11160 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11162 #ifdef RTE_NET_I40E
11163 if (ret == -ENOTSUP)
11164 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11166 #ifdef RTE_NET_BNXT
11167 if (ret == -ENOTSUP)
11168 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11170 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11171 if (ret == -ENOTSUP)
11172 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11179 printf("invalid is_on %d\n", is_on);
11182 printf("invalid port_id %d\n", res->port_id);
11185 printf("function not implemented\n");
11188 printf("programming error: (%s)\n", strerror(-ret));
11192 cmdline_parse_inst_t cmd_set_tx_loopback = {
11193 .f = cmd_set_tx_loopback_parsed,
11195 .help_str = "set tx loopback <port_id> on|off",
11197 (void *)&cmd_tx_loopback_set,
11198 (void *)&cmd_tx_loopback_tx,
11199 (void *)&cmd_tx_loopback_loopback,
11200 (void *)&cmd_tx_loopback_port_id,
11201 (void *)&cmd_tx_loopback_on_off,
11206 /* all queues drop enable configuration */
11208 /* Common result structure for all queues drop enable */
11209 struct cmd_all_queues_drop_en_result {
11210 cmdline_fixed_string_t set;
11211 cmdline_fixed_string_t all;
11212 cmdline_fixed_string_t queues;
11213 cmdline_fixed_string_t drop;
11215 cmdline_fixed_string_t on_off;
11218 /* Common CLI fields for tx loopback enable disable */
11219 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11220 TOKEN_STRING_INITIALIZER
11221 (struct cmd_all_queues_drop_en_result,
11223 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11224 TOKEN_STRING_INITIALIZER
11225 (struct cmd_all_queues_drop_en_result,
11227 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11228 TOKEN_STRING_INITIALIZER
11229 (struct cmd_all_queues_drop_en_result,
11231 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11232 TOKEN_STRING_INITIALIZER
11233 (struct cmd_all_queues_drop_en_result,
11235 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11236 TOKEN_NUM_INITIALIZER
11237 (struct cmd_all_queues_drop_en_result,
11238 port_id, RTE_UINT16);
11239 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11240 TOKEN_STRING_INITIALIZER
11241 (struct cmd_all_queues_drop_en_result,
11245 cmd_set_all_queues_drop_en_parsed(
11246 void *parsed_result,
11247 __rte_unused struct cmdline *cl,
11248 __rte_unused void *data)
11250 struct cmd_all_queues_drop_en_result *res = parsed_result;
11251 int ret = -ENOTSUP;
11252 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11254 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11257 #ifdef RTE_NET_IXGBE
11258 if (ret == -ENOTSUP)
11259 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11261 #ifdef RTE_NET_BNXT
11262 if (ret == -ENOTSUP)
11263 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11269 printf("invalid is_on %d\n", is_on);
11272 printf("invalid port_id %d\n", res->port_id);
11275 printf("function not implemented\n");
11278 printf("programming error: (%s)\n", strerror(-ret));
11282 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11283 .f = cmd_set_all_queues_drop_en_parsed,
11285 .help_str = "set all queues drop <port_id> on|off",
11287 (void *)&cmd_all_queues_drop_en_set,
11288 (void *)&cmd_all_queues_drop_en_all,
11289 (void *)&cmd_all_queues_drop_en_queues,
11290 (void *)&cmd_all_queues_drop_en_drop,
11291 (void *)&cmd_all_queues_drop_en_port_id,
11292 (void *)&cmd_all_queues_drop_en_on_off,
11297 /* vf split drop enable configuration */
11299 /* Common result structure for vf split drop enable */
11300 struct cmd_vf_split_drop_en_result {
11301 cmdline_fixed_string_t set;
11302 cmdline_fixed_string_t vf;
11303 cmdline_fixed_string_t split;
11304 cmdline_fixed_string_t drop;
11307 cmdline_fixed_string_t on_off;
11310 /* Common CLI fields for vf split drop enable disable */
11311 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11312 TOKEN_STRING_INITIALIZER
11313 (struct cmd_vf_split_drop_en_result,
11315 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11316 TOKEN_STRING_INITIALIZER
11317 (struct cmd_vf_split_drop_en_result,
11319 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11320 TOKEN_STRING_INITIALIZER
11321 (struct cmd_vf_split_drop_en_result,
11323 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11324 TOKEN_STRING_INITIALIZER
11325 (struct cmd_vf_split_drop_en_result,
11327 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11328 TOKEN_NUM_INITIALIZER
11329 (struct cmd_vf_split_drop_en_result,
11330 port_id, RTE_UINT16);
11331 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11332 TOKEN_NUM_INITIALIZER
11333 (struct cmd_vf_split_drop_en_result,
11334 vf_id, RTE_UINT16);
11335 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11336 TOKEN_STRING_INITIALIZER
11337 (struct cmd_vf_split_drop_en_result,
11341 cmd_set_vf_split_drop_en_parsed(
11342 void *parsed_result,
11343 __rte_unused struct cmdline *cl,
11344 __rte_unused void *data)
11346 struct cmd_vf_split_drop_en_result *res = parsed_result;
11347 int ret = -ENOTSUP;
11348 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11350 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11353 #ifdef RTE_NET_IXGBE
11354 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11361 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
11364 printf("invalid port_id %d\n", res->port_id);
11367 printf("not supported on port %d\n", res->port_id);
11370 printf("programming error: (%s)\n", strerror(-ret));
11374 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11375 .f = cmd_set_vf_split_drop_en_parsed,
11377 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11379 (void *)&cmd_vf_split_drop_en_set,
11380 (void *)&cmd_vf_split_drop_en_vf,
11381 (void *)&cmd_vf_split_drop_en_split,
11382 (void *)&cmd_vf_split_drop_en_drop,
11383 (void *)&cmd_vf_split_drop_en_port_id,
11384 (void *)&cmd_vf_split_drop_en_vf_id,
11385 (void *)&cmd_vf_split_drop_en_on_off,
11390 /* vf mac address configuration */
11392 /* Common result structure for vf mac address */
11393 struct cmd_set_vf_mac_addr_result {
11394 cmdline_fixed_string_t set;
11395 cmdline_fixed_string_t vf;
11396 cmdline_fixed_string_t mac;
11397 cmdline_fixed_string_t addr;
11400 struct rte_ether_addr mac_addr;
11404 /* Common CLI fields for vf split drop enable disable */
11405 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11406 TOKEN_STRING_INITIALIZER
11407 (struct cmd_set_vf_mac_addr_result,
11409 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11410 TOKEN_STRING_INITIALIZER
11411 (struct cmd_set_vf_mac_addr_result,
11413 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11414 TOKEN_STRING_INITIALIZER
11415 (struct cmd_set_vf_mac_addr_result,
11417 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11418 TOKEN_STRING_INITIALIZER
11419 (struct cmd_set_vf_mac_addr_result,
11421 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11422 TOKEN_NUM_INITIALIZER
11423 (struct cmd_set_vf_mac_addr_result,
11424 port_id, RTE_UINT16);
11425 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11426 TOKEN_NUM_INITIALIZER
11427 (struct cmd_set_vf_mac_addr_result,
11428 vf_id, RTE_UINT16);
11429 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11430 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11434 cmd_set_vf_mac_addr_parsed(
11435 void *parsed_result,
11436 __rte_unused struct cmdline *cl,
11437 __rte_unused void *data)
11439 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11440 int ret = -ENOTSUP;
11442 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11445 #ifdef RTE_NET_IXGBE
11446 if (ret == -ENOTSUP)
11447 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11450 #ifdef RTE_NET_I40E
11451 if (ret == -ENOTSUP)
11452 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11455 #ifdef RTE_NET_BNXT
11456 if (ret == -ENOTSUP)
11457 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11465 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
11468 printf("invalid port_id %d\n", res->port_id);
11471 printf("function not implemented\n");
11474 printf("programming error: (%s)\n", strerror(-ret));
11478 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11479 .f = cmd_set_vf_mac_addr_parsed,
11481 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11483 (void *)&cmd_set_vf_mac_addr_set,
11484 (void *)&cmd_set_vf_mac_addr_vf,
11485 (void *)&cmd_set_vf_mac_addr_mac,
11486 (void *)&cmd_set_vf_mac_addr_addr,
11487 (void *)&cmd_set_vf_mac_addr_port_id,
11488 (void *)&cmd_set_vf_mac_addr_vf_id,
11489 (void *)&cmd_set_vf_mac_addr_mac_addr,
11494 /* MACsec configuration */
11496 /* Common result structure for MACsec offload enable */
11497 struct cmd_macsec_offload_on_result {
11498 cmdline_fixed_string_t set;
11499 cmdline_fixed_string_t macsec;
11500 cmdline_fixed_string_t offload;
11502 cmdline_fixed_string_t on;
11503 cmdline_fixed_string_t encrypt;
11504 cmdline_fixed_string_t en_on_off;
11505 cmdline_fixed_string_t replay_protect;
11506 cmdline_fixed_string_t rp_on_off;
11509 /* Common CLI fields for MACsec offload disable */
11510 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11511 TOKEN_STRING_INITIALIZER
11512 (struct cmd_macsec_offload_on_result,
11514 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11515 TOKEN_STRING_INITIALIZER
11516 (struct cmd_macsec_offload_on_result,
11518 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11519 TOKEN_STRING_INITIALIZER
11520 (struct cmd_macsec_offload_on_result,
11521 offload, "offload");
11522 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11523 TOKEN_NUM_INITIALIZER
11524 (struct cmd_macsec_offload_on_result,
11525 port_id, RTE_UINT16);
11526 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11527 TOKEN_STRING_INITIALIZER
11528 (struct cmd_macsec_offload_on_result,
11530 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11531 TOKEN_STRING_INITIALIZER
11532 (struct cmd_macsec_offload_on_result,
11533 encrypt, "encrypt");
11534 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11535 TOKEN_STRING_INITIALIZER
11536 (struct cmd_macsec_offload_on_result,
11537 en_on_off, "on#off");
11538 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11539 TOKEN_STRING_INITIALIZER
11540 (struct cmd_macsec_offload_on_result,
11541 replay_protect, "replay-protect");
11542 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11543 TOKEN_STRING_INITIALIZER
11544 (struct cmd_macsec_offload_on_result,
11545 rp_on_off, "on#off");
11548 cmd_set_macsec_offload_on_parsed(
11549 void *parsed_result,
11550 __rte_unused struct cmdline *cl,
11551 __rte_unused void *data)
11553 struct cmd_macsec_offload_on_result *res = parsed_result;
11554 int ret = -ENOTSUP;
11555 portid_t port_id = res->port_id;
11556 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11557 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11558 struct rte_eth_dev_info dev_info;
11560 if (port_id_is_invalid(port_id, ENABLED_WARN))
11562 if (!port_is_stopped(port_id)) {
11563 printf("Please stop port %d first\n", port_id);
11567 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11571 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11572 #ifdef RTE_NET_IXGBE
11573 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11581 ports[port_id].dev_conf.txmode.offloads |=
11582 DEV_TX_OFFLOAD_MACSEC_INSERT;
11583 cmd_reconfig_device_queue(port_id, 1, 1);
11586 printf("invalid port_id %d\n", port_id);
11589 printf("not supported on port %d\n", port_id);
11592 printf("programming error: (%s)\n", strerror(-ret));
11596 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11597 .f = cmd_set_macsec_offload_on_parsed,
11599 .help_str = "set macsec offload <port_id> on "
11600 "encrypt on|off replay-protect on|off",
11602 (void *)&cmd_macsec_offload_on_set,
11603 (void *)&cmd_macsec_offload_on_macsec,
11604 (void *)&cmd_macsec_offload_on_offload,
11605 (void *)&cmd_macsec_offload_on_port_id,
11606 (void *)&cmd_macsec_offload_on_on,
11607 (void *)&cmd_macsec_offload_on_encrypt,
11608 (void *)&cmd_macsec_offload_on_en_on_off,
11609 (void *)&cmd_macsec_offload_on_replay_protect,
11610 (void *)&cmd_macsec_offload_on_rp_on_off,
11615 /* Common result structure for MACsec offload disable */
11616 struct cmd_macsec_offload_off_result {
11617 cmdline_fixed_string_t set;
11618 cmdline_fixed_string_t macsec;
11619 cmdline_fixed_string_t offload;
11621 cmdline_fixed_string_t off;
11624 /* Common CLI fields for MACsec offload disable */
11625 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11626 TOKEN_STRING_INITIALIZER
11627 (struct cmd_macsec_offload_off_result,
11629 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11630 TOKEN_STRING_INITIALIZER
11631 (struct cmd_macsec_offload_off_result,
11633 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11634 TOKEN_STRING_INITIALIZER
11635 (struct cmd_macsec_offload_off_result,
11636 offload, "offload");
11637 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11638 TOKEN_NUM_INITIALIZER
11639 (struct cmd_macsec_offload_off_result,
11640 port_id, RTE_UINT16);
11641 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11642 TOKEN_STRING_INITIALIZER
11643 (struct cmd_macsec_offload_off_result,
11647 cmd_set_macsec_offload_off_parsed(
11648 void *parsed_result,
11649 __rte_unused struct cmdline *cl,
11650 __rte_unused void *data)
11652 struct cmd_macsec_offload_off_result *res = parsed_result;
11653 int ret = -ENOTSUP;
11654 struct rte_eth_dev_info dev_info;
11655 portid_t port_id = res->port_id;
11657 if (port_id_is_invalid(port_id, ENABLED_WARN))
11659 if (!port_is_stopped(port_id)) {
11660 printf("Please stop port %d first\n", port_id);
11664 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11668 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11669 #ifdef RTE_NET_IXGBE
11670 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11675 ports[port_id].dev_conf.txmode.offloads &=
11676 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
11677 cmd_reconfig_device_queue(port_id, 1, 1);
11680 printf("invalid port_id %d\n", port_id);
11683 printf("not supported on port %d\n", port_id);
11686 printf("programming error: (%s)\n", strerror(-ret));
11690 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11691 .f = cmd_set_macsec_offload_off_parsed,
11693 .help_str = "set macsec offload <port_id> off",
11695 (void *)&cmd_macsec_offload_off_set,
11696 (void *)&cmd_macsec_offload_off_macsec,
11697 (void *)&cmd_macsec_offload_off_offload,
11698 (void *)&cmd_macsec_offload_off_port_id,
11699 (void *)&cmd_macsec_offload_off_off,
11704 /* Common result structure for MACsec secure connection configure */
11705 struct cmd_macsec_sc_result {
11706 cmdline_fixed_string_t set;
11707 cmdline_fixed_string_t macsec;
11708 cmdline_fixed_string_t sc;
11709 cmdline_fixed_string_t tx_rx;
11711 struct rte_ether_addr mac;
11715 /* Common CLI fields for MACsec secure connection configure */
11716 cmdline_parse_token_string_t cmd_macsec_sc_set =
11717 TOKEN_STRING_INITIALIZER
11718 (struct cmd_macsec_sc_result,
11720 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11721 TOKEN_STRING_INITIALIZER
11722 (struct cmd_macsec_sc_result,
11724 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11725 TOKEN_STRING_INITIALIZER
11726 (struct cmd_macsec_sc_result,
11728 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11729 TOKEN_STRING_INITIALIZER
11730 (struct cmd_macsec_sc_result,
11732 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11733 TOKEN_NUM_INITIALIZER
11734 (struct cmd_macsec_sc_result,
11735 port_id, RTE_UINT16);
11736 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11737 TOKEN_ETHERADDR_INITIALIZER
11738 (struct cmd_macsec_sc_result,
11740 cmdline_parse_token_num_t cmd_macsec_sc_pi =
11741 TOKEN_NUM_INITIALIZER
11742 (struct cmd_macsec_sc_result,
11746 cmd_set_macsec_sc_parsed(
11747 void *parsed_result,
11748 __rte_unused struct cmdline *cl,
11749 __rte_unused void *data)
11751 struct cmd_macsec_sc_result *res = parsed_result;
11752 int ret = -ENOTSUP;
11753 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11755 #ifdef RTE_NET_IXGBE
11757 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
11758 res->mac.addr_bytes) :
11759 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
11760 res->mac.addr_bytes, res->pi);
11762 RTE_SET_USED(is_tx);
11768 printf("invalid port_id %d\n", res->port_id);
11771 printf("not supported on port %d\n", res->port_id);
11774 printf("programming error: (%s)\n", strerror(-ret));
11778 cmdline_parse_inst_t cmd_set_macsec_sc = {
11779 .f = cmd_set_macsec_sc_parsed,
11781 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
11783 (void *)&cmd_macsec_sc_set,
11784 (void *)&cmd_macsec_sc_macsec,
11785 (void *)&cmd_macsec_sc_sc,
11786 (void *)&cmd_macsec_sc_tx_rx,
11787 (void *)&cmd_macsec_sc_port_id,
11788 (void *)&cmd_macsec_sc_mac,
11789 (void *)&cmd_macsec_sc_pi,
11794 /* Common result structure for MACsec secure connection configure */
11795 struct cmd_macsec_sa_result {
11796 cmdline_fixed_string_t set;
11797 cmdline_fixed_string_t macsec;
11798 cmdline_fixed_string_t sa;
11799 cmdline_fixed_string_t tx_rx;
11804 cmdline_fixed_string_t key;
11807 /* Common CLI fields for MACsec secure connection configure */
11808 cmdline_parse_token_string_t cmd_macsec_sa_set =
11809 TOKEN_STRING_INITIALIZER
11810 (struct cmd_macsec_sa_result,
11812 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
11813 TOKEN_STRING_INITIALIZER
11814 (struct cmd_macsec_sa_result,
11816 cmdline_parse_token_string_t cmd_macsec_sa_sa =
11817 TOKEN_STRING_INITIALIZER
11818 (struct cmd_macsec_sa_result,
11820 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
11821 TOKEN_STRING_INITIALIZER
11822 (struct cmd_macsec_sa_result,
11824 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
11825 TOKEN_NUM_INITIALIZER
11826 (struct cmd_macsec_sa_result,
11827 port_id, RTE_UINT16);
11828 cmdline_parse_token_num_t cmd_macsec_sa_idx =
11829 TOKEN_NUM_INITIALIZER
11830 (struct cmd_macsec_sa_result,
11832 cmdline_parse_token_num_t cmd_macsec_sa_an =
11833 TOKEN_NUM_INITIALIZER
11834 (struct cmd_macsec_sa_result,
11836 cmdline_parse_token_num_t cmd_macsec_sa_pn =
11837 TOKEN_NUM_INITIALIZER
11838 (struct cmd_macsec_sa_result,
11840 cmdline_parse_token_string_t cmd_macsec_sa_key =
11841 TOKEN_STRING_INITIALIZER
11842 (struct cmd_macsec_sa_result,
11846 cmd_set_macsec_sa_parsed(
11847 void *parsed_result,
11848 __rte_unused struct cmdline *cl,
11849 __rte_unused void *data)
11851 struct cmd_macsec_sa_result *res = parsed_result;
11852 int ret = -ENOTSUP;
11853 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
11854 uint8_t key[16] = { 0 };
11860 key_len = strlen(res->key) / 2;
11864 for (i = 0; i < key_len; i++) {
11865 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
11868 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
11871 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
11874 #ifdef RTE_NET_IXGBE
11876 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
11877 res->idx, res->an, res->pn, key) :
11878 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
11879 res->idx, res->an, res->pn, key);
11881 RTE_SET_USED(is_tx);
11888 printf("invalid idx %d or an %d\n", res->idx, res->an);
11891 printf("invalid port_id %d\n", res->port_id);
11894 printf("not supported on port %d\n", res->port_id);
11897 printf("programming error: (%s)\n", strerror(-ret));
11901 cmdline_parse_inst_t cmd_set_macsec_sa = {
11902 .f = cmd_set_macsec_sa_parsed,
11904 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
11906 (void *)&cmd_macsec_sa_set,
11907 (void *)&cmd_macsec_sa_macsec,
11908 (void *)&cmd_macsec_sa_sa,
11909 (void *)&cmd_macsec_sa_tx_rx,
11910 (void *)&cmd_macsec_sa_port_id,
11911 (void *)&cmd_macsec_sa_idx,
11912 (void *)&cmd_macsec_sa_an,
11913 (void *)&cmd_macsec_sa_pn,
11914 (void *)&cmd_macsec_sa_key,
11919 /* VF unicast promiscuous mode configuration */
11921 /* Common result structure for VF unicast promiscuous mode */
11922 struct cmd_vf_promisc_result {
11923 cmdline_fixed_string_t set;
11924 cmdline_fixed_string_t vf;
11925 cmdline_fixed_string_t promisc;
11928 cmdline_fixed_string_t on_off;
11931 /* Common CLI fields for VF unicast promiscuous mode enable disable */
11932 cmdline_parse_token_string_t cmd_vf_promisc_set =
11933 TOKEN_STRING_INITIALIZER
11934 (struct cmd_vf_promisc_result,
11936 cmdline_parse_token_string_t cmd_vf_promisc_vf =
11937 TOKEN_STRING_INITIALIZER
11938 (struct cmd_vf_promisc_result,
11940 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
11941 TOKEN_STRING_INITIALIZER
11942 (struct cmd_vf_promisc_result,
11943 promisc, "promisc");
11944 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
11945 TOKEN_NUM_INITIALIZER
11946 (struct cmd_vf_promisc_result,
11947 port_id, RTE_UINT16);
11948 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
11949 TOKEN_NUM_INITIALIZER
11950 (struct cmd_vf_promisc_result,
11951 vf_id, RTE_UINT32);
11952 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
11953 TOKEN_STRING_INITIALIZER
11954 (struct cmd_vf_promisc_result,
11958 cmd_set_vf_promisc_parsed(
11959 void *parsed_result,
11960 __rte_unused struct cmdline *cl,
11961 __rte_unused void *data)
11963 struct cmd_vf_promisc_result *res = parsed_result;
11964 int ret = -ENOTSUP;
11966 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11968 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11971 #ifdef RTE_NET_I40E
11972 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
11973 res->vf_id, is_on);
11980 printf("invalid vf_id %d\n", res->vf_id);
11983 printf("invalid port_id %d\n", res->port_id);
11986 printf("function not implemented\n");
11989 printf("programming error: (%s)\n", strerror(-ret));
11993 cmdline_parse_inst_t cmd_set_vf_promisc = {
11994 .f = cmd_set_vf_promisc_parsed,
11996 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
11997 "Set unicast promiscuous mode for a VF from the PF",
11999 (void *)&cmd_vf_promisc_set,
12000 (void *)&cmd_vf_promisc_vf,
12001 (void *)&cmd_vf_promisc_promisc,
12002 (void *)&cmd_vf_promisc_port_id,
12003 (void *)&cmd_vf_promisc_vf_id,
12004 (void *)&cmd_vf_promisc_on_off,
12009 /* VF multicast promiscuous mode configuration */
12011 /* Common result structure for VF multicast promiscuous mode */
12012 struct cmd_vf_allmulti_result {
12013 cmdline_fixed_string_t set;
12014 cmdline_fixed_string_t vf;
12015 cmdline_fixed_string_t allmulti;
12018 cmdline_fixed_string_t on_off;
12021 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12022 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12023 TOKEN_STRING_INITIALIZER
12024 (struct cmd_vf_allmulti_result,
12026 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12027 TOKEN_STRING_INITIALIZER
12028 (struct cmd_vf_allmulti_result,
12030 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12031 TOKEN_STRING_INITIALIZER
12032 (struct cmd_vf_allmulti_result,
12033 allmulti, "allmulti");
12034 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12035 TOKEN_NUM_INITIALIZER
12036 (struct cmd_vf_allmulti_result,
12037 port_id, RTE_UINT16);
12038 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12039 TOKEN_NUM_INITIALIZER
12040 (struct cmd_vf_allmulti_result,
12041 vf_id, RTE_UINT32);
12042 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12043 TOKEN_STRING_INITIALIZER
12044 (struct cmd_vf_allmulti_result,
12048 cmd_set_vf_allmulti_parsed(
12049 void *parsed_result,
12050 __rte_unused struct cmdline *cl,
12051 __rte_unused void *data)
12053 struct cmd_vf_allmulti_result *res = parsed_result;
12054 int ret = -ENOTSUP;
12056 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12058 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12061 #ifdef RTE_NET_I40E
12062 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12063 res->vf_id, is_on);
12070 printf("invalid vf_id %d\n", res->vf_id);
12073 printf("invalid port_id %d\n", res->port_id);
12076 printf("function not implemented\n");
12079 printf("programming error: (%s)\n", strerror(-ret));
12083 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12084 .f = cmd_set_vf_allmulti_parsed,
12086 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12087 "Set multicast promiscuous mode for a VF from the PF",
12089 (void *)&cmd_vf_allmulti_set,
12090 (void *)&cmd_vf_allmulti_vf,
12091 (void *)&cmd_vf_allmulti_allmulti,
12092 (void *)&cmd_vf_allmulti_port_id,
12093 (void *)&cmd_vf_allmulti_vf_id,
12094 (void *)&cmd_vf_allmulti_on_off,
12099 /* vf broadcast mode configuration */
12101 /* Common result structure for vf broadcast */
12102 struct cmd_set_vf_broadcast_result {
12103 cmdline_fixed_string_t set;
12104 cmdline_fixed_string_t vf;
12105 cmdline_fixed_string_t broadcast;
12108 cmdline_fixed_string_t on_off;
12111 /* Common CLI fields for vf broadcast enable disable */
12112 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12113 TOKEN_STRING_INITIALIZER
12114 (struct cmd_set_vf_broadcast_result,
12116 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12117 TOKEN_STRING_INITIALIZER
12118 (struct cmd_set_vf_broadcast_result,
12120 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12121 TOKEN_STRING_INITIALIZER
12122 (struct cmd_set_vf_broadcast_result,
12123 broadcast, "broadcast");
12124 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12125 TOKEN_NUM_INITIALIZER
12126 (struct cmd_set_vf_broadcast_result,
12127 port_id, RTE_UINT16);
12128 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12129 TOKEN_NUM_INITIALIZER
12130 (struct cmd_set_vf_broadcast_result,
12131 vf_id, RTE_UINT16);
12132 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12133 TOKEN_STRING_INITIALIZER
12134 (struct cmd_set_vf_broadcast_result,
12138 cmd_set_vf_broadcast_parsed(
12139 void *parsed_result,
12140 __rte_unused struct cmdline *cl,
12141 __rte_unused void *data)
12143 struct cmd_set_vf_broadcast_result *res = parsed_result;
12144 int ret = -ENOTSUP;
12146 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12148 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12151 #ifdef RTE_NET_I40E
12152 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12153 res->vf_id, is_on);
12160 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12163 printf("invalid port_id %d\n", res->port_id);
12166 printf("function not implemented\n");
12169 printf("programming error: (%s)\n", strerror(-ret));
12173 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12174 .f = cmd_set_vf_broadcast_parsed,
12176 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12178 (void *)&cmd_set_vf_broadcast_set,
12179 (void *)&cmd_set_vf_broadcast_vf,
12180 (void *)&cmd_set_vf_broadcast_broadcast,
12181 (void *)&cmd_set_vf_broadcast_port_id,
12182 (void *)&cmd_set_vf_broadcast_vf_id,
12183 (void *)&cmd_set_vf_broadcast_on_off,
12188 /* vf vlan tag configuration */
12190 /* Common result structure for vf vlan tag */
12191 struct cmd_set_vf_vlan_tag_result {
12192 cmdline_fixed_string_t set;
12193 cmdline_fixed_string_t vf;
12194 cmdline_fixed_string_t vlan;
12195 cmdline_fixed_string_t tag;
12198 cmdline_fixed_string_t on_off;
12201 /* Common CLI fields for vf vlan tag enable disable */
12202 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12203 TOKEN_STRING_INITIALIZER
12204 (struct cmd_set_vf_vlan_tag_result,
12206 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12207 TOKEN_STRING_INITIALIZER
12208 (struct cmd_set_vf_vlan_tag_result,
12210 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12211 TOKEN_STRING_INITIALIZER
12212 (struct cmd_set_vf_vlan_tag_result,
12214 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12215 TOKEN_STRING_INITIALIZER
12216 (struct cmd_set_vf_vlan_tag_result,
12218 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12219 TOKEN_NUM_INITIALIZER
12220 (struct cmd_set_vf_vlan_tag_result,
12221 port_id, RTE_UINT16);
12222 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12223 TOKEN_NUM_INITIALIZER
12224 (struct cmd_set_vf_vlan_tag_result,
12225 vf_id, RTE_UINT16);
12226 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12227 TOKEN_STRING_INITIALIZER
12228 (struct cmd_set_vf_vlan_tag_result,
12232 cmd_set_vf_vlan_tag_parsed(
12233 void *parsed_result,
12234 __rte_unused struct cmdline *cl,
12235 __rte_unused void *data)
12237 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12238 int ret = -ENOTSUP;
12240 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12242 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12245 #ifdef RTE_NET_I40E
12246 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12247 res->vf_id, is_on);
12254 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
12257 printf("invalid port_id %d\n", res->port_id);
12260 printf("function not implemented\n");
12263 printf("programming error: (%s)\n", strerror(-ret));
12267 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12268 .f = cmd_set_vf_vlan_tag_parsed,
12270 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12272 (void *)&cmd_set_vf_vlan_tag_set,
12273 (void *)&cmd_set_vf_vlan_tag_vf,
12274 (void *)&cmd_set_vf_vlan_tag_vlan,
12275 (void *)&cmd_set_vf_vlan_tag_tag,
12276 (void *)&cmd_set_vf_vlan_tag_port_id,
12277 (void *)&cmd_set_vf_vlan_tag_vf_id,
12278 (void *)&cmd_set_vf_vlan_tag_on_off,
12283 /* Common definition of VF and TC TX bandwidth configuration */
12284 struct cmd_vf_tc_bw_result {
12285 cmdline_fixed_string_t set;
12286 cmdline_fixed_string_t vf;
12287 cmdline_fixed_string_t tc;
12288 cmdline_fixed_string_t tx;
12289 cmdline_fixed_string_t min_bw;
12290 cmdline_fixed_string_t max_bw;
12291 cmdline_fixed_string_t strict_link_prio;
12296 cmdline_fixed_string_t bw_list;
12300 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12301 TOKEN_STRING_INITIALIZER
12302 (struct cmd_vf_tc_bw_result,
12304 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12305 TOKEN_STRING_INITIALIZER
12306 (struct cmd_vf_tc_bw_result,
12308 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12309 TOKEN_STRING_INITIALIZER
12310 (struct cmd_vf_tc_bw_result,
12312 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12313 TOKEN_STRING_INITIALIZER
12314 (struct cmd_vf_tc_bw_result,
12316 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12317 TOKEN_STRING_INITIALIZER
12318 (struct cmd_vf_tc_bw_result,
12319 strict_link_prio, "strict-link-priority");
12320 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12321 TOKEN_STRING_INITIALIZER
12322 (struct cmd_vf_tc_bw_result,
12323 min_bw, "min-bandwidth");
12324 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12325 TOKEN_STRING_INITIALIZER
12326 (struct cmd_vf_tc_bw_result,
12327 max_bw, "max-bandwidth");
12328 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12329 TOKEN_NUM_INITIALIZER
12330 (struct cmd_vf_tc_bw_result,
12331 port_id, RTE_UINT16);
12332 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12333 TOKEN_NUM_INITIALIZER
12334 (struct cmd_vf_tc_bw_result,
12335 vf_id, RTE_UINT16);
12336 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12337 TOKEN_NUM_INITIALIZER
12338 (struct cmd_vf_tc_bw_result,
12340 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12341 TOKEN_NUM_INITIALIZER
12342 (struct cmd_vf_tc_bw_result,
12344 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12345 TOKEN_STRING_INITIALIZER
12346 (struct cmd_vf_tc_bw_result,
12348 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12349 TOKEN_NUM_INITIALIZER
12350 (struct cmd_vf_tc_bw_result,
12351 tc_map, RTE_UINT8);
12353 /* VF max bandwidth setting */
12355 cmd_vf_max_bw_parsed(
12356 void *parsed_result,
12357 __rte_unused struct cmdline *cl,
12358 __rte_unused void *data)
12360 struct cmd_vf_tc_bw_result *res = parsed_result;
12361 int ret = -ENOTSUP;
12363 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12366 #ifdef RTE_NET_I40E
12367 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12368 res->vf_id, res->bw);
12375 printf("invalid vf_id %d or bandwidth %d\n",
12376 res->vf_id, res->bw);
12379 printf("invalid port_id %d\n", res->port_id);
12382 printf("function not implemented\n");
12385 printf("programming error: (%s)\n", strerror(-ret));
12389 cmdline_parse_inst_t cmd_vf_max_bw = {
12390 .f = cmd_vf_max_bw_parsed,
12392 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12394 (void *)&cmd_vf_tc_bw_set,
12395 (void *)&cmd_vf_tc_bw_vf,
12396 (void *)&cmd_vf_tc_bw_tx,
12397 (void *)&cmd_vf_tc_bw_max_bw,
12398 (void *)&cmd_vf_tc_bw_port_id,
12399 (void *)&cmd_vf_tc_bw_vf_id,
12400 (void *)&cmd_vf_tc_bw_bw,
12406 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12411 const char *p, *p0 = str;
12418 p = strchr(p0, '(');
12420 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12424 p0 = strchr(p, ')');
12426 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
12430 if (size >= sizeof(s)) {
12431 printf("The string size exceeds the internal buffer size\n");
12434 snprintf(s, sizeof(s), "%.*s", size, p);
12435 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12437 printf("Failed to get the bandwidth list. ");
12441 for (i = 0; i < ret; i++)
12442 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12447 /* TC min bandwidth setting */
12449 cmd_vf_tc_min_bw_parsed(
12450 void *parsed_result,
12451 __rte_unused struct cmdline *cl,
12452 __rte_unused void *data)
12454 struct cmd_vf_tc_bw_result *res = parsed_result;
12457 int ret = -ENOTSUP;
12459 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12462 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12466 #ifdef RTE_NET_I40E
12467 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12475 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
12478 printf("invalid port_id %d\n", res->port_id);
12481 printf("function not implemented\n");
12484 printf("programming error: (%s)\n", strerror(-ret));
12488 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12489 .f = cmd_vf_tc_min_bw_parsed,
12491 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12492 " <bw1, bw2, ...>",
12494 (void *)&cmd_vf_tc_bw_set,
12495 (void *)&cmd_vf_tc_bw_vf,
12496 (void *)&cmd_vf_tc_bw_tc,
12497 (void *)&cmd_vf_tc_bw_tx,
12498 (void *)&cmd_vf_tc_bw_min_bw,
12499 (void *)&cmd_vf_tc_bw_port_id,
12500 (void *)&cmd_vf_tc_bw_vf_id,
12501 (void *)&cmd_vf_tc_bw_bw_list,
12507 cmd_tc_min_bw_parsed(
12508 void *parsed_result,
12509 __rte_unused struct cmdline *cl,
12510 __rte_unused void *data)
12512 struct cmd_vf_tc_bw_result *res = parsed_result;
12513 struct rte_port *port;
12516 int ret = -ENOTSUP;
12518 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12521 port = &ports[res->port_id];
12522 /** Check if the port is not started **/
12523 if (port->port_status != RTE_PORT_STOPPED) {
12524 printf("Please stop port %d first\n", res->port_id);
12528 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12532 #ifdef RTE_NET_IXGBE
12533 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12540 printf("invalid bandwidth\n");
12543 printf("invalid port_id %d\n", res->port_id);
12546 printf("function not implemented\n");
12549 printf("programming error: (%s)\n", strerror(-ret));
12553 cmdline_parse_inst_t cmd_tc_min_bw = {
12554 .f = cmd_tc_min_bw_parsed,
12556 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12558 (void *)&cmd_vf_tc_bw_set,
12559 (void *)&cmd_vf_tc_bw_tc,
12560 (void *)&cmd_vf_tc_bw_tx,
12561 (void *)&cmd_vf_tc_bw_min_bw,
12562 (void *)&cmd_vf_tc_bw_port_id,
12563 (void *)&cmd_vf_tc_bw_bw_list,
12568 /* TC max bandwidth setting */
12570 cmd_vf_tc_max_bw_parsed(
12571 void *parsed_result,
12572 __rte_unused struct cmdline *cl,
12573 __rte_unused void *data)
12575 struct cmd_vf_tc_bw_result *res = parsed_result;
12576 int ret = -ENOTSUP;
12578 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12581 #ifdef RTE_NET_I40E
12582 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12583 res->tc_no, res->bw);
12590 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
12591 res->vf_id, res->tc_no, res->bw);
12594 printf("invalid port_id %d\n", res->port_id);
12597 printf("function not implemented\n");
12600 printf("programming error: (%s)\n", strerror(-ret));
12604 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12605 .f = cmd_vf_tc_max_bw_parsed,
12607 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12610 (void *)&cmd_vf_tc_bw_set,
12611 (void *)&cmd_vf_tc_bw_vf,
12612 (void *)&cmd_vf_tc_bw_tc,
12613 (void *)&cmd_vf_tc_bw_tx,
12614 (void *)&cmd_vf_tc_bw_max_bw,
12615 (void *)&cmd_vf_tc_bw_port_id,
12616 (void *)&cmd_vf_tc_bw_vf_id,
12617 (void *)&cmd_vf_tc_bw_tc_no,
12618 (void *)&cmd_vf_tc_bw_bw,
12623 /** Set VXLAN encapsulation details */
12624 struct cmd_set_vxlan_result {
12625 cmdline_fixed_string_t set;
12626 cmdline_fixed_string_t vxlan;
12627 cmdline_fixed_string_t pos_token;
12628 cmdline_fixed_string_t ip_version;
12629 uint32_t vlan_present:1;
12633 cmdline_ipaddr_t ip_src;
12634 cmdline_ipaddr_t ip_dst;
12638 struct rte_ether_addr eth_src;
12639 struct rte_ether_addr eth_dst;
12642 cmdline_parse_token_string_t cmd_set_vxlan_set =
12643 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
12644 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
12645 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
12646 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
12647 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12649 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
12650 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12651 "vxlan-with-vlan");
12652 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
12653 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12655 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
12656 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
12658 cmdline_parse_token_string_t cmd_set_vxlan_vni =
12659 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12661 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
12662 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
12663 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
12664 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12666 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
12667 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
12668 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
12669 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12671 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
12672 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
12673 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
12674 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12676 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
12677 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
12678 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
12679 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12681 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
12682 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
12683 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
12684 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12686 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
12687 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
12688 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
12689 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12691 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
12692 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
12693 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
12694 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12696 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
12697 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
12698 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
12699 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12701 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
12702 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
12703 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
12704 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12706 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
12707 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
12709 static void cmd_set_vxlan_parsed(void *parsed_result,
12710 __rte_unused struct cmdline *cl,
12711 __rte_unused void *data)
12713 struct cmd_set_vxlan_result *res = parsed_result;
12718 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
12721 vxlan_encap_conf.select_tos_ttl = 0;
12722 if (strcmp(res->vxlan, "vxlan") == 0)
12723 vxlan_encap_conf.select_vlan = 0;
12724 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
12725 vxlan_encap_conf.select_vlan = 1;
12726 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
12727 vxlan_encap_conf.select_vlan = 0;
12728 vxlan_encap_conf.select_tos_ttl = 1;
12730 if (strcmp(res->ip_version, "ipv4") == 0)
12731 vxlan_encap_conf.select_ipv4 = 1;
12732 else if (strcmp(res->ip_version, "ipv6") == 0)
12733 vxlan_encap_conf.select_ipv4 = 0;
12736 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
12737 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
12738 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
12739 vxlan_encap_conf.ip_tos = res->tos;
12740 vxlan_encap_conf.ip_ttl = res->ttl;
12741 if (vxlan_encap_conf.select_ipv4) {
12742 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
12743 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
12745 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
12746 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
12748 if (vxlan_encap_conf.select_vlan)
12749 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
12750 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
12751 RTE_ETHER_ADDR_LEN);
12752 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
12753 RTE_ETHER_ADDR_LEN);
12756 cmdline_parse_inst_t cmd_set_vxlan = {
12757 .f = cmd_set_vxlan_parsed,
12759 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
12760 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
12761 " eth-src <eth-src> eth-dst <eth-dst>",
12763 (void *)&cmd_set_vxlan_set,
12764 (void *)&cmd_set_vxlan_vxlan,
12765 (void *)&cmd_set_vxlan_ip_version,
12766 (void *)&cmd_set_vxlan_ip_version_value,
12767 (void *)&cmd_set_vxlan_vni,
12768 (void *)&cmd_set_vxlan_vni_value,
12769 (void *)&cmd_set_vxlan_udp_src,
12770 (void *)&cmd_set_vxlan_udp_src_value,
12771 (void *)&cmd_set_vxlan_udp_dst,
12772 (void *)&cmd_set_vxlan_udp_dst_value,
12773 (void *)&cmd_set_vxlan_ip_src,
12774 (void *)&cmd_set_vxlan_ip_src_value,
12775 (void *)&cmd_set_vxlan_ip_dst,
12776 (void *)&cmd_set_vxlan_ip_dst_value,
12777 (void *)&cmd_set_vxlan_eth_src,
12778 (void *)&cmd_set_vxlan_eth_src_value,
12779 (void *)&cmd_set_vxlan_eth_dst,
12780 (void *)&cmd_set_vxlan_eth_dst_value,
12785 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
12786 .f = cmd_set_vxlan_parsed,
12788 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
12789 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
12790 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
12791 " eth-dst <eth-dst>",
12793 (void *)&cmd_set_vxlan_set,
12794 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
12795 (void *)&cmd_set_vxlan_ip_version,
12796 (void *)&cmd_set_vxlan_ip_version_value,
12797 (void *)&cmd_set_vxlan_vni,
12798 (void *)&cmd_set_vxlan_vni_value,
12799 (void *)&cmd_set_vxlan_udp_src,
12800 (void *)&cmd_set_vxlan_udp_src_value,
12801 (void *)&cmd_set_vxlan_udp_dst,
12802 (void *)&cmd_set_vxlan_udp_dst_value,
12803 (void *)&cmd_set_vxlan_ip_tos,
12804 (void *)&cmd_set_vxlan_ip_tos_value,
12805 (void *)&cmd_set_vxlan_ip_ttl,
12806 (void *)&cmd_set_vxlan_ip_ttl_value,
12807 (void *)&cmd_set_vxlan_ip_src,
12808 (void *)&cmd_set_vxlan_ip_src_value,
12809 (void *)&cmd_set_vxlan_ip_dst,
12810 (void *)&cmd_set_vxlan_ip_dst_value,
12811 (void *)&cmd_set_vxlan_eth_src,
12812 (void *)&cmd_set_vxlan_eth_src_value,
12813 (void *)&cmd_set_vxlan_eth_dst,
12814 (void *)&cmd_set_vxlan_eth_dst_value,
12819 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
12820 .f = cmd_set_vxlan_parsed,
12822 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
12823 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
12824 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
12827 (void *)&cmd_set_vxlan_set,
12828 (void *)&cmd_set_vxlan_vxlan_with_vlan,
12829 (void *)&cmd_set_vxlan_ip_version,
12830 (void *)&cmd_set_vxlan_ip_version_value,
12831 (void *)&cmd_set_vxlan_vni,
12832 (void *)&cmd_set_vxlan_vni_value,
12833 (void *)&cmd_set_vxlan_udp_src,
12834 (void *)&cmd_set_vxlan_udp_src_value,
12835 (void *)&cmd_set_vxlan_udp_dst,
12836 (void *)&cmd_set_vxlan_udp_dst_value,
12837 (void *)&cmd_set_vxlan_ip_src,
12838 (void *)&cmd_set_vxlan_ip_src_value,
12839 (void *)&cmd_set_vxlan_ip_dst,
12840 (void *)&cmd_set_vxlan_ip_dst_value,
12841 (void *)&cmd_set_vxlan_vlan,
12842 (void *)&cmd_set_vxlan_vlan_value,
12843 (void *)&cmd_set_vxlan_eth_src,
12844 (void *)&cmd_set_vxlan_eth_src_value,
12845 (void *)&cmd_set_vxlan_eth_dst,
12846 (void *)&cmd_set_vxlan_eth_dst_value,
12851 /** Set NVGRE encapsulation details */
12852 struct cmd_set_nvgre_result {
12853 cmdline_fixed_string_t set;
12854 cmdline_fixed_string_t nvgre;
12855 cmdline_fixed_string_t pos_token;
12856 cmdline_fixed_string_t ip_version;
12858 cmdline_ipaddr_t ip_src;
12859 cmdline_ipaddr_t ip_dst;
12861 struct rte_ether_addr eth_src;
12862 struct rte_ether_addr eth_dst;
12865 cmdline_parse_token_string_t cmd_set_nvgre_set =
12866 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
12867 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
12868 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
12869 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
12870 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
12871 "nvgre-with-vlan");
12872 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
12873 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12875 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
12876 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
12878 cmdline_parse_token_string_t cmd_set_nvgre_tni =
12879 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12881 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
12882 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
12883 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
12884 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12886 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
12887 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
12888 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
12889 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12891 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
12892 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
12893 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
12894 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12896 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
12897 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
12898 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
12899 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12901 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
12902 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
12903 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
12904 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
12906 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
12907 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
12909 static void cmd_set_nvgre_parsed(void *parsed_result,
12910 __rte_unused struct cmdline *cl,
12911 __rte_unused void *data)
12913 struct cmd_set_nvgre_result *res = parsed_result;
12915 uint32_t nvgre_tni;
12918 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
12921 if (strcmp(res->nvgre, "nvgre") == 0)
12922 nvgre_encap_conf.select_vlan = 0;
12923 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
12924 nvgre_encap_conf.select_vlan = 1;
12925 if (strcmp(res->ip_version, "ipv4") == 0)
12926 nvgre_encap_conf.select_ipv4 = 1;
12927 else if (strcmp(res->ip_version, "ipv6") == 0)
12928 nvgre_encap_conf.select_ipv4 = 0;
12931 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
12932 if (nvgre_encap_conf.select_ipv4) {
12933 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
12934 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
12936 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
12937 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
12939 if (nvgre_encap_conf.select_vlan)
12940 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
12941 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
12942 RTE_ETHER_ADDR_LEN);
12943 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
12944 RTE_ETHER_ADDR_LEN);
12947 cmdline_parse_inst_t cmd_set_nvgre = {
12948 .f = cmd_set_nvgre_parsed,
12950 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
12951 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
12952 " eth-dst <eth-dst>",
12954 (void *)&cmd_set_nvgre_set,
12955 (void *)&cmd_set_nvgre_nvgre,
12956 (void *)&cmd_set_nvgre_ip_version,
12957 (void *)&cmd_set_nvgre_ip_version_value,
12958 (void *)&cmd_set_nvgre_tni,
12959 (void *)&cmd_set_nvgre_tni_value,
12960 (void *)&cmd_set_nvgre_ip_src,
12961 (void *)&cmd_set_nvgre_ip_src_value,
12962 (void *)&cmd_set_nvgre_ip_dst,
12963 (void *)&cmd_set_nvgre_ip_dst_value,
12964 (void *)&cmd_set_nvgre_eth_src,
12965 (void *)&cmd_set_nvgre_eth_src_value,
12966 (void *)&cmd_set_nvgre_eth_dst,
12967 (void *)&cmd_set_nvgre_eth_dst_value,
12972 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
12973 .f = cmd_set_nvgre_parsed,
12975 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
12976 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
12977 " eth-src <eth-src> eth-dst <eth-dst>",
12979 (void *)&cmd_set_nvgre_set,
12980 (void *)&cmd_set_nvgre_nvgre_with_vlan,
12981 (void *)&cmd_set_nvgre_ip_version,
12982 (void *)&cmd_set_nvgre_ip_version_value,
12983 (void *)&cmd_set_nvgre_tni,
12984 (void *)&cmd_set_nvgre_tni_value,
12985 (void *)&cmd_set_nvgre_ip_src,
12986 (void *)&cmd_set_nvgre_ip_src_value,
12987 (void *)&cmd_set_nvgre_ip_dst,
12988 (void *)&cmd_set_nvgre_ip_dst_value,
12989 (void *)&cmd_set_nvgre_vlan,
12990 (void *)&cmd_set_nvgre_vlan_value,
12991 (void *)&cmd_set_nvgre_eth_src,
12992 (void *)&cmd_set_nvgre_eth_src_value,
12993 (void *)&cmd_set_nvgre_eth_dst,
12994 (void *)&cmd_set_nvgre_eth_dst_value,
12999 /** Set L2 encapsulation details */
13000 struct cmd_set_l2_encap_result {
13001 cmdline_fixed_string_t set;
13002 cmdline_fixed_string_t l2_encap;
13003 cmdline_fixed_string_t pos_token;
13004 cmdline_fixed_string_t ip_version;
13005 uint32_t vlan_present:1;
13007 struct rte_ether_addr eth_src;
13008 struct rte_ether_addr eth_dst;
13011 cmdline_parse_token_string_t cmd_set_l2_encap_set =
13012 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13013 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13014 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13015 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13016 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13017 "l2_encap-with-vlan");
13018 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13019 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13021 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13022 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13024 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13025 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13027 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13028 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13029 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13030 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13032 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13033 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13034 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13035 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13037 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13038 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13040 static void cmd_set_l2_encap_parsed(void *parsed_result,
13041 __rte_unused struct cmdline *cl,
13042 __rte_unused void *data)
13044 struct cmd_set_l2_encap_result *res = parsed_result;
13046 if (strcmp(res->l2_encap, "l2_encap") == 0)
13047 l2_encap_conf.select_vlan = 0;
13048 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13049 l2_encap_conf.select_vlan = 1;
13050 if (strcmp(res->ip_version, "ipv4") == 0)
13051 l2_encap_conf.select_ipv4 = 1;
13052 else if (strcmp(res->ip_version, "ipv6") == 0)
13053 l2_encap_conf.select_ipv4 = 0;
13056 if (l2_encap_conf.select_vlan)
13057 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13058 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13059 RTE_ETHER_ADDR_LEN);
13060 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13061 RTE_ETHER_ADDR_LEN);
13064 cmdline_parse_inst_t cmd_set_l2_encap = {
13065 .f = cmd_set_l2_encap_parsed,
13067 .help_str = "set l2_encap ip-version ipv4|ipv6"
13068 " eth-src <eth-src> eth-dst <eth-dst>",
13070 (void *)&cmd_set_l2_encap_set,
13071 (void *)&cmd_set_l2_encap_l2_encap,
13072 (void *)&cmd_set_l2_encap_ip_version,
13073 (void *)&cmd_set_l2_encap_ip_version_value,
13074 (void *)&cmd_set_l2_encap_eth_src,
13075 (void *)&cmd_set_l2_encap_eth_src_value,
13076 (void *)&cmd_set_l2_encap_eth_dst,
13077 (void *)&cmd_set_l2_encap_eth_dst_value,
13082 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13083 .f = cmd_set_l2_encap_parsed,
13085 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13086 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13088 (void *)&cmd_set_l2_encap_set,
13089 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13090 (void *)&cmd_set_l2_encap_ip_version,
13091 (void *)&cmd_set_l2_encap_ip_version_value,
13092 (void *)&cmd_set_l2_encap_vlan,
13093 (void *)&cmd_set_l2_encap_vlan_value,
13094 (void *)&cmd_set_l2_encap_eth_src,
13095 (void *)&cmd_set_l2_encap_eth_src_value,
13096 (void *)&cmd_set_l2_encap_eth_dst,
13097 (void *)&cmd_set_l2_encap_eth_dst_value,
13102 /** Set L2 decapsulation details */
13103 struct cmd_set_l2_decap_result {
13104 cmdline_fixed_string_t set;
13105 cmdline_fixed_string_t l2_decap;
13106 cmdline_fixed_string_t pos_token;
13107 uint32_t vlan_present:1;
13110 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13111 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13112 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13113 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13115 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13116 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13117 "l2_decap-with-vlan");
13119 static void cmd_set_l2_decap_parsed(void *parsed_result,
13120 __rte_unused struct cmdline *cl,
13121 __rte_unused void *data)
13123 struct cmd_set_l2_decap_result *res = parsed_result;
13125 if (strcmp(res->l2_decap, "l2_decap") == 0)
13126 l2_decap_conf.select_vlan = 0;
13127 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13128 l2_decap_conf.select_vlan = 1;
13131 cmdline_parse_inst_t cmd_set_l2_decap = {
13132 .f = cmd_set_l2_decap_parsed,
13134 .help_str = "set l2_decap",
13136 (void *)&cmd_set_l2_decap_set,
13137 (void *)&cmd_set_l2_decap_l2_decap,
13142 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13143 .f = cmd_set_l2_decap_parsed,
13145 .help_str = "set l2_decap-with-vlan",
13147 (void *)&cmd_set_l2_decap_set,
13148 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13153 /** Set MPLSoGRE encapsulation details */
13154 struct cmd_set_mplsogre_encap_result {
13155 cmdline_fixed_string_t set;
13156 cmdline_fixed_string_t mplsogre;
13157 cmdline_fixed_string_t pos_token;
13158 cmdline_fixed_string_t ip_version;
13159 uint32_t vlan_present:1;
13161 cmdline_ipaddr_t ip_src;
13162 cmdline_ipaddr_t ip_dst;
13164 struct rte_ether_addr eth_src;
13165 struct rte_ether_addr eth_dst;
13168 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13169 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13171 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13172 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13174 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13175 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13176 mplsogre, "mplsogre_encap-with-vlan");
13177 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13178 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13179 pos_token, "ip-version");
13180 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13181 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13182 ip_version, "ipv4#ipv6");
13183 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13184 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13185 pos_token, "label");
13186 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13187 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13189 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13190 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13191 pos_token, "ip-src");
13192 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13193 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13194 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13195 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13196 pos_token, "ip-dst");
13197 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13198 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13199 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13200 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13201 pos_token, "vlan-tci");
13202 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13203 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13205 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13206 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13207 pos_token, "eth-src");
13208 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13209 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13211 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13212 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13213 pos_token, "eth-dst");
13214 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13215 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13218 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13219 __rte_unused struct cmdline *cl,
13220 __rte_unused void *data)
13222 struct cmd_set_mplsogre_encap_result *res = parsed_result;
13224 uint32_t mplsogre_label;
13227 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13230 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13231 mplsogre_encap_conf.select_vlan = 0;
13232 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13233 mplsogre_encap_conf.select_vlan = 1;
13234 if (strcmp(res->ip_version, "ipv4") == 0)
13235 mplsogre_encap_conf.select_ipv4 = 1;
13236 else if (strcmp(res->ip_version, "ipv6") == 0)
13237 mplsogre_encap_conf.select_ipv4 = 0;
13240 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13241 if (mplsogre_encap_conf.select_ipv4) {
13242 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13243 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13245 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13246 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13248 if (mplsogre_encap_conf.select_vlan)
13249 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13250 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13251 RTE_ETHER_ADDR_LEN);
13252 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13253 RTE_ETHER_ADDR_LEN);
13256 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13257 .f = cmd_set_mplsogre_encap_parsed,
13259 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13260 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13261 " eth-dst <eth-dst>",
13263 (void *)&cmd_set_mplsogre_encap_set,
13264 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13265 (void *)&cmd_set_mplsogre_encap_ip_version,
13266 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13267 (void *)&cmd_set_mplsogre_encap_label,
13268 (void *)&cmd_set_mplsogre_encap_label_value,
13269 (void *)&cmd_set_mplsogre_encap_ip_src,
13270 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13271 (void *)&cmd_set_mplsogre_encap_ip_dst,
13272 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13273 (void *)&cmd_set_mplsogre_encap_eth_src,
13274 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13275 (void *)&cmd_set_mplsogre_encap_eth_dst,
13276 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13281 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13282 .f = cmd_set_mplsogre_encap_parsed,
13284 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13285 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
13286 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13288 (void *)&cmd_set_mplsogre_encap_set,
13289 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13290 (void *)&cmd_set_mplsogre_encap_ip_version,
13291 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13292 (void *)&cmd_set_mplsogre_encap_label,
13293 (void *)&cmd_set_mplsogre_encap_label_value,
13294 (void *)&cmd_set_mplsogre_encap_ip_src,
13295 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13296 (void *)&cmd_set_mplsogre_encap_ip_dst,
13297 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13298 (void *)&cmd_set_mplsogre_encap_vlan,
13299 (void *)&cmd_set_mplsogre_encap_vlan_value,
13300 (void *)&cmd_set_mplsogre_encap_eth_src,
13301 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13302 (void *)&cmd_set_mplsogre_encap_eth_dst,
13303 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13308 /** Set MPLSoGRE decapsulation details */
13309 struct cmd_set_mplsogre_decap_result {
13310 cmdline_fixed_string_t set;
13311 cmdline_fixed_string_t mplsogre;
13312 cmdline_fixed_string_t pos_token;
13313 cmdline_fixed_string_t ip_version;
13314 uint32_t vlan_present:1;
13317 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13318 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13320 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13321 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13323 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13324 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13325 mplsogre, "mplsogre_decap-with-vlan");
13326 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13327 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13328 pos_token, "ip-version");
13329 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13330 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13331 ip_version, "ipv4#ipv6");
13333 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13334 __rte_unused struct cmdline *cl,
13335 __rte_unused void *data)
13337 struct cmd_set_mplsogre_decap_result *res = parsed_result;
13339 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13340 mplsogre_decap_conf.select_vlan = 0;
13341 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13342 mplsogre_decap_conf.select_vlan = 1;
13343 if (strcmp(res->ip_version, "ipv4") == 0)
13344 mplsogre_decap_conf.select_ipv4 = 1;
13345 else if (strcmp(res->ip_version, "ipv6") == 0)
13346 mplsogre_decap_conf.select_ipv4 = 0;
13349 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13350 .f = cmd_set_mplsogre_decap_parsed,
13352 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13354 (void *)&cmd_set_mplsogre_decap_set,
13355 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13356 (void *)&cmd_set_mplsogre_decap_ip_version,
13357 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13362 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13363 .f = cmd_set_mplsogre_decap_parsed,
13365 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13367 (void *)&cmd_set_mplsogre_decap_set,
13368 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13369 (void *)&cmd_set_mplsogre_decap_ip_version,
13370 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13375 /** Set MPLSoUDP encapsulation details */
13376 struct cmd_set_mplsoudp_encap_result {
13377 cmdline_fixed_string_t set;
13378 cmdline_fixed_string_t mplsoudp;
13379 cmdline_fixed_string_t pos_token;
13380 cmdline_fixed_string_t ip_version;
13381 uint32_t vlan_present:1;
13385 cmdline_ipaddr_t ip_src;
13386 cmdline_ipaddr_t ip_dst;
13388 struct rte_ether_addr eth_src;
13389 struct rte_ether_addr eth_dst;
13392 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13393 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13395 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13396 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13398 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13399 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13400 mplsoudp, "mplsoudp_encap-with-vlan");
13401 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13402 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13403 pos_token, "ip-version");
13404 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13405 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13406 ip_version, "ipv4#ipv6");
13407 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13408 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13409 pos_token, "label");
13410 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13411 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13413 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13414 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13415 pos_token, "udp-src");
13416 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13417 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13419 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13420 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13421 pos_token, "udp-dst");
13422 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13423 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13425 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13426 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13427 pos_token, "ip-src");
13428 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13429 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13430 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13431 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13432 pos_token, "ip-dst");
13433 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13434 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13435 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13436 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13437 pos_token, "vlan-tci");
13438 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13439 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13441 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13442 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13443 pos_token, "eth-src");
13444 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13445 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13447 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13448 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13449 pos_token, "eth-dst");
13450 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13451 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13454 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13455 __rte_unused struct cmdline *cl,
13456 __rte_unused void *data)
13458 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13460 uint32_t mplsoudp_label;
13463 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13466 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13467 mplsoudp_encap_conf.select_vlan = 0;
13468 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13469 mplsoudp_encap_conf.select_vlan = 1;
13470 if (strcmp(res->ip_version, "ipv4") == 0)
13471 mplsoudp_encap_conf.select_ipv4 = 1;
13472 else if (strcmp(res->ip_version, "ipv6") == 0)
13473 mplsoudp_encap_conf.select_ipv4 = 0;
13476 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13477 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13478 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13479 if (mplsoudp_encap_conf.select_ipv4) {
13480 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13481 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13483 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13484 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13486 if (mplsoudp_encap_conf.select_vlan)
13487 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13488 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13489 RTE_ETHER_ADDR_LEN);
13490 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13491 RTE_ETHER_ADDR_LEN);
13494 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13495 .f = cmd_set_mplsoudp_encap_parsed,
13497 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13498 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13499 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13501 (void *)&cmd_set_mplsoudp_encap_set,
13502 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13503 (void *)&cmd_set_mplsoudp_encap_ip_version,
13504 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13505 (void *)&cmd_set_mplsoudp_encap_label,
13506 (void *)&cmd_set_mplsoudp_encap_label_value,
13507 (void *)&cmd_set_mplsoudp_encap_udp_src,
13508 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13509 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13510 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13511 (void *)&cmd_set_mplsoudp_encap_ip_src,
13512 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13513 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13514 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13515 (void *)&cmd_set_mplsoudp_encap_eth_src,
13516 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13517 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13518 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13523 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13524 .f = cmd_set_mplsoudp_encap_parsed,
13526 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13527 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
13528 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13529 " eth-src <eth-src> eth-dst <eth-dst>",
13531 (void *)&cmd_set_mplsoudp_encap_set,
13532 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13533 (void *)&cmd_set_mplsoudp_encap_ip_version,
13534 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13535 (void *)&cmd_set_mplsoudp_encap_label,
13536 (void *)&cmd_set_mplsoudp_encap_label_value,
13537 (void *)&cmd_set_mplsoudp_encap_udp_src,
13538 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13539 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13540 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13541 (void *)&cmd_set_mplsoudp_encap_ip_src,
13542 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13543 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13544 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13545 (void *)&cmd_set_mplsoudp_encap_vlan,
13546 (void *)&cmd_set_mplsoudp_encap_vlan_value,
13547 (void *)&cmd_set_mplsoudp_encap_eth_src,
13548 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13549 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13550 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13555 /** Set MPLSoUDP decapsulation details */
13556 struct cmd_set_mplsoudp_decap_result {
13557 cmdline_fixed_string_t set;
13558 cmdline_fixed_string_t mplsoudp;
13559 cmdline_fixed_string_t pos_token;
13560 cmdline_fixed_string_t ip_version;
13561 uint32_t vlan_present:1;
13564 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
13565 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
13567 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
13568 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
13570 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
13571 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13572 mplsoudp, "mplsoudp_decap-with-vlan");
13573 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
13574 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13575 pos_token, "ip-version");
13576 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
13577 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13578 ip_version, "ipv4#ipv6");
13580 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
13581 __rte_unused struct cmdline *cl,
13582 __rte_unused void *data)
13584 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
13586 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
13587 mplsoudp_decap_conf.select_vlan = 0;
13588 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
13589 mplsoudp_decap_conf.select_vlan = 1;
13590 if (strcmp(res->ip_version, "ipv4") == 0)
13591 mplsoudp_decap_conf.select_ipv4 = 1;
13592 else if (strcmp(res->ip_version, "ipv6") == 0)
13593 mplsoudp_decap_conf.select_ipv4 = 0;
13596 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
13597 .f = cmd_set_mplsoudp_decap_parsed,
13599 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
13601 (void *)&cmd_set_mplsoudp_decap_set,
13602 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
13603 (void *)&cmd_set_mplsoudp_decap_ip_version,
13604 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13609 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
13610 .f = cmd_set_mplsoudp_decap_parsed,
13612 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
13614 (void *)&cmd_set_mplsoudp_decap_set,
13615 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
13616 (void *)&cmd_set_mplsoudp_decap_ip_version,
13617 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13622 /* Strict link priority scheduling mode setting */
13624 cmd_strict_link_prio_parsed(
13625 void *parsed_result,
13626 __rte_unused struct cmdline *cl,
13627 __rte_unused void *data)
13629 struct cmd_vf_tc_bw_result *res = parsed_result;
13630 int ret = -ENOTSUP;
13632 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13635 #ifdef RTE_NET_I40E
13636 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
13643 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
13646 printf("invalid port_id %d\n", res->port_id);
13649 printf("function not implemented\n");
13652 printf("programming error: (%s)\n", strerror(-ret));
13656 cmdline_parse_inst_t cmd_strict_link_prio = {
13657 .f = cmd_strict_link_prio_parsed,
13659 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
13661 (void *)&cmd_vf_tc_bw_set,
13662 (void *)&cmd_vf_tc_bw_tx,
13663 (void *)&cmd_vf_tc_bw_strict_link_prio,
13664 (void *)&cmd_vf_tc_bw_port_id,
13665 (void *)&cmd_vf_tc_bw_tc_map,
13670 /* Load dynamic device personalization*/
13671 struct cmd_ddp_add_result {
13672 cmdline_fixed_string_t ddp;
13673 cmdline_fixed_string_t add;
13678 cmdline_parse_token_string_t cmd_ddp_add_ddp =
13679 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
13680 cmdline_parse_token_string_t cmd_ddp_add_add =
13681 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
13682 cmdline_parse_token_num_t cmd_ddp_add_port_id =
13683 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
13685 cmdline_parse_token_string_t cmd_ddp_add_filepath =
13686 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
13689 cmd_ddp_add_parsed(
13690 void *parsed_result,
13691 __rte_unused struct cmdline *cl,
13692 __rte_unused void *data)
13694 struct cmd_ddp_add_result *res = parsed_result;
13700 int ret = -ENOTSUP;
13702 if (!all_ports_stopped()) {
13703 printf("Please stop all ports first\n");
13707 filepath = strdup(res->filepath);
13708 if (filepath == NULL) {
13709 printf("Failed to allocate memory\n");
13712 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
13714 buff = open_file(file_fld[0], &size);
13716 free((void *)filepath);
13720 #ifdef RTE_NET_I40E
13721 if (ret == -ENOTSUP)
13722 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13724 RTE_PMD_I40E_PKG_OP_WR_ADD);
13727 if (ret == -EEXIST)
13728 printf("Profile has already existed.\n");
13730 printf("Failed to load profile.\n");
13731 else if (file_num == 2)
13732 save_file(file_fld[1], buff, size);
13735 free((void *)filepath);
13738 cmdline_parse_inst_t cmd_ddp_add = {
13739 .f = cmd_ddp_add_parsed,
13741 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
13743 (void *)&cmd_ddp_add_ddp,
13744 (void *)&cmd_ddp_add_add,
13745 (void *)&cmd_ddp_add_port_id,
13746 (void *)&cmd_ddp_add_filepath,
13751 /* Delete dynamic device personalization*/
13752 struct cmd_ddp_del_result {
13753 cmdline_fixed_string_t ddp;
13754 cmdline_fixed_string_t del;
13759 cmdline_parse_token_string_t cmd_ddp_del_ddp =
13760 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
13761 cmdline_parse_token_string_t cmd_ddp_del_del =
13762 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
13763 cmdline_parse_token_num_t cmd_ddp_del_port_id =
13764 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
13765 cmdline_parse_token_string_t cmd_ddp_del_filepath =
13766 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
13769 cmd_ddp_del_parsed(
13770 void *parsed_result,
13771 __rte_unused struct cmdline *cl,
13772 __rte_unused void *data)
13774 struct cmd_ddp_del_result *res = parsed_result;
13777 int ret = -ENOTSUP;
13779 if (!all_ports_stopped()) {
13780 printf("Please stop all ports first\n");
13784 buff = open_file(res->filepath, &size);
13788 #ifdef RTE_NET_I40E
13789 if (ret == -ENOTSUP)
13790 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
13792 RTE_PMD_I40E_PKG_OP_WR_DEL);
13795 if (ret == -EACCES)
13796 printf("Profile does not exist.\n");
13798 printf("Failed to delete profile.\n");
13803 cmdline_parse_inst_t cmd_ddp_del = {
13804 .f = cmd_ddp_del_parsed,
13806 .help_str = "ddp del <port_id> <backup_profile_path>",
13808 (void *)&cmd_ddp_del_ddp,
13809 (void *)&cmd_ddp_del_del,
13810 (void *)&cmd_ddp_del_port_id,
13811 (void *)&cmd_ddp_del_filepath,
13816 /* Get dynamic device personalization profile info */
13817 struct cmd_ddp_info_result {
13818 cmdline_fixed_string_t ddp;
13819 cmdline_fixed_string_t get;
13820 cmdline_fixed_string_t info;
13824 cmdline_parse_token_string_t cmd_ddp_info_ddp =
13825 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
13826 cmdline_parse_token_string_t cmd_ddp_info_get =
13827 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
13828 cmdline_parse_token_string_t cmd_ddp_info_info =
13829 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
13830 cmdline_parse_token_string_t cmd_ddp_info_filepath =
13831 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
13834 cmd_ddp_info_parsed(
13835 void *parsed_result,
13836 __rte_unused struct cmdline *cl,
13837 __rte_unused void *data)
13839 struct cmd_ddp_info_result *res = parsed_result;
13842 int ret = -ENOTSUP;
13843 #ifdef RTE_NET_I40E
13846 uint32_t buff_size = 0;
13847 struct rte_pmd_i40e_profile_info info;
13848 uint32_t dev_num = 0;
13849 struct rte_pmd_i40e_ddp_device_id *devs;
13850 uint32_t proto_num = 0;
13851 struct rte_pmd_i40e_proto_info *proto = NULL;
13852 uint32_t pctype_num = 0;
13853 struct rte_pmd_i40e_ptype_info *pctype;
13854 uint32_t ptype_num = 0;
13855 struct rte_pmd_i40e_ptype_info *ptype;
13860 pkg = open_file(res->filepath, &pkg_size);
13864 #ifdef RTE_NET_I40E
13865 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13866 (uint8_t *)&info, sizeof(info),
13867 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
13869 printf("Global Track id: 0x%x\n", info.track_id);
13870 printf("Global Version: %d.%d.%d.%d\n",
13871 info.version.major,
13872 info.version.minor,
13873 info.version.update,
13874 info.version.draft);
13875 printf("Global Package name: %s\n\n", info.name);
13878 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13879 (uint8_t *)&info, sizeof(info),
13880 RTE_PMD_I40E_PKG_INFO_HEADER);
13882 printf("i40e Profile Track id: 0x%x\n", info.track_id);
13883 printf("i40e Profile Version: %d.%d.%d.%d\n",
13884 info.version.major,
13885 info.version.minor,
13886 info.version.update,
13887 info.version.draft);
13888 printf("i40e Profile name: %s\n\n", info.name);
13891 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13892 (uint8_t *)&buff_size, sizeof(buff_size),
13893 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
13894 if (!ret && buff_size) {
13895 buff = (uint8_t *)malloc(buff_size);
13897 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13899 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
13901 printf("Package Notes:\n%s\n\n", buff);
13906 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13907 (uint8_t *)&dev_num, sizeof(dev_num),
13908 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
13909 if (!ret && dev_num) {
13910 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
13911 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
13913 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13914 (uint8_t *)devs, buff_size,
13915 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
13917 printf("List of supported devices:\n");
13918 for (i = 0; i < dev_num; i++) {
13919 printf(" %04X:%04X %04X:%04X\n",
13920 devs[i].vendor_dev_id >> 16,
13921 devs[i].vendor_dev_id & 0xFFFF,
13922 devs[i].sub_vendor_dev_id >> 16,
13923 devs[i].sub_vendor_dev_id & 0xFFFF);
13931 /* get information about protocols and packet types */
13932 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13933 (uint8_t *)&proto_num, sizeof(proto_num),
13934 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
13935 if (ret || !proto_num)
13936 goto no_print_return;
13938 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
13939 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
13941 goto no_print_return;
13943 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
13945 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
13947 printf("List of used protocols:\n");
13948 for (i = 0; i < proto_num; i++)
13949 printf(" %2u: %s\n", proto[i].proto_id,
13953 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
13954 (uint8_t *)&pctype_num, sizeof(pctype_num),
13955 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
13956 if (ret || !pctype_num)
13957 goto no_print_pctypes;
13959 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
13960 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
13962 goto no_print_pctypes;
13964 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
13966 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
13969 goto no_print_pctypes;
13972 printf("List of defined packet classification types:\n");
13973 for (i = 0; i < pctype_num; i++) {
13974 printf(" %2u:", pctype[i].ptype_id);
13975 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
13976 proto_id = pctype[i].protocols[j];
13977 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
13978 for (n = 0; n < proto_num; n++) {
13979 if (proto[n].proto_id == proto_id) {
13980 printf(" %s", proto[n].name);
13993 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
13995 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
13996 if (ret || !ptype_num)
13997 goto no_print_return;
13999 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14000 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14002 goto no_print_return;
14004 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14006 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14009 goto no_print_return;
14011 printf("List of defined packet types:\n");
14012 for (i = 0; i < ptype_num; i++) {
14013 printf(" %2u:", ptype[i].ptype_id);
14014 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14015 proto_id = ptype[i].protocols[j];
14016 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14017 for (n = 0; n < proto_num; n++) {
14018 if (proto[n].proto_id == proto_id) {
14019 printf(" %s", proto[n].name);
14035 if (ret == -ENOTSUP)
14036 printf("Function not supported in PMD driver\n");
14040 cmdline_parse_inst_t cmd_ddp_get_info = {
14041 .f = cmd_ddp_info_parsed,
14043 .help_str = "ddp get info <profile_path>",
14045 (void *)&cmd_ddp_info_ddp,
14046 (void *)&cmd_ddp_info_get,
14047 (void *)&cmd_ddp_info_info,
14048 (void *)&cmd_ddp_info_filepath,
14053 /* Get dynamic device personalization profile info list*/
14054 #define PROFILE_INFO_SIZE 48
14055 #define MAX_PROFILE_NUM 16
14057 struct cmd_ddp_get_list_result {
14058 cmdline_fixed_string_t ddp;
14059 cmdline_fixed_string_t get;
14060 cmdline_fixed_string_t list;
14064 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14065 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14066 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14067 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14068 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14069 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14070 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14071 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14075 cmd_ddp_get_list_parsed(
14076 __rte_unused void *parsed_result,
14077 __rte_unused struct cmdline *cl,
14078 __rte_unused void *data)
14080 #ifdef RTE_NET_I40E
14081 struct cmd_ddp_get_list_result *res = parsed_result;
14082 struct rte_pmd_i40e_profile_list *p_list;
14083 struct rte_pmd_i40e_profile_info *p_info;
14088 int ret = -ENOTSUP;
14090 #ifdef RTE_NET_I40E
14091 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14092 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14094 printf("%s: Failed to malloc buffer\n", __func__);
14098 if (ret == -ENOTSUP)
14099 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14100 (uint8_t *)p_list, size);
14103 p_num = p_list->p_count;
14104 printf("Profile number is: %d\n\n", p_num);
14106 for (i = 0; i < p_num; i++) {
14107 p_info = &p_list->p_info[i];
14108 printf("Profile %d:\n", i);
14109 printf("Track id: 0x%x\n", p_info->track_id);
14110 printf("Version: %d.%d.%d.%d\n",
14111 p_info->version.major,
14112 p_info->version.minor,
14113 p_info->version.update,
14114 p_info->version.draft);
14115 printf("Profile name: %s\n\n", p_info->name);
14123 printf("Failed to get ddp list\n");
14126 cmdline_parse_inst_t cmd_ddp_get_list = {
14127 .f = cmd_ddp_get_list_parsed,
14129 .help_str = "ddp get list <port_id>",
14131 (void *)&cmd_ddp_get_list_ddp,
14132 (void *)&cmd_ddp_get_list_get,
14133 (void *)&cmd_ddp_get_list_list,
14134 (void *)&cmd_ddp_get_list_port_id,
14139 /* Configure input set */
14140 struct cmd_cfg_input_set_result {
14141 cmdline_fixed_string_t port;
14142 cmdline_fixed_string_t cfg;
14144 cmdline_fixed_string_t pctype;
14146 cmdline_fixed_string_t inset_type;
14147 cmdline_fixed_string_t opt;
14148 cmdline_fixed_string_t field;
14153 cmd_cfg_input_set_parsed(
14154 __rte_unused void *parsed_result,
14155 __rte_unused struct cmdline *cl,
14156 __rte_unused void *data)
14158 #ifdef RTE_NET_I40E
14159 struct cmd_cfg_input_set_result *res = parsed_result;
14160 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14161 struct rte_pmd_i40e_inset inset;
14163 int ret = -ENOTSUP;
14165 if (!all_ports_stopped()) {
14166 printf("Please stop all ports first\n");
14170 #ifdef RTE_NET_I40E
14171 if (!strcmp(res->inset_type, "hash_inset"))
14172 inset_type = INSET_HASH;
14173 else if (!strcmp(res->inset_type, "fdir_inset"))
14174 inset_type = INSET_FDIR;
14175 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14176 inset_type = INSET_FDIR_FLX;
14177 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14178 &inset, inset_type);
14180 printf("Failed to get input set.\n");
14184 if (!strcmp(res->opt, "get")) {
14185 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14188 printf("Field index %d is enabled.\n", res->field_idx);
14190 printf("Field index %d is disabled.\n", res->field_idx);
14192 } else if (!strcmp(res->opt, "set"))
14193 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14195 else if (!strcmp(res->opt, "clear"))
14196 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14199 printf("Failed to configure input set field.\n");
14203 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14204 &inset, inset_type);
14206 printf("Failed to set input set.\n");
14211 if (ret == -ENOTSUP)
14212 printf("Function not supported\n");
14215 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14216 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14218 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14219 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14221 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14222 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14223 port_id, RTE_UINT16);
14224 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14225 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14227 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14228 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14229 pctype_id, RTE_UINT8);
14230 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14231 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14233 "hash_inset#fdir_inset#fdir_flx_inset");
14234 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14235 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14236 opt, "get#set#clear");
14237 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14238 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14240 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14241 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14242 field_idx, RTE_UINT8);
14244 cmdline_parse_inst_t cmd_cfg_input_set = {
14245 .f = cmd_cfg_input_set_parsed,
14247 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14248 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
14250 (void *)&cmd_cfg_input_set_port,
14251 (void *)&cmd_cfg_input_set_cfg,
14252 (void *)&cmd_cfg_input_set_port_id,
14253 (void *)&cmd_cfg_input_set_pctype,
14254 (void *)&cmd_cfg_input_set_pctype_id,
14255 (void *)&cmd_cfg_input_set_inset_type,
14256 (void *)&cmd_cfg_input_set_opt,
14257 (void *)&cmd_cfg_input_set_field,
14258 (void *)&cmd_cfg_input_set_field_idx,
14263 /* Clear input set */
14264 struct cmd_clear_input_set_result {
14265 cmdline_fixed_string_t port;
14266 cmdline_fixed_string_t cfg;
14268 cmdline_fixed_string_t pctype;
14270 cmdline_fixed_string_t inset_type;
14271 cmdline_fixed_string_t clear;
14272 cmdline_fixed_string_t all;
14276 cmd_clear_input_set_parsed(
14277 __rte_unused void *parsed_result,
14278 __rte_unused struct cmdline *cl,
14279 __rte_unused void *data)
14281 #ifdef RTE_NET_I40E
14282 struct cmd_clear_input_set_result *res = parsed_result;
14283 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14284 struct rte_pmd_i40e_inset inset;
14286 int ret = -ENOTSUP;
14288 if (!all_ports_stopped()) {
14289 printf("Please stop all ports first\n");
14293 #ifdef RTE_NET_I40E
14294 if (!strcmp(res->inset_type, "hash_inset"))
14295 inset_type = INSET_HASH;
14296 else if (!strcmp(res->inset_type, "fdir_inset"))
14297 inset_type = INSET_FDIR;
14298 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14299 inset_type = INSET_FDIR_FLX;
14301 memset(&inset, 0, sizeof(inset));
14303 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14304 &inset, inset_type);
14306 printf("Failed to clear input set.\n");
14312 if (ret == -ENOTSUP)
14313 printf("Function not supported\n");
14316 cmdline_parse_token_string_t cmd_clear_input_set_port =
14317 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14319 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
14320 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14322 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
14323 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14324 port_id, RTE_UINT16);
14325 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
14326 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14328 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
14329 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14330 pctype_id, RTE_UINT8);
14331 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
14332 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14334 "hash_inset#fdir_inset#fdir_flx_inset");
14335 cmdline_parse_token_string_t cmd_clear_input_set_clear =
14336 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14338 cmdline_parse_token_string_t cmd_clear_input_set_all =
14339 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14342 cmdline_parse_inst_t cmd_clear_input_set = {
14343 .f = cmd_clear_input_set_parsed,
14345 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14346 "fdir_inset|fdir_flx_inset clear all",
14348 (void *)&cmd_clear_input_set_port,
14349 (void *)&cmd_clear_input_set_cfg,
14350 (void *)&cmd_clear_input_set_port_id,
14351 (void *)&cmd_clear_input_set_pctype,
14352 (void *)&cmd_clear_input_set_pctype_id,
14353 (void *)&cmd_clear_input_set_inset_type,
14354 (void *)&cmd_clear_input_set_clear,
14355 (void *)&cmd_clear_input_set_all,
14360 /* show vf stats */
14362 /* Common result structure for show vf stats */
14363 struct cmd_show_vf_stats_result {
14364 cmdline_fixed_string_t show;
14365 cmdline_fixed_string_t vf;
14366 cmdline_fixed_string_t stats;
14371 /* Common CLI fields show vf stats*/
14372 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14373 TOKEN_STRING_INITIALIZER
14374 (struct cmd_show_vf_stats_result,
14376 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14377 TOKEN_STRING_INITIALIZER
14378 (struct cmd_show_vf_stats_result,
14380 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
14381 TOKEN_STRING_INITIALIZER
14382 (struct cmd_show_vf_stats_result,
14384 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
14385 TOKEN_NUM_INITIALIZER
14386 (struct cmd_show_vf_stats_result,
14387 port_id, RTE_UINT16);
14388 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
14389 TOKEN_NUM_INITIALIZER
14390 (struct cmd_show_vf_stats_result,
14391 vf_id, RTE_UINT16);
14394 cmd_show_vf_stats_parsed(
14395 void *parsed_result,
14396 __rte_unused struct cmdline *cl,
14397 __rte_unused void *data)
14399 struct cmd_show_vf_stats_result *res = parsed_result;
14400 struct rte_eth_stats stats;
14401 int ret = -ENOTSUP;
14402 static const char *nic_stats_border = "########################";
14404 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14407 memset(&stats, 0, sizeof(stats));
14409 #ifdef RTE_NET_I40E
14410 if (ret == -ENOTSUP)
14411 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
14415 #ifdef RTE_NET_BNXT
14416 if (ret == -ENOTSUP)
14417 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
14426 printf("invalid vf_id %d\n", res->vf_id);
14429 printf("invalid port_id %d\n", res->port_id);
14432 printf("function not implemented\n");
14435 printf("programming error: (%s)\n", strerror(-ret));
14438 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
14439 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
14441 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
14443 stats.ipackets, stats.imissed, stats.ibytes);
14444 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
14445 printf(" RX-nombuf: %-10"PRIu64"\n",
14447 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
14449 stats.opackets, stats.oerrors, stats.obytes);
14451 printf(" %s############################%s\n",
14452 nic_stats_border, nic_stats_border);
14455 cmdline_parse_inst_t cmd_show_vf_stats = {
14456 .f = cmd_show_vf_stats_parsed,
14458 .help_str = "show vf stats <port_id> <vf_id>",
14460 (void *)&cmd_show_vf_stats_show,
14461 (void *)&cmd_show_vf_stats_vf,
14462 (void *)&cmd_show_vf_stats_stats,
14463 (void *)&cmd_show_vf_stats_port_id,
14464 (void *)&cmd_show_vf_stats_vf_id,
14469 /* clear vf stats */
14471 /* Common result structure for clear vf stats */
14472 struct cmd_clear_vf_stats_result {
14473 cmdline_fixed_string_t clear;
14474 cmdline_fixed_string_t vf;
14475 cmdline_fixed_string_t stats;
14480 /* Common CLI fields clear vf stats*/
14481 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
14482 TOKEN_STRING_INITIALIZER
14483 (struct cmd_clear_vf_stats_result,
14485 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
14486 TOKEN_STRING_INITIALIZER
14487 (struct cmd_clear_vf_stats_result,
14489 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
14490 TOKEN_STRING_INITIALIZER
14491 (struct cmd_clear_vf_stats_result,
14493 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
14494 TOKEN_NUM_INITIALIZER
14495 (struct cmd_clear_vf_stats_result,
14496 port_id, RTE_UINT16);
14497 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
14498 TOKEN_NUM_INITIALIZER
14499 (struct cmd_clear_vf_stats_result,
14500 vf_id, RTE_UINT16);
14503 cmd_clear_vf_stats_parsed(
14504 void *parsed_result,
14505 __rte_unused struct cmdline *cl,
14506 __rte_unused void *data)
14508 struct cmd_clear_vf_stats_result *res = parsed_result;
14509 int ret = -ENOTSUP;
14511 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14514 #ifdef RTE_NET_I40E
14515 if (ret == -ENOTSUP)
14516 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
14519 #ifdef RTE_NET_BNXT
14520 if (ret == -ENOTSUP)
14521 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
14529 printf("invalid vf_id %d\n", res->vf_id);
14532 printf("invalid port_id %d\n", res->port_id);
14535 printf("function not implemented\n");
14538 printf("programming error: (%s)\n", strerror(-ret));
14542 cmdline_parse_inst_t cmd_clear_vf_stats = {
14543 .f = cmd_clear_vf_stats_parsed,
14545 .help_str = "clear vf stats <port_id> <vf_id>",
14547 (void *)&cmd_clear_vf_stats_clear,
14548 (void *)&cmd_clear_vf_stats_vf,
14549 (void *)&cmd_clear_vf_stats_stats,
14550 (void *)&cmd_clear_vf_stats_port_id,
14551 (void *)&cmd_clear_vf_stats_vf_id,
14556 /* port config pctype mapping reset */
14558 /* Common result structure for port config pctype mapping reset */
14559 struct cmd_pctype_mapping_reset_result {
14560 cmdline_fixed_string_t port;
14561 cmdline_fixed_string_t config;
14563 cmdline_fixed_string_t pctype;
14564 cmdline_fixed_string_t mapping;
14565 cmdline_fixed_string_t reset;
14568 /* Common CLI fields for port config pctype mapping reset*/
14569 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
14570 TOKEN_STRING_INITIALIZER
14571 (struct cmd_pctype_mapping_reset_result,
14573 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
14574 TOKEN_STRING_INITIALIZER
14575 (struct cmd_pctype_mapping_reset_result,
14577 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
14578 TOKEN_NUM_INITIALIZER
14579 (struct cmd_pctype_mapping_reset_result,
14580 port_id, RTE_UINT16);
14581 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
14582 TOKEN_STRING_INITIALIZER
14583 (struct cmd_pctype_mapping_reset_result,
14585 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
14586 TOKEN_STRING_INITIALIZER
14587 (struct cmd_pctype_mapping_reset_result,
14588 mapping, "mapping");
14589 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
14590 TOKEN_STRING_INITIALIZER
14591 (struct cmd_pctype_mapping_reset_result,
14595 cmd_pctype_mapping_reset_parsed(
14596 void *parsed_result,
14597 __rte_unused struct cmdline *cl,
14598 __rte_unused void *data)
14600 struct cmd_pctype_mapping_reset_result *res = parsed_result;
14601 int ret = -ENOTSUP;
14603 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14606 #ifdef RTE_NET_I40E
14607 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
14614 printf("invalid port_id %d\n", res->port_id);
14617 printf("function not implemented\n");
14620 printf("programming error: (%s)\n", strerror(-ret));
14624 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
14625 .f = cmd_pctype_mapping_reset_parsed,
14627 .help_str = "port config <port_id> pctype mapping reset",
14629 (void *)&cmd_pctype_mapping_reset_port,
14630 (void *)&cmd_pctype_mapping_reset_config,
14631 (void *)&cmd_pctype_mapping_reset_port_id,
14632 (void *)&cmd_pctype_mapping_reset_pctype,
14633 (void *)&cmd_pctype_mapping_reset_mapping,
14634 (void *)&cmd_pctype_mapping_reset_reset,
14639 /* show port pctype mapping */
14641 /* Common result structure for show port pctype mapping */
14642 struct cmd_pctype_mapping_get_result {
14643 cmdline_fixed_string_t show;
14644 cmdline_fixed_string_t port;
14646 cmdline_fixed_string_t pctype;
14647 cmdline_fixed_string_t mapping;
14650 /* Common CLI fields for pctype mapping get */
14651 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
14652 TOKEN_STRING_INITIALIZER
14653 (struct cmd_pctype_mapping_get_result,
14655 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
14656 TOKEN_STRING_INITIALIZER
14657 (struct cmd_pctype_mapping_get_result,
14659 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
14660 TOKEN_NUM_INITIALIZER
14661 (struct cmd_pctype_mapping_get_result,
14662 port_id, RTE_UINT16);
14663 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
14664 TOKEN_STRING_INITIALIZER
14665 (struct cmd_pctype_mapping_get_result,
14667 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
14668 TOKEN_STRING_INITIALIZER
14669 (struct cmd_pctype_mapping_get_result,
14670 mapping, "mapping");
14673 cmd_pctype_mapping_get_parsed(
14674 void *parsed_result,
14675 __rte_unused struct cmdline *cl,
14676 __rte_unused void *data)
14678 struct cmd_pctype_mapping_get_result *res = parsed_result;
14679 int ret = -ENOTSUP;
14680 #ifdef RTE_NET_I40E
14681 struct rte_pmd_i40e_flow_type_mapping
14682 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
14683 int i, j, first_pctype;
14686 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14689 #ifdef RTE_NET_I40E
14690 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
14697 printf("invalid port_id %d\n", res->port_id);
14700 printf("function not implemented\n");
14703 printf("programming error: (%s)\n", strerror(-ret));
14707 #ifdef RTE_NET_I40E
14708 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
14709 if (mapping[i].pctype != 0ULL) {
14712 printf("pctype: ");
14713 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
14714 if (mapping[i].pctype & (1ULL << j)) {
14715 printf(first_pctype ?
14716 "%02d" : ",%02d", j);
14720 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
14726 cmdline_parse_inst_t cmd_pctype_mapping_get = {
14727 .f = cmd_pctype_mapping_get_parsed,
14729 .help_str = "show port <port_id> pctype mapping",
14731 (void *)&cmd_pctype_mapping_get_show,
14732 (void *)&cmd_pctype_mapping_get_port,
14733 (void *)&cmd_pctype_mapping_get_port_id,
14734 (void *)&cmd_pctype_mapping_get_pctype,
14735 (void *)&cmd_pctype_mapping_get_mapping,
14740 /* port config pctype mapping update */
14742 /* Common result structure for port config pctype mapping update */
14743 struct cmd_pctype_mapping_update_result {
14744 cmdline_fixed_string_t port;
14745 cmdline_fixed_string_t config;
14747 cmdline_fixed_string_t pctype;
14748 cmdline_fixed_string_t mapping;
14749 cmdline_fixed_string_t update;
14750 cmdline_fixed_string_t pctype_list;
14751 uint16_t flow_type;
14754 /* Common CLI fields for pctype mapping update*/
14755 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
14756 TOKEN_STRING_INITIALIZER
14757 (struct cmd_pctype_mapping_update_result,
14759 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
14760 TOKEN_STRING_INITIALIZER
14761 (struct cmd_pctype_mapping_update_result,
14763 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
14764 TOKEN_NUM_INITIALIZER
14765 (struct cmd_pctype_mapping_update_result,
14766 port_id, RTE_UINT16);
14767 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
14768 TOKEN_STRING_INITIALIZER
14769 (struct cmd_pctype_mapping_update_result,
14771 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
14772 TOKEN_STRING_INITIALIZER
14773 (struct cmd_pctype_mapping_update_result,
14774 mapping, "mapping");
14775 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
14776 TOKEN_STRING_INITIALIZER
14777 (struct cmd_pctype_mapping_update_result,
14779 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
14780 TOKEN_STRING_INITIALIZER
14781 (struct cmd_pctype_mapping_update_result,
14782 pctype_list, NULL);
14783 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
14784 TOKEN_NUM_INITIALIZER
14785 (struct cmd_pctype_mapping_update_result,
14786 flow_type, RTE_UINT16);
14789 cmd_pctype_mapping_update_parsed(
14790 void *parsed_result,
14791 __rte_unused struct cmdline *cl,
14792 __rte_unused void *data)
14794 struct cmd_pctype_mapping_update_result *res = parsed_result;
14795 int ret = -ENOTSUP;
14796 #ifdef RTE_NET_I40E
14797 struct rte_pmd_i40e_flow_type_mapping mapping;
14799 unsigned int nb_item;
14800 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
14803 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14806 #ifdef RTE_NET_I40E
14807 nb_item = parse_item_list(res->pctype_list, "pctypes",
14808 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
14809 mapping.flow_type = res->flow_type;
14810 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
14811 mapping.pctype |= (1ULL << pctype_list[i]);
14812 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
14822 printf("invalid pctype or flow type\n");
14825 printf("invalid port_id %d\n", res->port_id);
14828 printf("function not implemented\n");
14831 printf("programming error: (%s)\n", strerror(-ret));
14835 cmdline_parse_inst_t cmd_pctype_mapping_update = {
14836 .f = cmd_pctype_mapping_update_parsed,
14838 .help_str = "port config <port_id> pctype mapping update"
14839 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
14841 (void *)&cmd_pctype_mapping_update_port,
14842 (void *)&cmd_pctype_mapping_update_config,
14843 (void *)&cmd_pctype_mapping_update_port_id,
14844 (void *)&cmd_pctype_mapping_update_pctype,
14845 (void *)&cmd_pctype_mapping_update_mapping,
14846 (void *)&cmd_pctype_mapping_update_update,
14847 (void *)&cmd_pctype_mapping_update_pc_type,
14848 (void *)&cmd_pctype_mapping_update_flow_type,
14853 /* ptype mapping get */
14855 /* Common result structure for ptype mapping get */
14856 struct cmd_ptype_mapping_get_result {
14857 cmdline_fixed_string_t ptype;
14858 cmdline_fixed_string_t mapping;
14859 cmdline_fixed_string_t get;
14861 uint8_t valid_only;
14864 /* Common CLI fields for ptype mapping get */
14865 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
14866 TOKEN_STRING_INITIALIZER
14867 (struct cmd_ptype_mapping_get_result,
14869 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
14870 TOKEN_STRING_INITIALIZER
14871 (struct cmd_ptype_mapping_get_result,
14872 mapping, "mapping");
14873 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
14874 TOKEN_STRING_INITIALIZER
14875 (struct cmd_ptype_mapping_get_result,
14877 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
14878 TOKEN_NUM_INITIALIZER
14879 (struct cmd_ptype_mapping_get_result,
14880 port_id, RTE_UINT16);
14881 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
14882 TOKEN_NUM_INITIALIZER
14883 (struct cmd_ptype_mapping_get_result,
14884 valid_only, RTE_UINT8);
14887 cmd_ptype_mapping_get_parsed(
14888 void *parsed_result,
14889 __rte_unused struct cmdline *cl,
14890 __rte_unused void *data)
14892 struct cmd_ptype_mapping_get_result *res = parsed_result;
14893 int ret = -ENOTSUP;
14894 #ifdef RTE_NET_I40E
14895 int max_ptype_num = 256;
14896 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
14901 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14904 #ifdef RTE_NET_I40E
14905 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
14916 printf("invalid port_id %d\n", res->port_id);
14919 printf("function not implemented\n");
14922 printf("programming error: (%s)\n", strerror(-ret));
14925 #ifdef RTE_NET_I40E
14927 for (i = 0; i < count; i++)
14928 printf("%3d\t0x%08x\n",
14929 mapping[i].hw_ptype, mapping[i].sw_ptype);
14934 cmdline_parse_inst_t cmd_ptype_mapping_get = {
14935 .f = cmd_ptype_mapping_get_parsed,
14937 .help_str = "ptype mapping get <port_id> <valid_only>",
14939 (void *)&cmd_ptype_mapping_get_ptype,
14940 (void *)&cmd_ptype_mapping_get_mapping,
14941 (void *)&cmd_ptype_mapping_get_get,
14942 (void *)&cmd_ptype_mapping_get_port_id,
14943 (void *)&cmd_ptype_mapping_get_valid_only,
14948 /* ptype mapping replace */
14950 /* Common result structure for ptype mapping replace */
14951 struct cmd_ptype_mapping_replace_result {
14952 cmdline_fixed_string_t ptype;
14953 cmdline_fixed_string_t mapping;
14954 cmdline_fixed_string_t replace;
14961 /* Common CLI fields for ptype mapping replace */
14962 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
14963 TOKEN_STRING_INITIALIZER
14964 (struct cmd_ptype_mapping_replace_result,
14966 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
14967 TOKEN_STRING_INITIALIZER
14968 (struct cmd_ptype_mapping_replace_result,
14969 mapping, "mapping");
14970 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
14971 TOKEN_STRING_INITIALIZER
14972 (struct cmd_ptype_mapping_replace_result,
14973 replace, "replace");
14974 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
14975 TOKEN_NUM_INITIALIZER
14976 (struct cmd_ptype_mapping_replace_result,
14977 port_id, RTE_UINT16);
14978 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
14979 TOKEN_NUM_INITIALIZER
14980 (struct cmd_ptype_mapping_replace_result,
14981 target, RTE_UINT32);
14982 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
14983 TOKEN_NUM_INITIALIZER
14984 (struct cmd_ptype_mapping_replace_result,
14986 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
14987 TOKEN_NUM_INITIALIZER
14988 (struct cmd_ptype_mapping_replace_result,
14989 pkt_type, RTE_UINT32);
14992 cmd_ptype_mapping_replace_parsed(
14993 void *parsed_result,
14994 __rte_unused struct cmdline *cl,
14995 __rte_unused void *data)
14997 struct cmd_ptype_mapping_replace_result *res = parsed_result;
14998 int ret = -ENOTSUP;
15000 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15003 #ifdef RTE_NET_I40E
15004 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15014 printf("invalid ptype 0x%8x or 0x%8x\n",
15015 res->target, res->pkt_type);
15018 printf("invalid port_id %d\n", res->port_id);
15021 printf("function not implemented\n");
15024 printf("programming error: (%s)\n", strerror(-ret));
15028 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15029 .f = cmd_ptype_mapping_replace_parsed,
15032 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15034 (void *)&cmd_ptype_mapping_replace_ptype,
15035 (void *)&cmd_ptype_mapping_replace_mapping,
15036 (void *)&cmd_ptype_mapping_replace_replace,
15037 (void *)&cmd_ptype_mapping_replace_port_id,
15038 (void *)&cmd_ptype_mapping_replace_target,
15039 (void *)&cmd_ptype_mapping_replace_mask,
15040 (void *)&cmd_ptype_mapping_replace_pkt_type,
15045 /* ptype mapping reset */
15047 /* Common result structure for ptype mapping reset */
15048 struct cmd_ptype_mapping_reset_result {
15049 cmdline_fixed_string_t ptype;
15050 cmdline_fixed_string_t mapping;
15051 cmdline_fixed_string_t reset;
15055 /* Common CLI fields for ptype mapping reset*/
15056 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15057 TOKEN_STRING_INITIALIZER
15058 (struct cmd_ptype_mapping_reset_result,
15060 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15061 TOKEN_STRING_INITIALIZER
15062 (struct cmd_ptype_mapping_reset_result,
15063 mapping, "mapping");
15064 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15065 TOKEN_STRING_INITIALIZER
15066 (struct cmd_ptype_mapping_reset_result,
15068 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15069 TOKEN_NUM_INITIALIZER
15070 (struct cmd_ptype_mapping_reset_result,
15071 port_id, RTE_UINT16);
15074 cmd_ptype_mapping_reset_parsed(
15075 void *parsed_result,
15076 __rte_unused struct cmdline *cl,
15077 __rte_unused void *data)
15079 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15080 int ret = -ENOTSUP;
15082 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15085 #ifdef RTE_NET_I40E
15086 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15093 printf("invalid port_id %d\n", res->port_id);
15096 printf("function not implemented\n");
15099 printf("programming error: (%s)\n", strerror(-ret));
15103 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15104 .f = cmd_ptype_mapping_reset_parsed,
15106 .help_str = "ptype mapping reset <port_id>",
15108 (void *)&cmd_ptype_mapping_reset_ptype,
15109 (void *)&cmd_ptype_mapping_reset_mapping,
15110 (void *)&cmd_ptype_mapping_reset_reset,
15111 (void *)&cmd_ptype_mapping_reset_port_id,
15116 /* ptype mapping update */
15118 /* Common result structure for ptype mapping update */
15119 struct cmd_ptype_mapping_update_result {
15120 cmdline_fixed_string_t ptype;
15121 cmdline_fixed_string_t mapping;
15122 cmdline_fixed_string_t reset;
15128 /* Common CLI fields for ptype mapping update*/
15129 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15130 TOKEN_STRING_INITIALIZER
15131 (struct cmd_ptype_mapping_update_result,
15133 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15134 TOKEN_STRING_INITIALIZER
15135 (struct cmd_ptype_mapping_update_result,
15136 mapping, "mapping");
15137 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15138 TOKEN_STRING_INITIALIZER
15139 (struct cmd_ptype_mapping_update_result,
15141 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15142 TOKEN_NUM_INITIALIZER
15143 (struct cmd_ptype_mapping_update_result,
15144 port_id, RTE_UINT16);
15145 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15146 TOKEN_NUM_INITIALIZER
15147 (struct cmd_ptype_mapping_update_result,
15148 hw_ptype, RTE_UINT8);
15149 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15150 TOKEN_NUM_INITIALIZER
15151 (struct cmd_ptype_mapping_update_result,
15152 sw_ptype, RTE_UINT32);
15155 cmd_ptype_mapping_update_parsed(
15156 void *parsed_result,
15157 __rte_unused struct cmdline *cl,
15158 __rte_unused void *data)
15160 struct cmd_ptype_mapping_update_result *res = parsed_result;
15161 int ret = -ENOTSUP;
15162 #ifdef RTE_NET_I40E
15163 struct rte_pmd_i40e_ptype_mapping mapping;
15165 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15168 #ifdef RTE_NET_I40E
15169 mapping.hw_ptype = res->hw_ptype;
15170 mapping.sw_ptype = res->sw_ptype;
15171 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15181 printf("invalid ptype 0x%8x\n", res->sw_ptype);
15184 printf("invalid port_id %d\n", res->port_id);
15187 printf("function not implemented\n");
15190 printf("programming error: (%s)\n", strerror(-ret));
15194 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15195 .f = cmd_ptype_mapping_update_parsed,
15197 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15199 (void *)&cmd_ptype_mapping_update_ptype,
15200 (void *)&cmd_ptype_mapping_update_mapping,
15201 (void *)&cmd_ptype_mapping_update_update,
15202 (void *)&cmd_ptype_mapping_update_port_id,
15203 (void *)&cmd_ptype_mapping_update_hw_ptype,
15204 (void *)&cmd_ptype_mapping_update_sw_ptype,
15209 /* Common result structure for file commands */
15210 struct cmd_cmdfile_result {
15211 cmdline_fixed_string_t load;
15212 cmdline_fixed_string_t filename;
15215 /* Common CLI fields for file commands */
15216 cmdline_parse_token_string_t cmd_load_cmdfile =
15217 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15218 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15219 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15222 cmd_load_from_file_parsed(
15223 void *parsed_result,
15224 __rte_unused struct cmdline *cl,
15225 __rte_unused void *data)
15227 struct cmd_cmdfile_result *res = parsed_result;
15229 cmdline_read_from_file(res->filename);
15232 cmdline_parse_inst_t cmd_load_from_file = {
15233 .f = cmd_load_from_file_parsed,
15235 .help_str = "load <filename>",
15237 (void *)&cmd_load_cmdfile,
15238 (void *)&cmd_load_cmdfile_filename,
15243 /* Get Rx offloads capabilities */
15244 struct cmd_rx_offload_get_capa_result {
15245 cmdline_fixed_string_t show;
15246 cmdline_fixed_string_t port;
15248 cmdline_fixed_string_t rx_offload;
15249 cmdline_fixed_string_t capabilities;
15252 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
15253 TOKEN_STRING_INITIALIZER
15254 (struct cmd_rx_offload_get_capa_result,
15256 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
15257 TOKEN_STRING_INITIALIZER
15258 (struct cmd_rx_offload_get_capa_result,
15260 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
15261 TOKEN_NUM_INITIALIZER
15262 (struct cmd_rx_offload_get_capa_result,
15263 port_id, RTE_UINT16);
15264 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
15265 TOKEN_STRING_INITIALIZER
15266 (struct cmd_rx_offload_get_capa_result,
15267 rx_offload, "rx_offload");
15268 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
15269 TOKEN_STRING_INITIALIZER
15270 (struct cmd_rx_offload_get_capa_result,
15271 capabilities, "capabilities");
15274 print_rx_offloads(uint64_t offloads)
15276 uint64_t single_offload;
15284 begin = __builtin_ctzll(offloads);
15285 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15287 single_offload = 1ULL << begin;
15288 for (bit = begin; bit < end; bit++) {
15289 if (offloads & single_offload)
15291 rte_eth_dev_rx_offload_name(single_offload));
15292 single_offload <<= 1;
15297 cmd_rx_offload_get_capa_parsed(
15298 void *parsed_result,
15299 __rte_unused struct cmdline *cl,
15300 __rte_unused void *data)
15302 struct cmd_rx_offload_get_capa_result *res = parsed_result;
15303 struct rte_eth_dev_info dev_info;
15304 portid_t port_id = res->port_id;
15305 uint64_t queue_offloads;
15306 uint64_t port_offloads;
15309 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15313 queue_offloads = dev_info.rx_queue_offload_capa;
15314 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
15316 printf("Rx Offloading Capabilities of port %d :\n", port_id);
15317 printf(" Per Queue :");
15318 print_rx_offloads(queue_offloads);
15321 printf(" Per Port :");
15322 print_rx_offloads(port_offloads);
15326 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
15327 .f = cmd_rx_offload_get_capa_parsed,
15329 .help_str = "show port <port_id> rx_offload capabilities",
15331 (void *)&cmd_rx_offload_get_capa_show,
15332 (void *)&cmd_rx_offload_get_capa_port,
15333 (void *)&cmd_rx_offload_get_capa_port_id,
15334 (void *)&cmd_rx_offload_get_capa_rx_offload,
15335 (void *)&cmd_rx_offload_get_capa_capabilities,
15340 /* Get Rx offloads configuration */
15341 struct cmd_rx_offload_get_configuration_result {
15342 cmdline_fixed_string_t show;
15343 cmdline_fixed_string_t port;
15345 cmdline_fixed_string_t rx_offload;
15346 cmdline_fixed_string_t configuration;
15349 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
15350 TOKEN_STRING_INITIALIZER
15351 (struct cmd_rx_offload_get_configuration_result,
15353 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
15354 TOKEN_STRING_INITIALIZER
15355 (struct cmd_rx_offload_get_configuration_result,
15357 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
15358 TOKEN_NUM_INITIALIZER
15359 (struct cmd_rx_offload_get_configuration_result,
15360 port_id, RTE_UINT16);
15361 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
15362 TOKEN_STRING_INITIALIZER
15363 (struct cmd_rx_offload_get_configuration_result,
15364 rx_offload, "rx_offload");
15365 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
15366 TOKEN_STRING_INITIALIZER
15367 (struct cmd_rx_offload_get_configuration_result,
15368 configuration, "configuration");
15371 cmd_rx_offload_get_configuration_parsed(
15372 void *parsed_result,
15373 __rte_unused struct cmdline *cl,
15374 __rte_unused void *data)
15376 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
15377 struct rte_eth_dev_info dev_info;
15378 portid_t port_id = res->port_id;
15379 struct rte_port *port = &ports[port_id];
15380 uint64_t port_offloads;
15381 uint64_t queue_offloads;
15382 uint16_t nb_rx_queues;
15386 printf("Rx Offloading Configuration of port %d :\n", port_id);
15388 port_offloads = port->dev_conf.rxmode.offloads;
15390 print_rx_offloads(port_offloads);
15393 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15397 nb_rx_queues = dev_info.nb_rx_queues;
15398 for (q = 0; q < nb_rx_queues; q++) {
15399 queue_offloads = port->rx_conf[q].offloads;
15400 printf(" Queue[%2d] :", q);
15401 print_rx_offloads(queue_offloads);
15407 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
15408 .f = cmd_rx_offload_get_configuration_parsed,
15410 .help_str = "show port <port_id> rx_offload configuration",
15412 (void *)&cmd_rx_offload_get_configuration_show,
15413 (void *)&cmd_rx_offload_get_configuration_port,
15414 (void *)&cmd_rx_offload_get_configuration_port_id,
15415 (void *)&cmd_rx_offload_get_configuration_rx_offload,
15416 (void *)&cmd_rx_offload_get_configuration_configuration,
15421 /* Enable/Disable a per port offloading */
15422 struct cmd_config_per_port_rx_offload_result {
15423 cmdline_fixed_string_t port;
15424 cmdline_fixed_string_t config;
15426 cmdline_fixed_string_t rx_offload;
15427 cmdline_fixed_string_t offload;
15428 cmdline_fixed_string_t on_off;
15431 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
15432 TOKEN_STRING_INITIALIZER
15433 (struct cmd_config_per_port_rx_offload_result,
15435 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
15436 TOKEN_STRING_INITIALIZER
15437 (struct cmd_config_per_port_rx_offload_result,
15439 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
15440 TOKEN_NUM_INITIALIZER
15441 (struct cmd_config_per_port_rx_offload_result,
15442 port_id, RTE_UINT16);
15443 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
15444 TOKEN_STRING_INITIALIZER
15445 (struct cmd_config_per_port_rx_offload_result,
15446 rx_offload, "rx_offload");
15447 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
15448 TOKEN_STRING_INITIALIZER
15449 (struct cmd_config_per_port_rx_offload_result,
15450 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
15451 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
15452 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
15453 "scatter#buffer_split#timestamp#security#"
15454 "keep_crc#rss_hash");
15455 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
15456 TOKEN_STRING_INITIALIZER
15457 (struct cmd_config_per_port_rx_offload_result,
15461 search_rx_offload(const char *name)
15463 uint64_t single_offload;
15464 const char *single_name;
15468 single_offload = 1;
15469 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
15470 single_name = rte_eth_dev_rx_offload_name(single_offload);
15471 if (!strcasecmp(single_name, name)) {
15475 single_offload <<= 1;
15479 return single_offload;
15485 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
15486 __rte_unused struct cmdline *cl,
15487 __rte_unused void *data)
15489 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
15490 portid_t port_id = res->port_id;
15491 struct rte_eth_dev_info dev_info;
15492 struct rte_port *port = &ports[port_id];
15493 uint64_t single_offload;
15494 uint16_t nb_rx_queues;
15498 if (port->port_status != RTE_PORT_STOPPED) {
15499 printf("Error: Can't config offload when Port %d "
15500 "is not stopped\n", port_id);
15504 single_offload = search_rx_offload(res->offload);
15505 if (single_offload == 0) {
15506 printf("Unknown offload name: %s\n", res->offload);
15510 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15514 nb_rx_queues = dev_info.nb_rx_queues;
15515 if (!strcmp(res->on_off, "on")) {
15516 port->dev_conf.rxmode.offloads |= single_offload;
15517 for (q = 0; q < nb_rx_queues; q++)
15518 port->rx_conf[q].offloads |= single_offload;
15520 port->dev_conf.rxmode.offloads &= ~single_offload;
15521 for (q = 0; q < nb_rx_queues; q++)
15522 port->rx_conf[q].offloads &= ~single_offload;
15525 cmd_reconfig_device_queue(port_id, 1, 1);
15528 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
15529 .f = cmd_config_per_port_rx_offload_parsed,
15531 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
15532 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
15533 "macsec_strip|header_split|vlan_filter|vlan_extend|"
15534 "jumbo_frame|scatter|buffer_split|timestamp|security|"
15535 "keep_crc|rss_hash on|off",
15537 (void *)&cmd_config_per_port_rx_offload_result_port,
15538 (void *)&cmd_config_per_port_rx_offload_result_config,
15539 (void *)&cmd_config_per_port_rx_offload_result_port_id,
15540 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
15541 (void *)&cmd_config_per_port_rx_offload_result_offload,
15542 (void *)&cmd_config_per_port_rx_offload_result_on_off,
15547 /* Enable/Disable a per queue offloading */
15548 struct cmd_config_per_queue_rx_offload_result {
15549 cmdline_fixed_string_t port;
15551 cmdline_fixed_string_t rxq;
15553 cmdline_fixed_string_t rx_offload;
15554 cmdline_fixed_string_t offload;
15555 cmdline_fixed_string_t on_off;
15558 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
15559 TOKEN_STRING_INITIALIZER
15560 (struct cmd_config_per_queue_rx_offload_result,
15562 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
15563 TOKEN_NUM_INITIALIZER
15564 (struct cmd_config_per_queue_rx_offload_result,
15565 port_id, RTE_UINT16);
15566 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
15567 TOKEN_STRING_INITIALIZER
15568 (struct cmd_config_per_queue_rx_offload_result,
15570 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
15571 TOKEN_NUM_INITIALIZER
15572 (struct cmd_config_per_queue_rx_offload_result,
15573 queue_id, RTE_UINT16);
15574 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
15575 TOKEN_STRING_INITIALIZER
15576 (struct cmd_config_per_queue_rx_offload_result,
15577 rx_offload, "rx_offload");
15578 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
15579 TOKEN_STRING_INITIALIZER
15580 (struct cmd_config_per_queue_rx_offload_result,
15581 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
15582 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
15583 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
15584 "scatter#buffer_split#timestamp#security#keep_crc");
15585 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
15586 TOKEN_STRING_INITIALIZER
15587 (struct cmd_config_per_queue_rx_offload_result,
15591 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
15592 __rte_unused struct cmdline *cl,
15593 __rte_unused void *data)
15595 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
15596 struct rte_eth_dev_info dev_info;
15597 portid_t port_id = res->port_id;
15598 uint16_t queue_id = res->queue_id;
15599 struct rte_port *port = &ports[port_id];
15600 uint64_t single_offload;
15603 if (port->port_status != RTE_PORT_STOPPED) {
15604 printf("Error: Can't config offload when Port %d "
15605 "is not stopped\n", port_id);
15609 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15613 if (queue_id >= dev_info.nb_rx_queues) {
15614 printf("Error: input queue_id should be 0 ... "
15615 "%d\n", dev_info.nb_rx_queues - 1);
15619 single_offload = search_rx_offload(res->offload);
15620 if (single_offload == 0) {
15621 printf("Unknown offload name: %s\n", res->offload);
15625 if (!strcmp(res->on_off, "on"))
15626 port->rx_conf[queue_id].offloads |= single_offload;
15628 port->rx_conf[queue_id].offloads &= ~single_offload;
15630 cmd_reconfig_device_queue(port_id, 1, 1);
15633 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
15634 .f = cmd_config_per_queue_rx_offload_parsed,
15636 .help_str = "port <port_id> rxq <queue_id> rx_offload "
15637 "vlan_strip|ipv4_cksum|"
15638 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
15639 "macsec_strip|header_split|vlan_filter|vlan_extend|"
15640 "jumbo_frame|scatter|buffer_split|timestamp|security|"
15643 (void *)&cmd_config_per_queue_rx_offload_result_port,
15644 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
15645 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
15646 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
15647 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
15648 (void *)&cmd_config_per_queue_rx_offload_result_offload,
15649 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
15654 /* Get Tx offloads capabilities */
15655 struct cmd_tx_offload_get_capa_result {
15656 cmdline_fixed_string_t show;
15657 cmdline_fixed_string_t port;
15659 cmdline_fixed_string_t tx_offload;
15660 cmdline_fixed_string_t capabilities;
15663 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
15664 TOKEN_STRING_INITIALIZER
15665 (struct cmd_tx_offload_get_capa_result,
15667 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
15668 TOKEN_STRING_INITIALIZER
15669 (struct cmd_tx_offload_get_capa_result,
15671 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
15672 TOKEN_NUM_INITIALIZER
15673 (struct cmd_tx_offload_get_capa_result,
15674 port_id, RTE_UINT16);
15675 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
15676 TOKEN_STRING_INITIALIZER
15677 (struct cmd_tx_offload_get_capa_result,
15678 tx_offload, "tx_offload");
15679 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
15680 TOKEN_STRING_INITIALIZER
15681 (struct cmd_tx_offload_get_capa_result,
15682 capabilities, "capabilities");
15685 print_tx_offloads(uint64_t offloads)
15687 uint64_t single_offload;
15695 begin = __builtin_ctzll(offloads);
15696 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15698 single_offload = 1ULL << begin;
15699 for (bit = begin; bit < end; bit++) {
15700 if (offloads & single_offload)
15702 rte_eth_dev_tx_offload_name(single_offload));
15703 single_offload <<= 1;
15708 cmd_tx_offload_get_capa_parsed(
15709 void *parsed_result,
15710 __rte_unused struct cmdline *cl,
15711 __rte_unused void *data)
15713 struct cmd_tx_offload_get_capa_result *res = parsed_result;
15714 struct rte_eth_dev_info dev_info;
15715 portid_t port_id = res->port_id;
15716 uint64_t queue_offloads;
15717 uint64_t port_offloads;
15720 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15724 queue_offloads = dev_info.tx_queue_offload_capa;
15725 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
15727 printf("Tx Offloading Capabilities of port %d :\n", port_id);
15728 printf(" Per Queue :");
15729 print_tx_offloads(queue_offloads);
15732 printf(" Per Port :");
15733 print_tx_offloads(port_offloads);
15737 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
15738 .f = cmd_tx_offload_get_capa_parsed,
15740 .help_str = "show port <port_id> tx_offload capabilities",
15742 (void *)&cmd_tx_offload_get_capa_show,
15743 (void *)&cmd_tx_offload_get_capa_port,
15744 (void *)&cmd_tx_offload_get_capa_port_id,
15745 (void *)&cmd_tx_offload_get_capa_tx_offload,
15746 (void *)&cmd_tx_offload_get_capa_capabilities,
15751 /* Get Tx offloads configuration */
15752 struct cmd_tx_offload_get_configuration_result {
15753 cmdline_fixed_string_t show;
15754 cmdline_fixed_string_t port;
15756 cmdline_fixed_string_t tx_offload;
15757 cmdline_fixed_string_t configuration;
15760 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
15761 TOKEN_STRING_INITIALIZER
15762 (struct cmd_tx_offload_get_configuration_result,
15764 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
15765 TOKEN_STRING_INITIALIZER
15766 (struct cmd_tx_offload_get_configuration_result,
15768 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
15769 TOKEN_NUM_INITIALIZER
15770 (struct cmd_tx_offload_get_configuration_result,
15771 port_id, RTE_UINT16);
15772 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
15773 TOKEN_STRING_INITIALIZER
15774 (struct cmd_tx_offload_get_configuration_result,
15775 tx_offload, "tx_offload");
15776 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
15777 TOKEN_STRING_INITIALIZER
15778 (struct cmd_tx_offload_get_configuration_result,
15779 configuration, "configuration");
15782 cmd_tx_offload_get_configuration_parsed(
15783 void *parsed_result,
15784 __rte_unused struct cmdline *cl,
15785 __rte_unused void *data)
15787 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
15788 struct rte_eth_dev_info dev_info;
15789 portid_t port_id = res->port_id;
15790 struct rte_port *port = &ports[port_id];
15791 uint64_t port_offloads;
15792 uint64_t queue_offloads;
15793 uint16_t nb_tx_queues;
15797 printf("Tx Offloading Configuration of port %d :\n", port_id);
15799 port_offloads = port->dev_conf.txmode.offloads;
15801 print_tx_offloads(port_offloads);
15804 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15808 nb_tx_queues = dev_info.nb_tx_queues;
15809 for (q = 0; q < nb_tx_queues; q++) {
15810 queue_offloads = port->tx_conf[q].offloads;
15811 printf(" Queue[%2d] :", q);
15812 print_tx_offloads(queue_offloads);
15818 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
15819 .f = cmd_tx_offload_get_configuration_parsed,
15821 .help_str = "show port <port_id> tx_offload configuration",
15823 (void *)&cmd_tx_offload_get_configuration_show,
15824 (void *)&cmd_tx_offload_get_configuration_port,
15825 (void *)&cmd_tx_offload_get_configuration_port_id,
15826 (void *)&cmd_tx_offload_get_configuration_tx_offload,
15827 (void *)&cmd_tx_offload_get_configuration_configuration,
15832 /* Enable/Disable a per port offloading */
15833 struct cmd_config_per_port_tx_offload_result {
15834 cmdline_fixed_string_t port;
15835 cmdline_fixed_string_t config;
15837 cmdline_fixed_string_t tx_offload;
15838 cmdline_fixed_string_t offload;
15839 cmdline_fixed_string_t on_off;
15842 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
15843 TOKEN_STRING_INITIALIZER
15844 (struct cmd_config_per_port_tx_offload_result,
15846 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
15847 TOKEN_STRING_INITIALIZER
15848 (struct cmd_config_per_port_tx_offload_result,
15850 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
15851 TOKEN_NUM_INITIALIZER
15852 (struct cmd_config_per_port_tx_offload_result,
15853 port_id, RTE_UINT16);
15854 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
15855 TOKEN_STRING_INITIALIZER
15856 (struct cmd_config_per_port_tx_offload_result,
15857 tx_offload, "tx_offload");
15858 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
15859 TOKEN_STRING_INITIALIZER
15860 (struct cmd_config_per_port_tx_offload_result,
15861 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
15862 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
15863 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
15864 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
15865 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
15866 "send_on_timestamp");
15867 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
15868 TOKEN_STRING_INITIALIZER
15869 (struct cmd_config_per_port_tx_offload_result,
15873 search_tx_offload(const char *name)
15875 uint64_t single_offload;
15876 const char *single_name;
15880 single_offload = 1;
15881 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
15882 single_name = rte_eth_dev_tx_offload_name(single_offload);
15883 if (single_name == NULL)
15885 if (!strcasecmp(single_name, name)) {
15888 } else if (!strcasecmp(single_name, "UNKNOWN"))
15890 single_offload <<= 1;
15894 return single_offload;
15900 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
15901 __rte_unused struct cmdline *cl,
15902 __rte_unused void *data)
15904 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
15905 portid_t port_id = res->port_id;
15906 struct rte_eth_dev_info dev_info;
15907 struct rte_port *port = &ports[port_id];
15908 uint64_t single_offload;
15909 uint16_t nb_tx_queues;
15913 if (port->port_status != RTE_PORT_STOPPED) {
15914 printf("Error: Can't config offload when Port %d "
15915 "is not stopped\n", port_id);
15919 single_offload = search_tx_offload(res->offload);
15920 if (single_offload == 0) {
15921 printf("Unknown offload name: %s\n", res->offload);
15925 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15929 nb_tx_queues = dev_info.nb_tx_queues;
15930 if (!strcmp(res->on_off, "on")) {
15931 port->dev_conf.txmode.offloads |= single_offload;
15932 for (q = 0; q < nb_tx_queues; q++)
15933 port->tx_conf[q].offloads |= single_offload;
15935 port->dev_conf.txmode.offloads &= ~single_offload;
15936 for (q = 0; q < nb_tx_queues; q++)
15937 port->tx_conf[q].offloads &= ~single_offload;
15940 cmd_reconfig_device_queue(port_id, 1, 1);
15943 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
15944 .f = cmd_config_per_port_tx_offload_parsed,
15946 .help_str = "port config <port_id> tx_offload "
15947 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
15948 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
15949 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
15950 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
15951 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
15952 "send_on_timestamp on|off",
15954 (void *)&cmd_config_per_port_tx_offload_result_port,
15955 (void *)&cmd_config_per_port_tx_offload_result_config,
15956 (void *)&cmd_config_per_port_tx_offload_result_port_id,
15957 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
15958 (void *)&cmd_config_per_port_tx_offload_result_offload,
15959 (void *)&cmd_config_per_port_tx_offload_result_on_off,
15964 /* Enable/Disable a per queue offloading */
15965 struct cmd_config_per_queue_tx_offload_result {
15966 cmdline_fixed_string_t port;
15968 cmdline_fixed_string_t txq;
15970 cmdline_fixed_string_t tx_offload;
15971 cmdline_fixed_string_t offload;
15972 cmdline_fixed_string_t on_off;
15975 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
15976 TOKEN_STRING_INITIALIZER
15977 (struct cmd_config_per_queue_tx_offload_result,
15979 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
15980 TOKEN_NUM_INITIALIZER
15981 (struct cmd_config_per_queue_tx_offload_result,
15982 port_id, RTE_UINT16);
15983 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
15984 TOKEN_STRING_INITIALIZER
15985 (struct cmd_config_per_queue_tx_offload_result,
15987 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
15988 TOKEN_NUM_INITIALIZER
15989 (struct cmd_config_per_queue_tx_offload_result,
15990 queue_id, RTE_UINT16);
15991 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
15992 TOKEN_STRING_INITIALIZER
15993 (struct cmd_config_per_queue_tx_offload_result,
15994 tx_offload, "tx_offload");
15995 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
15996 TOKEN_STRING_INITIALIZER
15997 (struct cmd_config_per_queue_tx_offload_result,
15998 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
15999 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16000 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16001 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16002 "mt_lockfree#multi_segs#mbuf_fast_free#security");
16003 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16004 TOKEN_STRING_INITIALIZER
16005 (struct cmd_config_per_queue_tx_offload_result,
16009 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16010 __rte_unused struct cmdline *cl,
16011 __rte_unused void *data)
16013 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16014 struct rte_eth_dev_info dev_info;
16015 portid_t port_id = res->port_id;
16016 uint16_t queue_id = res->queue_id;
16017 struct rte_port *port = &ports[port_id];
16018 uint64_t single_offload;
16021 if (port->port_status != RTE_PORT_STOPPED) {
16022 printf("Error: Can't config offload when Port %d "
16023 "is not stopped\n", port_id);
16027 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16031 if (queue_id >= dev_info.nb_tx_queues) {
16032 printf("Error: input queue_id should be 0 ... "
16033 "%d\n", dev_info.nb_tx_queues - 1);
16037 single_offload = search_tx_offload(res->offload);
16038 if (single_offload == 0) {
16039 printf("Unknown offload name: %s\n", res->offload);
16043 if (!strcmp(res->on_off, "on"))
16044 port->tx_conf[queue_id].offloads |= single_offload;
16046 port->tx_conf[queue_id].offloads &= ~single_offload;
16048 cmd_reconfig_device_queue(port_id, 1, 1);
16051 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16052 .f = cmd_config_per_queue_tx_offload_parsed,
16054 .help_str = "port <port_id> txq <queue_id> tx_offload "
16055 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16056 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16057 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16058 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16059 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16062 (void *)&cmd_config_per_queue_tx_offload_result_port,
16063 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16064 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16065 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16066 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16067 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16068 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16073 /* *** configure tx_metadata for specific port *** */
16074 struct cmd_config_tx_metadata_specific_result {
16075 cmdline_fixed_string_t port;
16076 cmdline_fixed_string_t keyword;
16078 cmdline_fixed_string_t item;
16083 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16084 __rte_unused struct cmdline *cl,
16085 __rte_unused void *data)
16087 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16089 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16091 ports[res->port_id].tx_metadata = res->value;
16092 /* Add/remove callback to insert valid metadata in every Tx packet. */
16093 if (ports[res->port_id].tx_metadata)
16094 add_tx_md_callback(res->port_id);
16096 remove_tx_md_callback(res->port_id);
16097 rte_flow_dynf_metadata_register();
16100 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16101 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16103 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16104 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16105 keyword, "config");
16106 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16107 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16108 port_id, RTE_UINT16);
16109 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16110 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16111 item, "tx_metadata");
16112 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16113 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16114 value, RTE_UINT32);
16116 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16117 .f = cmd_config_tx_metadata_specific_parsed,
16119 .help_str = "port config <port_id> tx_metadata <value>",
16121 (void *)&cmd_config_tx_metadata_specific_port,
16122 (void *)&cmd_config_tx_metadata_specific_keyword,
16123 (void *)&cmd_config_tx_metadata_specific_id,
16124 (void *)&cmd_config_tx_metadata_specific_item,
16125 (void *)&cmd_config_tx_metadata_specific_value,
16130 /* *** set dynf *** */
16131 struct cmd_config_tx_dynf_specific_result {
16132 cmdline_fixed_string_t port;
16133 cmdline_fixed_string_t keyword;
16135 cmdline_fixed_string_t item;
16136 cmdline_fixed_string_t name;
16137 cmdline_fixed_string_t value;
16141 cmd_config_dynf_specific_parsed(void *parsed_result,
16142 __rte_unused struct cmdline *cl,
16143 __rte_unused void *data)
16145 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16146 struct rte_mbuf_dynflag desc_flag;
16148 uint64_t old_port_flags;
16150 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16152 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16154 if (strlcpy(desc_flag.name, res->name,
16155 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16156 printf("Flag name too long\n");
16159 desc_flag.flags = 0;
16160 flag = rte_mbuf_dynflag_register(&desc_flag);
16162 printf("Can't register flag\n");
16165 strcpy(dynf_names[flag], desc_flag.name);
16167 old_port_flags = ports[res->port_id].mbuf_dynf;
16168 if (!strcmp(res->value, "set")) {
16169 ports[res->port_id].mbuf_dynf |= 1UL << flag;
16170 if (old_port_flags == 0)
16171 add_tx_dynf_callback(res->port_id);
16173 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16174 if (ports[res->port_id].mbuf_dynf == 0)
16175 remove_tx_dynf_callback(res->port_id);
16179 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16180 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16182 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16183 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16184 keyword, "config");
16185 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
16186 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16187 port_id, RTE_UINT16);
16188 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
16189 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16191 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
16192 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16194 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
16195 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16196 value, "set#clear");
16198 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
16199 .f = cmd_config_dynf_specific_parsed,
16201 .help_str = "port config <port id> dynf <name> set|clear",
16203 (void *)&cmd_config_tx_dynf_specific_port,
16204 (void *)&cmd_config_tx_dynf_specific_keyword,
16205 (void *)&cmd_config_tx_dynf_specific_port_id,
16206 (void *)&cmd_config_tx_dynf_specific_item,
16207 (void *)&cmd_config_tx_dynf_specific_name,
16208 (void *)&cmd_config_tx_dynf_specific_value,
16213 /* *** display tx_metadata per port configuration *** */
16214 struct cmd_show_tx_metadata_result {
16215 cmdline_fixed_string_t cmd_show;
16216 cmdline_fixed_string_t cmd_port;
16217 cmdline_fixed_string_t cmd_keyword;
16222 cmd_show_tx_metadata_parsed(void *parsed_result,
16223 __rte_unused struct cmdline *cl,
16224 __rte_unused void *data)
16226 struct cmd_show_tx_metadata_result *res = parsed_result;
16228 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16229 printf("invalid port id %u\n", res->cmd_pid);
16232 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
16233 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
16234 ports[res->cmd_pid].tx_metadata);
16238 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
16239 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16241 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
16242 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16244 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
16245 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
16246 cmd_pid, RTE_UINT16);
16247 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
16248 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16249 cmd_keyword, "tx_metadata");
16251 cmdline_parse_inst_t cmd_show_tx_metadata = {
16252 .f = cmd_show_tx_metadata_parsed,
16254 .help_str = "show port <port_id> tx_metadata",
16256 (void *)&cmd_show_tx_metadata_show,
16257 (void *)&cmd_show_tx_metadata_port,
16258 (void *)&cmd_show_tx_metadata_pid,
16259 (void *)&cmd_show_tx_metadata_keyword,
16264 /* *** show fec capability per port configuration *** */
16265 struct cmd_show_fec_capability_result {
16266 cmdline_fixed_string_t cmd_show;
16267 cmdline_fixed_string_t cmd_port;
16268 cmdline_fixed_string_t cmd_fec;
16269 cmdline_fixed_string_t cmd_keyword;
16274 cmd_show_fec_capability_parsed(void *parsed_result,
16275 __rte_unused struct cmdline *cl,
16276 __rte_unused void *data)
16278 struct cmd_show_fec_capability_result *res = parsed_result;
16279 struct rte_eth_fec_capa *speed_fec_capa;
16283 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16284 printf("Invalid port id %u\n", res->cmd_pid);
16288 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
16289 if (ret == -ENOTSUP) {
16290 printf("Function not implemented\n");
16292 } else if (ret < 0) {
16293 printf("Get FEC capability failed: %d\n", ret);
16297 num = (unsigned int)ret;
16298 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
16299 if (speed_fec_capa == NULL) {
16300 printf("Failed to alloc FEC capability buffer\n");
16304 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
16306 printf("Error getting FEC capability: %d\n", ret);
16310 show_fec_capability(num, speed_fec_capa);
16312 free(speed_fec_capa);
16315 cmdline_parse_token_string_t cmd_show_fec_capability_show =
16316 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16318 cmdline_parse_token_string_t cmd_show_fec_capability_port =
16319 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16321 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
16322 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
16323 cmd_pid, RTE_UINT16);
16324 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
16325 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16327 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
16328 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16329 cmd_keyword, "capabilities");
16331 cmdline_parse_inst_t cmd_show_capability = {
16332 .f = cmd_show_fec_capability_parsed,
16334 .help_str = "show port <port_id> fec capabilities",
16336 (void *)&cmd_show_fec_capability_show,
16337 (void *)&cmd_show_fec_capability_port,
16338 (void *)&cmd_show_fec_capability_pid,
16339 (void *)&cmd_show_fec_capability_fec,
16340 (void *)&cmd_show_fec_capability_keyword,
16345 /* *** show fec mode per port configuration *** */
16346 struct cmd_show_fec_metadata_result {
16347 cmdline_fixed_string_t cmd_show;
16348 cmdline_fixed_string_t cmd_port;
16349 cmdline_fixed_string_t cmd_keyword;
16354 cmd_show_fec_mode_parsed(void *parsed_result,
16355 __rte_unused struct cmdline *cl,
16356 __rte_unused void *data)
16358 #define FEC_NAME_SIZE 16
16359 struct cmd_show_fec_metadata_result *res = parsed_result;
16361 char buf[FEC_NAME_SIZE];
16364 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16365 printf("Invalid port id %u\n", res->cmd_pid);
16368 ret = rte_eth_fec_get(res->cmd_pid, &mode);
16369 if (ret == -ENOTSUP) {
16370 printf("Function not implemented\n");
16372 } else if (ret < 0) {
16373 printf("Get FEC mode failed\n");
16378 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
16379 strlcpy(buf, "off", sizeof(buf));
16381 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
16382 strlcpy(buf, "auto", sizeof(buf));
16384 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
16385 strlcpy(buf, "baser", sizeof(buf));
16387 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
16388 strlcpy(buf, "rs", sizeof(buf));
16394 printf("%s\n", buf);
16397 cmdline_parse_token_string_t cmd_show_fec_mode_show =
16398 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16400 cmdline_parse_token_string_t cmd_show_fec_mode_port =
16401 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16403 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
16404 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
16405 cmd_pid, RTE_UINT16);
16406 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
16407 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
16408 cmd_keyword, "fec_mode");
16410 cmdline_parse_inst_t cmd_show_fec_mode = {
16411 .f = cmd_show_fec_mode_parsed,
16413 .help_str = "show port <port_id> fec_mode",
16415 (void *)&cmd_show_fec_mode_show,
16416 (void *)&cmd_show_fec_mode_port,
16417 (void *)&cmd_show_fec_mode_pid,
16418 (void *)&cmd_show_fec_mode_keyword,
16423 /* *** set fec mode per port configuration *** */
16424 struct cmd_set_port_fec_mode {
16425 cmdline_fixed_string_t set;
16426 cmdline_fixed_string_t port;
16428 cmdline_fixed_string_t fec_mode;
16429 cmdline_fixed_string_t fec_value;
16432 /* Common CLI fields for set fec mode */
16433 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
16434 TOKEN_STRING_INITIALIZER
16435 (struct cmd_set_port_fec_mode,
16437 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
16438 TOKEN_STRING_INITIALIZER
16439 (struct cmd_set_port_fec_mode,
16441 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
16442 TOKEN_NUM_INITIALIZER
16443 (struct cmd_set_port_fec_mode,
16444 port_id, RTE_UINT16);
16445 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
16446 TOKEN_STRING_INITIALIZER
16447 (struct cmd_set_port_fec_mode,
16448 fec_mode, "fec_mode");
16449 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
16450 TOKEN_STRING_INITIALIZER
16451 (struct cmd_set_port_fec_mode,
16455 cmd_set_port_fec_mode_parsed(
16456 void *parsed_result,
16457 __rte_unused struct cmdline *cl,
16458 __rte_unused void *data)
16460 struct cmd_set_port_fec_mode *res = parsed_result;
16461 uint16_t port_id = res->port_id;
16465 ret = parse_fec_mode(res->fec_value, &mode);
16467 printf("Unknown fec mode: %s for Port %d\n", res->fec_value,
16472 ret = rte_eth_fec_set(port_id, mode);
16473 if (ret == -ENOTSUP) {
16474 printf("Function not implemented\n");
16476 } else if (ret < 0) {
16477 printf("Set FEC mode failed\n");
16482 cmdline_parse_inst_t cmd_set_fec_mode = {
16483 .f = cmd_set_port_fec_mode_parsed,
16485 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
16487 (void *)&cmd_set_port_fec_mode_set,
16488 (void *)&cmd_set_port_fec_mode_port,
16489 (void *)&cmd_set_port_fec_mode_port_id,
16490 (void *)&cmd_set_port_fec_mode_str,
16491 (void *)&cmd_set_port_fec_mode_value,
16496 /* show port supported ptypes */
16498 /* Common result structure for show port ptypes */
16499 struct cmd_show_port_supported_ptypes_result {
16500 cmdline_fixed_string_t show;
16501 cmdline_fixed_string_t port;
16503 cmdline_fixed_string_t ptypes;
16506 /* Common CLI fields for show port ptypes */
16507 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
16508 TOKEN_STRING_INITIALIZER
16509 (struct cmd_show_port_supported_ptypes_result,
16511 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
16512 TOKEN_STRING_INITIALIZER
16513 (struct cmd_show_port_supported_ptypes_result,
16515 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
16516 TOKEN_NUM_INITIALIZER
16517 (struct cmd_show_port_supported_ptypes_result,
16518 port_id, RTE_UINT16);
16519 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
16520 TOKEN_STRING_INITIALIZER
16521 (struct cmd_show_port_supported_ptypes_result,
16525 cmd_show_port_supported_ptypes_parsed(
16526 void *parsed_result,
16527 __rte_unused struct cmdline *cl,
16528 __rte_unused void *data)
16530 #define RSVD_PTYPE_MASK 0xf0000000
16531 #define MAX_PTYPES_PER_LAYER 16
16532 #define LTYPE_NAMESIZE 32
16533 #define PTYPE_NAMESIZE 256
16534 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
16535 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
16536 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
16537 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
16538 uint16_t port_id = res->port_id;
16541 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
16545 while (ptype_mask != RSVD_PTYPE_MASK) {
16547 switch (ptype_mask) {
16548 case RTE_PTYPE_L2_MASK:
16549 strlcpy(ltype, "L2", sizeof(ltype));
16551 case RTE_PTYPE_L3_MASK:
16552 strlcpy(ltype, "L3", sizeof(ltype));
16554 case RTE_PTYPE_L4_MASK:
16555 strlcpy(ltype, "L4", sizeof(ltype));
16557 case RTE_PTYPE_TUNNEL_MASK:
16558 strlcpy(ltype, "Tunnel", sizeof(ltype));
16560 case RTE_PTYPE_INNER_L2_MASK:
16561 strlcpy(ltype, "Inner L2", sizeof(ltype));
16563 case RTE_PTYPE_INNER_L3_MASK:
16564 strlcpy(ltype, "Inner L3", sizeof(ltype));
16566 case RTE_PTYPE_INNER_L4_MASK:
16567 strlcpy(ltype, "Inner L4", sizeof(ltype));
16573 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
16574 ptype_mask, ptypes,
16575 MAX_PTYPES_PER_LAYER);
16578 printf("Supported %s ptypes:\n", ltype);
16580 printf("%s ptypes unsupported\n", ltype);
16582 for (i = 0; i < ret; ++i) {
16583 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
16584 printf("%s\n", buf);
16591 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
16592 .f = cmd_show_port_supported_ptypes_parsed,
16594 .help_str = "show port <port_id> ptypes",
16596 (void *)&cmd_show_port_supported_ptypes_show,
16597 (void *)&cmd_show_port_supported_ptypes_port,
16598 (void *)&cmd_show_port_supported_ptypes_port_id,
16599 (void *)&cmd_show_port_supported_ptypes_ptypes,
16604 /* *** display rx/tx descriptor status *** */
16605 struct cmd_show_rx_tx_desc_status_result {
16606 cmdline_fixed_string_t cmd_show;
16607 cmdline_fixed_string_t cmd_port;
16608 cmdline_fixed_string_t cmd_keyword;
16609 cmdline_fixed_string_t cmd_desc;
16610 cmdline_fixed_string_t cmd_status;
16617 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
16618 __rte_unused struct cmdline *cl,
16619 __rte_unused void *data)
16621 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
16624 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16625 printf("invalid port id %u\n", res->cmd_pid);
16629 if (!strcmp(res->cmd_keyword, "rxq")) {
16630 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
16633 printf("Invalid queueid = %d\n", res->cmd_qid);
16636 if (rc == RTE_ETH_RX_DESC_AVAIL)
16637 printf("Desc status = AVAILABLE\n");
16638 else if (rc == RTE_ETH_RX_DESC_DONE)
16639 printf("Desc status = DONE\n");
16641 printf("Desc status = UNAVAILABLE\n");
16642 } else if (!strcmp(res->cmd_keyword, "txq")) {
16643 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
16646 printf("Invalid queueid = %d\n", res->cmd_qid);
16649 if (rc == RTE_ETH_TX_DESC_FULL)
16650 printf("Desc status = FULL\n");
16651 else if (rc == RTE_ETH_TX_DESC_DONE)
16652 printf("Desc status = DONE\n");
16654 printf("Desc status = UNAVAILABLE\n");
16658 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
16659 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16661 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
16662 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16664 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
16665 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16666 cmd_pid, RTE_UINT16);
16667 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
16668 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16669 cmd_keyword, "rxq#txq");
16670 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
16671 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16672 cmd_qid, RTE_UINT16);
16673 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
16674 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16676 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
16677 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16678 cmd_did, RTE_UINT16);
16679 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
16680 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
16681 cmd_status, "status");
16682 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
16683 .f = cmd_show_rx_tx_desc_status_parsed,
16685 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
16688 (void *)&cmd_show_rx_tx_desc_status_show,
16689 (void *)&cmd_show_rx_tx_desc_status_port,
16690 (void *)&cmd_show_rx_tx_desc_status_pid,
16691 (void *)&cmd_show_rx_tx_desc_status_keyword,
16692 (void *)&cmd_show_rx_tx_desc_status_qid,
16693 (void *)&cmd_show_rx_tx_desc_status_desc,
16694 (void *)&cmd_show_rx_tx_desc_status_did,
16695 (void *)&cmd_show_rx_tx_desc_status_status,
16700 /* Common result structure for set port ptypes */
16701 struct cmd_set_port_ptypes_result {
16702 cmdline_fixed_string_t set;
16703 cmdline_fixed_string_t port;
16705 cmdline_fixed_string_t ptype_mask;
16709 /* Common CLI fields for set port ptypes */
16710 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
16711 TOKEN_STRING_INITIALIZER
16712 (struct cmd_set_port_ptypes_result,
16714 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
16715 TOKEN_STRING_INITIALIZER
16716 (struct cmd_set_port_ptypes_result,
16718 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
16719 TOKEN_NUM_INITIALIZER
16720 (struct cmd_set_port_ptypes_result,
16721 port_id, RTE_UINT16);
16722 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
16723 TOKEN_STRING_INITIALIZER
16724 (struct cmd_set_port_ptypes_result,
16725 ptype_mask, "ptype_mask");
16726 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
16727 TOKEN_NUM_INITIALIZER
16728 (struct cmd_set_port_ptypes_result,
16732 cmd_set_port_ptypes_parsed(
16733 void *parsed_result,
16734 __rte_unused struct cmdline *cl,
16735 __rte_unused void *data)
16737 struct cmd_set_port_ptypes_result *res = parsed_result;
16738 #define PTYPE_NAMESIZE 256
16739 char ptype_name[PTYPE_NAMESIZE];
16740 uint16_t port_id = res->port_id;
16741 uint32_t ptype_mask = res->mask;
16744 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
16747 printf("Port %d doesn't support any ptypes.\n", port_id);
16751 uint32_t ptypes[ret];
16753 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
16755 printf("Unable to set requested ptypes for Port %d\n", port_id);
16759 printf("Successfully set following ptypes for Port %d\n", port_id);
16760 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
16761 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
16762 printf("%s\n", ptype_name);
16765 clear_ptypes = false;
16768 cmdline_parse_inst_t cmd_set_port_ptypes = {
16769 .f = cmd_set_port_ptypes_parsed,
16771 .help_str = "set port <port_id> ptype_mask <mask>",
16773 (void *)&cmd_set_port_ptypes_set,
16774 (void *)&cmd_set_port_ptypes_port,
16775 (void *)&cmd_set_port_ptypes_port_id,
16776 (void *)&cmd_set_port_ptypes_mask_str,
16777 (void *)&cmd_set_port_ptypes_mask_u32,
16782 /* *** display mac addresses added to a port *** */
16783 struct cmd_showport_macs_result {
16784 cmdline_fixed_string_t cmd_show;
16785 cmdline_fixed_string_t cmd_port;
16786 cmdline_fixed_string_t cmd_keyword;
16791 cmd_showport_macs_parsed(void *parsed_result,
16792 __rte_unused struct cmdline *cl,
16793 __rte_unused void *data)
16795 struct cmd_showport_macs_result *res = parsed_result;
16797 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
16800 if (!strcmp(res->cmd_keyword, "macs"))
16801 show_macs(res->cmd_pid);
16802 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
16803 show_mcast_macs(res->cmd_pid);
16806 cmdline_parse_token_string_t cmd_showport_macs_show =
16807 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
16809 cmdline_parse_token_string_t cmd_showport_macs_port =
16810 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
16812 cmdline_parse_token_num_t cmd_showport_macs_pid =
16813 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
16814 cmd_pid, RTE_UINT16);
16815 cmdline_parse_token_string_t cmd_showport_macs_keyword =
16816 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
16817 cmd_keyword, "macs#mcast_macs");
16819 cmdline_parse_inst_t cmd_showport_macs = {
16820 .f = cmd_showport_macs_parsed,
16822 .help_str = "show port <port_id> macs|mcast_macs",
16824 (void *)&cmd_showport_macs_show,
16825 (void *)&cmd_showport_macs_port,
16826 (void *)&cmd_showport_macs_pid,
16827 (void *)&cmd_showport_macs_keyword,
16832 /* ******************************************************************************** */
16834 /* list of instructions */
16835 cmdline_parse_ctx_t main_ctx[] = {
16836 (cmdline_parse_inst_t *)&cmd_help_brief,
16837 (cmdline_parse_inst_t *)&cmd_help_long,
16838 (cmdline_parse_inst_t *)&cmd_quit,
16839 (cmdline_parse_inst_t *)&cmd_load_from_file,
16840 (cmdline_parse_inst_t *)&cmd_showport,
16841 (cmdline_parse_inst_t *)&cmd_showqueue,
16842 (cmdline_parse_inst_t *)&cmd_showeeprom,
16843 (cmdline_parse_inst_t *)&cmd_showportall,
16844 (cmdline_parse_inst_t *)&cmd_showdevice,
16845 (cmdline_parse_inst_t *)&cmd_showcfg,
16846 (cmdline_parse_inst_t *)&cmd_showfwdall,
16847 (cmdline_parse_inst_t *)&cmd_start,
16848 (cmdline_parse_inst_t *)&cmd_start_tx_first,
16849 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
16850 (cmdline_parse_inst_t *)&cmd_set_link_up,
16851 (cmdline_parse_inst_t *)&cmd_set_link_down,
16852 (cmdline_parse_inst_t *)&cmd_reset,
16853 (cmdline_parse_inst_t *)&cmd_set_numbers,
16854 (cmdline_parse_inst_t *)&cmd_set_log,
16855 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
16856 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
16857 (cmdline_parse_inst_t *)&cmd_set_txpkts,
16858 (cmdline_parse_inst_t *)&cmd_set_txsplit,
16859 (cmdline_parse_inst_t *)&cmd_set_txtimes,
16860 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
16861 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
16862 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
16863 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
16864 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
16865 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
16866 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
16867 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
16868 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
16869 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
16870 (cmdline_parse_inst_t *)&cmd_set_link_check,
16871 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
16872 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
16873 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
16874 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
16875 #ifdef RTE_NET_BOND
16876 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
16877 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
16878 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
16879 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
16880 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
16881 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
16882 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
16883 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
16884 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
16885 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
16886 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
16888 (cmdline_parse_inst_t *)&cmd_vlan_offload,
16889 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
16890 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
16891 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
16892 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
16893 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
16894 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
16895 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
16896 (cmdline_parse_inst_t *)&cmd_csum_set,
16897 (cmdline_parse_inst_t *)&cmd_csum_show,
16898 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
16899 (cmdline_parse_inst_t *)&cmd_tso_set,
16900 (cmdline_parse_inst_t *)&cmd_tso_show,
16901 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
16902 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
16903 (cmdline_parse_inst_t *)&cmd_gro_enable,
16904 (cmdline_parse_inst_t *)&cmd_gro_flush,
16905 (cmdline_parse_inst_t *)&cmd_gro_show,
16906 (cmdline_parse_inst_t *)&cmd_gso_enable,
16907 (cmdline_parse_inst_t *)&cmd_gso_size,
16908 (cmdline_parse_inst_t *)&cmd_gso_show,
16909 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
16910 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
16911 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
16912 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
16913 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
16914 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
16915 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
16916 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
16917 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
16918 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
16919 (cmdline_parse_inst_t *)&cmd_config_dcb,
16920 (cmdline_parse_inst_t *)&cmd_read_reg,
16921 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
16922 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
16923 (cmdline_parse_inst_t *)&cmd_write_reg,
16924 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
16925 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
16926 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
16927 (cmdline_parse_inst_t *)&cmd_stop,
16928 (cmdline_parse_inst_t *)&cmd_mac_addr,
16929 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
16930 (cmdline_parse_inst_t *)&cmd_set_qmap,
16931 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
16932 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
16933 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
16934 (cmdline_parse_inst_t *)&cmd_operate_port,
16935 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
16936 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
16937 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
16938 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
16939 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
16940 (cmdline_parse_inst_t *)&cmd_config_speed_all,
16941 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
16942 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
16943 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
16944 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
16945 (cmdline_parse_inst_t *)&cmd_config_mtu,
16946 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
16947 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
16948 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
16949 (cmdline_parse_inst_t *)&cmd_config_rss,
16950 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
16951 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
16952 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
16953 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
16954 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
16955 (cmdline_parse_inst_t *)&cmd_showport_reta,
16956 (cmdline_parse_inst_t *)&cmd_showport_macs,
16957 (cmdline_parse_inst_t *)&cmd_config_burst,
16958 (cmdline_parse_inst_t *)&cmd_config_thresh,
16959 (cmdline_parse_inst_t *)&cmd_config_threshold,
16960 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
16961 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
16962 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
16963 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
16964 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
16965 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
16966 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
16967 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
16968 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
16969 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
16970 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
16971 (cmdline_parse_inst_t *)&cmd_dump,
16972 (cmdline_parse_inst_t *)&cmd_dump_one,
16973 #ifdef RTE_NET_I40E
16974 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
16976 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
16977 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
16978 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
16979 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
16980 (cmdline_parse_inst_t *)&cmd_flow,
16981 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
16982 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
16983 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
16984 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
16985 (cmdline_parse_inst_t *)&cmd_create_port_meter,
16986 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
16987 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
16988 (cmdline_parse_inst_t *)&cmd_del_port_meter,
16989 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
16990 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
16991 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
16992 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
16993 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
16994 (cmdline_parse_inst_t *)&cmd_mcast_addr,
16995 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
16996 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
16997 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
16998 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
16999 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17000 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17001 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17002 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17003 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17004 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17005 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17006 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17007 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17008 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17009 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17010 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17011 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17012 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17013 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17014 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17015 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17016 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17017 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17018 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
17019 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
17020 (cmdline_parse_inst_t *)&cmd_set_vxlan,
17021 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
17022 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17023 (cmdline_parse_inst_t *)&cmd_set_nvgre,
17024 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17025 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
17026 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
17027 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
17028 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
17029 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
17030 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
17031 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
17032 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
17033 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
17034 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
17035 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
17036 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
17037 (cmdline_parse_inst_t *)&cmd_ddp_add,
17038 (cmdline_parse_inst_t *)&cmd_ddp_del,
17039 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
17040 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
17041 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
17042 (cmdline_parse_inst_t *)&cmd_clear_input_set,
17043 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
17044 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17045 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
17046 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
17047 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17048 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17049 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17050 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17052 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17053 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17054 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17055 (cmdline_parse_inst_t *)&cmd_queue_region,
17056 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17057 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17058 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17059 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17060 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17061 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17062 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17063 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17064 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17065 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17066 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17067 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17068 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17069 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17070 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17071 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17072 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17073 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
17074 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17075 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17076 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17077 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17078 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17079 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17080 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
17081 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
17082 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
17083 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17084 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17085 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17086 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17087 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17088 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17089 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17090 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17091 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17093 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17094 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17096 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
17097 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
17098 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
17099 (cmdline_parse_inst_t *)&cmd_set_raw,
17100 (cmdline_parse_inst_t *)&cmd_show_set_raw,
17101 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
17102 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
17103 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
17104 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
17105 (cmdline_parse_inst_t *)&cmd_show_capability,
17109 /* read cmdline commands from file */
17111 cmdline_read_from_file(const char *filename)
17113 struct cmdline *cl;
17115 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17117 printf("Failed to create file based cmdline context: %s\n",
17122 cmdline_interact(cl);
17127 printf("Read CLI commands from %s\n", filename);
17130 /* prompt function, called from main on MAIN lcore */
17134 /* initialize non-constant commands */
17135 cmd_set_fwd_mode_init();
17136 cmd_set_fwd_retry_mode_init();
17138 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17139 if (testpmd_cl == NULL)
17141 cmdline_interact(testpmd_cl);
17142 cmdline_stdin_exit(testpmd_cl);
17148 if (testpmd_cl != NULL)
17149 cmdline_quit(testpmd_cl);
17153 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17155 if (id == (portid_t)RTE_PORT_ALL) {
17158 RTE_ETH_FOREACH_DEV(pid) {
17159 /* check if need_reconfig has been set to 1 */
17160 if (ports[pid].need_reconfig == 0)
17161 ports[pid].need_reconfig = dev;
17162 /* check if need_reconfig_queues has been set to 1 */
17163 if (ports[pid].need_reconfig_queues == 0)
17164 ports[pid].need_reconfig_queues = queue;
17166 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17167 /* check if need_reconfig has been set to 1 */
17168 if (ports[id].need_reconfig == 0)
17169 ports[id].need_reconfig = dev;
17170 /* check if need_reconfig_queues has been set to 1 */
17171 if (ports[id].need_reconfig_queues == 0)
17172 ports[id].need_reconfig_queues = queue;