1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
13 #include <sys/queue.h>
15 #include <rte_common.h>
16 #include <rte_byteorder.h>
18 #include <rte_debug.h>
19 #include <rte_cycles.h>
20 #include <rte_memory.h>
21 #include <rte_memzone.h>
22 #include <rte_malloc.h>
23 #include <rte_launch.h>
25 #include <rte_per_lcore.h>
26 #include <rte_lcore.h>
27 #include <rte_atomic.h>
28 #include <rte_branch_prediction.h>
30 #include <rte_mempool.h>
31 #include <rte_interrupts.h>
33 #include <rte_ether.h>
34 #include <rte_ethdev.h>
35 #include <rte_string_fns.h>
36 #include <rte_devargs.h>
39 #include <rte_mbuf_dyn.h>
41 #include <cmdline_rdline.h>
42 #include <cmdline_parse.h>
43 #include <cmdline_parse_num.h>
44 #include <cmdline_parse_string.h>
45 #include <cmdline_parse_ipaddr.h>
46 #include <cmdline_parse_etheraddr.h>
47 #include <cmdline_socket.h>
50 #include <rte_eth_bond.h>
51 #include <rte_eth_bond_8023ad.h>
53 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
54 #include <rte_pmd_dpaa.h>
57 #include <rte_pmd_ixgbe.h>
60 #include <rte_pmd_i40e.h>
63 #include <rte_pmd_bnxt.h>
66 #include "cmdline_mtr.h"
67 #include "cmdline_tm.h"
70 static struct cmdline *testpmd_cl;
72 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
74 /* *** Help command with introduction. *** */
75 struct cmd_help_brief_result {
76 cmdline_fixed_string_t help;
79 static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
81 __rte_unused void *data)
86 "Help is available for the following sections:\n\n"
87 " help control : Start and stop forwarding.\n"
88 " help display : Displaying port, stats and config "
90 " help config : Configuration information.\n"
91 " help ports : Configuring ports.\n"
92 " help registers : Reading and setting port registers.\n"
93 " help filters : Filters configuration help.\n"
94 " help traffic_management : Traffic Management commands.\n"
95 " help devices : Device related cmds.\n"
96 " help all : All of the above sections.\n\n"
101 cmdline_parse_token_string_t cmd_help_brief_help =
102 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
104 cmdline_parse_inst_t cmd_help_brief = {
105 .f = cmd_help_brief_parsed,
107 .help_str = "help: Show help",
109 (void *)&cmd_help_brief_help,
114 /* *** Help command with help sections. *** */
115 struct cmd_help_long_result {
116 cmdline_fixed_string_t help;
117 cmdline_fixed_string_t section;
120 static void cmd_help_long_parsed(void *parsed_result,
122 __rte_unused void *data)
125 struct cmd_help_long_result *res = parsed_result;
127 if (!strcmp(res->section, "all"))
130 if (show_all || !strcmp(res->section, "control")) {
135 "Control forwarding:\n"
136 "-------------------\n\n"
139 " Start packet forwarding with current configuration.\n\n"
142 " Start packet forwarding with current config"
143 " after sending one burst of packets.\n\n"
146 " Stop packet forwarding, and display accumulated"
150 " Quit to prompt.\n\n"
154 if (show_all || !strcmp(res->section, "display")) {
162 "show port (info|stats|summary|xstats|fdir|dcb_tc) (port_id|all)\n"
163 " Display information for port_id, or all.\n\n"
165 "show port port_id (module_eeprom|eeprom)\n"
166 " Display the module EEPROM or EEPROM information for port_id.\n\n"
168 "show port X rss reta (size) (mask0,mask1,...)\n"
169 " Display the rss redirection table entry indicated"
170 " by masks on port X. size is used to indicate the"
171 " hardware supported reta size\n\n"
173 "show port (port_id) rss-hash [key]\n"
174 " Display the RSS hash functions and RSS hash key of port\n\n"
176 "clear port (info|stats|xstats|fdir) (port_id|all)\n"
177 " Clear information for port_id, or all.\n\n"
179 "show (rxq|txq) info (port_id) (queue_id)\n"
180 " Display information for configured RX/TX queue.\n\n"
182 "show config (rxtx|cores|fwd|rxoffs|rxpkts|txpkts)\n"
183 " Display the given configuration.\n\n"
185 "read rxd (port_id) (queue_id) (rxd_id)\n"
186 " Display an RX descriptor of a port RX queue.\n\n"
188 "read txd (port_id) (queue_id) (txd_id)\n"
189 " Display a TX descriptor of a port TX queue.\n\n"
191 "ddp get list (port_id)\n"
192 " Get ddp profile info list\n\n"
194 "ddp get info (profile_path)\n"
195 " Get ddp profile information.\n\n"
197 "show vf stats (port_id) (vf_id)\n"
198 " Display a VF's statistics.\n\n"
200 "clear vf stats (port_id) (vf_id)\n"
201 " Reset a VF's statistics.\n\n"
203 "show port (port_id) pctype mapping\n"
204 " Get flow ptype to pctype mapping on a port\n\n"
206 "show port meter stats (port_id) (meter_id) (clear)\n"
207 " Get meter stats on a port\n\n"
209 "show fwd stats all\n"
210 " Display statistics for all fwd engines.\n\n"
212 "clear fwd stats all\n"
213 " Clear statistics for all fwd engines.\n\n"
215 "show port (port_id) rx_offload capabilities\n"
216 " List all per queue and per port Rx offloading"
217 " capabilities of a port\n\n"
219 "show port (port_id) rx_offload configuration\n"
220 " List port level and all queue level"
221 " Rx offloading configuration\n\n"
223 "show port (port_id) tx_offload capabilities\n"
224 " List all per queue and per port"
225 " Tx offloading capabilities of a port\n\n"
227 "show port (port_id) tx_offload configuration\n"
228 " List port level and all queue level"
229 " Tx offloading configuration\n\n"
231 "show port (port_id) tx_metadata\n"
232 " Show Tx metadata value set"
233 " for a specific port\n\n"
235 "show port (port_id) ptypes\n"
236 " Show port supported ptypes"
237 " for a specific port\n\n"
239 "show device info (<identifier>|all)"
240 " Show general information about devices probed.\n\n"
242 "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
243 " Show status of rx|tx descriptor.\n\n"
245 "show port (port_id) rxq (queue_id) desc used count\n"
246 " Show current number of filled receive"
247 " packet descriptors.\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"
258 "show port (port_id) flow_ctrl"
259 " Show flow control info of a port.\n\n"
263 if (show_all || !strcmp(res->section, "config")) {
269 "Configuration changes only become active when"
270 " forwarding is started/restarted.\n\n"
273 " Reset forwarding to the default configuration.\n\n"
275 "set verbose (level)\n"
276 " Set the debug verbosity level X.\n\n"
278 "set log global|(type) (level)\n"
279 " Set the log level.\n\n"
282 " Set number of ports.\n\n"
285 " Set number of cores.\n\n"
287 "set coremask (mask)\n"
288 " Set the forwarding cores hexadecimal mask.\n\n"
290 "set portmask (mask)\n"
291 " Set the forwarding ports hexadecimal mask.\n\n"
294 " Set number of packets per burst.\n\n"
296 "set burst tx delay (microseconds) retry (num)\n"
297 " Set the transmit delay time and number of retries,"
298 " effective when retry is enabled.\n\n"
300 "set rxoffs (x[,y]*)\n"
301 " Set the offset of each packet segment on"
302 " receiving if split feature is engaged."
303 " Affects only the queues configured with split"
306 "set rxpkts (x[,y]*)\n"
307 " Set the length of each segment to scatter"
308 " packets on receiving if split feature is engaged."
309 " Affects only the queues configured with split"
312 "set txpkts (x[,y]*)\n"
313 " Set the length of each segment of TXONLY"
314 " and optionally CSUM packets.\n\n"
316 "set txsplit (off|on|rand)\n"
317 " Set the split policy for the TX packets."
318 " Right now only applicable for CSUM and TXONLY"
321 "set txtimes (x, y)\n"
322 " Set the scheduling on timestamps"
323 " timings for the TXONLY mode\n\n"
325 "set corelist (x[,y]*)\n"
326 " Set the list of forwarding cores.\n\n"
328 "set portlist (x[,y]*)\n"
329 " Set the list of forwarding ports.\n\n"
331 "set port setup on (iterator|event)\n"
332 " Select how attached port is retrieved for setup.\n\n"
334 "set tx loopback (port_id) (on|off)\n"
335 " Enable or disable tx loopback.\n\n"
337 "set all queues drop (port_id) (on|off)\n"
338 " Set drop enable bit for all queues.\n\n"
340 "set vf split drop (port_id) (vf_id) (on|off)\n"
341 " Set split drop enable bit for a VF from the PF.\n\n"
343 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
344 " Set MAC antispoof for a VF from the PF.\n\n"
346 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
347 " Enable MACsec offload.\n\n"
349 "set macsec offload (port_id) off\n"
350 " Disable MACsec offload.\n\n"
352 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
353 " Configure MACsec secure connection (SC).\n\n"
355 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
356 " Configure MACsec secure association (SA).\n\n"
358 "set vf broadcast (port_id) (vf_id) (on|off)\n"
359 " Set VF broadcast for a VF from the PF.\n\n"
361 "vlan set stripq (on|off) (port_id,queue_id)\n"
362 " Set the VLAN strip for a queue on a port.\n\n"
364 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
365 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
367 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
368 " Set VLAN insert for a VF from the PF.\n\n"
370 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
371 " Set VLAN antispoof for a VF from the PF.\n\n"
373 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
374 " Set VLAN tag for a VF from the PF.\n\n"
376 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
377 " Set a VF's max bandwidth(Mbps).\n\n"
379 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
380 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
382 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
383 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
385 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
386 " Set some TCs' strict link priority mode on a physical port.\n\n"
388 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
389 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
391 "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
392 " Set the VLAN strip or filter or qinq strip or extend\n\n"
394 "vlan set (inner|outer) tpid (value) (port_id)\n"
395 " Set the VLAN TPID for Packet Filtering on"
398 "rx_vlan add (vlan_id|all) (port_id)\n"
399 " Add a vlan_id, or all identifiers, to the set"
400 " of VLAN identifiers filtered by port_id.\n\n"
402 "rx_vlan rm (vlan_id|all) (port_id)\n"
403 " Remove a vlan_id, or all identifiers, from the set"
404 " of VLAN identifiers filtered by port_id.\n\n"
406 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
407 " Add a vlan_id, to the set of VLAN identifiers"
408 "filtered for VF(s) from port_id.\n\n"
410 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
411 " Remove a vlan_id, to the set of VLAN identifiers"
412 "filtered for VF(s) from port_id.\n\n"
414 "rx_vxlan_port add (udp_port) (port_id)\n"
415 " Add an UDP port for VXLAN packet filter on a port\n\n"
417 "rx_vxlan_port rm (udp_port) (port_id)\n"
418 " Remove an UDP port for VXLAN packet filter on a port\n\n"
420 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
421 " Set hardware insertion of VLAN IDs (single or double VLAN "
422 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
424 "tx_vlan set pvid port_id vlan_id (on|off)\n"
425 " Set port based TX VLAN insertion.\n\n"
427 "tx_vlan reset (port_id)\n"
428 " Disable hardware insertion of a VLAN header in"
429 " packets sent on a port.\n\n"
431 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
432 " Select hardware or software calculation of the"
433 " checksum when transmitting a packet using the"
434 " csum forward engine.\n"
435 " ip|udp|tcp|sctp always concern the inner layer.\n"
436 " outer-ip concerns the outer IP layer in"
437 " outer-udp concerns the outer UDP layer in"
438 " case the packet is recognized as a tunnel packet by"
439 " the forward engine (vxlan, gre and ipip are supported)\n"
440 " Please check the NIC datasheet for HW limits.\n\n"
442 "csum parse-tunnel (on|off) (tx_port_id)\n"
443 " If disabled, treat tunnel packets as non-tunneled"
444 " packets (treat inner headers as payload). The port\n"
445 " argument is the port used for TX in csum forward"
448 "csum show (port_id)\n"
449 " Display tx checksum offload configuration\n\n"
451 "tso set (segsize) (portid)\n"
452 " Enable TCP Segmentation Offload in csum forward"
454 " Please check the NIC datasheet for HW limits.\n\n"
457 " Display the status of TCP Segmentation Offload.\n\n"
459 "set port (port_id) gro on|off\n"
460 " Enable or disable Generic Receive Offload in"
461 " csum forwarding engine.\n\n"
463 "show port (port_id) gro\n"
464 " Display GRO configuration.\n\n"
466 "set gro flush (cycles)\n"
467 " Set the cycle to flush GROed packets from"
468 " reassembly tables.\n\n"
470 "set port (port_id) gso (on|off)"
471 " Enable or disable Generic Segmentation Offload in"
472 " csum forwarding engine.\n\n"
474 "set gso segsz (length)\n"
475 " Set max packet length for output GSO segments,"
476 " including packet header and payload.\n\n"
478 "show port (port_id) gso\n"
479 " Show GSO configuration.\n\n"
482 " Set packet forwarding mode.\n\n"
484 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
485 " Add a MAC address on port_id.\n\n"
487 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
488 " Remove a MAC address from port_id.\n\n"
490 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
491 " Set the default MAC address for port_id.\n\n"
493 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
494 " Add a MAC address for a VF on the port.\n\n"
496 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
497 " Set the MAC address for a VF from the PF.\n\n"
499 "set eth-peer (port_id) (peer_addr)\n"
500 " set the peer address for certain port.\n\n"
502 "set port (port_id) uta (mac_address|all) (on|off)\n"
503 " Add/Remove a or all unicast hash filter(s)"
506 "set promisc (port_id|all) (on|off)\n"
507 " Set the promiscuous mode on port_id, or all.\n\n"
509 "set allmulti (port_id|all) (on|off)\n"
510 " Set the allmulti mode on port_id, or all.\n\n"
512 "set vf promisc (port_id) (vf_id) (on|off)\n"
513 " Set unicast promiscuous mode for a VF from the PF.\n\n"
515 "set vf allmulti (port_id) (vf_id) (on|off)\n"
516 " Set multicast promiscuous mode for a VF from the PF.\n\n"
518 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
519 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
520 " (on|off) autoneg (on|off) (port_id)\n"
521 "set flow_ctrl rx (on|off) (portid)\n"
522 "set flow_ctrl tx (on|off) (portid)\n"
523 "set flow_ctrl high_water (high_water) (portid)\n"
524 "set flow_ctrl low_water (low_water) (portid)\n"
525 "set flow_ctrl pause_time (pause_time) (portid)\n"
526 "set flow_ctrl send_xon (send_xon) (portid)\n"
527 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
528 "set flow_ctrl autoneg (on|off) (port_id)\n"
529 " Set the link flow control parameter on a port.\n\n"
531 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
532 " (low_water) (pause_time) (priority) (port_id)\n"
533 " Set the priority flow control parameter on a"
536 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
537 " Set statistics mapping (qmapping 0..15) for RX/TX"
539 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
540 " on port 0 to mapping 5.\n\n"
542 "set xstats-hide-zero on|off\n"
543 " Set the option to hide the zero values"
544 " for xstats display.\n"
546 "set record-core-cycles on|off\n"
547 " Set the option to enable measurement of CPU cycles.\n"
549 "set record-burst-stats on|off\n"
550 " Set the option to enable display of RX and TX bursts.\n"
552 "set port (port_id) vf (vf_id) rx|tx on|off\n"
553 " Enable/Disable a VF receive/tranmit from a port\n\n"
555 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
557 " AUPE:accepts untagged VLAN;"
558 "ROPE:accept unicast hash\n\n"
559 " BAM:accepts broadcast packets;"
560 "MPE:accepts all multicast packets\n\n"
561 " Enable/Disable a VF receive mode of a port\n\n"
563 "set port (port_id) queue (queue_id) rate (rate_num)\n"
564 " Set rate limit for a queue of a port\n\n"
566 "set port (port_id) vf (vf_id) rate (rate_num) "
567 "queue_mask (queue_mask_value)\n"
568 " Set rate limit for queues in VF of a port\n\n"
570 "set port (port_id) mirror-rule (rule_id)"
571 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
572 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
573 " Set pool or vlan type mirror rule on a port.\n"
574 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
575 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
578 "set port (port_id) mirror-rule (rule_id)"
579 " (uplink-mirror|downlink-mirror) dst-pool"
580 " (pool_id) (on|off)\n"
581 " Set uplink or downlink type mirror rule on a port.\n"
582 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
583 " 0 on' enable mirror income traffic to pool 0.\n\n"
585 "reset port (port_id) mirror-rule (rule_id)\n"
586 " Reset a mirror rule.\n\n"
588 "set flush_rx (on|off)\n"
589 " Flush (default) or don't flush RX streams before"
590 " forwarding. Mainly used with PCAP drivers.\n\n"
592 "set bypass mode (normal|bypass|isolate) (port_id)\n"
593 " Set the bypass mode for the lowest port on bypass enabled"
596 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
597 "mode (normal|bypass|isolate) (port_id)\n"
598 " Set the event required to initiate specified bypass mode for"
599 " the lowest port on a bypass enabled NIC where:\n"
600 " timeout = enable bypass after watchdog timeout.\n"
601 " os_on = enable bypass when OS/board is powered on.\n"
602 " os_off = enable bypass when OS/board is powered off.\n"
603 " power_on = enable bypass when power supply is turned on.\n"
604 " power_off = enable bypass when power supply is turned off."
607 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
608 " Set the bypass watchdog timeout to 'n' seconds"
609 " where 0 = instant.\n\n"
611 "show bypass config (port_id)\n"
612 " Show the bypass configuration for a bypass enabled NIC"
613 " using the lowest port on the NIC.\n\n"
616 "create bonded device (mode) (socket)\n"
617 " Create a new bonded device with specific bonding mode and socket.\n\n"
619 "add bonding slave (slave_id) (port_id)\n"
620 " Add a slave device to a bonded device.\n\n"
622 "remove bonding slave (slave_id) (port_id)\n"
623 " Remove a slave device from a bonded device.\n\n"
625 "set bonding mode (value) (port_id)\n"
626 " Set the bonding mode on a bonded device.\n\n"
628 "set bonding primary (slave_id) (port_id)\n"
629 " Set the primary slave for a bonded device.\n\n"
631 "show bonding config (port_id)\n"
632 " Show the bonding config for port_id.\n\n"
634 "set bonding mac_addr (port_id) (address)\n"
635 " Set the MAC address of a bonded device.\n\n"
637 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
638 " Set Aggregation mode for IEEE802.3AD (mode 4)"
640 "set bonding balance_xmit_policy (port_id) (l2|l23|l34)\n"
641 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
643 "set bonding mon_period (port_id) (value)\n"
644 " Set the bonding link status monitoring polling period in ms.\n\n"
646 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
647 " Enable/disable dedicated queues for LACP control traffic.\n\n"
650 "set link-up port (port_id)\n"
651 " Set link up for a port.\n\n"
653 "set link-down port (port_id)\n"
654 " Set link down for a port.\n\n"
656 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
657 " Load a profile package on a port\n\n"
659 "ddp del (port_id) (backup_profile_path)\n"
660 " Delete a profile package from a port\n\n"
662 "ptype mapping get (port_id) (valid_only)\n"
663 " Get ptype mapping on a port\n\n"
665 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
666 " Replace target with the pkt_type in ptype mapping\n\n"
668 "ptype mapping reset (port_id)\n"
669 " Reset ptype mapping on a port\n\n"
671 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
672 " Update a ptype mapping item on a port\n\n"
674 "set port (port_id) ptype_mask (ptype_mask)\n"
675 " set packet types classification for a specific port\n\n"
677 "set port (port_id) queue-region region_id (value) "
678 "queue_start_index (value) queue_num (value)\n"
679 " Set a queue region on a port\n\n"
681 "set port (port_id) queue-region region_id (value) "
683 " Set a flowtype region index on a port\n\n"
685 "set port (port_id) queue-region UP (value) region_id (value)\n"
686 " Set the mapping of User Priority to "
687 "queue region on a port\n\n"
689 "set port (port_id) queue-region flush (on|off)\n"
690 " flush all queue region related configuration\n\n"
692 "show port meter cap (port_id)\n"
693 " Show port meter capability information\n\n"
695 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
696 " meter profile add - srtcm rfc 2697\n\n"
698 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
699 " meter profile add - trtcm rfc 2698\n\n"
701 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
702 " meter profile add - trtcm rfc 4115\n\n"
704 "del port meter profile (port_id) (profile_id)\n"
705 " meter profile delete\n\n"
707 "create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
708 "(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
709 "(dscp_tbl_entry63)]\n"
712 "enable port meter (port_id) (mtr_id)\n"
715 "disable port meter (port_id) (mtr_id)\n"
718 "del port meter (port_id) (mtr_id)\n"
721 "add port meter policy (port_id) (policy_id) g_actions (actions)\n"
722 "y_actions (actions) r_actions (actions)\n"
723 " meter policy add\n\n"
725 "del port meter policy (port_id) (policy_id)\n"
726 " meter policy delete\n\n"
728 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
729 " meter update meter profile\n\n"
731 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
732 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
733 " update meter dscp table entries\n\n"
735 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
736 "(action0) [(action1) (action2)]\n"
737 " meter update policer action\n\n"
739 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
740 " meter update stats\n\n"
742 "show port (port_id) queue-region\n"
743 " show all queue region related configuration info\n\n"
745 "set port (port_id) fec_mode auto|off|rs|baser\n"
746 " set fec mode for a specific port\n\n"
748 , list_pkt_forwarding_modes()
752 if (show_all || !strcmp(res->section, "ports")) {
758 "----------------\n\n"
760 "port start (port_id|all)\n"
761 " Start all ports or port_id.\n\n"
763 "port stop (port_id|all)\n"
764 " Stop all ports or port_id.\n\n"
766 "port close (port_id|all)\n"
767 " Close all ports or port_id.\n\n"
769 "port reset (port_id|all)\n"
770 " Reset all ports or port_id.\n\n"
772 "port attach (ident)\n"
773 " Attach physical or virtual dev by pci address or virtual device name\n\n"
775 "port detach (port_id)\n"
776 " Detach physical or virtual dev by port_id\n\n"
778 "port config (port_id|all)"
779 " speed (10|100|1000|10000|25000|40000|50000|100000|200000|auto)"
780 " duplex (half|full|auto)\n"
781 " Set speed and duplex for all ports or port_id\n\n"
783 "port config (port_id|all) loopback (mode)\n"
784 " Set loopback mode for all ports or port_id\n\n"
786 "port config all (rxq|txq|rxd|txd) (value)\n"
787 " Set number for rxq/txq/rxd/txd.\n\n"
789 "port config all max-pkt-len (value)\n"
790 " Set the max packet length.\n\n"
792 "port config all max-lro-pkt-size (value)\n"
793 " Set the max LRO aggregated packet size.\n\n"
795 "port config all drop-en (on|off)\n"
796 " Enable or disable packet drop on all RX queues of all ports when no "
797 "receive buffers available.\n\n"
799 "port config all rss (all|default|ip|tcp|udp|sctp|"
800 "ether|port|vxlan|geneve|nvgre|vxlan-gpe|ecpri|mpls|none|level-default|"
801 "level-outer|level-inner|<flowtype_id>)\n"
802 " Set the RSS mode.\n\n"
804 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
805 " Set the RSS redirection table.\n\n"
807 "port config (port_id) dcb vt (on|off) (traffic_class)"
809 " Set the DCB mode.\n\n"
811 "port config all burst (value)\n"
812 " Set the number of packets per burst.\n\n"
814 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
816 " Set the ring prefetch/host/writeback threshold"
817 " for tx/rx queue.\n\n"
819 "port config all (txfreet|txrst|rxfreet) (value)\n"
820 " Set free threshold for rx/tx, or set"
821 " tx rs bit threshold.\n\n"
822 "port config mtu X value\n"
823 " Set the MTU of port X to a given value\n\n"
825 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
826 " Set a rx/tx queue's ring size configuration, the new"
827 " value will take effect after command that (re-)start the port"
828 " or command that setup the specific queue\n\n"
830 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
831 " Start/stop a rx/tx queue of port X. Only take effect"
832 " when port X is started\n\n"
834 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
835 " Switch on/off a deferred start of port X rx/tx queue. Only"
836 " take effect when port X is stopped.\n\n"
838 "port (port_id) (rxq|txq) (queue_id) setup\n"
839 " Setup a rx/tx queue of port X.\n\n"
841 "port config (port_id) pctype mapping reset\n"
842 " Reset flow type to pctype mapping on a port\n\n"
844 "port config (port_id) pctype mapping update"
845 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
846 " Update a flow type to pctype mapping item on a port\n\n"
848 "port config (port_id) pctype (pctype_id) hash_inset|"
849 "fdir_inset|fdir_flx_inset get|set|clear field\n"
851 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
853 "port config (port_id) pctype (pctype_id) hash_inset|"
854 "fdir_inset|fdir_flx_inset clear all"
855 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
857 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
858 " Add/remove UDP tunnel port for tunneling offload\n\n"
860 "port config <port_id> rx_offload vlan_strip|"
861 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
862 "outer_ipv4_cksum|macsec_strip|header_split|"
863 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
864 "buffer_split|timestamp|security|keep_crc on|off\n"
865 " Enable or disable a per port Rx offloading"
866 " on all Rx queues of a port\n\n"
868 "port (port_id) rxq (queue_id) rx_offload vlan_strip|"
869 "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
870 "outer_ipv4_cksum|macsec_strip|header_split|"
871 "vlan_filter|vlan_extend|jumbo_frame|scatter|"
872 "buffer_split|timestamp|security|keep_crc on|off\n"
873 " Enable or disable a per queue Rx offloading"
874 " only on a specific Rx queue\n\n"
876 "port config (port_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|"
880 "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
882 " Enable or disable a per port Tx offloading"
883 " on all Tx queues of a port\n\n"
885 "port (port_id) txq (queue_id) tx_offload vlan_insert|"
886 "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
887 "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
888 "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
889 "|mt_lockfree|multi_segs|mbuf_fast_free|security"
891 " Enable or disable a per queue Tx offloading"
892 " only on a specific Tx queue\n\n"
894 "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
895 " Load an eBPF program as a callback"
896 " for particular RX/TX queue\n\n"
898 "bpf-unload rx|tx (port) (queue)\n"
899 " Unload previously loaded eBPF program"
900 " for particular RX/TX queue\n\n"
902 "port config (port_id) tx_metadata (value)\n"
903 " Set Tx metadata value per port. Testpmd will add this value"
904 " to any Tx packet sent from this port\n\n"
906 "port config (port_id) dynf (name) set|clear\n"
907 " Register a dynf and Set/clear this flag on Tx. "
908 "Testpmd will set this value to any Tx packet "
909 "sent from this port\n\n"
911 "port cleanup (port_id) txq (queue_id) (free_cnt)\n"
912 " Cleanup txq mbufs for a specific Tx queue\n\n"
916 if (show_all || !strcmp(res->section, "registers")) {
924 "read reg (port_id) (address)\n"
925 " Display value of a port register.\n\n"
927 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
928 " Display a port register bit field.\n\n"
930 "read regbit (port_id) (address) (bit_x)\n"
931 " Display a single port register bit.\n\n"
933 "write reg (port_id) (address) (value)\n"
934 " Set value of a port register.\n\n"
936 "write regfield (port_id) (address) (bit_x) (bit_y)"
938 " Set bit field of a port register.\n\n"
940 "write regbit (port_id) (address) (bit_x) (value)\n"
941 " Set single bit value of a port register.\n\n"
944 if (show_all || !strcmp(res->section, "filters")) {
953 "flow_director_filter (port_id) mode raw (add|del|update)"
954 " flow (flow_id) (drop|fwd) queue (queue_id)"
955 " fd_id (fd_id_value) packet (packet file name)\n"
956 " Add/Del a raw type flow director filter.\n\n"
959 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
960 " src_mask (ipv4_src) (ipv6_src) (src_port)"
961 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
962 " Set flow director IP mask.\n\n"
964 "flow_director_mask (port_id) mode MAC-VLAN"
965 " vlan (vlan_value)\n"
966 " Set flow director MAC-VLAN mask.\n\n"
968 "flow_director_mask (port_id) mode Tunnel"
969 " vlan (vlan_value) mac (mac_value)"
970 " tunnel-type (tunnel_type_value)"
971 " tunnel-id (tunnel_id_value)\n"
972 " Set flow director Tunnel mask.\n\n"
974 "flow_director_flex_payload (port_id)"
975 " (raw|l2|l3|l4) (config)\n"
976 " Configure flex payload selection.\n\n"
978 "flow validate {port_id}"
979 " [group {group_id}] [priority {level}]"
980 " [ingress] [egress]"
981 " pattern {item} [/ {item} [...]] / end"
982 " actions {action} [/ {action} [...]] / end\n"
983 " Check whether a flow rule can be created.\n\n"
985 "flow create {port_id}"
986 " [group {group_id}] [priority {level}]"
987 " [ingress] [egress]"
988 " pattern {item} [/ {item} [...]] / end"
989 " actions {action} [/ {action} [...]] / end\n"
990 " Create a flow rule.\n\n"
992 "flow destroy {port_id} rule {rule_id} [...]\n"
993 " Destroy specific flow rules.\n\n"
995 "flow flush {port_id}\n"
996 " Destroy all flow rules.\n\n"
998 "flow query {port_id} {rule_id} {action}\n"
999 " Query an existing flow rule.\n\n"
1001 "flow list {port_id} [group {group_id}] [...]\n"
1002 " List existing flow rules sorted by priority,"
1003 " filtered by group identifiers.\n\n"
1005 "flow isolate {port_id} {boolean}\n"
1006 " Restrict ingress traffic to the defined"
1009 "flow aged {port_id} [destroy]\n"
1010 " List and destroy aged flows"
1013 "flow indirect_action {port_id} create"
1014 " [action_id {indirect_action_id}]"
1015 " [ingress] [egress]"
1016 " action {action} / end\n"
1017 " Create indirect action.\n\n"
1019 "flow indirect_action {port_id} update"
1020 " {indirect_action_id} action {action} / end\n"
1021 " Update indirect action.\n\n"
1023 "flow indirect_action {port_id} destroy"
1024 " action_id {indirect_action_id} [...]\n"
1025 " Destroy specific indirect actions.\n\n"
1027 "flow indirect_action {port_id} query"
1028 " {indirect_action_id}\n"
1029 " Query an existing indirect action.\n\n"
1031 "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
1032 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
1033 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
1034 " Configure the VXLAN encapsulation for flows.\n\n"
1036 "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
1037 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
1038 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
1039 " eth-dst (eth-dst)\n"
1040 " Configure the VXLAN encapsulation for flows.\n\n"
1042 "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
1043 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
1044 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
1045 " eth-dst (eth-dst)\n"
1046 " Configure the VXLAN encapsulation for flows.\n\n"
1048 "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
1049 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
1051 " Configure the NVGRE encapsulation for flows.\n\n"
1053 "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
1054 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
1055 " eth-src (eth-src) eth-dst (eth-dst)\n"
1056 " Configure the NVGRE encapsulation for flows.\n\n"
1058 "set raw_encap {flow items}\n"
1059 " Configure the encapsulation with raw data.\n\n"
1061 "set raw_decap {flow items}\n"
1062 " Configure the decapsulation with raw data.\n\n"
1067 if (show_all || !strcmp(res->section, "traffic_management")) {
1071 "Traffic Management:\n"
1073 "show port tm cap (port_id)\n"
1074 " Display the port TM capability.\n\n"
1076 "show port tm level cap (port_id) (level_id)\n"
1077 " Display the port TM hierarchical level capability.\n\n"
1079 "show port tm node cap (port_id) (node_id)\n"
1080 " Display the port TM node capability.\n\n"
1082 "show port tm node type (port_id) (node_id)\n"
1083 " Display the port TM node type.\n\n"
1085 "show port tm node stats (port_id) (node_id) (clear)\n"
1086 " Display the port TM node stats.\n\n"
1088 "add port tm node shaper profile (port_id) (shaper_profile_id)"
1089 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
1090 " (packet_length_adjust) (packet_mode)\n"
1091 " Add port tm node private shaper profile.\n\n"
1093 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
1094 " Delete port tm node private shaper profile.\n\n"
1096 "add port tm node shared shaper (port_id) (shared_shaper_id)"
1097 " (shaper_profile_id)\n"
1098 " Add/update port tm node shared shaper.\n\n"
1100 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1101 " Delete port tm node shared shaper.\n\n"
1103 "set port tm node shaper profile (port_id) (node_id)"
1104 " (shaper_profile_id)\n"
1105 " Set port tm node shaper profile.\n\n"
1107 "add port tm node wred profile (port_id) (wred_profile_id)"
1108 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1109 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1110 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1111 " Add port tm node wred profile.\n\n"
1113 "del port tm node wred profile (port_id) (wred_profile_id)\n"
1114 " Delete port tm node wred profile.\n\n"
1116 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1117 " (priority) (weight) (level_id) (shaper_profile_id)"
1118 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1119 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1120 " Add port tm nonleaf node.\n\n"
1122 "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1123 " (priority) (weight) (level_id) (shaper_profile_id)"
1124 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1125 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1126 " Add port tm nonleaf node with pkt mode enabled.\n\n"
1128 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1129 " (priority) (weight) (level_id) (shaper_profile_id)"
1130 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1131 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1132 " Add port tm leaf node.\n\n"
1134 "del port tm node (port_id) (node_id)\n"
1135 " Delete port tm node.\n\n"
1137 "set port tm node parent (port_id) (node_id) (parent_node_id)"
1138 " (priority) (weight)\n"
1139 " Set port tm node parent.\n\n"
1141 "suspend port tm node (port_id) (node_id)"
1142 " Suspend tm node.\n\n"
1144 "resume port tm node (port_id) (node_id)"
1145 " Resume tm node.\n\n"
1147 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1148 " Commit tm hierarchy.\n\n"
1150 "set port tm mark ip_ecn (port) (green) (yellow)"
1152 " Enables/Disables the traffic management marking"
1153 " for IP ECN (Explicit Congestion Notification)"
1154 " packets on a given port\n\n"
1156 "set port tm mark ip_dscp (port) (green) (yellow)"
1158 " Enables/Disables the traffic management marking"
1159 " on the port for IP dscp packets\n\n"
1161 "set port tm mark vlan_dei (port) (green) (yellow)"
1163 " Enables/Disables the traffic management marking"
1164 " on the port for VLAN packets with DEI enabled\n\n"
1168 if (show_all || !strcmp(res->section, "devices")) {
1172 "Device Operations:\n"
1174 "device detach (identifier)\n"
1175 " Detach device by identifier.\n\n"
1181 cmdline_parse_token_string_t cmd_help_long_help =
1182 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1184 cmdline_parse_token_string_t cmd_help_long_section =
1185 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1186 "all#control#display#config#"
1187 "ports#registers#filters#traffic_management#devices");
1189 cmdline_parse_inst_t cmd_help_long = {
1190 .f = cmd_help_long_parsed,
1192 .help_str = "help all|control|display|config|ports|register|"
1193 "filters|traffic_management|devices: "
1196 (void *)&cmd_help_long_help,
1197 (void *)&cmd_help_long_section,
1203 /* *** start/stop/close all ports *** */
1204 struct cmd_operate_port_result {
1205 cmdline_fixed_string_t keyword;
1206 cmdline_fixed_string_t name;
1207 cmdline_fixed_string_t value;
1210 static void cmd_operate_port_parsed(void *parsed_result,
1211 __rte_unused struct cmdline *cl,
1212 __rte_unused void *data)
1214 struct cmd_operate_port_result *res = parsed_result;
1216 if (!strcmp(res->name, "start"))
1217 start_port(RTE_PORT_ALL);
1218 else if (!strcmp(res->name, "stop"))
1219 stop_port(RTE_PORT_ALL);
1220 else if (!strcmp(res->name, "close"))
1221 close_port(RTE_PORT_ALL);
1222 else if (!strcmp(res->name, "reset"))
1223 reset_port(RTE_PORT_ALL);
1225 fprintf(stderr, "Unknown parameter\n");
1228 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1229 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1231 cmdline_parse_token_string_t cmd_operate_port_all_port =
1232 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1233 "start#stop#close#reset");
1234 cmdline_parse_token_string_t cmd_operate_port_all_all =
1235 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1237 cmdline_parse_inst_t cmd_operate_port = {
1238 .f = cmd_operate_port_parsed,
1240 .help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports",
1242 (void *)&cmd_operate_port_all_cmd,
1243 (void *)&cmd_operate_port_all_port,
1244 (void *)&cmd_operate_port_all_all,
1249 /* *** start/stop/close specific port *** */
1250 struct cmd_operate_specific_port_result {
1251 cmdline_fixed_string_t keyword;
1252 cmdline_fixed_string_t name;
1256 static void cmd_operate_specific_port_parsed(void *parsed_result,
1257 __rte_unused struct cmdline *cl,
1258 __rte_unused void *data)
1260 struct cmd_operate_specific_port_result *res = parsed_result;
1262 if (!strcmp(res->name, "start"))
1263 start_port(res->value);
1264 else if (!strcmp(res->name, "stop"))
1265 stop_port(res->value);
1266 else if (!strcmp(res->name, "close"))
1267 close_port(res->value);
1268 else if (!strcmp(res->name, "reset"))
1269 reset_port(res->value);
1271 fprintf(stderr, "Unknown parameter\n");
1274 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1275 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1277 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1278 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1279 name, "start#stop#close#reset");
1280 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1281 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1284 cmdline_parse_inst_t cmd_operate_specific_port = {
1285 .f = cmd_operate_specific_port_parsed,
1287 .help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id",
1289 (void *)&cmd_operate_specific_port_cmd,
1290 (void *)&cmd_operate_specific_port_port,
1291 (void *)&cmd_operate_specific_port_id,
1296 /* *** enable port setup (after attach) via iterator or event *** */
1297 struct cmd_set_port_setup_on_result {
1298 cmdline_fixed_string_t set;
1299 cmdline_fixed_string_t port;
1300 cmdline_fixed_string_t setup;
1301 cmdline_fixed_string_t on;
1302 cmdline_fixed_string_t mode;
1305 static void cmd_set_port_setup_on_parsed(void *parsed_result,
1306 __rte_unused struct cmdline *cl,
1307 __rte_unused void *data)
1309 struct cmd_set_port_setup_on_result *res = parsed_result;
1311 if (strcmp(res->mode, "event") == 0)
1312 setup_on_probe_event = true;
1313 else if (strcmp(res->mode, "iterator") == 0)
1314 setup_on_probe_event = false;
1316 fprintf(stderr, "Unknown mode\n");
1319 cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1320 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1322 cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1323 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1325 cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1326 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1328 cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1329 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1331 cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1332 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1333 mode, "iterator#event");
1335 cmdline_parse_inst_t cmd_set_port_setup_on = {
1336 .f = cmd_set_port_setup_on_parsed,
1338 .help_str = "set port setup on iterator|event",
1340 (void *)&cmd_set_port_setup_on_set,
1341 (void *)&cmd_set_port_setup_on_port,
1342 (void *)&cmd_set_port_setup_on_setup,
1343 (void *)&cmd_set_port_setup_on_on,
1344 (void *)&cmd_set_port_setup_on_mode,
1349 /* *** attach a specified port *** */
1350 struct cmd_operate_attach_port_result {
1351 cmdline_fixed_string_t port;
1352 cmdline_fixed_string_t keyword;
1353 cmdline_multi_string_t identifier;
1356 static void cmd_operate_attach_port_parsed(void *parsed_result,
1357 __rte_unused struct cmdline *cl,
1358 __rte_unused void *data)
1360 struct cmd_operate_attach_port_result *res = parsed_result;
1362 if (!strcmp(res->keyword, "attach"))
1363 attach_port(res->identifier);
1365 fprintf(stderr, "Unknown parameter\n");
1368 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1369 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1371 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1372 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1374 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1375 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1376 identifier, TOKEN_STRING_MULTI);
1378 cmdline_parse_inst_t cmd_operate_attach_port = {
1379 .f = cmd_operate_attach_port_parsed,
1381 .help_str = "port attach <identifier>: "
1382 "(identifier: pci address or virtual dev name)",
1384 (void *)&cmd_operate_attach_port_port,
1385 (void *)&cmd_operate_attach_port_keyword,
1386 (void *)&cmd_operate_attach_port_identifier,
1391 /* *** detach a specified port *** */
1392 struct cmd_operate_detach_port_result {
1393 cmdline_fixed_string_t port;
1394 cmdline_fixed_string_t keyword;
1398 static void cmd_operate_detach_port_parsed(void *parsed_result,
1399 __rte_unused struct cmdline *cl,
1400 __rte_unused void *data)
1402 struct cmd_operate_detach_port_result *res = parsed_result;
1404 if (!strcmp(res->keyword, "detach")) {
1405 RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1406 detach_port_device(res->port_id);
1408 fprintf(stderr, "Unknown parameter\n");
1412 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1413 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1415 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1416 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1418 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1419 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1420 port_id, RTE_UINT16);
1422 cmdline_parse_inst_t cmd_operate_detach_port = {
1423 .f = cmd_operate_detach_port_parsed,
1425 .help_str = "port detach <port_id>",
1427 (void *)&cmd_operate_detach_port_port,
1428 (void *)&cmd_operate_detach_port_keyword,
1429 (void *)&cmd_operate_detach_port_port_id,
1434 /* *** detach device by identifier *** */
1435 struct cmd_operate_detach_device_result {
1436 cmdline_fixed_string_t device;
1437 cmdline_fixed_string_t keyword;
1438 cmdline_fixed_string_t identifier;
1441 static void cmd_operate_detach_device_parsed(void *parsed_result,
1442 __rte_unused struct cmdline *cl,
1443 __rte_unused void *data)
1445 struct cmd_operate_detach_device_result *res = parsed_result;
1447 if (!strcmp(res->keyword, "detach"))
1448 detach_devargs(res->identifier);
1450 fprintf(stderr, "Unknown parameter\n");
1453 cmdline_parse_token_string_t cmd_operate_detach_device_device =
1454 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1456 cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1457 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1459 cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1460 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1463 cmdline_parse_inst_t cmd_operate_detach_device = {
1464 .f = cmd_operate_detach_device_parsed,
1466 .help_str = "device detach <identifier>:"
1467 "(identifier: pci address or virtual dev name)",
1469 (void *)&cmd_operate_detach_device_device,
1470 (void *)&cmd_operate_detach_device_keyword,
1471 (void *)&cmd_operate_detach_device_identifier,
1475 /* *** configure speed for all ports *** */
1476 struct cmd_config_speed_all {
1477 cmdline_fixed_string_t port;
1478 cmdline_fixed_string_t keyword;
1479 cmdline_fixed_string_t all;
1480 cmdline_fixed_string_t item1;
1481 cmdline_fixed_string_t item2;
1482 cmdline_fixed_string_t value1;
1483 cmdline_fixed_string_t value2;
1487 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1492 if (!strcmp(duplexstr, "half")) {
1493 duplex = ETH_LINK_HALF_DUPLEX;
1494 } else if (!strcmp(duplexstr, "full")) {
1495 duplex = ETH_LINK_FULL_DUPLEX;
1496 } else if (!strcmp(duplexstr, "auto")) {
1497 duplex = ETH_LINK_FULL_DUPLEX;
1499 fprintf(stderr, "Unknown duplex parameter\n");
1503 if (!strcmp(speedstr, "10")) {
1504 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1505 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1506 } else if (!strcmp(speedstr, "100")) {
1507 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1508 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1510 if (duplex != ETH_LINK_FULL_DUPLEX) {
1511 fprintf(stderr, "Invalid speed/duplex parameters\n");
1514 if (!strcmp(speedstr, "1000")) {
1515 *speed = ETH_LINK_SPEED_1G;
1516 } else if (!strcmp(speedstr, "10000")) {
1517 *speed = ETH_LINK_SPEED_10G;
1518 } else if (!strcmp(speedstr, "25000")) {
1519 *speed = ETH_LINK_SPEED_25G;
1520 } else if (!strcmp(speedstr, "40000")) {
1521 *speed = ETH_LINK_SPEED_40G;
1522 } else if (!strcmp(speedstr, "50000")) {
1523 *speed = ETH_LINK_SPEED_50G;
1524 } else if (!strcmp(speedstr, "100000")) {
1525 *speed = ETH_LINK_SPEED_100G;
1526 } else if (!strcmp(speedstr, "200000")) {
1527 *speed = ETH_LINK_SPEED_200G;
1528 } else if (!strcmp(speedstr, "auto")) {
1529 *speed = ETH_LINK_SPEED_AUTONEG;
1531 fprintf(stderr, "Unknown speed parameter\n");
1536 if (*speed != ETH_LINK_SPEED_AUTONEG)
1537 *speed |= ETH_LINK_SPEED_FIXED;
1543 cmd_config_speed_all_parsed(void *parsed_result,
1544 __rte_unused struct cmdline *cl,
1545 __rte_unused void *data)
1547 struct cmd_config_speed_all *res = parsed_result;
1548 uint32_t link_speed;
1551 if (!all_ports_stopped()) {
1552 fprintf(stderr, "Please stop all ports first\n");
1556 if (parse_and_check_speed_duplex(res->value1, res->value2,
1560 RTE_ETH_FOREACH_DEV(pid) {
1561 ports[pid].dev_conf.link_speeds = link_speed;
1564 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1567 cmdline_parse_token_string_t cmd_config_speed_all_port =
1568 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1569 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1570 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1572 cmdline_parse_token_string_t cmd_config_speed_all_all =
1573 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1574 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1575 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1576 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1577 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1578 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1579 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1580 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1581 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1582 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1585 cmdline_parse_inst_t cmd_config_speed_all = {
1586 .f = cmd_config_speed_all_parsed,
1588 .help_str = "port config all speed "
1589 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1592 (void *)&cmd_config_speed_all_port,
1593 (void *)&cmd_config_speed_all_keyword,
1594 (void *)&cmd_config_speed_all_all,
1595 (void *)&cmd_config_speed_all_item1,
1596 (void *)&cmd_config_speed_all_value1,
1597 (void *)&cmd_config_speed_all_item2,
1598 (void *)&cmd_config_speed_all_value2,
1603 /* *** configure speed for specific port *** */
1604 struct cmd_config_speed_specific {
1605 cmdline_fixed_string_t port;
1606 cmdline_fixed_string_t keyword;
1608 cmdline_fixed_string_t item1;
1609 cmdline_fixed_string_t item2;
1610 cmdline_fixed_string_t value1;
1611 cmdline_fixed_string_t value2;
1615 cmd_config_speed_specific_parsed(void *parsed_result,
1616 __rte_unused struct cmdline *cl,
1617 __rte_unused void *data)
1619 struct cmd_config_speed_specific *res = parsed_result;
1620 uint32_t link_speed;
1622 if (port_id_is_invalid(res->id, ENABLED_WARN))
1625 if (!port_is_stopped(res->id)) {
1626 fprintf(stderr, "Please stop port %d first\n", res->id);
1630 if (parse_and_check_speed_duplex(res->value1, res->value2,
1634 ports[res->id].dev_conf.link_speeds = link_speed;
1636 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1640 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1641 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1643 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1644 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1646 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1647 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1648 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1649 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1651 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1652 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1653 "10#100#1000#10000#25000#40000#50000#100000#200000#auto");
1654 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1655 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1657 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1658 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1661 cmdline_parse_inst_t cmd_config_speed_specific = {
1662 .f = cmd_config_speed_specific_parsed,
1664 .help_str = "port config <port_id> speed "
1665 "10|100|1000|10000|25000|40000|50000|100000|200000|auto duplex "
1668 (void *)&cmd_config_speed_specific_port,
1669 (void *)&cmd_config_speed_specific_keyword,
1670 (void *)&cmd_config_speed_specific_id,
1671 (void *)&cmd_config_speed_specific_item1,
1672 (void *)&cmd_config_speed_specific_value1,
1673 (void *)&cmd_config_speed_specific_item2,
1674 (void *)&cmd_config_speed_specific_value2,
1679 /* *** configure loopback for all ports *** */
1680 struct cmd_config_loopback_all {
1681 cmdline_fixed_string_t port;
1682 cmdline_fixed_string_t keyword;
1683 cmdline_fixed_string_t all;
1684 cmdline_fixed_string_t item;
1689 cmd_config_loopback_all_parsed(void *parsed_result,
1690 __rte_unused struct cmdline *cl,
1691 __rte_unused void *data)
1693 struct cmd_config_loopback_all *res = parsed_result;
1696 if (!all_ports_stopped()) {
1697 fprintf(stderr, "Please stop all ports first\n");
1701 RTE_ETH_FOREACH_DEV(pid) {
1702 ports[pid].dev_conf.lpbk_mode = res->mode;
1705 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1708 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1709 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1710 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1711 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1713 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1714 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1715 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1716 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1718 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1719 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1721 cmdline_parse_inst_t cmd_config_loopback_all = {
1722 .f = cmd_config_loopback_all_parsed,
1724 .help_str = "port config all loopback <mode>",
1726 (void *)&cmd_config_loopback_all_port,
1727 (void *)&cmd_config_loopback_all_keyword,
1728 (void *)&cmd_config_loopback_all_all,
1729 (void *)&cmd_config_loopback_all_item,
1730 (void *)&cmd_config_loopback_all_mode,
1735 /* *** configure loopback for specific port *** */
1736 struct cmd_config_loopback_specific {
1737 cmdline_fixed_string_t port;
1738 cmdline_fixed_string_t keyword;
1740 cmdline_fixed_string_t item;
1745 cmd_config_loopback_specific_parsed(void *parsed_result,
1746 __rte_unused struct cmdline *cl,
1747 __rte_unused void *data)
1749 struct cmd_config_loopback_specific *res = parsed_result;
1751 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1754 if (!port_is_stopped(res->port_id)) {
1755 fprintf(stderr, "Please stop port %u first\n", res->port_id);
1759 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1761 cmd_reconfig_device_queue(res->port_id, 1, 1);
1765 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1766 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1768 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1769 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1771 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1772 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1774 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1775 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1777 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1778 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1781 cmdline_parse_inst_t cmd_config_loopback_specific = {
1782 .f = cmd_config_loopback_specific_parsed,
1784 .help_str = "port config <port_id> loopback <mode>",
1786 (void *)&cmd_config_loopback_specific_port,
1787 (void *)&cmd_config_loopback_specific_keyword,
1788 (void *)&cmd_config_loopback_specific_id,
1789 (void *)&cmd_config_loopback_specific_item,
1790 (void *)&cmd_config_loopback_specific_mode,
1795 /* *** configure txq/rxq, txd/rxd *** */
1796 struct cmd_config_rx_tx {
1797 cmdline_fixed_string_t port;
1798 cmdline_fixed_string_t keyword;
1799 cmdline_fixed_string_t all;
1800 cmdline_fixed_string_t name;
1805 cmd_config_rx_tx_parsed(void *parsed_result,
1806 __rte_unused struct cmdline *cl,
1807 __rte_unused void *data)
1809 struct cmd_config_rx_tx *res = parsed_result;
1811 if (!all_ports_stopped()) {
1812 fprintf(stderr, "Please stop all ports first\n");
1815 if (!strcmp(res->name, "rxq")) {
1816 if (!res->value && !nb_txq) {
1817 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1820 if (check_nb_rxq(res->value) != 0)
1822 nb_rxq = res->value;
1824 else if (!strcmp(res->name, "txq")) {
1825 if (!res->value && !nb_rxq) {
1826 fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1829 if (check_nb_txq(res->value) != 0)
1831 nb_txq = res->value;
1833 else if (!strcmp(res->name, "rxd")) {
1834 if (check_nb_rxd(res->value) != 0)
1836 nb_rxd = res->value;
1837 } else if (!strcmp(res->name, "txd")) {
1838 if (check_nb_txd(res->value) != 0)
1841 nb_txd = res->value;
1843 fprintf(stderr, "Unknown parameter\n");
1851 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1854 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1855 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1856 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1857 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1858 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1859 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1860 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1861 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1863 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1864 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
1866 cmdline_parse_inst_t cmd_config_rx_tx = {
1867 .f = cmd_config_rx_tx_parsed,
1869 .help_str = "port config all rxq|txq|rxd|txd <value>",
1871 (void *)&cmd_config_rx_tx_port,
1872 (void *)&cmd_config_rx_tx_keyword,
1873 (void *)&cmd_config_rx_tx_all,
1874 (void *)&cmd_config_rx_tx_name,
1875 (void *)&cmd_config_rx_tx_value,
1880 /* *** config max packet length *** */
1881 struct cmd_config_max_pkt_len_result {
1882 cmdline_fixed_string_t port;
1883 cmdline_fixed_string_t keyword;
1884 cmdline_fixed_string_t all;
1885 cmdline_fixed_string_t name;
1890 cmd_config_max_pkt_len_parsed(void *parsed_result,
1891 __rte_unused struct cmdline *cl,
1892 __rte_unused void *data)
1894 struct cmd_config_max_pkt_len_result *res = parsed_result;
1895 uint32_t max_rx_pkt_len_backup = 0;
1899 if (!all_ports_stopped()) {
1900 fprintf(stderr, "Please stop all ports first\n");
1904 RTE_ETH_FOREACH_DEV(pid) {
1905 struct rte_port *port = &ports[pid];
1907 if (!strcmp(res->name, "max-pkt-len")) {
1908 if (res->value < RTE_ETHER_MIN_LEN) {
1910 "max-pkt-len can not be less than %d\n",
1914 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1917 ret = eth_dev_info_get_print_err(pid, &port->dev_info);
1920 "rte_eth_dev_info_get() failed for port %u\n",
1925 max_rx_pkt_len_backup = port->dev_conf.rxmode.max_rx_pkt_len;
1927 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1928 if (update_jumbo_frame_offload(pid) != 0)
1929 port->dev_conf.rxmode.max_rx_pkt_len = max_rx_pkt_len_backup;
1931 fprintf(stderr, "Unknown parameter\n");
1938 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1941 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1942 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1944 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1945 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1947 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1948 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1950 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1951 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1953 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1954 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1957 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1958 .f = cmd_config_max_pkt_len_parsed,
1960 .help_str = "port config all max-pkt-len <value>",
1962 (void *)&cmd_config_max_pkt_len_port,
1963 (void *)&cmd_config_max_pkt_len_keyword,
1964 (void *)&cmd_config_max_pkt_len_all,
1965 (void *)&cmd_config_max_pkt_len_name,
1966 (void *)&cmd_config_max_pkt_len_value,
1971 /* *** config max LRO aggregated packet size *** */
1972 struct cmd_config_max_lro_pkt_size_result {
1973 cmdline_fixed_string_t port;
1974 cmdline_fixed_string_t keyword;
1975 cmdline_fixed_string_t all;
1976 cmdline_fixed_string_t name;
1981 cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1982 __rte_unused struct cmdline *cl,
1983 __rte_unused void *data)
1985 struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1988 if (!all_ports_stopped()) {
1989 fprintf(stderr, "Please stop all ports first\n");
1993 RTE_ETH_FOREACH_DEV(pid) {
1994 struct rte_port *port = &ports[pid];
1996 if (!strcmp(res->name, "max-lro-pkt-size")) {
1998 port->dev_conf.rxmode.max_lro_pkt_size)
2001 port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2003 fprintf(stderr, "Unknown parameter\n");
2010 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2013 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2014 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2016 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2017 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2019 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2020 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2022 cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2023 TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2024 name, "max-lro-pkt-size");
2025 cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2026 TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2029 cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2030 .f = cmd_config_max_lro_pkt_size_parsed,
2032 .help_str = "port config all max-lro-pkt-size <value>",
2034 (void *)&cmd_config_max_lro_pkt_size_port,
2035 (void *)&cmd_config_max_lro_pkt_size_keyword,
2036 (void *)&cmd_config_max_lro_pkt_size_all,
2037 (void *)&cmd_config_max_lro_pkt_size_name,
2038 (void *)&cmd_config_max_lro_pkt_size_value,
2043 /* *** configure port MTU *** */
2044 struct cmd_config_mtu_result {
2045 cmdline_fixed_string_t port;
2046 cmdline_fixed_string_t keyword;
2047 cmdline_fixed_string_t mtu;
2053 cmd_config_mtu_parsed(void *parsed_result,
2054 __rte_unused struct cmdline *cl,
2055 __rte_unused void *data)
2057 struct cmd_config_mtu_result *res = parsed_result;
2059 if (res->value < RTE_ETHER_MIN_LEN) {
2060 fprintf(stderr, "mtu cannot be less than %d\n", RTE_ETHER_MIN_LEN);
2063 port_mtu_set(res->port_id, res->value);
2066 cmdline_parse_token_string_t cmd_config_mtu_port =
2067 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2069 cmdline_parse_token_string_t cmd_config_mtu_keyword =
2070 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2072 cmdline_parse_token_string_t cmd_config_mtu_mtu =
2073 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2075 cmdline_parse_token_num_t cmd_config_mtu_port_id =
2076 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2078 cmdline_parse_token_num_t cmd_config_mtu_value =
2079 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2082 cmdline_parse_inst_t cmd_config_mtu = {
2083 .f = cmd_config_mtu_parsed,
2085 .help_str = "port config mtu <port_id> <value>",
2087 (void *)&cmd_config_mtu_port,
2088 (void *)&cmd_config_mtu_keyword,
2089 (void *)&cmd_config_mtu_mtu,
2090 (void *)&cmd_config_mtu_port_id,
2091 (void *)&cmd_config_mtu_value,
2096 /* *** configure rx mode *** */
2097 struct cmd_config_rx_mode_flag {
2098 cmdline_fixed_string_t port;
2099 cmdline_fixed_string_t keyword;
2100 cmdline_fixed_string_t all;
2101 cmdline_fixed_string_t name;
2102 cmdline_fixed_string_t value;
2106 cmd_config_rx_mode_flag_parsed(void *parsed_result,
2107 __rte_unused struct cmdline *cl,
2108 __rte_unused void *data)
2110 struct cmd_config_rx_mode_flag *res = parsed_result;
2112 if (!all_ports_stopped()) {
2113 fprintf(stderr, "Please stop all ports first\n");
2117 if (!strcmp(res->name, "drop-en")) {
2118 if (!strcmp(res->value, "on"))
2120 else if (!strcmp(res->value, "off"))
2123 fprintf(stderr, "Unknown parameter\n");
2127 fprintf(stderr, "Unknown parameter\n");
2133 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2136 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2137 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2138 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2139 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2141 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2142 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2143 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2144 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2146 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2147 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2150 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2151 .f = cmd_config_rx_mode_flag_parsed,
2153 .help_str = "port config all drop-en on|off",
2155 (void *)&cmd_config_rx_mode_flag_port,
2156 (void *)&cmd_config_rx_mode_flag_keyword,
2157 (void *)&cmd_config_rx_mode_flag_all,
2158 (void *)&cmd_config_rx_mode_flag_name,
2159 (void *)&cmd_config_rx_mode_flag_value,
2164 /* *** configure rss *** */
2165 struct cmd_config_rss {
2166 cmdline_fixed_string_t port;
2167 cmdline_fixed_string_t keyword;
2168 cmdline_fixed_string_t all;
2169 cmdline_fixed_string_t name;
2170 cmdline_fixed_string_t value;
2174 cmd_config_rss_parsed(void *parsed_result,
2175 __rte_unused struct cmdline *cl,
2176 __rte_unused void *data)
2178 struct cmd_config_rss *res = parsed_result;
2179 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2180 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2181 int use_default = 0;
2182 int all_updated = 1;
2187 if (!strcmp(res->value, "all"))
2188 rss_conf.rss_hf = ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP |
2189 ETH_RSS_TCP | ETH_RSS_UDP | ETH_RSS_SCTP |
2190 ETH_RSS_L2_PAYLOAD | ETH_RSS_L2TPV3 | ETH_RSS_ESP |
2191 ETH_RSS_AH | ETH_RSS_PFCP | ETH_RSS_GTPU |
2193 else if (!strcmp(res->value, "eth"))
2194 rss_conf.rss_hf = ETH_RSS_ETH;
2195 else if (!strcmp(res->value, "vlan"))
2196 rss_conf.rss_hf = ETH_RSS_VLAN;
2197 else if (!strcmp(res->value, "ip"))
2198 rss_conf.rss_hf = ETH_RSS_IP;
2199 else if (!strcmp(res->value, "udp"))
2200 rss_conf.rss_hf = ETH_RSS_UDP;
2201 else if (!strcmp(res->value, "tcp"))
2202 rss_conf.rss_hf = ETH_RSS_TCP;
2203 else if (!strcmp(res->value, "sctp"))
2204 rss_conf.rss_hf = ETH_RSS_SCTP;
2205 else if (!strcmp(res->value, "ether"))
2206 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2207 else if (!strcmp(res->value, "port"))
2208 rss_conf.rss_hf = ETH_RSS_PORT;
2209 else if (!strcmp(res->value, "vxlan"))
2210 rss_conf.rss_hf = ETH_RSS_VXLAN;
2211 else if (!strcmp(res->value, "geneve"))
2212 rss_conf.rss_hf = ETH_RSS_GENEVE;
2213 else if (!strcmp(res->value, "nvgre"))
2214 rss_conf.rss_hf = ETH_RSS_NVGRE;
2215 else if (!strcmp(res->value, "l3-pre32"))
2216 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE32;
2217 else if (!strcmp(res->value, "l3-pre40"))
2218 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE40;
2219 else if (!strcmp(res->value, "l3-pre48"))
2220 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE48;
2221 else if (!strcmp(res->value, "l3-pre56"))
2222 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE56;
2223 else if (!strcmp(res->value, "l3-pre64"))
2224 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE64;
2225 else if (!strcmp(res->value, "l3-pre96"))
2226 rss_conf.rss_hf = RTE_ETH_RSS_L3_PRE96;
2227 else if (!strcmp(res->value, "l3-src-only"))
2228 rss_conf.rss_hf = ETH_RSS_L3_SRC_ONLY;
2229 else if (!strcmp(res->value, "l3-dst-only"))
2230 rss_conf.rss_hf = ETH_RSS_L3_DST_ONLY;
2231 else if (!strcmp(res->value, "l4-src-only"))
2232 rss_conf.rss_hf = ETH_RSS_L4_SRC_ONLY;
2233 else if (!strcmp(res->value, "l4-dst-only"))
2234 rss_conf.rss_hf = ETH_RSS_L4_DST_ONLY;
2235 else if (!strcmp(res->value, "l2-src-only"))
2236 rss_conf.rss_hf = ETH_RSS_L2_SRC_ONLY;
2237 else if (!strcmp(res->value, "l2-dst-only"))
2238 rss_conf.rss_hf = ETH_RSS_L2_DST_ONLY;
2239 else if (!strcmp(res->value, "l2tpv3"))
2240 rss_conf.rss_hf = ETH_RSS_L2TPV3;
2241 else if (!strcmp(res->value, "esp"))
2242 rss_conf.rss_hf = ETH_RSS_ESP;
2243 else if (!strcmp(res->value, "ah"))
2244 rss_conf.rss_hf = ETH_RSS_AH;
2245 else if (!strcmp(res->value, "pfcp"))
2246 rss_conf.rss_hf = ETH_RSS_PFCP;
2247 else if (!strcmp(res->value, "pppoe"))
2248 rss_conf.rss_hf = ETH_RSS_PPPOE;
2249 else if (!strcmp(res->value, "gtpu"))
2250 rss_conf.rss_hf = ETH_RSS_GTPU;
2251 else if (!strcmp(res->value, "ecpri"))
2252 rss_conf.rss_hf = ETH_RSS_ECPRI;
2253 else if (!strcmp(res->value, "mpls"))
2254 rss_conf.rss_hf = ETH_RSS_MPLS;
2255 else if (!strcmp(res->value, "ipv4-chksum"))
2256 rss_conf.rss_hf = ETH_RSS_IPV4_CHKSUM;
2257 else if (!strcmp(res->value, "none"))
2258 rss_conf.rss_hf = 0;
2259 else if (!strcmp(res->value, "level-default")) {
2260 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2261 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_PMD_DEFAULT);
2262 } else if (!strcmp(res->value, "level-outer")) {
2263 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2264 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_OUTERMOST);
2265 } else if (!strcmp(res->value, "level-inner")) {
2266 rss_hf &= (~ETH_RSS_LEVEL_MASK);
2267 rss_conf.rss_hf = (rss_hf | ETH_RSS_LEVEL_INNERMOST);
2268 } else if (!strcmp(res->value, "default"))
2270 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2271 atoi(res->value) < 64)
2272 rss_conf.rss_hf = 1ULL << atoi(res->value);
2274 fprintf(stderr, "Unknown parameter\n");
2277 rss_conf.rss_key = NULL;
2278 /* Update global configuration for RSS types. */
2279 RTE_ETH_FOREACH_DEV(i) {
2280 struct rte_eth_rss_conf local_rss_conf;
2282 ret = eth_dev_info_get_print_err(i, &dev_info);
2287 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2289 local_rss_conf = rss_conf;
2290 local_rss_conf.rss_hf = rss_conf.rss_hf &
2291 dev_info.flow_type_rss_offloads;
2292 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2293 printf("Port %u modified RSS hash function based on hardware support,"
2294 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2295 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2297 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2301 "Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n",
2302 i, -diag, strerror(-diag));
2305 if (all_updated && !use_default) {
2306 rss_hf = rss_conf.rss_hf;
2307 printf("rss_hf %#"PRIx64"\n", rss_hf);
2311 cmdline_parse_token_string_t cmd_config_rss_port =
2312 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2313 cmdline_parse_token_string_t cmd_config_rss_keyword =
2314 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2315 cmdline_parse_token_string_t cmd_config_rss_all =
2316 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2317 cmdline_parse_token_string_t cmd_config_rss_name =
2318 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2319 cmdline_parse_token_string_t cmd_config_rss_value =
2320 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2322 cmdline_parse_inst_t cmd_config_rss = {
2323 .f = cmd_config_rss_parsed,
2325 .help_str = "port config all rss "
2326 "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|"
2327 "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none|level-default|"
2328 "level-outer|level-inner|ipv4-chksum|<flowtype_id>",
2330 (void *)&cmd_config_rss_port,
2331 (void *)&cmd_config_rss_keyword,
2332 (void *)&cmd_config_rss_all,
2333 (void *)&cmd_config_rss_name,
2334 (void *)&cmd_config_rss_value,
2339 /* *** configure rss hash key *** */
2340 struct cmd_config_rss_hash_key {
2341 cmdline_fixed_string_t port;
2342 cmdline_fixed_string_t config;
2344 cmdline_fixed_string_t rss_hash_key;
2345 cmdline_fixed_string_t rss_type;
2346 cmdline_fixed_string_t key;
2350 hexa_digit_to_value(char hexa_digit)
2352 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2353 return (uint8_t) (hexa_digit - '0');
2354 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2355 return (uint8_t) ((hexa_digit - 'a') + 10);
2356 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2357 return (uint8_t) ((hexa_digit - 'A') + 10);
2358 /* Invalid hexa digit */
2363 parse_and_check_key_hexa_digit(char *key, int idx)
2367 hexa_v = hexa_digit_to_value(key[idx]);
2370 "invalid key: character %c at position %d is not a valid hexa digit\n",
2376 cmd_config_rss_hash_key_parsed(void *parsed_result,
2377 __rte_unused struct cmdline *cl,
2378 __rte_unused void *data)
2380 struct cmd_config_rss_hash_key *res = parsed_result;
2381 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2385 struct rte_eth_dev_info dev_info;
2386 uint8_t hash_key_size;
2390 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2394 if (dev_info.hash_key_size > 0 &&
2395 dev_info.hash_key_size <= sizeof(hash_key))
2396 hash_key_size = dev_info.hash_key_size;
2399 "dev_info did not provide a valid hash key size\n");
2402 /* Check the length of the RSS hash key */
2403 key_len = strlen(res->key);
2404 if (key_len != (hash_key_size * 2)) {
2406 "key length: %d invalid - key must be a string of %d hexa-decimal numbers\n",
2407 (int)key_len, hash_key_size * 2);
2410 /* Translate RSS hash key into binary representation */
2411 for (i = 0; i < hash_key_size; i++) {
2412 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2415 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2418 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2420 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2424 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2425 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2426 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2427 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2429 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2430 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2432 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2433 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2434 rss_hash_key, "rss-hash-key");
2435 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2436 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2437 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2438 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2439 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2440 "ipv6-tcp-ex#ipv6-udp-ex#"
2441 "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2442 "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2443 "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls");
2444 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2445 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2447 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2448 .f = cmd_config_rss_hash_key_parsed,
2450 .help_str = "port config <port_id> rss-hash-key "
2451 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2452 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2453 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|"
2454 "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2455 "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2456 "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls "
2457 "<string of hex digits (variable length, NIC dependent)>",
2459 (void *)&cmd_config_rss_hash_key_port,
2460 (void *)&cmd_config_rss_hash_key_config,
2461 (void *)&cmd_config_rss_hash_key_port_id,
2462 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2463 (void *)&cmd_config_rss_hash_key_rss_type,
2464 (void *)&cmd_config_rss_hash_key_value,
2469 /* *** cleanup txq mbufs *** */
2470 struct cmd_cleanup_txq_mbufs_result {
2471 cmdline_fixed_string_t port;
2472 cmdline_fixed_string_t keyword;
2473 cmdline_fixed_string_t name;
2480 cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2481 __rte_unused struct cmdline *cl,
2482 __rte_unused void *data)
2484 struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2485 uint16_t port_id = res->port_id;
2486 uint16_t queue_id = res->queue_id;
2487 uint32_t free_cnt = res->free_cnt;
2488 struct rte_eth_txq_info qinfo;
2491 if (test_done == 0) {
2492 fprintf(stderr, "Please stop forwarding first\n");
2496 if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2497 fprintf(stderr, "Failed to get port %u Tx queue %u info\n",
2502 if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2503 fprintf(stderr, "Tx queue %u not started\n", queue_id);
2507 ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2510 "Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n",
2511 port_id, queue_id, strerror(-ret), ret);
2515 printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2516 port_id, queue_id, ret);
2519 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2520 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2522 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2523 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2525 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2526 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2528 cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2529 TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2531 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2532 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2534 cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2535 TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2538 cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2539 .f = cmd_cleanup_txq_mbufs_parsed,
2541 .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2543 (void *)&cmd_cleanup_txq_mbufs_port,
2544 (void *)&cmd_cleanup_txq_mbufs_cleanup,
2545 (void *)&cmd_cleanup_txq_mbufs_port_id,
2546 (void *)&cmd_cleanup_txq_mbufs_txq,
2547 (void *)&cmd_cleanup_txq_mbufs_queue_id,
2548 (void *)&cmd_cleanup_txq_mbufs_free_cnt,
2553 /* *** configure port rxq/txq ring size *** */
2554 struct cmd_config_rxtx_ring_size {
2555 cmdline_fixed_string_t port;
2556 cmdline_fixed_string_t config;
2558 cmdline_fixed_string_t rxtxq;
2560 cmdline_fixed_string_t rsize;
2565 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2566 __rte_unused struct cmdline *cl,
2567 __rte_unused void *data)
2569 struct cmd_config_rxtx_ring_size *res = parsed_result;
2570 struct rte_port *port;
2573 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2576 if (res->portid == (portid_t)RTE_PORT_ALL) {
2577 fprintf(stderr, "Invalid port id\n");
2581 port = &ports[res->portid];
2583 if (!strcmp(res->rxtxq, "rxq"))
2585 else if (!strcmp(res->rxtxq, "txq"))
2588 fprintf(stderr, "Unknown parameter\n");
2592 if (isrx && rx_queue_id_is_invalid(res->qid))
2594 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2597 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2599 "Invalid rx ring_size, must > rx_free_thresh: %d\n",
2605 port->nb_rx_desc[res->qid] = res->size;
2607 port->nb_tx_desc[res->qid] = res->size;
2609 cmd_reconfig_device_queue(res->portid, 0, 1);
2612 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2613 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2615 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2616 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2618 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2619 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2620 portid, RTE_UINT16);
2621 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2622 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2624 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2625 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2627 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2628 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2629 rsize, "ring_size");
2630 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2631 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2634 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2635 .f = cmd_config_rxtx_ring_size_parsed,
2637 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2639 (void *)&cmd_config_rxtx_ring_size_port,
2640 (void *)&cmd_config_rxtx_ring_size_config,
2641 (void *)&cmd_config_rxtx_ring_size_portid,
2642 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2643 (void *)&cmd_config_rxtx_ring_size_qid,
2644 (void *)&cmd_config_rxtx_ring_size_rsize,
2645 (void *)&cmd_config_rxtx_ring_size_size,
2650 /* *** configure port rxq/txq start/stop *** */
2651 struct cmd_config_rxtx_queue {
2652 cmdline_fixed_string_t port;
2654 cmdline_fixed_string_t rxtxq;
2656 cmdline_fixed_string_t opname;
2660 cmd_config_rxtx_queue_parsed(void *parsed_result,
2661 __rte_unused struct cmdline *cl,
2662 __rte_unused void *data)
2664 struct cmd_config_rxtx_queue *res = parsed_result;
2669 if (test_done == 0) {
2670 fprintf(stderr, "Please stop forwarding first\n");
2674 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2677 if (port_is_started(res->portid) != 1) {
2678 fprintf(stderr, "Please start port %u first\n", res->portid);
2682 if (!strcmp(res->rxtxq, "rxq"))
2684 else if (!strcmp(res->rxtxq, "txq"))
2687 fprintf(stderr, "Unknown parameter\n");
2691 if (isrx && rx_queue_id_is_invalid(res->qid))
2693 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2696 if (!strcmp(res->opname, "start"))
2698 else if (!strcmp(res->opname, "stop"))
2701 fprintf(stderr, "Unknown parameter\n");
2705 if (isstart && isrx)
2706 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2707 else if (!isstart && isrx)
2708 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2709 else if (isstart && !isrx)
2710 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2712 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2714 if (ret == -ENOTSUP)
2715 fprintf(stderr, "Function not supported in PMD driver\n");
2718 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2719 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2720 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2721 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2722 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2723 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2724 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2725 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2726 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2727 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2730 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2731 .f = cmd_config_rxtx_queue_parsed,
2733 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2735 (void *)&cmd_config_rxtx_queue_port,
2736 (void *)&cmd_config_rxtx_queue_portid,
2737 (void *)&cmd_config_rxtx_queue_rxtxq,
2738 (void *)&cmd_config_rxtx_queue_qid,
2739 (void *)&cmd_config_rxtx_queue_opname,
2744 /* *** configure port rxq/txq deferred start on/off *** */
2745 struct cmd_config_deferred_start_rxtx_queue {
2746 cmdline_fixed_string_t port;
2748 cmdline_fixed_string_t rxtxq;
2750 cmdline_fixed_string_t opname;
2751 cmdline_fixed_string_t state;
2755 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2756 __rte_unused struct cmdline *cl,
2757 __rte_unused void *data)
2759 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2760 struct rte_port *port;
2763 uint8_t needreconfig = 0;
2765 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2768 if (port_is_started(res->port_id) != 0) {
2769 fprintf(stderr, "Please stop port %u first\n", res->port_id);
2773 port = &ports[res->port_id];
2775 isrx = !strcmp(res->rxtxq, "rxq");
2777 if (isrx && rx_queue_id_is_invalid(res->qid))
2779 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2782 ison = !strcmp(res->state, "on");
2784 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) {
2785 port->rx_conf[res->qid].rx_deferred_start = ison;
2787 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) {
2788 port->tx_conf[res->qid].tx_deferred_start = ison;
2793 cmd_reconfig_device_queue(res->port_id, 0, 1);
2796 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2797 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2799 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2800 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2801 port_id, RTE_UINT16);
2802 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2803 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2805 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2806 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2808 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2809 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2810 opname, "deferred_start");
2811 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2812 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2815 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2816 .f = cmd_config_deferred_start_rxtx_queue_parsed,
2818 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2820 (void *)&cmd_config_deferred_start_rxtx_queue_port,
2821 (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2822 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2823 (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2824 (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2825 (void *)&cmd_config_deferred_start_rxtx_queue_state,
2830 /* *** configure port rxq/txq setup *** */
2831 struct cmd_setup_rxtx_queue {
2832 cmdline_fixed_string_t port;
2834 cmdline_fixed_string_t rxtxq;
2836 cmdline_fixed_string_t setup;
2839 /* Common CLI fields for queue setup */
2840 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2841 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2842 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2843 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2844 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2845 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2846 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2847 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2848 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2849 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2852 cmd_setup_rxtx_queue_parsed(
2853 void *parsed_result,
2854 __rte_unused struct cmdline *cl,
2855 __rte_unused void *data)
2857 struct cmd_setup_rxtx_queue *res = parsed_result;
2858 struct rte_port *port;
2859 struct rte_mempool *mp;
2860 unsigned int socket_id;
2864 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2867 if (res->portid == (portid_t)RTE_PORT_ALL) {
2868 fprintf(stderr, "Invalid port id\n");
2872 if (!strcmp(res->rxtxq, "rxq"))
2874 else if (!strcmp(res->rxtxq, "txq"))
2877 fprintf(stderr, "Unknown parameter\n");
2881 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2882 fprintf(stderr, "Invalid rx queue\n");
2884 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2885 fprintf(stderr, "Invalid tx queue\n");
2889 port = &ports[res->portid];
2891 socket_id = rxring_numa[res->portid];
2892 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2893 socket_id = port->socket_id;
2895 mp = mbuf_pool_find(socket_id, 0);
2898 "Failed to setup RX queue: No mempool allocation on the socket %d\n",
2899 rxring_numa[res->portid]);
2902 ret = rx_queue_setup(res->portid,
2904 port->nb_rx_desc[res->qid],
2906 &port->rx_conf[res->qid],
2909 fprintf(stderr, "Failed to setup RX queue\n");
2911 socket_id = txring_numa[res->portid];
2912 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2913 socket_id = port->socket_id;
2915 if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
2917 "Failed to setup TX queue: not enough descriptors\n");
2920 ret = rte_eth_tx_queue_setup(res->portid,
2922 port->nb_tx_desc[res->qid],
2924 &port->tx_conf[res->qid]);
2926 fprintf(stderr, "Failed to setup TX queue\n");
2930 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2931 .f = cmd_setup_rxtx_queue_parsed,
2933 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2935 (void *)&cmd_setup_rxtx_queue_port,
2936 (void *)&cmd_setup_rxtx_queue_portid,
2937 (void *)&cmd_setup_rxtx_queue_rxtxq,
2938 (void *)&cmd_setup_rxtx_queue_qid,
2939 (void *)&cmd_setup_rxtx_queue_setup,
2945 /* *** Configure RSS RETA *** */
2946 struct cmd_config_rss_reta {
2947 cmdline_fixed_string_t port;
2948 cmdline_fixed_string_t keyword;
2950 cmdline_fixed_string_t name;
2951 cmdline_fixed_string_t list_name;
2952 cmdline_fixed_string_t list_of_items;
2956 parse_reta_config(const char *str,
2957 struct rte_eth_rss_reta_entry64 *reta_conf,
2958 uint16_t nb_entries)
2962 uint16_t hash_index, idx, shift;
2965 const char *p, *p0 = str;
2972 unsigned long int_fld[_NUM_FLD];
2973 char *str_fld[_NUM_FLD];
2975 while ((p = strchr(p0,'(')) != NULL) {
2977 if((p0 = strchr(p,')')) == NULL)
2981 if(size >= sizeof(s))
2984 snprintf(s, sizeof(s), "%.*s", size, p);
2985 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2987 for (i = 0; i < _NUM_FLD; i++) {
2989 int_fld[i] = strtoul(str_fld[i], &end, 0);
2990 if (errno != 0 || end == str_fld[i] ||
2995 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2996 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2998 if (hash_index >= nb_entries) {
2999 fprintf(stderr, "Invalid RETA hash index=%d\n",
3004 idx = hash_index / RTE_RETA_GROUP_SIZE;
3005 shift = hash_index % RTE_RETA_GROUP_SIZE;
3006 reta_conf[idx].mask |= (1ULL << shift);
3007 reta_conf[idx].reta[shift] = nb_queue;
3014 cmd_set_rss_reta_parsed(void *parsed_result,
3015 __rte_unused struct cmdline *cl,
3016 __rte_unused void *data)
3019 struct rte_eth_dev_info dev_info;
3020 struct rte_eth_rss_reta_entry64 reta_conf[8];
3021 struct cmd_config_rss_reta *res = parsed_result;
3023 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3027 if (dev_info.reta_size == 0) {
3029 "Redirection table size is 0 which is invalid for RSS\n");
3032 printf("The reta size of port %d is %u\n",
3033 res->port_id, dev_info.reta_size);
3034 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
3036 "Currently do not support more than %u entries of redirection table\n",
3037 ETH_RSS_RETA_SIZE_512);
3041 memset(reta_conf, 0, sizeof(reta_conf));
3042 if (!strcmp(res->list_name, "reta")) {
3043 if (parse_reta_config(res->list_of_items, reta_conf,
3044 dev_info.reta_size)) {
3046 "Invalid RSS Redirection Table config entered\n");
3049 ret = rte_eth_dev_rss_reta_update(res->port_id,
3050 reta_conf, dev_info.reta_size);
3053 "Bad redirection table parameter, return code = %d\n",
3058 cmdline_parse_token_string_t cmd_config_rss_reta_port =
3059 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3060 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3061 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3062 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3063 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3064 cmdline_parse_token_string_t cmd_config_rss_reta_name =
3065 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3066 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3067 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3068 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3069 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3071 cmdline_parse_inst_t cmd_config_rss_reta = {
3072 .f = cmd_set_rss_reta_parsed,
3074 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3076 (void *)&cmd_config_rss_reta_port,
3077 (void *)&cmd_config_rss_reta_keyword,
3078 (void *)&cmd_config_rss_reta_port_id,
3079 (void *)&cmd_config_rss_reta_name,
3080 (void *)&cmd_config_rss_reta_list_name,
3081 (void *)&cmd_config_rss_reta_list_of_items,
3086 /* *** SHOW PORT RETA INFO *** */
3087 struct cmd_showport_reta {
3088 cmdline_fixed_string_t show;
3089 cmdline_fixed_string_t port;
3091 cmdline_fixed_string_t rss;
3092 cmdline_fixed_string_t reta;
3094 cmdline_fixed_string_t list_of_items;
3098 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3099 uint16_t nb_entries,
3103 const char *p, *p0 = str;
3108 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
3109 RTE_RETA_GROUP_SIZE;
3112 p = strchr(p0, '(');
3116 p0 = strchr(p, ')');
3120 if (size >= sizeof(s)) {
3122 "The string size exceeds the internal buffer size\n");
3125 snprintf(s, sizeof(s), "%.*s", size, p);
3126 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3127 if (ret <= 0 || ret != num) {
3129 "The bits of masks do not match the number of reta entries: %u\n",
3133 for (i = 0; i < ret; i++)
3134 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
3140 cmd_showport_reta_parsed(void *parsed_result,
3141 __rte_unused struct cmdline *cl,
3142 __rte_unused void *data)
3144 struct cmd_showport_reta *res = parsed_result;
3145 struct rte_eth_rss_reta_entry64 reta_conf[8];
3146 struct rte_eth_dev_info dev_info;
3147 uint16_t max_reta_size;
3150 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3154 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
3155 if (res->size == 0 || res->size > max_reta_size) {
3156 fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n",
3157 res->size, max_reta_size);
3161 memset(reta_conf, 0, sizeof(reta_conf));
3162 if (showport_parse_reta_config(reta_conf, res->size,
3163 res->list_of_items) < 0) {
3164 fprintf(stderr, "Invalid string: %s for reta masks\n",
3165 res->list_of_items);
3168 port_rss_reta_info(res->port_id, reta_conf, res->size);
3171 cmdline_parse_token_string_t cmd_showport_reta_show =
3172 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3173 cmdline_parse_token_string_t cmd_showport_reta_port =
3174 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3175 cmdline_parse_token_num_t cmd_showport_reta_port_id =
3176 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3177 cmdline_parse_token_string_t cmd_showport_reta_rss =
3178 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3179 cmdline_parse_token_string_t cmd_showport_reta_reta =
3180 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3181 cmdline_parse_token_num_t cmd_showport_reta_size =
3182 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3183 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3184 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3185 list_of_items, NULL);
3187 cmdline_parse_inst_t cmd_showport_reta = {
3188 .f = cmd_showport_reta_parsed,
3190 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3192 (void *)&cmd_showport_reta_show,
3193 (void *)&cmd_showport_reta_port,
3194 (void *)&cmd_showport_reta_port_id,
3195 (void *)&cmd_showport_reta_rss,
3196 (void *)&cmd_showport_reta_reta,
3197 (void *)&cmd_showport_reta_size,
3198 (void *)&cmd_showport_reta_list_of_items,
3203 /* *** Show RSS hash configuration *** */
3204 struct cmd_showport_rss_hash {
3205 cmdline_fixed_string_t show;
3206 cmdline_fixed_string_t port;
3208 cmdline_fixed_string_t rss_hash;
3209 cmdline_fixed_string_t rss_type;
3210 cmdline_fixed_string_t key; /* optional argument */
3213 static void cmd_showport_rss_hash_parsed(void *parsed_result,
3214 __rte_unused struct cmdline *cl,
3217 struct cmd_showport_rss_hash *res = parsed_result;
3219 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL);
3222 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3223 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3224 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3225 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3226 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3227 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3229 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3230 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3232 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3233 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3235 cmdline_parse_inst_t cmd_showport_rss_hash = {
3236 .f = cmd_showport_rss_hash_parsed,
3238 .help_str = "show port <port_id> rss-hash",
3240 (void *)&cmd_showport_rss_hash_show,
3241 (void *)&cmd_showport_rss_hash_port,
3242 (void *)&cmd_showport_rss_hash_port_id,
3243 (void *)&cmd_showport_rss_hash_rss_hash,
3248 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3249 .f = cmd_showport_rss_hash_parsed,
3251 .help_str = "show port <port_id> rss-hash key",
3253 (void *)&cmd_showport_rss_hash_show,
3254 (void *)&cmd_showport_rss_hash_port,
3255 (void *)&cmd_showport_rss_hash_port_id,
3256 (void *)&cmd_showport_rss_hash_rss_hash,
3257 (void *)&cmd_showport_rss_hash_rss_key,
3262 /* *** Configure DCB *** */
3263 struct cmd_config_dcb {
3264 cmdline_fixed_string_t port;
3265 cmdline_fixed_string_t config;
3267 cmdline_fixed_string_t dcb;
3268 cmdline_fixed_string_t vt;
3269 cmdline_fixed_string_t vt_en;
3271 cmdline_fixed_string_t pfc;
3272 cmdline_fixed_string_t pfc_en;
3276 cmd_config_dcb_parsed(void *parsed_result,
3277 __rte_unused struct cmdline *cl,
3278 __rte_unused void *data)
3280 struct cmd_config_dcb *res = parsed_result;
3281 struct rte_eth_dcb_info dcb_info;
3282 portid_t port_id = res->port_id;
3283 struct rte_port *port;
3287 port = &ports[port_id];
3288 /** Check if the port is not started **/
3289 if (port->port_status != RTE_PORT_STOPPED) {
3290 fprintf(stderr, "Please stop port %d first\n", port_id);
3294 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
3296 "The invalid number of traffic class, only 4 or 8 allowed.\n");
3300 if (nb_fwd_lcores < res->num_tcs) {
3302 "nb_cores shouldn't be less than number of TCs.\n");
3306 /* Check whether the port supports the report of DCB info. */
3307 ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3308 if (ret == -ENOTSUP) {
3309 fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n");
3313 if (!strncmp(res->pfc_en, "on", 2))
3318 /* DCB in VT mode */
3319 if (!strncmp(res->vt_en, "on", 2))
3320 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3321 (enum rte_eth_nb_tcs)res->num_tcs,
3324 ret = init_port_dcb_config(port_id, DCB_ENABLED,
3325 (enum rte_eth_nb_tcs)res->num_tcs,
3328 fprintf(stderr, "Cannot initialize network ports.\n");
3334 cmd_reconfig_device_queue(port_id, 1, 1);
3337 cmdline_parse_token_string_t cmd_config_dcb_port =
3338 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3339 cmdline_parse_token_string_t cmd_config_dcb_config =
3340 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3341 cmdline_parse_token_num_t cmd_config_dcb_port_id =
3342 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3343 cmdline_parse_token_string_t cmd_config_dcb_dcb =
3344 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3345 cmdline_parse_token_string_t cmd_config_dcb_vt =
3346 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3347 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3348 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3349 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3350 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3351 cmdline_parse_token_string_t cmd_config_dcb_pfc=
3352 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3353 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3354 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3356 cmdline_parse_inst_t cmd_config_dcb = {
3357 .f = cmd_config_dcb_parsed,
3359 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3361 (void *)&cmd_config_dcb_port,
3362 (void *)&cmd_config_dcb_config,
3363 (void *)&cmd_config_dcb_port_id,
3364 (void *)&cmd_config_dcb_dcb,
3365 (void *)&cmd_config_dcb_vt,
3366 (void *)&cmd_config_dcb_vt_en,
3367 (void *)&cmd_config_dcb_num_tcs,
3368 (void *)&cmd_config_dcb_pfc,
3369 (void *)&cmd_config_dcb_pfc_en,
3374 /* *** configure number of packets per burst *** */
3375 struct cmd_config_burst {
3376 cmdline_fixed_string_t port;
3377 cmdline_fixed_string_t keyword;
3378 cmdline_fixed_string_t all;
3379 cmdline_fixed_string_t name;
3384 cmd_config_burst_parsed(void *parsed_result,
3385 __rte_unused struct cmdline *cl,
3386 __rte_unused void *data)
3388 struct cmd_config_burst *res = parsed_result;
3389 struct rte_eth_dev_info dev_info;
3390 uint16_t rec_nb_pkts;
3393 if (!all_ports_stopped()) {
3394 fprintf(stderr, "Please stop all ports first\n");
3398 if (!strcmp(res->name, "burst")) {
3399 if (res->value == 0) {
3400 /* If user gives a value of zero, query the PMD for
3401 * its recommended Rx burst size. Testpmd uses a single
3402 * size for all ports, so assume all ports are the same
3403 * NIC model and use the values from Port 0.
3405 ret = eth_dev_info_get_print_err(0, &dev_info);
3409 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3411 if (rec_nb_pkts == 0) {
3412 printf("PMD does not recommend a burst size.\n"
3413 "User provided value must be between"
3414 " 1 and %d\n", MAX_PKT_BURST);
3416 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3417 printf("PMD recommended burst size of %d"
3418 " exceeds maximum value of %d\n",
3419 rec_nb_pkts, MAX_PKT_BURST);
3422 printf("Using PMD-provided burst value of %d\n",
3424 nb_pkt_per_burst = rec_nb_pkts;
3425 } else if (res->value > MAX_PKT_BURST) {
3426 fprintf(stderr, "burst must be >= 1 && <= %d\n",
3430 nb_pkt_per_burst = res->value;
3432 fprintf(stderr, "Unknown parameter\n");
3438 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3441 cmdline_parse_token_string_t cmd_config_burst_port =
3442 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3443 cmdline_parse_token_string_t cmd_config_burst_keyword =
3444 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3445 cmdline_parse_token_string_t cmd_config_burst_all =
3446 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3447 cmdline_parse_token_string_t cmd_config_burst_name =
3448 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3449 cmdline_parse_token_num_t cmd_config_burst_value =
3450 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3452 cmdline_parse_inst_t cmd_config_burst = {
3453 .f = cmd_config_burst_parsed,
3455 .help_str = "port config all burst <value>",
3457 (void *)&cmd_config_burst_port,
3458 (void *)&cmd_config_burst_keyword,
3459 (void *)&cmd_config_burst_all,
3460 (void *)&cmd_config_burst_name,
3461 (void *)&cmd_config_burst_value,
3466 /* *** configure rx/tx queues *** */
3467 struct cmd_config_thresh {
3468 cmdline_fixed_string_t port;
3469 cmdline_fixed_string_t keyword;
3470 cmdline_fixed_string_t all;
3471 cmdline_fixed_string_t name;
3476 cmd_config_thresh_parsed(void *parsed_result,
3477 __rte_unused struct cmdline *cl,
3478 __rte_unused void *data)
3480 struct cmd_config_thresh *res = parsed_result;
3482 if (!all_ports_stopped()) {
3483 fprintf(stderr, "Please stop all ports first\n");
3487 if (!strcmp(res->name, "txpt"))
3488 tx_pthresh = res->value;
3489 else if(!strcmp(res->name, "txht"))
3490 tx_hthresh = res->value;
3491 else if(!strcmp(res->name, "txwt"))
3492 tx_wthresh = res->value;
3493 else if(!strcmp(res->name, "rxpt"))
3494 rx_pthresh = res->value;
3495 else if(!strcmp(res->name, "rxht"))
3496 rx_hthresh = res->value;
3497 else if(!strcmp(res->name, "rxwt"))
3498 rx_wthresh = res->value;
3500 fprintf(stderr, "Unknown parameter\n");
3506 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3509 cmdline_parse_token_string_t cmd_config_thresh_port =
3510 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3511 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3512 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3513 cmdline_parse_token_string_t cmd_config_thresh_all =
3514 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3515 cmdline_parse_token_string_t cmd_config_thresh_name =
3516 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3517 "txpt#txht#txwt#rxpt#rxht#rxwt");
3518 cmdline_parse_token_num_t cmd_config_thresh_value =
3519 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3521 cmdline_parse_inst_t cmd_config_thresh = {
3522 .f = cmd_config_thresh_parsed,
3524 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3526 (void *)&cmd_config_thresh_port,
3527 (void *)&cmd_config_thresh_keyword,
3528 (void *)&cmd_config_thresh_all,
3529 (void *)&cmd_config_thresh_name,
3530 (void *)&cmd_config_thresh_value,
3535 /* *** configure free/rs threshold *** */
3536 struct cmd_config_threshold {
3537 cmdline_fixed_string_t port;
3538 cmdline_fixed_string_t keyword;
3539 cmdline_fixed_string_t all;
3540 cmdline_fixed_string_t name;
3545 cmd_config_threshold_parsed(void *parsed_result,
3546 __rte_unused struct cmdline *cl,
3547 __rte_unused void *data)
3549 struct cmd_config_threshold *res = parsed_result;
3551 if (!all_ports_stopped()) {
3552 fprintf(stderr, "Please stop all ports first\n");
3556 if (!strcmp(res->name, "txfreet"))
3557 tx_free_thresh = res->value;
3558 else if (!strcmp(res->name, "txrst"))
3559 tx_rs_thresh = res->value;
3560 else if (!strcmp(res->name, "rxfreet"))
3561 rx_free_thresh = res->value;
3563 fprintf(stderr, "Unknown parameter\n");
3569 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3572 cmdline_parse_token_string_t cmd_config_threshold_port =
3573 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3574 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3575 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3577 cmdline_parse_token_string_t cmd_config_threshold_all =
3578 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3579 cmdline_parse_token_string_t cmd_config_threshold_name =
3580 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3581 "txfreet#txrst#rxfreet");
3582 cmdline_parse_token_num_t cmd_config_threshold_value =
3583 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3585 cmdline_parse_inst_t cmd_config_threshold = {
3586 .f = cmd_config_threshold_parsed,
3588 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3590 (void *)&cmd_config_threshold_port,
3591 (void *)&cmd_config_threshold_keyword,
3592 (void *)&cmd_config_threshold_all,
3593 (void *)&cmd_config_threshold_name,
3594 (void *)&cmd_config_threshold_value,
3600 struct cmd_stop_result {
3601 cmdline_fixed_string_t stop;
3604 static void cmd_stop_parsed(__rte_unused void *parsed_result,
3605 __rte_unused struct cmdline *cl,
3606 __rte_unused void *data)
3608 stop_packet_forwarding();
3611 cmdline_parse_token_string_t cmd_stop_stop =
3612 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3614 cmdline_parse_inst_t cmd_stop = {
3615 .f = cmd_stop_parsed,
3617 .help_str = "stop: Stop packet forwarding",
3619 (void *)&cmd_stop_stop,
3624 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3627 parse_item_list(const char *str, const char *item_name, unsigned int max_items,
3628 unsigned int *parsed_items, int check_unique_values)
3630 unsigned int nb_item;
3638 * First parse all items in the list and store their value.
3643 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3645 if ((c >= '0') && (c <= '9')) {
3646 value = (unsigned int) (value * 10 + (c - '0'));
3651 fprintf(stderr, "character %c is not a decimal digit\n", c);
3655 fprintf(stderr, "No valid value before comma\n");
3658 if (nb_item < max_items) {
3659 parsed_items[nb_item] = value;
3665 if (nb_item >= max_items) {
3666 fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
3667 item_name, nb_item + 1, max_items);
3670 parsed_items[nb_item++] = value;
3671 if (! check_unique_values)
3675 * Then, check that all values in the list are differents.
3676 * No optimization here...
3678 for (i = 0; i < nb_item; i++) {
3679 for (j = i + 1; j < nb_item; j++) {
3680 if (parsed_items[j] == parsed_items[i]) {
3682 "duplicated %s %u at index %u and %u\n",
3683 item_name, parsed_items[i], i, j);
3691 struct cmd_set_list_result {
3692 cmdline_fixed_string_t cmd_keyword;
3693 cmdline_fixed_string_t list_name;
3694 cmdline_fixed_string_t list_of_items;
3697 static void cmd_set_list_parsed(void *parsed_result,
3698 __rte_unused struct cmdline *cl,
3699 __rte_unused void *data)
3701 struct cmd_set_list_result *res;
3703 unsigned int lcorelist[RTE_MAX_LCORE];
3704 unsigned int portlist[RTE_MAX_ETHPORTS];
3706 unsigned int nb_item;
3708 if (test_done == 0) {
3709 fprintf(stderr, "Please stop forwarding first\n");
3713 res = parsed_result;
3714 if (!strcmp(res->list_name, "corelist")) {
3715 nb_item = parse_item_list(res->list_of_items, "core",
3717 parsed_items.lcorelist, 1);
3719 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3724 if (!strcmp(res->list_name, "portlist")) {
3725 nb_item = parse_item_list(res->list_of_items, "port",
3727 parsed_items.portlist, 1);
3729 set_fwd_ports_list(parsed_items.portlist, nb_item);
3735 cmdline_parse_token_string_t cmd_set_list_keyword =
3736 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3738 cmdline_parse_token_string_t cmd_set_list_name =
3739 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3740 "corelist#portlist");
3741 cmdline_parse_token_string_t cmd_set_list_of_items =
3742 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3745 cmdline_parse_inst_t cmd_set_fwd_list = {
3746 .f = cmd_set_list_parsed,
3748 .help_str = "set corelist|portlist <list0[,list1]*>",
3750 (void *)&cmd_set_list_keyword,
3751 (void *)&cmd_set_list_name,
3752 (void *)&cmd_set_list_of_items,
3757 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3759 struct cmd_setmask_result {
3760 cmdline_fixed_string_t set;
3761 cmdline_fixed_string_t mask;
3765 static void cmd_set_mask_parsed(void *parsed_result,
3766 __rte_unused struct cmdline *cl,
3767 __rte_unused void *data)
3769 struct cmd_setmask_result *res = parsed_result;
3771 if (test_done == 0) {
3772 fprintf(stderr, "Please stop forwarding first\n");
3775 if (!strcmp(res->mask, "coremask")) {
3776 set_fwd_lcores_mask(res->hexavalue);
3778 } else if (!strcmp(res->mask, "portmask")) {
3779 set_fwd_ports_mask(res->hexavalue);
3784 cmdline_parse_token_string_t cmd_setmask_set =
3785 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3786 cmdline_parse_token_string_t cmd_setmask_mask =
3787 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3788 "coremask#portmask");
3789 cmdline_parse_token_num_t cmd_setmask_value =
3790 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3792 cmdline_parse_inst_t cmd_set_fwd_mask = {
3793 .f = cmd_set_mask_parsed,
3795 .help_str = "set coremask|portmask <hexadecimal value>",
3797 (void *)&cmd_setmask_set,
3798 (void *)&cmd_setmask_mask,
3799 (void *)&cmd_setmask_value,
3805 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3807 struct cmd_set_result {
3808 cmdline_fixed_string_t set;
3809 cmdline_fixed_string_t what;
3813 static void cmd_set_parsed(void *parsed_result,
3814 __rte_unused struct cmdline *cl,
3815 __rte_unused void *data)
3817 struct cmd_set_result *res = parsed_result;
3818 if (!strcmp(res->what, "nbport")) {
3819 set_fwd_ports_number(res->value);
3821 } else if (!strcmp(res->what, "nbcore")) {
3822 set_fwd_lcores_number(res->value);
3824 } else if (!strcmp(res->what, "burst"))
3825 set_nb_pkt_per_burst(res->value);
3826 else if (!strcmp(res->what, "verbose"))
3827 set_verbose_level(res->value);
3830 cmdline_parse_token_string_t cmd_set_set =
3831 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3832 cmdline_parse_token_string_t cmd_set_what =
3833 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3834 "nbport#nbcore#burst#verbose");
3835 cmdline_parse_token_num_t cmd_set_value =
3836 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3838 cmdline_parse_inst_t cmd_set_numbers = {
3839 .f = cmd_set_parsed,
3841 .help_str = "set nbport|nbcore|burst|verbose <value>",
3843 (void *)&cmd_set_set,
3844 (void *)&cmd_set_what,
3845 (void *)&cmd_set_value,
3850 /* *** SET LOG LEVEL CONFIGURATION *** */
3852 struct cmd_set_log_result {
3853 cmdline_fixed_string_t set;
3854 cmdline_fixed_string_t log;
3855 cmdline_fixed_string_t type;
3860 cmd_set_log_parsed(void *parsed_result,
3861 __rte_unused struct cmdline *cl,
3862 __rte_unused void *data)
3864 struct cmd_set_log_result *res;
3867 res = parsed_result;
3868 if (!strcmp(res->type, "global"))
3869 rte_log_set_global_level(res->level);
3871 ret = rte_log_set_level_regexp(res->type, res->level);
3873 fprintf(stderr, "Unable to set log level\n");
3877 cmdline_parse_token_string_t cmd_set_log_set =
3878 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3879 cmdline_parse_token_string_t cmd_set_log_log =
3880 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3881 cmdline_parse_token_string_t cmd_set_log_type =
3882 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3883 cmdline_parse_token_num_t cmd_set_log_level =
3884 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3886 cmdline_parse_inst_t cmd_set_log = {
3887 .f = cmd_set_log_parsed,
3889 .help_str = "set log global|<type> <level>",
3891 (void *)&cmd_set_log_set,
3892 (void *)&cmd_set_log_log,
3893 (void *)&cmd_set_log_type,
3894 (void *)&cmd_set_log_level,
3899 /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3901 struct cmd_set_rxoffs_result {
3902 cmdline_fixed_string_t cmd_keyword;
3903 cmdline_fixed_string_t rxoffs;
3904 cmdline_fixed_string_t seg_offsets;
3908 cmd_set_rxoffs_parsed(void *parsed_result,
3909 __rte_unused struct cmdline *cl,
3910 __rte_unused void *data)
3912 struct cmd_set_rxoffs_result *res;
3913 unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3914 unsigned int nb_segs;
3916 res = parsed_result;
3917 nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3918 MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3920 set_rx_pkt_offsets(seg_offsets, nb_segs);
3921 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3924 cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3925 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3926 cmd_keyword, "set");
3927 cmdline_parse_token_string_t cmd_set_rxoffs_name =
3928 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3930 cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3931 TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3934 cmdline_parse_inst_t cmd_set_rxoffs = {
3935 .f = cmd_set_rxoffs_parsed,
3937 .help_str = "set rxoffs <len0[,len1]*>",
3939 (void *)&cmd_set_rxoffs_keyword,
3940 (void *)&cmd_set_rxoffs_name,
3941 (void *)&cmd_set_rxoffs_offsets,
3946 /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3948 struct cmd_set_rxpkts_result {
3949 cmdline_fixed_string_t cmd_keyword;
3950 cmdline_fixed_string_t rxpkts;
3951 cmdline_fixed_string_t seg_lengths;
3955 cmd_set_rxpkts_parsed(void *parsed_result,
3956 __rte_unused struct cmdline *cl,
3957 __rte_unused void *data)
3959 struct cmd_set_rxpkts_result *res;
3960 unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3961 unsigned int nb_segs;
3963 res = parsed_result;
3964 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3965 MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3967 set_rx_pkt_segments(seg_lengths, nb_segs);
3968 cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3971 cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3972 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3973 cmd_keyword, "set");
3974 cmdline_parse_token_string_t cmd_set_rxpkts_name =
3975 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3977 cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3978 TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3981 cmdline_parse_inst_t cmd_set_rxpkts = {
3982 .f = cmd_set_rxpkts_parsed,
3984 .help_str = "set rxpkts <len0[,len1]*>",
3986 (void *)&cmd_set_rxpkts_keyword,
3987 (void *)&cmd_set_rxpkts_name,
3988 (void *)&cmd_set_rxpkts_lengths,
3993 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3995 struct cmd_set_txpkts_result {
3996 cmdline_fixed_string_t cmd_keyword;
3997 cmdline_fixed_string_t txpkts;
3998 cmdline_fixed_string_t seg_lengths;
4002 cmd_set_txpkts_parsed(void *parsed_result,
4003 __rte_unused struct cmdline *cl,
4004 __rte_unused void *data)
4006 struct cmd_set_txpkts_result *res;
4007 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
4008 unsigned int nb_segs;
4010 res = parsed_result;
4011 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4012 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4014 set_tx_pkt_segments(seg_lengths, nb_segs);
4017 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4018 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4019 cmd_keyword, "set");
4020 cmdline_parse_token_string_t cmd_set_txpkts_name =
4021 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4023 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4024 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4027 cmdline_parse_inst_t cmd_set_txpkts = {
4028 .f = cmd_set_txpkts_parsed,
4030 .help_str = "set txpkts <len0[,len1]*>",
4032 (void *)&cmd_set_txpkts_keyword,
4033 (void *)&cmd_set_txpkts_name,
4034 (void *)&cmd_set_txpkts_lengths,
4039 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4041 struct cmd_set_txsplit_result {
4042 cmdline_fixed_string_t cmd_keyword;
4043 cmdline_fixed_string_t txsplit;
4044 cmdline_fixed_string_t mode;
4048 cmd_set_txsplit_parsed(void *parsed_result,
4049 __rte_unused struct cmdline *cl,
4050 __rte_unused void *data)
4052 struct cmd_set_txsplit_result *res;
4054 res = parsed_result;
4055 set_tx_pkt_split(res->mode);
4058 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4059 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4060 cmd_keyword, "set");
4061 cmdline_parse_token_string_t cmd_set_txsplit_name =
4062 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4063 txsplit, "txsplit");
4064 cmdline_parse_token_string_t cmd_set_txsplit_mode =
4065 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4068 cmdline_parse_inst_t cmd_set_txsplit = {
4069 .f = cmd_set_txsplit_parsed,
4071 .help_str = "set txsplit on|off|rand",
4073 (void *)&cmd_set_txsplit_keyword,
4074 (void *)&cmd_set_txsplit_name,
4075 (void *)&cmd_set_txsplit_mode,
4080 /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4082 struct cmd_set_txtimes_result {
4083 cmdline_fixed_string_t cmd_keyword;
4084 cmdline_fixed_string_t txtimes;
4085 cmdline_fixed_string_t tx_times;
4089 cmd_set_txtimes_parsed(void *parsed_result,
4090 __rte_unused struct cmdline *cl,
4091 __rte_unused void *data)
4093 struct cmd_set_txtimes_result *res;
4094 unsigned int tx_times[2] = {0, 0};
4095 unsigned int n_times;
4097 res = parsed_result;
4098 n_times = parse_item_list(res->tx_times, "tx times",
4101 set_tx_pkt_times(tx_times);
4104 cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4105 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4106 cmd_keyword, "set");
4107 cmdline_parse_token_string_t cmd_set_txtimes_name =
4108 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4109 txtimes, "txtimes");
4110 cmdline_parse_token_string_t cmd_set_txtimes_value =
4111 TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4114 cmdline_parse_inst_t cmd_set_txtimes = {
4115 .f = cmd_set_txtimes_parsed,
4117 .help_str = "set txtimes <inter_burst>,<intra_burst>",
4119 (void *)&cmd_set_txtimes_keyword,
4120 (void *)&cmd_set_txtimes_name,
4121 (void *)&cmd_set_txtimes_value,
4126 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4127 struct cmd_rx_vlan_filter_all_result {
4128 cmdline_fixed_string_t rx_vlan;
4129 cmdline_fixed_string_t what;
4130 cmdline_fixed_string_t all;
4135 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4136 __rte_unused struct cmdline *cl,
4137 __rte_unused void *data)
4139 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4141 if (!strcmp(res->what, "add"))
4142 rx_vlan_all_filter_set(res->port_id, 1);
4144 rx_vlan_all_filter_set(res->port_id, 0);
4147 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4148 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4149 rx_vlan, "rx_vlan");
4150 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4151 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4153 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4154 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4156 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4157 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4158 port_id, RTE_UINT16);
4160 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4161 .f = cmd_rx_vlan_filter_all_parsed,
4163 .help_str = "rx_vlan add|rm all <port_id>: "
4164 "Add/Remove all identifiers to/from the set of VLAN "
4165 "identifiers filtered by a port",
4167 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4168 (void *)&cmd_rx_vlan_filter_all_what,
4169 (void *)&cmd_rx_vlan_filter_all_all,
4170 (void *)&cmd_rx_vlan_filter_all_portid,
4175 /* *** VLAN OFFLOAD SET ON A PORT *** */
4176 struct cmd_vlan_offload_result {
4177 cmdline_fixed_string_t vlan;
4178 cmdline_fixed_string_t set;
4179 cmdline_fixed_string_t vlan_type;
4180 cmdline_fixed_string_t what;
4181 cmdline_fixed_string_t on;
4182 cmdline_fixed_string_t port_id;
4186 cmd_vlan_offload_parsed(void *parsed_result,
4187 __rte_unused struct cmdline *cl,
4188 __rte_unused void *data)
4191 struct cmd_vlan_offload_result *res = parsed_result;
4194 portid_t port_id = 0;
4198 len = strnlen(str, STR_TOKEN_SIZE);
4200 /* Get port_id first */
4208 tmp = strtoul(str, NULL, 0);
4209 /* If port_id greater that what portid_t can represent, return */
4210 if(tmp >= RTE_MAX_ETHPORTS)
4212 port_id = (portid_t)tmp;
4214 if (!strcmp(res->on, "on"))
4219 if (!strcmp(res->what, "strip"))
4220 rx_vlan_strip_set(port_id, on);
4221 else if(!strcmp(res->what, "stripq")){
4222 uint16_t queue_id = 0;
4224 /* No queue_id, return */
4226 fprintf(stderr, "must specify (port,queue_id)\n");
4229 tmp = strtoul(str + i + 1, NULL, 0);
4230 /* If queue_id greater that what 16-bits can represent, return */
4234 queue_id = (uint16_t)tmp;
4235 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4237 else if (!strcmp(res->what, "filter"))
4238 rx_vlan_filter_set(port_id, on);
4239 else if (!strcmp(res->what, "qinq_strip"))
4240 rx_vlan_qinq_strip_set(port_id, on);
4242 vlan_extend_set(port_id, on);
4247 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4248 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4250 cmdline_parse_token_string_t cmd_vlan_offload_set =
4251 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4253 cmdline_parse_token_string_t cmd_vlan_offload_what =
4254 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4255 what, "strip#filter#qinq_strip#extend#stripq");
4256 cmdline_parse_token_string_t cmd_vlan_offload_on =
4257 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4259 cmdline_parse_token_string_t cmd_vlan_offload_portid =
4260 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4263 cmdline_parse_inst_t cmd_vlan_offload = {
4264 .f = cmd_vlan_offload_parsed,
4266 .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4267 "<port_id[,queue_id]>: "
4268 "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4270 (void *)&cmd_vlan_offload_vlan,
4271 (void *)&cmd_vlan_offload_set,
4272 (void *)&cmd_vlan_offload_what,
4273 (void *)&cmd_vlan_offload_on,
4274 (void *)&cmd_vlan_offload_portid,
4279 /* *** VLAN TPID SET ON A PORT *** */
4280 struct cmd_vlan_tpid_result {
4281 cmdline_fixed_string_t vlan;
4282 cmdline_fixed_string_t set;
4283 cmdline_fixed_string_t vlan_type;
4284 cmdline_fixed_string_t what;
4290 cmd_vlan_tpid_parsed(void *parsed_result,
4291 __rte_unused struct cmdline *cl,
4292 __rte_unused void *data)
4294 struct cmd_vlan_tpid_result *res = parsed_result;
4295 enum rte_vlan_type vlan_type;
4297 if (!strcmp(res->vlan_type, "inner"))
4298 vlan_type = ETH_VLAN_TYPE_INNER;
4299 else if (!strcmp(res->vlan_type, "outer"))
4300 vlan_type = ETH_VLAN_TYPE_OUTER;
4302 fprintf(stderr, "Unknown vlan type\n");
4305 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4308 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4309 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4311 cmdline_parse_token_string_t cmd_vlan_tpid_set =
4312 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4314 cmdline_parse_token_string_t cmd_vlan_type =
4315 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4316 vlan_type, "inner#outer");
4317 cmdline_parse_token_string_t cmd_vlan_tpid_what =
4318 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4320 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4321 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4323 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4324 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4325 port_id, RTE_UINT16);
4327 cmdline_parse_inst_t cmd_vlan_tpid = {
4328 .f = cmd_vlan_tpid_parsed,
4330 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4331 "Set the VLAN Ether type",
4333 (void *)&cmd_vlan_tpid_vlan,
4334 (void *)&cmd_vlan_tpid_set,
4335 (void *)&cmd_vlan_type,
4336 (void *)&cmd_vlan_tpid_what,
4337 (void *)&cmd_vlan_tpid_tpid,
4338 (void *)&cmd_vlan_tpid_portid,
4343 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4344 struct cmd_rx_vlan_filter_result {
4345 cmdline_fixed_string_t rx_vlan;
4346 cmdline_fixed_string_t what;
4352 cmd_rx_vlan_filter_parsed(void *parsed_result,
4353 __rte_unused struct cmdline *cl,
4354 __rte_unused void *data)
4356 struct cmd_rx_vlan_filter_result *res = parsed_result;
4358 if (!strcmp(res->what, "add"))
4359 rx_vft_set(res->port_id, res->vlan_id, 1);
4361 rx_vft_set(res->port_id, res->vlan_id, 0);
4364 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4365 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4366 rx_vlan, "rx_vlan");
4367 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4368 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4370 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4371 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4372 vlan_id, RTE_UINT16);
4373 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4374 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4375 port_id, RTE_UINT16);
4377 cmdline_parse_inst_t cmd_rx_vlan_filter = {
4378 .f = cmd_rx_vlan_filter_parsed,
4380 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4381 "Add/Remove a VLAN identifier to/from the set of VLAN "
4382 "identifiers filtered by a port",
4384 (void *)&cmd_rx_vlan_filter_rx_vlan,
4385 (void *)&cmd_rx_vlan_filter_what,
4386 (void *)&cmd_rx_vlan_filter_vlanid,
4387 (void *)&cmd_rx_vlan_filter_portid,
4392 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4393 struct cmd_tx_vlan_set_result {
4394 cmdline_fixed_string_t tx_vlan;
4395 cmdline_fixed_string_t set;
4401 cmd_tx_vlan_set_parsed(void *parsed_result,
4402 __rte_unused struct cmdline *cl,
4403 __rte_unused void *data)
4405 struct cmd_tx_vlan_set_result *res = parsed_result;
4407 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4410 if (!port_is_stopped(res->port_id)) {
4411 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4415 tx_vlan_set(res->port_id, res->vlan_id);
4417 cmd_reconfig_device_queue(res->port_id, 1, 1);
4420 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4421 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4422 tx_vlan, "tx_vlan");
4423 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4424 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4426 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4427 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4428 port_id, RTE_UINT16);
4429 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4430 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4431 vlan_id, RTE_UINT16);
4433 cmdline_parse_inst_t cmd_tx_vlan_set = {
4434 .f = cmd_tx_vlan_set_parsed,
4436 .help_str = "tx_vlan set <port_id> <vlan_id>: "
4437 "Enable hardware insertion of a single VLAN header "
4438 "with a given TAG Identifier in packets sent on a port",
4440 (void *)&cmd_tx_vlan_set_tx_vlan,
4441 (void *)&cmd_tx_vlan_set_set,
4442 (void *)&cmd_tx_vlan_set_portid,
4443 (void *)&cmd_tx_vlan_set_vlanid,
4448 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4449 struct cmd_tx_vlan_set_qinq_result {
4450 cmdline_fixed_string_t tx_vlan;
4451 cmdline_fixed_string_t set;
4454 uint16_t vlan_id_outer;
4458 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4459 __rte_unused struct cmdline *cl,
4460 __rte_unused void *data)
4462 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4464 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4467 if (!port_is_stopped(res->port_id)) {
4468 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4472 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4474 cmd_reconfig_device_queue(res->port_id, 1, 1);
4477 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4478 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4479 tx_vlan, "tx_vlan");
4480 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4481 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4483 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4484 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4485 port_id, RTE_UINT16);
4486 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4487 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4488 vlan_id, RTE_UINT16);
4489 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4490 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4491 vlan_id_outer, RTE_UINT16);
4493 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4494 .f = cmd_tx_vlan_set_qinq_parsed,
4496 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4497 "Enable hardware insertion of double VLAN header "
4498 "with given TAG Identifiers in packets sent on a port",
4500 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4501 (void *)&cmd_tx_vlan_set_qinq_set,
4502 (void *)&cmd_tx_vlan_set_qinq_portid,
4503 (void *)&cmd_tx_vlan_set_qinq_vlanid,
4504 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4509 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4510 struct cmd_tx_vlan_set_pvid_result {
4511 cmdline_fixed_string_t tx_vlan;
4512 cmdline_fixed_string_t set;
4513 cmdline_fixed_string_t pvid;
4516 cmdline_fixed_string_t mode;
4520 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4521 __rte_unused struct cmdline *cl,
4522 __rte_unused void *data)
4524 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4526 if (strcmp(res->mode, "on") == 0)
4527 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4529 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4532 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4533 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4534 tx_vlan, "tx_vlan");
4535 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4536 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4538 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4539 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4541 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4542 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4543 port_id, RTE_UINT16);
4544 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4545 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4546 vlan_id, RTE_UINT16);
4547 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4548 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4551 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4552 .f = cmd_tx_vlan_set_pvid_parsed,
4554 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4556 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4557 (void *)&cmd_tx_vlan_set_pvid_set,
4558 (void *)&cmd_tx_vlan_set_pvid_pvid,
4559 (void *)&cmd_tx_vlan_set_pvid_port_id,
4560 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4561 (void *)&cmd_tx_vlan_set_pvid_mode,
4566 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4567 struct cmd_tx_vlan_reset_result {
4568 cmdline_fixed_string_t tx_vlan;
4569 cmdline_fixed_string_t reset;
4574 cmd_tx_vlan_reset_parsed(void *parsed_result,
4575 __rte_unused struct cmdline *cl,
4576 __rte_unused void *data)
4578 struct cmd_tx_vlan_reset_result *res = parsed_result;
4580 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4583 if (!port_is_stopped(res->port_id)) {
4584 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4588 tx_vlan_reset(res->port_id);
4590 cmd_reconfig_device_queue(res->port_id, 1, 1);
4593 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4594 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4595 tx_vlan, "tx_vlan");
4596 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4597 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4599 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4600 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4601 port_id, RTE_UINT16);
4603 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4604 .f = cmd_tx_vlan_reset_parsed,
4606 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4607 "VLAN header in packets sent on a port",
4609 (void *)&cmd_tx_vlan_reset_tx_vlan,
4610 (void *)&cmd_tx_vlan_reset_reset,
4611 (void *)&cmd_tx_vlan_reset_portid,
4617 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4618 struct cmd_csum_result {
4619 cmdline_fixed_string_t csum;
4620 cmdline_fixed_string_t mode;
4621 cmdline_fixed_string_t proto;
4622 cmdline_fixed_string_t hwsw;
4627 csum_show(int port_id)
4629 struct rte_eth_dev_info dev_info;
4630 uint64_t tx_offloads;
4633 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4634 printf("Parse tunnel is %s\n",
4635 (ports[port_id].parse_tunnel) ? "on" : "off");
4636 printf("IP checksum offload is %s\n",
4637 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4638 printf("UDP checksum offload is %s\n",
4639 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4640 printf("TCP checksum offload is %s\n",
4641 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4642 printf("SCTP checksum offload is %s\n",
4643 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4644 printf("Outer-Ip checksum offload is %s\n",
4645 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4646 printf("Outer-Udp checksum offload is %s\n",
4647 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4649 /* display warnings if configuration is not supported by the NIC */
4650 ret = eth_dev_info_get_print_err(port_id, &dev_info);
4654 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4655 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4657 "Warning: hardware IP checksum enabled but not supported by port %d\n",
4660 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4661 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4663 "Warning: hardware UDP checksum enabled but not supported by port %d\n",
4666 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4667 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4669 "Warning: hardware TCP checksum enabled but not supported by port %d\n",
4672 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4673 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4675 "Warning: hardware SCTP checksum enabled but not supported by port %d\n",
4678 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4679 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4681 "Warning: hardware outer IP checksum enabled but not supported by port %d\n",
4684 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4685 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
4688 "Warning: hardware outer UDP checksum enabled but not supported by port %d\n",
4694 cmd_config_queue_tx_offloads(struct rte_port *port)
4698 /* Apply queue tx offloads configuration */
4699 for (k = 0; k < port->dev_info.max_tx_queues; k++)
4700 port->tx_conf[k].offloads =
4701 port->dev_conf.txmode.offloads;
4705 cmd_csum_parsed(void *parsed_result,
4706 __rte_unused struct cmdline *cl,
4707 __rte_unused void *data)
4709 struct cmd_csum_result *res = parsed_result;
4711 uint64_t csum_offloads = 0;
4712 struct rte_eth_dev_info dev_info;
4715 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4716 fprintf(stderr, "invalid port %d\n", res->port_id);
4719 if (!port_is_stopped(res->port_id)) {
4720 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4724 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4728 if (!strcmp(res->mode, "set")) {
4730 if (!strcmp(res->hwsw, "hw"))
4733 if (!strcmp(res->proto, "ip")) {
4734 if (hw == 0 || (dev_info.tx_offload_capa &
4735 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4736 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4739 "IP checksum offload is not supported by port %u\n",
4742 } else if (!strcmp(res->proto, "udp")) {
4743 if (hw == 0 || (dev_info.tx_offload_capa &
4744 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4745 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4748 "UDP checksum offload is not supported by port %u\n",
4751 } else if (!strcmp(res->proto, "tcp")) {
4752 if (hw == 0 || (dev_info.tx_offload_capa &
4753 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4754 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4757 "TCP checksum offload is not supported by port %u\n",
4760 } else if (!strcmp(res->proto, "sctp")) {
4761 if (hw == 0 || (dev_info.tx_offload_capa &
4762 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4763 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4766 "SCTP checksum offload is not supported by port %u\n",
4769 } else if (!strcmp(res->proto, "outer-ip")) {
4770 if (hw == 0 || (dev_info.tx_offload_capa &
4771 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4773 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4776 "Outer IP checksum offload is not supported by port %u\n",
4779 } else if (!strcmp(res->proto, "outer-udp")) {
4780 if (hw == 0 || (dev_info.tx_offload_capa &
4781 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4783 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM;
4786 "Outer UDP checksum offload is not supported by port %u\n",
4792 ports[res->port_id].dev_conf.txmode.offloads |=
4795 ports[res->port_id].dev_conf.txmode.offloads &=
4798 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4800 csum_show(res->port_id);
4802 cmd_reconfig_device_queue(res->port_id, 1, 1);
4805 cmdline_parse_token_string_t cmd_csum_csum =
4806 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4808 cmdline_parse_token_string_t cmd_csum_mode =
4809 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4811 cmdline_parse_token_string_t cmd_csum_proto =
4812 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4813 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4814 cmdline_parse_token_string_t cmd_csum_hwsw =
4815 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4817 cmdline_parse_token_num_t cmd_csum_portid =
4818 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4819 port_id, RTE_UINT16);
4821 cmdline_parse_inst_t cmd_csum_set = {
4822 .f = cmd_csum_parsed,
4824 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4825 "Enable/Disable hardware calculation of L3/L4 checksum when "
4826 "using csum forward engine",
4828 (void *)&cmd_csum_csum,
4829 (void *)&cmd_csum_mode,
4830 (void *)&cmd_csum_proto,
4831 (void *)&cmd_csum_hwsw,
4832 (void *)&cmd_csum_portid,
4837 cmdline_parse_token_string_t cmd_csum_mode_show =
4838 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4841 cmdline_parse_inst_t cmd_csum_show = {
4842 .f = cmd_csum_parsed,
4844 .help_str = "csum show <port_id>: Show checksum offload configuration",
4846 (void *)&cmd_csum_csum,
4847 (void *)&cmd_csum_mode_show,
4848 (void *)&cmd_csum_portid,
4853 /* Enable/disable tunnel parsing */
4854 struct cmd_csum_tunnel_result {
4855 cmdline_fixed_string_t csum;
4856 cmdline_fixed_string_t parse;
4857 cmdline_fixed_string_t onoff;
4862 cmd_csum_tunnel_parsed(void *parsed_result,
4863 __rte_unused struct cmdline *cl,
4864 __rte_unused void *data)
4866 struct cmd_csum_tunnel_result *res = parsed_result;
4868 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4871 if (!strcmp(res->onoff, "on"))
4872 ports[res->port_id].parse_tunnel = 1;
4874 ports[res->port_id].parse_tunnel = 0;
4876 csum_show(res->port_id);
4879 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4880 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4882 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4883 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4884 parse, "parse-tunnel");
4885 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4886 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4888 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4889 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4890 port_id, RTE_UINT16);
4892 cmdline_parse_inst_t cmd_csum_tunnel = {
4893 .f = cmd_csum_tunnel_parsed,
4895 .help_str = "csum parse-tunnel on|off <port_id>: "
4896 "Enable/Disable parsing of tunnels for csum engine",
4898 (void *)&cmd_csum_tunnel_csum,
4899 (void *)&cmd_csum_tunnel_parse,
4900 (void *)&cmd_csum_tunnel_onoff,
4901 (void *)&cmd_csum_tunnel_portid,
4906 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4907 struct cmd_tso_set_result {
4908 cmdline_fixed_string_t tso;
4909 cmdline_fixed_string_t mode;
4915 cmd_tso_set_parsed(void *parsed_result,
4916 __rte_unused struct cmdline *cl,
4917 __rte_unused void *data)
4919 struct cmd_tso_set_result *res = parsed_result;
4920 struct rte_eth_dev_info dev_info;
4923 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4925 if (!port_is_stopped(res->port_id)) {
4926 fprintf(stderr, "Please stop port %d first\n", res->port_id);
4930 if (!strcmp(res->mode, "set"))
4931 ports[res->port_id].tso_segsz = res->tso_segsz;
4933 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4937 if ((ports[res->port_id].tso_segsz != 0) &&
4938 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4939 fprintf(stderr, "Error: TSO is not supported by port %d\n",
4944 if (ports[res->port_id].tso_segsz == 0) {
4945 ports[res->port_id].dev_conf.txmode.offloads &=
4946 ~DEV_TX_OFFLOAD_TCP_TSO;
4947 printf("TSO for non-tunneled packets is disabled\n");
4949 ports[res->port_id].dev_conf.txmode.offloads |=
4950 DEV_TX_OFFLOAD_TCP_TSO;
4951 printf("TSO segment size for non-tunneled packets is %d\n",
4952 ports[res->port_id].tso_segsz);
4954 cmd_config_queue_tx_offloads(&ports[res->port_id]);
4956 /* display warnings if configuration is not supported by the NIC */
4957 ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4961 if ((ports[res->port_id].tso_segsz != 0) &&
4962 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4964 "Warning: TSO enabled but not supported by port %d\n",
4968 cmd_reconfig_device_queue(res->port_id, 1, 1);
4971 cmdline_parse_token_string_t cmd_tso_set_tso =
4972 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4974 cmdline_parse_token_string_t cmd_tso_set_mode =
4975 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4977 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4978 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4979 tso_segsz, RTE_UINT16);
4980 cmdline_parse_token_num_t cmd_tso_set_portid =
4981 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4982 port_id, RTE_UINT16);
4984 cmdline_parse_inst_t cmd_tso_set = {
4985 .f = cmd_tso_set_parsed,
4987 .help_str = "tso set <tso_segsz> <port_id>: "
4988 "Set TSO segment size of non-tunneled packets for csum engine "
4991 (void *)&cmd_tso_set_tso,
4992 (void *)&cmd_tso_set_mode,
4993 (void *)&cmd_tso_set_tso_segsz,
4994 (void *)&cmd_tso_set_portid,
4999 cmdline_parse_token_string_t cmd_tso_show_mode =
5000 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5004 cmdline_parse_inst_t cmd_tso_show = {
5005 .f = cmd_tso_set_parsed,
5007 .help_str = "tso show <port_id>: "
5008 "Show TSO segment size of non-tunneled packets for csum engine",
5010 (void *)&cmd_tso_set_tso,
5011 (void *)&cmd_tso_show_mode,
5012 (void *)&cmd_tso_set_portid,
5017 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5018 struct cmd_tunnel_tso_set_result {
5019 cmdline_fixed_string_t tso;
5020 cmdline_fixed_string_t mode;
5025 static struct rte_eth_dev_info
5026 check_tunnel_tso_nic_support(portid_t port_id)
5028 struct rte_eth_dev_info dev_info;
5030 if (eth_dev_info_get_print_err(port_id, &dev_info) != 0)
5033 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
5035 "Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n",
5037 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
5039 "Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n",
5041 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
5043 "Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n",
5045 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
5047 "Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n",
5049 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
5051 "Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n",
5053 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
5055 "Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n",
5061 cmd_tunnel_tso_set_parsed(void *parsed_result,
5062 __rte_unused struct cmdline *cl,
5063 __rte_unused void *data)
5065 struct cmd_tunnel_tso_set_result *res = parsed_result;
5066 struct rte_eth_dev_info dev_info;
5068 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5070 if (!port_is_stopped(res->port_id)) {
5071 fprintf(stderr, "Please stop port %d first\n", res->port_id);
5075 if (!strcmp(res->mode, "set"))
5076 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5078 dev_info = check_tunnel_tso_nic_support(res->port_id);
5079 if (ports[res->port_id].tunnel_tso_segsz == 0) {
5080 ports[res->port_id].dev_conf.txmode.offloads &=
5081 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5082 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5083 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5084 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5085 DEV_TX_OFFLOAD_IP_TNL_TSO |
5086 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5087 printf("TSO for tunneled packets is disabled\n");
5089 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
5090 DEV_TX_OFFLOAD_GRE_TNL_TSO |
5091 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
5092 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
5093 DEV_TX_OFFLOAD_IP_TNL_TSO |
5094 DEV_TX_OFFLOAD_UDP_TNL_TSO);
5096 ports[res->port_id].dev_conf.txmode.offloads |=
5097 (tso_offloads & dev_info.tx_offload_capa);
5098 printf("TSO segment size for tunneled packets is %d\n",
5099 ports[res->port_id].tunnel_tso_segsz);
5101 /* Below conditions are needed to make it work:
5102 * (1) tunnel TSO is supported by the NIC;
5103 * (2) "csum parse_tunnel" must be set so that tunneled pkts
5105 * (3) for tunneled pkts with outer L3 of IPv4,
5106 * "csum set outer-ip" must be set to hw, because after tso,
5107 * total_len of outer IP header is changed, and the checksum
5108 * of outer IP header calculated by sw should be wrong; that
5109 * is not necessary for IPv6 tunneled pkts because there's no
5110 * checksum in IP header anymore.
5113 if (!ports[res->port_id].parse_tunnel)
5115 "Warning: csum parse_tunnel must be set so that tunneled packets are recognized\n");
5116 if (!(ports[res->port_id].dev_conf.txmode.offloads &
5117 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
5119 "Warning: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n");
5122 cmd_config_queue_tx_offloads(&ports[res->port_id]);
5123 cmd_reconfig_device_queue(res->port_id, 1, 1);
5126 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5127 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5129 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5130 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5132 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5133 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5134 tso_segsz, RTE_UINT16);
5135 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5136 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5137 port_id, RTE_UINT16);
5139 cmdline_parse_inst_t cmd_tunnel_tso_set = {
5140 .f = cmd_tunnel_tso_set_parsed,
5142 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5143 "Set TSO segment size of tunneled packets for csum engine "
5146 (void *)&cmd_tunnel_tso_set_tso,
5147 (void *)&cmd_tunnel_tso_set_mode,
5148 (void *)&cmd_tunnel_tso_set_tso_segsz,
5149 (void *)&cmd_tunnel_tso_set_portid,
5154 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5155 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5159 cmdline_parse_inst_t cmd_tunnel_tso_show = {
5160 .f = cmd_tunnel_tso_set_parsed,
5162 .help_str = "tunnel_tso show <port_id> "
5163 "Show TSO segment size of tunneled packets for csum engine",
5165 (void *)&cmd_tunnel_tso_set_tso,
5166 (void *)&cmd_tunnel_tso_show_mode,
5167 (void *)&cmd_tunnel_tso_set_portid,
5172 /* *** SET GRO FOR A PORT *** */
5173 struct cmd_gro_enable_result {
5174 cmdline_fixed_string_t cmd_set;
5175 cmdline_fixed_string_t cmd_port;
5176 cmdline_fixed_string_t cmd_keyword;
5177 cmdline_fixed_string_t cmd_onoff;
5182 cmd_gro_enable_parsed(void *parsed_result,
5183 __rte_unused struct cmdline *cl,
5184 __rte_unused void *data)
5186 struct cmd_gro_enable_result *res;
5188 res = parsed_result;
5189 if (!strcmp(res->cmd_keyword, "gro"))
5190 setup_gro(res->cmd_onoff, res->cmd_pid);
5193 cmdline_parse_token_string_t cmd_gro_enable_set =
5194 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5196 cmdline_parse_token_string_t cmd_gro_enable_port =
5197 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5198 cmd_keyword, "port");
5199 cmdline_parse_token_num_t cmd_gro_enable_pid =
5200 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5201 cmd_pid, RTE_UINT16);
5202 cmdline_parse_token_string_t cmd_gro_enable_keyword =
5203 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5204 cmd_keyword, "gro");
5205 cmdline_parse_token_string_t cmd_gro_enable_onoff =
5206 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5207 cmd_onoff, "on#off");
5209 cmdline_parse_inst_t cmd_gro_enable = {
5210 .f = cmd_gro_enable_parsed,
5212 .help_str = "set port <port_id> gro on|off",
5214 (void *)&cmd_gro_enable_set,
5215 (void *)&cmd_gro_enable_port,
5216 (void *)&cmd_gro_enable_pid,
5217 (void *)&cmd_gro_enable_keyword,
5218 (void *)&cmd_gro_enable_onoff,
5223 /* *** DISPLAY GRO CONFIGURATION *** */
5224 struct cmd_gro_show_result {
5225 cmdline_fixed_string_t cmd_show;
5226 cmdline_fixed_string_t cmd_port;
5227 cmdline_fixed_string_t cmd_keyword;
5232 cmd_gro_show_parsed(void *parsed_result,
5233 __rte_unused struct cmdline *cl,
5234 __rte_unused void *data)
5236 struct cmd_gro_show_result *res;
5238 res = parsed_result;
5239 if (!strcmp(res->cmd_keyword, "gro"))
5240 show_gro(res->cmd_pid);
5243 cmdline_parse_token_string_t cmd_gro_show_show =
5244 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5246 cmdline_parse_token_string_t cmd_gro_show_port =
5247 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5249 cmdline_parse_token_num_t cmd_gro_show_pid =
5250 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5251 cmd_pid, RTE_UINT16);
5252 cmdline_parse_token_string_t cmd_gro_show_keyword =
5253 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5254 cmd_keyword, "gro");
5256 cmdline_parse_inst_t cmd_gro_show = {
5257 .f = cmd_gro_show_parsed,
5259 .help_str = "show port <port_id> gro",
5261 (void *)&cmd_gro_show_show,
5262 (void *)&cmd_gro_show_port,
5263 (void *)&cmd_gro_show_pid,
5264 (void *)&cmd_gro_show_keyword,
5269 /* *** SET FLUSH CYCLES FOR GRO *** */
5270 struct cmd_gro_flush_result {
5271 cmdline_fixed_string_t cmd_set;
5272 cmdline_fixed_string_t cmd_keyword;
5273 cmdline_fixed_string_t cmd_flush;
5278 cmd_gro_flush_parsed(void *parsed_result,
5279 __rte_unused struct cmdline *cl,
5280 __rte_unused void *data)
5282 struct cmd_gro_flush_result *res;
5284 res = parsed_result;
5285 if ((!strcmp(res->cmd_keyword, "gro")) &&
5286 (!strcmp(res->cmd_flush, "flush")))
5287 setup_gro_flush_cycles(res->cmd_cycles);
5290 cmdline_parse_token_string_t cmd_gro_flush_set =
5291 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5293 cmdline_parse_token_string_t cmd_gro_flush_keyword =
5294 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5295 cmd_keyword, "gro");
5296 cmdline_parse_token_string_t cmd_gro_flush_flush =
5297 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5298 cmd_flush, "flush");
5299 cmdline_parse_token_num_t cmd_gro_flush_cycles =
5300 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5301 cmd_cycles, RTE_UINT8);
5303 cmdline_parse_inst_t cmd_gro_flush = {
5304 .f = cmd_gro_flush_parsed,
5306 .help_str = "set gro flush <cycles>",
5308 (void *)&cmd_gro_flush_set,
5309 (void *)&cmd_gro_flush_keyword,
5310 (void *)&cmd_gro_flush_flush,
5311 (void *)&cmd_gro_flush_cycles,
5316 /* *** ENABLE/DISABLE GSO *** */
5317 struct cmd_gso_enable_result {
5318 cmdline_fixed_string_t cmd_set;
5319 cmdline_fixed_string_t cmd_port;
5320 cmdline_fixed_string_t cmd_keyword;
5321 cmdline_fixed_string_t cmd_mode;
5326 cmd_gso_enable_parsed(void *parsed_result,
5327 __rte_unused struct cmdline *cl,
5328 __rte_unused void *data)
5330 struct cmd_gso_enable_result *res;
5332 res = parsed_result;
5333 if (!strcmp(res->cmd_keyword, "gso"))
5334 setup_gso(res->cmd_mode, res->cmd_pid);
5337 cmdline_parse_token_string_t cmd_gso_enable_set =
5338 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5340 cmdline_parse_token_string_t cmd_gso_enable_port =
5341 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5343 cmdline_parse_token_string_t cmd_gso_enable_keyword =
5344 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5345 cmd_keyword, "gso");
5346 cmdline_parse_token_string_t cmd_gso_enable_mode =
5347 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5348 cmd_mode, "on#off");
5349 cmdline_parse_token_num_t cmd_gso_enable_pid =
5350 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5351 cmd_pid, RTE_UINT16);
5353 cmdline_parse_inst_t cmd_gso_enable = {
5354 .f = cmd_gso_enable_parsed,
5356 .help_str = "set port <port_id> gso on|off",
5358 (void *)&cmd_gso_enable_set,
5359 (void *)&cmd_gso_enable_port,
5360 (void *)&cmd_gso_enable_pid,
5361 (void *)&cmd_gso_enable_keyword,
5362 (void *)&cmd_gso_enable_mode,
5367 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5368 struct cmd_gso_size_result {
5369 cmdline_fixed_string_t cmd_set;
5370 cmdline_fixed_string_t cmd_keyword;
5371 cmdline_fixed_string_t cmd_segsz;
5376 cmd_gso_size_parsed(void *parsed_result,
5377 __rte_unused struct cmdline *cl,
5378 __rte_unused void *data)
5380 struct cmd_gso_size_result *res = parsed_result;
5382 if (test_done == 0) {
5384 "Before setting GSO segsz, please first stop forwarding\n");
5388 if (!strcmp(res->cmd_keyword, "gso") &&
5389 !strcmp(res->cmd_segsz, "segsz")) {
5390 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5392 "gso_size should be larger than %zu. Please input a legal value\n",
5393 RTE_GSO_SEG_SIZE_MIN);
5395 gso_max_segment_size = res->cmd_size;
5399 cmdline_parse_token_string_t cmd_gso_size_set =
5400 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5402 cmdline_parse_token_string_t cmd_gso_size_keyword =
5403 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5404 cmd_keyword, "gso");
5405 cmdline_parse_token_string_t cmd_gso_size_segsz =
5406 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5407 cmd_segsz, "segsz");
5408 cmdline_parse_token_num_t cmd_gso_size_size =
5409 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5410 cmd_size, RTE_UINT16);
5412 cmdline_parse_inst_t cmd_gso_size = {
5413 .f = cmd_gso_size_parsed,
5415 .help_str = "set gso segsz <length>",
5417 (void *)&cmd_gso_size_set,
5418 (void *)&cmd_gso_size_keyword,
5419 (void *)&cmd_gso_size_segsz,
5420 (void *)&cmd_gso_size_size,
5425 /* *** SHOW GSO CONFIGURATION *** */
5426 struct cmd_gso_show_result {
5427 cmdline_fixed_string_t cmd_show;
5428 cmdline_fixed_string_t cmd_port;
5429 cmdline_fixed_string_t cmd_keyword;
5434 cmd_gso_show_parsed(void *parsed_result,
5435 __rte_unused struct cmdline *cl,
5436 __rte_unused void *data)
5438 struct cmd_gso_show_result *res = parsed_result;
5440 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5441 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
5444 if (!strcmp(res->cmd_keyword, "gso")) {
5445 if (gso_ports[res->cmd_pid].enable) {
5446 printf("Max GSO'd packet size: %uB\n"
5447 "Supported GSO types: TCP/IPv4, "
5448 "UDP/IPv4, VxLAN with inner "
5449 "TCP/IPv4 packet, GRE with inner "
5450 "TCP/IPv4 packet\n",
5451 gso_max_segment_size);
5453 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5457 cmdline_parse_token_string_t cmd_gso_show_show =
5458 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5460 cmdline_parse_token_string_t cmd_gso_show_port =
5461 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5463 cmdline_parse_token_string_t cmd_gso_show_keyword =
5464 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5465 cmd_keyword, "gso");
5466 cmdline_parse_token_num_t cmd_gso_show_pid =
5467 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5468 cmd_pid, RTE_UINT16);
5470 cmdline_parse_inst_t cmd_gso_show = {
5471 .f = cmd_gso_show_parsed,
5473 .help_str = "show port <port_id> gso",
5475 (void *)&cmd_gso_show_show,
5476 (void *)&cmd_gso_show_port,
5477 (void *)&cmd_gso_show_pid,
5478 (void *)&cmd_gso_show_keyword,
5483 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5484 struct cmd_set_flush_rx {
5485 cmdline_fixed_string_t set;
5486 cmdline_fixed_string_t flush_rx;
5487 cmdline_fixed_string_t mode;
5491 cmd_set_flush_rx_parsed(void *parsed_result,
5492 __rte_unused struct cmdline *cl,
5493 __rte_unused void *data)
5495 struct cmd_set_flush_rx *res = parsed_result;
5497 if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) {
5498 printf("multi-process doesn't support to flush Rx queues.\n");
5502 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5505 cmdline_parse_token_string_t cmd_setflushrx_set =
5506 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5508 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5509 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5510 flush_rx, "flush_rx");
5511 cmdline_parse_token_string_t cmd_setflushrx_mode =
5512 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5516 cmdline_parse_inst_t cmd_set_flush_rx = {
5517 .f = cmd_set_flush_rx_parsed,
5518 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5521 (void *)&cmd_setflushrx_set,
5522 (void *)&cmd_setflushrx_flush_rx,
5523 (void *)&cmd_setflushrx_mode,
5528 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5529 struct cmd_set_link_check {
5530 cmdline_fixed_string_t set;
5531 cmdline_fixed_string_t link_check;
5532 cmdline_fixed_string_t mode;
5536 cmd_set_link_check_parsed(void *parsed_result,
5537 __rte_unused struct cmdline *cl,
5538 __rte_unused void *data)
5540 struct cmd_set_link_check *res = parsed_result;
5541 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5544 cmdline_parse_token_string_t cmd_setlinkcheck_set =
5545 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5547 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5548 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5549 link_check, "link_check");
5550 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5551 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5555 cmdline_parse_inst_t cmd_set_link_check = {
5556 .f = cmd_set_link_check_parsed,
5557 .help_str = "set link_check on|off: Enable/Disable link status check "
5558 "when starting/stopping a port",
5561 (void *)&cmd_setlinkcheck_set,
5562 (void *)&cmd_setlinkcheck_link_check,
5563 (void *)&cmd_setlinkcheck_mode,
5568 /* *** SET NIC BYPASS MODE *** */
5569 struct cmd_set_bypass_mode_result {
5570 cmdline_fixed_string_t set;
5571 cmdline_fixed_string_t bypass;
5572 cmdline_fixed_string_t mode;
5573 cmdline_fixed_string_t value;
5578 cmd_set_bypass_mode_parsed(void *parsed_result,
5579 __rte_unused struct cmdline *cl,
5580 __rte_unused void *data)
5582 struct cmd_set_bypass_mode_result *res = parsed_result;
5583 portid_t port_id = res->port_id;
5584 int32_t rc = -EINVAL;
5586 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5587 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5589 if (!strcmp(res->value, "bypass"))
5590 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5591 else if (!strcmp(res->value, "isolate"))
5592 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5594 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5596 /* Set the bypass mode for the relevant port. */
5597 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
5600 fprintf(stderr, "\t Failed to set bypass mode for port = %d.\n",
5604 cmdline_parse_token_string_t cmd_setbypass_mode_set =
5605 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5607 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
5608 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5610 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
5611 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5613 cmdline_parse_token_string_t cmd_setbypass_mode_value =
5614 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
5615 value, "normal#bypass#isolate");
5616 cmdline_parse_token_num_t cmd_setbypass_mode_port =
5617 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
5618 port_id, RTE_UINT16);
5620 cmdline_parse_inst_t cmd_set_bypass_mode = {
5621 .f = cmd_set_bypass_mode_parsed,
5622 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
5623 "Set the NIC bypass mode for port_id",
5626 (void *)&cmd_setbypass_mode_set,
5627 (void *)&cmd_setbypass_mode_bypass,
5628 (void *)&cmd_setbypass_mode_mode,
5629 (void *)&cmd_setbypass_mode_value,
5630 (void *)&cmd_setbypass_mode_port,
5635 /* *** SET NIC BYPASS EVENT *** */
5636 struct cmd_set_bypass_event_result {
5637 cmdline_fixed_string_t set;
5638 cmdline_fixed_string_t bypass;
5639 cmdline_fixed_string_t event;
5640 cmdline_fixed_string_t event_value;
5641 cmdline_fixed_string_t mode;
5642 cmdline_fixed_string_t mode_value;
5647 cmd_set_bypass_event_parsed(void *parsed_result,
5648 __rte_unused struct cmdline *cl,
5649 __rte_unused void *data)
5651 int32_t rc = -EINVAL;
5652 struct cmd_set_bypass_event_result *res = parsed_result;
5653 portid_t port_id = res->port_id;
5655 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5656 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5657 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5659 if (!strcmp(res->event_value, "timeout"))
5660 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5661 else if (!strcmp(res->event_value, "os_on"))
5662 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5663 else if (!strcmp(res->event_value, "os_off"))
5664 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5665 else if (!strcmp(res->event_value, "power_on"))
5666 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5667 else if (!strcmp(res->event_value, "power_off"))
5668 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5670 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5672 if (!strcmp(res->mode_value, "bypass"))
5673 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5674 else if (!strcmp(res->mode_value, "isolate"))
5675 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5677 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5679 /* Set the watchdog timeout. */
5680 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5683 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5684 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5689 "Failed to set timeout value %u for port %d, errto code: %d.\n",
5690 bypass_timeout, port_id, rc);
5694 /* Set the bypass event to transition to bypass mode. */
5695 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5700 fprintf(stderr, "\t Failed to set bypass event for port = %d.\n",
5704 cmdline_parse_token_string_t cmd_setbypass_event_set =
5705 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5707 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5708 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5710 cmdline_parse_token_string_t cmd_setbypass_event_event =
5711 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5713 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5714 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5715 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5716 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5717 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5719 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5720 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5721 mode_value, "normal#bypass#isolate");
5722 cmdline_parse_token_num_t cmd_setbypass_event_port =
5723 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5724 port_id, RTE_UINT16);
5726 cmdline_parse_inst_t cmd_set_bypass_event = {
5727 .f = cmd_set_bypass_event_parsed,
5728 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5729 "power_off mode normal|bypass|isolate <port_id>: "
5730 "Set the NIC bypass event mode for port_id",
5733 (void *)&cmd_setbypass_event_set,
5734 (void *)&cmd_setbypass_event_bypass,
5735 (void *)&cmd_setbypass_event_event,
5736 (void *)&cmd_setbypass_event_event_value,
5737 (void *)&cmd_setbypass_event_mode,
5738 (void *)&cmd_setbypass_event_mode_value,
5739 (void *)&cmd_setbypass_event_port,
5745 /* *** SET NIC BYPASS TIMEOUT *** */
5746 struct cmd_set_bypass_timeout_result {
5747 cmdline_fixed_string_t set;
5748 cmdline_fixed_string_t bypass;
5749 cmdline_fixed_string_t timeout;
5750 cmdline_fixed_string_t value;
5754 cmd_set_bypass_timeout_parsed(void *parsed_result,
5755 __rte_unused struct cmdline *cl,
5756 __rte_unused void *data)
5758 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5760 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5761 if (!strcmp(res->value, "1.5"))
5762 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5763 else if (!strcmp(res->value, "2"))
5764 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5765 else if (!strcmp(res->value, "3"))
5766 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5767 else if (!strcmp(res->value, "4"))
5768 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5769 else if (!strcmp(res->value, "8"))
5770 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5771 else if (!strcmp(res->value, "16"))
5772 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5773 else if (!strcmp(res->value, "32"))
5774 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5776 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5780 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5781 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5783 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5784 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5786 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5787 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5788 timeout, "timeout");
5789 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5790 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5791 value, "0#1.5#2#3#4#8#16#32");
5793 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5794 .f = cmd_set_bypass_timeout_parsed,
5795 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5796 "Set the NIC bypass watchdog timeout in seconds",
5799 (void *)&cmd_setbypass_timeout_set,
5800 (void *)&cmd_setbypass_timeout_bypass,
5801 (void *)&cmd_setbypass_timeout_timeout,
5802 (void *)&cmd_setbypass_timeout_value,
5807 /* *** SHOW NIC BYPASS MODE *** */
5808 struct cmd_show_bypass_config_result {
5809 cmdline_fixed_string_t show;
5810 cmdline_fixed_string_t bypass;
5811 cmdline_fixed_string_t config;
5816 cmd_show_bypass_config_parsed(void *parsed_result,
5817 __rte_unused struct cmdline *cl,
5818 __rte_unused void *data)
5820 struct cmd_show_bypass_config_result *res = parsed_result;
5821 portid_t port_id = res->port_id;
5823 #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS
5824 uint32_t event_mode;
5825 uint32_t bypass_mode;
5826 uint32_t timeout = bypass_timeout;
5829 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5830 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5831 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5832 {"UNKNOWN", "normal", "bypass", "isolate"};
5833 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5841 /* Display the bypass mode.*/
5842 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5843 fprintf(stderr, "\tFailed to get bypass mode for port = %d\n",
5848 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5849 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5851 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5854 /* Display the bypass timeout.*/
5855 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5856 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5858 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5860 /* Display the bypass events and associated modes. */
5861 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < RTE_DIM(events); i++) {
5863 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5865 "\tFailed to get bypass mode for event = %s\n",
5868 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5869 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5871 printf("\tbypass event: %-16s = %s\n", events[i],
5878 "\tFailed to get bypass configuration for port = %d\n",
5882 cmdline_parse_token_string_t cmd_showbypass_config_show =
5883 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5885 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5886 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5888 cmdline_parse_token_string_t cmd_showbypass_config_config =
5889 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5891 cmdline_parse_token_num_t cmd_showbypass_config_port =
5892 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5893 port_id, RTE_UINT16);
5895 cmdline_parse_inst_t cmd_show_bypass_config = {
5896 .f = cmd_show_bypass_config_parsed,
5897 .help_str = "show bypass config <port_id>: "
5898 "Show the NIC bypass config for port_id",
5901 (void *)&cmd_showbypass_config_show,
5902 (void *)&cmd_showbypass_config_bypass,
5903 (void *)&cmd_showbypass_config_config,
5904 (void *)&cmd_showbypass_config_port,
5910 /* *** SET BONDING MODE *** */
5911 struct cmd_set_bonding_mode_result {
5912 cmdline_fixed_string_t set;
5913 cmdline_fixed_string_t bonding;
5914 cmdline_fixed_string_t mode;
5919 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5920 __rte_unused struct cmdline *cl,
5921 __rte_unused void *data)
5923 struct cmd_set_bonding_mode_result *res = parsed_result;
5924 portid_t port_id = res->port_id;
5926 /* Set the bonding mode for the relevant port. */
5927 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5928 fprintf(stderr, "\t Failed to set bonding mode for port = %d.\n",
5932 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5933 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5935 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5936 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5937 bonding, "bonding");
5938 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5939 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5941 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5942 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5944 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5945 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5946 port_id, RTE_UINT16);
5948 cmdline_parse_inst_t cmd_set_bonding_mode = {
5949 .f = cmd_set_bonding_mode_parsed,
5950 .help_str = "set bonding mode <mode_value> <port_id>: "
5951 "Set the bonding mode for port_id",
5954 (void *) &cmd_setbonding_mode_set,
5955 (void *) &cmd_setbonding_mode_bonding,
5956 (void *) &cmd_setbonding_mode_mode,
5957 (void *) &cmd_setbonding_mode_value,
5958 (void *) &cmd_setbonding_mode_port,
5963 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5964 struct cmd_set_bonding_lacp_dedicated_queues_result {
5965 cmdline_fixed_string_t set;
5966 cmdline_fixed_string_t bonding;
5967 cmdline_fixed_string_t lacp;
5968 cmdline_fixed_string_t dedicated_queues;
5970 cmdline_fixed_string_t mode;
5973 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5974 __rte_unused struct cmdline *cl,
5975 __rte_unused void *data)
5977 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5978 portid_t port_id = res->port_id;
5979 struct rte_port *port;
5981 port = &ports[port_id];
5983 /** Check if the port is not started **/
5984 if (port->port_status != RTE_PORT_STOPPED) {
5985 fprintf(stderr, "Please stop port %d first\n", port_id);
5989 if (!strcmp(res->mode, "enable")) {
5990 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5991 printf("Dedicate queues for LACP control packets"
5994 printf("Enabling dedicate queues for LACP control "
5995 "packets on port %d failed\n", port_id);
5996 } else if (!strcmp(res->mode, "disable")) {
5997 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5998 printf("Dedicated queues for LACP control packets "
6001 printf("Disabling dedicated queues for LACP control "
6002 "traffic on port %d failed\n", port_id);
6006 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
6007 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6009 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
6010 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6011 bonding, "bonding");
6012 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
6013 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6015 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
6016 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6017 dedicated_queues, "dedicated_queues");
6018 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
6019 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6020 port_id, RTE_UINT16);
6021 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
6022 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
6023 mode, "enable#disable");
6025 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
6026 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
6027 .help_str = "set bonding lacp dedicated_queues <port_id> "
6029 "Enable/disable dedicated queues for LACP control traffic for port_id",
6032 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
6033 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
6034 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
6035 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
6036 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
6037 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
6042 /* *** SET BALANCE XMIT POLICY *** */
6043 struct cmd_set_bonding_balance_xmit_policy_result {
6044 cmdline_fixed_string_t set;
6045 cmdline_fixed_string_t bonding;
6046 cmdline_fixed_string_t balance_xmit_policy;
6048 cmdline_fixed_string_t policy;
6051 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
6052 __rte_unused struct cmdline *cl,
6053 __rte_unused void *data)
6055 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
6056 portid_t port_id = res->port_id;
6059 if (!strcmp(res->policy, "l2")) {
6060 policy = BALANCE_XMIT_POLICY_LAYER2;
6061 } else if (!strcmp(res->policy, "l23")) {
6062 policy = BALANCE_XMIT_POLICY_LAYER23;
6063 } else if (!strcmp(res->policy, "l34")) {
6064 policy = BALANCE_XMIT_POLICY_LAYER34;
6066 fprintf(stderr, "\t Invalid xmit policy selection");
6070 /* Set the bonding mode for the relevant port. */
6071 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
6073 "\t Failed to set bonding balance xmit policy for port = %d.\n",
6078 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
6079 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6081 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
6082 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6083 bonding, "bonding");
6084 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
6085 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6086 balance_xmit_policy, "balance_xmit_policy");
6087 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
6088 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6089 port_id, RTE_UINT16);
6090 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
6091 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
6092 policy, "l2#l23#l34");
6094 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
6095 .f = cmd_set_bonding_balance_xmit_policy_parsed,
6096 .help_str = "set bonding balance_xmit_policy <port_id> "
6098 "Set the bonding balance_xmit_policy for port_id",
6101 (void *)&cmd_setbonding_balance_xmit_policy_set,
6102 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
6103 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
6104 (void *)&cmd_setbonding_balance_xmit_policy_port,
6105 (void *)&cmd_setbonding_balance_xmit_policy_policy,
6110 /* *** SHOW NIC BONDING CONFIGURATION *** */
6111 struct cmd_show_bonding_config_result {
6112 cmdline_fixed_string_t show;
6113 cmdline_fixed_string_t bonding;
6114 cmdline_fixed_string_t config;
6118 static void cmd_show_bonding_config_parsed(void *parsed_result,
6119 __rte_unused struct cmdline *cl,
6120 __rte_unused void *data)
6122 struct cmd_show_bonding_config_result *res = parsed_result;
6123 int bonding_mode, agg_mode;
6124 portid_t slaves[RTE_MAX_ETHPORTS];
6125 int num_slaves, num_active_slaves;
6128 portid_t port_id = res->port_id;
6130 /* Display the bonding mode.*/
6131 bonding_mode = rte_eth_bond_mode_get(port_id);
6132 if (bonding_mode < 0) {
6133 fprintf(stderr, "\tFailed to get bonding mode for port = %d\n",
6137 printf("\tBonding mode: %d\n", bonding_mode);
6139 if (bonding_mode == BONDING_MODE_BALANCE) {
6140 int balance_xmit_policy;
6142 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
6143 if (balance_xmit_policy < 0) {
6145 "\tFailed to get balance xmit policy for port = %d\n",
6149 printf("\tBalance Xmit Policy: ");
6151 switch (balance_xmit_policy) {
6152 case BALANCE_XMIT_POLICY_LAYER2:
6153 printf("BALANCE_XMIT_POLICY_LAYER2");
6155 case BALANCE_XMIT_POLICY_LAYER23:
6156 printf("BALANCE_XMIT_POLICY_LAYER23");
6158 case BALANCE_XMIT_POLICY_LAYER34:
6159 printf("BALANCE_XMIT_POLICY_LAYER34");
6166 if (bonding_mode == BONDING_MODE_8023AD) {
6167 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
6168 printf("\tIEEE802.3AD Aggregator Mode: ");
6171 printf("bandwidth");
6183 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
6185 if (num_slaves < 0) {
6186 fprintf(stderr, "\tFailed to get slave list for port = %d\n",
6190 if (num_slaves > 0) {
6191 printf("\tSlaves (%d): [", num_slaves);
6192 for (i = 0; i < num_slaves - 1; i++)
6193 printf("%d ", slaves[i]);
6195 printf("%d]\n", slaves[num_slaves - 1]);
6197 printf("\tSlaves: []\n");
6201 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
6204 if (num_active_slaves < 0) {
6206 "\tFailed to get active slave list for port = %d\n",
6210 if (num_active_slaves > 0) {
6211 printf("\tActive Slaves (%d): [", num_active_slaves);
6212 for (i = 0; i < num_active_slaves - 1; i++)
6213 printf("%d ", slaves[i]);
6215 printf("%d]\n", slaves[num_active_slaves - 1]);
6218 printf("\tActive Slaves: []\n");
6222 primary_id = rte_eth_bond_primary_get(port_id);
6223 if (primary_id < 0) {
6224 fprintf(stderr, "\tFailed to get primary slave for port = %d\n",
6228 printf("\tPrimary: [%d]\n", primary_id);
6232 cmdline_parse_token_string_t cmd_showbonding_config_show =
6233 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6235 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
6236 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6237 bonding, "bonding");
6238 cmdline_parse_token_string_t cmd_showbonding_config_config =
6239 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
6241 cmdline_parse_token_num_t cmd_showbonding_config_port =
6242 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
6243 port_id, RTE_UINT16);
6245 cmdline_parse_inst_t cmd_show_bonding_config = {
6246 .f = cmd_show_bonding_config_parsed,
6247 .help_str = "show bonding config <port_id>: "
6248 "Show the bonding config for port_id",
6251 (void *)&cmd_showbonding_config_show,
6252 (void *)&cmd_showbonding_config_bonding,
6253 (void *)&cmd_showbonding_config_config,
6254 (void *)&cmd_showbonding_config_port,
6259 /* *** SET BONDING PRIMARY *** */
6260 struct cmd_set_bonding_primary_result {
6261 cmdline_fixed_string_t set;
6262 cmdline_fixed_string_t bonding;
6263 cmdline_fixed_string_t primary;
6268 static void cmd_set_bonding_primary_parsed(void *parsed_result,
6269 __rte_unused struct cmdline *cl,
6270 __rte_unused void *data)
6272 struct cmd_set_bonding_primary_result *res = parsed_result;
6273 portid_t master_port_id = res->port_id;
6274 portid_t slave_port_id = res->slave_id;
6276 /* Set the primary slave for a bonded device. */
6277 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
6278 fprintf(stderr, "\t Failed to set primary slave for port = %d.\n",
6285 cmdline_parse_token_string_t cmd_setbonding_primary_set =
6286 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6288 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
6289 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6290 bonding, "bonding");
6291 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
6292 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
6293 primary, "primary");
6294 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
6295 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6296 slave_id, RTE_UINT16);
6297 cmdline_parse_token_num_t cmd_setbonding_primary_port =
6298 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
6299 port_id, RTE_UINT16);
6301 cmdline_parse_inst_t cmd_set_bonding_primary = {
6302 .f = cmd_set_bonding_primary_parsed,
6303 .help_str = "set bonding primary <slave_id> <port_id>: "
6304 "Set the primary slave for port_id",
6307 (void *)&cmd_setbonding_primary_set,
6308 (void *)&cmd_setbonding_primary_bonding,
6309 (void *)&cmd_setbonding_primary_primary,
6310 (void *)&cmd_setbonding_primary_slave,
6311 (void *)&cmd_setbonding_primary_port,
6316 /* *** ADD SLAVE *** */
6317 struct cmd_add_bonding_slave_result {
6318 cmdline_fixed_string_t add;
6319 cmdline_fixed_string_t bonding;
6320 cmdline_fixed_string_t slave;
6325 static void cmd_add_bonding_slave_parsed(void *parsed_result,
6326 __rte_unused struct cmdline *cl,
6327 __rte_unused void *data)
6329 struct cmd_add_bonding_slave_result *res = parsed_result;
6330 portid_t master_port_id = res->port_id;
6331 portid_t slave_port_id = res->slave_id;
6333 /* add the slave for a bonded device. */
6334 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
6336 "\t Failed to add slave %d to master port = %d.\n",
6337 slave_port_id, master_port_id);
6341 set_port_slave_flag(slave_port_id);
6344 cmdline_parse_token_string_t cmd_addbonding_slave_add =
6345 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6347 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
6348 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6349 bonding, "bonding");
6350 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
6351 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
6353 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
6354 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6355 slave_id, RTE_UINT16);
6356 cmdline_parse_token_num_t cmd_addbonding_slave_port =
6357 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
6358 port_id, RTE_UINT16);
6360 cmdline_parse_inst_t cmd_add_bonding_slave = {
6361 .f = cmd_add_bonding_slave_parsed,
6362 .help_str = "add bonding slave <slave_id> <port_id>: "
6363 "Add a slave device to a bonded device",
6366 (void *)&cmd_addbonding_slave_add,
6367 (void *)&cmd_addbonding_slave_bonding,
6368 (void *)&cmd_addbonding_slave_slave,
6369 (void *)&cmd_addbonding_slave_slaveid,
6370 (void *)&cmd_addbonding_slave_port,
6375 /* *** REMOVE SLAVE *** */
6376 struct cmd_remove_bonding_slave_result {
6377 cmdline_fixed_string_t remove;
6378 cmdline_fixed_string_t bonding;
6379 cmdline_fixed_string_t slave;
6384 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
6385 __rte_unused struct cmdline *cl,
6386 __rte_unused void *data)
6388 struct cmd_remove_bonding_slave_result *res = parsed_result;
6389 portid_t master_port_id = res->port_id;
6390 portid_t slave_port_id = res->slave_id;
6392 /* remove the slave from a bonded device. */
6393 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
6395 "\t Failed to remove slave %d from master port = %d.\n",
6396 slave_port_id, master_port_id);
6400 clear_port_slave_flag(slave_port_id);
6403 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
6404 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6406 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
6407 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6408 bonding, "bonding");
6409 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
6410 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
6412 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
6413 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6414 slave_id, RTE_UINT16);
6415 cmdline_parse_token_num_t cmd_removebonding_slave_port =
6416 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
6417 port_id, RTE_UINT16);
6419 cmdline_parse_inst_t cmd_remove_bonding_slave = {
6420 .f = cmd_remove_bonding_slave_parsed,
6421 .help_str = "remove bonding slave <slave_id> <port_id>: "
6422 "Remove a slave device from a bonded device",
6425 (void *)&cmd_removebonding_slave_remove,
6426 (void *)&cmd_removebonding_slave_bonding,
6427 (void *)&cmd_removebonding_slave_slave,
6428 (void *)&cmd_removebonding_slave_slaveid,
6429 (void *)&cmd_removebonding_slave_port,
6434 /* *** CREATE BONDED DEVICE *** */
6435 struct cmd_create_bonded_device_result {
6436 cmdline_fixed_string_t create;
6437 cmdline_fixed_string_t bonded;
6438 cmdline_fixed_string_t device;
6443 static int bond_dev_num = 0;
6445 static void cmd_create_bonded_device_parsed(void *parsed_result,
6446 __rte_unused struct cmdline *cl,
6447 __rte_unused void *data)
6449 struct cmd_create_bonded_device_result *res = parsed_result;
6450 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
6454 if (test_done == 0) {
6455 fprintf(stderr, "Please stop forwarding first\n");
6459 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
6462 /* Create a new bonded device. */
6463 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
6465 fprintf(stderr, "\t Failed to create bonded device.\n");
6468 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
6471 /* Update number of ports */
6472 nb_ports = rte_eth_dev_count_avail();
6473 reconfig(port_id, res->socket);
6474 ret = rte_eth_promiscuous_enable(port_id);
6477 "Failed to enable promiscuous mode for port %u: %s - ignore\n",
6478 port_id, rte_strerror(-ret));
6480 ports[port_id].need_setup = 0;
6481 ports[port_id].port_status = RTE_PORT_STOPPED;
6486 cmdline_parse_token_string_t cmd_createbonded_device_create =
6487 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6489 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
6490 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6492 cmdline_parse_token_string_t cmd_createbonded_device_device =
6493 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
6495 cmdline_parse_token_num_t cmd_createbonded_device_mode =
6496 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6498 cmdline_parse_token_num_t cmd_createbonded_device_socket =
6499 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
6502 cmdline_parse_inst_t cmd_create_bonded_device = {
6503 .f = cmd_create_bonded_device_parsed,
6504 .help_str = "create bonded device <mode> <socket>: "
6505 "Create a new bonded device with specific bonding mode and socket",
6508 (void *)&cmd_createbonded_device_create,
6509 (void *)&cmd_createbonded_device_bonded,
6510 (void *)&cmd_createbonded_device_device,
6511 (void *)&cmd_createbonded_device_mode,
6512 (void *)&cmd_createbonded_device_socket,
6517 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
6518 struct cmd_set_bond_mac_addr_result {
6519 cmdline_fixed_string_t set;
6520 cmdline_fixed_string_t bonding;
6521 cmdline_fixed_string_t mac_addr;
6523 struct rte_ether_addr address;
6526 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
6527 __rte_unused struct cmdline *cl,
6528 __rte_unused void *data)
6530 struct cmd_set_bond_mac_addr_result *res = parsed_result;
6533 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
6536 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
6538 /* check the return value and print it if is < 0 */
6540 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6544 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
6545 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
6546 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
6547 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
6549 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
6550 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
6552 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
6553 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
6554 port_num, RTE_UINT16);
6555 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
6556 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
6558 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
6559 .f = cmd_set_bond_mac_addr_parsed,
6561 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
6563 (void *)&cmd_set_bond_mac_addr_set,
6564 (void *)&cmd_set_bond_mac_addr_bonding,
6565 (void *)&cmd_set_bond_mac_addr_mac,
6566 (void *)&cmd_set_bond_mac_addr_portnum,
6567 (void *)&cmd_set_bond_mac_addr_addr,
6573 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
6574 struct cmd_set_bond_mon_period_result {
6575 cmdline_fixed_string_t set;
6576 cmdline_fixed_string_t bonding;
6577 cmdline_fixed_string_t mon_period;
6582 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
6583 __rte_unused struct cmdline *cl,
6584 __rte_unused void *data)
6586 struct cmd_set_bond_mon_period_result *res = parsed_result;
6589 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
6591 /* check the return value and print it if is < 0 */
6593 fprintf(stderr, "set_bond_mac_addr error: (%s)\n",
6597 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
6598 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6600 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
6601 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6602 bonding, "bonding");
6603 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
6604 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
6605 mon_period, "mon_period");
6606 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
6607 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6608 port_num, RTE_UINT16);
6609 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
6610 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
6611 period_ms, RTE_UINT32);
6613 cmdline_parse_inst_t cmd_set_bond_mon_period = {
6614 .f = cmd_set_bond_mon_period_parsed,
6616 .help_str = "set bonding mon_period <port_id> <period_ms>",
6618 (void *)&cmd_set_bond_mon_period_set,
6619 (void *)&cmd_set_bond_mon_period_bonding,
6620 (void *)&cmd_set_bond_mon_period_mon_period,
6621 (void *)&cmd_set_bond_mon_period_portnum,
6622 (void *)&cmd_set_bond_mon_period_period_ms,
6629 struct cmd_set_bonding_agg_mode_policy_result {
6630 cmdline_fixed_string_t set;
6631 cmdline_fixed_string_t bonding;
6632 cmdline_fixed_string_t agg_mode;
6634 cmdline_fixed_string_t policy;
6639 cmd_set_bonding_agg_mode(void *parsed_result,
6640 __rte_unused struct cmdline *cl,
6641 __rte_unused void *data)
6643 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
6644 uint8_t policy = AGG_BANDWIDTH;
6646 if (!strcmp(res->policy, "bandwidth"))
6647 policy = AGG_BANDWIDTH;
6648 else if (!strcmp(res->policy, "stable"))
6649 policy = AGG_STABLE;
6650 else if (!strcmp(res->policy, "count"))
6653 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6657 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6658 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6660 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6661 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6662 bonding, "bonding");
6664 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6665 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6666 agg_mode, "agg_mode");
6668 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6669 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6670 port_num, RTE_UINT16);
6672 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6673 TOKEN_STRING_INITIALIZER(
6674 struct cmd_set_bonding_balance_xmit_policy_result,
6675 policy, "stable#bandwidth#count");
6677 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6678 .f = cmd_set_bonding_agg_mode,
6680 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6682 (void *)&cmd_set_bonding_agg_mode_set,
6683 (void *)&cmd_set_bonding_agg_mode_bonding,
6684 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6685 (void *)&cmd_set_bonding_agg_mode_portnum,
6686 (void *)&cmd_set_bonding_agg_mode_policy_string,
6692 #endif /* RTE_NET_BOND */
6694 /* *** SET FORWARDING MODE *** */
6695 struct cmd_set_fwd_mode_result {
6696 cmdline_fixed_string_t set;
6697 cmdline_fixed_string_t fwd;
6698 cmdline_fixed_string_t mode;
6701 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6702 __rte_unused struct cmdline *cl,
6703 __rte_unused void *data)
6705 struct cmd_set_fwd_mode_result *res = parsed_result;
6708 set_pkt_forwarding_mode(res->mode);
6711 cmdline_parse_token_string_t cmd_setfwd_set =
6712 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6713 cmdline_parse_token_string_t cmd_setfwd_fwd =
6714 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6715 cmdline_parse_token_string_t cmd_setfwd_mode =
6716 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6717 "" /* defined at init */);
6719 cmdline_parse_inst_t cmd_set_fwd_mode = {
6720 .f = cmd_set_fwd_mode_parsed,
6722 .help_str = NULL, /* defined at init */
6724 (void *)&cmd_setfwd_set,
6725 (void *)&cmd_setfwd_fwd,
6726 (void *)&cmd_setfwd_mode,
6731 static void cmd_set_fwd_mode_init(void)
6734 static char token[128];
6735 static char help[256];
6736 cmdline_parse_token_string_t *token_struct;
6738 modes = list_pkt_forwarding_modes();
6739 snprintf(help, sizeof(help), "set fwd %s: "
6740 "Set packet forwarding mode", modes);
6741 cmd_set_fwd_mode.help_str = help;
6743 /* string token separator is # */
6744 for (c = token; *modes != '\0'; modes++)
6749 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6750 token_struct->string_data.str = token;
6753 /* *** SET RETRY FORWARDING MODE *** */
6754 struct cmd_set_fwd_retry_mode_result {
6755 cmdline_fixed_string_t set;
6756 cmdline_fixed_string_t fwd;
6757 cmdline_fixed_string_t mode;
6758 cmdline_fixed_string_t retry;
6761 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6762 __rte_unused struct cmdline *cl,
6763 __rte_unused void *data)
6765 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6768 set_pkt_forwarding_mode(res->mode);
6771 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6772 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6774 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6775 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6777 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6778 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6780 "" /* defined at init */);
6781 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6782 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6785 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6786 .f = cmd_set_fwd_retry_mode_parsed,
6788 .help_str = NULL, /* defined at init */
6790 (void *)&cmd_setfwd_retry_set,
6791 (void *)&cmd_setfwd_retry_fwd,
6792 (void *)&cmd_setfwd_retry_mode,
6793 (void *)&cmd_setfwd_retry_retry,
6798 static void cmd_set_fwd_retry_mode_init(void)
6801 static char token[128];
6802 static char help[256];
6803 cmdline_parse_token_string_t *token_struct;
6805 modes = list_pkt_forwarding_retry_modes();
6806 snprintf(help, sizeof(help), "set fwd %s retry: "
6807 "Set packet forwarding mode with retry", modes);
6808 cmd_set_fwd_retry_mode.help_str = help;
6810 /* string token separator is # */
6811 for (c = token; *modes != '\0'; modes++)
6816 token_struct = (cmdline_parse_token_string_t *)
6817 cmd_set_fwd_retry_mode.tokens[2];
6818 token_struct->string_data.str = token;
6821 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6822 struct cmd_set_burst_tx_retry_result {
6823 cmdline_fixed_string_t set;
6824 cmdline_fixed_string_t burst;
6825 cmdline_fixed_string_t tx;
6826 cmdline_fixed_string_t delay;
6828 cmdline_fixed_string_t retry;
6832 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6833 __rte_unused struct cmdline *cl,
6834 __rte_unused void *data)
6836 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6838 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6839 && !strcmp(res->tx, "tx")) {
6840 if (!strcmp(res->delay, "delay"))
6841 burst_tx_delay_time = res->time;
6842 if (!strcmp(res->retry, "retry"))
6843 burst_tx_retry_num = res->retry_num;
6848 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6849 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6850 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6851 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6853 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6854 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6855 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6856 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6857 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6858 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
6860 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6861 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6862 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6863 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
6866 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6867 .f = cmd_set_burst_tx_retry_parsed,
6868 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6870 (void *)&cmd_set_burst_tx_retry_set,
6871 (void *)&cmd_set_burst_tx_retry_burst,
6872 (void *)&cmd_set_burst_tx_retry_tx,
6873 (void *)&cmd_set_burst_tx_retry_delay,
6874 (void *)&cmd_set_burst_tx_retry_time,
6875 (void *)&cmd_set_burst_tx_retry_retry,
6876 (void *)&cmd_set_burst_tx_retry_retry_num,
6881 /* *** SET PROMISC MODE *** */
6882 struct cmd_set_promisc_mode_result {
6883 cmdline_fixed_string_t set;
6884 cmdline_fixed_string_t promisc;
6885 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6886 uint16_t port_num; /* valid if "allports" argument == 0 */
6887 cmdline_fixed_string_t mode;
6890 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6891 __rte_unused struct cmdline *cl,
6894 struct cmd_set_promisc_mode_result *res = parsed_result;
6898 if (!strcmp(res->mode, "on"))
6905 RTE_ETH_FOREACH_DEV(i)
6906 eth_set_promisc_mode(i, enable);
6908 eth_set_promisc_mode(res->port_num, enable);
6912 cmdline_parse_token_string_t cmd_setpromisc_set =
6913 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6914 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6915 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6917 cmdline_parse_token_string_t cmd_setpromisc_portall =
6918 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6920 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6921 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6923 cmdline_parse_token_string_t cmd_setpromisc_mode =
6924 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6927 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6928 .f = cmd_set_promisc_mode_parsed,
6930 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6932 (void *)&cmd_setpromisc_set,
6933 (void *)&cmd_setpromisc_promisc,
6934 (void *)&cmd_setpromisc_portall,
6935 (void *)&cmd_setpromisc_mode,
6940 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6941 .f = cmd_set_promisc_mode_parsed,
6943 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6945 (void *)&cmd_setpromisc_set,
6946 (void *)&cmd_setpromisc_promisc,
6947 (void *)&cmd_setpromisc_portnum,
6948 (void *)&cmd_setpromisc_mode,
6953 /* *** SET ALLMULTI MODE *** */
6954 struct cmd_set_allmulti_mode_result {
6955 cmdline_fixed_string_t set;
6956 cmdline_fixed_string_t allmulti;
6957 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6958 uint16_t port_num; /* valid if "allports" argument == 0 */
6959 cmdline_fixed_string_t mode;
6962 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6963 __rte_unused struct cmdline *cl,
6966 struct cmd_set_allmulti_mode_result *res = parsed_result;
6970 if (!strcmp(res->mode, "on"))
6977 RTE_ETH_FOREACH_DEV(i) {
6978 eth_set_allmulticast_mode(i, enable);
6982 eth_set_allmulticast_mode(res->port_num, enable);
6986 cmdline_parse_token_string_t cmd_setallmulti_set =
6987 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6988 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6989 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6991 cmdline_parse_token_string_t cmd_setallmulti_portall =
6992 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6994 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6995 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6997 cmdline_parse_token_string_t cmd_setallmulti_mode =
6998 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
7001 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
7002 .f = cmd_set_allmulti_mode_parsed,
7004 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
7006 (void *)&cmd_setallmulti_set,
7007 (void *)&cmd_setallmulti_allmulti,
7008 (void *)&cmd_setallmulti_portall,
7009 (void *)&cmd_setallmulti_mode,
7014 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
7015 .f = cmd_set_allmulti_mode_parsed,
7017 .help_str = "set allmulti <port_id> on|off: "
7018 "Set allmulti mode on port_id",
7020 (void *)&cmd_setallmulti_set,
7021 (void *)&cmd_setallmulti_allmulti,
7022 (void *)&cmd_setallmulti_portnum,
7023 (void *)&cmd_setallmulti_mode,
7028 /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
7029 struct cmd_link_flow_ctrl_show {
7030 cmdline_fixed_string_t show;
7031 cmdline_fixed_string_t port;
7033 cmdline_fixed_string_t flow_ctrl;
7036 cmdline_parse_token_string_t cmd_lfc_show_show =
7037 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7039 cmdline_parse_token_string_t cmd_lfc_show_port =
7040 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7042 cmdline_parse_token_num_t cmd_lfc_show_portid =
7043 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
7044 port_id, RTE_UINT16);
7045 cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
7046 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
7047 flow_ctrl, "flow_ctrl");
7050 cmd_link_flow_ctrl_show_parsed(void *parsed_result,
7051 __rte_unused struct cmdline *cl,
7052 __rte_unused void *data)
7054 struct cmd_link_flow_ctrl_show *res = parsed_result;
7055 static const char *info_border = "*********************";
7056 struct rte_eth_fc_conf fc_conf;
7057 bool rx_fc_en = false;
7058 bool tx_fc_en = false;
7061 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7064 "Failed to get current flow ctrl information: err = %d\n",
7069 if (fc_conf.mode == RTE_FC_RX_PAUSE || fc_conf.mode == RTE_FC_FULL)
7071 if (fc_conf.mode == RTE_FC_TX_PAUSE || fc_conf.mode == RTE_FC_FULL)
7074 printf("\n%s Flow control infos for port %-2d %s\n",
7075 info_border, res->port_id, info_border);
7076 printf("FC mode:\n");
7077 printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
7078 printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
7079 printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
7080 printf("Pause time: 0x%x\n", fc_conf.pause_time);
7081 printf("High waterline: 0x%x\n", fc_conf.high_water);
7082 printf("Low waterline: 0x%x\n", fc_conf.low_water);
7083 printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
7084 printf("Forward MAC control frames: %s\n",
7085 fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
7086 printf("\n%s************** End ***********%s\n",
7087 info_border, info_border);
7090 cmdline_parse_inst_t cmd_link_flow_control_show = {
7091 .f = cmd_link_flow_ctrl_show_parsed,
7093 .help_str = "show port <port_id> flow_ctrl",
7095 (void *)&cmd_lfc_show_show,
7096 (void *)&cmd_lfc_show_port,
7097 (void *)&cmd_lfc_show_portid,
7098 (void *)&cmd_lfc_show_flow_ctrl,
7103 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
7104 struct cmd_link_flow_ctrl_set_result {
7105 cmdline_fixed_string_t set;
7106 cmdline_fixed_string_t flow_ctrl;
7107 cmdline_fixed_string_t rx;
7108 cmdline_fixed_string_t rx_lfc_mode;
7109 cmdline_fixed_string_t tx;
7110 cmdline_fixed_string_t tx_lfc_mode;
7111 cmdline_fixed_string_t mac_ctrl_frame_fwd;
7112 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
7113 cmdline_fixed_string_t autoneg_str;
7114 cmdline_fixed_string_t autoneg;
7115 cmdline_fixed_string_t hw_str;
7116 uint32_t high_water;
7117 cmdline_fixed_string_t lw_str;
7119 cmdline_fixed_string_t pt_str;
7120 uint16_t pause_time;
7121 cmdline_fixed_string_t xon_str;
7126 cmdline_parse_token_string_t cmd_lfc_set_set =
7127 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7129 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
7130 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7131 flow_ctrl, "flow_ctrl");
7132 cmdline_parse_token_string_t cmd_lfc_set_rx =
7133 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7135 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
7136 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7137 rx_lfc_mode, "on#off");
7138 cmdline_parse_token_string_t cmd_lfc_set_tx =
7139 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7141 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
7142 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7143 tx_lfc_mode, "on#off");
7144 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
7145 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7146 hw_str, "high_water");
7147 cmdline_parse_token_num_t cmd_lfc_set_high_water =
7148 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7149 high_water, RTE_UINT32);
7150 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
7151 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7152 lw_str, "low_water");
7153 cmdline_parse_token_num_t cmd_lfc_set_low_water =
7154 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7155 low_water, RTE_UINT32);
7156 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
7157 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7158 pt_str, "pause_time");
7159 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
7160 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7161 pause_time, RTE_UINT16);
7162 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
7163 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7164 xon_str, "send_xon");
7165 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
7166 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7167 send_xon, RTE_UINT16);
7168 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
7169 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7170 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
7171 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
7172 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7173 mac_ctrl_frame_fwd_mode, "on#off");
7174 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
7175 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7176 autoneg_str, "autoneg");
7177 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
7178 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7180 cmdline_parse_token_num_t cmd_lfc_set_portid =
7181 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
7182 port_id, RTE_UINT16);
7184 /* forward declaration */
7186 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
7189 cmdline_parse_inst_t cmd_link_flow_control_set = {
7190 .f = cmd_link_flow_ctrl_set_parsed,
7192 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
7193 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
7194 "autoneg on|off <port_id>: Configure the Ethernet flow control",
7196 (void *)&cmd_lfc_set_set,
7197 (void *)&cmd_lfc_set_flow_ctrl,
7198 (void *)&cmd_lfc_set_rx,
7199 (void *)&cmd_lfc_set_rx_mode,
7200 (void *)&cmd_lfc_set_tx,
7201 (void *)&cmd_lfc_set_tx_mode,
7202 (void *)&cmd_lfc_set_high_water,
7203 (void *)&cmd_lfc_set_low_water,
7204 (void *)&cmd_lfc_set_pause_time,
7205 (void *)&cmd_lfc_set_send_xon,
7206 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7207 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7208 (void *)&cmd_lfc_set_autoneg_str,
7209 (void *)&cmd_lfc_set_autoneg,
7210 (void *)&cmd_lfc_set_portid,
7215 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
7216 .f = cmd_link_flow_ctrl_set_parsed,
7217 .data = (void *)&cmd_link_flow_control_set_rx,
7218 .help_str = "set flow_ctrl rx on|off <port_id>: "
7219 "Change rx flow control parameter",
7221 (void *)&cmd_lfc_set_set,
7222 (void *)&cmd_lfc_set_flow_ctrl,
7223 (void *)&cmd_lfc_set_rx,
7224 (void *)&cmd_lfc_set_rx_mode,
7225 (void *)&cmd_lfc_set_portid,
7230 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
7231 .f = cmd_link_flow_ctrl_set_parsed,
7232 .data = (void *)&cmd_link_flow_control_set_tx,
7233 .help_str = "set flow_ctrl tx on|off <port_id>: "
7234 "Change tx flow control parameter",
7236 (void *)&cmd_lfc_set_set,
7237 (void *)&cmd_lfc_set_flow_ctrl,
7238 (void *)&cmd_lfc_set_tx,
7239 (void *)&cmd_lfc_set_tx_mode,
7240 (void *)&cmd_lfc_set_portid,
7245 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
7246 .f = cmd_link_flow_ctrl_set_parsed,
7247 .data = (void *)&cmd_link_flow_control_set_hw,
7248 .help_str = "set flow_ctrl high_water <value> <port_id>: "
7249 "Change high water flow control parameter",
7251 (void *)&cmd_lfc_set_set,
7252 (void *)&cmd_lfc_set_flow_ctrl,
7253 (void *)&cmd_lfc_set_high_water_str,
7254 (void *)&cmd_lfc_set_high_water,
7255 (void *)&cmd_lfc_set_portid,
7260 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
7261 .f = cmd_link_flow_ctrl_set_parsed,
7262 .data = (void *)&cmd_link_flow_control_set_lw,
7263 .help_str = "set flow_ctrl low_water <value> <port_id>: "
7264 "Change low water flow control parameter",
7266 (void *)&cmd_lfc_set_set,
7267 (void *)&cmd_lfc_set_flow_ctrl,
7268 (void *)&cmd_lfc_set_low_water_str,
7269 (void *)&cmd_lfc_set_low_water,
7270 (void *)&cmd_lfc_set_portid,
7275 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
7276 .f = cmd_link_flow_ctrl_set_parsed,
7277 .data = (void *)&cmd_link_flow_control_set_pt,
7278 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
7279 "Change pause time flow control parameter",
7281 (void *)&cmd_lfc_set_set,
7282 (void *)&cmd_lfc_set_flow_ctrl,
7283 (void *)&cmd_lfc_set_pause_time_str,
7284 (void *)&cmd_lfc_set_pause_time,
7285 (void *)&cmd_lfc_set_portid,
7290 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
7291 .f = cmd_link_flow_ctrl_set_parsed,
7292 .data = (void *)&cmd_link_flow_control_set_xon,
7293 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
7294 "Change send_xon flow control parameter",
7296 (void *)&cmd_lfc_set_set,
7297 (void *)&cmd_lfc_set_flow_ctrl,
7298 (void *)&cmd_lfc_set_send_xon_str,
7299 (void *)&cmd_lfc_set_send_xon,
7300 (void *)&cmd_lfc_set_portid,
7305 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
7306 .f = cmd_link_flow_ctrl_set_parsed,
7307 .data = (void *)&cmd_link_flow_control_set_macfwd,
7308 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
7309 "Change mac ctrl fwd flow control parameter",
7311 (void *)&cmd_lfc_set_set,
7312 (void *)&cmd_lfc_set_flow_ctrl,
7313 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
7314 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
7315 (void *)&cmd_lfc_set_portid,
7320 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
7321 .f = cmd_link_flow_ctrl_set_parsed,
7322 .data = (void *)&cmd_link_flow_control_set_autoneg,
7323 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
7324 "Change autoneg flow control parameter",
7326 (void *)&cmd_lfc_set_set,
7327 (void *)&cmd_lfc_set_flow_ctrl,
7328 (void *)&cmd_lfc_set_autoneg_str,
7329 (void *)&cmd_lfc_set_autoneg,
7330 (void *)&cmd_lfc_set_portid,
7336 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
7337 __rte_unused struct cmdline *cl,
7340 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
7341 cmdline_parse_inst_t *cmd = data;
7342 struct rte_eth_fc_conf fc_conf;
7348 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7349 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7350 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7351 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7353 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7354 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7357 /* Partial command line, retrieve current configuration */
7359 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7362 "cannot get current flow ctrl parameters, return code = %d\n",
7367 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
7368 (fc_conf.mode == RTE_FC_FULL))
7370 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
7371 (fc_conf.mode == RTE_FC_FULL))
7375 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7376 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7378 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7379 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7381 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7383 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7384 fc_conf.high_water = res->high_water;
7386 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7387 fc_conf.low_water = res->low_water;
7389 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7390 fc_conf.pause_time = res->pause_time;
7392 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7393 fc_conf.send_xon = res->send_xon;
7395 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7396 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7397 fc_conf.mac_ctrl_frame_fwd = 1;
7399 fc_conf.mac_ctrl_frame_fwd = 0;
7402 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7403 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7405 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7408 "bad flow control parameter, return code = %d\n",
7412 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7413 struct cmd_priority_flow_ctrl_set_result {
7414 cmdline_fixed_string_t set;
7415 cmdline_fixed_string_t pfc_ctrl;
7416 cmdline_fixed_string_t rx;
7417 cmdline_fixed_string_t rx_pfc_mode;
7418 cmdline_fixed_string_t tx;
7419 cmdline_fixed_string_t tx_pfc_mode;
7420 uint32_t high_water;
7422 uint16_t pause_time;
7428 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7429 __rte_unused struct cmdline *cl,
7430 __rte_unused void *data)
7432 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7433 struct rte_eth_pfc_conf pfc_conf;
7434 int rx_fc_enable, tx_fc_enable;
7438 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7439 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7440 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7441 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7443 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7444 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
7447 memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7448 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7449 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7450 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7451 pfc_conf.fc.high_water = res->high_water;
7452 pfc_conf.fc.low_water = res->low_water;
7453 pfc_conf.fc.pause_time = res->pause_time;
7454 pfc_conf.priority = res->priority;
7456 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7459 "bad priority flow control parameter, return code = %d\n",
7463 cmdline_parse_token_string_t cmd_pfc_set_set =
7464 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7466 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7467 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7468 pfc_ctrl, "pfc_ctrl");
7469 cmdline_parse_token_string_t cmd_pfc_set_rx =
7470 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7472 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7473 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7474 rx_pfc_mode, "on#off");
7475 cmdline_parse_token_string_t cmd_pfc_set_tx =
7476 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7478 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7479 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7480 tx_pfc_mode, "on#off");
7481 cmdline_parse_token_num_t cmd_pfc_set_high_water =
7482 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7483 high_water, RTE_UINT32);
7484 cmdline_parse_token_num_t cmd_pfc_set_low_water =
7485 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7486 low_water, RTE_UINT32);
7487 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7488 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7489 pause_time, RTE_UINT16);
7490 cmdline_parse_token_num_t cmd_pfc_set_priority =
7491 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7492 priority, RTE_UINT8);
7493 cmdline_parse_token_num_t cmd_pfc_set_portid =
7494 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7495 port_id, RTE_UINT16);
7497 cmdline_parse_inst_t cmd_priority_flow_control_set = {
7498 .f = cmd_priority_flow_ctrl_set_parsed,
7500 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7501 "<pause_time> <priority> <port_id>: "
7502 "Configure the Ethernet priority flow control",
7504 (void *)&cmd_pfc_set_set,
7505 (void *)&cmd_pfc_set_flow_ctrl,
7506 (void *)&cmd_pfc_set_rx,
7507 (void *)&cmd_pfc_set_rx_mode,
7508 (void *)&cmd_pfc_set_tx,
7509 (void *)&cmd_pfc_set_tx_mode,
7510 (void *)&cmd_pfc_set_high_water,
7511 (void *)&cmd_pfc_set_low_water,
7512 (void *)&cmd_pfc_set_pause_time,
7513 (void *)&cmd_pfc_set_priority,
7514 (void *)&cmd_pfc_set_portid,
7519 /* *** RESET CONFIGURATION *** */
7520 struct cmd_reset_result {
7521 cmdline_fixed_string_t reset;
7522 cmdline_fixed_string_t def;
7525 static void cmd_reset_parsed(__rte_unused void *parsed_result,
7527 __rte_unused void *data)
7529 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7530 set_def_fwd_config();
7533 cmdline_parse_token_string_t cmd_reset_set =
7534 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7535 cmdline_parse_token_string_t cmd_reset_def =
7536 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7539 cmdline_parse_inst_t cmd_reset = {
7540 .f = cmd_reset_parsed,
7542 .help_str = "set default: Reset default forwarding configuration",
7544 (void *)&cmd_reset_set,
7545 (void *)&cmd_reset_def,
7550 /* *** START FORWARDING *** */
7551 struct cmd_start_result {
7552 cmdline_fixed_string_t start;
7555 cmdline_parse_token_string_t cmd_start_start =
7556 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7558 static void cmd_start_parsed(__rte_unused void *parsed_result,
7559 __rte_unused struct cmdline *cl,
7560 __rte_unused void *data)
7562 start_packet_forwarding(0);
7565 cmdline_parse_inst_t cmd_start = {
7566 .f = cmd_start_parsed,
7568 .help_str = "start: Start packet forwarding",
7570 (void *)&cmd_start_start,
7575 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7576 struct cmd_start_tx_first_result {
7577 cmdline_fixed_string_t start;
7578 cmdline_fixed_string_t tx_first;
7582 cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7583 __rte_unused struct cmdline *cl,
7584 __rte_unused void *data)
7586 start_packet_forwarding(1);
7589 cmdline_parse_token_string_t cmd_start_tx_first_start =
7590 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7592 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7593 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7594 tx_first, "tx_first");
7596 cmdline_parse_inst_t cmd_start_tx_first = {
7597 .f = cmd_start_tx_first_parsed,
7599 .help_str = "start tx_first: Start packet forwarding, "
7600 "after sending 1 burst of packets",
7602 (void *)&cmd_start_tx_first_start,
7603 (void *)&cmd_start_tx_first_tx_first,
7608 /* *** START FORWARDING WITH N TX BURST FIRST *** */
7609 struct cmd_start_tx_first_n_result {
7610 cmdline_fixed_string_t start;
7611 cmdline_fixed_string_t tx_first;
7616 cmd_start_tx_first_n_parsed(void *parsed_result,
7617 __rte_unused struct cmdline *cl,
7618 __rte_unused void *data)
7620 struct cmd_start_tx_first_n_result *res = parsed_result;
7622 start_packet_forwarding(res->tx_num);
7625 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7626 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7628 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7629 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7630 tx_first, "tx_first");
7631 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7632 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7633 tx_num, RTE_UINT32);
7635 cmdline_parse_inst_t cmd_start_tx_first_n = {
7636 .f = cmd_start_tx_first_n_parsed,
7638 .help_str = "start tx_first <num>: "
7639 "packet forwarding, after sending <num> bursts of packets",
7641 (void *)&cmd_start_tx_first_n_start,
7642 (void *)&cmd_start_tx_first_n_tx_first,
7643 (void *)&cmd_start_tx_first_n_tx_num,
7648 /* *** SET LINK UP *** */
7649 struct cmd_set_link_up_result {
7650 cmdline_fixed_string_t set;
7651 cmdline_fixed_string_t link_up;
7652 cmdline_fixed_string_t port;
7656 cmdline_parse_token_string_t cmd_set_link_up_set =
7657 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7658 cmdline_parse_token_string_t cmd_set_link_up_link_up =
7659 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7661 cmdline_parse_token_string_t cmd_set_link_up_port =
7662 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7663 cmdline_parse_token_num_t cmd_set_link_up_port_id =
7664 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7667 static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7668 __rte_unused struct cmdline *cl,
7669 __rte_unused void *data)
7671 struct cmd_set_link_up_result *res = parsed_result;
7672 dev_set_link_up(res->port_id);
7675 cmdline_parse_inst_t cmd_set_link_up = {
7676 .f = cmd_set_link_up_parsed,
7678 .help_str = "set link-up port <port id>",
7680 (void *)&cmd_set_link_up_set,
7681 (void *)&cmd_set_link_up_link_up,
7682 (void *)&cmd_set_link_up_port,
7683 (void *)&cmd_set_link_up_port_id,
7688 /* *** SET LINK DOWN *** */
7689 struct cmd_set_link_down_result {
7690 cmdline_fixed_string_t set;
7691 cmdline_fixed_string_t link_down;
7692 cmdline_fixed_string_t port;
7696 cmdline_parse_token_string_t cmd_set_link_down_set =
7697 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7698 cmdline_parse_token_string_t cmd_set_link_down_link_down =
7699 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7701 cmdline_parse_token_string_t cmd_set_link_down_port =
7702 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7703 cmdline_parse_token_num_t cmd_set_link_down_port_id =
7704 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7707 static void cmd_set_link_down_parsed(
7708 __rte_unused void *parsed_result,
7709 __rte_unused struct cmdline *cl,
7710 __rte_unused void *data)
7712 struct cmd_set_link_down_result *res = parsed_result;
7713 dev_set_link_down(res->port_id);
7716 cmdline_parse_inst_t cmd_set_link_down = {
7717 .f = cmd_set_link_down_parsed,
7719 .help_str = "set link-down port <port id>",
7721 (void *)&cmd_set_link_down_set,
7722 (void *)&cmd_set_link_down_link_down,
7723 (void *)&cmd_set_link_down_port,
7724 (void *)&cmd_set_link_down_port_id,
7729 /* *** SHOW CFG *** */
7730 struct cmd_showcfg_result {
7731 cmdline_fixed_string_t show;
7732 cmdline_fixed_string_t cfg;
7733 cmdline_fixed_string_t what;
7736 static void cmd_showcfg_parsed(void *parsed_result,
7737 __rte_unused struct cmdline *cl,
7738 __rte_unused void *data)
7740 struct cmd_showcfg_result *res = parsed_result;
7741 if (!strcmp(res->what, "rxtx"))
7742 rxtx_config_display();
7743 else if (!strcmp(res->what, "cores"))
7744 fwd_lcores_config_display();
7745 else if (!strcmp(res->what, "fwd"))
7746 pkt_fwd_config_display(&cur_fwd_config);
7747 else if (!strcmp(res->what, "rxoffs"))
7748 show_rx_pkt_offsets();
7749 else if (!strcmp(res->what, "rxpkts"))
7750 show_rx_pkt_segments();
7751 else if (!strcmp(res->what, "txpkts"))
7752 show_tx_pkt_segments();
7753 else if (!strcmp(res->what, "txtimes"))
7754 show_tx_pkt_times();
7757 cmdline_parse_token_string_t cmd_showcfg_show =
7758 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7759 cmdline_parse_token_string_t cmd_showcfg_port =
7760 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7761 cmdline_parse_token_string_t cmd_showcfg_what =
7762 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7763 "rxtx#cores#fwd#rxoffs#rxpkts#txpkts#txtimes");
7765 cmdline_parse_inst_t cmd_showcfg = {
7766 .f = cmd_showcfg_parsed,
7768 .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|txpkts|txtimes",
7770 (void *)&cmd_showcfg_show,
7771 (void *)&cmd_showcfg_port,
7772 (void *)&cmd_showcfg_what,
7777 /* *** SHOW ALL PORT INFO *** */
7778 struct cmd_showportall_result {
7779 cmdline_fixed_string_t show;
7780 cmdline_fixed_string_t port;
7781 cmdline_fixed_string_t what;
7782 cmdline_fixed_string_t all;
7785 static void cmd_showportall_parsed(void *parsed_result,
7786 __rte_unused struct cmdline *cl,
7787 __rte_unused void *data)
7791 struct cmd_showportall_result *res = parsed_result;
7792 if (!strcmp(res->show, "clear")) {
7793 if (!strcmp(res->what, "stats"))
7794 RTE_ETH_FOREACH_DEV(i)
7796 else if (!strcmp(res->what, "xstats"))
7797 RTE_ETH_FOREACH_DEV(i)
7798 nic_xstats_clear(i);
7799 } else if (!strcmp(res->what, "info"))
7800 RTE_ETH_FOREACH_DEV(i)
7801 port_infos_display(i);
7802 else if (!strcmp(res->what, "summary")) {
7803 port_summary_header_display();
7804 RTE_ETH_FOREACH_DEV(i)
7805 port_summary_display(i);
7807 else if (!strcmp(res->what, "stats"))
7808 RTE_ETH_FOREACH_DEV(i)
7809 nic_stats_display(i);
7810 else if (!strcmp(res->what, "xstats"))
7811 RTE_ETH_FOREACH_DEV(i)
7812 nic_xstats_display(i);
7813 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7814 else if (!strcmp(res->what, "fdir"))
7815 RTE_ETH_FOREACH_DEV(i)
7818 else if (!strcmp(res->what, "dcb_tc"))
7819 RTE_ETH_FOREACH_DEV(i)
7820 port_dcb_info_display(i);
7823 cmdline_parse_token_string_t cmd_showportall_show =
7824 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7826 cmdline_parse_token_string_t cmd_showportall_port =
7827 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7828 cmdline_parse_token_string_t cmd_showportall_what =
7829 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7830 "info#summary#stats#xstats#fdir#dcb_tc");
7831 cmdline_parse_token_string_t cmd_showportall_all =
7832 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7833 cmdline_parse_inst_t cmd_showportall = {
7834 .f = cmd_showportall_parsed,
7836 .help_str = "show|clear port "
7837 "info|summary|stats|xstats|fdir|dcb_tc all",
7839 (void *)&cmd_showportall_show,
7840 (void *)&cmd_showportall_port,
7841 (void *)&cmd_showportall_what,
7842 (void *)&cmd_showportall_all,
7847 /* *** SHOW PORT INFO *** */
7848 struct cmd_showport_result {
7849 cmdline_fixed_string_t show;
7850 cmdline_fixed_string_t port;
7851 cmdline_fixed_string_t what;
7855 static void cmd_showport_parsed(void *parsed_result,
7856 __rte_unused struct cmdline *cl,
7857 __rte_unused void *data)
7859 struct cmd_showport_result *res = parsed_result;
7860 if (!strcmp(res->show, "clear")) {
7861 if (!strcmp(res->what, "stats"))
7862 nic_stats_clear(res->portnum);
7863 else if (!strcmp(res->what, "xstats"))
7864 nic_xstats_clear(res->portnum);
7865 } else if (!strcmp(res->what, "info"))
7866 port_infos_display(res->portnum);
7867 else if (!strcmp(res->what, "summary")) {
7868 port_summary_header_display();
7869 port_summary_display(res->portnum);
7871 else if (!strcmp(res->what, "stats"))
7872 nic_stats_display(res->portnum);
7873 else if (!strcmp(res->what, "xstats"))
7874 nic_xstats_display(res->portnum);
7875 #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7876 else if (!strcmp(res->what, "fdir"))
7877 fdir_get_infos(res->portnum);
7879 else if (!strcmp(res->what, "dcb_tc"))
7880 port_dcb_info_display(res->portnum);
7883 cmdline_parse_token_string_t cmd_showport_show =
7884 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7886 cmdline_parse_token_string_t cmd_showport_port =
7887 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7888 cmdline_parse_token_string_t cmd_showport_what =
7889 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7890 "info#summary#stats#xstats#fdir#dcb_tc");
7891 cmdline_parse_token_num_t cmd_showport_portnum =
7892 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
7894 cmdline_parse_inst_t cmd_showport = {
7895 .f = cmd_showport_parsed,
7897 .help_str = "show|clear port "
7898 "info|summary|stats|xstats|fdir|dcb_tc "
7901 (void *)&cmd_showport_show,
7902 (void *)&cmd_showport_port,
7903 (void *)&cmd_showport_what,
7904 (void *)&cmd_showport_portnum,
7909 /* *** SHOW DEVICE INFO *** */
7910 struct cmd_showdevice_result {
7911 cmdline_fixed_string_t show;
7912 cmdline_fixed_string_t device;
7913 cmdline_fixed_string_t what;
7914 cmdline_fixed_string_t identifier;
7917 static void cmd_showdevice_parsed(void *parsed_result,
7918 __rte_unused struct cmdline *cl,
7919 __rte_unused void *data)
7921 struct cmd_showdevice_result *res = parsed_result;
7922 if (!strcmp(res->what, "info")) {
7923 if (!strcmp(res->identifier, "all"))
7924 device_infos_display(NULL);
7926 device_infos_display(res->identifier);
7930 cmdline_parse_token_string_t cmd_showdevice_show =
7931 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7933 cmdline_parse_token_string_t cmd_showdevice_device =
7934 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7935 cmdline_parse_token_string_t cmd_showdevice_what =
7936 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7938 cmdline_parse_token_string_t cmd_showdevice_identifier =
7939 TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7942 cmdline_parse_inst_t cmd_showdevice = {
7943 .f = cmd_showdevice_parsed,
7945 .help_str = "show device info <identifier>|all",
7947 (void *)&cmd_showdevice_show,
7948 (void *)&cmd_showdevice_device,
7949 (void *)&cmd_showdevice_what,
7950 (void *)&cmd_showdevice_identifier,
7955 /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7956 struct cmd_showeeprom_result {
7957 cmdline_fixed_string_t show;
7958 cmdline_fixed_string_t port;
7960 cmdline_fixed_string_t type;
7963 static void cmd_showeeprom_parsed(void *parsed_result,
7964 __rte_unused struct cmdline *cl,
7965 __rte_unused void *data)
7967 struct cmd_showeeprom_result *res = parsed_result;
7969 if (!strcmp(res->type, "eeprom"))
7970 port_eeprom_display(res->portnum);
7971 else if (!strcmp(res->type, "module_eeprom"))
7972 port_module_eeprom_display(res->portnum);
7974 fprintf(stderr, "Unknown argument\n");
7977 cmdline_parse_token_string_t cmd_showeeprom_show =
7978 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7979 cmdline_parse_token_string_t cmd_showeeprom_port =
7980 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7981 cmdline_parse_token_num_t cmd_showeeprom_portnum =
7982 TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7984 cmdline_parse_token_string_t cmd_showeeprom_type =
7985 TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7987 cmdline_parse_inst_t cmd_showeeprom = {
7988 .f = cmd_showeeprom_parsed,
7990 .help_str = "show port <port_id> module_eeprom|eeprom",
7992 (void *)&cmd_showeeprom_show,
7993 (void *)&cmd_showeeprom_port,
7994 (void *)&cmd_showeeprom_portnum,
7995 (void *)&cmd_showeeprom_type,
8000 /* *** SHOW QUEUE INFO *** */
8001 struct cmd_showqueue_result {
8002 cmdline_fixed_string_t show;
8003 cmdline_fixed_string_t type;
8004 cmdline_fixed_string_t what;
8010 cmd_showqueue_parsed(void *parsed_result,
8011 __rte_unused struct cmdline *cl,
8012 __rte_unused void *data)
8014 struct cmd_showqueue_result *res = parsed_result;
8016 if (!strcmp(res->type, "rxq"))
8017 rx_queue_infos_display(res->portnum, res->queuenum);
8018 else if (!strcmp(res->type, "txq"))
8019 tx_queue_infos_display(res->portnum, res->queuenum);
8022 cmdline_parse_token_string_t cmd_showqueue_show =
8023 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
8024 cmdline_parse_token_string_t cmd_showqueue_type =
8025 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
8026 cmdline_parse_token_string_t cmd_showqueue_what =
8027 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
8028 cmdline_parse_token_num_t cmd_showqueue_portnum =
8029 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
8031 cmdline_parse_token_num_t cmd_showqueue_queuenum =
8032 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
8035 cmdline_parse_inst_t cmd_showqueue = {
8036 .f = cmd_showqueue_parsed,
8038 .help_str = "show rxq|txq info <port_id> <queue_id>",
8040 (void *)&cmd_showqueue_show,
8041 (void *)&cmd_showqueue_type,
8042 (void *)&cmd_showqueue_what,
8043 (void *)&cmd_showqueue_portnum,
8044 (void *)&cmd_showqueue_queuenum,
8049 /* show/clear fwd engine statistics */
8051 cmdline_fixed_string_t action;
8052 cmdline_fixed_string_t fwd;
8053 cmdline_fixed_string_t stats;
8054 cmdline_fixed_string_t all;
8057 cmdline_parse_token_string_t cmd_fwd_action =
8058 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
8059 cmdline_parse_token_string_t cmd_fwd_fwd =
8060 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
8061 cmdline_parse_token_string_t cmd_fwd_stats =
8062 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
8063 cmdline_parse_token_string_t cmd_fwd_all =
8064 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
8067 cmd_showfwdall_parsed(void *parsed_result,
8068 __rte_unused struct cmdline *cl,
8069 __rte_unused void *data)
8071 struct fwd_result *res = parsed_result;
8073 if (!strcmp(res->action, "show"))
8074 fwd_stats_display();
8079 static cmdline_parse_inst_t cmd_showfwdall = {
8080 .f = cmd_showfwdall_parsed,
8082 .help_str = "show|clear fwd stats all",
8084 (void *)&cmd_fwd_action,
8085 (void *)&cmd_fwd_fwd,
8086 (void *)&cmd_fwd_stats,
8087 (void *)&cmd_fwd_all,
8092 /* *** READ PORT REGISTER *** */
8093 struct cmd_read_reg_result {
8094 cmdline_fixed_string_t read;
8095 cmdline_fixed_string_t reg;
8101 cmd_read_reg_parsed(void *parsed_result,
8102 __rte_unused struct cmdline *cl,
8103 __rte_unused void *data)
8105 struct cmd_read_reg_result *res = parsed_result;
8106 port_reg_display(res->port_id, res->reg_off);
8109 cmdline_parse_token_string_t cmd_read_reg_read =
8110 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
8111 cmdline_parse_token_string_t cmd_read_reg_reg =
8112 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
8113 cmdline_parse_token_num_t cmd_read_reg_port_id =
8114 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, RTE_UINT16);
8115 cmdline_parse_token_num_t cmd_read_reg_reg_off =
8116 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, RTE_UINT32);
8118 cmdline_parse_inst_t cmd_read_reg = {
8119 .f = cmd_read_reg_parsed,
8121 .help_str = "read reg <port_id> <reg_off>",
8123 (void *)&cmd_read_reg_read,
8124 (void *)&cmd_read_reg_reg,
8125 (void *)&cmd_read_reg_port_id,
8126 (void *)&cmd_read_reg_reg_off,
8131 /* *** READ PORT REGISTER BIT FIELD *** */
8132 struct cmd_read_reg_bit_field_result {
8133 cmdline_fixed_string_t read;
8134 cmdline_fixed_string_t regfield;
8142 cmd_read_reg_bit_field_parsed(void *parsed_result,
8143 __rte_unused struct cmdline *cl,
8144 __rte_unused void *data)
8146 struct cmd_read_reg_bit_field_result *res = parsed_result;
8147 port_reg_bit_field_display(res->port_id, res->reg_off,
8148 res->bit1_pos, res->bit2_pos);
8151 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
8152 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
8154 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
8155 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
8156 regfield, "regfield");
8157 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
8158 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
8160 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
8161 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
8163 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
8164 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
8166 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
8167 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
8170 cmdline_parse_inst_t cmd_read_reg_bit_field = {
8171 .f = cmd_read_reg_bit_field_parsed,
8173 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
8174 "Read register bit field between bit_x and bit_y included",
8176 (void *)&cmd_read_reg_bit_field_read,
8177 (void *)&cmd_read_reg_bit_field_regfield,
8178 (void *)&cmd_read_reg_bit_field_port_id,
8179 (void *)&cmd_read_reg_bit_field_reg_off,
8180 (void *)&cmd_read_reg_bit_field_bit1_pos,
8181 (void *)&cmd_read_reg_bit_field_bit2_pos,
8186 /* *** READ PORT REGISTER BIT *** */
8187 struct cmd_read_reg_bit_result {
8188 cmdline_fixed_string_t read;
8189 cmdline_fixed_string_t regbit;
8196 cmd_read_reg_bit_parsed(void *parsed_result,
8197 __rte_unused struct cmdline *cl,
8198 __rte_unused void *data)
8200 struct cmd_read_reg_bit_result *res = parsed_result;
8201 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
8204 cmdline_parse_token_string_t cmd_read_reg_bit_read =
8205 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
8206 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
8207 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
8209 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
8210 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id,
8212 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
8213 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off,
8215 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
8216 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos,
8219 cmdline_parse_inst_t cmd_read_reg_bit = {
8220 .f = cmd_read_reg_bit_parsed,
8222 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
8224 (void *)&cmd_read_reg_bit_read,
8225 (void *)&cmd_read_reg_bit_regbit,
8226 (void *)&cmd_read_reg_bit_port_id,
8227 (void *)&cmd_read_reg_bit_reg_off,
8228 (void *)&cmd_read_reg_bit_bit_pos,
8233 /* *** WRITE PORT REGISTER *** */
8234 struct cmd_write_reg_result {
8235 cmdline_fixed_string_t write;
8236 cmdline_fixed_string_t reg;
8243 cmd_write_reg_parsed(void *parsed_result,
8244 __rte_unused struct cmdline *cl,
8245 __rte_unused void *data)
8247 struct cmd_write_reg_result *res = parsed_result;
8248 port_reg_set(res->port_id, res->reg_off, res->value);
8251 cmdline_parse_token_string_t cmd_write_reg_write =
8252 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
8253 cmdline_parse_token_string_t cmd_write_reg_reg =
8254 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
8255 cmdline_parse_token_num_t cmd_write_reg_port_id =
8256 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, RTE_UINT16);
8257 cmdline_parse_token_num_t cmd_write_reg_reg_off =
8258 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, RTE_UINT32);
8259 cmdline_parse_token_num_t cmd_write_reg_value =
8260 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, RTE_UINT32);
8262 cmdline_parse_inst_t cmd_write_reg = {
8263 .f = cmd_write_reg_parsed,
8265 .help_str = "write reg <port_id> <reg_off> <reg_value>",
8267 (void *)&cmd_write_reg_write,
8268 (void *)&cmd_write_reg_reg,
8269 (void *)&cmd_write_reg_port_id,
8270 (void *)&cmd_write_reg_reg_off,
8271 (void *)&cmd_write_reg_value,
8276 /* *** WRITE PORT REGISTER BIT FIELD *** */
8277 struct cmd_write_reg_bit_field_result {
8278 cmdline_fixed_string_t write;
8279 cmdline_fixed_string_t regfield;
8288 cmd_write_reg_bit_field_parsed(void *parsed_result,
8289 __rte_unused struct cmdline *cl,
8290 __rte_unused void *data)
8292 struct cmd_write_reg_bit_field_result *res = parsed_result;
8293 port_reg_bit_field_set(res->port_id, res->reg_off,
8294 res->bit1_pos, res->bit2_pos, res->value);
8297 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
8298 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
8300 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
8301 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
8302 regfield, "regfield");
8303 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
8304 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
8306 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
8307 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
8309 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
8310 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
8312 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
8313 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
8315 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
8316 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
8319 cmdline_parse_inst_t cmd_write_reg_bit_field = {
8320 .f = cmd_write_reg_bit_field_parsed,
8322 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
8324 "Set register bit field between bit_x and bit_y included",
8326 (void *)&cmd_write_reg_bit_field_write,
8327 (void *)&cmd_write_reg_bit_field_regfield,
8328 (void *)&cmd_write_reg_bit_field_port_id,
8329 (void *)&cmd_write_reg_bit_field_reg_off,
8330 (void *)&cmd_write_reg_bit_field_bit1_pos,
8331 (void *)&cmd_write_reg_bit_field_bit2_pos,
8332 (void *)&cmd_write_reg_bit_field_value,
8337 /* *** WRITE PORT REGISTER BIT *** */
8338 struct cmd_write_reg_bit_result {
8339 cmdline_fixed_string_t write;
8340 cmdline_fixed_string_t regbit;
8348 cmd_write_reg_bit_parsed(void *parsed_result,
8349 __rte_unused struct cmdline *cl,
8350 __rte_unused void *data)
8352 struct cmd_write_reg_bit_result *res = parsed_result;
8353 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
8356 cmdline_parse_token_string_t cmd_write_reg_bit_write =
8357 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
8359 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
8360 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
8362 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
8363 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id,
8365 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
8366 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off,
8368 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
8369 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos,
8371 cmdline_parse_token_num_t cmd_write_reg_bit_value =
8372 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value,
8375 cmdline_parse_inst_t cmd_write_reg_bit = {
8376 .f = cmd_write_reg_bit_parsed,
8378 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
8381 (void *)&cmd_write_reg_bit_write,
8382 (void *)&cmd_write_reg_bit_regbit,
8383 (void *)&cmd_write_reg_bit_port_id,
8384 (void *)&cmd_write_reg_bit_reg_off,
8385 (void *)&cmd_write_reg_bit_bit_pos,
8386 (void *)&cmd_write_reg_bit_value,
8391 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8392 struct cmd_read_rxd_txd_result {
8393 cmdline_fixed_string_t read;
8394 cmdline_fixed_string_t rxd_txd;
8401 cmd_read_rxd_txd_parsed(void *parsed_result,
8402 __rte_unused struct cmdline *cl,
8403 __rte_unused void *data)
8405 struct cmd_read_rxd_txd_result *res = parsed_result;
8407 if (!strcmp(res->rxd_txd, "rxd"))
8408 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8409 else if (!strcmp(res->rxd_txd, "txd"))
8410 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8413 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8414 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8415 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8416 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8418 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8419 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8421 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8422 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8424 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8425 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8428 cmdline_parse_inst_t cmd_read_rxd_txd = {
8429 .f = cmd_read_rxd_txd_parsed,
8431 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8433 (void *)&cmd_read_rxd_txd_read,
8434 (void *)&cmd_read_rxd_txd_rxd_txd,
8435 (void *)&cmd_read_rxd_txd_port_id,
8436 (void *)&cmd_read_rxd_txd_queue_id,
8437 (void *)&cmd_read_rxd_txd_desc_id,
8443 struct cmd_quit_result {
8444 cmdline_fixed_string_t quit;
8447 static void cmd_quit_parsed(__rte_unused void *parsed_result,
8449 __rte_unused void *data)
8454 cmdline_parse_token_string_t cmd_quit_quit =
8455 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8457 cmdline_parse_inst_t cmd_quit = {
8458 .f = cmd_quit_parsed,
8460 .help_str = "quit: Exit application",
8462 (void *)&cmd_quit_quit,
8467 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8468 struct cmd_mac_addr_result {
8469 cmdline_fixed_string_t mac_addr_cmd;
8470 cmdline_fixed_string_t what;
8472 struct rte_ether_addr address;
8475 static void cmd_mac_addr_parsed(void *parsed_result,
8476 __rte_unused struct cmdline *cl,
8477 __rte_unused void *data)
8479 struct cmd_mac_addr_result *res = parsed_result;
8482 if (strcmp(res->what, "add") == 0)
8483 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8484 else if (strcmp(res->what, "set") == 0)
8485 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8488 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8490 /* check the return value and print it if is < 0 */
8492 fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
8496 cmdline_parse_token_string_t cmd_mac_addr_cmd =
8497 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8499 cmdline_parse_token_string_t cmd_mac_addr_what =
8500 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8502 cmdline_parse_token_num_t cmd_mac_addr_portnum =
8503 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8505 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8506 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8508 cmdline_parse_inst_t cmd_mac_addr = {
8509 .f = cmd_mac_addr_parsed,
8511 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8512 "Add/Remove/Set MAC address on port_id",
8514 (void *)&cmd_mac_addr_cmd,
8515 (void *)&cmd_mac_addr_what,
8516 (void *)&cmd_mac_addr_portnum,
8517 (void *)&cmd_mac_addr_addr,
8522 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8523 struct cmd_eth_peer_result {
8524 cmdline_fixed_string_t set;
8525 cmdline_fixed_string_t eth_peer;
8527 cmdline_fixed_string_t peer_addr;
8530 static void cmd_set_eth_peer_parsed(void *parsed_result,
8531 __rte_unused struct cmdline *cl,
8532 __rte_unused void *data)
8534 struct cmd_eth_peer_result *res = parsed_result;
8536 if (test_done == 0) {
8537 fprintf(stderr, "Please stop forwarding first\n");
8540 if (!strcmp(res->eth_peer, "eth-peer")) {
8541 set_fwd_eth_peer(res->port_id, res->peer_addr);
8545 cmdline_parse_token_string_t cmd_eth_peer_set =
8546 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8547 cmdline_parse_token_string_t cmd_eth_peer =
8548 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8549 cmdline_parse_token_num_t cmd_eth_peer_port_id =
8550 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8552 cmdline_parse_token_string_t cmd_eth_peer_addr =
8553 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8555 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8556 .f = cmd_set_eth_peer_parsed,
8558 .help_str = "set eth-peer <port_id> <peer_mac>",
8560 (void *)&cmd_eth_peer_set,
8561 (void *)&cmd_eth_peer,
8562 (void *)&cmd_eth_peer_port_id,
8563 (void *)&cmd_eth_peer_addr,
8568 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8569 struct cmd_set_qmap_result {
8570 cmdline_fixed_string_t set;
8571 cmdline_fixed_string_t qmap;
8572 cmdline_fixed_string_t what;
8579 cmd_set_qmap_parsed(void *parsed_result,
8580 __rte_unused struct cmdline *cl,
8581 __rte_unused void *data)
8583 struct cmd_set_qmap_result *res = parsed_result;
8584 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8586 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8589 cmdline_parse_token_string_t cmd_setqmap_set =
8590 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8592 cmdline_parse_token_string_t cmd_setqmap_qmap =
8593 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8595 cmdline_parse_token_string_t cmd_setqmap_what =
8596 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8598 cmdline_parse_token_num_t cmd_setqmap_portid =
8599 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8600 port_id, RTE_UINT16);
8601 cmdline_parse_token_num_t cmd_setqmap_queueid =
8602 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8603 queue_id, RTE_UINT16);
8604 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8605 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8606 map_value, RTE_UINT8);
8608 cmdline_parse_inst_t cmd_set_qmap = {
8609 .f = cmd_set_qmap_parsed,
8611 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8612 "Set statistics mapping value on tx|rx queue_id of port_id",
8614 (void *)&cmd_setqmap_set,
8615 (void *)&cmd_setqmap_qmap,
8616 (void *)&cmd_setqmap_what,
8617 (void *)&cmd_setqmap_portid,
8618 (void *)&cmd_setqmap_queueid,
8619 (void *)&cmd_setqmap_mapvalue,
8624 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8625 struct cmd_set_xstats_hide_zero_result {
8626 cmdline_fixed_string_t keyword;
8627 cmdline_fixed_string_t name;
8628 cmdline_fixed_string_t on_off;
8632 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8633 __rte_unused struct cmdline *cl,
8634 __rte_unused void *data)
8636 struct cmd_set_xstats_hide_zero_result *res;
8637 uint16_t on_off = 0;
8639 res = parsed_result;
8640 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8641 set_xstats_hide_zero(on_off);
8644 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8645 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8647 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8648 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8649 name, "xstats-hide-zero");
8650 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8651 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8654 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8655 .f = cmd_set_xstats_hide_zero_parsed,
8657 .help_str = "set xstats-hide-zero on|off",
8659 (void *)&cmd_set_xstats_hide_zero_keyword,
8660 (void *)&cmd_set_xstats_hide_zero_name,
8661 (void *)&cmd_set_xstats_hide_zero_on_off,
8666 /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8667 struct cmd_set_record_core_cycles_result {
8668 cmdline_fixed_string_t keyword;
8669 cmdline_fixed_string_t name;
8670 cmdline_fixed_string_t on_off;
8674 cmd_set_record_core_cycles_parsed(void *parsed_result,
8675 __rte_unused struct cmdline *cl,
8676 __rte_unused void *data)
8678 struct cmd_set_record_core_cycles_result *res;
8679 uint16_t on_off = 0;
8681 res = parsed_result;
8682 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8683 set_record_core_cycles(on_off);
8686 cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8687 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8689 cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8690 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8691 name, "record-core-cycles");
8692 cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8693 TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8696 cmdline_parse_inst_t cmd_set_record_core_cycles = {
8697 .f = cmd_set_record_core_cycles_parsed,
8699 .help_str = "set record-core-cycles on|off",
8701 (void *)&cmd_set_record_core_cycles_keyword,
8702 (void *)&cmd_set_record_core_cycles_name,
8703 (void *)&cmd_set_record_core_cycles_on_off,
8708 /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8709 struct cmd_set_record_burst_stats_result {
8710 cmdline_fixed_string_t keyword;
8711 cmdline_fixed_string_t name;
8712 cmdline_fixed_string_t on_off;
8716 cmd_set_record_burst_stats_parsed(void *parsed_result,
8717 __rte_unused struct cmdline *cl,
8718 __rte_unused void *data)
8720 struct cmd_set_record_burst_stats_result *res;
8721 uint16_t on_off = 0;
8723 res = parsed_result;
8724 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8725 set_record_burst_stats(on_off);
8728 cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8729 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8731 cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8732 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8733 name, "record-burst-stats");
8734 cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8735 TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8738 cmdline_parse_inst_t cmd_set_record_burst_stats = {
8739 .f = cmd_set_record_burst_stats_parsed,
8741 .help_str = "set record-burst-stats on|off",
8743 (void *)&cmd_set_record_burst_stats_keyword,
8744 (void *)&cmd_set_record_burst_stats_name,
8745 (void *)&cmd_set_record_burst_stats_on_off,
8750 /* *** CONFIGURE UNICAST HASH TABLE *** */
8751 struct cmd_set_uc_hash_table {
8752 cmdline_fixed_string_t set;
8753 cmdline_fixed_string_t port;
8755 cmdline_fixed_string_t what;
8756 struct rte_ether_addr address;
8757 cmdline_fixed_string_t mode;
8761 cmd_set_uc_hash_parsed(void *parsed_result,
8762 __rte_unused struct cmdline *cl,
8763 __rte_unused void *data)
8766 struct cmd_set_uc_hash_table *res = parsed_result;
8768 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8770 if (strcmp(res->what, "uta") == 0)
8771 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8772 &res->address,(uint8_t)is_on);
8775 "bad unicast hash table parameter, return code = %d\n",
8780 cmdline_parse_token_string_t cmd_set_uc_hash_set =
8781 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8783 cmdline_parse_token_string_t cmd_set_uc_hash_port =
8784 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8786 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8787 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8788 port_id, RTE_UINT16);
8789 cmdline_parse_token_string_t cmd_set_uc_hash_what =
8790 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8792 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8793 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8795 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8796 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8799 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8800 .f = cmd_set_uc_hash_parsed,
8802 .help_str = "set port <port_id> uta <mac_addr> on|off)",
8804 (void *)&cmd_set_uc_hash_set,
8805 (void *)&cmd_set_uc_hash_port,
8806 (void *)&cmd_set_uc_hash_portid,
8807 (void *)&cmd_set_uc_hash_what,
8808 (void *)&cmd_set_uc_hash_mac,
8809 (void *)&cmd_set_uc_hash_mode,
8814 struct cmd_set_uc_all_hash_table {
8815 cmdline_fixed_string_t set;
8816 cmdline_fixed_string_t port;
8818 cmdline_fixed_string_t what;
8819 cmdline_fixed_string_t value;
8820 cmdline_fixed_string_t mode;
8824 cmd_set_uc_all_hash_parsed(void *parsed_result,
8825 __rte_unused struct cmdline *cl,
8826 __rte_unused void *data)
8829 struct cmd_set_uc_all_hash_table *res = parsed_result;
8831 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8833 if ((strcmp(res->what, "uta") == 0) &&
8834 (strcmp(res->value, "all") == 0))
8835 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8838 "bad unicast hash table parameter, return code = %d\n",
8842 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8843 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8845 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8846 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8848 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8849 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8850 port_id, RTE_UINT16);
8851 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8852 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8854 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8855 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8857 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8858 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8861 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8862 .f = cmd_set_uc_all_hash_parsed,
8864 .help_str = "set port <port_id> uta all on|off",
8866 (void *)&cmd_set_uc_all_hash_set,
8867 (void *)&cmd_set_uc_all_hash_port,
8868 (void *)&cmd_set_uc_all_hash_portid,
8869 (void *)&cmd_set_uc_all_hash_what,
8870 (void *)&cmd_set_uc_all_hash_value,
8871 (void *)&cmd_set_uc_all_hash_mode,
8876 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8877 struct cmd_set_vf_traffic {
8878 cmdline_fixed_string_t set;
8879 cmdline_fixed_string_t port;
8881 cmdline_fixed_string_t vf;
8883 cmdline_fixed_string_t what;
8884 cmdline_fixed_string_t mode;
8888 cmd_set_vf_traffic_parsed(void *parsed_result,
8889 __rte_unused struct cmdline *cl,
8890 __rte_unused void *data)
8892 struct cmd_set_vf_traffic *res = parsed_result;
8893 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8894 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8896 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8899 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8900 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8902 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8903 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8905 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8906 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8907 port_id, RTE_UINT16);
8908 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8909 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8911 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8912 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8914 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8915 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8917 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8918 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8921 cmdline_parse_inst_t cmd_set_vf_traffic = {
8922 .f = cmd_set_vf_traffic_parsed,
8924 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8926 (void *)&cmd_setvf_traffic_set,
8927 (void *)&cmd_setvf_traffic_port,
8928 (void *)&cmd_setvf_traffic_portid,
8929 (void *)&cmd_setvf_traffic_vf,
8930 (void *)&cmd_setvf_traffic_vfid,
8931 (void *)&cmd_setvf_traffic_what,
8932 (void *)&cmd_setvf_traffic_mode,
8937 /* *** CONFIGURE VF RECEIVE MODE *** */
8938 struct cmd_set_vf_rxmode {
8939 cmdline_fixed_string_t set;
8940 cmdline_fixed_string_t port;
8942 cmdline_fixed_string_t vf;
8944 cmdline_fixed_string_t what;
8945 cmdline_fixed_string_t mode;
8946 cmdline_fixed_string_t on;
8950 cmd_set_vf_rxmode_parsed(void *parsed_result,
8951 __rte_unused struct cmdline *cl,
8952 __rte_unused void *data)
8955 uint16_t vf_rxmode = 0;
8956 struct cmd_set_vf_rxmode *res = parsed_result;
8958 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8959 if (!strcmp(res->what,"rxmode")) {
8960 if (!strcmp(res->mode, "AUPE"))
8961 vf_rxmode |= ETH_VMDQ_ACCEPT_UNTAG;
8962 else if (!strcmp(res->mode, "ROPE"))
8963 vf_rxmode |= ETH_VMDQ_ACCEPT_HASH_UC;
8964 else if (!strcmp(res->mode, "BAM"))
8965 vf_rxmode |= ETH_VMDQ_ACCEPT_BROADCAST;
8966 else if (!strncmp(res->mode, "MPE",3))
8967 vf_rxmode |= ETH_VMDQ_ACCEPT_MULTICAST;
8970 RTE_SET_USED(is_on);
8972 #ifdef RTE_NET_IXGBE
8973 if (ret == -ENOTSUP)
8974 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8975 vf_rxmode, (uint8_t)is_on);
8978 if (ret == -ENOTSUP)
8979 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8980 vf_rxmode, (uint8_t)is_on);
8984 "bad VF receive mode parameter, return code = %d\n",
8988 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8989 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8991 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8992 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8994 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8995 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8996 port_id, RTE_UINT16);
8997 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8998 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9000 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
9001 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
9003 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
9004 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9006 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
9007 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9008 mode, "AUPE#ROPE#BAM#MPE");
9009 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
9010 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
9013 cmdline_parse_inst_t cmd_set_vf_rxmode = {
9014 .f = cmd_set_vf_rxmode_parsed,
9016 .help_str = "set port <port_id> vf <vf_id> rxmode "
9017 "AUPE|ROPE|BAM|MPE on|off",
9019 (void *)&cmd_set_vf_rxmode_set,
9020 (void *)&cmd_set_vf_rxmode_port,
9021 (void *)&cmd_set_vf_rxmode_portid,
9022 (void *)&cmd_set_vf_rxmode_vf,
9023 (void *)&cmd_set_vf_rxmode_vfid,
9024 (void *)&cmd_set_vf_rxmode_what,
9025 (void *)&cmd_set_vf_rxmode_mode,
9026 (void *)&cmd_set_vf_rxmode_on,
9031 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
9032 struct cmd_vf_mac_addr_result {
9033 cmdline_fixed_string_t mac_addr_cmd;
9034 cmdline_fixed_string_t what;
9035 cmdline_fixed_string_t port;
9037 cmdline_fixed_string_t vf;
9039 struct rte_ether_addr address;
9042 static void cmd_vf_mac_addr_parsed(void *parsed_result,
9043 __rte_unused struct cmdline *cl,
9044 __rte_unused void *data)
9046 struct cmd_vf_mac_addr_result *res = parsed_result;
9049 if (strcmp(res->what, "add") != 0)
9053 if (ret == -ENOTSUP)
9054 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
9058 if (ret == -ENOTSUP)
9059 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
9064 fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
9068 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
9069 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9070 mac_addr_cmd,"mac_addr");
9071 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
9072 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9074 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
9075 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9077 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
9078 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9079 port_num, RTE_UINT16);
9080 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
9081 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
9083 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
9084 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
9086 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
9087 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
9090 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
9091 .f = cmd_vf_mac_addr_parsed,
9093 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
9094 "Add MAC address filtering for a VF on port_id",
9096 (void *)&cmd_vf_mac_addr_cmd,
9097 (void *)&cmd_vf_mac_addr_what,
9098 (void *)&cmd_vf_mac_addr_port,
9099 (void *)&cmd_vf_mac_addr_portnum,
9100 (void *)&cmd_vf_mac_addr_vf,
9101 (void *)&cmd_vf_mac_addr_vfnum,
9102 (void *)&cmd_vf_mac_addr_addr,
9107 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
9108 struct cmd_vf_rx_vlan_filter {
9109 cmdline_fixed_string_t rx_vlan;
9110 cmdline_fixed_string_t what;
9112 cmdline_fixed_string_t port;
9114 cmdline_fixed_string_t vf;
9119 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
9120 __rte_unused struct cmdline *cl,
9121 __rte_unused void *data)
9123 struct cmd_vf_rx_vlan_filter *res = parsed_result;
9126 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
9128 #ifdef RTE_NET_IXGBE
9129 if (ret == -ENOTSUP)
9130 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
9131 res->vlan_id, res->vf_mask, is_add);
9134 if (ret == -ENOTSUP)
9135 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
9136 res->vlan_id, res->vf_mask, is_add);
9139 if (ret == -ENOTSUP)
9140 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
9141 res->vlan_id, res->vf_mask, is_add);
9148 fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
9149 res->vlan_id, res->vf_mask);
9152 fprintf(stderr, "invalid port_id %d\n", res->port_id);
9155 fprintf(stderr, "function not implemented or supported\n");
9158 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9162 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
9163 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9164 rx_vlan, "rx_vlan");
9165 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9166 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9168 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9169 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9170 vlan_id, RTE_UINT16);
9171 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9172 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9174 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9175 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9176 port_id, RTE_UINT16);
9177 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9178 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9180 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9181 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9182 vf_mask, RTE_UINT64);
9184 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9185 .f = cmd_vf_rx_vlan_filter_parsed,
9187 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9188 "(vf_mask = hexadecimal VF mask)",
9190 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9191 (void *)&cmd_vf_rx_vlan_filter_what,
9192 (void *)&cmd_vf_rx_vlan_filter_vlanid,
9193 (void *)&cmd_vf_rx_vlan_filter_port,
9194 (void *)&cmd_vf_rx_vlan_filter_portid,
9195 (void *)&cmd_vf_rx_vlan_filter_vf,
9196 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9201 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9202 struct cmd_queue_rate_limit_result {
9203 cmdline_fixed_string_t set;
9204 cmdline_fixed_string_t port;
9206 cmdline_fixed_string_t queue;
9208 cmdline_fixed_string_t rate;
9212 static void cmd_queue_rate_limit_parsed(void *parsed_result,
9213 __rte_unused struct cmdline *cl,
9214 __rte_unused void *data)
9216 struct cmd_queue_rate_limit_result *res = parsed_result;
9219 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9220 && (strcmp(res->queue, "queue") == 0)
9221 && (strcmp(res->rate, "rate") == 0))
9222 ret = set_queue_rate_limit(res->port_num, res->queue_num,
9225 fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
9230 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9231 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9233 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9234 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9236 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9237 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9238 port_num, RTE_UINT16);
9239 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9240 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9242 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9243 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9244 queue_num, RTE_UINT8);
9245 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9246 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9248 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9249 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9250 rate_num, RTE_UINT16);
9252 cmdline_parse_inst_t cmd_queue_rate_limit = {
9253 .f = cmd_queue_rate_limit_parsed,
9255 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9256 "Set rate limit for a queue on port_id",
9258 (void *)&cmd_queue_rate_limit_set,
9259 (void *)&cmd_queue_rate_limit_port,
9260 (void *)&cmd_queue_rate_limit_portnum,
9261 (void *)&cmd_queue_rate_limit_queue,
9262 (void *)&cmd_queue_rate_limit_queuenum,
9263 (void *)&cmd_queue_rate_limit_rate,
9264 (void *)&cmd_queue_rate_limit_ratenum,
9269 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9270 struct cmd_vf_rate_limit_result {
9271 cmdline_fixed_string_t set;
9272 cmdline_fixed_string_t port;
9274 cmdline_fixed_string_t vf;
9276 cmdline_fixed_string_t rate;
9278 cmdline_fixed_string_t q_msk;
9282 static void cmd_vf_rate_limit_parsed(void *parsed_result,
9283 __rte_unused struct cmdline *cl,
9284 __rte_unused void *data)
9286 struct cmd_vf_rate_limit_result *res = parsed_result;
9289 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9290 && (strcmp(res->vf, "vf") == 0)
9291 && (strcmp(res->rate, "rate") == 0)
9292 && (strcmp(res->q_msk, "queue_mask") == 0))
9293 ret = set_vf_rate_limit(res->port_num, res->vf_num,
9294 res->rate_num, res->q_msk_val);
9296 fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
9301 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9302 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9304 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9305 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9307 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9308 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9309 port_num, RTE_UINT16);
9310 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9311 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9313 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9314 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9316 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9317 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9319 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9320 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9321 rate_num, RTE_UINT16);
9322 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9323 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9324 q_msk, "queue_mask");
9325 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9326 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9327 q_msk_val, RTE_UINT64);
9329 cmdline_parse_inst_t cmd_vf_rate_limit = {
9330 .f = cmd_vf_rate_limit_parsed,
9332 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9333 "queue_mask <queue_mask_value>: "
9334 "Set rate limit for queues of VF on port_id",
9336 (void *)&cmd_vf_rate_limit_set,
9337 (void *)&cmd_vf_rate_limit_port,
9338 (void *)&cmd_vf_rate_limit_portnum,
9339 (void *)&cmd_vf_rate_limit_vf,
9340 (void *)&cmd_vf_rate_limit_vfnum,
9341 (void *)&cmd_vf_rate_limit_rate,
9342 (void *)&cmd_vf_rate_limit_ratenum,
9343 (void *)&cmd_vf_rate_limit_q_msk,
9344 (void *)&cmd_vf_rate_limit_q_msk_val,
9349 /* *** CONFIGURE TUNNEL UDP PORT *** */
9350 struct cmd_tunnel_udp_config {
9351 cmdline_fixed_string_t rx_vxlan_port;
9352 cmdline_fixed_string_t what;
9358 cmd_tunnel_udp_config_parsed(void *parsed_result,
9359 __rte_unused struct cmdline *cl,
9360 __rte_unused void *data)
9362 struct cmd_tunnel_udp_config *res = parsed_result;
9363 struct rte_eth_udp_tunnel tunnel_udp;
9366 tunnel_udp.udp_port = res->udp_port;
9367 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9369 if (!strcmp(res->what, "add"))
9370 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9373 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9377 fprintf(stderr, "udp tunneling add error: (%s)\n",
9381 cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9382 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9383 rx_vxlan_port, "rx_vxlan_port");
9384 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9385 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9387 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9388 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9389 udp_port, RTE_UINT16);
9390 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9391 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9392 port_id, RTE_UINT16);
9394 cmdline_parse_inst_t cmd_tunnel_udp_config = {
9395 .f = cmd_tunnel_udp_config_parsed,
9397 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9398 "Add/Remove a tunneling UDP port filter",
9400 (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9401 (void *)&cmd_tunnel_udp_config_what,
9402 (void *)&cmd_tunnel_udp_config_udp_port,
9403 (void *)&cmd_tunnel_udp_config_port_id,
9408 struct cmd_config_tunnel_udp_port {
9409 cmdline_fixed_string_t port;
9410 cmdline_fixed_string_t config;
9412 cmdline_fixed_string_t udp_tunnel_port;
9413 cmdline_fixed_string_t action;
9414 cmdline_fixed_string_t tunnel_type;
9419 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9420 __rte_unused struct cmdline *cl,
9421 __rte_unused void *data)
9423 struct cmd_config_tunnel_udp_port *res = parsed_result;
9424 struct rte_eth_udp_tunnel tunnel_udp;
9427 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9430 tunnel_udp.udp_port = res->udp_port;
9432 if (!strcmp(res->tunnel_type, "vxlan")) {
9433 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
9434 } else if (!strcmp(res->tunnel_type, "geneve")) {
9435 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
9436 } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9437 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN_GPE;
9438 } else if (!strcmp(res->tunnel_type, "ecpri")) {
9439 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_ECPRI;
9441 fprintf(stderr, "Invalid tunnel type\n");
9445 if (!strcmp(res->action, "add"))
9446 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9449 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9453 fprintf(stderr, "udp tunneling port add error: (%s)\n",
9457 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9458 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9460 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9461 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9463 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9464 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9466 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9467 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9470 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9471 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9473 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9474 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9475 "vxlan#geneve#vxlan-gpe#ecpri");
9476 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9477 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9480 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9481 .f = cmd_cfg_tunnel_udp_port_parsed,
9483 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9484 "geneve|vxlan-gpe|ecpri <udp_port>",
9486 (void *)&cmd_config_tunnel_udp_port_port,
9487 (void *)&cmd_config_tunnel_udp_port_config,
9488 (void *)&cmd_config_tunnel_udp_port_port_id,
9489 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9490 (void *)&cmd_config_tunnel_udp_port_action,
9491 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9492 (void *)&cmd_config_tunnel_udp_port_value,
9497 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
9498 struct cmd_set_mirror_mask_result {
9499 cmdline_fixed_string_t set;
9500 cmdline_fixed_string_t port;
9502 cmdline_fixed_string_t mirror;
9504 cmdline_fixed_string_t what;
9505 cmdline_fixed_string_t value;
9506 cmdline_fixed_string_t dstpool;
9508 cmdline_fixed_string_t on;
9511 cmdline_parse_token_string_t cmd_mirror_mask_set =
9512 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9514 cmdline_parse_token_string_t cmd_mirror_mask_port =
9515 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9517 cmdline_parse_token_num_t cmd_mirror_mask_portid =
9518 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9519 port_id, RTE_UINT16);
9520 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
9521 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9522 mirror, "mirror-rule");
9523 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
9524 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9525 rule_id, RTE_UINT8);
9526 cmdline_parse_token_string_t cmd_mirror_mask_what =
9527 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9528 what, "pool-mirror-up#pool-mirror-down"
9530 cmdline_parse_token_string_t cmd_mirror_mask_value =
9531 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9533 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
9534 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9535 dstpool, "dst-pool");
9536 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
9537 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
9538 dstpool_id, RTE_UINT8);
9539 cmdline_parse_token_string_t cmd_mirror_mask_on =
9540 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
9544 cmd_set_mirror_mask_parsed(void *parsed_result,
9545 __rte_unused struct cmdline *cl,
9546 __rte_unused void *data)
9549 struct cmd_set_mirror_mask_result *res = parsed_result;
9550 struct rte_eth_mirror_conf mr_conf;
9552 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9554 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
9556 mr_conf.dst_pool = res->dstpool_id;
9558 if (!strcmp(res->what, "pool-mirror-up")) {
9559 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9560 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
9561 } else if (!strcmp(res->what, "pool-mirror-down")) {
9562 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
9563 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
9564 } else if (!strcmp(res->what, "vlan-mirror")) {
9565 mr_conf.rule_type = ETH_MIRROR_VLAN;
9566 nb_item = parse_item_list(res->value, "vlan",
9567 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
9571 for (i = 0; i < nb_item; i++) {
9572 if (vlan_list[i] > RTE_ETHER_MAX_VLAN_ID) {
9574 "Invalid vlan_id: must be < 4096\n");
9578 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
9579 mr_conf.vlan.vlan_mask |= 1ULL << i;
9583 if (!strcmp(res->on, "on"))
9584 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9587 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9590 fprintf(stderr, "mirror rule add error: (%s)\n",
9594 cmdline_parse_inst_t cmd_set_mirror_mask = {
9595 .f = cmd_set_mirror_mask_parsed,
9597 .help_str = "set port <port_id> mirror-rule <rule_id> "
9598 "pool-mirror-up|pool-mirror-down|vlan-mirror "
9599 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
9601 (void *)&cmd_mirror_mask_set,
9602 (void *)&cmd_mirror_mask_port,
9603 (void *)&cmd_mirror_mask_portid,
9604 (void *)&cmd_mirror_mask_mirror,
9605 (void *)&cmd_mirror_mask_ruleid,
9606 (void *)&cmd_mirror_mask_what,
9607 (void *)&cmd_mirror_mask_value,
9608 (void *)&cmd_mirror_mask_dstpool,
9609 (void *)&cmd_mirror_mask_poolid,
9610 (void *)&cmd_mirror_mask_on,
9615 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
9616 struct cmd_set_mirror_link_result {
9617 cmdline_fixed_string_t set;
9618 cmdline_fixed_string_t port;
9620 cmdline_fixed_string_t mirror;
9622 cmdline_fixed_string_t what;
9623 cmdline_fixed_string_t dstpool;
9625 cmdline_fixed_string_t on;
9628 cmdline_parse_token_string_t cmd_mirror_link_set =
9629 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9631 cmdline_parse_token_string_t cmd_mirror_link_port =
9632 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9634 cmdline_parse_token_num_t cmd_mirror_link_portid =
9635 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9636 port_id, RTE_UINT16);
9637 cmdline_parse_token_string_t cmd_mirror_link_mirror =
9638 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9639 mirror, "mirror-rule");
9640 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
9641 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9642 rule_id, RTE_UINT8);
9643 cmdline_parse_token_string_t cmd_mirror_link_what =
9644 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9645 what, "uplink-mirror#downlink-mirror");
9646 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
9647 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9648 dstpool, "dst-pool");
9649 cmdline_parse_token_num_t cmd_mirror_link_poolid =
9650 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
9651 dstpool_id, RTE_UINT8);
9652 cmdline_parse_token_string_t cmd_mirror_link_on =
9653 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
9657 cmd_set_mirror_link_parsed(void *parsed_result,
9658 __rte_unused struct cmdline *cl,
9659 __rte_unused void *data)
9662 struct cmd_set_mirror_link_result *res = parsed_result;
9663 struct rte_eth_mirror_conf mr_conf;
9665 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
9666 if (!strcmp(res->what, "uplink-mirror"))
9667 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9669 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9671 mr_conf.dst_pool = res->dstpool_id;
9673 if (!strcmp(res->on, "on"))
9674 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9677 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9680 /* check the return value and print it if is < 0 */
9682 fprintf(stderr, "mirror rule add error: (%s)\n",
9687 cmdline_parse_inst_t cmd_set_mirror_link = {
9688 .f = cmd_set_mirror_link_parsed,
9690 .help_str = "set port <port_id> mirror-rule <rule_id> "
9691 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9693 (void *)&cmd_mirror_link_set,
9694 (void *)&cmd_mirror_link_port,
9695 (void *)&cmd_mirror_link_portid,
9696 (void *)&cmd_mirror_link_mirror,
9697 (void *)&cmd_mirror_link_ruleid,
9698 (void *)&cmd_mirror_link_what,
9699 (void *)&cmd_mirror_link_dstpool,
9700 (void *)&cmd_mirror_link_poolid,
9701 (void *)&cmd_mirror_link_on,
9706 /* *** RESET VM MIRROR RULE *** */
9707 struct cmd_rm_mirror_rule_result {
9708 cmdline_fixed_string_t reset;
9709 cmdline_fixed_string_t port;
9711 cmdline_fixed_string_t mirror;
9715 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9716 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9718 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9719 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9721 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9722 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9723 port_id, RTE_UINT16);
9724 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9725 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9726 mirror, "mirror-rule");
9727 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9728 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9729 rule_id, RTE_UINT8);
9732 cmd_reset_mirror_rule_parsed(void *parsed_result,
9733 __rte_unused struct cmdline *cl,
9734 __rte_unused void *data)
9737 struct cmd_set_mirror_link_result *res = parsed_result;
9739 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9741 fprintf(stderr, "mirror rule remove error: (%s)\n",
9745 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9746 .f = cmd_reset_mirror_rule_parsed,
9748 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9750 (void *)&cmd_rm_mirror_rule_reset,
9751 (void *)&cmd_rm_mirror_rule_port,
9752 (void *)&cmd_rm_mirror_rule_portid,
9753 (void *)&cmd_rm_mirror_rule_mirror,
9754 (void *)&cmd_rm_mirror_rule_ruleid,
9759 /* ******************************************************************************** */
9761 struct cmd_dump_result {
9762 cmdline_fixed_string_t dump;
9766 dump_struct_sizes(void)
9768 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9769 DUMP_SIZE(struct rte_mbuf);
9770 DUMP_SIZE(struct rte_mempool);
9771 DUMP_SIZE(struct rte_ring);
9776 /* Dump the socket memory statistics on console */
9778 dump_socket_mem(FILE *f)
9780 struct rte_malloc_socket_stats socket_stats;
9785 unsigned int n_alloc = 0;
9786 unsigned int n_free = 0;
9787 static size_t last_allocs;
9788 static size_t last_total;
9791 for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9792 if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9793 !socket_stats.heap_totalsz_bytes)
9795 total += socket_stats.heap_totalsz_bytes;
9796 alloc += socket_stats.heap_allocsz_bytes;
9797 free += socket_stats.heap_freesz_bytes;
9798 n_alloc += socket_stats.alloc_count;
9799 n_free += socket_stats.free_count;
9801 "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9803 (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9804 (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9805 (double)socket_stats.heap_allocsz_bytes * 100 /
9806 (double)socket_stats.heap_totalsz_bytes,
9807 (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9808 socket_stats.alloc_count,
9809 socket_stats.free_count);
9812 "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9813 (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9814 total ? ((double)alloc * 100 / (double)total) : 0,
9815 (double)free / (1024 * 1024),
9818 fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9819 ((double)total - (double)last_total) / (1024 * 1024),
9820 (double)(alloc - (double)last_allocs) / 1024 / 1024);
9821 last_allocs = alloc;
9825 static void cmd_dump_parsed(void *parsed_result,
9826 __rte_unused struct cmdline *cl,
9827 __rte_unused void *data)
9829 struct cmd_dump_result *res = parsed_result;
9831 if (!strcmp(res->dump, "dump_physmem"))
9832 rte_dump_physmem_layout(stdout);
9833 else if (!strcmp(res->dump, "dump_socket_mem"))
9834 dump_socket_mem(stdout);
9835 else if (!strcmp(res->dump, "dump_memzone"))
9836 rte_memzone_dump(stdout);
9837 else if (!strcmp(res->dump, "dump_struct_sizes"))
9838 dump_struct_sizes();
9839 else if (!strcmp(res->dump, "dump_ring"))
9840 rte_ring_list_dump(stdout);
9841 else if (!strcmp(res->dump, "dump_mempool"))
9842 rte_mempool_list_dump(stdout);
9843 else if (!strcmp(res->dump, "dump_devargs"))
9844 rte_devargs_dump(stdout);
9845 else if (!strcmp(res->dump, "dump_log_types"))
9846 rte_log_dump(stdout);
9849 cmdline_parse_token_string_t cmd_dump_dump =
9850 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9854 "dump_struct_sizes#"
9860 cmdline_parse_inst_t cmd_dump = {
9861 .f = cmd_dump_parsed, /* function to call */
9862 .data = NULL, /* 2nd arg of func */
9863 .help_str = "Dump status",
9864 .tokens = { /* token list, NULL terminated */
9865 (void *)&cmd_dump_dump,
9870 /* ******************************************************************************** */
9872 struct cmd_dump_one_result {
9873 cmdline_fixed_string_t dump;
9874 cmdline_fixed_string_t name;
9877 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9878 __rte_unused void *data)
9880 struct cmd_dump_one_result *res = parsed_result;
9882 if (!strcmp(res->dump, "dump_ring")) {
9884 r = rte_ring_lookup(res->name);
9886 cmdline_printf(cl, "Cannot find ring\n");
9889 rte_ring_dump(stdout, r);
9890 } else if (!strcmp(res->dump, "dump_mempool")) {
9891 struct rte_mempool *mp;
9892 mp = rte_mempool_lookup(res->name);
9894 cmdline_printf(cl, "Cannot find mempool\n");
9897 rte_mempool_dump(stdout, mp);
9901 cmdline_parse_token_string_t cmd_dump_one_dump =
9902 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9903 "dump_ring#dump_mempool");
9905 cmdline_parse_token_string_t cmd_dump_one_name =
9906 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9908 cmdline_parse_inst_t cmd_dump_one = {
9909 .f = cmd_dump_one_parsed, /* function to call */
9910 .data = NULL, /* 2nd arg of func */
9911 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9912 .tokens = { /* token list, NULL terminated */
9913 (void *)&cmd_dump_one_dump,
9914 (void *)&cmd_dump_one_name,
9919 /* *** queue region set *** */
9920 struct cmd_queue_region_result {
9921 cmdline_fixed_string_t set;
9922 cmdline_fixed_string_t port;
9924 cmdline_fixed_string_t cmd;
9925 cmdline_fixed_string_t region;
9927 cmdline_fixed_string_t queue_start_index;
9929 cmdline_fixed_string_t queue_num;
9930 uint8_t queue_num_value;
9934 cmd_queue_region_parsed(void *parsed_result,
9935 __rte_unused struct cmdline *cl,
9936 __rte_unused void *data)
9938 struct cmd_queue_region_result *res = parsed_result;
9941 struct rte_pmd_i40e_queue_region_conf region_conf;
9942 enum rte_pmd_i40e_queue_region_op op_type;
9945 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9949 memset(®ion_conf, 0, sizeof(region_conf));
9950 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9951 region_conf.region_id = res->region_id;
9952 region_conf.queue_num = res->queue_num_value;
9953 region_conf.queue_start_index = res->queue_id;
9955 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9956 op_type, ®ion_conf);
9963 fprintf(stderr, "function not implemented or supported\n");
9966 fprintf(stderr, "queue region config error: (%s)\n",
9971 cmdline_parse_token_string_t cmd_queue_region_set =
9972 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9974 cmdline_parse_token_string_t cmd_queue_region_port =
9975 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9976 cmdline_parse_token_num_t cmd_queue_region_port_id =
9977 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9978 port_id, RTE_UINT16);
9979 cmdline_parse_token_string_t cmd_queue_region_cmd =
9980 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9981 cmd, "queue-region");
9982 cmdline_parse_token_string_t cmd_queue_region_id =
9983 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9984 region, "region_id");
9985 cmdline_parse_token_num_t cmd_queue_region_index =
9986 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9987 region_id, RTE_UINT8);
9988 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9989 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9990 queue_start_index, "queue_start_index");
9991 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9992 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9993 queue_id, RTE_UINT8);
9994 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9995 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9996 queue_num, "queue_num");
9997 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9998 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9999 queue_num_value, RTE_UINT8);
10001 cmdline_parse_inst_t cmd_queue_region = {
10002 .f = cmd_queue_region_parsed,
10004 .help_str = "set port <port_id> queue-region region_id <value> "
10005 "queue_start_index <value> queue_num <value>: Set a queue region",
10007 (void *)&cmd_queue_region_set,
10008 (void *)&cmd_queue_region_port,
10009 (void *)&cmd_queue_region_port_id,
10010 (void *)&cmd_queue_region_cmd,
10011 (void *)&cmd_queue_region_id,
10012 (void *)&cmd_queue_region_index,
10013 (void *)&cmd_queue_region_queue_start_index,
10014 (void *)&cmd_queue_region_queue_id,
10015 (void *)&cmd_queue_region_queue_num,
10016 (void *)&cmd_queue_region_queue_num_value,
10021 /* *** queue region and flowtype set *** */
10022 struct cmd_region_flowtype_result {
10023 cmdline_fixed_string_t set;
10024 cmdline_fixed_string_t port;
10026 cmdline_fixed_string_t cmd;
10027 cmdline_fixed_string_t region;
10029 cmdline_fixed_string_t flowtype;
10030 uint8_t flowtype_id;
10034 cmd_region_flowtype_parsed(void *parsed_result,
10035 __rte_unused struct cmdline *cl,
10036 __rte_unused void *data)
10038 struct cmd_region_flowtype_result *res = parsed_result;
10039 int ret = -ENOTSUP;
10040 #ifdef RTE_NET_I40E
10041 struct rte_pmd_i40e_queue_region_conf region_conf;
10042 enum rte_pmd_i40e_queue_region_op op_type;
10045 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10048 #ifdef RTE_NET_I40E
10049 memset(®ion_conf, 0, sizeof(region_conf));
10051 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
10052 region_conf.region_id = res->region_id;
10053 region_conf.hw_flowtype = res->flowtype_id;
10055 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10056 op_type, ®ion_conf);
10063 fprintf(stderr, "function not implemented or supported\n");
10066 fprintf(stderr, "region flowtype config error: (%s)\n",
10071 cmdline_parse_token_string_t cmd_region_flowtype_set =
10072 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10074 cmdline_parse_token_string_t cmd_region_flowtype_port =
10075 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10077 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
10078 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10079 port_id, RTE_UINT16);
10080 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
10081 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10082 cmd, "queue-region");
10083 cmdline_parse_token_string_t cmd_region_flowtype_index =
10084 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10085 region, "region_id");
10086 cmdline_parse_token_num_t cmd_region_flowtype_id =
10087 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10088 region_id, RTE_UINT8);
10089 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
10090 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
10091 flowtype, "flowtype");
10092 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
10093 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
10094 flowtype_id, RTE_UINT8);
10095 cmdline_parse_inst_t cmd_region_flowtype = {
10096 .f = cmd_region_flowtype_parsed,
10098 .help_str = "set port <port_id> queue-region region_id <value> "
10099 "flowtype <value>: Set a flowtype region index",
10101 (void *)&cmd_region_flowtype_set,
10102 (void *)&cmd_region_flowtype_port,
10103 (void *)&cmd_region_flowtype_port_index,
10104 (void *)&cmd_region_flowtype_cmd,
10105 (void *)&cmd_region_flowtype_index,
10106 (void *)&cmd_region_flowtype_id,
10107 (void *)&cmd_region_flowtype_flow_index,
10108 (void *)&cmd_region_flowtype_flow_id,
10113 /* *** User Priority (UP) to queue region (region_id) set *** */
10114 struct cmd_user_priority_region_result {
10115 cmdline_fixed_string_t set;
10116 cmdline_fixed_string_t port;
10118 cmdline_fixed_string_t cmd;
10119 cmdline_fixed_string_t user_priority;
10120 uint8_t user_priority_id;
10121 cmdline_fixed_string_t region;
10126 cmd_user_priority_region_parsed(void *parsed_result,
10127 __rte_unused struct cmdline *cl,
10128 __rte_unused void *data)
10130 struct cmd_user_priority_region_result *res = parsed_result;
10131 int ret = -ENOTSUP;
10132 #ifdef RTE_NET_I40E
10133 struct rte_pmd_i40e_queue_region_conf region_conf;
10134 enum rte_pmd_i40e_queue_region_op op_type;
10137 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10140 #ifdef RTE_NET_I40E
10141 memset(®ion_conf, 0, sizeof(region_conf));
10142 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
10143 region_conf.user_priority = res->user_priority_id;
10144 region_conf.region_id = res->region_id;
10146 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10147 op_type, ®ion_conf);
10154 fprintf(stderr, "function not implemented or supported\n");
10157 fprintf(stderr, "user_priority region config error: (%s)\n",
10162 cmdline_parse_token_string_t cmd_user_priority_region_set =
10163 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10165 cmdline_parse_token_string_t cmd_user_priority_region_port =
10166 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10168 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
10169 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10170 port_id, RTE_UINT16);
10171 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
10172 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10173 cmd, "queue-region");
10174 cmdline_parse_token_string_t cmd_user_priority_region_UP =
10175 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10176 user_priority, "UP");
10177 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
10178 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10179 user_priority_id, RTE_UINT8);
10180 cmdline_parse_token_string_t cmd_user_priority_region_region =
10181 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
10182 region, "region_id");
10183 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
10184 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
10185 region_id, RTE_UINT8);
10187 cmdline_parse_inst_t cmd_user_priority_region = {
10188 .f = cmd_user_priority_region_parsed,
10190 .help_str = "set port <port_id> queue-region UP <value> "
10191 "region_id <value>: Set the mapping of User Priority (UP) "
10192 "to queue region (region_id) ",
10194 (void *)&cmd_user_priority_region_set,
10195 (void *)&cmd_user_priority_region_port,
10196 (void *)&cmd_user_priority_region_port_index,
10197 (void *)&cmd_user_priority_region_cmd,
10198 (void *)&cmd_user_priority_region_UP,
10199 (void *)&cmd_user_priority_region_UP_id,
10200 (void *)&cmd_user_priority_region_region,
10201 (void *)&cmd_user_priority_region_region_id,
10206 /* *** flush all queue region related configuration *** */
10207 struct cmd_flush_queue_region_result {
10208 cmdline_fixed_string_t set;
10209 cmdline_fixed_string_t port;
10211 cmdline_fixed_string_t cmd;
10212 cmdline_fixed_string_t flush;
10213 cmdline_fixed_string_t what;
10217 cmd_flush_queue_region_parsed(void *parsed_result,
10218 __rte_unused struct cmdline *cl,
10219 __rte_unused void *data)
10221 struct cmd_flush_queue_region_result *res = parsed_result;
10222 int ret = -ENOTSUP;
10223 #ifdef RTE_NET_I40E
10224 struct rte_pmd_i40e_queue_region_conf region_conf;
10225 enum rte_pmd_i40e_queue_region_op op_type;
10228 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10231 #ifdef RTE_NET_I40E
10232 memset(®ion_conf, 0, sizeof(region_conf));
10234 if (strcmp(res->what, "on") == 0)
10235 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
10237 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
10239 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10240 op_type, ®ion_conf);
10247 fprintf(stderr, "function not implemented or supported\n");
10250 fprintf(stderr, "queue region config flush error: (%s)\n",
10255 cmdline_parse_token_string_t cmd_flush_queue_region_set =
10256 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10258 cmdline_parse_token_string_t cmd_flush_queue_region_port =
10259 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10261 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
10262 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
10263 port_id, RTE_UINT16);
10264 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
10265 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10266 cmd, "queue-region");
10267 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
10268 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10270 cmdline_parse_token_string_t cmd_flush_queue_region_what =
10271 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
10274 cmdline_parse_inst_t cmd_flush_queue_region = {
10275 .f = cmd_flush_queue_region_parsed,
10277 .help_str = "set port <port_id> queue-region flush on|off"
10278 ": flush all queue region related configuration",
10280 (void *)&cmd_flush_queue_region_set,
10281 (void *)&cmd_flush_queue_region_port,
10282 (void *)&cmd_flush_queue_region_port_index,
10283 (void *)&cmd_flush_queue_region_cmd,
10284 (void *)&cmd_flush_queue_region_flush,
10285 (void *)&cmd_flush_queue_region_what,
10290 /* *** get all queue region related configuration info *** */
10291 struct cmd_show_queue_region_info {
10292 cmdline_fixed_string_t show;
10293 cmdline_fixed_string_t port;
10295 cmdline_fixed_string_t cmd;
10299 cmd_show_queue_region_info_parsed(void *parsed_result,
10300 __rte_unused struct cmdline *cl,
10301 __rte_unused void *data)
10303 struct cmd_show_queue_region_info *res = parsed_result;
10304 int ret = -ENOTSUP;
10305 #ifdef RTE_NET_I40E
10306 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
10307 enum rte_pmd_i40e_queue_region_op op_type;
10310 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10313 #ifdef RTE_NET_I40E
10314 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
10316 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
10318 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
10319 op_type, &rte_pmd_regions);
10321 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
10328 fprintf(stderr, "function not implemented or supported\n");
10331 fprintf(stderr, "queue region config info show error: (%s)\n",
10336 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
10337 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10339 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
10340 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10342 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
10343 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
10344 port_id, RTE_UINT16);
10345 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
10346 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
10347 cmd, "queue-region");
10349 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
10350 .f = cmd_show_queue_region_info_parsed,
10352 .help_str = "show port <port_id> queue-region"
10353 ": show all queue region related configuration info",
10355 (void *)&cmd_show_queue_region_info_get,
10356 (void *)&cmd_show_queue_region_info_port,
10357 (void *)&cmd_show_queue_region_info_port_index,
10358 (void *)&cmd_show_queue_region_info_cmd,
10363 /* *** Filters Control *** */
10365 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10367 if ((ip_addr).family == AF_INET) \
10368 (ip) = (ip_addr).addr.ipv4.s_addr; \
10370 fprintf(stderr, "invalid parameter.\n"); \
10375 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10377 if ((ip_addr).family == AF_INET6) \
10378 rte_memcpy(&(ip), \
10379 &((ip_addr).addr.ipv6), \
10380 sizeof(struct in6_addr)); \
10382 fprintf(stderr, "invalid parameter.\n"); \
10387 #ifdef RTE_NET_I40E
10390 str2flowtype(char *string)
10393 static const struct {
10396 } flowtype_str[] = {
10397 {"raw", RTE_ETH_FLOW_RAW},
10398 {"ipv4", RTE_ETH_FLOW_IPV4},
10399 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10400 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10401 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10402 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10403 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10404 {"ipv6", RTE_ETH_FLOW_IPV6},
10405 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10406 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10407 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10408 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10409 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10410 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10413 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10414 if (!strcmp(flowtype_str[i].str, string))
10415 return flowtype_str[i].type;
10418 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10419 return (uint16_t)atoi(string);
10421 return RTE_ETH_FLOW_UNKNOWN;
10424 /* *** deal with flow director filter *** */
10425 struct cmd_flow_director_result {
10426 cmdline_fixed_string_t flow_director_filter;
10428 cmdline_fixed_string_t mode;
10429 cmdline_fixed_string_t mode_value;
10430 cmdline_fixed_string_t ops;
10431 cmdline_fixed_string_t flow;
10432 cmdline_fixed_string_t flow_type;
10433 cmdline_fixed_string_t drop;
10434 cmdline_fixed_string_t queue;
10436 cmdline_fixed_string_t fd_id;
10437 uint32_t fd_id_value;
10438 cmdline_fixed_string_t packet;
10443 cmd_flow_director_filter_parsed(void *parsed_result,
10444 __rte_unused struct cmdline *cl,
10445 __rte_unused void *data)
10447 struct cmd_flow_director_result *res = parsed_result;
10449 struct rte_pmd_i40e_flow_type_mapping
10450 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10451 struct rte_pmd_i40e_pkt_template_conf conf;
10452 uint16_t flow_type = str2flowtype(res->flow_type);
10453 uint16_t i, port = res->port_id;
10456 memset(&conf, 0, sizeof(conf));
10458 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10459 fprintf(stderr, "Invalid flow type specified.\n");
10462 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10466 if (mapping[flow_type].pctype == 0ULL) {
10467 fprintf(stderr, "Invalid flow type specified.\n");
10470 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10471 if (mapping[flow_type].pctype & (1ULL << i)) {
10472 conf.input.pctype = i;
10477 conf.input.packet = open_file(res->filepath,
10478 &conf.input.length);
10479 if (!conf.input.packet)
10481 if (!strcmp(res->drop, "drop"))
10482 conf.action.behavior =
10483 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10485 conf.action.behavior =
10486 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10487 conf.action.report_status =
10488 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10489 conf.action.rx_queue = res->queue_id;
10490 conf.soft_id = res->fd_id_value;
10491 add = strcmp(res->ops, "del") ? 1 : 0;
10492 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10496 fprintf(stderr, "flow director config error: (%s)\n",
10498 close_file(conf.input.packet);
10501 cmdline_parse_token_string_t cmd_flow_director_filter =
10502 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10503 flow_director_filter, "flow_director_filter");
10504 cmdline_parse_token_num_t cmd_flow_director_port_id =
10505 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10506 port_id, RTE_UINT16);
10507 cmdline_parse_token_string_t cmd_flow_director_ops =
10508 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10509 ops, "add#del#update");
10510 cmdline_parse_token_string_t cmd_flow_director_flow =
10511 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10513 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10514 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10516 cmdline_parse_token_string_t cmd_flow_director_drop =
10517 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10519 cmdline_parse_token_string_t cmd_flow_director_queue =
10520 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10522 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10523 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10524 queue_id, RTE_UINT16);
10525 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10526 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10528 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10529 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10530 fd_id_value, RTE_UINT32);
10532 cmdline_parse_token_string_t cmd_flow_director_mode =
10533 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10535 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10536 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10537 mode_value, "raw");
10538 cmdline_parse_token_string_t cmd_flow_director_packet =
10539 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10541 cmdline_parse_token_string_t cmd_flow_director_filepath =
10542 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10545 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
10546 .f = cmd_flow_director_filter_parsed,
10548 .help_str = "flow_director_filter ... : Add or delete a raw flow "
10549 "director entry on NIC",
10551 (void *)&cmd_flow_director_filter,
10552 (void *)&cmd_flow_director_port_id,
10553 (void *)&cmd_flow_director_mode,
10554 (void *)&cmd_flow_director_mode_raw,
10555 (void *)&cmd_flow_director_ops,
10556 (void *)&cmd_flow_director_flow,
10557 (void *)&cmd_flow_director_flow_type,
10558 (void *)&cmd_flow_director_drop,
10559 (void *)&cmd_flow_director_queue,
10560 (void *)&cmd_flow_director_queue_id,
10561 (void *)&cmd_flow_director_fd_id,
10562 (void *)&cmd_flow_director_fd_id_value,
10563 (void *)&cmd_flow_director_packet,
10564 (void *)&cmd_flow_director_filepath,
10569 #endif /* RTE_NET_I40E */
10571 /* *** deal with flow director mask *** */
10572 struct cmd_flow_director_mask_result {
10573 cmdline_fixed_string_t flow_director_mask;
10575 cmdline_fixed_string_t mode;
10576 cmdline_fixed_string_t mode_value;
10577 cmdline_fixed_string_t vlan;
10578 uint16_t vlan_mask;
10579 cmdline_fixed_string_t src_mask;
10580 cmdline_ipaddr_t ipv4_src;
10581 cmdline_ipaddr_t ipv6_src;
10583 cmdline_fixed_string_t dst_mask;
10584 cmdline_ipaddr_t ipv4_dst;
10585 cmdline_ipaddr_t ipv6_dst;
10587 cmdline_fixed_string_t mac;
10588 uint8_t mac_addr_byte_mask;
10589 cmdline_fixed_string_t tunnel_id;
10590 uint32_t tunnel_id_mask;
10591 cmdline_fixed_string_t tunnel_type;
10592 uint8_t tunnel_type_mask;
10596 cmd_flow_director_mask_parsed(void *parsed_result,
10597 __rte_unused struct cmdline *cl,
10598 __rte_unused void *data)
10600 struct cmd_flow_director_mask_result *res = parsed_result;
10601 struct rte_eth_fdir_masks *mask;
10602 struct rte_port *port;
10604 port = &ports[res->port_id];
10605 /** Check if the port is not started **/
10606 if (port->port_status != RTE_PORT_STOPPED) {
10607 fprintf(stderr, "Please stop port %d first\n", res->port_id);
10611 mask = &port->dev_conf.fdir_conf.mask;
10613 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10614 if (strcmp(res->mode_value, "MAC-VLAN")) {
10615 fprintf(stderr, "Please set mode to MAC-VLAN.\n");
10619 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10620 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10621 if (strcmp(res->mode_value, "Tunnel")) {
10622 fprintf(stderr, "Please set mode to Tunnel.\n");
10626 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10627 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
10628 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
10629 mask->tunnel_type_mask = res->tunnel_type_mask;
10631 if (strcmp(res->mode_value, "IP")) {
10632 fprintf(stderr, "Please set mode to IP.\n");
10636 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
10637 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
10638 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
10639 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
10640 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
10641 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
10642 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
10645 cmd_reconfig_device_queue(res->port_id, 1, 1);
10648 cmdline_parse_token_string_t cmd_flow_director_mask =
10649 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10650 flow_director_mask, "flow_director_mask");
10651 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
10652 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10653 port_id, RTE_UINT16);
10654 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
10655 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10657 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
10658 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10659 vlan_mask, RTE_UINT16);
10660 cmdline_parse_token_string_t cmd_flow_director_mask_src =
10661 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10662 src_mask, "src_mask");
10663 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
10664 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10666 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
10667 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10669 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
10670 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10671 port_src, RTE_UINT16);
10672 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
10673 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10674 dst_mask, "dst_mask");
10675 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
10676 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10678 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
10679 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
10681 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
10682 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10683 port_dst, RTE_UINT16);
10685 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
10686 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10688 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
10689 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10691 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
10692 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10693 mode_value, "MAC-VLAN");
10694 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
10695 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10696 mode_value, "Tunnel");
10697 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
10698 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10700 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
10701 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10702 mac_addr_byte_mask, RTE_UINT8);
10703 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
10704 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10705 tunnel_type, "tunnel-type");
10706 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
10707 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10708 tunnel_type_mask, RTE_UINT8);
10709 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
10710 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
10711 tunnel_id, "tunnel-id");
10712 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
10713 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
10714 tunnel_id_mask, RTE_UINT32);
10716 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
10717 .f = cmd_flow_director_mask_parsed,
10719 .help_str = "flow_director_mask ... : "
10720 "Set IP mode flow director's mask on NIC",
10722 (void *)&cmd_flow_director_mask,
10723 (void *)&cmd_flow_director_mask_port_id,
10724 (void *)&cmd_flow_director_mask_mode,
10725 (void *)&cmd_flow_director_mask_mode_ip,
10726 (void *)&cmd_flow_director_mask_vlan,
10727 (void *)&cmd_flow_director_mask_vlan_value,
10728 (void *)&cmd_flow_director_mask_src,
10729 (void *)&cmd_flow_director_mask_ipv4_src,
10730 (void *)&cmd_flow_director_mask_ipv6_src,
10731 (void *)&cmd_flow_director_mask_port_src,
10732 (void *)&cmd_flow_director_mask_dst,
10733 (void *)&cmd_flow_director_mask_ipv4_dst,
10734 (void *)&cmd_flow_director_mask_ipv6_dst,
10735 (void *)&cmd_flow_director_mask_port_dst,
10740 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
10741 .f = cmd_flow_director_mask_parsed,
10743 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
10744 "flow director's mask on NIC",
10746 (void *)&cmd_flow_director_mask,
10747 (void *)&cmd_flow_director_mask_port_id,
10748 (void *)&cmd_flow_director_mask_mode,
10749 (void *)&cmd_flow_director_mask_mode_mac_vlan,
10750 (void *)&cmd_flow_director_mask_vlan,
10751 (void *)&cmd_flow_director_mask_vlan_value,
10756 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
10757 .f = cmd_flow_director_mask_parsed,
10759 .help_str = "flow_director_mask ... : Set tunnel mode "
10760 "flow director's mask on NIC",
10762 (void *)&cmd_flow_director_mask,
10763 (void *)&cmd_flow_director_mask_port_id,
10764 (void *)&cmd_flow_director_mask_mode,
10765 (void *)&cmd_flow_director_mask_mode_tunnel,
10766 (void *)&cmd_flow_director_mask_vlan,
10767 (void *)&cmd_flow_director_mask_vlan_value,
10768 (void *)&cmd_flow_director_mask_mac,
10769 (void *)&cmd_flow_director_mask_mac_value,
10770 (void *)&cmd_flow_director_mask_tunnel_type,
10771 (void *)&cmd_flow_director_mask_tunnel_type_value,
10772 (void *)&cmd_flow_director_mask_tunnel_id,
10773 (void *)&cmd_flow_director_mask_tunnel_id_value,
10778 /* *** deal with flow director flexible payload configuration *** */
10779 struct cmd_flow_director_flexpayload_result {
10780 cmdline_fixed_string_t flow_director_flexpayload;
10782 cmdline_fixed_string_t payload_layer;
10783 cmdline_fixed_string_t payload_cfg;
10787 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
10790 const char *p, *p0 = q_arg;
10792 unsigned long int_fld;
10793 char *str_fld[max_num];
10798 p = strchr(p0, '(');
10802 p0 = strchr(p, ')');
10807 if (size >= sizeof(s))
10810 snprintf(s, sizeof(s), "%.*s", size, p);
10811 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10812 if (ret < 0 || ret > max_num)
10814 for (i = 0; i < ret; i++) {
10816 int_fld = strtoul(str_fld[i], &end, 0);
10817 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
10819 offsets[i] = (uint16_t)int_fld;
10825 cmd_flow_director_flxpld_parsed(void *parsed_result,
10826 __rte_unused struct cmdline *cl,
10827 __rte_unused void *data)
10829 struct cmd_flow_director_flexpayload_result *res = parsed_result;
10830 struct rte_eth_flex_payload_cfg flex_cfg;
10831 struct rte_port *port;
10834 port = &ports[res->port_id];
10835 /** Check if the port is not started **/
10836 if (port->port_status != RTE_PORT_STOPPED) {
10837 fprintf(stderr, "Please stop port %d first\n", res->port_id);
10841 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
10843 if (!strcmp(res->payload_layer, "raw"))
10844 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
10845 else if (!strcmp(res->payload_layer, "l2"))
10846 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
10847 else if (!strcmp(res->payload_layer, "l3"))
10848 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
10849 else if (!strcmp(res->payload_layer, "l4"))
10850 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
10852 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
10853 RTE_ETH_FDIR_MAX_FLEXLEN);
10855 fprintf(stderr, "error: Cannot parse flex payload input.\n");
10859 fdir_set_flex_payload(res->port_id, &flex_cfg);
10860 cmd_reconfig_device_queue(res->port_id, 1, 1);
10863 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
10864 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10865 flow_director_flexpayload,
10866 "flow_director_flex_payload");
10867 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
10868 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10869 port_id, RTE_UINT16);
10870 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
10871 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10872 payload_layer, "raw#l2#l3#l4");
10873 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
10874 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
10875 payload_cfg, NULL);
10877 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
10878 .f = cmd_flow_director_flxpld_parsed,
10880 .help_str = "flow_director_flexpayload ... : "
10881 "Set flow director's flex payload on NIC",
10883 (void *)&cmd_flow_director_flexpayload,
10884 (void *)&cmd_flow_director_flexpayload_port_id,
10885 (void *)&cmd_flow_director_flexpayload_payload_layer,
10886 (void *)&cmd_flow_director_flexpayload_payload_cfg,
10891 /* Generic flow interface command. */
10892 extern cmdline_parse_inst_t cmd_flow;
10894 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
10895 struct cmd_mcast_addr_result {
10896 cmdline_fixed_string_t mcast_addr_cmd;
10897 cmdline_fixed_string_t what;
10899 struct rte_ether_addr mc_addr;
10902 static void cmd_mcast_addr_parsed(void *parsed_result,
10903 __rte_unused struct cmdline *cl,
10904 __rte_unused void *data)
10906 struct cmd_mcast_addr_result *res = parsed_result;
10908 if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
10910 "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
10911 RTE_ETHER_ADDR_BYTES(&res->mc_addr));
10914 if (strcmp(res->what, "add") == 0)
10915 mcast_addr_add(res->port_num, &res->mc_addr);
10917 mcast_addr_remove(res->port_num, &res->mc_addr);
10920 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
10921 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
10922 mcast_addr_cmd, "mcast_addr");
10923 cmdline_parse_token_string_t cmd_mcast_addr_what =
10924 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
10926 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
10927 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
10929 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
10930 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
10932 cmdline_parse_inst_t cmd_mcast_addr = {
10933 .f = cmd_mcast_addr_parsed,
10935 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
10936 "Add/Remove multicast MAC address on port_id",
10938 (void *)&cmd_mcast_addr_cmd,
10939 (void *)&cmd_mcast_addr_what,
10940 (void *)&cmd_mcast_addr_portnum,
10941 (void *)&cmd_mcast_addr_addr,
10946 /* vf vlan anti spoof configuration */
10948 /* Common result structure for vf vlan anti spoof */
10949 struct cmd_vf_vlan_anti_spoof_result {
10950 cmdline_fixed_string_t set;
10951 cmdline_fixed_string_t vf;
10952 cmdline_fixed_string_t vlan;
10953 cmdline_fixed_string_t antispoof;
10956 cmdline_fixed_string_t on_off;
10959 /* Common CLI fields for vf vlan anti spoof enable disable */
10960 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
10961 TOKEN_STRING_INITIALIZER
10962 (struct cmd_vf_vlan_anti_spoof_result,
10964 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
10965 TOKEN_STRING_INITIALIZER
10966 (struct cmd_vf_vlan_anti_spoof_result,
10968 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
10969 TOKEN_STRING_INITIALIZER
10970 (struct cmd_vf_vlan_anti_spoof_result,
10972 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
10973 TOKEN_STRING_INITIALIZER
10974 (struct cmd_vf_vlan_anti_spoof_result,
10975 antispoof, "antispoof");
10976 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
10977 TOKEN_NUM_INITIALIZER
10978 (struct cmd_vf_vlan_anti_spoof_result,
10979 port_id, RTE_UINT16);
10980 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
10981 TOKEN_NUM_INITIALIZER
10982 (struct cmd_vf_vlan_anti_spoof_result,
10983 vf_id, RTE_UINT32);
10984 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
10985 TOKEN_STRING_INITIALIZER
10986 (struct cmd_vf_vlan_anti_spoof_result,
10990 cmd_set_vf_vlan_anti_spoof_parsed(
10991 void *parsed_result,
10992 __rte_unused struct cmdline *cl,
10993 __rte_unused void *data)
10995 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
10996 int ret = -ENOTSUP;
10998 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11000 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11003 #ifdef RTE_NET_IXGBE
11004 if (ret == -ENOTSUP)
11005 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
11006 res->vf_id, is_on);
11008 #ifdef RTE_NET_I40E
11009 if (ret == -ENOTSUP)
11010 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
11011 res->vf_id, is_on);
11013 #ifdef RTE_NET_BNXT
11014 if (ret == -ENOTSUP)
11015 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
11016 res->vf_id, is_on);
11023 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11026 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11029 fprintf(stderr, "function not implemented\n");
11032 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11036 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
11037 .f = cmd_set_vf_vlan_anti_spoof_parsed,
11039 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
11041 (void *)&cmd_vf_vlan_anti_spoof_set,
11042 (void *)&cmd_vf_vlan_anti_spoof_vf,
11043 (void *)&cmd_vf_vlan_anti_spoof_vlan,
11044 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
11045 (void *)&cmd_vf_vlan_anti_spoof_port_id,
11046 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
11047 (void *)&cmd_vf_vlan_anti_spoof_on_off,
11052 /* vf mac anti spoof configuration */
11054 /* Common result structure for vf mac anti spoof */
11055 struct cmd_vf_mac_anti_spoof_result {
11056 cmdline_fixed_string_t set;
11057 cmdline_fixed_string_t vf;
11058 cmdline_fixed_string_t mac;
11059 cmdline_fixed_string_t antispoof;
11062 cmdline_fixed_string_t on_off;
11065 /* Common CLI fields for vf mac anti spoof enable disable */
11066 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
11067 TOKEN_STRING_INITIALIZER
11068 (struct cmd_vf_mac_anti_spoof_result,
11070 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
11071 TOKEN_STRING_INITIALIZER
11072 (struct cmd_vf_mac_anti_spoof_result,
11074 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
11075 TOKEN_STRING_INITIALIZER
11076 (struct cmd_vf_mac_anti_spoof_result,
11078 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
11079 TOKEN_STRING_INITIALIZER
11080 (struct cmd_vf_mac_anti_spoof_result,
11081 antispoof, "antispoof");
11082 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
11083 TOKEN_NUM_INITIALIZER
11084 (struct cmd_vf_mac_anti_spoof_result,
11085 port_id, RTE_UINT16);
11086 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
11087 TOKEN_NUM_INITIALIZER
11088 (struct cmd_vf_mac_anti_spoof_result,
11089 vf_id, RTE_UINT32);
11090 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
11091 TOKEN_STRING_INITIALIZER
11092 (struct cmd_vf_mac_anti_spoof_result,
11096 cmd_set_vf_mac_anti_spoof_parsed(
11097 void *parsed_result,
11098 __rte_unused struct cmdline *cl,
11099 __rte_unused void *data)
11101 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
11102 int ret = -ENOTSUP;
11104 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11106 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11109 #ifdef RTE_NET_IXGBE
11110 if (ret == -ENOTSUP)
11111 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
11112 res->vf_id, is_on);
11114 #ifdef RTE_NET_I40E
11115 if (ret == -ENOTSUP)
11116 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
11117 res->vf_id, is_on);
11119 #ifdef RTE_NET_BNXT
11120 if (ret == -ENOTSUP)
11121 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
11122 res->vf_id, is_on);
11129 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11130 res->vf_id, is_on);
11133 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11136 fprintf(stderr, "function not implemented\n");
11139 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11143 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
11144 .f = cmd_set_vf_mac_anti_spoof_parsed,
11146 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
11148 (void *)&cmd_vf_mac_anti_spoof_set,
11149 (void *)&cmd_vf_mac_anti_spoof_vf,
11150 (void *)&cmd_vf_mac_anti_spoof_mac,
11151 (void *)&cmd_vf_mac_anti_spoof_antispoof,
11152 (void *)&cmd_vf_mac_anti_spoof_port_id,
11153 (void *)&cmd_vf_mac_anti_spoof_vf_id,
11154 (void *)&cmd_vf_mac_anti_spoof_on_off,
11159 /* vf vlan strip queue configuration */
11161 /* Common result structure for vf mac anti spoof */
11162 struct cmd_vf_vlan_stripq_result {
11163 cmdline_fixed_string_t set;
11164 cmdline_fixed_string_t vf;
11165 cmdline_fixed_string_t vlan;
11166 cmdline_fixed_string_t stripq;
11169 cmdline_fixed_string_t on_off;
11172 /* Common CLI fields for vf vlan strip enable disable */
11173 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
11174 TOKEN_STRING_INITIALIZER
11175 (struct cmd_vf_vlan_stripq_result,
11177 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
11178 TOKEN_STRING_INITIALIZER
11179 (struct cmd_vf_vlan_stripq_result,
11181 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
11182 TOKEN_STRING_INITIALIZER
11183 (struct cmd_vf_vlan_stripq_result,
11185 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
11186 TOKEN_STRING_INITIALIZER
11187 (struct cmd_vf_vlan_stripq_result,
11189 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
11190 TOKEN_NUM_INITIALIZER
11191 (struct cmd_vf_vlan_stripq_result,
11192 port_id, RTE_UINT16);
11193 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
11194 TOKEN_NUM_INITIALIZER
11195 (struct cmd_vf_vlan_stripq_result,
11196 vf_id, RTE_UINT16);
11197 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
11198 TOKEN_STRING_INITIALIZER
11199 (struct cmd_vf_vlan_stripq_result,
11203 cmd_set_vf_vlan_stripq_parsed(
11204 void *parsed_result,
11205 __rte_unused struct cmdline *cl,
11206 __rte_unused void *data)
11208 struct cmd_vf_vlan_stripq_result *res = parsed_result;
11209 int ret = -ENOTSUP;
11211 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11213 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11216 #ifdef RTE_NET_IXGBE
11217 if (ret == -ENOTSUP)
11218 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
11219 res->vf_id, is_on);
11221 #ifdef RTE_NET_I40E
11222 if (ret == -ENOTSUP)
11223 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
11224 res->vf_id, is_on);
11226 #ifdef RTE_NET_BNXT
11227 if (ret == -ENOTSUP)
11228 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
11229 res->vf_id, is_on);
11236 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11237 res->vf_id, is_on);
11240 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11243 fprintf(stderr, "function not implemented\n");
11246 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11250 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
11251 .f = cmd_set_vf_vlan_stripq_parsed,
11253 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
11255 (void *)&cmd_vf_vlan_stripq_set,
11256 (void *)&cmd_vf_vlan_stripq_vf,
11257 (void *)&cmd_vf_vlan_stripq_vlan,
11258 (void *)&cmd_vf_vlan_stripq_stripq,
11259 (void *)&cmd_vf_vlan_stripq_port_id,
11260 (void *)&cmd_vf_vlan_stripq_vf_id,
11261 (void *)&cmd_vf_vlan_stripq_on_off,
11266 /* vf vlan insert configuration */
11268 /* Common result structure for vf vlan insert */
11269 struct cmd_vf_vlan_insert_result {
11270 cmdline_fixed_string_t set;
11271 cmdline_fixed_string_t vf;
11272 cmdline_fixed_string_t vlan;
11273 cmdline_fixed_string_t insert;
11279 /* Common CLI fields for vf vlan insert enable disable */
11280 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
11281 TOKEN_STRING_INITIALIZER
11282 (struct cmd_vf_vlan_insert_result,
11284 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
11285 TOKEN_STRING_INITIALIZER
11286 (struct cmd_vf_vlan_insert_result,
11288 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
11289 TOKEN_STRING_INITIALIZER
11290 (struct cmd_vf_vlan_insert_result,
11292 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
11293 TOKEN_STRING_INITIALIZER
11294 (struct cmd_vf_vlan_insert_result,
11296 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
11297 TOKEN_NUM_INITIALIZER
11298 (struct cmd_vf_vlan_insert_result,
11299 port_id, RTE_UINT16);
11300 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
11301 TOKEN_NUM_INITIALIZER
11302 (struct cmd_vf_vlan_insert_result,
11303 vf_id, RTE_UINT16);
11304 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
11305 TOKEN_NUM_INITIALIZER
11306 (struct cmd_vf_vlan_insert_result,
11307 vlan_id, RTE_UINT16);
11310 cmd_set_vf_vlan_insert_parsed(
11311 void *parsed_result,
11312 __rte_unused struct cmdline *cl,
11313 __rte_unused void *data)
11315 struct cmd_vf_vlan_insert_result *res = parsed_result;
11316 int ret = -ENOTSUP;
11318 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11321 #ifdef RTE_NET_IXGBE
11322 if (ret == -ENOTSUP)
11323 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
11326 #ifdef RTE_NET_I40E
11327 if (ret == -ENOTSUP)
11328 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
11331 #ifdef RTE_NET_BNXT
11332 if (ret == -ENOTSUP)
11333 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
11341 fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
11342 res->vf_id, res->vlan_id);
11345 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11348 fprintf(stderr, "function not implemented\n");
11351 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11355 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
11356 .f = cmd_set_vf_vlan_insert_parsed,
11358 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
11360 (void *)&cmd_vf_vlan_insert_set,
11361 (void *)&cmd_vf_vlan_insert_vf,
11362 (void *)&cmd_vf_vlan_insert_vlan,
11363 (void *)&cmd_vf_vlan_insert_insert,
11364 (void *)&cmd_vf_vlan_insert_port_id,
11365 (void *)&cmd_vf_vlan_insert_vf_id,
11366 (void *)&cmd_vf_vlan_insert_vlan_id,
11371 /* tx loopback configuration */
11373 /* Common result structure for tx loopback */
11374 struct cmd_tx_loopback_result {
11375 cmdline_fixed_string_t set;
11376 cmdline_fixed_string_t tx;
11377 cmdline_fixed_string_t loopback;
11379 cmdline_fixed_string_t on_off;
11382 /* Common CLI fields for tx loopback enable disable */
11383 cmdline_parse_token_string_t cmd_tx_loopback_set =
11384 TOKEN_STRING_INITIALIZER
11385 (struct cmd_tx_loopback_result,
11387 cmdline_parse_token_string_t cmd_tx_loopback_tx =
11388 TOKEN_STRING_INITIALIZER
11389 (struct cmd_tx_loopback_result,
11391 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
11392 TOKEN_STRING_INITIALIZER
11393 (struct cmd_tx_loopback_result,
11394 loopback, "loopback");
11395 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
11396 TOKEN_NUM_INITIALIZER
11397 (struct cmd_tx_loopback_result,
11398 port_id, RTE_UINT16);
11399 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
11400 TOKEN_STRING_INITIALIZER
11401 (struct cmd_tx_loopback_result,
11405 cmd_set_tx_loopback_parsed(
11406 void *parsed_result,
11407 __rte_unused struct cmdline *cl,
11408 __rte_unused void *data)
11410 struct cmd_tx_loopback_result *res = parsed_result;
11411 int ret = -ENOTSUP;
11413 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11415 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11418 #ifdef RTE_NET_IXGBE
11419 if (ret == -ENOTSUP)
11420 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
11422 #ifdef RTE_NET_I40E
11423 if (ret == -ENOTSUP)
11424 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
11426 #ifdef RTE_NET_BNXT
11427 if (ret == -ENOTSUP)
11428 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
11430 #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
11431 if (ret == -ENOTSUP)
11432 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
11439 fprintf(stderr, "invalid is_on %d\n", is_on);
11442 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11445 fprintf(stderr, "function not implemented\n");
11448 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11452 cmdline_parse_inst_t cmd_set_tx_loopback = {
11453 .f = cmd_set_tx_loopback_parsed,
11455 .help_str = "set tx loopback <port_id> on|off",
11457 (void *)&cmd_tx_loopback_set,
11458 (void *)&cmd_tx_loopback_tx,
11459 (void *)&cmd_tx_loopback_loopback,
11460 (void *)&cmd_tx_loopback_port_id,
11461 (void *)&cmd_tx_loopback_on_off,
11466 /* all queues drop enable configuration */
11468 /* Common result structure for all queues drop enable */
11469 struct cmd_all_queues_drop_en_result {
11470 cmdline_fixed_string_t set;
11471 cmdline_fixed_string_t all;
11472 cmdline_fixed_string_t queues;
11473 cmdline_fixed_string_t drop;
11475 cmdline_fixed_string_t on_off;
11478 /* Common CLI fields for tx loopback enable disable */
11479 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
11480 TOKEN_STRING_INITIALIZER
11481 (struct cmd_all_queues_drop_en_result,
11483 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
11484 TOKEN_STRING_INITIALIZER
11485 (struct cmd_all_queues_drop_en_result,
11487 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
11488 TOKEN_STRING_INITIALIZER
11489 (struct cmd_all_queues_drop_en_result,
11491 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
11492 TOKEN_STRING_INITIALIZER
11493 (struct cmd_all_queues_drop_en_result,
11495 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
11496 TOKEN_NUM_INITIALIZER
11497 (struct cmd_all_queues_drop_en_result,
11498 port_id, RTE_UINT16);
11499 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
11500 TOKEN_STRING_INITIALIZER
11501 (struct cmd_all_queues_drop_en_result,
11505 cmd_set_all_queues_drop_en_parsed(
11506 void *parsed_result,
11507 __rte_unused struct cmdline *cl,
11508 __rte_unused void *data)
11510 struct cmd_all_queues_drop_en_result *res = parsed_result;
11511 int ret = -ENOTSUP;
11512 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11514 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11517 #ifdef RTE_NET_IXGBE
11518 if (ret == -ENOTSUP)
11519 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
11521 #ifdef RTE_NET_BNXT
11522 if (ret == -ENOTSUP)
11523 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
11529 fprintf(stderr, "invalid is_on %d\n", is_on);
11532 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11535 fprintf(stderr, "function not implemented\n");
11538 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11542 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
11543 .f = cmd_set_all_queues_drop_en_parsed,
11545 .help_str = "set all queues drop <port_id> on|off",
11547 (void *)&cmd_all_queues_drop_en_set,
11548 (void *)&cmd_all_queues_drop_en_all,
11549 (void *)&cmd_all_queues_drop_en_queues,
11550 (void *)&cmd_all_queues_drop_en_drop,
11551 (void *)&cmd_all_queues_drop_en_port_id,
11552 (void *)&cmd_all_queues_drop_en_on_off,
11557 /* vf split drop enable configuration */
11559 /* Common result structure for vf split drop enable */
11560 struct cmd_vf_split_drop_en_result {
11561 cmdline_fixed_string_t set;
11562 cmdline_fixed_string_t vf;
11563 cmdline_fixed_string_t split;
11564 cmdline_fixed_string_t drop;
11567 cmdline_fixed_string_t on_off;
11570 /* Common CLI fields for vf split drop enable disable */
11571 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
11572 TOKEN_STRING_INITIALIZER
11573 (struct cmd_vf_split_drop_en_result,
11575 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
11576 TOKEN_STRING_INITIALIZER
11577 (struct cmd_vf_split_drop_en_result,
11579 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
11580 TOKEN_STRING_INITIALIZER
11581 (struct cmd_vf_split_drop_en_result,
11583 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
11584 TOKEN_STRING_INITIALIZER
11585 (struct cmd_vf_split_drop_en_result,
11587 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
11588 TOKEN_NUM_INITIALIZER
11589 (struct cmd_vf_split_drop_en_result,
11590 port_id, RTE_UINT16);
11591 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
11592 TOKEN_NUM_INITIALIZER
11593 (struct cmd_vf_split_drop_en_result,
11594 vf_id, RTE_UINT16);
11595 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
11596 TOKEN_STRING_INITIALIZER
11597 (struct cmd_vf_split_drop_en_result,
11601 cmd_set_vf_split_drop_en_parsed(
11602 void *parsed_result,
11603 __rte_unused struct cmdline *cl,
11604 __rte_unused void *data)
11606 struct cmd_vf_split_drop_en_result *res = parsed_result;
11607 int ret = -ENOTSUP;
11608 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
11610 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11613 #ifdef RTE_NET_IXGBE
11614 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
11621 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
11622 res->vf_id, is_on);
11625 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11628 fprintf(stderr, "not supported on port %d\n", res->port_id);
11631 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11635 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
11636 .f = cmd_set_vf_split_drop_en_parsed,
11638 .help_str = "set vf split drop <port_id> <vf_id> on|off",
11640 (void *)&cmd_vf_split_drop_en_set,
11641 (void *)&cmd_vf_split_drop_en_vf,
11642 (void *)&cmd_vf_split_drop_en_split,
11643 (void *)&cmd_vf_split_drop_en_drop,
11644 (void *)&cmd_vf_split_drop_en_port_id,
11645 (void *)&cmd_vf_split_drop_en_vf_id,
11646 (void *)&cmd_vf_split_drop_en_on_off,
11651 /* vf mac address configuration */
11653 /* Common result structure for vf mac address */
11654 struct cmd_set_vf_mac_addr_result {
11655 cmdline_fixed_string_t set;
11656 cmdline_fixed_string_t vf;
11657 cmdline_fixed_string_t mac;
11658 cmdline_fixed_string_t addr;
11661 struct rte_ether_addr mac_addr;
11665 /* Common CLI fields for vf split drop enable disable */
11666 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
11667 TOKEN_STRING_INITIALIZER
11668 (struct cmd_set_vf_mac_addr_result,
11670 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
11671 TOKEN_STRING_INITIALIZER
11672 (struct cmd_set_vf_mac_addr_result,
11674 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
11675 TOKEN_STRING_INITIALIZER
11676 (struct cmd_set_vf_mac_addr_result,
11678 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
11679 TOKEN_STRING_INITIALIZER
11680 (struct cmd_set_vf_mac_addr_result,
11682 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
11683 TOKEN_NUM_INITIALIZER
11684 (struct cmd_set_vf_mac_addr_result,
11685 port_id, RTE_UINT16);
11686 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
11687 TOKEN_NUM_INITIALIZER
11688 (struct cmd_set_vf_mac_addr_result,
11689 vf_id, RTE_UINT16);
11690 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
11691 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
11695 cmd_set_vf_mac_addr_parsed(
11696 void *parsed_result,
11697 __rte_unused struct cmdline *cl,
11698 __rte_unused void *data)
11700 struct cmd_set_vf_mac_addr_result *res = parsed_result;
11701 int ret = -ENOTSUP;
11703 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11706 #ifdef RTE_NET_IXGBE
11707 if (ret == -ENOTSUP)
11708 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
11711 #ifdef RTE_NET_I40E
11712 if (ret == -ENOTSUP)
11713 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
11716 #ifdef RTE_NET_BNXT
11717 if (ret == -ENOTSUP)
11718 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
11726 fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
11729 fprintf(stderr, "invalid port_id %d\n", res->port_id);
11732 fprintf(stderr, "function not implemented\n");
11735 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11739 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
11740 .f = cmd_set_vf_mac_addr_parsed,
11742 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
11744 (void *)&cmd_set_vf_mac_addr_set,
11745 (void *)&cmd_set_vf_mac_addr_vf,
11746 (void *)&cmd_set_vf_mac_addr_mac,
11747 (void *)&cmd_set_vf_mac_addr_addr,
11748 (void *)&cmd_set_vf_mac_addr_port_id,
11749 (void *)&cmd_set_vf_mac_addr_vf_id,
11750 (void *)&cmd_set_vf_mac_addr_mac_addr,
11755 /* MACsec configuration */
11757 /* Common result structure for MACsec offload enable */
11758 struct cmd_macsec_offload_on_result {
11759 cmdline_fixed_string_t set;
11760 cmdline_fixed_string_t macsec;
11761 cmdline_fixed_string_t offload;
11763 cmdline_fixed_string_t on;
11764 cmdline_fixed_string_t encrypt;
11765 cmdline_fixed_string_t en_on_off;
11766 cmdline_fixed_string_t replay_protect;
11767 cmdline_fixed_string_t rp_on_off;
11770 /* Common CLI fields for MACsec offload disable */
11771 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
11772 TOKEN_STRING_INITIALIZER
11773 (struct cmd_macsec_offload_on_result,
11775 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
11776 TOKEN_STRING_INITIALIZER
11777 (struct cmd_macsec_offload_on_result,
11779 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
11780 TOKEN_STRING_INITIALIZER
11781 (struct cmd_macsec_offload_on_result,
11782 offload, "offload");
11783 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
11784 TOKEN_NUM_INITIALIZER
11785 (struct cmd_macsec_offload_on_result,
11786 port_id, RTE_UINT16);
11787 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
11788 TOKEN_STRING_INITIALIZER
11789 (struct cmd_macsec_offload_on_result,
11791 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
11792 TOKEN_STRING_INITIALIZER
11793 (struct cmd_macsec_offload_on_result,
11794 encrypt, "encrypt");
11795 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
11796 TOKEN_STRING_INITIALIZER
11797 (struct cmd_macsec_offload_on_result,
11798 en_on_off, "on#off");
11799 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
11800 TOKEN_STRING_INITIALIZER
11801 (struct cmd_macsec_offload_on_result,
11802 replay_protect, "replay-protect");
11803 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
11804 TOKEN_STRING_INITIALIZER
11805 (struct cmd_macsec_offload_on_result,
11806 rp_on_off, "on#off");
11809 cmd_set_macsec_offload_on_parsed(
11810 void *parsed_result,
11811 __rte_unused struct cmdline *cl,
11812 __rte_unused void *data)
11814 struct cmd_macsec_offload_on_result *res = parsed_result;
11815 int ret = -ENOTSUP;
11816 portid_t port_id = res->port_id;
11817 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
11818 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
11819 struct rte_eth_dev_info dev_info;
11821 if (port_id_is_invalid(port_id, ENABLED_WARN))
11823 if (!port_is_stopped(port_id)) {
11824 fprintf(stderr, "Please stop port %d first\n", port_id);
11828 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11832 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11833 #ifdef RTE_NET_IXGBE
11834 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
11842 ports[port_id].dev_conf.txmode.offloads |=
11843 DEV_TX_OFFLOAD_MACSEC_INSERT;
11844 cmd_reconfig_device_queue(port_id, 1, 1);
11847 fprintf(stderr, "invalid port_id %d\n", port_id);
11850 fprintf(stderr, "not supported on port %d\n", port_id);
11853 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11857 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
11858 .f = cmd_set_macsec_offload_on_parsed,
11860 .help_str = "set macsec offload <port_id> on "
11861 "encrypt on|off replay-protect on|off",
11863 (void *)&cmd_macsec_offload_on_set,
11864 (void *)&cmd_macsec_offload_on_macsec,
11865 (void *)&cmd_macsec_offload_on_offload,
11866 (void *)&cmd_macsec_offload_on_port_id,
11867 (void *)&cmd_macsec_offload_on_on,
11868 (void *)&cmd_macsec_offload_on_encrypt,
11869 (void *)&cmd_macsec_offload_on_en_on_off,
11870 (void *)&cmd_macsec_offload_on_replay_protect,
11871 (void *)&cmd_macsec_offload_on_rp_on_off,
11876 /* Common result structure for MACsec offload disable */
11877 struct cmd_macsec_offload_off_result {
11878 cmdline_fixed_string_t set;
11879 cmdline_fixed_string_t macsec;
11880 cmdline_fixed_string_t offload;
11882 cmdline_fixed_string_t off;
11885 /* Common CLI fields for MACsec offload disable */
11886 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
11887 TOKEN_STRING_INITIALIZER
11888 (struct cmd_macsec_offload_off_result,
11890 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
11891 TOKEN_STRING_INITIALIZER
11892 (struct cmd_macsec_offload_off_result,
11894 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
11895 TOKEN_STRING_INITIALIZER
11896 (struct cmd_macsec_offload_off_result,
11897 offload, "offload");
11898 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
11899 TOKEN_NUM_INITIALIZER
11900 (struct cmd_macsec_offload_off_result,
11901 port_id, RTE_UINT16);
11902 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
11903 TOKEN_STRING_INITIALIZER
11904 (struct cmd_macsec_offload_off_result,
11908 cmd_set_macsec_offload_off_parsed(
11909 void *parsed_result,
11910 __rte_unused struct cmdline *cl,
11911 __rte_unused void *data)
11913 struct cmd_macsec_offload_off_result *res = parsed_result;
11914 int ret = -ENOTSUP;
11915 struct rte_eth_dev_info dev_info;
11916 portid_t port_id = res->port_id;
11918 if (port_id_is_invalid(port_id, ENABLED_WARN))
11920 if (!port_is_stopped(port_id)) {
11921 fprintf(stderr, "Please stop port %d first\n", port_id);
11925 ret = eth_dev_info_get_print_err(port_id, &dev_info);
11929 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
11930 #ifdef RTE_NET_IXGBE
11931 ret = rte_pmd_ixgbe_macsec_disable(port_id);
11936 ports[port_id].dev_conf.txmode.offloads &=
11937 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
11938 cmd_reconfig_device_queue(port_id, 1, 1);
11941 fprintf(stderr, "invalid port_id %d\n", port_id);
11944 fprintf(stderr, "not supported on port %d\n", port_id);
11947 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11951 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
11952 .f = cmd_set_macsec_offload_off_parsed,
11954 .help_str = "set macsec offload <port_id> off",
11956 (void *)&cmd_macsec_offload_off_set,
11957 (void *)&cmd_macsec_offload_off_macsec,
11958 (void *)&cmd_macsec_offload_off_offload,
11959 (void *)&cmd_macsec_offload_off_port_id,
11960 (void *)&cmd_macsec_offload_off_off,
11965 /* Common result structure for MACsec secure connection configure */
11966 struct cmd_macsec_sc_result {
11967 cmdline_fixed_string_t set;
11968 cmdline_fixed_string_t macsec;
11969 cmdline_fixed_string_t sc;
11970 cmdline_fixed_string_t tx_rx;
11972 struct rte_ether_addr mac;
11976 /* Common CLI fields for MACsec secure connection configure */
11977 cmdline_parse_token_string_t cmd_macsec_sc_set =
11978 TOKEN_STRING_INITIALIZER
11979 (struct cmd_macsec_sc_result,
11981 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
11982 TOKEN_STRING_INITIALIZER
11983 (struct cmd_macsec_sc_result,
11985 cmdline_parse_token_string_t cmd_macsec_sc_sc =
11986 TOKEN_STRING_INITIALIZER
11987 (struct cmd_macsec_sc_result,
11989 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
11990 TOKEN_STRING_INITIALIZER
11991 (struct cmd_macsec_sc_result,
11993 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
11994 TOKEN_NUM_INITIALIZER
11995 (struct cmd_macsec_sc_result,
11996 port_id, RTE_UINT16);
11997 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
11998 TOKEN_ETHERADDR_INITIALIZER
11999 (struct cmd_macsec_sc_result,
12001 cmdline_parse_token_num_t cmd_macsec_sc_pi =
12002 TOKEN_NUM_INITIALIZER
12003 (struct cmd_macsec_sc_result,
12007 cmd_set_macsec_sc_parsed(
12008 void *parsed_result,
12009 __rte_unused struct cmdline *cl,
12010 __rte_unused void *data)
12012 struct cmd_macsec_sc_result *res = parsed_result;
12013 int ret = -ENOTSUP;
12014 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12016 #ifdef RTE_NET_IXGBE
12018 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
12019 res->mac.addr_bytes) :
12020 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
12021 res->mac.addr_bytes, res->pi);
12023 RTE_SET_USED(is_tx);
12029 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12032 fprintf(stderr, "not supported on port %d\n", res->port_id);
12035 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12039 cmdline_parse_inst_t cmd_set_macsec_sc = {
12040 .f = cmd_set_macsec_sc_parsed,
12042 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
12044 (void *)&cmd_macsec_sc_set,
12045 (void *)&cmd_macsec_sc_macsec,
12046 (void *)&cmd_macsec_sc_sc,
12047 (void *)&cmd_macsec_sc_tx_rx,
12048 (void *)&cmd_macsec_sc_port_id,
12049 (void *)&cmd_macsec_sc_mac,
12050 (void *)&cmd_macsec_sc_pi,
12055 /* Common result structure for MACsec secure connection configure */
12056 struct cmd_macsec_sa_result {
12057 cmdline_fixed_string_t set;
12058 cmdline_fixed_string_t macsec;
12059 cmdline_fixed_string_t sa;
12060 cmdline_fixed_string_t tx_rx;
12065 cmdline_fixed_string_t key;
12068 /* Common CLI fields for MACsec secure connection configure */
12069 cmdline_parse_token_string_t cmd_macsec_sa_set =
12070 TOKEN_STRING_INITIALIZER
12071 (struct cmd_macsec_sa_result,
12073 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
12074 TOKEN_STRING_INITIALIZER
12075 (struct cmd_macsec_sa_result,
12077 cmdline_parse_token_string_t cmd_macsec_sa_sa =
12078 TOKEN_STRING_INITIALIZER
12079 (struct cmd_macsec_sa_result,
12081 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
12082 TOKEN_STRING_INITIALIZER
12083 (struct cmd_macsec_sa_result,
12085 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
12086 TOKEN_NUM_INITIALIZER
12087 (struct cmd_macsec_sa_result,
12088 port_id, RTE_UINT16);
12089 cmdline_parse_token_num_t cmd_macsec_sa_idx =
12090 TOKEN_NUM_INITIALIZER
12091 (struct cmd_macsec_sa_result,
12093 cmdline_parse_token_num_t cmd_macsec_sa_an =
12094 TOKEN_NUM_INITIALIZER
12095 (struct cmd_macsec_sa_result,
12097 cmdline_parse_token_num_t cmd_macsec_sa_pn =
12098 TOKEN_NUM_INITIALIZER
12099 (struct cmd_macsec_sa_result,
12101 cmdline_parse_token_string_t cmd_macsec_sa_key =
12102 TOKEN_STRING_INITIALIZER
12103 (struct cmd_macsec_sa_result,
12107 cmd_set_macsec_sa_parsed(
12108 void *parsed_result,
12109 __rte_unused struct cmdline *cl,
12110 __rte_unused void *data)
12112 struct cmd_macsec_sa_result *res = parsed_result;
12113 int ret = -ENOTSUP;
12114 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
12115 uint8_t key[16] = { 0 };
12121 key_len = strlen(res->key) / 2;
12125 for (i = 0; i < key_len; i++) {
12126 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
12129 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
12132 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
12135 #ifdef RTE_NET_IXGBE
12137 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
12138 res->idx, res->an, res->pn, key) :
12139 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
12140 res->idx, res->an, res->pn, key);
12142 RTE_SET_USED(is_tx);
12149 fprintf(stderr, "invalid idx %d or an %d\n", res->idx, res->an);
12152 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12155 fprintf(stderr, "not supported on port %d\n", res->port_id);
12158 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12162 cmdline_parse_inst_t cmd_set_macsec_sa = {
12163 .f = cmd_set_macsec_sa_parsed,
12165 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
12167 (void *)&cmd_macsec_sa_set,
12168 (void *)&cmd_macsec_sa_macsec,
12169 (void *)&cmd_macsec_sa_sa,
12170 (void *)&cmd_macsec_sa_tx_rx,
12171 (void *)&cmd_macsec_sa_port_id,
12172 (void *)&cmd_macsec_sa_idx,
12173 (void *)&cmd_macsec_sa_an,
12174 (void *)&cmd_macsec_sa_pn,
12175 (void *)&cmd_macsec_sa_key,
12180 /* VF unicast promiscuous mode configuration */
12182 /* Common result structure for VF unicast promiscuous mode */
12183 struct cmd_vf_promisc_result {
12184 cmdline_fixed_string_t set;
12185 cmdline_fixed_string_t vf;
12186 cmdline_fixed_string_t promisc;
12189 cmdline_fixed_string_t on_off;
12192 /* Common CLI fields for VF unicast promiscuous mode enable disable */
12193 cmdline_parse_token_string_t cmd_vf_promisc_set =
12194 TOKEN_STRING_INITIALIZER
12195 (struct cmd_vf_promisc_result,
12197 cmdline_parse_token_string_t cmd_vf_promisc_vf =
12198 TOKEN_STRING_INITIALIZER
12199 (struct cmd_vf_promisc_result,
12201 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
12202 TOKEN_STRING_INITIALIZER
12203 (struct cmd_vf_promisc_result,
12204 promisc, "promisc");
12205 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
12206 TOKEN_NUM_INITIALIZER
12207 (struct cmd_vf_promisc_result,
12208 port_id, RTE_UINT16);
12209 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
12210 TOKEN_NUM_INITIALIZER
12211 (struct cmd_vf_promisc_result,
12212 vf_id, RTE_UINT32);
12213 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
12214 TOKEN_STRING_INITIALIZER
12215 (struct cmd_vf_promisc_result,
12219 cmd_set_vf_promisc_parsed(
12220 void *parsed_result,
12221 __rte_unused struct cmdline *cl,
12222 __rte_unused void *data)
12224 struct cmd_vf_promisc_result *res = parsed_result;
12225 int ret = -ENOTSUP;
12227 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12229 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12232 #ifdef RTE_NET_I40E
12233 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
12234 res->vf_id, is_on);
12241 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12244 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12247 fprintf(stderr, "function not implemented\n");
12250 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12254 cmdline_parse_inst_t cmd_set_vf_promisc = {
12255 .f = cmd_set_vf_promisc_parsed,
12257 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
12258 "Set unicast promiscuous mode for a VF from the PF",
12260 (void *)&cmd_vf_promisc_set,
12261 (void *)&cmd_vf_promisc_vf,
12262 (void *)&cmd_vf_promisc_promisc,
12263 (void *)&cmd_vf_promisc_port_id,
12264 (void *)&cmd_vf_promisc_vf_id,
12265 (void *)&cmd_vf_promisc_on_off,
12270 /* VF multicast promiscuous mode configuration */
12272 /* Common result structure for VF multicast promiscuous mode */
12273 struct cmd_vf_allmulti_result {
12274 cmdline_fixed_string_t set;
12275 cmdline_fixed_string_t vf;
12276 cmdline_fixed_string_t allmulti;
12279 cmdline_fixed_string_t on_off;
12282 /* Common CLI fields for VF multicast promiscuous mode enable disable */
12283 cmdline_parse_token_string_t cmd_vf_allmulti_set =
12284 TOKEN_STRING_INITIALIZER
12285 (struct cmd_vf_allmulti_result,
12287 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
12288 TOKEN_STRING_INITIALIZER
12289 (struct cmd_vf_allmulti_result,
12291 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
12292 TOKEN_STRING_INITIALIZER
12293 (struct cmd_vf_allmulti_result,
12294 allmulti, "allmulti");
12295 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
12296 TOKEN_NUM_INITIALIZER
12297 (struct cmd_vf_allmulti_result,
12298 port_id, RTE_UINT16);
12299 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
12300 TOKEN_NUM_INITIALIZER
12301 (struct cmd_vf_allmulti_result,
12302 vf_id, RTE_UINT32);
12303 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
12304 TOKEN_STRING_INITIALIZER
12305 (struct cmd_vf_allmulti_result,
12309 cmd_set_vf_allmulti_parsed(
12310 void *parsed_result,
12311 __rte_unused struct cmdline *cl,
12312 __rte_unused void *data)
12314 struct cmd_vf_allmulti_result *res = parsed_result;
12315 int ret = -ENOTSUP;
12317 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12319 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12322 #ifdef RTE_NET_I40E
12323 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
12324 res->vf_id, is_on);
12331 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12334 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12337 fprintf(stderr, "function not implemented\n");
12340 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12344 cmdline_parse_inst_t cmd_set_vf_allmulti = {
12345 .f = cmd_set_vf_allmulti_parsed,
12347 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
12348 "Set multicast promiscuous mode for a VF from the PF",
12350 (void *)&cmd_vf_allmulti_set,
12351 (void *)&cmd_vf_allmulti_vf,
12352 (void *)&cmd_vf_allmulti_allmulti,
12353 (void *)&cmd_vf_allmulti_port_id,
12354 (void *)&cmd_vf_allmulti_vf_id,
12355 (void *)&cmd_vf_allmulti_on_off,
12360 /* vf broadcast mode configuration */
12362 /* Common result structure for vf broadcast */
12363 struct cmd_set_vf_broadcast_result {
12364 cmdline_fixed_string_t set;
12365 cmdline_fixed_string_t vf;
12366 cmdline_fixed_string_t broadcast;
12369 cmdline_fixed_string_t on_off;
12372 /* Common CLI fields for vf broadcast enable disable */
12373 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
12374 TOKEN_STRING_INITIALIZER
12375 (struct cmd_set_vf_broadcast_result,
12377 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
12378 TOKEN_STRING_INITIALIZER
12379 (struct cmd_set_vf_broadcast_result,
12381 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
12382 TOKEN_STRING_INITIALIZER
12383 (struct cmd_set_vf_broadcast_result,
12384 broadcast, "broadcast");
12385 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
12386 TOKEN_NUM_INITIALIZER
12387 (struct cmd_set_vf_broadcast_result,
12388 port_id, RTE_UINT16);
12389 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
12390 TOKEN_NUM_INITIALIZER
12391 (struct cmd_set_vf_broadcast_result,
12392 vf_id, RTE_UINT16);
12393 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
12394 TOKEN_STRING_INITIALIZER
12395 (struct cmd_set_vf_broadcast_result,
12399 cmd_set_vf_broadcast_parsed(
12400 void *parsed_result,
12401 __rte_unused struct cmdline *cl,
12402 __rte_unused void *data)
12404 struct cmd_set_vf_broadcast_result *res = parsed_result;
12405 int ret = -ENOTSUP;
12407 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12409 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12412 #ifdef RTE_NET_I40E
12413 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
12414 res->vf_id, is_on);
12421 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12422 res->vf_id, is_on);
12425 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12428 fprintf(stderr, "function not implemented\n");
12431 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12435 cmdline_parse_inst_t cmd_set_vf_broadcast = {
12436 .f = cmd_set_vf_broadcast_parsed,
12438 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
12440 (void *)&cmd_set_vf_broadcast_set,
12441 (void *)&cmd_set_vf_broadcast_vf,
12442 (void *)&cmd_set_vf_broadcast_broadcast,
12443 (void *)&cmd_set_vf_broadcast_port_id,
12444 (void *)&cmd_set_vf_broadcast_vf_id,
12445 (void *)&cmd_set_vf_broadcast_on_off,
12450 /* vf vlan tag configuration */
12452 /* Common result structure for vf vlan tag */
12453 struct cmd_set_vf_vlan_tag_result {
12454 cmdline_fixed_string_t set;
12455 cmdline_fixed_string_t vf;
12456 cmdline_fixed_string_t vlan;
12457 cmdline_fixed_string_t tag;
12460 cmdline_fixed_string_t on_off;
12463 /* Common CLI fields for vf vlan tag enable disable */
12464 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
12465 TOKEN_STRING_INITIALIZER
12466 (struct cmd_set_vf_vlan_tag_result,
12468 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
12469 TOKEN_STRING_INITIALIZER
12470 (struct cmd_set_vf_vlan_tag_result,
12472 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
12473 TOKEN_STRING_INITIALIZER
12474 (struct cmd_set_vf_vlan_tag_result,
12476 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
12477 TOKEN_STRING_INITIALIZER
12478 (struct cmd_set_vf_vlan_tag_result,
12480 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
12481 TOKEN_NUM_INITIALIZER
12482 (struct cmd_set_vf_vlan_tag_result,
12483 port_id, RTE_UINT16);
12484 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
12485 TOKEN_NUM_INITIALIZER
12486 (struct cmd_set_vf_vlan_tag_result,
12487 vf_id, RTE_UINT16);
12488 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
12489 TOKEN_STRING_INITIALIZER
12490 (struct cmd_set_vf_vlan_tag_result,
12494 cmd_set_vf_vlan_tag_parsed(
12495 void *parsed_result,
12496 __rte_unused struct cmdline *cl,
12497 __rte_unused void *data)
12499 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
12500 int ret = -ENOTSUP;
12502 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12504 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12507 #ifdef RTE_NET_I40E
12508 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
12509 res->vf_id, is_on);
12516 fprintf(stderr, "invalid vf_id %d or is_on %d\n",
12517 res->vf_id, is_on);
12520 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12523 fprintf(stderr, "function not implemented\n");
12526 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12530 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
12531 .f = cmd_set_vf_vlan_tag_parsed,
12533 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
12535 (void *)&cmd_set_vf_vlan_tag_set,
12536 (void *)&cmd_set_vf_vlan_tag_vf,
12537 (void *)&cmd_set_vf_vlan_tag_vlan,
12538 (void *)&cmd_set_vf_vlan_tag_tag,
12539 (void *)&cmd_set_vf_vlan_tag_port_id,
12540 (void *)&cmd_set_vf_vlan_tag_vf_id,
12541 (void *)&cmd_set_vf_vlan_tag_on_off,
12546 /* Common definition of VF and TC TX bandwidth configuration */
12547 struct cmd_vf_tc_bw_result {
12548 cmdline_fixed_string_t set;
12549 cmdline_fixed_string_t vf;
12550 cmdline_fixed_string_t tc;
12551 cmdline_fixed_string_t tx;
12552 cmdline_fixed_string_t min_bw;
12553 cmdline_fixed_string_t max_bw;
12554 cmdline_fixed_string_t strict_link_prio;
12559 cmdline_fixed_string_t bw_list;
12563 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
12564 TOKEN_STRING_INITIALIZER
12565 (struct cmd_vf_tc_bw_result,
12567 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
12568 TOKEN_STRING_INITIALIZER
12569 (struct cmd_vf_tc_bw_result,
12571 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
12572 TOKEN_STRING_INITIALIZER
12573 (struct cmd_vf_tc_bw_result,
12575 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
12576 TOKEN_STRING_INITIALIZER
12577 (struct cmd_vf_tc_bw_result,
12579 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
12580 TOKEN_STRING_INITIALIZER
12581 (struct cmd_vf_tc_bw_result,
12582 strict_link_prio, "strict-link-priority");
12583 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
12584 TOKEN_STRING_INITIALIZER
12585 (struct cmd_vf_tc_bw_result,
12586 min_bw, "min-bandwidth");
12587 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
12588 TOKEN_STRING_INITIALIZER
12589 (struct cmd_vf_tc_bw_result,
12590 max_bw, "max-bandwidth");
12591 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
12592 TOKEN_NUM_INITIALIZER
12593 (struct cmd_vf_tc_bw_result,
12594 port_id, RTE_UINT16);
12595 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
12596 TOKEN_NUM_INITIALIZER
12597 (struct cmd_vf_tc_bw_result,
12598 vf_id, RTE_UINT16);
12599 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
12600 TOKEN_NUM_INITIALIZER
12601 (struct cmd_vf_tc_bw_result,
12603 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
12604 TOKEN_NUM_INITIALIZER
12605 (struct cmd_vf_tc_bw_result,
12607 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
12608 TOKEN_STRING_INITIALIZER
12609 (struct cmd_vf_tc_bw_result,
12611 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
12612 TOKEN_NUM_INITIALIZER
12613 (struct cmd_vf_tc_bw_result,
12614 tc_map, RTE_UINT8);
12616 /* VF max bandwidth setting */
12618 cmd_vf_max_bw_parsed(
12619 void *parsed_result,
12620 __rte_unused struct cmdline *cl,
12621 __rte_unused void *data)
12623 struct cmd_vf_tc_bw_result *res = parsed_result;
12624 int ret = -ENOTSUP;
12626 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12629 #ifdef RTE_NET_I40E
12630 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
12631 res->vf_id, res->bw);
12638 fprintf(stderr, "invalid vf_id %d or bandwidth %d\n",
12639 res->vf_id, res->bw);
12642 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12645 fprintf(stderr, "function not implemented\n");
12648 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12652 cmdline_parse_inst_t cmd_vf_max_bw = {
12653 .f = cmd_vf_max_bw_parsed,
12655 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
12657 (void *)&cmd_vf_tc_bw_set,
12658 (void *)&cmd_vf_tc_bw_vf,
12659 (void *)&cmd_vf_tc_bw_tx,
12660 (void *)&cmd_vf_tc_bw_max_bw,
12661 (void *)&cmd_vf_tc_bw_port_id,
12662 (void *)&cmd_vf_tc_bw_vf_id,
12663 (void *)&cmd_vf_tc_bw_bw,
12669 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
12674 const char *p, *p0 = str;
12681 p = strchr(p0, '(');
12684 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12688 p0 = strchr(p, ')');
12691 "The bandwidth-list should be '(bw1, bw2, ...)'\n");
12695 if (size >= sizeof(s)) {
12697 "The string size exceeds the internal buffer size\n");
12700 snprintf(s, sizeof(s), "%.*s", size, p);
12701 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
12703 fprintf(stderr, "Failed to get the bandwidth list.\n");
12707 for (i = 0; i < ret; i++)
12708 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
12713 /* TC min bandwidth setting */
12715 cmd_vf_tc_min_bw_parsed(
12716 void *parsed_result,
12717 __rte_unused struct cmdline *cl,
12718 __rte_unused void *data)
12720 struct cmd_vf_tc_bw_result *res = parsed_result;
12723 int ret = -ENOTSUP;
12725 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12728 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12732 #ifdef RTE_NET_I40E
12733 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
12741 fprintf(stderr, "invalid vf_id %d or bandwidth\n", res->vf_id);
12744 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12747 fprintf(stderr, "function not implemented\n");
12750 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12754 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
12755 .f = cmd_vf_tc_min_bw_parsed,
12757 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
12758 " <bw1, bw2, ...>",
12760 (void *)&cmd_vf_tc_bw_set,
12761 (void *)&cmd_vf_tc_bw_vf,
12762 (void *)&cmd_vf_tc_bw_tc,
12763 (void *)&cmd_vf_tc_bw_tx,
12764 (void *)&cmd_vf_tc_bw_min_bw,
12765 (void *)&cmd_vf_tc_bw_port_id,
12766 (void *)&cmd_vf_tc_bw_vf_id,
12767 (void *)&cmd_vf_tc_bw_bw_list,
12773 cmd_tc_min_bw_parsed(
12774 void *parsed_result,
12775 __rte_unused struct cmdline *cl,
12776 __rte_unused void *data)
12778 struct cmd_vf_tc_bw_result *res = parsed_result;
12779 struct rte_port *port;
12782 int ret = -ENOTSUP;
12784 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12787 port = &ports[res->port_id];
12788 /** Check if the port is not started **/
12789 if (port->port_status != RTE_PORT_STOPPED) {
12790 fprintf(stderr, "Please stop port %d first\n", res->port_id);
12794 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
12798 #ifdef RTE_NET_IXGBE
12799 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
12806 fprintf(stderr, "invalid bandwidth\n");
12809 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12812 fprintf(stderr, "function not implemented\n");
12815 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12819 cmdline_parse_inst_t cmd_tc_min_bw = {
12820 .f = cmd_tc_min_bw_parsed,
12822 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
12824 (void *)&cmd_vf_tc_bw_set,
12825 (void *)&cmd_vf_tc_bw_tc,
12826 (void *)&cmd_vf_tc_bw_tx,
12827 (void *)&cmd_vf_tc_bw_min_bw,
12828 (void *)&cmd_vf_tc_bw_port_id,
12829 (void *)&cmd_vf_tc_bw_bw_list,
12834 /* TC max bandwidth setting */
12836 cmd_vf_tc_max_bw_parsed(
12837 void *parsed_result,
12838 __rte_unused struct cmdline *cl,
12839 __rte_unused void *data)
12841 struct cmd_vf_tc_bw_result *res = parsed_result;
12842 int ret = -ENOTSUP;
12844 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12847 #ifdef RTE_NET_I40E
12848 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
12849 res->tc_no, res->bw);
12857 "invalid vf_id %d, tc_no %d or bandwidth %d\n",
12858 res->vf_id, res->tc_no, res->bw);
12861 fprintf(stderr, "invalid port_id %d\n", res->port_id);
12864 fprintf(stderr, "function not implemented\n");
12867 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12871 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
12872 .f = cmd_vf_tc_max_bw_parsed,
12874 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
12877 (void *)&cmd_vf_tc_bw_set,
12878 (void *)&cmd_vf_tc_bw_vf,
12879 (void *)&cmd_vf_tc_bw_tc,
12880 (void *)&cmd_vf_tc_bw_tx,
12881 (void *)&cmd_vf_tc_bw_max_bw,
12882 (void *)&cmd_vf_tc_bw_port_id,
12883 (void *)&cmd_vf_tc_bw_vf_id,
12884 (void *)&cmd_vf_tc_bw_tc_no,
12885 (void *)&cmd_vf_tc_bw_bw,
12890 /** Set VXLAN encapsulation details */
12891 struct cmd_set_vxlan_result {
12892 cmdline_fixed_string_t set;
12893 cmdline_fixed_string_t vxlan;
12894 cmdline_fixed_string_t pos_token;
12895 cmdline_fixed_string_t ip_version;
12896 uint32_t vlan_present:1;
12900 cmdline_ipaddr_t ip_src;
12901 cmdline_ipaddr_t ip_dst;
12905 struct rte_ether_addr eth_src;
12906 struct rte_ether_addr eth_dst;
12909 cmdline_parse_token_string_t cmd_set_vxlan_set =
12910 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
12911 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
12912 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
12913 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
12914 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12916 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
12917 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
12918 "vxlan-with-vlan");
12919 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
12920 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12922 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
12923 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
12925 cmdline_parse_token_string_t cmd_set_vxlan_vni =
12926 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12928 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
12929 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
12930 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
12931 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12933 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
12934 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
12935 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
12936 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12938 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
12939 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
12940 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
12941 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12943 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
12944 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
12945 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
12946 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12948 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
12949 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
12950 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
12951 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12953 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
12954 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
12955 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
12956 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12958 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
12959 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
12960 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
12961 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12963 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
12964 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
12965 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
12966 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12968 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
12969 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
12970 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
12971 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
12973 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
12974 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
12976 static void cmd_set_vxlan_parsed(void *parsed_result,
12977 __rte_unused struct cmdline *cl,
12978 __rte_unused void *data)
12980 struct cmd_set_vxlan_result *res = parsed_result;
12985 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
12988 vxlan_encap_conf.select_tos_ttl = 0;
12989 if (strcmp(res->vxlan, "vxlan") == 0)
12990 vxlan_encap_conf.select_vlan = 0;
12991 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
12992 vxlan_encap_conf.select_vlan = 1;
12993 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
12994 vxlan_encap_conf.select_vlan = 0;
12995 vxlan_encap_conf.select_tos_ttl = 1;
12997 if (strcmp(res->ip_version, "ipv4") == 0)
12998 vxlan_encap_conf.select_ipv4 = 1;
12999 else if (strcmp(res->ip_version, "ipv6") == 0)
13000 vxlan_encap_conf.select_ipv4 = 0;
13003 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
13004 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13005 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13006 vxlan_encap_conf.ip_tos = res->tos;
13007 vxlan_encap_conf.ip_ttl = res->ttl;
13008 if (vxlan_encap_conf.select_ipv4) {
13009 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
13010 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
13012 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
13013 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
13015 if (vxlan_encap_conf.select_vlan)
13016 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13017 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
13018 RTE_ETHER_ADDR_LEN);
13019 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13020 RTE_ETHER_ADDR_LEN);
13023 cmdline_parse_inst_t cmd_set_vxlan = {
13024 .f = cmd_set_vxlan_parsed,
13026 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
13027 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
13028 " eth-src <eth-src> eth-dst <eth-dst>",
13030 (void *)&cmd_set_vxlan_set,
13031 (void *)&cmd_set_vxlan_vxlan,
13032 (void *)&cmd_set_vxlan_ip_version,
13033 (void *)&cmd_set_vxlan_ip_version_value,
13034 (void *)&cmd_set_vxlan_vni,
13035 (void *)&cmd_set_vxlan_vni_value,
13036 (void *)&cmd_set_vxlan_udp_src,
13037 (void *)&cmd_set_vxlan_udp_src_value,
13038 (void *)&cmd_set_vxlan_udp_dst,
13039 (void *)&cmd_set_vxlan_udp_dst_value,
13040 (void *)&cmd_set_vxlan_ip_src,
13041 (void *)&cmd_set_vxlan_ip_src_value,
13042 (void *)&cmd_set_vxlan_ip_dst,
13043 (void *)&cmd_set_vxlan_ip_dst_value,
13044 (void *)&cmd_set_vxlan_eth_src,
13045 (void *)&cmd_set_vxlan_eth_src_value,
13046 (void *)&cmd_set_vxlan_eth_dst,
13047 (void *)&cmd_set_vxlan_eth_dst_value,
13052 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
13053 .f = cmd_set_vxlan_parsed,
13055 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
13056 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
13057 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13058 " eth-dst <eth-dst>",
13060 (void *)&cmd_set_vxlan_set,
13061 (void *)&cmd_set_vxlan_vxlan_tos_ttl,
13062 (void *)&cmd_set_vxlan_ip_version,
13063 (void *)&cmd_set_vxlan_ip_version_value,
13064 (void *)&cmd_set_vxlan_vni,
13065 (void *)&cmd_set_vxlan_vni_value,
13066 (void *)&cmd_set_vxlan_udp_src,
13067 (void *)&cmd_set_vxlan_udp_src_value,
13068 (void *)&cmd_set_vxlan_udp_dst,
13069 (void *)&cmd_set_vxlan_udp_dst_value,
13070 (void *)&cmd_set_vxlan_ip_tos,
13071 (void *)&cmd_set_vxlan_ip_tos_value,
13072 (void *)&cmd_set_vxlan_ip_ttl,
13073 (void *)&cmd_set_vxlan_ip_ttl_value,
13074 (void *)&cmd_set_vxlan_ip_src,
13075 (void *)&cmd_set_vxlan_ip_src_value,
13076 (void *)&cmd_set_vxlan_ip_dst,
13077 (void *)&cmd_set_vxlan_ip_dst_value,
13078 (void *)&cmd_set_vxlan_eth_src,
13079 (void *)&cmd_set_vxlan_eth_src_value,
13080 (void *)&cmd_set_vxlan_eth_dst,
13081 (void *)&cmd_set_vxlan_eth_dst_value,
13086 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
13087 .f = cmd_set_vxlan_parsed,
13089 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
13090 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
13091 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
13094 (void *)&cmd_set_vxlan_set,
13095 (void *)&cmd_set_vxlan_vxlan_with_vlan,
13096 (void *)&cmd_set_vxlan_ip_version,
13097 (void *)&cmd_set_vxlan_ip_version_value,
13098 (void *)&cmd_set_vxlan_vni,
13099 (void *)&cmd_set_vxlan_vni_value,
13100 (void *)&cmd_set_vxlan_udp_src,
13101 (void *)&cmd_set_vxlan_udp_src_value,
13102 (void *)&cmd_set_vxlan_udp_dst,
13103 (void *)&cmd_set_vxlan_udp_dst_value,
13104 (void *)&cmd_set_vxlan_ip_src,
13105 (void *)&cmd_set_vxlan_ip_src_value,
13106 (void *)&cmd_set_vxlan_ip_dst,
13107 (void *)&cmd_set_vxlan_ip_dst_value,
13108 (void *)&cmd_set_vxlan_vlan,
13109 (void *)&cmd_set_vxlan_vlan_value,
13110 (void *)&cmd_set_vxlan_eth_src,
13111 (void *)&cmd_set_vxlan_eth_src_value,
13112 (void *)&cmd_set_vxlan_eth_dst,
13113 (void *)&cmd_set_vxlan_eth_dst_value,
13118 /** Set NVGRE encapsulation details */
13119 struct cmd_set_nvgre_result {
13120 cmdline_fixed_string_t set;
13121 cmdline_fixed_string_t nvgre;
13122 cmdline_fixed_string_t pos_token;
13123 cmdline_fixed_string_t ip_version;
13125 cmdline_ipaddr_t ip_src;
13126 cmdline_ipaddr_t ip_dst;
13128 struct rte_ether_addr eth_src;
13129 struct rte_ether_addr eth_dst;
13132 cmdline_parse_token_string_t cmd_set_nvgre_set =
13133 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
13134 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
13135 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
13136 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
13137 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
13138 "nvgre-with-vlan");
13139 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
13140 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13142 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
13143 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
13145 cmdline_parse_token_string_t cmd_set_nvgre_tni =
13146 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13148 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
13149 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
13150 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
13151 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13153 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
13154 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
13155 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
13156 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13158 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
13159 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
13160 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
13161 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13163 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
13164 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
13165 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
13166 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13168 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
13169 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
13170 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
13171 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
13173 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
13174 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
13176 static void cmd_set_nvgre_parsed(void *parsed_result,
13177 __rte_unused struct cmdline *cl,
13178 __rte_unused void *data)
13180 struct cmd_set_nvgre_result *res = parsed_result;
13182 uint32_t nvgre_tni;
13185 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
13188 if (strcmp(res->nvgre, "nvgre") == 0)
13189 nvgre_encap_conf.select_vlan = 0;
13190 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
13191 nvgre_encap_conf.select_vlan = 1;
13192 if (strcmp(res->ip_version, "ipv4") == 0)
13193 nvgre_encap_conf.select_ipv4 = 1;
13194 else if (strcmp(res->ip_version, "ipv6") == 0)
13195 nvgre_encap_conf.select_ipv4 = 0;
13198 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
13199 if (nvgre_encap_conf.select_ipv4) {
13200 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
13201 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
13203 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
13204 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
13206 if (nvgre_encap_conf.select_vlan)
13207 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13208 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
13209 RTE_ETHER_ADDR_LEN);
13210 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13211 RTE_ETHER_ADDR_LEN);
13214 cmdline_parse_inst_t cmd_set_nvgre = {
13215 .f = cmd_set_nvgre_parsed,
13217 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
13218 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13219 " eth-dst <eth-dst>",
13221 (void *)&cmd_set_nvgre_set,
13222 (void *)&cmd_set_nvgre_nvgre,
13223 (void *)&cmd_set_nvgre_ip_version,
13224 (void *)&cmd_set_nvgre_ip_version_value,
13225 (void *)&cmd_set_nvgre_tni,
13226 (void *)&cmd_set_nvgre_tni_value,
13227 (void *)&cmd_set_nvgre_ip_src,
13228 (void *)&cmd_set_nvgre_ip_src_value,
13229 (void *)&cmd_set_nvgre_ip_dst,
13230 (void *)&cmd_set_nvgre_ip_dst_value,
13231 (void *)&cmd_set_nvgre_eth_src,
13232 (void *)&cmd_set_nvgre_eth_src_value,
13233 (void *)&cmd_set_nvgre_eth_dst,
13234 (void *)&cmd_set_nvgre_eth_dst_value,
13239 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
13240 .f = cmd_set_nvgre_parsed,
13242 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
13243 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13244 " eth-src <eth-src> eth-dst <eth-dst>",
13246 (void *)&cmd_set_nvgre_set,
13247 (void *)&cmd_set_nvgre_nvgre_with_vlan,
13248 (void *)&cmd_set_nvgre_ip_version,
13249 (void *)&cmd_set_nvgre_ip_version_value,
13250 (void *)&cmd_set_nvgre_tni,
13251 (void *)&cmd_set_nvgre_tni_value,
13252 (void *)&cmd_set_nvgre_ip_src,
13253 (void *)&cmd_set_nvgre_ip_src_value,
13254 (void *)&cmd_set_nvgre_ip_dst,
13255 (void *)&cmd_set_nvgre_ip_dst_value,
13256 (void *)&cmd_set_nvgre_vlan,
13257 (void *)&cmd_set_nvgre_vlan_value,
13258 (void *)&cmd_set_nvgre_eth_src,
13259 (void *)&cmd_set_nvgre_eth_src_value,
13260 (void *)&cmd_set_nvgre_eth_dst,
13261 (void *)&cmd_set_nvgre_eth_dst_value,
13266 /** Set L2 encapsulation details */
13267 struct cmd_set_l2_encap_result {
13268 cmdline_fixed_string_t set;
13269 cmdline_fixed_string_t l2_encap;
13270 cmdline_fixed_string_t pos_token;
13271 cmdline_fixed_string_t ip_version;
13272 uint32_t vlan_present:1;
13274 struct rte_ether_addr eth_src;
13275 struct rte_ether_addr eth_dst;
13278 cmdline_parse_token_string_t cmd_set_l2_encap_set =
13279 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
13280 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
13281 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
13282 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
13283 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
13284 "l2_encap-with-vlan");
13285 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
13286 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13288 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
13289 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
13291 cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
13292 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13294 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
13295 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
13296 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
13297 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13299 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
13300 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
13301 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
13302 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
13304 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
13305 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
13307 static void cmd_set_l2_encap_parsed(void *parsed_result,
13308 __rte_unused struct cmdline *cl,
13309 __rte_unused void *data)
13311 struct cmd_set_l2_encap_result *res = parsed_result;
13313 if (strcmp(res->l2_encap, "l2_encap") == 0)
13314 l2_encap_conf.select_vlan = 0;
13315 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
13316 l2_encap_conf.select_vlan = 1;
13317 if (strcmp(res->ip_version, "ipv4") == 0)
13318 l2_encap_conf.select_ipv4 = 1;
13319 else if (strcmp(res->ip_version, "ipv6") == 0)
13320 l2_encap_conf.select_ipv4 = 0;
13323 if (l2_encap_conf.select_vlan)
13324 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13325 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
13326 RTE_ETHER_ADDR_LEN);
13327 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13328 RTE_ETHER_ADDR_LEN);
13331 cmdline_parse_inst_t cmd_set_l2_encap = {
13332 .f = cmd_set_l2_encap_parsed,
13334 .help_str = "set l2_encap ip-version ipv4|ipv6"
13335 " eth-src <eth-src> eth-dst <eth-dst>",
13337 (void *)&cmd_set_l2_encap_set,
13338 (void *)&cmd_set_l2_encap_l2_encap,
13339 (void *)&cmd_set_l2_encap_ip_version,
13340 (void *)&cmd_set_l2_encap_ip_version_value,
13341 (void *)&cmd_set_l2_encap_eth_src,
13342 (void *)&cmd_set_l2_encap_eth_src_value,
13343 (void *)&cmd_set_l2_encap_eth_dst,
13344 (void *)&cmd_set_l2_encap_eth_dst_value,
13349 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
13350 .f = cmd_set_l2_encap_parsed,
13352 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
13353 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13355 (void *)&cmd_set_l2_encap_set,
13356 (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
13357 (void *)&cmd_set_l2_encap_ip_version,
13358 (void *)&cmd_set_l2_encap_ip_version_value,
13359 (void *)&cmd_set_l2_encap_vlan,
13360 (void *)&cmd_set_l2_encap_vlan_value,
13361 (void *)&cmd_set_l2_encap_eth_src,
13362 (void *)&cmd_set_l2_encap_eth_src_value,
13363 (void *)&cmd_set_l2_encap_eth_dst,
13364 (void *)&cmd_set_l2_encap_eth_dst_value,
13369 /** Set L2 decapsulation details */
13370 struct cmd_set_l2_decap_result {
13371 cmdline_fixed_string_t set;
13372 cmdline_fixed_string_t l2_decap;
13373 cmdline_fixed_string_t pos_token;
13374 uint32_t vlan_present:1;
13377 cmdline_parse_token_string_t cmd_set_l2_decap_set =
13378 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
13379 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
13380 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13382 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
13383 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
13384 "l2_decap-with-vlan");
13386 static void cmd_set_l2_decap_parsed(void *parsed_result,
13387 __rte_unused struct cmdline *cl,
13388 __rte_unused void *data)
13390 struct cmd_set_l2_decap_result *res = parsed_result;
13392 if (strcmp(res->l2_decap, "l2_decap") == 0)
13393 l2_decap_conf.select_vlan = 0;
13394 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
13395 l2_decap_conf.select_vlan = 1;
13398 cmdline_parse_inst_t cmd_set_l2_decap = {
13399 .f = cmd_set_l2_decap_parsed,
13401 .help_str = "set l2_decap",
13403 (void *)&cmd_set_l2_decap_set,
13404 (void *)&cmd_set_l2_decap_l2_decap,
13409 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
13410 .f = cmd_set_l2_decap_parsed,
13412 .help_str = "set l2_decap-with-vlan",
13414 (void *)&cmd_set_l2_decap_set,
13415 (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
13420 /** Set MPLSoGRE encapsulation details */
13421 struct cmd_set_mplsogre_encap_result {
13422 cmdline_fixed_string_t set;
13423 cmdline_fixed_string_t mplsogre;
13424 cmdline_fixed_string_t pos_token;
13425 cmdline_fixed_string_t ip_version;
13426 uint32_t vlan_present:1;
13428 cmdline_ipaddr_t ip_src;
13429 cmdline_ipaddr_t ip_dst;
13431 struct rte_ether_addr eth_src;
13432 struct rte_ether_addr eth_dst;
13435 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
13436 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
13438 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
13439 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
13441 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
13442 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13443 mplsogre, "mplsogre_encap-with-vlan");
13444 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
13445 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13446 pos_token, "ip-version");
13447 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
13448 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13449 ip_version, "ipv4#ipv6");
13450 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
13451 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13452 pos_token, "label");
13453 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
13454 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
13456 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
13457 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13458 pos_token, "ip-src");
13459 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
13460 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
13461 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
13462 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13463 pos_token, "ip-dst");
13464 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
13465 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
13466 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
13467 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13468 pos_token, "vlan-tci");
13469 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
13470 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
13472 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
13473 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13474 pos_token, "eth-src");
13475 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
13476 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13478 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
13479 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13480 pos_token, "eth-dst");
13481 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
13482 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
13485 static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
13486 __rte_unused struct cmdline *cl,
13487 __rte_unused void *data)
13489 struct cmd_set_mplsogre_encap_result *res = parsed_result;
13491 uint32_t mplsogre_label;
13494 .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
13497 if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
13498 mplsogre_encap_conf.select_vlan = 0;
13499 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
13500 mplsogre_encap_conf.select_vlan = 1;
13501 if (strcmp(res->ip_version, "ipv4") == 0)
13502 mplsogre_encap_conf.select_ipv4 = 1;
13503 else if (strcmp(res->ip_version, "ipv6") == 0)
13504 mplsogre_encap_conf.select_ipv4 = 0;
13507 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
13508 if (mplsogre_encap_conf.select_ipv4) {
13509 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
13510 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
13512 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
13513 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
13515 if (mplsogre_encap_conf.select_vlan)
13516 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13517 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
13518 RTE_ETHER_ADDR_LEN);
13519 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13520 RTE_ETHER_ADDR_LEN);
13523 cmdline_parse_inst_t cmd_set_mplsogre_encap = {
13524 .f = cmd_set_mplsogre_encap_parsed,
13526 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
13527 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
13528 " eth-dst <eth-dst>",
13530 (void *)&cmd_set_mplsogre_encap_set,
13531 (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
13532 (void *)&cmd_set_mplsogre_encap_ip_version,
13533 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13534 (void *)&cmd_set_mplsogre_encap_label,
13535 (void *)&cmd_set_mplsogre_encap_label_value,
13536 (void *)&cmd_set_mplsogre_encap_ip_src,
13537 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13538 (void *)&cmd_set_mplsogre_encap_ip_dst,
13539 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13540 (void *)&cmd_set_mplsogre_encap_eth_src,
13541 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13542 (void *)&cmd_set_mplsogre_encap_eth_dst,
13543 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13548 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
13549 .f = cmd_set_mplsogre_encap_parsed,
13551 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
13552 " label <label> ip-src <ip-src> ip-dst <ip-dst>"
13553 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
13555 (void *)&cmd_set_mplsogre_encap_set,
13556 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
13557 (void *)&cmd_set_mplsogre_encap_ip_version,
13558 (void *)&cmd_set_mplsogre_encap_ip_version_value,
13559 (void *)&cmd_set_mplsogre_encap_label,
13560 (void *)&cmd_set_mplsogre_encap_label_value,
13561 (void *)&cmd_set_mplsogre_encap_ip_src,
13562 (void *)&cmd_set_mplsogre_encap_ip_src_value,
13563 (void *)&cmd_set_mplsogre_encap_ip_dst,
13564 (void *)&cmd_set_mplsogre_encap_ip_dst_value,
13565 (void *)&cmd_set_mplsogre_encap_vlan,
13566 (void *)&cmd_set_mplsogre_encap_vlan_value,
13567 (void *)&cmd_set_mplsogre_encap_eth_src,
13568 (void *)&cmd_set_mplsogre_encap_eth_src_value,
13569 (void *)&cmd_set_mplsogre_encap_eth_dst,
13570 (void *)&cmd_set_mplsogre_encap_eth_dst_value,
13575 /** Set MPLSoGRE decapsulation details */
13576 struct cmd_set_mplsogre_decap_result {
13577 cmdline_fixed_string_t set;
13578 cmdline_fixed_string_t mplsogre;
13579 cmdline_fixed_string_t pos_token;
13580 cmdline_fixed_string_t ip_version;
13581 uint32_t vlan_present:1;
13584 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
13585 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
13587 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
13588 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
13590 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
13591 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13592 mplsogre, "mplsogre_decap-with-vlan");
13593 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
13594 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13595 pos_token, "ip-version");
13596 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
13597 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
13598 ip_version, "ipv4#ipv6");
13600 static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
13601 __rte_unused struct cmdline *cl,
13602 __rte_unused void *data)
13604 struct cmd_set_mplsogre_decap_result *res = parsed_result;
13606 if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
13607 mplsogre_decap_conf.select_vlan = 0;
13608 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
13609 mplsogre_decap_conf.select_vlan = 1;
13610 if (strcmp(res->ip_version, "ipv4") == 0)
13611 mplsogre_decap_conf.select_ipv4 = 1;
13612 else if (strcmp(res->ip_version, "ipv6") == 0)
13613 mplsogre_decap_conf.select_ipv4 = 0;
13616 cmdline_parse_inst_t cmd_set_mplsogre_decap = {
13617 .f = cmd_set_mplsogre_decap_parsed,
13619 .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
13621 (void *)&cmd_set_mplsogre_decap_set,
13622 (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
13623 (void *)&cmd_set_mplsogre_decap_ip_version,
13624 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13629 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
13630 .f = cmd_set_mplsogre_decap_parsed,
13632 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
13634 (void *)&cmd_set_mplsogre_decap_set,
13635 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
13636 (void *)&cmd_set_mplsogre_decap_ip_version,
13637 (void *)&cmd_set_mplsogre_decap_ip_version_value,
13642 /** Set MPLSoUDP encapsulation details */
13643 struct cmd_set_mplsoudp_encap_result {
13644 cmdline_fixed_string_t set;
13645 cmdline_fixed_string_t mplsoudp;
13646 cmdline_fixed_string_t pos_token;
13647 cmdline_fixed_string_t ip_version;
13648 uint32_t vlan_present:1;
13652 cmdline_ipaddr_t ip_src;
13653 cmdline_ipaddr_t ip_dst;
13655 struct rte_ether_addr eth_src;
13656 struct rte_ether_addr eth_dst;
13659 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
13660 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
13662 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
13663 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
13665 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
13666 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13667 mplsoudp, "mplsoudp_encap-with-vlan");
13668 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
13669 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13670 pos_token, "ip-version");
13671 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
13672 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13673 ip_version, "ipv4#ipv6");
13674 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
13675 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13676 pos_token, "label");
13677 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
13678 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
13680 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
13681 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13682 pos_token, "udp-src");
13683 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
13684 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
13686 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
13687 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13688 pos_token, "udp-dst");
13689 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
13690 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
13692 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
13693 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13694 pos_token, "ip-src");
13695 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
13696 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
13697 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
13698 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13699 pos_token, "ip-dst");
13700 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
13701 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
13702 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
13703 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13704 pos_token, "vlan-tci");
13705 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
13706 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
13708 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
13709 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13710 pos_token, "eth-src");
13711 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
13712 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13714 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
13715 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13716 pos_token, "eth-dst");
13717 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
13718 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
13721 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
13722 __rte_unused struct cmdline *cl,
13723 __rte_unused void *data)
13725 struct cmd_set_mplsoudp_encap_result *res = parsed_result;
13727 uint32_t mplsoudp_label;
13730 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
13733 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
13734 mplsoudp_encap_conf.select_vlan = 0;
13735 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
13736 mplsoudp_encap_conf.select_vlan = 1;
13737 if (strcmp(res->ip_version, "ipv4") == 0)
13738 mplsoudp_encap_conf.select_ipv4 = 1;
13739 else if (strcmp(res->ip_version, "ipv6") == 0)
13740 mplsoudp_encap_conf.select_ipv4 = 0;
13743 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
13744 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
13745 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
13746 if (mplsoudp_encap_conf.select_ipv4) {
13747 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
13748 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
13750 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
13751 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
13753 if (mplsoudp_encap_conf.select_vlan)
13754 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
13755 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
13756 RTE_ETHER_ADDR_LEN);
13757 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
13758 RTE_ETHER_ADDR_LEN);
13761 cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
13762 .f = cmd_set_mplsoudp_encap_parsed,
13764 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
13765 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
13766 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
13768 (void *)&cmd_set_mplsoudp_encap_set,
13769 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
13770 (void *)&cmd_set_mplsoudp_encap_ip_version,
13771 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13772 (void *)&cmd_set_mplsoudp_encap_label,
13773 (void *)&cmd_set_mplsoudp_encap_label_value,
13774 (void *)&cmd_set_mplsoudp_encap_udp_src,
13775 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13776 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13777 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13778 (void *)&cmd_set_mplsoudp_encap_ip_src,
13779 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13780 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13781 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13782 (void *)&cmd_set_mplsoudp_encap_eth_src,
13783 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13784 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13785 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13790 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
13791 .f = cmd_set_mplsoudp_encap_parsed,
13793 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
13794 " label <label> udp-src <udp-src> udp-dst <udp-dst>"
13795 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
13796 " eth-src <eth-src> eth-dst <eth-dst>",
13798 (void *)&cmd_set_mplsoudp_encap_set,
13799 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
13800 (void *)&cmd_set_mplsoudp_encap_ip_version,
13801 (void *)&cmd_set_mplsoudp_encap_ip_version_value,
13802 (void *)&cmd_set_mplsoudp_encap_label,
13803 (void *)&cmd_set_mplsoudp_encap_label_value,
13804 (void *)&cmd_set_mplsoudp_encap_udp_src,
13805 (void *)&cmd_set_mplsoudp_encap_udp_src_value,
13806 (void *)&cmd_set_mplsoudp_encap_udp_dst,
13807 (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
13808 (void *)&cmd_set_mplsoudp_encap_ip_src,
13809 (void *)&cmd_set_mplsoudp_encap_ip_src_value,
13810 (void *)&cmd_set_mplsoudp_encap_ip_dst,
13811 (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
13812 (void *)&cmd_set_mplsoudp_encap_vlan,
13813 (void *)&cmd_set_mplsoudp_encap_vlan_value,
13814 (void *)&cmd_set_mplsoudp_encap_eth_src,
13815 (void *)&cmd_set_mplsoudp_encap_eth_src_value,
13816 (void *)&cmd_set_mplsoudp_encap_eth_dst,
13817 (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
13822 /** Set MPLSoUDP decapsulation details */
13823 struct cmd_set_mplsoudp_decap_result {
13824 cmdline_fixed_string_t set;
13825 cmdline_fixed_string_t mplsoudp;
13826 cmdline_fixed_string_t pos_token;
13827 cmdline_fixed_string_t ip_version;
13828 uint32_t vlan_present:1;
13831 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
13832 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
13834 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
13835 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
13837 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
13838 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13839 mplsoudp, "mplsoudp_decap-with-vlan");
13840 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
13841 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13842 pos_token, "ip-version");
13843 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
13844 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
13845 ip_version, "ipv4#ipv6");
13847 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
13848 __rte_unused struct cmdline *cl,
13849 __rte_unused void *data)
13851 struct cmd_set_mplsoudp_decap_result *res = parsed_result;
13853 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
13854 mplsoudp_decap_conf.select_vlan = 0;
13855 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
13856 mplsoudp_decap_conf.select_vlan = 1;
13857 if (strcmp(res->ip_version, "ipv4") == 0)
13858 mplsoudp_decap_conf.select_ipv4 = 1;
13859 else if (strcmp(res->ip_version, "ipv6") == 0)
13860 mplsoudp_decap_conf.select_ipv4 = 0;
13863 cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
13864 .f = cmd_set_mplsoudp_decap_parsed,
13866 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
13868 (void *)&cmd_set_mplsoudp_decap_set,
13869 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
13870 (void *)&cmd_set_mplsoudp_decap_ip_version,
13871 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13876 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
13877 .f = cmd_set_mplsoudp_decap_parsed,
13879 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
13881 (void *)&cmd_set_mplsoudp_decap_set,
13882 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
13883 (void *)&cmd_set_mplsoudp_decap_ip_version,
13884 (void *)&cmd_set_mplsoudp_decap_ip_version_value,
13889 /** Set connection tracking object common details */
13890 struct cmd_set_conntrack_common_result {
13891 cmdline_fixed_string_t set;
13892 cmdline_fixed_string_t conntrack;
13893 cmdline_fixed_string_t common;
13894 cmdline_fixed_string_t peer;
13895 cmdline_fixed_string_t is_orig;
13896 cmdline_fixed_string_t enable;
13897 cmdline_fixed_string_t live;
13898 cmdline_fixed_string_t sack;
13899 cmdline_fixed_string_t cack;
13900 cmdline_fixed_string_t last_dir;
13901 cmdline_fixed_string_t liberal;
13902 cmdline_fixed_string_t state;
13903 cmdline_fixed_string_t max_ack_win;
13904 cmdline_fixed_string_t retrans;
13905 cmdline_fixed_string_t last_win;
13906 cmdline_fixed_string_t last_seq;
13907 cmdline_fixed_string_t last_ack;
13908 cmdline_fixed_string_t last_end;
13909 cmdline_fixed_string_t last_index;
13912 uint16_t peer_port;
13913 uint32_t is_original;
13928 cmdline_parse_token_string_t cmd_set_conntrack_set =
13929 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13931 cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
13932 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13933 conntrack, "conntrack");
13934 cmdline_parse_token_string_t cmd_set_conntrack_common_com =
13935 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13937 cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
13938 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13940 cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
13941 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13942 peer_port, RTE_UINT16);
13943 cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
13944 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13945 is_orig, "is_orig");
13946 cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
13947 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13948 is_original, RTE_UINT32);
13949 cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
13950 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13952 cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
13953 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13955 cmdline_parse_token_string_t cmd_set_conntrack_common_live =
13956 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13958 cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
13959 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13960 is_live, RTE_UINT32);
13961 cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
13962 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13964 cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
13965 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13966 s_ack, RTE_UINT32);
13967 cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
13968 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13970 cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
13971 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13972 c_ack, RTE_UINT32);
13973 cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
13974 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13975 last_dir, "last_dir");
13976 cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
13977 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13979 cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
13980 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13981 liberal, "liberal");
13982 cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
13983 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13985 cmdline_parse_token_string_t cmd_set_conntrack_common_state =
13986 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13988 cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
13989 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13991 cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
13992 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
13993 max_ack_win, "max_ack_win");
13994 cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
13995 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
13996 factor, RTE_UINT8);
13997 cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
13998 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14000 cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
14001 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14002 re_num, RTE_UINT8);
14003 cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
14004 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14005 last_win, "last_win");
14006 cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
14007 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14009 cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
14010 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14011 last_seq, "last_seq");
14012 cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
14013 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14015 cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
14016 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14017 last_ack, "last_ack");
14018 cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
14019 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14021 cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
14022 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14023 last_end, "last_end");
14024 cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
14025 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14027 cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
14028 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
14029 last_index, "last_index");
14030 cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
14031 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
14034 static void cmd_set_conntrack_common_parsed(void *parsed_result,
14035 __rte_unused struct cmdline *cl,
14036 __rte_unused void *data)
14038 struct cmd_set_conntrack_common_result *res = parsed_result;
14040 /* No need to swap to big endian. */
14041 conntrack_context.peer_port = res->peer_port;
14042 conntrack_context.is_original_dir = res->is_original;
14043 conntrack_context.enable = res->en;
14044 conntrack_context.live_connection = res->is_live;
14045 conntrack_context.selective_ack = res->s_ack;
14046 conntrack_context.challenge_ack_passed = res->c_ack;
14047 conntrack_context.last_direction = res->ld;
14048 conntrack_context.liberal_mode = res->lb;
14049 conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
14050 conntrack_context.max_ack_window = res->factor;
14051 conntrack_context.retransmission_limit = res->re_num;
14052 conntrack_context.last_window = res->lw;
14053 conntrack_context.last_index =
14054 (enum rte_flow_conntrack_tcp_last_index)res->li;
14055 conntrack_context.last_seq = res->ls;
14056 conntrack_context.last_ack = res->la;
14057 conntrack_context.last_end = res->le;
14060 cmdline_parse_inst_t cmd_set_conntrack_common = {
14061 .f = cmd_set_conntrack_common_parsed,
14063 .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
14064 " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
14065 " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
14066 " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
14067 " last_index <flag>",
14069 (void *)&cmd_set_conntrack_set,
14070 (void *)&cmd_set_conntrack_conntrack,
14071 (void *)&cmd_set_conntrack_common_com,
14072 (void *)&cmd_set_conntrack_common_peer,
14073 (void *)&cmd_set_conntrack_common_peer_value,
14074 (void *)&cmd_set_conntrack_common_is_orig,
14075 (void *)&cmd_set_conntrack_common_is_orig_value,
14076 (void *)&cmd_set_conntrack_common_enable,
14077 (void *)&cmd_set_conntrack_common_enable_value,
14078 (void *)&cmd_set_conntrack_common_live,
14079 (void *)&cmd_set_conntrack_common_live_value,
14080 (void *)&cmd_set_conntrack_common_sack,
14081 (void *)&cmd_set_conntrack_common_sack_value,
14082 (void *)&cmd_set_conntrack_common_cack,
14083 (void *)&cmd_set_conntrack_common_cack_value,
14084 (void *)&cmd_set_conntrack_common_last_dir,
14085 (void *)&cmd_set_conntrack_common_last_dir_value,
14086 (void *)&cmd_set_conntrack_common_liberal,
14087 (void *)&cmd_set_conntrack_common_liberal_value,
14088 (void *)&cmd_set_conntrack_common_state,
14089 (void *)&cmd_set_conntrack_common_state_value,
14090 (void *)&cmd_set_conntrack_common_max_ackwin,
14091 (void *)&cmd_set_conntrack_common_max_ackwin_value,
14092 (void *)&cmd_set_conntrack_common_retrans,
14093 (void *)&cmd_set_conntrack_common_retrans_value,
14094 (void *)&cmd_set_conntrack_common_last_win,
14095 (void *)&cmd_set_conntrack_common_last_win_value,
14096 (void *)&cmd_set_conntrack_common_last_seq,
14097 (void *)&cmd_set_conntrack_common_last_seq_value,
14098 (void *)&cmd_set_conntrack_common_last_ack,
14099 (void *)&cmd_set_conntrack_common_last_ack_value,
14100 (void *)&cmd_set_conntrack_common_last_end,
14101 (void *)&cmd_set_conntrack_common_last_end_value,
14102 (void *)&cmd_set_conntrack_common_last_index,
14103 (void *)&cmd_set_conntrack_common_last_index_value,
14108 /** Set connection tracking object both directions' details */
14109 struct cmd_set_conntrack_dir_result {
14110 cmdline_fixed_string_t set;
14111 cmdline_fixed_string_t conntrack;
14112 cmdline_fixed_string_t dir;
14113 cmdline_fixed_string_t scale;
14114 cmdline_fixed_string_t fin;
14115 cmdline_fixed_string_t ack_seen;
14116 cmdline_fixed_string_t unack;
14117 cmdline_fixed_string_t sent_end;
14118 cmdline_fixed_string_t reply_end;
14119 cmdline_fixed_string_t max_win;
14120 cmdline_fixed_string_t max_ack;
14131 cmdline_parse_token_string_t cmd_set_conntrack_dir_set =
14132 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14134 cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack =
14135 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14136 conntrack, "conntrack");
14137 cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
14138 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14140 cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
14141 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14143 cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
14144 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14145 factor, RTE_UINT32);
14146 cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
14147 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14149 cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
14150 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14152 cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
14153 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14154 ack_seen, "acked");
14155 cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
14156 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14158 cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
14159 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14160 unack, "unack_data");
14161 cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
14162 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14164 cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
14165 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14166 sent_end, "sent_end");
14167 cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
14168 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14170 cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
14171 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14172 reply_end, "reply_end");
14173 cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
14174 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14176 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
14177 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14178 max_win, "max_win");
14179 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
14180 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14182 cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
14183 TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
14184 max_ack, "max_ack");
14185 cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
14186 TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
14189 static void cmd_set_conntrack_dir_parsed(void *parsed_result,
14190 __rte_unused struct cmdline *cl,
14191 __rte_unused void *data)
14193 struct cmd_set_conntrack_dir_result *res = parsed_result;
14194 struct rte_flow_tcp_dir_param *dir = NULL;
14196 if (strcmp(res->dir, "orig") == 0)
14197 dir = &conntrack_context.original_dir;
14198 else if (strcmp(res->dir, "rply") == 0)
14199 dir = &conntrack_context.reply_dir;
14202 dir->scale = res->factor;
14203 dir->close_initiated = res->f;
14204 dir->last_ack_seen = res->as;
14205 dir->data_unacked = res->un;
14206 dir->sent_end = res->se;
14207 dir->reply_end = res->re;
14208 dir->max_ack = res->ma;
14209 dir->max_win = res->mw;
14212 cmdline_parse_inst_t cmd_set_conntrack_dir = {
14213 .f = cmd_set_conntrack_dir_parsed,
14215 .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
14216 " acked <seen> unack_data <unack> sent_end <sent>"
14217 " reply_end <reply> max_win <win> max_ack <ack>",
14219 (void *)&cmd_set_conntrack_set,
14220 (void *)&cmd_set_conntrack_conntrack,
14221 (void *)&cmd_set_conntrack_dir_dir,
14222 (void *)&cmd_set_conntrack_dir_scale,
14223 (void *)&cmd_set_conntrack_dir_scale_value,
14224 (void *)&cmd_set_conntrack_dir_fin,
14225 (void *)&cmd_set_conntrack_dir_fin_value,
14226 (void *)&cmd_set_conntrack_dir_ack,
14227 (void *)&cmd_set_conntrack_dir_ack_value,
14228 (void *)&cmd_set_conntrack_dir_unack_data,
14229 (void *)&cmd_set_conntrack_dir_unack_data_value,
14230 (void *)&cmd_set_conntrack_dir_sent_end,
14231 (void *)&cmd_set_conntrack_dir_sent_end_value,
14232 (void *)&cmd_set_conntrack_dir_reply_end,
14233 (void *)&cmd_set_conntrack_dir_reply_end_value,
14234 (void *)&cmd_set_conntrack_dir_max_win,
14235 (void *)&cmd_set_conntrack_dir_max_win_value,
14236 (void *)&cmd_set_conntrack_dir_max_ack,
14237 (void *)&cmd_set_conntrack_dir_max_ack_value,
14242 /* Strict link priority scheduling mode setting */
14244 cmd_strict_link_prio_parsed(
14245 void *parsed_result,
14246 __rte_unused struct cmdline *cl,
14247 __rte_unused void *data)
14249 struct cmd_vf_tc_bw_result *res = parsed_result;
14250 int ret = -ENOTSUP;
14252 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14255 #ifdef RTE_NET_I40E
14256 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14263 fprintf(stderr, "invalid tc_bitmap 0x%x\n", res->tc_map);
14266 fprintf(stderr, "invalid port_id %d\n", res->port_id);
14269 fprintf(stderr, "function not implemented\n");
14272 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
14276 cmdline_parse_inst_t cmd_strict_link_prio = {
14277 .f = cmd_strict_link_prio_parsed,
14279 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14281 (void *)&cmd_vf_tc_bw_set,
14282 (void *)&cmd_vf_tc_bw_tx,
14283 (void *)&cmd_vf_tc_bw_strict_link_prio,
14284 (void *)&cmd_vf_tc_bw_port_id,
14285 (void *)&cmd_vf_tc_bw_tc_map,
14290 /* Load dynamic device personalization*/
14291 struct cmd_ddp_add_result {
14292 cmdline_fixed_string_t ddp;
14293 cmdline_fixed_string_t add;
14298 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14299 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14300 cmdline_parse_token_string_t cmd_ddp_add_add =
14301 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14302 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14303 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id,
14305 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14306 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14309 cmd_ddp_add_parsed(
14310 void *parsed_result,
14311 __rte_unused struct cmdline *cl,
14312 __rte_unused void *data)
14314 struct cmd_ddp_add_result *res = parsed_result;
14320 int ret = -ENOTSUP;
14322 if (!all_ports_stopped()) {
14323 fprintf(stderr, "Please stop all ports first\n");
14327 filepath = strdup(res->filepath);
14328 if (filepath == NULL) {
14329 fprintf(stderr, "Failed to allocate memory\n");
14332 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14334 buff = open_file(file_fld[0], &size);
14336 free((void *)filepath);
14340 #ifdef RTE_NET_I40E
14341 if (ret == -ENOTSUP)
14342 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14344 RTE_PMD_I40E_PKG_OP_WR_ADD);
14347 if (ret == -EEXIST)
14348 fprintf(stderr, "Profile has already existed.\n");
14350 fprintf(stderr, "Failed to load profile.\n");
14351 else if (file_num == 2)
14352 save_file(file_fld[1], buff, size);
14355 free((void *)filepath);
14358 cmdline_parse_inst_t cmd_ddp_add = {
14359 .f = cmd_ddp_add_parsed,
14361 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14363 (void *)&cmd_ddp_add_ddp,
14364 (void *)&cmd_ddp_add_add,
14365 (void *)&cmd_ddp_add_port_id,
14366 (void *)&cmd_ddp_add_filepath,
14371 /* Delete dynamic device personalization*/
14372 struct cmd_ddp_del_result {
14373 cmdline_fixed_string_t ddp;
14374 cmdline_fixed_string_t del;
14379 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14380 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14381 cmdline_parse_token_string_t cmd_ddp_del_del =
14382 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14383 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14384 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, RTE_UINT16);
14385 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14386 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14389 cmd_ddp_del_parsed(
14390 void *parsed_result,
14391 __rte_unused struct cmdline *cl,
14392 __rte_unused void *data)
14394 struct cmd_ddp_del_result *res = parsed_result;
14397 int ret = -ENOTSUP;
14399 if (!all_ports_stopped()) {
14400 fprintf(stderr, "Please stop all ports first\n");
14404 buff = open_file(res->filepath, &size);
14408 #ifdef RTE_NET_I40E
14409 if (ret == -ENOTSUP)
14410 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14412 RTE_PMD_I40E_PKG_OP_WR_DEL);
14415 if (ret == -EACCES)
14416 fprintf(stderr, "Profile does not exist.\n");
14418 fprintf(stderr, "Failed to delete profile.\n");
14423 cmdline_parse_inst_t cmd_ddp_del = {
14424 .f = cmd_ddp_del_parsed,
14426 .help_str = "ddp del <port_id> <backup_profile_path>",
14428 (void *)&cmd_ddp_del_ddp,
14429 (void *)&cmd_ddp_del_del,
14430 (void *)&cmd_ddp_del_port_id,
14431 (void *)&cmd_ddp_del_filepath,
14436 /* Get dynamic device personalization profile info */
14437 struct cmd_ddp_info_result {
14438 cmdline_fixed_string_t ddp;
14439 cmdline_fixed_string_t get;
14440 cmdline_fixed_string_t info;
14444 cmdline_parse_token_string_t cmd_ddp_info_ddp =
14445 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
14446 cmdline_parse_token_string_t cmd_ddp_info_get =
14447 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
14448 cmdline_parse_token_string_t cmd_ddp_info_info =
14449 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
14450 cmdline_parse_token_string_t cmd_ddp_info_filepath =
14451 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
14454 cmd_ddp_info_parsed(
14455 void *parsed_result,
14456 __rte_unused struct cmdline *cl,
14457 __rte_unused void *data)
14459 struct cmd_ddp_info_result *res = parsed_result;
14462 int ret = -ENOTSUP;
14463 #ifdef RTE_NET_I40E
14466 uint32_t buff_size = 0;
14467 struct rte_pmd_i40e_profile_info info;
14468 uint32_t dev_num = 0;
14469 struct rte_pmd_i40e_ddp_device_id *devs;
14470 uint32_t proto_num = 0;
14471 struct rte_pmd_i40e_proto_info *proto = NULL;
14472 uint32_t pctype_num = 0;
14473 struct rte_pmd_i40e_ptype_info *pctype;
14474 uint32_t ptype_num = 0;
14475 struct rte_pmd_i40e_ptype_info *ptype;
14480 pkg = open_file(res->filepath, &pkg_size);
14484 #ifdef RTE_NET_I40E
14485 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14486 (uint8_t *)&info, sizeof(info),
14487 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
14489 printf("Global Track id: 0x%x\n", info.track_id);
14490 printf("Global Version: %d.%d.%d.%d\n",
14491 info.version.major,
14492 info.version.minor,
14493 info.version.update,
14494 info.version.draft);
14495 printf("Global Package name: %s\n\n", info.name);
14498 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14499 (uint8_t *)&info, sizeof(info),
14500 RTE_PMD_I40E_PKG_INFO_HEADER);
14502 printf("i40e Profile Track id: 0x%x\n", info.track_id);
14503 printf("i40e Profile Version: %d.%d.%d.%d\n",
14504 info.version.major,
14505 info.version.minor,
14506 info.version.update,
14507 info.version.draft);
14508 printf("i40e Profile name: %s\n\n", info.name);
14511 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14512 (uint8_t *)&buff_size, sizeof(buff_size),
14513 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
14514 if (!ret && buff_size) {
14515 buff = (uint8_t *)malloc(buff_size);
14517 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14519 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
14521 printf("Package Notes:\n%s\n\n", buff);
14526 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14527 (uint8_t *)&dev_num, sizeof(dev_num),
14528 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
14529 if (!ret && dev_num) {
14530 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
14531 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
14533 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14534 (uint8_t *)devs, buff_size,
14535 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
14537 printf("List of supported devices:\n");
14538 for (i = 0; i < dev_num; i++) {
14539 printf(" %04X:%04X %04X:%04X\n",
14540 devs[i].vendor_dev_id >> 16,
14541 devs[i].vendor_dev_id & 0xFFFF,
14542 devs[i].sub_vendor_dev_id >> 16,
14543 devs[i].sub_vendor_dev_id & 0xFFFF);
14551 /* get information about protocols and packet types */
14552 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14553 (uint8_t *)&proto_num, sizeof(proto_num),
14554 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
14555 if (ret || !proto_num)
14556 goto no_print_return;
14558 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
14559 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
14561 goto no_print_return;
14563 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
14565 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
14567 printf("List of used protocols:\n");
14568 for (i = 0; i < proto_num; i++)
14569 printf(" %2u: %s\n", proto[i].proto_id,
14573 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
14574 (uint8_t *)&pctype_num, sizeof(pctype_num),
14575 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
14576 if (ret || !pctype_num)
14577 goto no_print_pctypes;
14579 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14580 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14582 goto no_print_pctypes;
14584 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
14586 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
14589 goto no_print_pctypes;
14592 printf("List of defined packet classification types:\n");
14593 for (i = 0; i < pctype_num; i++) {
14594 printf(" %2u:", pctype[i].ptype_id);
14595 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14596 proto_id = pctype[i].protocols[j];
14597 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14598 for (n = 0; n < proto_num; n++) {
14599 if (proto[n].proto_id == proto_id) {
14600 printf(" %s", proto[n].name);
14613 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
14615 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
14616 if (ret || !ptype_num)
14617 goto no_print_return;
14619 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
14620 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
14622 goto no_print_return;
14624 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
14626 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
14629 goto no_print_return;
14631 printf("List of defined packet types:\n");
14632 for (i = 0; i < ptype_num; i++) {
14633 printf(" %2u:", ptype[i].ptype_id);
14634 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
14635 proto_id = ptype[i].protocols[j];
14636 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
14637 for (n = 0; n < proto_num; n++) {
14638 if (proto[n].proto_id == proto_id) {
14639 printf(" %s", proto[n].name);
14655 if (ret == -ENOTSUP)
14656 fprintf(stderr, "Function not supported in PMD driver\n");
14660 cmdline_parse_inst_t cmd_ddp_get_info = {
14661 .f = cmd_ddp_info_parsed,
14663 .help_str = "ddp get info <profile_path>",
14665 (void *)&cmd_ddp_info_ddp,
14666 (void *)&cmd_ddp_info_get,
14667 (void *)&cmd_ddp_info_info,
14668 (void *)&cmd_ddp_info_filepath,
14673 /* Get dynamic device personalization profile info list*/
14674 #define PROFILE_INFO_SIZE 48
14675 #define MAX_PROFILE_NUM 16
14677 struct cmd_ddp_get_list_result {
14678 cmdline_fixed_string_t ddp;
14679 cmdline_fixed_string_t get;
14680 cmdline_fixed_string_t list;
14684 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
14685 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
14686 cmdline_parse_token_string_t cmd_ddp_get_list_get =
14687 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
14688 cmdline_parse_token_string_t cmd_ddp_get_list_list =
14689 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
14690 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
14691 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id,
14695 cmd_ddp_get_list_parsed(
14696 __rte_unused void *parsed_result,
14697 __rte_unused struct cmdline *cl,
14698 __rte_unused void *data)
14700 #ifdef RTE_NET_I40E
14701 struct cmd_ddp_get_list_result *res = parsed_result;
14702 struct rte_pmd_i40e_profile_list *p_list;
14703 struct rte_pmd_i40e_profile_info *p_info;
14708 int ret = -ENOTSUP;
14710 #ifdef RTE_NET_I40E
14711 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
14712 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
14714 fprintf(stderr, "%s: Failed to malloc buffer\n", __func__);
14718 if (ret == -ENOTSUP)
14719 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
14720 (uint8_t *)p_list, size);
14723 p_num = p_list->p_count;
14724 printf("Profile number is: %d\n\n", p_num);
14726 for (i = 0; i < p_num; i++) {
14727 p_info = &p_list->p_info[i];
14728 printf("Profile %d:\n", i);
14729 printf("Track id: 0x%x\n", p_info->track_id);
14730 printf("Version: %d.%d.%d.%d\n",
14731 p_info->version.major,
14732 p_info->version.minor,
14733 p_info->version.update,
14734 p_info->version.draft);
14735 printf("Profile name: %s\n\n", p_info->name);
14743 fprintf(stderr, "Failed to get ddp list\n");
14746 cmdline_parse_inst_t cmd_ddp_get_list = {
14747 .f = cmd_ddp_get_list_parsed,
14749 .help_str = "ddp get list <port_id>",
14751 (void *)&cmd_ddp_get_list_ddp,
14752 (void *)&cmd_ddp_get_list_get,
14753 (void *)&cmd_ddp_get_list_list,
14754 (void *)&cmd_ddp_get_list_port_id,
14759 /* Configure input set */
14760 struct cmd_cfg_input_set_result {
14761 cmdline_fixed_string_t port;
14762 cmdline_fixed_string_t cfg;
14764 cmdline_fixed_string_t pctype;
14766 cmdline_fixed_string_t inset_type;
14767 cmdline_fixed_string_t opt;
14768 cmdline_fixed_string_t field;
14773 cmd_cfg_input_set_parsed(
14774 __rte_unused void *parsed_result,
14775 __rte_unused struct cmdline *cl,
14776 __rte_unused void *data)
14778 #ifdef RTE_NET_I40E
14779 struct cmd_cfg_input_set_result *res = parsed_result;
14780 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14781 struct rte_pmd_i40e_inset inset;
14783 int ret = -ENOTSUP;
14785 if (!all_ports_stopped()) {
14786 fprintf(stderr, "Please stop all ports first\n");
14790 #ifdef RTE_NET_I40E
14791 if (!strcmp(res->inset_type, "hash_inset"))
14792 inset_type = INSET_HASH;
14793 else if (!strcmp(res->inset_type, "fdir_inset"))
14794 inset_type = INSET_FDIR;
14795 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14796 inset_type = INSET_FDIR_FLX;
14797 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
14798 &inset, inset_type);
14800 fprintf(stderr, "Failed to get input set.\n");
14804 if (!strcmp(res->opt, "get")) {
14805 ret = rte_pmd_i40e_inset_field_get(inset.inset,
14808 printf("Field index %d is enabled.\n", res->field_idx);
14810 printf("Field index %d is disabled.\n", res->field_idx);
14812 } else if (!strcmp(res->opt, "set"))
14813 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
14815 else if (!strcmp(res->opt, "clear"))
14816 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
14819 fprintf(stderr, "Failed to configure input set field.\n");
14823 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14824 &inset, inset_type);
14826 fprintf(stderr, "Failed to set input set.\n");
14831 if (ret == -ENOTSUP)
14832 fprintf(stderr, "Function not supported\n");
14835 cmdline_parse_token_string_t cmd_cfg_input_set_port =
14836 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14838 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
14839 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14841 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
14842 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14843 port_id, RTE_UINT16);
14844 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
14845 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14847 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
14848 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14849 pctype_id, RTE_UINT8);
14850 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
14851 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14853 "hash_inset#fdir_inset#fdir_flx_inset");
14854 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
14855 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14856 opt, "get#set#clear");
14857 cmdline_parse_token_string_t cmd_cfg_input_set_field =
14858 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
14860 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
14861 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
14862 field_idx, RTE_UINT8);
14864 cmdline_parse_inst_t cmd_cfg_input_set = {
14865 .f = cmd_cfg_input_set_parsed,
14867 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14868 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
14870 (void *)&cmd_cfg_input_set_port,
14871 (void *)&cmd_cfg_input_set_cfg,
14872 (void *)&cmd_cfg_input_set_port_id,
14873 (void *)&cmd_cfg_input_set_pctype,
14874 (void *)&cmd_cfg_input_set_pctype_id,
14875 (void *)&cmd_cfg_input_set_inset_type,
14876 (void *)&cmd_cfg_input_set_opt,
14877 (void *)&cmd_cfg_input_set_field,
14878 (void *)&cmd_cfg_input_set_field_idx,
14883 /* Clear input set */
14884 struct cmd_clear_input_set_result {
14885 cmdline_fixed_string_t port;
14886 cmdline_fixed_string_t cfg;
14888 cmdline_fixed_string_t pctype;
14890 cmdline_fixed_string_t inset_type;
14891 cmdline_fixed_string_t clear;
14892 cmdline_fixed_string_t all;
14896 cmd_clear_input_set_parsed(
14897 __rte_unused void *parsed_result,
14898 __rte_unused struct cmdline *cl,
14899 __rte_unused void *data)
14901 #ifdef RTE_NET_I40E
14902 struct cmd_clear_input_set_result *res = parsed_result;
14903 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
14904 struct rte_pmd_i40e_inset inset;
14906 int ret = -ENOTSUP;
14908 if (!all_ports_stopped()) {
14909 fprintf(stderr, "Please stop all ports first\n");
14913 #ifdef RTE_NET_I40E
14914 if (!strcmp(res->inset_type, "hash_inset"))
14915 inset_type = INSET_HASH;
14916 else if (!strcmp(res->inset_type, "fdir_inset"))
14917 inset_type = INSET_FDIR;
14918 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
14919 inset_type = INSET_FDIR_FLX;
14921 memset(&inset, 0, sizeof(inset));
14923 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
14924 &inset, inset_type);
14926 fprintf(stderr, "Failed to clear input set.\n");
14932 if (ret == -ENOTSUP)
14933 fprintf(stderr, "Function not supported\n");
14936 cmdline_parse_token_string_t cmd_clear_input_set_port =
14937 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14939 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
14940 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14942 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
14943 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14944 port_id, RTE_UINT16);
14945 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
14946 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14948 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
14949 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
14950 pctype_id, RTE_UINT8);
14951 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
14952 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14954 "hash_inset#fdir_inset#fdir_flx_inset");
14955 cmdline_parse_token_string_t cmd_clear_input_set_clear =
14956 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14958 cmdline_parse_token_string_t cmd_clear_input_set_all =
14959 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
14962 cmdline_parse_inst_t cmd_clear_input_set = {
14963 .f = cmd_clear_input_set_parsed,
14965 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
14966 "fdir_inset|fdir_flx_inset clear all",
14968 (void *)&cmd_clear_input_set_port,
14969 (void *)&cmd_clear_input_set_cfg,
14970 (void *)&cmd_clear_input_set_port_id,
14971 (void *)&cmd_clear_input_set_pctype,
14972 (void *)&cmd_clear_input_set_pctype_id,
14973 (void *)&cmd_clear_input_set_inset_type,
14974 (void *)&cmd_clear_input_set_clear,
14975 (void *)&cmd_clear_input_set_all,
14980 /* show vf stats */
14982 /* Common result structure for show vf stats */
14983 struct cmd_show_vf_stats_result {
14984 cmdline_fixed_string_t show;
14985 cmdline_fixed_string_t vf;
14986 cmdline_fixed_string_t stats;
14991 /* Common CLI fields show vf stats*/
14992 cmdline_parse_token_string_t cmd_show_vf_stats_show =
14993 TOKEN_STRING_INITIALIZER
14994 (struct cmd_show_vf_stats_result,
14996 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
14997 TOKEN_STRING_INITIALIZER
14998 (struct cmd_show_vf_stats_result,
15000 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15001 TOKEN_STRING_INITIALIZER
15002 (struct cmd_show_vf_stats_result,
15004 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15005 TOKEN_NUM_INITIALIZER
15006 (struct cmd_show_vf_stats_result,
15007 port_id, RTE_UINT16);
15008 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15009 TOKEN_NUM_INITIALIZER
15010 (struct cmd_show_vf_stats_result,
15011 vf_id, RTE_UINT16);
15014 cmd_show_vf_stats_parsed(
15015 void *parsed_result,
15016 __rte_unused struct cmdline *cl,
15017 __rte_unused void *data)
15019 struct cmd_show_vf_stats_result *res = parsed_result;
15020 struct rte_eth_stats stats;
15021 int ret = -ENOTSUP;
15022 static const char *nic_stats_border = "########################";
15024 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15027 memset(&stats, 0, sizeof(stats));
15029 #ifdef RTE_NET_I40E
15030 if (ret == -ENOTSUP)
15031 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15035 #ifdef RTE_NET_BNXT
15036 if (ret == -ENOTSUP)
15037 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15046 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15049 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15052 fprintf(stderr, "function not implemented\n");
15055 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15058 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15059 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15061 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15063 stats.ipackets, stats.imissed, stats.ibytes);
15064 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15065 printf(" RX-nombuf: %-10"PRIu64"\n",
15067 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15069 stats.opackets, stats.oerrors, stats.obytes);
15071 printf(" %s############################%s\n",
15072 nic_stats_border, nic_stats_border);
15075 cmdline_parse_inst_t cmd_show_vf_stats = {
15076 .f = cmd_show_vf_stats_parsed,
15078 .help_str = "show vf stats <port_id> <vf_id>",
15080 (void *)&cmd_show_vf_stats_show,
15081 (void *)&cmd_show_vf_stats_vf,
15082 (void *)&cmd_show_vf_stats_stats,
15083 (void *)&cmd_show_vf_stats_port_id,
15084 (void *)&cmd_show_vf_stats_vf_id,
15089 /* clear vf stats */
15091 /* Common result structure for clear vf stats */
15092 struct cmd_clear_vf_stats_result {
15093 cmdline_fixed_string_t clear;
15094 cmdline_fixed_string_t vf;
15095 cmdline_fixed_string_t stats;
15100 /* Common CLI fields clear vf stats*/
15101 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15102 TOKEN_STRING_INITIALIZER
15103 (struct cmd_clear_vf_stats_result,
15105 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15106 TOKEN_STRING_INITIALIZER
15107 (struct cmd_clear_vf_stats_result,
15109 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15110 TOKEN_STRING_INITIALIZER
15111 (struct cmd_clear_vf_stats_result,
15113 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15114 TOKEN_NUM_INITIALIZER
15115 (struct cmd_clear_vf_stats_result,
15116 port_id, RTE_UINT16);
15117 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15118 TOKEN_NUM_INITIALIZER
15119 (struct cmd_clear_vf_stats_result,
15120 vf_id, RTE_UINT16);
15123 cmd_clear_vf_stats_parsed(
15124 void *parsed_result,
15125 __rte_unused struct cmdline *cl,
15126 __rte_unused void *data)
15128 struct cmd_clear_vf_stats_result *res = parsed_result;
15129 int ret = -ENOTSUP;
15131 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15134 #ifdef RTE_NET_I40E
15135 if (ret == -ENOTSUP)
15136 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15139 #ifdef RTE_NET_BNXT
15140 if (ret == -ENOTSUP)
15141 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15149 fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
15152 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15155 fprintf(stderr, "function not implemented\n");
15158 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15162 cmdline_parse_inst_t cmd_clear_vf_stats = {
15163 .f = cmd_clear_vf_stats_parsed,
15165 .help_str = "clear vf stats <port_id> <vf_id>",
15167 (void *)&cmd_clear_vf_stats_clear,
15168 (void *)&cmd_clear_vf_stats_vf,
15169 (void *)&cmd_clear_vf_stats_stats,
15170 (void *)&cmd_clear_vf_stats_port_id,
15171 (void *)&cmd_clear_vf_stats_vf_id,
15176 /* port config pctype mapping reset */
15178 /* Common result structure for port config pctype mapping reset */
15179 struct cmd_pctype_mapping_reset_result {
15180 cmdline_fixed_string_t port;
15181 cmdline_fixed_string_t config;
15183 cmdline_fixed_string_t pctype;
15184 cmdline_fixed_string_t mapping;
15185 cmdline_fixed_string_t reset;
15188 /* Common CLI fields for port config pctype mapping reset*/
15189 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15190 TOKEN_STRING_INITIALIZER
15191 (struct cmd_pctype_mapping_reset_result,
15193 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15194 TOKEN_STRING_INITIALIZER
15195 (struct cmd_pctype_mapping_reset_result,
15197 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15198 TOKEN_NUM_INITIALIZER
15199 (struct cmd_pctype_mapping_reset_result,
15200 port_id, RTE_UINT16);
15201 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15202 TOKEN_STRING_INITIALIZER
15203 (struct cmd_pctype_mapping_reset_result,
15205 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15206 TOKEN_STRING_INITIALIZER
15207 (struct cmd_pctype_mapping_reset_result,
15208 mapping, "mapping");
15209 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15210 TOKEN_STRING_INITIALIZER
15211 (struct cmd_pctype_mapping_reset_result,
15215 cmd_pctype_mapping_reset_parsed(
15216 void *parsed_result,
15217 __rte_unused struct cmdline *cl,
15218 __rte_unused void *data)
15220 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15221 int ret = -ENOTSUP;
15223 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15226 #ifdef RTE_NET_I40E
15227 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15234 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15237 fprintf(stderr, "function not implemented\n");
15240 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15244 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15245 .f = cmd_pctype_mapping_reset_parsed,
15247 .help_str = "port config <port_id> pctype mapping reset",
15249 (void *)&cmd_pctype_mapping_reset_port,
15250 (void *)&cmd_pctype_mapping_reset_config,
15251 (void *)&cmd_pctype_mapping_reset_port_id,
15252 (void *)&cmd_pctype_mapping_reset_pctype,
15253 (void *)&cmd_pctype_mapping_reset_mapping,
15254 (void *)&cmd_pctype_mapping_reset_reset,
15259 /* show port pctype mapping */
15261 /* Common result structure for show port pctype mapping */
15262 struct cmd_pctype_mapping_get_result {
15263 cmdline_fixed_string_t show;
15264 cmdline_fixed_string_t port;
15266 cmdline_fixed_string_t pctype;
15267 cmdline_fixed_string_t mapping;
15270 /* Common CLI fields for pctype mapping get */
15271 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15272 TOKEN_STRING_INITIALIZER
15273 (struct cmd_pctype_mapping_get_result,
15275 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15276 TOKEN_STRING_INITIALIZER
15277 (struct cmd_pctype_mapping_get_result,
15279 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15280 TOKEN_NUM_INITIALIZER
15281 (struct cmd_pctype_mapping_get_result,
15282 port_id, RTE_UINT16);
15283 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15284 TOKEN_STRING_INITIALIZER
15285 (struct cmd_pctype_mapping_get_result,
15287 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15288 TOKEN_STRING_INITIALIZER
15289 (struct cmd_pctype_mapping_get_result,
15290 mapping, "mapping");
15293 cmd_pctype_mapping_get_parsed(
15294 void *parsed_result,
15295 __rte_unused struct cmdline *cl,
15296 __rte_unused void *data)
15298 struct cmd_pctype_mapping_get_result *res = parsed_result;
15299 int ret = -ENOTSUP;
15300 #ifdef RTE_NET_I40E
15301 struct rte_pmd_i40e_flow_type_mapping
15302 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15303 int i, j, first_pctype;
15306 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15309 #ifdef RTE_NET_I40E
15310 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15317 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15320 fprintf(stderr, "function not implemented\n");
15323 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15327 #ifdef RTE_NET_I40E
15328 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15329 if (mapping[i].pctype != 0ULL) {
15332 printf("pctype: ");
15333 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15334 if (mapping[i].pctype & (1ULL << j)) {
15335 printf(first_pctype ?
15336 "%02d" : ",%02d", j);
15340 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15346 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15347 .f = cmd_pctype_mapping_get_parsed,
15349 .help_str = "show port <port_id> pctype mapping",
15351 (void *)&cmd_pctype_mapping_get_show,
15352 (void *)&cmd_pctype_mapping_get_port,
15353 (void *)&cmd_pctype_mapping_get_port_id,
15354 (void *)&cmd_pctype_mapping_get_pctype,
15355 (void *)&cmd_pctype_mapping_get_mapping,
15360 /* port config pctype mapping update */
15362 /* Common result structure for port config pctype mapping update */
15363 struct cmd_pctype_mapping_update_result {
15364 cmdline_fixed_string_t port;
15365 cmdline_fixed_string_t config;
15367 cmdline_fixed_string_t pctype;
15368 cmdline_fixed_string_t mapping;
15369 cmdline_fixed_string_t update;
15370 cmdline_fixed_string_t pctype_list;
15371 uint16_t flow_type;
15374 /* Common CLI fields for pctype mapping update*/
15375 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15376 TOKEN_STRING_INITIALIZER
15377 (struct cmd_pctype_mapping_update_result,
15379 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15380 TOKEN_STRING_INITIALIZER
15381 (struct cmd_pctype_mapping_update_result,
15383 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15384 TOKEN_NUM_INITIALIZER
15385 (struct cmd_pctype_mapping_update_result,
15386 port_id, RTE_UINT16);
15387 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15388 TOKEN_STRING_INITIALIZER
15389 (struct cmd_pctype_mapping_update_result,
15391 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15392 TOKEN_STRING_INITIALIZER
15393 (struct cmd_pctype_mapping_update_result,
15394 mapping, "mapping");
15395 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15396 TOKEN_STRING_INITIALIZER
15397 (struct cmd_pctype_mapping_update_result,
15399 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15400 TOKEN_STRING_INITIALIZER
15401 (struct cmd_pctype_mapping_update_result,
15402 pctype_list, NULL);
15403 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15404 TOKEN_NUM_INITIALIZER
15405 (struct cmd_pctype_mapping_update_result,
15406 flow_type, RTE_UINT16);
15409 cmd_pctype_mapping_update_parsed(
15410 void *parsed_result,
15411 __rte_unused struct cmdline *cl,
15412 __rte_unused void *data)
15414 struct cmd_pctype_mapping_update_result *res = parsed_result;
15415 int ret = -ENOTSUP;
15416 #ifdef RTE_NET_I40E
15417 struct rte_pmd_i40e_flow_type_mapping mapping;
15419 unsigned int nb_item;
15420 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
15423 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15426 #ifdef RTE_NET_I40E
15427 nb_item = parse_item_list(res->pctype_list, "pctypes",
15428 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
15429 mapping.flow_type = res->flow_type;
15430 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
15431 mapping.pctype |= (1ULL << pctype_list[i]);
15432 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
15442 fprintf(stderr, "invalid pctype or flow type\n");
15445 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15448 fprintf(stderr, "function not implemented\n");
15451 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15455 cmdline_parse_inst_t cmd_pctype_mapping_update = {
15456 .f = cmd_pctype_mapping_update_parsed,
15458 .help_str = "port config <port_id> pctype mapping update"
15459 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
15461 (void *)&cmd_pctype_mapping_update_port,
15462 (void *)&cmd_pctype_mapping_update_config,
15463 (void *)&cmd_pctype_mapping_update_port_id,
15464 (void *)&cmd_pctype_mapping_update_pctype,
15465 (void *)&cmd_pctype_mapping_update_mapping,
15466 (void *)&cmd_pctype_mapping_update_update,
15467 (void *)&cmd_pctype_mapping_update_pc_type,
15468 (void *)&cmd_pctype_mapping_update_flow_type,
15473 /* ptype mapping get */
15475 /* Common result structure for ptype mapping get */
15476 struct cmd_ptype_mapping_get_result {
15477 cmdline_fixed_string_t ptype;
15478 cmdline_fixed_string_t mapping;
15479 cmdline_fixed_string_t get;
15481 uint8_t valid_only;
15484 /* Common CLI fields for ptype mapping get */
15485 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
15486 TOKEN_STRING_INITIALIZER
15487 (struct cmd_ptype_mapping_get_result,
15489 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
15490 TOKEN_STRING_INITIALIZER
15491 (struct cmd_ptype_mapping_get_result,
15492 mapping, "mapping");
15493 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
15494 TOKEN_STRING_INITIALIZER
15495 (struct cmd_ptype_mapping_get_result,
15497 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
15498 TOKEN_NUM_INITIALIZER
15499 (struct cmd_ptype_mapping_get_result,
15500 port_id, RTE_UINT16);
15501 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
15502 TOKEN_NUM_INITIALIZER
15503 (struct cmd_ptype_mapping_get_result,
15504 valid_only, RTE_UINT8);
15507 cmd_ptype_mapping_get_parsed(
15508 void *parsed_result,
15509 __rte_unused struct cmdline *cl,
15510 __rte_unused void *data)
15512 struct cmd_ptype_mapping_get_result *res = parsed_result;
15513 int ret = -ENOTSUP;
15514 #ifdef RTE_NET_I40E
15515 int max_ptype_num = 256;
15516 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
15521 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15524 #ifdef RTE_NET_I40E
15525 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
15536 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15539 fprintf(stderr, "function not implemented\n");
15542 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15545 #ifdef RTE_NET_I40E
15547 for (i = 0; i < count; i++)
15548 printf("%3d\t0x%08x\n",
15549 mapping[i].hw_ptype, mapping[i].sw_ptype);
15554 cmdline_parse_inst_t cmd_ptype_mapping_get = {
15555 .f = cmd_ptype_mapping_get_parsed,
15557 .help_str = "ptype mapping get <port_id> <valid_only>",
15559 (void *)&cmd_ptype_mapping_get_ptype,
15560 (void *)&cmd_ptype_mapping_get_mapping,
15561 (void *)&cmd_ptype_mapping_get_get,
15562 (void *)&cmd_ptype_mapping_get_port_id,
15563 (void *)&cmd_ptype_mapping_get_valid_only,
15568 /* ptype mapping replace */
15570 /* Common result structure for ptype mapping replace */
15571 struct cmd_ptype_mapping_replace_result {
15572 cmdline_fixed_string_t ptype;
15573 cmdline_fixed_string_t mapping;
15574 cmdline_fixed_string_t replace;
15581 /* Common CLI fields for ptype mapping replace */
15582 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
15583 TOKEN_STRING_INITIALIZER
15584 (struct cmd_ptype_mapping_replace_result,
15586 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
15587 TOKEN_STRING_INITIALIZER
15588 (struct cmd_ptype_mapping_replace_result,
15589 mapping, "mapping");
15590 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
15591 TOKEN_STRING_INITIALIZER
15592 (struct cmd_ptype_mapping_replace_result,
15593 replace, "replace");
15594 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
15595 TOKEN_NUM_INITIALIZER
15596 (struct cmd_ptype_mapping_replace_result,
15597 port_id, RTE_UINT16);
15598 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
15599 TOKEN_NUM_INITIALIZER
15600 (struct cmd_ptype_mapping_replace_result,
15601 target, RTE_UINT32);
15602 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
15603 TOKEN_NUM_INITIALIZER
15604 (struct cmd_ptype_mapping_replace_result,
15606 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
15607 TOKEN_NUM_INITIALIZER
15608 (struct cmd_ptype_mapping_replace_result,
15609 pkt_type, RTE_UINT32);
15612 cmd_ptype_mapping_replace_parsed(
15613 void *parsed_result,
15614 __rte_unused struct cmdline *cl,
15615 __rte_unused void *data)
15617 struct cmd_ptype_mapping_replace_result *res = parsed_result;
15618 int ret = -ENOTSUP;
15620 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15623 #ifdef RTE_NET_I40E
15624 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
15634 fprintf(stderr, "invalid ptype 0x%8x or 0x%8x\n",
15635 res->target, res->pkt_type);
15638 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15641 fprintf(stderr, "function not implemented\n");
15644 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15648 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
15649 .f = cmd_ptype_mapping_replace_parsed,
15652 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
15654 (void *)&cmd_ptype_mapping_replace_ptype,
15655 (void *)&cmd_ptype_mapping_replace_mapping,
15656 (void *)&cmd_ptype_mapping_replace_replace,
15657 (void *)&cmd_ptype_mapping_replace_port_id,
15658 (void *)&cmd_ptype_mapping_replace_target,
15659 (void *)&cmd_ptype_mapping_replace_mask,
15660 (void *)&cmd_ptype_mapping_replace_pkt_type,
15665 /* ptype mapping reset */
15667 /* Common result structure for ptype mapping reset */
15668 struct cmd_ptype_mapping_reset_result {
15669 cmdline_fixed_string_t ptype;
15670 cmdline_fixed_string_t mapping;
15671 cmdline_fixed_string_t reset;
15675 /* Common CLI fields for ptype mapping reset*/
15676 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
15677 TOKEN_STRING_INITIALIZER
15678 (struct cmd_ptype_mapping_reset_result,
15680 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
15681 TOKEN_STRING_INITIALIZER
15682 (struct cmd_ptype_mapping_reset_result,
15683 mapping, "mapping");
15684 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
15685 TOKEN_STRING_INITIALIZER
15686 (struct cmd_ptype_mapping_reset_result,
15688 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
15689 TOKEN_NUM_INITIALIZER
15690 (struct cmd_ptype_mapping_reset_result,
15691 port_id, RTE_UINT16);
15694 cmd_ptype_mapping_reset_parsed(
15695 void *parsed_result,
15696 __rte_unused struct cmdline *cl,
15697 __rte_unused void *data)
15699 struct cmd_ptype_mapping_reset_result *res = parsed_result;
15700 int ret = -ENOTSUP;
15702 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15705 #ifdef RTE_NET_I40E
15706 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
15713 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15716 fprintf(stderr, "function not implemented\n");
15719 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15723 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
15724 .f = cmd_ptype_mapping_reset_parsed,
15726 .help_str = "ptype mapping reset <port_id>",
15728 (void *)&cmd_ptype_mapping_reset_ptype,
15729 (void *)&cmd_ptype_mapping_reset_mapping,
15730 (void *)&cmd_ptype_mapping_reset_reset,
15731 (void *)&cmd_ptype_mapping_reset_port_id,
15736 /* ptype mapping update */
15738 /* Common result structure for ptype mapping update */
15739 struct cmd_ptype_mapping_update_result {
15740 cmdline_fixed_string_t ptype;
15741 cmdline_fixed_string_t mapping;
15742 cmdline_fixed_string_t reset;
15748 /* Common CLI fields for ptype mapping update*/
15749 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
15750 TOKEN_STRING_INITIALIZER
15751 (struct cmd_ptype_mapping_update_result,
15753 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
15754 TOKEN_STRING_INITIALIZER
15755 (struct cmd_ptype_mapping_update_result,
15756 mapping, "mapping");
15757 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
15758 TOKEN_STRING_INITIALIZER
15759 (struct cmd_ptype_mapping_update_result,
15761 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
15762 TOKEN_NUM_INITIALIZER
15763 (struct cmd_ptype_mapping_update_result,
15764 port_id, RTE_UINT16);
15765 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
15766 TOKEN_NUM_INITIALIZER
15767 (struct cmd_ptype_mapping_update_result,
15768 hw_ptype, RTE_UINT8);
15769 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
15770 TOKEN_NUM_INITIALIZER
15771 (struct cmd_ptype_mapping_update_result,
15772 sw_ptype, RTE_UINT32);
15775 cmd_ptype_mapping_update_parsed(
15776 void *parsed_result,
15777 __rte_unused struct cmdline *cl,
15778 __rte_unused void *data)
15780 struct cmd_ptype_mapping_update_result *res = parsed_result;
15781 int ret = -ENOTSUP;
15782 #ifdef RTE_NET_I40E
15783 struct rte_pmd_i40e_ptype_mapping mapping;
15785 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15788 #ifdef RTE_NET_I40E
15789 mapping.hw_ptype = res->hw_ptype;
15790 mapping.sw_ptype = res->sw_ptype;
15791 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
15801 fprintf(stderr, "invalid ptype 0x%8x\n", res->sw_ptype);
15804 fprintf(stderr, "invalid port_id %d\n", res->port_id);
15807 fprintf(stderr, "function not implemented\n");
15810 fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
15814 cmdline_parse_inst_t cmd_ptype_mapping_update = {
15815 .f = cmd_ptype_mapping_update_parsed,
15817 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
15819 (void *)&cmd_ptype_mapping_update_ptype,
15820 (void *)&cmd_ptype_mapping_update_mapping,
15821 (void *)&cmd_ptype_mapping_update_update,
15822 (void *)&cmd_ptype_mapping_update_port_id,
15823 (void *)&cmd_ptype_mapping_update_hw_ptype,
15824 (void *)&cmd_ptype_mapping_update_sw_ptype,
15829 /* Common result structure for file commands */
15830 struct cmd_cmdfile_result {
15831 cmdline_fixed_string_t load;
15832 cmdline_fixed_string_t filename;
15835 /* Common CLI fields for file commands */
15836 cmdline_parse_token_string_t cmd_load_cmdfile =
15837 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
15838 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
15839 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
15842 cmd_load_from_file_parsed(
15843 void *parsed_result,
15844 __rte_unused struct cmdline *cl,
15845 __rte_unused void *data)
15847 struct cmd_cmdfile_result *res = parsed_result;
15849 cmdline_read_from_file(res->filename);
15852 cmdline_parse_inst_t cmd_load_from_file = {
15853 .f = cmd_load_from_file_parsed,
15855 .help_str = "load <filename>",
15857 (void *)&cmd_load_cmdfile,
15858 (void *)&cmd_load_cmdfile_filename,
15863 /* Get Rx offloads capabilities */
15864 struct cmd_rx_offload_get_capa_result {
15865 cmdline_fixed_string_t show;
15866 cmdline_fixed_string_t port;
15868 cmdline_fixed_string_t rx_offload;
15869 cmdline_fixed_string_t capabilities;
15872 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
15873 TOKEN_STRING_INITIALIZER
15874 (struct cmd_rx_offload_get_capa_result,
15876 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
15877 TOKEN_STRING_INITIALIZER
15878 (struct cmd_rx_offload_get_capa_result,
15880 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
15881 TOKEN_NUM_INITIALIZER
15882 (struct cmd_rx_offload_get_capa_result,
15883 port_id, RTE_UINT16);
15884 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
15885 TOKEN_STRING_INITIALIZER
15886 (struct cmd_rx_offload_get_capa_result,
15887 rx_offload, "rx_offload");
15888 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
15889 TOKEN_STRING_INITIALIZER
15890 (struct cmd_rx_offload_get_capa_result,
15891 capabilities, "capabilities");
15894 print_rx_offloads(uint64_t offloads)
15896 uint64_t single_offload;
15904 begin = __builtin_ctzll(offloads);
15905 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
15907 single_offload = 1ULL << begin;
15908 for (bit = begin; bit < end; bit++) {
15909 if (offloads & single_offload)
15911 rte_eth_dev_rx_offload_name(single_offload));
15912 single_offload <<= 1;
15917 cmd_rx_offload_get_capa_parsed(
15918 void *parsed_result,
15919 __rte_unused struct cmdline *cl,
15920 __rte_unused void *data)
15922 struct cmd_rx_offload_get_capa_result *res = parsed_result;
15923 struct rte_eth_dev_info dev_info;
15924 portid_t port_id = res->port_id;
15925 uint64_t queue_offloads;
15926 uint64_t port_offloads;
15929 ret = eth_dev_info_get_print_err(port_id, &dev_info);
15933 queue_offloads = dev_info.rx_queue_offload_capa;
15934 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
15936 printf("Rx Offloading Capabilities of port %d :\n", port_id);
15937 printf(" Per Queue :");
15938 print_rx_offloads(queue_offloads);
15941 printf(" Per Port :");
15942 print_rx_offloads(port_offloads);
15946 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
15947 .f = cmd_rx_offload_get_capa_parsed,
15949 .help_str = "show port <port_id> rx_offload capabilities",
15951 (void *)&cmd_rx_offload_get_capa_show,
15952 (void *)&cmd_rx_offload_get_capa_port,
15953 (void *)&cmd_rx_offload_get_capa_port_id,
15954 (void *)&cmd_rx_offload_get_capa_rx_offload,
15955 (void *)&cmd_rx_offload_get_capa_capabilities,
15960 /* Get Rx offloads configuration */
15961 struct cmd_rx_offload_get_configuration_result {
15962 cmdline_fixed_string_t show;
15963 cmdline_fixed_string_t port;
15965 cmdline_fixed_string_t rx_offload;
15966 cmdline_fixed_string_t configuration;
15969 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
15970 TOKEN_STRING_INITIALIZER
15971 (struct cmd_rx_offload_get_configuration_result,
15973 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
15974 TOKEN_STRING_INITIALIZER
15975 (struct cmd_rx_offload_get_configuration_result,
15977 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
15978 TOKEN_NUM_INITIALIZER
15979 (struct cmd_rx_offload_get_configuration_result,
15980 port_id, RTE_UINT16);
15981 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
15982 TOKEN_STRING_INITIALIZER
15983 (struct cmd_rx_offload_get_configuration_result,
15984 rx_offload, "rx_offload");
15985 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
15986 TOKEN_STRING_INITIALIZER
15987 (struct cmd_rx_offload_get_configuration_result,
15988 configuration, "configuration");
15991 cmd_rx_offload_get_configuration_parsed(
15992 void *parsed_result,
15993 __rte_unused struct cmdline *cl,
15994 __rte_unused void *data)
15996 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
15997 struct rte_eth_dev_info dev_info;
15998 portid_t port_id = res->port_id;
15999 struct rte_port *port = &ports[port_id];
16000 uint64_t port_offloads;
16001 uint64_t queue_offloads;
16002 uint16_t nb_rx_queues;
16006 printf("Rx Offloading Configuration of port %d :\n", port_id);
16008 port_offloads = port->dev_conf.rxmode.offloads;
16010 print_rx_offloads(port_offloads);
16013 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16017 nb_rx_queues = dev_info.nb_rx_queues;
16018 for (q = 0; q < nb_rx_queues; q++) {
16019 queue_offloads = port->rx_conf[q].offloads;
16020 printf(" Queue[%2d] :", q);
16021 print_rx_offloads(queue_offloads);
16027 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
16028 .f = cmd_rx_offload_get_configuration_parsed,
16030 .help_str = "show port <port_id> rx_offload configuration",
16032 (void *)&cmd_rx_offload_get_configuration_show,
16033 (void *)&cmd_rx_offload_get_configuration_port,
16034 (void *)&cmd_rx_offload_get_configuration_port_id,
16035 (void *)&cmd_rx_offload_get_configuration_rx_offload,
16036 (void *)&cmd_rx_offload_get_configuration_configuration,
16041 /* Enable/Disable a per port offloading */
16042 struct cmd_config_per_port_rx_offload_result {
16043 cmdline_fixed_string_t port;
16044 cmdline_fixed_string_t config;
16046 cmdline_fixed_string_t rx_offload;
16047 cmdline_fixed_string_t offload;
16048 cmdline_fixed_string_t on_off;
16051 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
16052 TOKEN_STRING_INITIALIZER
16053 (struct cmd_config_per_port_rx_offload_result,
16055 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
16056 TOKEN_STRING_INITIALIZER
16057 (struct cmd_config_per_port_rx_offload_result,
16059 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
16060 TOKEN_NUM_INITIALIZER
16061 (struct cmd_config_per_port_rx_offload_result,
16062 port_id, RTE_UINT16);
16063 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
16064 TOKEN_STRING_INITIALIZER
16065 (struct cmd_config_per_port_rx_offload_result,
16066 rx_offload, "rx_offload");
16067 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
16068 TOKEN_STRING_INITIALIZER
16069 (struct cmd_config_per_port_rx_offload_result,
16070 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16071 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16072 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16073 "scatter#buffer_split#timestamp#security#"
16074 "keep_crc#rss_hash");
16075 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
16076 TOKEN_STRING_INITIALIZER
16077 (struct cmd_config_per_port_rx_offload_result,
16081 search_rx_offload(const char *name)
16083 uint64_t single_offload;
16084 const char *single_name;
16088 single_offload = 1;
16089 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16090 single_name = rte_eth_dev_rx_offload_name(single_offload);
16091 if (!strcasecmp(single_name, name)) {
16095 single_offload <<= 1;
16099 return single_offload;
16105 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16106 __rte_unused struct cmdline *cl,
16107 __rte_unused void *data)
16109 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16110 portid_t port_id = res->port_id;
16111 struct rte_eth_dev_info dev_info;
16112 struct rte_port *port = &ports[port_id];
16113 uint64_t single_offload;
16114 uint16_t nb_rx_queues;
16118 if (port->port_status != RTE_PORT_STOPPED) {
16120 "Error: Can't config offload when Port %d is not stopped\n",
16125 single_offload = search_rx_offload(res->offload);
16126 if (single_offload == 0) {
16127 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16131 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16135 nb_rx_queues = dev_info.nb_rx_queues;
16136 if (!strcmp(res->on_off, "on")) {
16137 port->dev_conf.rxmode.offloads |= single_offload;
16138 for (q = 0; q < nb_rx_queues; q++)
16139 port->rx_conf[q].offloads |= single_offload;
16141 port->dev_conf.rxmode.offloads &= ~single_offload;
16142 for (q = 0; q < nb_rx_queues; q++)
16143 port->rx_conf[q].offloads &= ~single_offload;
16146 cmd_reconfig_device_queue(port_id, 1, 1);
16149 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16150 .f = cmd_config_per_port_rx_offload_parsed,
16152 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16153 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16154 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16155 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16156 "keep_crc|rss_hash on|off",
16158 (void *)&cmd_config_per_port_rx_offload_result_port,
16159 (void *)&cmd_config_per_port_rx_offload_result_config,
16160 (void *)&cmd_config_per_port_rx_offload_result_port_id,
16161 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16162 (void *)&cmd_config_per_port_rx_offload_result_offload,
16163 (void *)&cmd_config_per_port_rx_offload_result_on_off,
16168 /* Enable/Disable a per queue offloading */
16169 struct cmd_config_per_queue_rx_offload_result {
16170 cmdline_fixed_string_t port;
16172 cmdline_fixed_string_t rxq;
16174 cmdline_fixed_string_t rx_offload;
16175 cmdline_fixed_string_t offload;
16176 cmdline_fixed_string_t on_off;
16179 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16180 TOKEN_STRING_INITIALIZER
16181 (struct cmd_config_per_queue_rx_offload_result,
16183 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16184 TOKEN_NUM_INITIALIZER
16185 (struct cmd_config_per_queue_rx_offload_result,
16186 port_id, RTE_UINT16);
16187 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16188 TOKEN_STRING_INITIALIZER
16189 (struct cmd_config_per_queue_rx_offload_result,
16191 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16192 TOKEN_NUM_INITIALIZER
16193 (struct cmd_config_per_queue_rx_offload_result,
16194 queue_id, RTE_UINT16);
16195 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16196 TOKEN_STRING_INITIALIZER
16197 (struct cmd_config_per_queue_rx_offload_result,
16198 rx_offload, "rx_offload");
16199 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16200 TOKEN_STRING_INITIALIZER
16201 (struct cmd_config_per_queue_rx_offload_result,
16202 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16203 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16204 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16205 "scatter#buffer_split#timestamp#security#keep_crc");
16206 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16207 TOKEN_STRING_INITIALIZER
16208 (struct cmd_config_per_queue_rx_offload_result,
16212 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16213 __rte_unused struct cmdline *cl,
16214 __rte_unused void *data)
16216 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16217 struct rte_eth_dev_info dev_info;
16218 portid_t port_id = res->port_id;
16219 uint16_t queue_id = res->queue_id;
16220 struct rte_port *port = &ports[port_id];
16221 uint64_t single_offload;
16224 if (port->port_status != RTE_PORT_STOPPED) {
16226 "Error: Can't config offload when Port %d is not stopped\n",
16231 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16235 if (queue_id >= dev_info.nb_rx_queues) {
16237 "Error: input queue_id should be 0 ... %d\n",
16238 dev_info.nb_rx_queues - 1);
16242 single_offload = search_rx_offload(res->offload);
16243 if (single_offload == 0) {
16244 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16248 if (!strcmp(res->on_off, "on"))
16249 port->rx_conf[queue_id].offloads |= single_offload;
16251 port->rx_conf[queue_id].offloads &= ~single_offload;
16253 cmd_reconfig_device_queue(port_id, 1, 1);
16256 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16257 .f = cmd_config_per_queue_rx_offload_parsed,
16259 .help_str = "port <port_id> rxq <queue_id> rx_offload "
16260 "vlan_strip|ipv4_cksum|"
16261 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16262 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16263 "jumbo_frame|scatter|buffer_split|timestamp|security|"
16266 (void *)&cmd_config_per_queue_rx_offload_result_port,
16267 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
16268 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
16269 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16270 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16271 (void *)&cmd_config_per_queue_rx_offload_result_offload,
16272 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
16277 /* Get Tx offloads capabilities */
16278 struct cmd_tx_offload_get_capa_result {
16279 cmdline_fixed_string_t show;
16280 cmdline_fixed_string_t port;
16282 cmdline_fixed_string_t tx_offload;
16283 cmdline_fixed_string_t capabilities;
16286 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16287 TOKEN_STRING_INITIALIZER
16288 (struct cmd_tx_offload_get_capa_result,
16290 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16291 TOKEN_STRING_INITIALIZER
16292 (struct cmd_tx_offload_get_capa_result,
16294 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16295 TOKEN_NUM_INITIALIZER
16296 (struct cmd_tx_offload_get_capa_result,
16297 port_id, RTE_UINT16);
16298 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16299 TOKEN_STRING_INITIALIZER
16300 (struct cmd_tx_offload_get_capa_result,
16301 tx_offload, "tx_offload");
16302 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16303 TOKEN_STRING_INITIALIZER
16304 (struct cmd_tx_offload_get_capa_result,
16305 capabilities, "capabilities");
16308 print_tx_offloads(uint64_t offloads)
16310 uint64_t single_offload;
16318 begin = __builtin_ctzll(offloads);
16319 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16321 single_offload = 1ULL << begin;
16322 for (bit = begin; bit < end; bit++) {
16323 if (offloads & single_offload)
16325 rte_eth_dev_tx_offload_name(single_offload));
16326 single_offload <<= 1;
16331 cmd_tx_offload_get_capa_parsed(
16332 void *parsed_result,
16333 __rte_unused struct cmdline *cl,
16334 __rte_unused void *data)
16336 struct cmd_tx_offload_get_capa_result *res = parsed_result;
16337 struct rte_eth_dev_info dev_info;
16338 portid_t port_id = res->port_id;
16339 uint64_t queue_offloads;
16340 uint64_t port_offloads;
16343 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16347 queue_offloads = dev_info.tx_queue_offload_capa;
16348 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16350 printf("Tx Offloading Capabilities of port %d :\n", port_id);
16351 printf(" Per Queue :");
16352 print_tx_offloads(queue_offloads);
16355 printf(" Per Port :");
16356 print_tx_offloads(port_offloads);
16360 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16361 .f = cmd_tx_offload_get_capa_parsed,
16363 .help_str = "show port <port_id> tx_offload capabilities",
16365 (void *)&cmd_tx_offload_get_capa_show,
16366 (void *)&cmd_tx_offload_get_capa_port,
16367 (void *)&cmd_tx_offload_get_capa_port_id,
16368 (void *)&cmd_tx_offload_get_capa_tx_offload,
16369 (void *)&cmd_tx_offload_get_capa_capabilities,
16374 /* Get Tx offloads configuration */
16375 struct cmd_tx_offload_get_configuration_result {
16376 cmdline_fixed_string_t show;
16377 cmdline_fixed_string_t port;
16379 cmdline_fixed_string_t tx_offload;
16380 cmdline_fixed_string_t configuration;
16383 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16384 TOKEN_STRING_INITIALIZER
16385 (struct cmd_tx_offload_get_configuration_result,
16387 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16388 TOKEN_STRING_INITIALIZER
16389 (struct cmd_tx_offload_get_configuration_result,
16391 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16392 TOKEN_NUM_INITIALIZER
16393 (struct cmd_tx_offload_get_configuration_result,
16394 port_id, RTE_UINT16);
16395 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16396 TOKEN_STRING_INITIALIZER
16397 (struct cmd_tx_offload_get_configuration_result,
16398 tx_offload, "tx_offload");
16399 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16400 TOKEN_STRING_INITIALIZER
16401 (struct cmd_tx_offload_get_configuration_result,
16402 configuration, "configuration");
16405 cmd_tx_offload_get_configuration_parsed(
16406 void *parsed_result,
16407 __rte_unused struct cmdline *cl,
16408 __rte_unused void *data)
16410 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16411 struct rte_eth_dev_info dev_info;
16412 portid_t port_id = res->port_id;
16413 struct rte_port *port = &ports[port_id];
16414 uint64_t port_offloads;
16415 uint64_t queue_offloads;
16416 uint16_t nb_tx_queues;
16420 printf("Tx Offloading Configuration of port %d :\n", port_id);
16422 port_offloads = port->dev_conf.txmode.offloads;
16424 print_tx_offloads(port_offloads);
16427 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16431 nb_tx_queues = dev_info.nb_tx_queues;
16432 for (q = 0; q < nb_tx_queues; q++) {
16433 queue_offloads = port->tx_conf[q].offloads;
16434 printf(" Queue[%2d] :", q);
16435 print_tx_offloads(queue_offloads);
16441 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
16442 .f = cmd_tx_offload_get_configuration_parsed,
16444 .help_str = "show port <port_id> tx_offload configuration",
16446 (void *)&cmd_tx_offload_get_configuration_show,
16447 (void *)&cmd_tx_offload_get_configuration_port,
16448 (void *)&cmd_tx_offload_get_configuration_port_id,
16449 (void *)&cmd_tx_offload_get_configuration_tx_offload,
16450 (void *)&cmd_tx_offload_get_configuration_configuration,
16455 /* Enable/Disable a per port offloading */
16456 struct cmd_config_per_port_tx_offload_result {
16457 cmdline_fixed_string_t port;
16458 cmdline_fixed_string_t config;
16460 cmdline_fixed_string_t tx_offload;
16461 cmdline_fixed_string_t offload;
16462 cmdline_fixed_string_t on_off;
16465 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
16466 TOKEN_STRING_INITIALIZER
16467 (struct cmd_config_per_port_tx_offload_result,
16469 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
16470 TOKEN_STRING_INITIALIZER
16471 (struct cmd_config_per_port_tx_offload_result,
16473 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
16474 TOKEN_NUM_INITIALIZER
16475 (struct cmd_config_per_port_tx_offload_result,
16476 port_id, RTE_UINT16);
16477 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
16478 TOKEN_STRING_INITIALIZER
16479 (struct cmd_config_per_port_tx_offload_result,
16480 tx_offload, "tx_offload");
16481 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
16482 TOKEN_STRING_INITIALIZER
16483 (struct cmd_config_per_port_tx_offload_result,
16484 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16485 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16486 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16487 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16488 "mt_lockfree#multi_segs#mbuf_fast_free#security#"
16489 "send_on_timestamp");
16490 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
16491 TOKEN_STRING_INITIALIZER
16492 (struct cmd_config_per_port_tx_offload_result,
16496 search_tx_offload(const char *name)
16498 uint64_t single_offload;
16499 const char *single_name;
16503 single_offload = 1;
16504 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16505 single_name = rte_eth_dev_tx_offload_name(single_offload);
16506 if (single_name == NULL)
16508 if (!strcasecmp(single_name, name)) {
16511 } else if (!strcasecmp(single_name, "UNKNOWN"))
16513 single_offload <<= 1;
16517 return single_offload;
16523 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
16524 __rte_unused struct cmdline *cl,
16525 __rte_unused void *data)
16527 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
16528 portid_t port_id = res->port_id;
16529 struct rte_eth_dev_info dev_info;
16530 struct rte_port *port = &ports[port_id];
16531 uint64_t single_offload;
16532 uint16_t nb_tx_queues;
16536 if (port->port_status != RTE_PORT_STOPPED) {
16538 "Error: Can't config offload when Port %d is not stopped\n",
16543 single_offload = search_tx_offload(res->offload);
16544 if (single_offload == 0) {
16545 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16549 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16553 nb_tx_queues = dev_info.nb_tx_queues;
16554 if (!strcmp(res->on_off, "on")) {
16555 port->dev_conf.txmode.offloads |= single_offload;
16556 for (q = 0; q < nb_tx_queues; q++)
16557 port->tx_conf[q].offloads |= single_offload;
16559 port->dev_conf.txmode.offloads &= ~single_offload;
16560 for (q = 0; q < nb_tx_queues; q++)
16561 port->tx_conf[q].offloads &= ~single_offload;
16564 cmd_reconfig_device_queue(port_id, 1, 1);
16567 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
16568 .f = cmd_config_per_port_tx_offload_parsed,
16570 .help_str = "port config <port_id> tx_offload "
16571 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16572 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16573 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16574 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16575 "mt_lockfree|multi_segs|mbuf_fast_free|security|"
16576 "send_on_timestamp on|off",
16578 (void *)&cmd_config_per_port_tx_offload_result_port,
16579 (void *)&cmd_config_per_port_tx_offload_result_config,
16580 (void *)&cmd_config_per_port_tx_offload_result_port_id,
16581 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
16582 (void *)&cmd_config_per_port_tx_offload_result_offload,
16583 (void *)&cmd_config_per_port_tx_offload_result_on_off,
16588 /* Enable/Disable a per queue offloading */
16589 struct cmd_config_per_queue_tx_offload_result {
16590 cmdline_fixed_string_t port;
16592 cmdline_fixed_string_t txq;
16594 cmdline_fixed_string_t tx_offload;
16595 cmdline_fixed_string_t offload;
16596 cmdline_fixed_string_t on_off;
16599 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
16600 TOKEN_STRING_INITIALIZER
16601 (struct cmd_config_per_queue_tx_offload_result,
16603 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
16604 TOKEN_NUM_INITIALIZER
16605 (struct cmd_config_per_queue_tx_offload_result,
16606 port_id, RTE_UINT16);
16607 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
16608 TOKEN_STRING_INITIALIZER
16609 (struct cmd_config_per_queue_tx_offload_result,
16611 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
16612 TOKEN_NUM_INITIALIZER
16613 (struct cmd_config_per_queue_tx_offload_result,
16614 queue_id, RTE_UINT16);
16615 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
16616 TOKEN_STRING_INITIALIZER
16617 (struct cmd_config_per_queue_tx_offload_result,
16618 tx_offload, "tx_offload");
16619 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
16620 TOKEN_STRING_INITIALIZER
16621 (struct cmd_config_per_queue_tx_offload_result,
16622 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
16623 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
16624 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
16625 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
16626 "mt_lockfree#multi_segs#mbuf_fast_free#security");
16627 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
16628 TOKEN_STRING_INITIALIZER
16629 (struct cmd_config_per_queue_tx_offload_result,
16633 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
16634 __rte_unused struct cmdline *cl,
16635 __rte_unused void *data)
16637 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
16638 struct rte_eth_dev_info dev_info;
16639 portid_t port_id = res->port_id;
16640 uint16_t queue_id = res->queue_id;
16641 struct rte_port *port = &ports[port_id];
16642 uint64_t single_offload;
16645 if (port->port_status != RTE_PORT_STOPPED) {
16647 "Error: Can't config offload when Port %d is not stopped\n",
16652 ret = eth_dev_info_get_print_err(port_id, &dev_info);
16656 if (queue_id >= dev_info.nb_tx_queues) {
16658 "Error: input queue_id should be 0 ... %d\n",
16659 dev_info.nb_tx_queues - 1);
16663 single_offload = search_tx_offload(res->offload);
16664 if (single_offload == 0) {
16665 fprintf(stderr, "Unknown offload name: %s\n", res->offload);
16669 if (!strcmp(res->on_off, "on"))
16670 port->tx_conf[queue_id].offloads |= single_offload;
16672 port->tx_conf[queue_id].offloads &= ~single_offload;
16674 cmd_reconfig_device_queue(port_id, 1, 1);
16677 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
16678 .f = cmd_config_per_queue_tx_offload_parsed,
16680 .help_str = "port <port_id> txq <queue_id> tx_offload "
16681 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
16682 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
16683 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
16684 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
16685 "mt_lockfree|multi_segs|mbuf_fast_free|security "
16688 (void *)&cmd_config_per_queue_tx_offload_result_port,
16689 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
16690 (void *)&cmd_config_per_queue_tx_offload_result_txq,
16691 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
16692 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
16693 (void *)&cmd_config_per_queue_tx_offload_result_offload,
16694 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
16699 /* *** configure tx_metadata for specific port *** */
16700 struct cmd_config_tx_metadata_specific_result {
16701 cmdline_fixed_string_t port;
16702 cmdline_fixed_string_t keyword;
16704 cmdline_fixed_string_t item;
16709 cmd_config_tx_metadata_specific_parsed(void *parsed_result,
16710 __rte_unused struct cmdline *cl,
16711 __rte_unused void *data)
16713 struct cmd_config_tx_metadata_specific_result *res = parsed_result;
16715 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16717 ports[res->port_id].tx_metadata = res->value;
16718 /* Add/remove callback to insert valid metadata in every Tx packet. */
16719 if (ports[res->port_id].tx_metadata)
16720 add_tx_md_callback(res->port_id);
16722 remove_tx_md_callback(res->port_id);
16723 rte_flow_dynf_metadata_register();
16726 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
16727 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16729 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
16730 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16731 keyword, "config");
16732 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
16733 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16734 port_id, RTE_UINT16);
16735 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
16736 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16737 item, "tx_metadata");
16738 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
16739 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
16740 value, RTE_UINT32);
16742 cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
16743 .f = cmd_config_tx_metadata_specific_parsed,
16745 .help_str = "port config <port_id> tx_metadata <value>",
16747 (void *)&cmd_config_tx_metadata_specific_port,
16748 (void *)&cmd_config_tx_metadata_specific_keyword,
16749 (void *)&cmd_config_tx_metadata_specific_id,
16750 (void *)&cmd_config_tx_metadata_specific_item,
16751 (void *)&cmd_config_tx_metadata_specific_value,
16756 /* *** set dynf *** */
16757 struct cmd_config_tx_dynf_specific_result {
16758 cmdline_fixed_string_t port;
16759 cmdline_fixed_string_t keyword;
16761 cmdline_fixed_string_t item;
16762 cmdline_fixed_string_t name;
16763 cmdline_fixed_string_t value;
16767 cmd_config_dynf_specific_parsed(void *parsed_result,
16768 __rte_unused struct cmdline *cl,
16769 __rte_unused void *data)
16771 struct cmd_config_tx_dynf_specific_result *res = parsed_result;
16772 struct rte_mbuf_dynflag desc_flag;
16774 uint64_t old_port_flags;
16776 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16778 flag = rte_mbuf_dynflag_lookup(res->name, NULL);
16780 if (strlcpy(desc_flag.name, res->name,
16781 RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
16782 fprintf(stderr, "Flag name too long\n");
16785 desc_flag.flags = 0;
16786 flag = rte_mbuf_dynflag_register(&desc_flag);
16788 fprintf(stderr, "Can't register flag\n");
16791 strcpy(dynf_names[flag], desc_flag.name);
16793 old_port_flags = ports[res->port_id].mbuf_dynf;
16794 if (!strcmp(res->value, "set")) {
16795 ports[res->port_id].mbuf_dynf |= 1UL << flag;
16796 if (old_port_flags == 0)
16797 add_tx_dynf_callback(res->port_id);
16799 ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
16800 if (ports[res->port_id].mbuf_dynf == 0)
16801 remove_tx_dynf_callback(res->port_id);
16805 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
16806 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16808 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
16809 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16810 keyword, "config");
16811 cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
16812 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16813 port_id, RTE_UINT16);
16814 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
16815 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16817 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
16818 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16820 cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
16821 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
16822 value, "set#clear");
16824 cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
16825 .f = cmd_config_dynf_specific_parsed,
16827 .help_str = "port config <port id> dynf <name> set|clear",
16829 (void *)&cmd_config_tx_dynf_specific_port,
16830 (void *)&cmd_config_tx_dynf_specific_keyword,
16831 (void *)&cmd_config_tx_dynf_specific_port_id,
16832 (void *)&cmd_config_tx_dynf_specific_item,
16833 (void *)&cmd_config_tx_dynf_specific_name,
16834 (void *)&cmd_config_tx_dynf_specific_value,
16839 /* *** display tx_metadata per port configuration *** */
16840 struct cmd_show_tx_metadata_result {
16841 cmdline_fixed_string_t cmd_show;
16842 cmdline_fixed_string_t cmd_port;
16843 cmdline_fixed_string_t cmd_keyword;
16848 cmd_show_tx_metadata_parsed(void *parsed_result,
16849 __rte_unused struct cmdline *cl,
16850 __rte_unused void *data)
16852 struct cmd_show_tx_metadata_result *res = parsed_result;
16854 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16855 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
16858 if (!strcmp(res->cmd_keyword, "tx_metadata")) {
16859 printf("Port %u tx_metadata: %u\n", res->cmd_pid,
16860 ports[res->cmd_pid].tx_metadata);
16864 cmdline_parse_token_string_t cmd_show_tx_metadata_show =
16865 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16867 cmdline_parse_token_string_t cmd_show_tx_metadata_port =
16868 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16870 cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
16871 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
16872 cmd_pid, RTE_UINT16);
16873 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
16874 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
16875 cmd_keyword, "tx_metadata");
16877 cmdline_parse_inst_t cmd_show_tx_metadata = {
16878 .f = cmd_show_tx_metadata_parsed,
16880 .help_str = "show port <port_id> tx_metadata",
16882 (void *)&cmd_show_tx_metadata_show,
16883 (void *)&cmd_show_tx_metadata_port,
16884 (void *)&cmd_show_tx_metadata_pid,
16885 (void *)&cmd_show_tx_metadata_keyword,
16890 /* *** show fec capability per port configuration *** */
16891 struct cmd_show_fec_capability_result {
16892 cmdline_fixed_string_t cmd_show;
16893 cmdline_fixed_string_t cmd_port;
16894 cmdline_fixed_string_t cmd_fec;
16895 cmdline_fixed_string_t cmd_keyword;
16900 cmd_show_fec_capability_parsed(void *parsed_result,
16901 __rte_unused struct cmdline *cl,
16902 __rte_unused void *data)
16904 struct cmd_show_fec_capability_result *res = parsed_result;
16905 struct rte_eth_fec_capa *speed_fec_capa;
16909 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16910 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
16914 ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
16915 if (ret == -ENOTSUP) {
16916 fprintf(stderr, "Function not implemented\n");
16918 } else if (ret < 0) {
16919 fprintf(stderr, "Get FEC capability failed: %d\n", ret);
16923 num = (unsigned int)ret;
16924 speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
16925 if (speed_fec_capa == NULL) {
16926 fprintf(stderr, "Failed to alloc FEC capability buffer\n");
16930 ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
16932 fprintf(stderr, "Error getting FEC capability: %d\n", ret);
16936 show_fec_capability(num, speed_fec_capa);
16938 free(speed_fec_capa);
16941 cmdline_parse_token_string_t cmd_show_fec_capability_show =
16942 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16944 cmdline_parse_token_string_t cmd_show_fec_capability_port =
16945 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16947 cmdline_parse_token_num_t cmd_show_fec_capability_pid =
16948 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
16949 cmd_pid, RTE_UINT16);
16950 cmdline_parse_token_string_t cmd_show_fec_capability_fec =
16951 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16953 cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
16954 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
16955 cmd_keyword, "capabilities");
16957 cmdline_parse_inst_t cmd_show_capability = {
16958 .f = cmd_show_fec_capability_parsed,
16960 .help_str = "show port <port_id> fec capabilities",
16962 (void *)&cmd_show_fec_capability_show,
16963 (void *)&cmd_show_fec_capability_port,
16964 (void *)&cmd_show_fec_capability_pid,
16965 (void *)&cmd_show_fec_capability_fec,
16966 (void *)&cmd_show_fec_capability_keyword,
16971 /* *** show fec mode per port configuration *** */
16972 struct cmd_show_fec_metadata_result {
16973 cmdline_fixed_string_t cmd_show;
16974 cmdline_fixed_string_t cmd_port;
16975 cmdline_fixed_string_t cmd_keyword;
16980 cmd_show_fec_mode_parsed(void *parsed_result,
16981 __rte_unused struct cmdline *cl,
16982 __rte_unused void *data)
16984 #define FEC_NAME_SIZE 16
16985 struct cmd_show_fec_metadata_result *res = parsed_result;
16987 char buf[FEC_NAME_SIZE];
16990 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
16991 fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
16994 ret = rte_eth_fec_get(res->cmd_pid, &mode);
16995 if (ret == -ENOTSUP) {
16996 fprintf(stderr, "Function not implemented\n");
16998 } else if (ret < 0) {
16999 fprintf(stderr, "Get FEC mode failed\n");
17004 case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
17005 strlcpy(buf, "off", sizeof(buf));
17007 case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
17008 strlcpy(buf, "auto", sizeof(buf));
17010 case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
17011 strlcpy(buf, "baser", sizeof(buf));
17013 case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
17014 strlcpy(buf, "rs", sizeof(buf));
17020 printf("%s\n", buf);
17023 cmdline_parse_token_string_t cmd_show_fec_mode_show =
17024 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17026 cmdline_parse_token_string_t cmd_show_fec_mode_port =
17027 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17029 cmdline_parse_token_num_t cmd_show_fec_mode_pid =
17030 TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
17031 cmd_pid, RTE_UINT16);
17032 cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
17033 TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
17034 cmd_keyword, "fec_mode");
17036 cmdline_parse_inst_t cmd_show_fec_mode = {
17037 .f = cmd_show_fec_mode_parsed,
17039 .help_str = "show port <port_id> fec_mode",
17041 (void *)&cmd_show_fec_mode_show,
17042 (void *)&cmd_show_fec_mode_port,
17043 (void *)&cmd_show_fec_mode_pid,
17044 (void *)&cmd_show_fec_mode_keyword,
17049 /* *** set fec mode per port configuration *** */
17050 struct cmd_set_port_fec_mode {
17051 cmdline_fixed_string_t set;
17052 cmdline_fixed_string_t port;
17054 cmdline_fixed_string_t fec_mode;
17055 cmdline_fixed_string_t fec_value;
17058 /* Common CLI fields for set fec mode */
17059 cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
17060 TOKEN_STRING_INITIALIZER
17061 (struct cmd_set_port_fec_mode,
17063 cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
17064 TOKEN_STRING_INITIALIZER
17065 (struct cmd_set_port_fec_mode,
17067 cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
17068 TOKEN_NUM_INITIALIZER
17069 (struct cmd_set_port_fec_mode,
17070 port_id, RTE_UINT16);
17071 cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
17072 TOKEN_STRING_INITIALIZER
17073 (struct cmd_set_port_fec_mode,
17074 fec_mode, "fec_mode");
17075 cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
17076 TOKEN_STRING_INITIALIZER
17077 (struct cmd_set_port_fec_mode,
17081 cmd_set_port_fec_mode_parsed(
17082 void *parsed_result,
17083 __rte_unused struct cmdline *cl,
17084 __rte_unused void *data)
17086 struct cmd_set_port_fec_mode *res = parsed_result;
17087 uint16_t port_id = res->port_id;
17091 ret = parse_fec_mode(res->fec_value, &fec_capa);
17093 fprintf(stderr, "Unknown fec mode: %s for port %d\n",
17094 res->fec_value, port_id);
17098 ret = rte_eth_fec_set(port_id, fec_capa);
17099 if (ret == -ENOTSUP) {
17100 fprintf(stderr, "Function not implemented\n");
17102 } else if (ret < 0) {
17103 fprintf(stderr, "Set FEC mode failed\n");
17108 cmdline_parse_inst_t cmd_set_fec_mode = {
17109 .f = cmd_set_port_fec_mode_parsed,
17111 .help_str = "set port <port_id> fec_mode auto|off|rs|baser",
17113 (void *)&cmd_set_port_fec_mode_set,
17114 (void *)&cmd_set_port_fec_mode_port,
17115 (void *)&cmd_set_port_fec_mode_port_id,
17116 (void *)&cmd_set_port_fec_mode_str,
17117 (void *)&cmd_set_port_fec_mode_value,
17122 /* show port supported ptypes */
17124 /* Common result structure for show port ptypes */
17125 struct cmd_show_port_supported_ptypes_result {
17126 cmdline_fixed_string_t show;
17127 cmdline_fixed_string_t port;
17129 cmdline_fixed_string_t ptypes;
17132 /* Common CLI fields for show port ptypes */
17133 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
17134 TOKEN_STRING_INITIALIZER
17135 (struct cmd_show_port_supported_ptypes_result,
17137 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
17138 TOKEN_STRING_INITIALIZER
17139 (struct cmd_show_port_supported_ptypes_result,
17141 cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
17142 TOKEN_NUM_INITIALIZER
17143 (struct cmd_show_port_supported_ptypes_result,
17144 port_id, RTE_UINT16);
17145 cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
17146 TOKEN_STRING_INITIALIZER
17147 (struct cmd_show_port_supported_ptypes_result,
17151 cmd_show_port_supported_ptypes_parsed(
17152 void *parsed_result,
17153 __rte_unused struct cmdline *cl,
17154 __rte_unused void *data)
17156 #define RSVD_PTYPE_MASK 0xf0000000
17157 #define MAX_PTYPES_PER_LAYER 16
17158 #define LTYPE_NAMESIZE 32
17159 #define PTYPE_NAMESIZE 256
17160 struct cmd_show_port_supported_ptypes_result *res = parsed_result;
17161 char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
17162 uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
17163 uint32_t ptypes[MAX_PTYPES_PER_LAYER];
17164 uint16_t port_id = res->port_id;
17167 ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
17171 while (ptype_mask != RSVD_PTYPE_MASK) {
17173 switch (ptype_mask) {
17174 case RTE_PTYPE_L2_MASK:
17175 strlcpy(ltype, "L2", sizeof(ltype));
17177 case RTE_PTYPE_L3_MASK:
17178 strlcpy(ltype, "L3", sizeof(ltype));
17180 case RTE_PTYPE_L4_MASK:
17181 strlcpy(ltype, "L4", sizeof(ltype));
17183 case RTE_PTYPE_TUNNEL_MASK:
17184 strlcpy(ltype, "Tunnel", sizeof(ltype));
17186 case RTE_PTYPE_INNER_L2_MASK:
17187 strlcpy(ltype, "Inner L2", sizeof(ltype));
17189 case RTE_PTYPE_INNER_L3_MASK:
17190 strlcpy(ltype, "Inner L3", sizeof(ltype));
17192 case RTE_PTYPE_INNER_L4_MASK:
17193 strlcpy(ltype, "Inner L4", sizeof(ltype));
17199 ret = rte_eth_dev_get_supported_ptypes(res->port_id,
17200 ptype_mask, ptypes,
17201 MAX_PTYPES_PER_LAYER);
17204 printf("Supported %s ptypes:\n", ltype);
17206 printf("%s ptypes unsupported\n", ltype);
17208 for (i = 0; i < ret; ++i) {
17209 rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
17210 printf("%s\n", buf);
17217 cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
17218 .f = cmd_show_port_supported_ptypes_parsed,
17220 .help_str = "show port <port_id> ptypes",
17222 (void *)&cmd_show_port_supported_ptypes_show,
17223 (void *)&cmd_show_port_supported_ptypes_port,
17224 (void *)&cmd_show_port_supported_ptypes_port_id,
17225 (void *)&cmd_show_port_supported_ptypes_ptypes,
17230 /* *** display rx/tx descriptor status *** */
17231 struct cmd_show_rx_tx_desc_status_result {
17232 cmdline_fixed_string_t cmd_show;
17233 cmdline_fixed_string_t cmd_port;
17234 cmdline_fixed_string_t cmd_keyword;
17235 cmdline_fixed_string_t cmd_desc;
17236 cmdline_fixed_string_t cmd_status;
17243 cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
17244 __rte_unused struct cmdline *cl,
17245 __rte_unused void *data)
17247 struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
17250 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17251 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17255 if (!strcmp(res->cmd_keyword, "rxq")) {
17256 rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
17260 "Invalid input: queue id = %d, desc id = %d\n",
17261 res->cmd_qid, res->cmd_did);
17264 if (rc == RTE_ETH_RX_DESC_AVAIL)
17265 printf("Desc status = AVAILABLE\n");
17266 else if (rc == RTE_ETH_RX_DESC_DONE)
17267 printf("Desc status = DONE\n");
17269 printf("Desc status = UNAVAILABLE\n");
17270 } else if (!strcmp(res->cmd_keyword, "txq")) {
17271 rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
17275 "Invalid input: queue id = %d, desc id = %d\n",
17276 res->cmd_qid, res->cmd_did);
17279 if (rc == RTE_ETH_TX_DESC_FULL)
17280 printf("Desc status = FULL\n");
17281 else if (rc == RTE_ETH_TX_DESC_DONE)
17282 printf("Desc status = DONE\n");
17284 printf("Desc status = UNAVAILABLE\n");
17288 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
17289 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17291 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
17292 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17294 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
17295 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17296 cmd_pid, RTE_UINT16);
17297 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
17298 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17299 cmd_keyword, "rxq#txq");
17300 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
17301 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17302 cmd_qid, RTE_UINT16);
17303 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
17304 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17306 cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
17307 TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17308 cmd_did, RTE_UINT16);
17309 cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
17310 TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
17311 cmd_status, "status");
17312 cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
17313 .f = cmd_show_rx_tx_desc_status_parsed,
17315 .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
17318 (void *)&cmd_show_rx_tx_desc_status_show,
17319 (void *)&cmd_show_rx_tx_desc_status_port,
17320 (void *)&cmd_show_rx_tx_desc_status_pid,
17321 (void *)&cmd_show_rx_tx_desc_status_keyword,
17322 (void *)&cmd_show_rx_tx_desc_status_qid,
17323 (void *)&cmd_show_rx_tx_desc_status_desc,
17324 (void *)&cmd_show_rx_tx_desc_status_did,
17325 (void *)&cmd_show_rx_tx_desc_status_status,
17330 /* *** display rx queue desc used count *** */
17331 struct cmd_show_rx_queue_desc_used_count_result {
17332 cmdline_fixed_string_t cmd_show;
17333 cmdline_fixed_string_t cmd_port;
17334 cmdline_fixed_string_t cmd_rxq;
17335 cmdline_fixed_string_t cmd_desc;
17336 cmdline_fixed_string_t cmd_used;
17337 cmdline_fixed_string_t cmd_count;
17343 cmd_show_rx_queue_desc_used_count_parsed(void *parsed_result,
17344 __rte_unused struct cmdline *cl,
17345 __rte_unused void *data)
17347 struct cmd_show_rx_queue_desc_used_count_result *res = parsed_result;
17350 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
17351 fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
17355 rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
17357 fprintf(stderr, "Invalid queueid = %d\n", res->cmd_qid);
17360 printf("Used desc count = %d\n", rc);
17363 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_show =
17364 TOKEN_STRING_INITIALIZER
17365 (struct cmd_show_rx_queue_desc_used_count_result,
17367 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_port =
17368 TOKEN_STRING_INITIALIZER
17369 (struct cmd_show_rx_queue_desc_used_count_result,
17371 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_pid =
17372 TOKEN_NUM_INITIALIZER
17373 (struct cmd_show_rx_queue_desc_used_count_result,
17374 cmd_pid, RTE_UINT16);
17375 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_rxq =
17376 TOKEN_STRING_INITIALIZER
17377 (struct cmd_show_rx_queue_desc_used_count_result,
17379 cmdline_parse_token_num_t cmd_show_rx_queue_desc_used_count_qid =
17380 TOKEN_NUM_INITIALIZER
17381 (struct cmd_show_rx_queue_desc_used_count_result,
17382 cmd_qid, RTE_UINT16);
17383 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_desc =
17384 TOKEN_STRING_INITIALIZER
17385 (struct cmd_show_rx_queue_desc_used_count_result,
17386 cmd_count, "desc");
17387 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_used =
17388 TOKEN_STRING_INITIALIZER
17389 (struct cmd_show_rx_queue_desc_used_count_result,
17390 cmd_count, "used");
17391 cmdline_parse_token_string_t cmd_show_rx_queue_desc_used_count_count =
17392 TOKEN_STRING_INITIALIZER
17393 (struct cmd_show_rx_queue_desc_used_count_result,
17394 cmd_count, "count");
17395 cmdline_parse_inst_t cmd_show_rx_queue_desc_used_count = {
17396 .f = cmd_show_rx_queue_desc_used_count_parsed,
17398 .help_str = "show port <port_id> rxq <queue_id> desc used count",
17400 (void *)&cmd_show_rx_queue_desc_used_count_show,
17401 (void *)&cmd_show_rx_queue_desc_used_count_port,
17402 (void *)&cmd_show_rx_queue_desc_used_count_pid,
17403 (void *)&cmd_show_rx_queue_desc_used_count_rxq,
17404 (void *)&cmd_show_rx_queue_desc_used_count_qid,
17405 (void *)&cmd_show_rx_queue_desc_used_count_desc,
17406 (void *)&cmd_show_rx_queue_desc_used_count_used,
17407 (void *)&cmd_show_rx_queue_desc_used_count_count,
17412 /* Common result structure for set port ptypes */
17413 struct cmd_set_port_ptypes_result {
17414 cmdline_fixed_string_t set;
17415 cmdline_fixed_string_t port;
17417 cmdline_fixed_string_t ptype_mask;
17421 /* Common CLI fields for set port ptypes */
17422 cmdline_parse_token_string_t cmd_set_port_ptypes_set =
17423 TOKEN_STRING_INITIALIZER
17424 (struct cmd_set_port_ptypes_result,
17426 cmdline_parse_token_string_t cmd_set_port_ptypes_port =
17427 TOKEN_STRING_INITIALIZER
17428 (struct cmd_set_port_ptypes_result,
17430 cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
17431 TOKEN_NUM_INITIALIZER
17432 (struct cmd_set_port_ptypes_result,
17433 port_id, RTE_UINT16);
17434 cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
17435 TOKEN_STRING_INITIALIZER
17436 (struct cmd_set_port_ptypes_result,
17437 ptype_mask, "ptype_mask");
17438 cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
17439 TOKEN_NUM_INITIALIZER
17440 (struct cmd_set_port_ptypes_result,
17444 cmd_set_port_ptypes_parsed(
17445 void *parsed_result,
17446 __rte_unused struct cmdline *cl,
17447 __rte_unused void *data)
17449 struct cmd_set_port_ptypes_result *res = parsed_result;
17450 #define PTYPE_NAMESIZE 256
17451 char ptype_name[PTYPE_NAMESIZE];
17452 uint16_t port_id = res->port_id;
17453 uint32_t ptype_mask = res->mask;
17456 ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
17459 fprintf(stderr, "Port %d doesn't support any ptypes.\n",
17464 uint32_t ptypes[ret];
17466 ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
17468 fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
17473 printf("Successfully set following ptypes for Port %d\n", port_id);
17474 for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
17475 rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
17476 printf("%s\n", ptype_name);
17479 clear_ptypes = false;
17482 cmdline_parse_inst_t cmd_set_port_ptypes = {
17483 .f = cmd_set_port_ptypes_parsed,
17485 .help_str = "set port <port_id> ptype_mask <mask>",
17487 (void *)&cmd_set_port_ptypes_set,
17488 (void *)&cmd_set_port_ptypes_port,
17489 (void *)&cmd_set_port_ptypes_port_id,
17490 (void *)&cmd_set_port_ptypes_mask_str,
17491 (void *)&cmd_set_port_ptypes_mask_u32,
17496 /* *** display mac addresses added to a port *** */
17497 struct cmd_showport_macs_result {
17498 cmdline_fixed_string_t cmd_show;
17499 cmdline_fixed_string_t cmd_port;
17500 cmdline_fixed_string_t cmd_keyword;
17505 cmd_showport_macs_parsed(void *parsed_result,
17506 __rte_unused struct cmdline *cl,
17507 __rte_unused void *data)
17509 struct cmd_showport_macs_result *res = parsed_result;
17511 if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
17514 if (!strcmp(res->cmd_keyword, "macs"))
17515 show_macs(res->cmd_pid);
17516 else if (!strcmp(res->cmd_keyword, "mcast_macs"))
17517 show_mcast_macs(res->cmd_pid);
17520 cmdline_parse_token_string_t cmd_showport_macs_show =
17521 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17523 cmdline_parse_token_string_t cmd_showport_macs_port =
17524 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17526 cmdline_parse_token_num_t cmd_showport_macs_pid =
17527 TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
17528 cmd_pid, RTE_UINT16);
17529 cmdline_parse_token_string_t cmd_showport_macs_keyword =
17530 TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
17531 cmd_keyword, "macs#mcast_macs");
17533 cmdline_parse_inst_t cmd_showport_macs = {
17534 .f = cmd_showport_macs_parsed,
17536 .help_str = "show port <port_id> macs|mcast_macs",
17538 (void *)&cmd_showport_macs_show,
17539 (void *)&cmd_showport_macs_port,
17540 (void *)&cmd_showport_macs_pid,
17541 (void *)&cmd_showport_macs_keyword,
17546 /* ******************************************************************************** */
17548 /* list of instructions */
17549 cmdline_parse_ctx_t main_ctx[] = {
17550 (cmdline_parse_inst_t *)&cmd_help_brief,
17551 (cmdline_parse_inst_t *)&cmd_help_long,
17552 (cmdline_parse_inst_t *)&cmd_quit,
17553 (cmdline_parse_inst_t *)&cmd_load_from_file,
17554 (cmdline_parse_inst_t *)&cmd_showport,
17555 (cmdline_parse_inst_t *)&cmd_showqueue,
17556 (cmdline_parse_inst_t *)&cmd_showeeprom,
17557 (cmdline_parse_inst_t *)&cmd_showportall,
17558 (cmdline_parse_inst_t *)&cmd_showdevice,
17559 (cmdline_parse_inst_t *)&cmd_showcfg,
17560 (cmdline_parse_inst_t *)&cmd_showfwdall,
17561 (cmdline_parse_inst_t *)&cmd_start,
17562 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17563 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17564 (cmdline_parse_inst_t *)&cmd_set_link_up,
17565 (cmdline_parse_inst_t *)&cmd_set_link_down,
17566 (cmdline_parse_inst_t *)&cmd_reset,
17567 (cmdline_parse_inst_t *)&cmd_set_numbers,
17568 (cmdline_parse_inst_t *)&cmd_set_log,
17569 (cmdline_parse_inst_t *)&cmd_set_rxoffs,
17570 (cmdline_parse_inst_t *)&cmd_set_rxpkts,
17571 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17572 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17573 (cmdline_parse_inst_t *)&cmd_set_txtimes,
17574 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17575 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17576 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17577 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17578 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17579 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17580 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17581 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17582 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17583 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17584 (cmdline_parse_inst_t *)&cmd_set_link_check,
17585 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17586 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17587 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17588 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17589 #ifdef RTE_NET_BOND
17590 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17591 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17592 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17593 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17594 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17595 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17596 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17597 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17598 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17599 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17600 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17602 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17603 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17604 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17605 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17606 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17607 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17608 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17609 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17610 (cmdline_parse_inst_t *)&cmd_csum_set,
17611 (cmdline_parse_inst_t *)&cmd_csum_show,
17612 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17613 (cmdline_parse_inst_t *)&cmd_tso_set,
17614 (cmdline_parse_inst_t *)&cmd_tso_show,
17615 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17616 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17617 (cmdline_parse_inst_t *)&cmd_gro_enable,
17618 (cmdline_parse_inst_t *)&cmd_gro_flush,
17619 (cmdline_parse_inst_t *)&cmd_gro_show,
17620 (cmdline_parse_inst_t *)&cmd_gso_enable,
17621 (cmdline_parse_inst_t *)&cmd_gso_size,
17622 (cmdline_parse_inst_t *)&cmd_gso_show,
17623 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17624 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17625 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17626 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17627 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17628 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17629 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17630 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17631 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17632 (cmdline_parse_inst_t *)&cmd_link_flow_control_show,
17633 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17634 (cmdline_parse_inst_t *)&cmd_config_dcb,
17635 (cmdline_parse_inst_t *)&cmd_read_reg,
17636 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17637 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17638 (cmdline_parse_inst_t *)&cmd_write_reg,
17639 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17640 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17641 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17642 (cmdline_parse_inst_t *)&cmd_stop,
17643 (cmdline_parse_inst_t *)&cmd_mac_addr,
17644 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17645 (cmdline_parse_inst_t *)&cmd_set_qmap,
17646 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17647 (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
17648 (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
17649 (cmdline_parse_inst_t *)&cmd_operate_port,
17650 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17651 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17652 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17653 (cmdline_parse_inst_t *)&cmd_operate_detach_device,
17654 (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
17655 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17656 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17657 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17658 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17659 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17660 (cmdline_parse_inst_t *)&cmd_config_mtu,
17661 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17662 (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
17663 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17664 (cmdline_parse_inst_t *)&cmd_config_rss,
17665 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17666 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17667 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
17668 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17669 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17670 (cmdline_parse_inst_t *)&cmd_showport_reta,
17671 (cmdline_parse_inst_t *)&cmd_showport_macs,
17672 (cmdline_parse_inst_t *)&cmd_config_burst,
17673 (cmdline_parse_inst_t *)&cmd_config_thresh,
17674 (cmdline_parse_inst_t *)&cmd_config_threshold,
17675 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17676 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17677 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17678 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17679 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17680 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
17681 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
17682 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
17683 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17684 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17685 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17686 (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
17687 (cmdline_parse_inst_t *)&cmd_dump,
17688 (cmdline_parse_inst_t *)&cmd_dump_one,
17689 #ifdef RTE_NET_I40E
17690 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17692 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17693 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17694 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17695 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17696 (cmdline_parse_inst_t *)&cmd_flow,
17697 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17698 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17699 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17700 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17701 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17702 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17703 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17704 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17705 (cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
17706 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17707 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17708 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17709 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17710 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17711 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17712 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17713 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17714 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17715 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17716 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17717 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17718 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17719 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17720 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17721 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17722 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17723 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17724 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17725 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17726 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17727 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17728 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17729 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17730 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17731 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17732 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17733 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17734 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
17735 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
17736 (cmdline_parse_inst_t *)&cmd_set_vxlan,
17737 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
17738 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17739 (cmdline_parse_inst_t *)&cmd_set_nvgre,
17740 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17741 (cmdline_parse_inst_t *)&cmd_set_l2_encap,
17742 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
17743 (cmdline_parse_inst_t *)&cmd_set_l2_decap,
17744 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
17745 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
17746 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
17747 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
17748 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
17749 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
17750 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
17751 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
17752 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
17753 (cmdline_parse_inst_t *)&cmd_set_conntrack_common,
17754 (cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
17755 (cmdline_parse_inst_t *)&cmd_ddp_add,
17756 (cmdline_parse_inst_t *)&cmd_ddp_del,
17757 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
17758 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
17759 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
17760 (cmdline_parse_inst_t *)&cmd_clear_input_set,
17761 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
17762 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17763 (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
17764 (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
17765 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17766 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17767 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17768 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17770 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17771 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17772 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17773 (cmdline_parse_inst_t *)&cmd_queue_region,
17774 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17775 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17776 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17777 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17778 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17779 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17780 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17781 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17782 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17783 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17784 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17785 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17786 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17787 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17788 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17789 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17790 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17791 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
17792 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17793 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17794 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17795 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17796 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17797 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17798 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
17799 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
17800 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
17801 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17802 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17803 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17804 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17805 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17806 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17807 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17808 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17809 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17811 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17812 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17814 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
17815 (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
17816 (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
17817 (cmdline_parse_inst_t *)&cmd_show_rx_queue_desc_used_count,
17818 (cmdline_parse_inst_t *)&cmd_set_raw,
17819 (cmdline_parse_inst_t *)&cmd_show_set_raw,
17820 (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
17821 (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
17822 (cmdline_parse_inst_t *)&cmd_show_fec_mode,
17823 (cmdline_parse_inst_t *)&cmd_set_fec_mode,
17824 (cmdline_parse_inst_t *)&cmd_show_capability,
17828 /* read cmdline commands from file */
17830 cmdline_read_from_file(const char *filename)
17832 struct cmdline *cl;
17834 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17837 "Failed to create file based cmdline context: %s\n",
17842 cmdline_interact(cl);
17847 printf("Read CLI commands from %s\n", filename);
17850 /* prompt function, called from main on MAIN lcore */
17855 /* initialize non-constant commands */
17856 cmd_set_fwd_mode_init();
17857 cmd_set_fwd_retry_mode_init();
17859 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17860 if (testpmd_cl == NULL)
17863 ret = atexit(prompt_exit);
17865 fprintf(stderr, "Cannot set exit function for cmdline\n");
17867 cmdline_interact(testpmd_cl);
17869 cmdline_stdin_exit(testpmd_cl);
17875 if (testpmd_cl != NULL) {
17876 cmdline_quit(testpmd_cl);
17877 cmdline_stdin_exit(testpmd_cl);
17882 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17884 if (id == (portid_t)RTE_PORT_ALL) {
17887 RTE_ETH_FOREACH_DEV(pid) {
17888 /* check if need_reconfig has been set to 1 */
17889 if (ports[pid].need_reconfig == 0)
17890 ports[pid].need_reconfig = dev;
17891 /* check if need_reconfig_queues has been set to 1 */
17892 if (ports[pid].need_reconfig_queues == 0)
17893 ports[pid].need_reconfig_queues = queue;
17895 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17896 /* check if need_reconfig has been set to 1 */
17897 if (ports[id].need_reconfig == 0)
17898 ports[id].need_reconfig = dev;
17899 /* check if need_reconfig_queues has been set to 1 */
17900 if (ports[id].need_reconfig_queues == 0)
17901 ports[id].need_reconfig_queues = queue;